diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2024-02-20 10:12:27 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-20 15:12:27 +0000 |
commit | 0e4ae922451af967c78616057ed26b85ba5d4b5c (patch) | |
tree | 8f1aed3d93e9c6e99e6c55e846b29d8dc154e113 /ext/js/app | |
parent | 088c6c17ac7b6076604fd3bc40287d4afda0d940 (diff) |
Popup preview frame API map (#712)
* Add API map type safety
* Add API map types
* Simplify names
* Remove unused type
Diffstat (limited to 'ext/js/app')
-rw-r--r-- | ext/js/app/popup.js | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/ext/js/app/popup.js b/ext/js/app/popup.js index 7a8b3f8c..4caf8241 100644 --- a/ext/js/app/popup.js +++ b/ext/js/app/popup.js @@ -722,22 +722,25 @@ export class Popup extends EventDispatcher { } /** - * @param {string} action - * @param {import('core').SerializableObject} params + * @template {import('display').WindowApiNames} TName + * @param {TName} action + * @param {import('display').WindowApiParams<TName>} params */ - _invokeWindow(action, params = {}) { + _invokeWindow(action, params) { const contentWindow = this._frame.contentWindow; if (this._frameClient === null || !this._frameClient.isConnected() || contentWindow === null) { return; } - const message = this._frameClient.createMessage({action, params}); - contentWindow.postMessage(message, this._targetOrigin); + /** @type {import('display').WindowApiMessage<TName>} */ + const message = {action, params}; + const messageWrapper = this._frameClient.createMessage(message); + contentWindow.postMessage(messageWrapper, this._targetOrigin); } /** * @returns {void} */ _onExtensionUnloaded() { - this._invokeWindow('displayExtensionUnloaded'); + this._invokeWindow('displayExtensionUnloaded', void 0); } /** |