doc: add JSDoc annotations in the core folder

start documenting a bit, mostly inconsequential changes
This commit is contained in:
2024-02-19 19:12:42 +01:00
parent 4f869252a2
commit ce5ca1875b
7 changed files with 600 additions and 12 deletions

View File

@ -3,6 +3,10 @@ let g_api = {};
let g_next_id = 1;
let g_calls = {};
/**
* TODOC
* @returns
*/
function get_is_browser() {
try { return window !== undefined && console !== undefined; } catch { return false; }
}
@ -11,6 +15,13 @@ if (k_is_browser) {
print = console.log;
}
/**
* TODOC
* @param {*} target
* @param {*} prop
* @param {*} receiver
* @returns
*/
function make_rpc(target, prop, receiver) {
return function() {
let id = g_next_id++;
@ -29,6 +40,10 @@ function make_rpc(target, prop, receiver) {
}
}
/**
* TODOC
* @param {*} response
*/
function send(response) {
if (k_is_browser) {
window.parent.postMessage(response, '*');
@ -37,6 +52,10 @@ function send(response) {
}
}
/**
* TODOC
* @param {*} message
*/
function call_rpc(message) {
if (message && message.message === 'tfrpc') {
let id = message.id;
@ -85,6 +104,10 @@ if (k_is_browser) {
export let rpc = new Proxy({}, {get: make_rpc});
/**
* TODOC
* @param {*} method
*/
export function register(method) {
g_api[method.name] = method;
}