docs: Expose the rest of the core js to doxygen.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 31m35s

This commit is contained in:
2025-07-27 21:48:18 -04:00
parent e4729b22f2
commit 705e8b553f
4 changed files with 248 additions and 227 deletions

View File

@@ -1,12 +1,17 @@
/**
** \defgroup tfcore Tilde Friends Core JS
** Tilde Friends process management, in JavaScript.
** @{
*/
* \file
* \defgroup tfcore Tilde Friends Core JS
* Tilde Friends process management, in JavaScript.
* @{
*/
/** \cond */
import * as app from './app.js';
import * as http from './http.js';
export {invoke, getProcessBlob};
/** \endcond */
/** All running processes. */
let gProcesses = {};
/** Whether stats are currently being sent. */
@@ -17,9 +22,9 @@ let g_handler_index = 0;
const k_ping_interval = 60 * 1000;
/**
** Print an error.
** @param error The error.
*/
* Print an error.
* @param error The error.
*/
function printError(error) {
if (error.stackTrace) {
print(error.fileName + ':' + error.lineNumber + ': ' + error.message);
@@ -33,11 +38,11 @@ function printError(error) {
}
/**
** Invoke a handler.
** @param handlers The handlers on which to invoke the callback.
** @param argv Arguments to pass to the handlers.
** @return A promise.
*/
* Invoke a handler.
* @param handlers The handlers on which to invoke the callback.
* @param argv Arguments to pass to the handlers.
* @return A promise.
*/
function invoke(handlers, argv) {
let promises = [];
if (handlers) {
@@ -59,11 +64,11 @@ function invoke(handlers, argv) {
}
/**
** Broadcast a named event to all registered apps.
** @param eventName the name of the event.
** @param argv Arguments to pass to the handlers.
** @return A promise.
*/
* Broadcast a named event to all registered apps.
* @param eventName the name of the event.
* @param argv Arguments to pass to the handlers.
* @return A promise.
*/
function broadcastEvent(eventName, argv) {
let promises = [];
for (let process of Object.values(gProcesses)) {
@@ -75,10 +80,10 @@ function broadcastEvent(eventName, argv) {
}
/**
** Send a message to all other instances of the same app.
** @param message The message.
** @return A promise.
*/
* Send a message to all other instances of the same app.
* @param message The message.
* @return A promise.
*/
function broadcast(message) {
let sender = this;
let promises = [];
@@ -96,14 +101,14 @@ function broadcast(message) {
}
/**
** Send a message to all instances of the same app running as the same user.
** @param user The user.
** @param packageOwner The owner of the app.
** @param packageName The name of the app.
** @param eventName The name of the event.
** @param argv The arguments to pass.
** @return A promise.
*/
* Send a message to all instances of the same app running as the same user.
* @param user The user.
* @param packageOwner The owner of the app.
* @param packageName The name of the app.
* @param eventName The name of the event.
* @param argv The arguments to pass.
* @return A promise.
*/
function broadcastAppEventToUser(
user,
packageOwner,
@@ -127,10 +132,10 @@ function broadcastAppEventToUser(
}
/**
** Get user context information for a call.
** @param caller The calling process.
** @param process The receiving process.
*/
* Get user context information for a call.
* @param caller The calling process.
* @param process The receiving process.
*/
function getUser(caller, process) {
return {
key: process.key,
@@ -142,12 +147,12 @@ function getUser(caller, process) {
}
/**
** Send a message.
** @param from The calling process.
** @param to The receiving process.
** @param message The message.
** @return A promise.
*/
* Send a message.
* @param from The calling process.
* @param to The receiving process.
* @param message The message.
* @return A promise.
*/
function postMessageInternal(from, to, message) {
if (to.eventHandlers['message']) {
return invoke(to.eventHandlers['message'], [getUser(from, from), message]);
@@ -155,12 +160,12 @@ function postMessageInternal(from, to, message) {
}
/**
** Get or create a process for an app blob.
** @param blobId The blob identifier.
** @param key A unique key for the invocation.
** @param options Other options.
** @return The process.
*/
* Get or create a process for an app blob.
* @param blobId The blob identifier.
* @param key A unique key for the invocation.
* @param options Other options.
* @return The process.
*/
async function getProcessBlob(blobId, key, options) {
let process = gProcesses[key];
if (!process && !(options && 'create' in options && !options.create)) {
@@ -711,9 +716,9 @@ ssb.addEventListener('connections', function () {
});
/**
** Load settings from the database.
** @return The settings as a key value pairs object.
*/
* Load settings from the database.
* @return The settings as a key value pairs object.
*/
async function loadSettings() {
let data = {};
try {
@@ -733,8 +738,8 @@ async function loadSettings() {
}
/**
** Send periodic stats to all clients.
*/
* Send periodic stats to all clients.
*/
function sendStats() {
let apps = Object.values(gProcesses)
.filter((process) => process.app)
@@ -751,15 +756,15 @@ function sendStats() {
}
/**
** Invoke an app's handler.js.
** @param response The response object.
** @param app_blob_id The app's blob identifier.
** @param path The request path.
** @param query The request query string.
** @param headers The request headers.
** @param package_owner The app's owner.
** @param package_name The app's name.
*/
* Invoke an app's handler.js.
* @param response The response object.
* @param app_blob_id The app's blob identifier.
* @param path The request path.
* @param query The request query string.
* @param headers The request headers.
* @param package_owner The app's owner.
* @param package_name The app's name.
*/
exports.callAppHandler = async function callAppHandler(
response,
app_blob_id,
@@ -826,5 +831,3 @@ exports.callAppHandler = async function callAppHandler(
};
/** @} */
export { invoke, getProcessBlob };