Merge branch 'tasiaiso-prettier'

This commit is contained in:
Cory McWilliams 2024-02-24 11:03:36 -05:00
commit 8e7e0ed490
12 changed files with 272 additions and 221 deletions

2
.git-blame-ignore-revs Normal file
View File

@ -0,0 +1,2 @@
# Add prettier to the project
41024ddb7961b04a5688bbc997cb74de6fab4763

14
.prettierignore Normal file
View File

@ -0,0 +1,14 @@
node_modules
src
deps
.clang-format
# Minified files
**/*.min.css
**/*.min.js
**/leaflet.*
**/commonmark*
**/w3.css
apps/ssb/tribute.esm.js
apps/api/app.js
**/emojis.json

10
.prettierrc.yaml Normal file
View File

@ -0,0 +1,10 @@
trailingComma: 'es5'
useTabs: true
semi: true
singleQuote: true
bracketSpacing: false
# overrides:
# - files: '**/*.json'
# options:
# useTabs: false
# tabWidth: 2

View File

@ -8,7 +8,7 @@ let gSessionIndex = 0;
/** /**
* TODOC * TODOC
* @returns * @returns
*/ */
function makeSessionId() { function makeSessionId() {
return (gSessionIndex++).toString(); return (gSessionIndex++).toString();
@ -16,7 +16,7 @@ function makeSessionId() {
/** /**
* TODOC * TODOC
* @returns * @returns
*/ */
function App() { function App() {
this._on_output = null; this._on_output = null;
@ -26,7 +26,7 @@ function App() {
/** /**
* TODOC * TODOC
* @param {*} callback * @param {*} callback
*/ */
App.prototype.readOutput = function(callback) { App.prototype.readOutput = function(callback) {
this._on_output = callback; this._on_output = callback;
@ -34,8 +34,8 @@ App.prototype.readOutput = function(callback) {
/** /**
* TODOC * TODOC
* @param {*} api * @param {*} api
* @returns * @returns
*/ */
App.prototype.makeFunction = function(api) { App.prototype.makeFunction = function(api) {
let self = this; let self = this;
@ -62,7 +62,7 @@ App.prototype.makeFunction = function(api) {
/** /**
* TODOC * TODOC
* @param {*} message * @param {*} message
*/ */
App.prototype.send = function(message) { App.prototype.send = function(message) {
if (this._send_queue) { if (this._send_queue) {
@ -76,13 +76,13 @@ App.prototype.send = function(message) {
if (message && this._on_output) { if (message && this._on_output) {
this._on_output(message); this._on_output(message);
} }
} };
/** /**
* TODOC * TODOC
* @param {*} request * @param {*} request
* @param {*} response * @param {*} response
* @param {*} client * @param {*} client
*/ */
function socket(request, response, client) { function socket(request, response, client) {
let process; let process;

View File

@ -7,7 +7,7 @@ const kRefreshInterval = 1 * 7 * 24 * 60 * 60 * 1000;
/** /**
* Makes a Base64 value URL safe * Makes a Base64 value URL safe
* @param {string} value * @param {string} value
* @returns TODOC * @returns TODOC
*/ */
function b64url(value) { function b64url(value) {
@ -23,8 +23,8 @@ function b64url(value) {
/** /**
* TODOC * TODOC
* @param {string} value * @param {string} value
* @returns * @returns
*/ */
function unb64url(value) { function unb64url(value) {
value = value.replaceAll('-', '+').replaceAll('_', '/'); value = value.replaceAll('-', '+').replaceAll('_', '/');
@ -47,44 +47,22 @@ function unb64url(value) {
function makeJwt(payload) { function makeJwt(payload) {
const ids = ssb.getIdentities(':auth'); const ids = ssb.getIdentities(':auth');
let id; let id;
if (ids?.length) { if (ids?.length) {
id = ids[0]; id = ids[0];
} else { } else {
id = ssb.createIdentity(':auth'); id = ssb.createIdentity(':auth');
} }
const final_payload = b64url( const final_payload = b64url(base64Encode(JSON.stringify(Object.assign({}, payload, {exp: (new Date().valueOf()) + kRefreshInterval}))));
base64Encode( const jwt = [b64url(base64Encode(JSON.stringify({alg: 'HS256', typ: 'JWT'}))), final_payload, b64url(ssb.hmacsha256sign(final_payload, ':auth', id))].join('.');
JSON.stringify(
Object.assign({}, payload, {exp: (new Date().valueOf()) + kRefreshInterval}
)
)
)
);
const jwt = [
b64url(
base64Encode(
JSON.stringify({
alg: 'HS256',
typ: 'JWT'
})
)
),
final_payload,
b64url(
ssb.hmacsha256sign(final_payload, ':auth', id)
)
].join('.');
return jwt; return jwt;
} }
/** /**
* Validates a JWT ? * Validates a JWT ?
* @param {*} session TODOC * @param {*} session TODOC
* @returns * @returns
*/ */
function readSession(session) { function readSession(session) {
let jwt_parts = session?.split('.'); let jwt_parts = session?.split('.');
@ -118,7 +96,7 @@ function readSession(session) {
/** /**
* Check the provided password matches the hash * Check the provided password matches the hash
* @param {string} password * @param {string} password
* @param {string} hash bcrypt hash * @param {string} hash bcrypt hash
* @returns true if the password matches the hash * @returns true if the password matches the hash
*/ */
@ -128,7 +106,7 @@ function verifyPassword(password, hash) {
/** /**
* Hashes a password * Hashes a password
* @param {string} password * @param {string} password
* @returns {string} TODOC * @returns {string} TODOC
*/ */
function hashPassword(password) { function hashPassword(password) {
@ -141,11 +119,15 @@ function hashPassword(password) {
* @returns TODOC * @returns TODOC
*/ */
function noAdministrator() { function noAdministrator() {
return !core.globalSettings || return (
!core.globalSettings.permissions || !core.globalSettings ||
!Object.keys(core.globalSettings.permissions).some(function(name) { !core.globalSettings.permissions ||
return core.globalSettings.permissions[name].indexOf("administration") != -1; !Object.keys(core.globalSettings.permissions).some(function (name) {
}); return (
core.globalSettings.permissions[name].indexOf('administration') != -1
);
})
);
} }
/** /**
@ -162,14 +144,14 @@ function makeAdministrator(name) {
if (core.globalSettings.permissions[name].indexOf("administration") == -1) { if (core.globalSettings.permissions[name].indexOf("administration") == -1) {
core.globalSettings.permissions[name].push("administration"); core.globalSettings.permissions[name].push("administration");
} }
core.setGlobalSettings(core.globalSettings); core.setGlobalSettings(core.globalSettings);
} }
/** /**
* TODOC * TODOC
* @param {*} headers most likely an object * @param {*} headers most likely an object
* @returns * @returns
*/ */
function getCookies(headers) { function getCookies(headers) {
let cookies = {}; let cookies = {};
@ -189,7 +171,7 @@ function getCookies(headers) {
/** /**
* Validates a username * Validates a username
* @param {string} name * @param {string} name
* @returns false | boolean[] ? * @returns false | boolean[] ?
*/ */
function isNameValid(name) { function isNameValid(name) {
@ -201,13 +183,12 @@ function isNameValid(name) {
/** /**
* Request handler ? * Request handler ?
* @param {*} request TODOC * @param {*} request TODOC
* @param {*} response * @param {*} response
* @returns * @returns
*/ */
function handler(request, response) { function handler(request, response) {
// TODO(tasiaiso): split this function // TODO(tasiaiso): split this function
let session = getCookies(request.headers).session; let session = getCookies(request.headers).session;
if (request.uri == "/login") { if (request.uri == "/login") {
let formData = form.decodeForm(request.query); let formData = form.decodeForm(request.query);
if (query(request.headers)?.permissions?.authenticated) { if (query(request.headers)?.permissions?.authenticated) {
@ -319,7 +300,7 @@ function handler(request, response) {
/** /**
* Gets a user's permissions based on it's session ? * Gets a user's permissions based on it's session ?
* @param {*} session TODOC * @param {*} session TODOC
* @returns * @returns
*/ */
function getPermissions(session) { function getPermissions(session) {
let permissions; let permissions;
@ -334,7 +315,7 @@ function getPermissions(session) {
/** /**
* Get a user's permissions ? * Get a user's permissions ?
* @param {string} userName TODOC * @param {string} userName TODOC
* @returns * @returns
*/ */
function getPermissionsForUser(userName) { function getPermissionsForUser(userName) {
let permissions = {}; let permissions = {};
@ -348,8 +329,8 @@ function getPermissionsForUser(userName) {
/** /**
* TODOC * TODOC
* @param {*} headers * @param {*} headers
* @returns * @returns
*/ */
function query(headers) { function query(headers) {
let session = getCookies(headers).session; let session = getCookies(headers).session;
@ -366,7 +347,7 @@ function query(headers) {
/** /**
* Refreshes a JWT ? * Refreshes a JWT ?
* @param {*} credentials TODOC * @param {*} credentials TODOC
* @returns * @returns
*/ */
function makeRefresh(credentials) { function makeRefresh(credentials) {
if (credentials?.session?.name) { if (credentials?.session?.name) {
@ -377,4 +358,4 @@ function makeRefresh(credentials) {
} }
} }
export { handler, query, makeRefresh }; export {handler, query, makeRefresh};

View File

@ -69,7 +69,7 @@ class TfNavigationElement extends LitElement {
/** /**
* TODOC * TODOC
* @param {*} event * @param {*} event
*/ */
toggle_edit(event) { toggle_edit(event) {
event.preventDefault(); event.preventDefault();
@ -82,7 +82,7 @@ class TfNavigationElement extends LitElement {
/** /**
* TODOC * TODOC
* @param {*} key * @param {*} key
*/ */
reset_permission(key) { reset_permission(key) {
send({action: "resetPermission", permission: key}); send({action: "resetPermission", permission: key});
@ -90,9 +90,9 @@ class TfNavigationElement extends LitElement {
/** /**
* TODOC * TODOC
* @param {*} key * @param {*} key
* @param {*} options * @param {*} options
* @returns * @returns
*/ */
get_spark_line(key, options) { get_spark_line(key, options) {
if (!this.spark_lines[key]) { if (!this.spark_lines[key]) {
@ -114,7 +114,7 @@ class TfNavigationElement extends LitElement {
/** /**
* TODOC * TODOC
* @returns * @returns
*/ */
render_login() { render_login() {
if (this?.credentials?.session?.name) { if (this?.credentials?.session?.name) {
@ -126,7 +126,7 @@ class TfNavigationElement extends LitElement {
/** /**
* TODOC * TODOC
* @returns * @returns
*/ */
render_permissions() { render_permissions() {
if (this.show_permissions) { if (this.show_permissions) {
@ -150,7 +150,7 @@ class TfNavigationElement extends LitElement {
/** /**
* TODOC * TODOC
* @returns * @returns
*/ */
render() { render() {
let self = this; let self = this;
@ -210,7 +210,7 @@ class TfFilesElement extends LitElement {
/** /**
* TODOC * TODOC
* @param {*} file * @param {*} file
*/ */
file_click(file) { file_click(file) {
this.dispatchEvent(new CustomEvent('file_click', { this.dispatchEvent(new CustomEvent('file_click', {
@ -224,8 +224,8 @@ class TfFilesElement extends LitElement {
/** /**
* TODOC * TODOC
* @param {*} file * @param {*} file
* @returns * @returns
*/ */
render_file(file) { render_file(file) {
let classes = ['file']; let classes = ['file'];
@ -240,7 +240,7 @@ class TfFilesElement extends LitElement {
/** /**
* TODOC * TODOC
* @param {*} event * @param {*} event
*/ */
async drop(event) { async drop(event) {
event.preventDefault(); event.preventDefault();
@ -262,7 +262,7 @@ class TfFilesElement extends LitElement {
/** /**
* TODOC * TODOC
* @param {*} event * @param {*} event
*/ */
drag_enter(event) { drag_enter(event) {
this.dropping++; this.dropping++;
@ -271,7 +271,7 @@ class TfFilesElement extends LitElement {
/** /**
* TODOC * TODOC
* @param {*} event * @param {*} event
*/ */
drag_leave(event) { drag_leave(event) {
this.dropping--; this.dropping--;
@ -279,7 +279,7 @@ class TfFilesElement extends LitElement {
/** /**
* TODOC * TODOC
* @returns * @returns
*/ */
render() { render() {
let self = this; let self = this;
@ -340,7 +340,7 @@ class TfFilesPaneElement extends LitElement {
/** /**
* TODOC * TODOC
* @param {*} expanded * @param {*} expanded
*/ */
set_expanded(expanded) { set_expanded(expanded) {
this.expanded = expanded; this.expanded = expanded;
@ -349,7 +349,7 @@ class TfFilesPaneElement extends LitElement {
/** /**
* TODOC * TODOC
* @returns * @returns
*/ */
render() { render() {
let self = this; let self = this;
@ -398,8 +398,8 @@ class TfSparkLineElement extends LitElement {
/** /**
* TODOC * TODOC
* @param {*} key * @param {*} key
* @param {*} value * @param {*} value
*/ */
append(key, value) { append(key, value) {
let line = null; let line = null;
@ -427,8 +427,8 @@ class TfSparkLineElement extends LitElement {
/** /**
* TODOC * TODOC
* @param {*} line * @param {*} line
* @returns * @returns
*/ */
render_line(line) { render_line(line) {
if (line?.values?.length >= 2) { if (line?.values?.length >= 2) {
@ -440,7 +440,7 @@ class TfSparkLineElement extends LitElement {
/** /**
* TODOC * TODOC
* @returns * @returns
*/ */
render() { render() {
let max = Math.round(10.0 * Math.max(...this.lines.map(line => line.values[line.values.length - 1]))) / 10.0; let max = Math.round(10.0 * Math.max(...this.lines.map(line => line.values[line.values.length - 1]))) / 10.0;
@ -456,7 +456,7 @@ class TfSparkLineElement extends LitElement {
customElements.define('tf-sparkline', TfSparkLineElement); customElements.define('tf-sparkline', TfSparkLineElement);
// TODOC // TODOC
window.addEventListener("keydown", function(event) { window.addEventListener('keydown', function (event) {
if (event.keyCode == 83 && (event.altKey || event.ctrlKey)) { if (event.keyCode == 83 && (event.altKey || event.ctrlKey)) {
if (editing()) { if (editing()) {
save(); save();
@ -472,9 +472,9 @@ window.addEventListener("keydown", function(event) {
/** /**
* TODOC * TODOC
* @param {*} nodes * @param {*} nodes
* @param {*} callback * @param {*} callback
* @returns * @returns
*/ */
function ensureLoaded(nodes, callback) { function ensureLoaded(nodes, callback) {
if (!nodes.length) { if (!nodes.length) {
@ -515,7 +515,7 @@ function ensureLoaded(nodes, callback) {
/** /**
* TODOC * TODOC
* @returns * @returns
*/ */
function editing() { function editing() {
return document.getElementById("editPane").style.display != 'none'; return document.getElementById("editPane").style.display != 'none';
@ -523,7 +523,7 @@ function editing() {
/** /**
* TODOC * TODOC
* @returns * @returns
*/ */
function is_edit_only() { function is_edit_only() {
return window.location.search == '?editonly=1' || window.innerWidth < 1024; return window.location.search == '?editonly=1' || window.innerWidth < 1024;
@ -531,7 +531,7 @@ function is_edit_only() {
/** /**
* TODOC * TODOC
* @returns * @returns
*/ */
async function edit() { async function edit() {
if (editing()) { if (editing()) {
@ -564,8 +564,8 @@ function trace() {
/** /**
* TODOC * TODOC
* @param {*} name * @param {*} name
* @returns * @returns
*/ */
function guessMode(name) { function guessMode(name) {
return name.endsWith(".js") ? "javascript" : return name.endsWith(".js") ? "javascript" :
@ -575,9 +575,9 @@ function guessMode(name) {
/** /**
* TODOC * TODOC
* @param {*} name * @param {*} name
* @param {*} id * @param {*} id
* @returns * @returns
*/ */
function loadFile(name, id) { function loadFile(name, id) {
return fetch('/' + id + '/view').then(function(response) { return fetch('/' + id + '/view').then(function(response) {
@ -597,8 +597,8 @@ function loadFile(name, id) {
/** /**
* TODOC * TODOC
* @param {*} path * @param {*} path
* @returns * @returns
*/ */
async function load(path) { async function load(path) {
let response = await fetch((path || url()) + 'view'); let response = await fetch((path || url()) + 'view');
@ -648,7 +648,7 @@ function closeEditor() {
/** /**
* TODOC * TODOC
* @returns * @returns
*/ */
function explodePath() { function explodePath() {
return /^\/~([^\/]+)\/([^\/]+)(.*)/.exec(window.location.pathname); return /^\/~([^\/]+)\/([^\/]+)(.*)/.exec(window.location.pathname);
@ -656,8 +656,8 @@ function explodePath() {
/** /**
* TODOC * TODOC
* @param {*} save_to * @param {*} save_to
* @returns * @returns
*/ */
function save(save_to) { function save(save_to) {
document.getElementById("save").disabled = true; document.getElementById("save").disabled = true;
@ -775,7 +775,7 @@ function deleteApp() {
/** /**
* TODOC * TODOC
* @returns * @returns
*/ */
function url() { function url() {
let hash = window.location.href.indexOf('#'); let hash = window.location.href.indexOf('#');
@ -794,7 +794,7 @@ function url() {
/** /**
* TODOC * TODOC
* @returns * @returns
*/ */
function hash() { function hash() {
return window.location.hash != "#" ? window.location.hash : ""; return window.location.hash != "#" ? window.location.hash : "";
@ -802,7 +802,7 @@ function hash() {
/** /**
* TODOC * TODOC
* @param {*} content * @param {*} content
*/ */
function api_setDocument(content) { function api_setDocument(content) {
let iframe = document.getElementById("document"); let iframe = document.getElementById("document");
@ -811,7 +811,7 @@ function api_setDocument(content) {
/** /**
* TODOC * TODOC
* @param {*} message * @param {*} message
*/ */
function api_postMessage(message) { function api_postMessage(message) {
let iframe = document.getElementById("document"); let iframe = document.getElementById("document");
@ -820,7 +820,7 @@ function api_postMessage(message) {
/** /**
* TODOC * TODOC
* @param {*} error * @param {*} error
*/ */
function api_error(error) { function api_error(error) {
if (error) { if (error) {
@ -835,8 +835,8 @@ function api_error(error) {
/** /**
* TODOC * TODOC
* @param {*} key * @param {*} key
* @param {*} value * @param {*} value
*/ */
function api_localStorageSet(key, value) { function api_localStorageSet(key, value) {
window.localStorage.setItem('app:' + key, value); window.localStorage.setItem('app:' + key, value);
@ -844,8 +844,8 @@ function api_localStorageSet(key, value) {
/** /**
* TODOC * TODOC
* @param {*} key * @param {*} key
* @returns * @returns
*/ */
function api_localStorageGet(key) { function api_localStorageGet(key) {
return window.localStorage.getItem('app:' + key); return window.localStorage.getItem('app:' + key);
@ -853,9 +853,9 @@ function api_localStorageGet(key) {
/** /**
* TODOC * TODOC
* @param {*} permission * @param {*} permission
* @param {*} id * @param {*} id
* @returns * @returns
*/ */
function api_requestPermission(permission, id) { function api_requestPermission(permission, id) {
let outer = document.createElement('div'); let outer = document.createElement('div');
@ -930,7 +930,7 @@ function api_print() {
/** /**
* TODOC * TODOC
* @param {*} hash * @param {*} hash
*/ */
function api_setHash(hash) { function api_setHash(hash) {
window.location.hash = hash; window.location.hash = hash;
@ -938,7 +938,7 @@ function api_setHash(hash) {
/** /**
* TODOC * TODOC
* @param {*} message * @param {*} message
*/ */
function _receive_websocket_message(message) { function _receive_websocket_message(message) {
if (message && message.action == "session") { if (message && message.action == "session") {
@ -1022,8 +1022,8 @@ function _receive_websocket_message(message) {
/** /**
* TODOC * TODOC
* @param {*} message * @param {*} message
* @param {*} color * @param {*} color
*/ */
function setStatusMessage(message, color) { function setStatusMessage(message, color) {
document.getElementsByTagName('tf-navigation')[0].status = {message: message, color: color}; document.getElementsByTagName('tf-navigation')[0].status = {message: message, color: color};
@ -1031,7 +1031,7 @@ function setStatusMessage(message, color) {
/** /**
* TODOC * TODOC
* @param {*} value * @param {*} value
*/ */
function send(value) { function send(value) {
try { try {
@ -1045,10 +1045,10 @@ function send(value) {
/** /**
* TODOC * TODOC
* @param {*} sourceData * @param {*} sourceData
* @param {*} maxWidth * @param {*} maxWidth
* @param {*} maxHeight * @param {*} maxHeight
* @param {*} callback * @param {*} callback
*/ */
function fixImage(sourceData, maxWidth, maxHeight, callback) { function fixImage(sourceData, maxWidth, maxHeight, callback) {
let result = sourceData; let result = sourceData;
@ -1075,7 +1075,7 @@ function fixImage(sourceData, maxWidth, maxHeight, callback) {
/** /**
* TODOC * TODOC
* @param {*} image * @param {*} image
*/ */
function sendImage(image) { function sendImage(image) {
fixImage(image, 320, 240, function(result) { fixImage(image, 320, 240, function(result) {
@ -1112,7 +1112,7 @@ function blur() {
/** /**
* TODOC * TODOC
* @param {*} event * @param {*} event
*/ */
function message(event) { function message(event) {
if (event.data && event.data.event == "resizeMe" && event.data.width && event.data.height) { if (event.data && event.data.event == "resizeMe" && event.data.width && event.data.height) {
@ -1144,7 +1144,7 @@ function message(event) {
/** /**
* TODOC * TODOC
* @param {*} path * @param {*} path
*/ */
function reconnect(path) { function reconnect(path) {
let oldSocket = gSocket; let oldSocket = gSocket;
@ -1160,7 +1160,7 @@ function reconnect(path) {
/** /**
* TODOC * TODOC
* @param {*} path * @param {*} path
*/ */
function connectSocket(path) { function connectSocket(path) {
if (!gSocket || gSocket.readyState != gSocket.OPEN) { if (!gSocket || gSocket.readyState != gSocket.OPEN) {
@ -1215,7 +1215,7 @@ function connectSocket(path) {
/** /**
* TODOC * TODOC
* @param {*} name * @param {*} name
*/ */
function openFile(name) { function openFile(name) {
let newDoc = (name && gFiles[name]) ? gFiles[name].doc : cm6.EditorState.create({doc: "", extensions: cm6.extensions}); let newDoc = (name && gFiles[name]) ? gFiles[name].doc : cm6.EditorState.create({doc: "", extensions: cm6.extensions});
@ -1249,7 +1249,7 @@ function updateFiles() {
/** /**
* TODOC * TODOC
* @param {*} name * @param {*} name
*/ */
function makeNewFile(name) { function makeNewFile(name) {
gFiles[name] = { gFiles[name] = {
@ -1305,9 +1305,9 @@ async function appExport() {
/** /**
* TODOC * TODOC
* @param {*} name * @param {*} name
* @param {*} file * @param {*} file
* @returns * @returns
*/ */
async function save_file_to_blob_id(name, file) { async function save_file_to_blob_id(name, file) {
console.log(`Saving ${name}.`); console.log(`Saving ${name}.`);
@ -1383,7 +1383,7 @@ async function appImport() {
} }
/** /**
* *
*/ */
async function sourcePretty() { async function sourcePretty() {
let prettier = (await import('/prettier/standalone.mjs')).default; let prettier = (await import('/prettier/standalone.mjs')).default;
@ -1393,7 +1393,11 @@ async function sourcePretty() {
let formatted = await prettier.format(source, { let formatted = await prettier.format(source, {
parser: 'babel', parser: 'babel',
plugins: [babel, estree], plugins: [babel, estree],
trailingComma: 'es5',
useTabs: true, useTabs: true,
semi: true,
singleQuote: true,
bracketSpacing: false,
}); });
if (source !== formatted) { if (source !== formatted) {
gEditor.dispatch({ gEditor.dispatch({
@ -1407,14 +1411,16 @@ async function sourcePretty() {
} }
// TODOC // TODOC
window.addEventListener("load", function() { window.addEventListener('load', function () {
window.addEventListener("hashchange", hashChange); window.addEventListener('hashchange', hashChange);
window.addEventListener("focus", focus); window.addEventListener('focus', focus);
window.addEventListener("blur", blur); window.addEventListener('blur', blur);
window.addEventListener("message", message, false); window.addEventListener('message', message, false);
window.addEventListener("online", connectSocket); window.addEventListener('online', connectSocket);
document.getElementById("name").value = window.location.pathname; document.getElementById('name').value = window.location.pathname;
document.getElementById('closeEditor').addEventListener('click', () => closeEditor()); document
.getElementById('closeEditor')
.addEventListener('click', () => closeEditor());
document.getElementById('save').addEventListener('click', () => save()); document.getElementById('save').addEventListener('click', () => save());
document.getElementById('icon').addEventListener('click', () => changeIcon()); document.getElementById('icon').addEventListener('click', () => changeIcon());
document.getElementById('delete').addEventListener('click', () => deleteApp()); document.getElementById('delete').addEventListener('click', () => deleteApp());

View File

@ -93,8 +93,8 @@ let kPingInterval = 60 * 1000;
/** /**
* TODOC * TODOC
* @param {*} out * @param {*} out
* @param {*} error * @param {*} error
*/ */
function printError(out, error) { function printError(out, error) {
if (error.stackTrace) { if (error.stackTrace) {
@ -110,9 +110,9 @@ function printError(out, error) {
/** /**
* TODOC * TODOC
* @param {*} handlers * @param {*} handlers
* @param {*} argv * @param {*} argv
* @returns * @returns
*/ */
function invoke(handlers, argv) { function invoke(handlers, argv) {
let promises = []; let promises = [];
@ -132,9 +132,9 @@ function invoke(handlers, argv) {
/** /**
* TODOC * TODOC
* @param {*} eventName * @param {*} eventName
* @param {*} argv * @param {*} argv
* @returns * @returns
*/ */
function broadcastEvent(eventName, argv) { function broadcastEvent(eventName, argv) {
let promises = []; let promises = [];
@ -147,8 +147,8 @@ function broadcastEvent(eventName, argv) {
} }
/** /**
* TODOC * TODOC
* @param {*} message * @param {*} message
* @returns * @returns
*/ */
function broadcast(message) { function broadcast(message) {
let sender = this; let sender = this;
@ -166,9 +166,9 @@ function broadcast(message) {
/** /**
* TODOC * TODOC
* @param {*} caller * @param {*} caller
* @param {*} process * @param {*} process
* @returns * @returns
*/ */
function getUser(caller, process) { function getUser(caller, process) {
return { return {
@ -182,9 +182,9 @@ function getUser(caller, process) {
/** /**
* TODOC * TODOC
* @param {*} user * @param {*} user
* @param {*} process * @param {*} process
* @returns * @returns
*/ */
function getApps(user, process) { function getApps(user, process) {
if (process.credentials && if (process.credentials &&
@ -209,10 +209,10 @@ function getApps(user, process) {
/** /**
* TODOC * TODOC
* @param {*} from * @param {*} from
* @param {*} to * @param {*} to
* @param {*} message * @param {*} message
* @returns * @returns
*/ */
function postMessageInternal(from, to, message) { function postMessageInternal(from, to, message) {
if (to.eventHandlers['message']) { if (to.eventHandlers['message']) {
@ -222,10 +222,10 @@ function postMessageInternal(from, to, message) {
/** /**
* TODOC * TODOC
* @param {*} blobId * @param {*} blobId
* @param {*} session * @param {*} session
* @param {*} options * @param {*} options
* @returns * @returns
*/ */
async function getSessionProcessBlob(blobId, session, options) { async function getSessionProcessBlob(blobId, session, options) {
let actualOptions = {timeout: kPingInterval}; let actualOptions = {timeout: kPingInterval};
@ -239,10 +239,10 @@ async function getSessionProcessBlob(blobId, session, options) {
/** /**
* TODOC * TODOC
* @param {*} blobId * @param {*} blobId
* @param {*} key * @param {*} key
* @param {*} options * @param {*} options
* @returns * @returns
*/ */
async function getProcessBlob(blobId, key, options) { async function getProcessBlob(blobId, key, options) {
// TODO(tasiaiso): break this down ? // TODO(tasiaiso): break this down ?
@ -592,8 +592,8 @@ async function getProcessBlob(blobId, key, options) {
/** /**
* TODOC * TODOC
* @param {*} settings * @param {*} settings
* @returns * @returns
*/ */
function setGlobalSettings(settings) { function setGlobalSettings(settings) {
gGlobalSettings = settings; gGlobalSettings = settings;
@ -606,9 +606,9 @@ function setGlobalSettings(settings) {
/** /**
* TODOC * TODOC
* @param {*} data * @param {*} data
* @param {*} bytes * @param {*} bytes
* @returns * @returns
*/ */
function startsWithBytes(data, bytes) { function startsWithBytes(data, bytes) {
if (data.byteLength >= bytes.length) { if (data.byteLength >= bytes.length) {
@ -624,8 +624,8 @@ function startsWithBytes(data, bytes) {
/** /**
* TODOC * TODOC
* @param {*} path * @param {*} path
* @returns * @returns
*/ */
function guessTypeFromName(path) { function guessTypeFromName(path) {
let extension = path.split('.').pop(); let extension = path.split('.').pop();
@ -634,8 +634,8 @@ function guessTypeFromName(path) {
/** /**
* TODOC * TODOC
* @param {*} data * @param {*} data
* @returns * @returns
*/ */
function guessTypeFromMagicBytes(data) { function guessTypeFromMagicBytes(data) {
for (let magic of k_magic_bytes) { for (let magic of k_magic_bytes) {
@ -647,11 +647,11 @@ function guessTypeFromMagicBytes(data) {
/** /**
* TODOC * TODOC
* @param {*} response * @param {*} response
* @param {*} data * @param {*} data
* @param {*} type * @param {*} type
* @param {*} headers * @param {*} headers
* @param {*} status_code * @param {*} status_code
*/ */
function sendData(response, data, type, headers, status_code) { function sendData(response, data, type, headers, status_code) {
if (data) { if (data) {
@ -665,8 +665,8 @@ function sendData(response, data, type, headers, status_code) {
/** /**
* TODOC * TODOC
* @param {*} id * @param {*} id
* @returns * @returns
*/ */
async function getBlobOrContent(id) { async function getBlobOrContent(id) {
if (!id) { if (!id) {
@ -682,14 +682,14 @@ let g_handler_index = 0;
/** /**
* TODOC * TODOC
* @param {*} response * @param {*} response
* @param {*} handler_blob_id * @param {*} handler_blob_id
* @param {*} path * @param {*} path
* @param {*} query * @param {*} query
* @param {*} headers * @param {*} headers
* @param {*} packageOwner * @param {*} packageOwner
* @param {*} packageName * @param {*} packageName
* @returns * @returns
*/ */
async function useAppHandler(response, handler_blob_id, path, query, headers, packageOwner, packageName) { async function useAppHandler(response, handler_blob_id, path, query, headers, packageOwner, packageName) {
print('useAppHandler', packageOwner, packageName); print('useAppHandler', packageOwner, packageName);
@ -726,11 +726,11 @@ async function useAppHandler(response, handler_blob_id, path, query, headers, pa
/** /**
* TODOC * TODOC
* @param {*} request * @param {*} request
* @param {*} response * @param {*} response
* @param {*} blobId * @param {*} blobId
* @param {*} uri * @param {*} uri
* @returns * @returns
*/ */
async function blobHandler(request, response, blobId, uri) { async function blobHandler(request, response, blobId, uri) {
// TODO(tasiaiso): break this down ? // TODO(tasiaiso): break this down ?
@ -1000,8 +1000,8 @@ function sendStats() {
/** /**
* TODOC * TODOC
* @param {*} process * @param {*} process
* @param {*} enabled * @param {*} enabled
*/ */
function enableStats(process, enabled) { function enableStats(process, enabled) {
process.stats = enabled; process.stats = enabled;
@ -1081,11 +1081,11 @@ loadSettings().then(function() {
/** /**
* TODOC * TODOC
* @param {*} user * @param {*} user
* @param {*} packageOwner * @param {*} packageOwner
* @param {*} packageName * @param {*} packageName
* @param {*} permission * @param {*} permission
* @param {*} allow * @param {*} allow
*/ */
function storePermission(user, packageOwner, packageName, permission, allow) { function storePermission(user, packageOwner, packageName, permission, allow) {
if (!gGlobalSettings.userPermissions) { if (!gGlobalSettings.userPermissions) {

View File

@ -1,7 +1,7 @@
/** /**
* TODOC * TODOC
* @param {*} encoded * @param {*} encoded
* @returns * @returns
*/ */
function decode(encoded) { function decode(encoded) {
let result = ""; let result = "";
@ -21,9 +21,9 @@ function decode(encoded) {
/** /**
* TODOC * TODOC
* @param {*} encoded * @param {*} encoded
* @param {*} initial * @param {*} initial
* @returns * @returns
*/ */
function decodeForm(encoded, initial) { function decodeForm(encoded, initial) {
let result = initial || {}; let result = initial || {};

View File

@ -1,8 +1,8 @@
/** /**
* TODOC * TODOC
* TODO: document so we can improve this * TODO: document so we can improve this
* @param {*} url * @param {*} url
* @returns * @returns
*/ */
function parseUrl(url) { function parseUrl(url) {
// XXX: Hack. // XXX: Hack.
@ -17,8 +17,8 @@ function parseUrl(url) {
/** /**
* TODOC * TODOC
* @param {*} data * @param {*} data
* @returns * @returns
*/ */
function parseResponse(data) { function parseResponse(data) {
let firstLine; let firstLine;
@ -41,10 +41,10 @@ function parseResponse(data) {
/** /**
* TODOC * TODOC
* @param {*} url * @param {*} url
* @param {*} options * @param {*} options
* @param {*} allowed_hosts * @param {*} allowed_hosts
* @returns * @returns
*/ */
export function fetch(url, options, allowed_hosts) { export function fetch(url, options, allowed_hosts) {
let parsed = parseUrl(url); let parsed = parseUrl(url);

View File

@ -5,7 +5,7 @@ let g_calls = {};
/** /**
* TODOC * TODOC
* @returns * @returns
*/ */
function get_is_browser() { function get_is_browser() {
try { return window !== undefined && console !== undefined; } catch { return false; } try { return window !== undefined && console !== undefined; } catch { return false; }
@ -17,10 +17,10 @@ if (k_is_browser) {
/** /**
* TODOC * TODOC
* @param {*} target * @param {*} target
* @param {*} prop * @param {*} prop
* @param {*} receiver * @param {*} receiver
* @returns * @returns
*/ */
function make_rpc(target, prop, receiver) { function make_rpc(target, prop, receiver) {
return function() { return function() {
@ -42,7 +42,7 @@ function make_rpc(target, prop, receiver) {
/** /**
* TODOC * TODOC
* @param {*} response * @param {*} response
*/ */
function send(response) { function send(response) {
if (k_is_browser) { if (k_is_browser) {
@ -54,7 +54,7 @@ function send(response) {
/** /**
* TODOC * TODOC
* @param {*} message * @param {*} message
*/ */
function call_rpc(message) { function call_rpc(message) {
if (message && message.message === 'tfrpc') { if (message && message.message === 'tfrpc') {
@ -106,7 +106,7 @@ export let rpc = new Proxy({}, {get: make_rpc});
/** /**
* TODOC * TODOC
* @param {*} method * @param {*} method
*/ */
export function register(method) { export function register(method) {
g_api[method.name] = method; g_api[method.name] = method;

27
package-lock.json generated Normal file
View File

@ -0,0 +1,27 @@
{
"name": "tildefriends",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "tildefriends",
"license": "MIT",
"dependencies": {
"prettier": "^3.2.5"
}
},
"node_modules/prettier": {
"version": "3.2.5",
"license": "MIT",
"bin": {
"prettier": "bin/prettier.cjs"
},
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/prettier/prettier?sponsor=1"
}
}
}
}

11
package.json Normal file
View File

@ -0,0 +1,11 @@
{
"name": "tildefriends",
"scripts": {
"prettier": "prettier . --check --cache --write"
},
"author": "Cory McWilliams",
"license": "MIT",
"dependencies": {
"prettier": "^3.2.5"
}
}