aboutsummaryrefslogtreecommitdiff
path: root/ext/js/app/popup-window.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/app/popup-window.js')
-rw-r--r--ext/js/app/popup-window.js34
1 files changed, 22 insertions, 12 deletions
diff --git a/ext/js/app/popup-window.js b/ext/js/app/popup-window.js
index 801afb3f..a696885a 100644
--- a/ext/js/app/popup-window.js
+++ b/ext/js/app/popup-window.js
@@ -126,7 +126,7 @@ export class PopupWindow extends EventDispatcher {
* @returns {Promise<void>}
*/
async setOptionsContext(optionsContext) {
- await this._invoke(false, 'displaySetOptionsContext', {id: this._id, optionsContext});
+ await this._invoke(false, 'displaySetOptionsContext', {optionsContext});
}
/**
@@ -183,7 +183,7 @@ export class PopupWindow extends EventDispatcher {
*/
async showContent(_details, displayDetails) {
if (displayDetails === null) { return; }
- await this._invoke(true, 'displaySetContent', {id: this._id, details: displayDetails});
+ await this._invoke(true, 'displaySetContent', {details: displayDetails});
}
/**
@@ -192,7 +192,7 @@ export class PopupWindow extends EventDispatcher {
* @returns {Promise<void>}
*/
async setCustomCss(css) {
- await this._invoke(false, 'displaySetCustomCss', {id: this._id, css});
+ await this._invoke(false, 'displaySetCustomCss', {css});
}
/**
@@ -200,7 +200,7 @@ export class PopupWindow extends EventDispatcher {
* @returns {Promise<void>}
*/
async clearAutoPlayTimer() {
- await this._invoke(false, 'displayAudioClearAutoPlayTimer', {id: this._id});
+ await this._invoke(false, 'displayAudioClearAutoPlayTimer', void 0);
}
/**
@@ -266,24 +266,29 @@ export class PopupWindow extends EventDispatcher {
// Private
- // TODO : Type safety
/**
- * @template {import('core').SerializableObject} TParams
- * @template [TReturn=unknown]
+ * @template {import('display').DirectApiNames} TName
* @param {boolean} open
- * @param {string} action
- * @param {TParams} params
- * @returns {Promise<TReturn|undefined>}
+ * @param {TName} action
+ * @param {import('display').DirectApiParams<TName>} params
+ * @returns {Promise<import('display').DirectApiReturn<TName>|undefined>}
*/
async _invoke(open, action, params) {
if (yomitan.isExtensionUnloaded) {
return void 0;
}
+ const message = /** @type {import('display').DirectApiMessageAny} */ ({action, params});
+
const frameId = 0;
if (this._popupTabId !== null) {
try {
- return await yomitan.crossFrame.invokeTab(this._popupTabId, frameId, 'popupMessage', {action, params});
+ return /** @type {import('display').DirectApiReturn<TName>} */ (await yomitan.crossFrame.invokeTab(
+ this._popupTabId,
+ frameId,
+ 'displayPopupMessage2',
+ message
+ ));
} catch (e) {
if (yomitan.isExtensionUnloaded) {
open = false;
@@ -299,6 +304,11 @@ export class PopupWindow extends EventDispatcher {
const {tabId} = await yomitan.api.getOrCreateSearchPopup({focus: 'ifCreated'});
this._popupTabId = tabId;
- return await yomitan.crossFrame.invokeTab(this._popupTabId, frameId, 'popupMessage', {action, params});
+ return /** @type {import('display').DirectApiReturn<TName>} */ (await yomitan.crossFrame.invokeTab(
+ this._popupTabId,
+ frameId,
+ 'displayPopupMessage2',
+ message
+ ));
}
}