aboutsummaryrefslogtreecommitdiff
path: root/ext/js/core.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-12-29 19:17:46 -0500
committerGitHub <noreply@github.com>2023-12-30 00:17:46 +0000
commit7303da3991814a0ce220bf2fff3e51b968913b86 (patch)
tree809c289d824ec2a08c5ff54579766b7f5c5e09e1 /ext/js/core.js
parent1b0e0c551d1505ed4242c04ebac224e5fff81f04 (diff)
Cross frame API safety (#491)
* Require error type * Add TODOs * Fix init * Updates * More type safety * Fix incorrect API map * Update type safety * Updates * Add API * Update types * Update types * Updates * Remove unused * Restore types * Update frame ancestry handler * Simplify names * Fix * Remove old message handlers
Diffstat (limited to 'ext/js/core.js')
-rw-r--r--ext/js/core.js32
1 files changed, 0 insertions, 32 deletions
diff --git a/ext/js/core.js b/ext/js/core.js
index c9c989ac..726b037c 100644
--- a/ext/js/core.js
+++ b/ext/js/core.js
@@ -321,38 +321,6 @@ export function promiseAnimationFrame(timeout) {
}
/**
- * Invokes a standard message handler. This function is used to react and respond
- * to communication messages within the extension.
- * @template {import('core').SafeAny} TParams
- * @param {import('core').MessageHandler} handler The message handler function.
- * @param {TParams} params Information which was passed with the original message.
- * @param {(response: import('core').Response) => void} callback A callback function which is invoked after the handler has completed. The value passed
- * to the function is in the format:
- * - `{result: unknown}` if the handler invoked successfully.
- * - `{error: object}` if the handler thew an error. The error is serialized.
- * @param {...*} extraArgs Additional arguments which are passed to the `handler` function.
- * @returns {boolean} `true` if the function is invoked asynchronously, `false` otherwise.
- */
-export function invokeMessageHandler(handler, params, callback, ...extraArgs) {
- try {
- const promiseOrResult = handler(params, ...extraArgs);
- if (promiseOrResult instanceof Promise) {
- /** @type {Promise<any>} */ (promiseOrResult).then(
- (result) => { callback({result}); },
- (error) => { callback({error: ExtensionError.serialize(error)}); }
- );
- return true;
- } else {
- callback({result: promiseOrResult});
- return false;
- }
- } catch (error) {
- callback({error: ExtensionError.serialize(error)});
- return false;
- }
-}
-
-/**
* The following typedef is required because the JSDoc `implements` tag doesn't work with `import()`.
* https://github.com/microsoft/TypeScript/issues/49905
* @typedef {import('core').EventDispatcherOffGeneric} EventDispatcherOffGeneric