Skip to content

Commit

Permalink
refactor: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4007 committed Oct 22, 2024
1 parent 4e0acca commit 0c02394
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 47 deletions.
31 changes: 26 additions & 5 deletions .cspell.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
{
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
"version": "0.2",
"ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log"],
"ignorePaths": [
"**/*.json",
"**/*.css",
"node_modules",
"**/*.log"
],
"useGitignore": true,
"language": "en",
"words": ["dataurl", "devpool", "outdir", "servedir"],
"dictionaries": ["typescript", "node", "software-terms"],
"import": ["@cspell/dict-typescript/cspell-ext.json", "@cspell/dict-node/cspell-ext.json", "@cspell/dict-software-terms"],
"ignoreRegExpList": ["[0-9a-fA-F]{6}"]
"words": [
"dataurl",
"devpool",
"outdir",
"servedir",
"SUPABASE"
],
"dictionaries": [
"typescript",
"node",
"software-terms"
],
"import": [
"@cspell/dict-typescript/cspell-ext.json",
"@cspell/dict-node/cspell-ext.json",
"@cspell/dict-software-terms"
],
"ignoreRegExpList": [
"[0-9a-fA-F]{6}"
]
}
9 changes: 0 additions & 9 deletions fixtures/manifest.min.json

This file was deleted.

7 changes: 4 additions & 3 deletions static/script/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY);

const controlsContainer = document.getElementById("controls") as HTMLElement;

function renderErrorInModal(error: Error, info?: string) {
function renderErrorInConsole(error: Error, info?: string) {
if (info) {
console.error(error);
} else {
Expand All @@ -32,7 +32,7 @@ async function gitHubLoginButtonHandler(scopes = "public_repo read:org") {
},
});
if (error) {
renderErrorInModal(error, "Error logging in");
renderErrorInConsole(error, "Error logging in");
}
}

Expand Down Expand Up @@ -64,7 +64,7 @@ async function renderGitHubUserInformation(gitHubUser: UserMetadata) {
authButton.addEventListener("click", async function signOut() {
const { error } = await supabase.auth.signOut();
if (error) {
renderErrorInModal(error, "Error logging out");
renderErrorInConsole(error, "Error logging out");
}
window.location.reload();
});
Expand All @@ -85,6 +85,7 @@ async function renderGitHubUserInformation(gitHubUser: UserMetadata) {
if (user.user_metadata) {
await renderGitHubUserInformation(user.user_metadata);
}
console.trace(user);
})().catch(() => {
console.log("[ERROR] Auth module");
});
1 change: 0 additions & 1 deletion static/script/decode-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
if (!encodedManifestEnvelope) {
throw new Error("No encoded manifest found!");
}
console.log(encodedManifestEnvelope);
const encodedManifest = encodedManifestEnvelope["manifest"];
const decodedManifest = decodeURI(encodedManifest);
// const decodedManifest = encodedManifest;
Expand Down
53 changes: 24 additions & 29 deletions static/script/render-manifest.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
const manifestGui = document.querySelector(`#manifest-gui`);
const manifestGuiBody = document.querySelector(`#manifest-gui-body`);
const manifestGui = document.querySelector(`#manifest-gui`) as HTMLElement | null;
const manifestGuiBody = document.querySelector(`#manifest-gui-body`) as HTMLElement | null;
import Manifest from "../../fixtures/manifest.json";
type DecodedManifest = typeof Manifest;

(function renderManifest() {
manifestGui?.classList.add("rendering");
const decodedManifest = window.decodedManifest;
const decodedManifest = window.decodedManifest as DecodedManifest;

if (!decodedManifest || !manifestGuiBody) {
console.error("Missing required elements");
return;
}

const dfg = document.createDocumentFragment();
const _div = document.createElement("DIV");
const _div = document.createElement("div");
const _nestedObject = document.createElement("pre");
// const _h3 = document.createElement("h3");

/**
* name": "Start | Stop",
description": "Assign or un-assign yourself from an issue.",
ubiquity:listeners": [
commands": {
*/

console.trace(decodedManifest);
const decodedManifestKeys = Object.keys(decodedManifest);
let x = -1;
const limit = decodedManifestKeys.length;
// const buffer = [];
const _tableRow = document.createElement("tr");
const _tableDataHeader = document.createElement("td");
_tableDataHeader.className = "table-data-header";
Expand All @@ -30,16 +26,14 @@ const manifestGuiBody = document.querySelector(`#manifest-gui-body`);
_tableRow.appendChild(_tableDataHeader);
_tableRow.appendChild(_tableDataValue);

console.trace(_tableRow);

while (++x < limit) {
const tableRow = _tableRow.cloneNode(true);
for (let x = 0; x < limit; x++) {
const tableRow = _tableRow.cloneNode(true) as HTMLTableRowElement;
const key = decodedManifestKeys[x];
tableRow.id = key;
let rawValue = decodedManifest[key];
let isString = true;
if (typeof rawValue != "string") {
const prettified = JSON.stringify(decodedManifest[key], null, 2);
if (typeof rawValue !== "string") {
const prettified = JSON.stringify(rawValue, null, 2);
let humanize = prettified.replace(/\{|\}|\[|\]/gim, ``);
humanize = humanize.replace(/ubiquity:/gim, ``);
humanize = humanize.replace(/": "/gim, ` ➡️ `);
Expand All @@ -51,22 +45,23 @@ const manifestGuiBody = document.querySelector(`#manifest-gui-body`);
rawValue = humanize;
isString = false;
}
const valueParsed = rawValue;
const keyDiv = _div.cloneNode();
const valueParsed = rawValue as string;
const keyDiv = _div.cloneNode() as HTMLDivElement;
keyDiv.textContent = key.replace("ubiquity:", "");

// h3.id = `key-${key}`;
const valueDiv = _div.cloneNode();
const valueDiv = _div.cloneNode() as HTMLDivElement;
if (isString) {
valueDiv.textContent = valueParsed;
} else {
const nestedObject = _nestedObject.cloneNode();
const nestedObject = _nestedObject.cloneNode() as HTMLPreElement;
nestedObject.textContent = valueParsed;
valueDiv.appendChild(nestedObject);
}
// div.id = `value-${key}`;
tableRow.children[0].appendChild(keyDiv);
tableRow.children[1].appendChild(valueDiv);

const firstChild = tableRow.children[0] as HTMLTableCellElement;
const secondChild = tableRow.children[1] as HTMLTableCellElement;
firstChild.appendChild(keyDiv);
secondChild.appendChild(valueDiv);
dfg.appendChild(tableRow);
}

Expand Down

0 comments on commit 0c02394

Please sign in to comment.