aboutsummaryrefslogtreecommitdiff
path: root/ext/js/app/popup.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/app/popup.js')
-rw-r--r--ext/js/app/popup.js32
1 files changed, 17 insertions, 15 deletions
diff --git a/ext/js/app/popup.js b/ext/js/app/popup.js
index a8cdf1a6..0f7fbd87 100644
--- a/ext/js/app/popup.js
+++ b/ext/js/app/popup.js
@@ -316,7 +316,7 @@ export class Popup extends EventDispatcher {
*/
async clearAutoPlayTimer() {
if (this._frameConnected) {
- await this._invokeSafe('displayAudioClearAutoPlayTimer', {});
+ await this._invokeSafe('displayAudioClearAutoPlayTimer', void 0);
}
}
@@ -679,13 +679,11 @@ export class Popup extends EventDispatcher {
}
}
- // TODO : Type safety
/**
- * @template {import('core').SerializableObject} TParams
- * @template [TReturn=unknown]
- * @param {string} action
- * @param {TParams} params
- * @returns {Promise<TReturn>}
+ * @template {import('display').DirectApiNames} TName
+ * @param {TName} action
+ * @param {import('display').DirectApiParams<TName>} params
+ * @returns {Promise<import('display').DirectApiReturn<TName>>}
*/
async _invoke(action, params) {
const contentWindow = this._frame.contentWindow;
@@ -693,17 +691,21 @@ export class Popup extends EventDispatcher {
throw new Error(`Failed to invoke action ${action}: frame state invalid`);
}
- const message = this._frameClient.createMessage({action, params});
- return await yomitan.crossFrame.invoke(this._frameClient.frameId, 'popupMessage', message);
+ /** @type {import('display').DirectApiMessage<TName>} */
+ const message = {action, params};
+ const wrappedMessage = this._frameClient.createMessage(message);
+ return /** @type {import('display').DirectApiReturn<TName>} */ (await yomitan.crossFrame.invoke(
+ this._frameClient.frameId,
+ 'displayPopupMessage1',
+ /** @type {import('display').DirectApiFrameClientMessageAny} */ (wrappedMessage)
+ ));
}
- // TODO : Type safety
/**
- * @template {import('core').SerializableObject} TParams
- * @template [TReturn=unknown]
- * @param {string} action
- * @param {TParams} params
- * @returns {Promise<TReturn|undefined>}
+ * @template {import('display').DirectApiNames} TName
+ * @param {TName} action
+ * @param {import('display').DirectApiParams<TName>} params
+ * @returns {Promise<import('display').DirectApiReturn<TName>|undefined>}
*/
async _invokeSafe(action, params) {
try {