forked from cory/tildefriends
		
	Merge branch 'tasiaiso-prettier'
This commit is contained in:
		
							
								
								
									
										2
									
								
								.git-blame-ignore-revs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								.git-blame-ignore-revs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,2 @@
 | 
			
		||||
# Add prettier to the project
 | 
			
		||||
41024ddb7961b04a5688bbc997cb74de6fab4763
 | 
			
		||||
							
								
								
									
										14
									
								
								.prettierignore
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								.prettierignore
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										10
									
								
								.prettierrc.yaml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
			
		||||
trailingComma: 'es5'
 | 
			
		||||
useTabs: true
 | 
			
		||||
semi: true
 | 
			
		||||
singleQuote: true
 | 
			
		||||
bracketSpacing: false
 | 
			
		||||
# overrides:
 | 
			
		||||
#   - files: '**/*.json'
 | 
			
		||||
#     options:
 | 
			
		||||
#       useTabs: false
 | 
			
		||||
#       tabWidth: 2
 | 
			
		||||
							
								
								
									
										20
									
								
								core/app.js
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								core/app.js
									
									
									
									
									
								
							@@ -8,7 +8,7 @@ let gSessionIndex = 0;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function makeSessionId() {
 | 
			
		||||
	return (gSessionIndex++).toString();
 | 
			
		||||
@@ -16,7 +16,7 @@ function makeSessionId() {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function App() {
 | 
			
		||||
	this._on_output = null;
 | 
			
		||||
@@ -26,7 +26,7 @@ function App() {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} callback 
 | 
			
		||||
 * @param {*} callback
 | 
			
		||||
 */
 | 
			
		||||
App.prototype.readOutput = function(callback) {
 | 
			
		||||
	this._on_output = callback;
 | 
			
		||||
@@ -34,8 +34,8 @@ App.prototype.readOutput = function(callback) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} api 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} api
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
App.prototype.makeFunction = function(api) {
 | 
			
		||||
	let self = this;
 | 
			
		||||
@@ -62,7 +62,7 @@ App.prototype.makeFunction = function(api) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} message 
 | 
			
		||||
 * @param {*} message
 | 
			
		||||
 */
 | 
			
		||||
App.prototype.send = function(message) {
 | 
			
		||||
	if (this._send_queue) {
 | 
			
		||||
@@ -76,13 +76,13 @@ App.prototype.send = function(message) {
 | 
			
		||||
	if (message && this._on_output) {
 | 
			
		||||
		this._on_output(message);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} request 
 | 
			
		||||
 * @param {*} response 
 | 
			
		||||
 * @param {*} client 
 | 
			
		||||
 * @param {*} request
 | 
			
		||||
 * @param {*} response
 | 
			
		||||
 * @param {*} client
 | 
			
		||||
 */
 | 
			
		||||
function socket(request, response, client) {
 | 
			
		||||
	let process;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										77
									
								
								core/auth.js
									
									
									
									
									
								
							
							
						
						
									
										77
									
								
								core/auth.js
									
									
									
									
									
								
							@@ -7,7 +7,7 @@ const kRefreshInterval = 1 * 7 * 24 * 60 * 60 * 1000;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Makes a Base64 value URL safe
 | 
			
		||||
 * @param {string} value 
 | 
			
		||||
 * @param {string} value
 | 
			
		||||
 * @returns TODOC
 | 
			
		||||
 */
 | 
			
		||||
function b64url(value) {
 | 
			
		||||
@@ -23,8 +23,8 @@ function b64url(value) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {string} value 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {string} value
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function unb64url(value) {
 | 
			
		||||
	value = value.replaceAll('-', '+').replaceAll('_', '/');
 | 
			
		||||
@@ -47,44 +47,22 @@ function unb64url(value) {
 | 
			
		||||
function makeJwt(payload) {
 | 
			
		||||
	const ids = ssb.getIdentities(':auth');
 | 
			
		||||
	let id;
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	if (ids?.length) {
 | 
			
		||||
		id = ids[0];
 | 
			
		||||
	} else {
 | 
			
		||||
		id = ssb.createIdentity(':auth');
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	const final_payload = b64url(
 | 
			
		||||
		base64Encode(
 | 
			
		||||
			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('.');
 | 
			
		||||
	
 | 
			
		||||
	const final_payload = b64url(base64Encode(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;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Validates a JWT ?
 | 
			
		||||
 * @param {*} session TODOC
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function readSession(session) {
 | 
			
		||||
	let jwt_parts = session?.split('.');
 | 
			
		||||
@@ -118,7 +96,7 @@ function readSession(session) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Check the provided password matches the hash
 | 
			
		||||
 * @param {string} password 
 | 
			
		||||
 * @param {string} password
 | 
			
		||||
 * @param {string} hash bcrypt hash
 | 
			
		||||
 * @returns true if the password matches the hash
 | 
			
		||||
 */
 | 
			
		||||
@@ -128,7 +106,7 @@ function verifyPassword(password, hash) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Hashes a password
 | 
			
		||||
 * @param {string} password 
 | 
			
		||||
 * @param {string} password
 | 
			
		||||
 * @returns {string} TODOC
 | 
			
		||||
 */
 | 
			
		||||
function hashPassword(password) {
 | 
			
		||||
@@ -141,11 +119,15 @@ function hashPassword(password) {
 | 
			
		||||
 * @returns TODOC
 | 
			
		||||
 */
 | 
			
		||||
function noAdministrator() {
 | 
			
		||||
	return !core.globalSettings ||
 | 
			
		||||
	!core.globalSettings.permissions ||
 | 
			
		||||
	!Object.keys(core.globalSettings.permissions).some(function(name) {
 | 
			
		||||
		return core.globalSettings.permissions[name].indexOf("administration") != -1;
 | 
			
		||||
	});
 | 
			
		||||
	return (
 | 
			
		||||
		!core.globalSettings ||
 | 
			
		||||
		!core.globalSettings.permissions ||
 | 
			
		||||
		!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) {
 | 
			
		||||
		core.globalSettings.permissions[name].push("administration");
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	core.setGlobalSettings(core.globalSettings);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} headers most likely an object
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function getCookies(headers) {
 | 
			
		||||
	let cookies = {};
 | 
			
		||||
@@ -189,7 +171,7 @@ function getCookies(headers) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Validates a username
 | 
			
		||||
 * @param {string} name 
 | 
			
		||||
 * @param {string} name
 | 
			
		||||
 * @returns false | boolean[] ?
 | 
			
		||||
 */
 | 
			
		||||
function isNameValid(name) {
 | 
			
		||||
@@ -201,13 +183,12 @@ function isNameValid(name) {
 | 
			
		||||
/**
 | 
			
		||||
 * Request handler ?
 | 
			
		||||
 * @param {*} request TODOC
 | 
			
		||||
 * @param {*} response 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} response
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function handler(request, response) {
 | 
			
		||||
	// TODO(tasiaiso): split this function
 | 
			
		||||
	let session = getCookies(request.headers).session;
 | 
			
		||||
	
 | 
			
		||||
	if (request.uri == "/login") {
 | 
			
		||||
		let formData = form.decodeForm(request.query);
 | 
			
		||||
		if (query(request.headers)?.permissions?.authenticated) {
 | 
			
		||||
@@ -319,7 +300,7 @@ function handler(request, response) {
 | 
			
		||||
/**
 | 
			
		||||
 * Gets a user's permissions based on it's session ?
 | 
			
		||||
 * @param {*} session TODOC
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function getPermissions(session) {
 | 
			
		||||
	let permissions;
 | 
			
		||||
@@ -334,7 +315,7 @@ function getPermissions(session) {
 | 
			
		||||
/**
 | 
			
		||||
 * Get a user's permissions ?
 | 
			
		||||
 * @param {string} userName TODOC
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function getPermissionsForUser(userName) {
 | 
			
		||||
	let permissions = {};
 | 
			
		||||
@@ -348,8 +329,8 @@ function getPermissionsForUser(userName) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} headers 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} headers
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function query(headers) {
 | 
			
		||||
	let session = getCookies(headers).session;
 | 
			
		||||
@@ -366,7 +347,7 @@ function query(headers) {
 | 
			
		||||
/**
 | 
			
		||||
 * Refreshes a JWT ?
 | 
			
		||||
 * @param {*} credentials TODOC
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function makeRefresh(credentials) {
 | 
			
		||||
	if (credentials?.session?.name) {
 | 
			
		||||
@@ -377,4 +358,4 @@ function makeRefresh(credentials) {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export { handler, query, makeRefresh };
 | 
			
		||||
export {handler, query, makeRefresh};
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										162
									
								
								core/client.js
									
									
									
									
									
								
							
							
						
						
									
										162
									
								
								core/client.js
									
									
									
									
									
								
							@@ -69,7 +69,7 @@ class TfNavigationElement extends LitElement {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * TODOC
 | 
			
		||||
	 * @param {*} event 
 | 
			
		||||
	 * @param {*} event
 | 
			
		||||
	 */
 | 
			
		||||
	toggle_edit(event) {
 | 
			
		||||
		event.preventDefault();
 | 
			
		||||
@@ -82,7 +82,7 @@ class TfNavigationElement extends LitElement {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * TODOC
 | 
			
		||||
	 * @param {*} key 
 | 
			
		||||
	 * @param {*} key
 | 
			
		||||
	 */
 | 
			
		||||
	reset_permission(key) {
 | 
			
		||||
		send({action: "resetPermission", permission: key});
 | 
			
		||||
@@ -90,9 +90,9 @@ class TfNavigationElement extends LitElement {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * TODOC
 | 
			
		||||
	 * @param {*} key 
 | 
			
		||||
	 * @param {*} options 
 | 
			
		||||
	 * @returns 
 | 
			
		||||
	 * @param {*} key
 | 
			
		||||
	 * @param {*} options
 | 
			
		||||
	 * @returns
 | 
			
		||||
	 */
 | 
			
		||||
	get_spark_line(key, options) {
 | 
			
		||||
		if (!this.spark_lines[key]) {
 | 
			
		||||
@@ -114,7 +114,7 @@ class TfNavigationElement extends LitElement {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * TODOC
 | 
			
		||||
	 * @returns 
 | 
			
		||||
	 * @returns
 | 
			
		||||
	 */
 | 
			
		||||
	render_login() {
 | 
			
		||||
		if (this?.credentials?.session?.name) {
 | 
			
		||||
@@ -126,7 +126,7 @@ class TfNavigationElement extends LitElement {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * TODOC
 | 
			
		||||
	 * @returns 
 | 
			
		||||
	 * @returns
 | 
			
		||||
	 */
 | 
			
		||||
	render_permissions() {
 | 
			
		||||
		if (this.show_permissions) {
 | 
			
		||||
@@ -150,7 +150,7 @@ class TfNavigationElement extends LitElement {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * TODOC
 | 
			
		||||
	 * @returns 
 | 
			
		||||
	 * @returns
 | 
			
		||||
	 */
 | 
			
		||||
	render() {
 | 
			
		||||
		let self = this;
 | 
			
		||||
@@ -210,7 +210,7 @@ class TfFilesElement extends LitElement {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * TODOC
 | 
			
		||||
	 * @param {*} file 
 | 
			
		||||
	 * @param {*} file
 | 
			
		||||
	 */
 | 
			
		||||
	file_click(file) {
 | 
			
		||||
		this.dispatchEvent(new CustomEvent('file_click', {
 | 
			
		||||
@@ -224,8 +224,8 @@ class TfFilesElement extends LitElement {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * TODOC
 | 
			
		||||
	 * @param {*} file 
 | 
			
		||||
	 * @returns 
 | 
			
		||||
	 * @param {*} file
 | 
			
		||||
	 * @returns
 | 
			
		||||
	 */
 | 
			
		||||
	render_file(file) {
 | 
			
		||||
		let classes = ['file'];
 | 
			
		||||
@@ -240,7 +240,7 @@ class TfFilesElement extends LitElement {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * TODOC
 | 
			
		||||
	 * @param {*} event 
 | 
			
		||||
	 * @param {*} event
 | 
			
		||||
	 */
 | 
			
		||||
	async drop(event) {
 | 
			
		||||
		event.preventDefault();
 | 
			
		||||
@@ -262,7 +262,7 @@ class TfFilesElement extends LitElement {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * TODOC
 | 
			
		||||
	 * @param {*} event 
 | 
			
		||||
	 * @param {*} event
 | 
			
		||||
	 */
 | 
			
		||||
	drag_enter(event) {
 | 
			
		||||
		this.dropping++;
 | 
			
		||||
@@ -271,7 +271,7 @@ class TfFilesElement extends LitElement {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * TODOC
 | 
			
		||||
	 * @param {*} event 
 | 
			
		||||
	 * @param {*} event
 | 
			
		||||
	 */
 | 
			
		||||
	drag_leave(event) {
 | 
			
		||||
		this.dropping--;
 | 
			
		||||
@@ -279,7 +279,7 @@ class TfFilesElement extends LitElement {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * TODOC
 | 
			
		||||
	 * @returns 
 | 
			
		||||
	 * @returns
 | 
			
		||||
	 */
 | 
			
		||||
	render() {
 | 
			
		||||
		let self = this;
 | 
			
		||||
@@ -340,7 +340,7 @@ class TfFilesPaneElement extends LitElement {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * TODOC
 | 
			
		||||
	 * @param {*} expanded 
 | 
			
		||||
	 * @param {*} expanded
 | 
			
		||||
	 */
 | 
			
		||||
	set_expanded(expanded) {
 | 
			
		||||
		this.expanded = expanded;
 | 
			
		||||
@@ -349,7 +349,7 @@ class TfFilesPaneElement extends LitElement {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * TODOC
 | 
			
		||||
	 * @returns 
 | 
			
		||||
	 * @returns
 | 
			
		||||
	 */
 | 
			
		||||
	render() {
 | 
			
		||||
		let self = this;
 | 
			
		||||
@@ -398,8 +398,8 @@ class TfSparkLineElement extends LitElement {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * TODOC
 | 
			
		||||
	 * @param {*} key 
 | 
			
		||||
	 * @param {*} value 
 | 
			
		||||
	 * @param {*} key
 | 
			
		||||
	 * @param {*} value
 | 
			
		||||
	 */
 | 
			
		||||
	append(key, value) {
 | 
			
		||||
		let line = null;
 | 
			
		||||
@@ -427,8 +427,8 @@ class TfSparkLineElement extends LitElement {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * TODOC
 | 
			
		||||
	 * @param {*} line 
 | 
			
		||||
	 * @returns 
 | 
			
		||||
	 * @param {*} line
 | 
			
		||||
	 * @returns
 | 
			
		||||
	 */
 | 
			
		||||
	render_line(line) {
 | 
			
		||||
		if (line?.values?.length >= 2) {
 | 
			
		||||
@@ -440,7 +440,7 @@ class TfSparkLineElement extends LitElement {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * TODOC
 | 
			
		||||
	 * @returns 
 | 
			
		||||
	 * @returns
 | 
			
		||||
	 */
 | 
			
		||||
	render() {
 | 
			
		||||
		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);
 | 
			
		||||
 | 
			
		||||
// TODOC
 | 
			
		||||
window.addEventListener("keydown", function(event) {
 | 
			
		||||
window.addEventListener('keydown', function (event) {
 | 
			
		||||
	if (event.keyCode == 83 && (event.altKey || event.ctrlKey)) {
 | 
			
		||||
		if (editing()) {
 | 
			
		||||
			save();
 | 
			
		||||
@@ -472,9 +472,9 @@ window.addEventListener("keydown", function(event) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} nodes 
 | 
			
		||||
 * @param {*} callback 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} nodes
 | 
			
		||||
 * @param {*} callback
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function ensureLoaded(nodes, callback) {
 | 
			
		||||
	if (!nodes.length) {
 | 
			
		||||
@@ -515,7 +515,7 @@ function ensureLoaded(nodes, callback) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function editing() {
 | 
			
		||||
	return document.getElementById("editPane").style.display != 'none';
 | 
			
		||||
@@ -523,7 +523,7 @@ function editing() {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function is_edit_only() {
 | 
			
		||||
	return window.location.search == '?editonly=1' || window.innerWidth < 1024;
 | 
			
		||||
@@ -531,7 +531,7 @@ function is_edit_only() {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
async function edit() {
 | 
			
		||||
	if (editing()) {
 | 
			
		||||
@@ -564,8 +564,8 @@ function trace() {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} name 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} name
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function guessMode(name) {
 | 
			
		||||
	return name.endsWith(".js") ? "javascript" :
 | 
			
		||||
@@ -575,9 +575,9 @@ function guessMode(name) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} name 
 | 
			
		||||
 * @param {*} id 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} name
 | 
			
		||||
 * @param {*} id
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function loadFile(name, id) {
 | 
			
		||||
	return fetch('/' + id + '/view').then(function(response) {
 | 
			
		||||
@@ -597,8 +597,8 @@ function loadFile(name, id) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} path 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} path
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
async function load(path) {
 | 
			
		||||
	let response = await fetch((path || url()) + 'view');
 | 
			
		||||
@@ -648,7 +648,7 @@ function closeEditor() {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function explodePath() {
 | 
			
		||||
	return /^\/~([^\/]+)\/([^\/]+)(.*)/.exec(window.location.pathname);
 | 
			
		||||
@@ -656,8 +656,8 @@ function explodePath() {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} save_to 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} save_to
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function save(save_to) {
 | 
			
		||||
	document.getElementById("save").disabled = true;
 | 
			
		||||
@@ -775,7 +775,7 @@ function deleteApp() {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function url() {
 | 
			
		||||
	let hash = window.location.href.indexOf('#');
 | 
			
		||||
@@ -794,7 +794,7 @@ function url() {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function hash() {
 | 
			
		||||
	return window.location.hash != "#" ? window.location.hash : "";
 | 
			
		||||
@@ -802,7 +802,7 @@ function hash() {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} content 
 | 
			
		||||
 * @param {*} content
 | 
			
		||||
 */
 | 
			
		||||
function api_setDocument(content) {
 | 
			
		||||
	let iframe = document.getElementById("document");
 | 
			
		||||
@@ -811,7 +811,7 @@ function api_setDocument(content) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} message 
 | 
			
		||||
 * @param {*} message
 | 
			
		||||
 */
 | 
			
		||||
function api_postMessage(message) {
 | 
			
		||||
	let iframe = document.getElementById("document");
 | 
			
		||||
@@ -820,7 +820,7 @@ function api_postMessage(message) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} error 
 | 
			
		||||
 * @param {*} error
 | 
			
		||||
 */
 | 
			
		||||
function api_error(error) {
 | 
			
		||||
	if (error) {
 | 
			
		||||
@@ -835,8 +835,8 @@ function api_error(error) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} key 
 | 
			
		||||
 * @param {*} value 
 | 
			
		||||
 * @param {*} key
 | 
			
		||||
 * @param {*} value
 | 
			
		||||
 */
 | 
			
		||||
function api_localStorageSet(key, value) {
 | 
			
		||||
	window.localStorage.setItem('app:' + key, value);
 | 
			
		||||
@@ -844,8 +844,8 @@ function api_localStorageSet(key, value) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} key 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} key
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function api_localStorageGet(key) {
 | 
			
		||||
	return window.localStorage.getItem('app:' + key);
 | 
			
		||||
@@ -853,9 +853,9 @@ function api_localStorageGet(key) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} permission 
 | 
			
		||||
 * @param {*} id 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} permission
 | 
			
		||||
 * @param {*} id
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function api_requestPermission(permission, id) {
 | 
			
		||||
	let outer = document.createElement('div');
 | 
			
		||||
@@ -930,7 +930,7 @@ function api_print() {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} hash 
 | 
			
		||||
 * @param {*} hash
 | 
			
		||||
 */
 | 
			
		||||
function api_setHash(hash) {
 | 
			
		||||
	window.location.hash = hash;
 | 
			
		||||
@@ -938,7 +938,7 @@ function api_setHash(hash) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} message 
 | 
			
		||||
 * @param {*} message
 | 
			
		||||
 */
 | 
			
		||||
function _receive_websocket_message(message) {
 | 
			
		||||
	if (message && message.action == "session") {
 | 
			
		||||
@@ -1022,8 +1022,8 @@ function _receive_websocket_message(message) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} message 
 | 
			
		||||
 * @param {*} color 
 | 
			
		||||
 * @param {*} message
 | 
			
		||||
 * @param {*} color
 | 
			
		||||
 */
 | 
			
		||||
function setStatusMessage(message, color) {
 | 
			
		||||
	document.getElementsByTagName('tf-navigation')[0].status = {message: message, color: color};
 | 
			
		||||
@@ -1031,7 +1031,7 @@ function setStatusMessage(message, color) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} value 
 | 
			
		||||
 * @param {*} value
 | 
			
		||||
 */
 | 
			
		||||
function send(value) {
 | 
			
		||||
	try {
 | 
			
		||||
@@ -1045,10 +1045,10 @@ function send(value) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} sourceData 
 | 
			
		||||
 * @param {*} maxWidth 
 | 
			
		||||
 * @param {*} maxHeight 
 | 
			
		||||
 * @param {*} callback 
 | 
			
		||||
 * @param {*} sourceData
 | 
			
		||||
 * @param {*} maxWidth
 | 
			
		||||
 * @param {*} maxHeight
 | 
			
		||||
 * @param {*} callback
 | 
			
		||||
 */
 | 
			
		||||
function fixImage(sourceData, maxWidth, maxHeight, callback) {
 | 
			
		||||
	let result = sourceData;
 | 
			
		||||
@@ -1075,7 +1075,7 @@ function fixImage(sourceData, maxWidth, maxHeight, callback) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} image 
 | 
			
		||||
 * @param {*} image
 | 
			
		||||
 */
 | 
			
		||||
function sendImage(image) {
 | 
			
		||||
	fixImage(image, 320, 240, function(result) {
 | 
			
		||||
@@ -1112,7 +1112,7 @@ function blur() {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} event 
 | 
			
		||||
 * @param {*} event
 | 
			
		||||
 */
 | 
			
		||||
function message(event) {
 | 
			
		||||
	if (event.data && event.data.event == "resizeMe" && event.data.width && event.data.height) {
 | 
			
		||||
@@ -1144,7 +1144,7 @@ function message(event) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} path 
 | 
			
		||||
 * @param {*} path
 | 
			
		||||
 */
 | 
			
		||||
function reconnect(path) {
 | 
			
		||||
	let oldSocket = gSocket;
 | 
			
		||||
@@ -1160,7 +1160,7 @@ function reconnect(path) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} path 
 | 
			
		||||
 * @param {*} path
 | 
			
		||||
 */
 | 
			
		||||
function connectSocket(path) {
 | 
			
		||||
	if (!gSocket || gSocket.readyState != gSocket.OPEN) {
 | 
			
		||||
@@ -1215,7 +1215,7 @@ function connectSocket(path) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} name 
 | 
			
		||||
 * @param {*} name
 | 
			
		||||
 */
 | 
			
		||||
function openFile(name) {
 | 
			
		||||
	let newDoc = (name && gFiles[name]) ? gFiles[name].doc : cm6.EditorState.create({doc: "", extensions: cm6.extensions});
 | 
			
		||||
@@ -1249,7 +1249,7 @@ function updateFiles() {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} name 
 | 
			
		||||
 * @param {*} name
 | 
			
		||||
 */
 | 
			
		||||
function makeNewFile(name) {
 | 
			
		||||
	gFiles[name] = {
 | 
			
		||||
@@ -1305,9 +1305,9 @@ async function appExport() {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} name 
 | 
			
		||||
 * @param {*} file 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} name
 | 
			
		||||
 * @param {*} file
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
async function save_file_to_blob_id(name, file) {
 | 
			
		||||
	console.log(`Saving ${name}.`);
 | 
			
		||||
@@ -1383,7 +1383,7 @@ async function appImport() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
async function sourcePretty() {
 | 
			
		||||
	let prettier = (await import('/prettier/standalone.mjs')).default;
 | 
			
		||||
@@ -1393,7 +1393,11 @@ async function sourcePretty() {
 | 
			
		||||
	let formatted = await prettier.format(source, {
 | 
			
		||||
		parser: 'babel',
 | 
			
		||||
		plugins: [babel, estree],
 | 
			
		||||
		trailingComma: 'es5',
 | 
			
		||||
		useTabs: true,
 | 
			
		||||
		semi: true,
 | 
			
		||||
		singleQuote: true,
 | 
			
		||||
		bracketSpacing: false,
 | 
			
		||||
	});
 | 
			
		||||
	if (source !== formatted) {
 | 
			
		||||
		gEditor.dispatch({
 | 
			
		||||
@@ -1407,14 +1411,16 @@ async function sourcePretty() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// TODOC
 | 
			
		||||
window.addEventListener("load", function() {
 | 
			
		||||
	window.addEventListener("hashchange", hashChange);
 | 
			
		||||
	window.addEventListener("focus", focus);
 | 
			
		||||
	window.addEventListener("blur", blur);
 | 
			
		||||
	window.addEventListener("message", message, false);
 | 
			
		||||
	window.addEventListener("online", connectSocket);
 | 
			
		||||
	document.getElementById("name").value = window.location.pathname;
 | 
			
		||||
	document.getElementById('closeEditor').addEventListener('click', () => closeEditor());
 | 
			
		||||
window.addEventListener('load', function () {
 | 
			
		||||
	window.addEventListener('hashchange', hashChange);
 | 
			
		||||
	window.addEventListener('focus', focus);
 | 
			
		||||
	window.addEventListener('blur', blur);
 | 
			
		||||
	window.addEventListener('message', message, false);
 | 
			
		||||
	window.addEventListener('online', connectSocket);
 | 
			
		||||
	document.getElementById('name').value = window.location.pathname;
 | 
			
		||||
	document
 | 
			
		||||
		.getElementById('closeEditor')
 | 
			
		||||
		.addEventListener('click', () => closeEditor());
 | 
			
		||||
	document.getElementById('save').addEventListener('click', () => save());
 | 
			
		||||
	document.getElementById('icon').addEventListener('click', () => changeIcon());
 | 
			
		||||
	document.getElementById('delete').addEventListener('click', () => deleteApp());
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										128
									
								
								core/core.js
									
									
									
									
									
								
							
							
						
						
									
										128
									
								
								core/core.js
									
									
									
									
									
								
							@@ -93,8 +93,8 @@ let kPingInterval = 60 * 1000;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} out 
 | 
			
		||||
 * @param {*} error 
 | 
			
		||||
 * @param {*} out
 | 
			
		||||
 * @param {*} error
 | 
			
		||||
 */
 | 
			
		||||
function printError(out, error) {
 | 
			
		||||
	if (error.stackTrace) {
 | 
			
		||||
@@ -110,9 +110,9 @@ function printError(out, error) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} handlers 
 | 
			
		||||
 * @param {*} argv 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} handlers
 | 
			
		||||
 * @param {*} argv
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function invoke(handlers, argv) {
 | 
			
		||||
	let promises = [];
 | 
			
		||||
@@ -132,9 +132,9 @@ function invoke(handlers, argv) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} eventName 
 | 
			
		||||
 * @param {*} argv 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} eventName
 | 
			
		||||
 * @param {*} argv
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function broadcastEvent(eventName, argv) {
 | 
			
		||||
	let promises = [];
 | 
			
		||||
@@ -147,8 +147,8 @@ function broadcastEvent(eventName, argv) {
 | 
			
		||||
}
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} message 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} message
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function broadcast(message) {
 | 
			
		||||
	let sender = this;
 | 
			
		||||
@@ -166,9 +166,9 @@ function broadcast(message) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} caller 
 | 
			
		||||
 * @param {*} process 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} caller
 | 
			
		||||
 * @param {*} process
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function getUser(caller, process) {
 | 
			
		||||
	return {
 | 
			
		||||
@@ -182,9 +182,9 @@ function getUser(caller, process) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} user 
 | 
			
		||||
 * @param {*} process 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} user
 | 
			
		||||
 * @param {*} process
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function getApps(user, process) {
 | 
			
		||||
	if (process.credentials &&
 | 
			
		||||
@@ -209,10 +209,10 @@ function getApps(user, process) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} from 
 | 
			
		||||
 * @param {*} to 
 | 
			
		||||
 * @param {*} message 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} from
 | 
			
		||||
 * @param {*} to
 | 
			
		||||
 * @param {*} message
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function postMessageInternal(from, to, message) {
 | 
			
		||||
	if (to.eventHandlers['message']) {
 | 
			
		||||
@@ -222,10 +222,10 @@ function postMessageInternal(from, to, message) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} blobId 
 | 
			
		||||
 * @param {*} session 
 | 
			
		||||
 * @param {*} options 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} blobId
 | 
			
		||||
 * @param {*} session
 | 
			
		||||
 * @param {*} options
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
async function getSessionProcessBlob(blobId, session, options) {
 | 
			
		||||
	let actualOptions = {timeout: kPingInterval};
 | 
			
		||||
@@ -239,10 +239,10 @@ async function getSessionProcessBlob(blobId, session, options) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} blobId 
 | 
			
		||||
 * @param {*} key 
 | 
			
		||||
 * @param {*} options 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} blobId
 | 
			
		||||
 * @param {*} key
 | 
			
		||||
 * @param {*} options
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
async function getProcessBlob(blobId, key, options) {
 | 
			
		||||
	// TODO(tasiaiso): break this down ?
 | 
			
		||||
@@ -592,8 +592,8 @@ async function getProcessBlob(blobId, key, options) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} settings 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} settings
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function setGlobalSettings(settings) {
 | 
			
		||||
	gGlobalSettings = settings;
 | 
			
		||||
@@ -606,9 +606,9 @@ function setGlobalSettings(settings) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} data 
 | 
			
		||||
 * @param {*} bytes 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} data
 | 
			
		||||
 * @param {*} bytes
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function startsWithBytes(data, bytes) {
 | 
			
		||||
	if (data.byteLength >= bytes.length) {
 | 
			
		||||
@@ -624,8 +624,8 @@ function startsWithBytes(data, bytes) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} path 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} path
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function guessTypeFromName(path) {
 | 
			
		||||
	let extension = path.split('.').pop();
 | 
			
		||||
@@ -634,8 +634,8 @@ function guessTypeFromName(path) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} data 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} data
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function guessTypeFromMagicBytes(data) {
 | 
			
		||||
	for (let magic of k_magic_bytes) {
 | 
			
		||||
@@ -647,11 +647,11 @@ function guessTypeFromMagicBytes(data) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} response 
 | 
			
		||||
 * @param {*} data 
 | 
			
		||||
 * @param {*} type 
 | 
			
		||||
 * @param {*} headers 
 | 
			
		||||
 * @param {*} status_code 
 | 
			
		||||
 * @param {*} response
 | 
			
		||||
 * @param {*} data
 | 
			
		||||
 * @param {*} type
 | 
			
		||||
 * @param {*} headers
 | 
			
		||||
 * @param {*} status_code
 | 
			
		||||
 */
 | 
			
		||||
function sendData(response, data, type, headers, status_code) {
 | 
			
		||||
	if (data) {
 | 
			
		||||
@@ -665,8 +665,8 @@ function sendData(response, data, type, headers, status_code) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} id 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} id
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
async function getBlobOrContent(id) {
 | 
			
		||||
	if (!id) {
 | 
			
		||||
@@ -682,14 +682,14 @@ let g_handler_index = 0;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} response 
 | 
			
		||||
 * @param {*} handler_blob_id 
 | 
			
		||||
 * @param {*} path 
 | 
			
		||||
 * @param {*} query 
 | 
			
		||||
 * @param {*} headers 
 | 
			
		||||
 * @param {*} packageOwner 
 | 
			
		||||
 * @param {*} packageName 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} response
 | 
			
		||||
 * @param {*} handler_blob_id
 | 
			
		||||
 * @param {*} path
 | 
			
		||||
 * @param {*} query
 | 
			
		||||
 * @param {*} headers
 | 
			
		||||
 * @param {*} packageOwner
 | 
			
		||||
 * @param {*} packageName
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
async function useAppHandler(response, handler_blob_id, path, query, headers, packageOwner, packageName) {
 | 
			
		||||
	print('useAppHandler', packageOwner, packageName);
 | 
			
		||||
@@ -726,11 +726,11 @@ async function useAppHandler(response, handler_blob_id, path, query, headers, pa
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} request 
 | 
			
		||||
 * @param {*} response 
 | 
			
		||||
 * @param {*} blobId 
 | 
			
		||||
 * @param {*} uri 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} request
 | 
			
		||||
 * @param {*} response
 | 
			
		||||
 * @param {*} blobId
 | 
			
		||||
 * @param {*} uri
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
async function blobHandler(request, response, blobId, uri) {
 | 
			
		||||
	// TODO(tasiaiso): break this down ?
 | 
			
		||||
@@ -1000,8 +1000,8 @@ function sendStats() {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} process 
 | 
			
		||||
 * @param {*} enabled 
 | 
			
		||||
 * @param {*} process
 | 
			
		||||
 * @param {*} enabled
 | 
			
		||||
 */
 | 
			
		||||
function enableStats(process, enabled) {
 | 
			
		||||
	process.stats = enabled;
 | 
			
		||||
@@ -1081,11 +1081,11 @@ loadSettings().then(function() {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} user 
 | 
			
		||||
 * @param {*} packageOwner 
 | 
			
		||||
 * @param {*} packageName 
 | 
			
		||||
 * @param {*} permission 
 | 
			
		||||
 * @param {*} allow 
 | 
			
		||||
 * @param {*} user
 | 
			
		||||
 * @param {*} packageOwner
 | 
			
		||||
 * @param {*} packageName
 | 
			
		||||
 * @param {*} permission
 | 
			
		||||
 * @param {*} allow
 | 
			
		||||
 */
 | 
			
		||||
function storePermission(user, packageOwner, packageName, permission, allow) {
 | 
			
		||||
	if (!gGlobalSettings.userPermissions) {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										10
									
								
								core/form.js
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								core/form.js
									
									
									
									
									
								
							@@ -1,7 +1,7 @@
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} encoded 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} encoded
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function decode(encoded) {
 | 
			
		||||
	let result = "";
 | 
			
		||||
@@ -21,9 +21,9 @@ function decode(encoded) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} encoded 
 | 
			
		||||
 * @param {*} initial 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} encoded
 | 
			
		||||
 * @param {*} initial
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function decodeForm(encoded, initial) {
 | 
			
		||||
	let result = initial || {};
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										16
									
								
								core/http.js
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								core/http.js
									
									
									
									
									
								
							@@ -1,8 +1,8 @@
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * TODO: document so we can improve this
 | 
			
		||||
 * @param {*} url 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} url
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function parseUrl(url) {
 | 
			
		||||
	// XXX: Hack.
 | 
			
		||||
@@ -17,8 +17,8 @@ function parseUrl(url) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} data 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} data
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function parseResponse(data) {
 | 
			
		||||
	let firstLine;
 | 
			
		||||
@@ -41,10 +41,10 @@ function parseResponse(data) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} url 
 | 
			
		||||
 * @param {*} options 
 | 
			
		||||
 * @param {*} allowed_hosts 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} url
 | 
			
		||||
 * @param {*} options
 | 
			
		||||
 * @param {*} allowed_hosts
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
export function fetch(url, options, allowed_hosts) {
 | 
			
		||||
	let parsed = parseUrl(url);
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,7 @@ let g_calls = {};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function get_is_browser() {
 | 
			
		||||
	try { return window !== undefined && console !== undefined; } catch { return false; }
 | 
			
		||||
@@ -17,10 +17,10 @@ if (k_is_browser) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} target 
 | 
			
		||||
 * @param {*} prop 
 | 
			
		||||
 * @param {*} receiver 
 | 
			
		||||
 * @returns 
 | 
			
		||||
 * @param {*} target
 | 
			
		||||
 * @param {*} prop
 | 
			
		||||
 * @param {*} receiver
 | 
			
		||||
 * @returns
 | 
			
		||||
 */
 | 
			
		||||
function make_rpc(target, prop, receiver) {
 | 
			
		||||
	return function() {
 | 
			
		||||
@@ -42,7 +42,7 @@ function make_rpc(target, prop, receiver) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} response 
 | 
			
		||||
 * @param {*} response
 | 
			
		||||
 */
 | 
			
		||||
function send(response) {
 | 
			
		||||
	if (k_is_browser) {
 | 
			
		||||
@@ -54,7 +54,7 @@ function send(response) {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} message 
 | 
			
		||||
 * @param {*} message
 | 
			
		||||
 */
 | 
			
		||||
function call_rpc(message) {
 | 
			
		||||
	if (message && message.message === 'tfrpc') {
 | 
			
		||||
@@ -106,7 +106,7 @@ export let rpc = new Proxy({}, {get: make_rpc});
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODOC
 | 
			
		||||
 * @param {*} method 
 | 
			
		||||
 * @param {*} method
 | 
			
		||||
 */
 | 
			
		||||
export function register(method) {
 | 
			
		||||
	g_api[method.name] = method;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										27
									
								
								package-lock.json
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								package-lock.json
									
									
									
										generated
									
									
									
										Normal 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
									
								
							
							
						
						
									
										11
									
								
								package.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
{
 | 
			
		||||
	"name": "tildefriends",
 | 
			
		||||
	"scripts": {
 | 
			
		||||
		"prettier": "prettier . --check --cache --write"
 | 
			
		||||
	},
 | 
			
		||||
	"author": "Cory McWilliams",
 | 
			
		||||
	"license": "MIT",
 | 
			
		||||
	"dependencies": {
 | 
			
		||||
		"prettier": "^3.2.5"
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user