diff options
| author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-11-21 15:54:58 -0500 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-21 15:54:58 -0500 | 
| commit | 005f9658d98143ea1189482ae627405c8bf5a566 (patch) | |
| tree | 712732685dd3300ad9403f17d2937486e3835661 | |
| parent | 06e70c1cd8a6e23b54ba9081caf82902820ceccd (diff) | |
Action handler name disambiguation (#2018)
* Disambiguate PopupFactory action handlers
* Update HotkeyHandler action names
* Disambiguate Frontend action handlers
* Disambiguate Display action handlers
* Disambiguate PopupPreviewFrame action handlers
* Disambiguate Yomichan action handlers
* Disambiguate Frontend action handlers
* Disambiguate Display action handlers
* Disambiguate SearchDisplayController action handlers
| -rw-r--r-- | ext/js/app/frontend.js | 22 | ||||
| -rw-r--r-- | ext/js/app/popup-factory.js | 32 | ||||
| -rw-r--r-- | ext/js/app/popup-proxy.js | 28 | ||||
| -rw-r--r-- | ext/js/app/popup-window.js | 8 | ||||
| -rw-r--r-- | ext/js/app/popup.js | 16 | ||||
| -rw-r--r-- | ext/js/background/backend.js | 26 | ||||
| -rw-r--r-- | ext/js/display/display-audio.js | 2 | ||||
| -rw-r--r-- | ext/js/display/display-resizer.js | 4 | ||||
| -rw-r--r-- | ext/js/display/display.js | 20 | ||||
| -rw-r--r-- | ext/js/display/search-display-controller.js | 6 | ||||
| -rw-r--r-- | ext/js/input/hotkey-handler.js | 2 | ||||
| -rw-r--r-- | ext/js/pages/settings/popup-preview-controller.js | 6 | ||||
| -rw-r--r-- | ext/js/pages/settings/popup-preview-frame.js | 8 | ||||
| -rw-r--r-- | ext/js/yomichan.js | 12 | 
14 files changed, 96 insertions, 96 deletions
| diff --git a/ext/js/app/frontend.js b/ext/js/app/frontend.js index 0f72e06b..3b482ad2 100644 --- a/ext/js/app/frontend.js +++ b/ext/js/app/frontend.js @@ -92,9 +92,9 @@ class Frontend {          this._optionsContextOverride = null;          this._runtimeMessageHandlers = new Map([ -            ['requestFrontendReadyBroadcast', {async: false, handler: this._onMessageRequestFrontendReadyBroadcast.bind(this)}], -            ['setAllVisibleOverride',         {async: true,  handler: this._onApiSetAllVisibleOverride.bind(this)}], -            ['clearAllVisibleOverride',       {async: true,  handler: this._onApiClearAllVisibleOverride.bind(this)}] +            ['Frontend.requestReadyBroadcast',   {async: false, handler: this._onMessageRequestFrontendReadyBroadcast.bind(this)}], +            ['Frontend.setAllVisibleOverride',   {async: true,  handler: this._onApiSetAllVisibleOverride.bind(this)}], +            ['Frontend.clearAllVisibleOverride', {async: true,  handler: this._onApiClearAllVisibleOverride.bind(this)}]          ]);          this._hotkeyHandler.registerActions([ @@ -159,11 +159,11 @@ class Frontend {          this._textScanner.on('searched', this._onSearched.bind(this));          yomichan.crossFrame.registerHandlers([ -            ['closePopup',              {async: false, handler: this._onApiClosePopup.bind(this)}], -            ['copySelection',           {async: false, handler: this._onApiCopySelection.bind(this)}], -            ['getSelectionText',        {async: false, handler: this._onApiGetSelectionText.bind(this)}], -            ['getPopupInfo',            {async: false, handler: this._onApiGetPopupInfo.bind(this)}], -            ['getPageInfo',             {async: false, handler: this._onApiGetPageInfo.bind(this)}] +            ['Frontend.closePopup',       {async: false, handler: this._onApiClosePopup.bind(this)}], +            ['Frontend.copySelection',    {async: false, handler: this._onApiCopySelection.bind(this)}], +            ['Frontend.getSelectionText', {async: false, handler: this._onApiGetSelectionText.bind(this)}], +            ['Frontend.getPopupInfo',     {async: false, handler: this._onApiGetPopupInfo.bind(this)}], +            ['Frontend.getPageInfo',      {async: false, handler: this._onApiGetPageInfo.bind(this)}]          ]);          this._updateContentScale(); @@ -509,7 +509,7 @@ class Frontend {              return await this._getDefaultPopup();          } -        const {popupId} = await yomichan.crossFrame.invoke(targetFrameId, 'getPopupInfo'); +        const {popupId} = await yomichan.crossFrame.invoke(targetFrameId, 'Frontend.getPopupInfo');          if (popupId === null) {              return null;          } @@ -702,7 +702,7 @@ class Frontend {              }              chrome.runtime.onMessage.addListener(onMessage); -            yomichan.api.broadcastTab('requestFrontendReadyBroadcast', {frameId: this._frameId}); +            yomichan.api.broadcastTab('Frontend.requestReadyBroadcast', {frameId: this._frameId});          });      } @@ -728,7 +728,7 @@ class Frontend {          let documentTitle = document.title;          if (this._useProxyPopup) {              try { -                ({url, documentTitle} = await yomichan.crossFrame.invoke(this._parentFrameId, 'getPageInfo', {})); +                ({url, documentTitle} = await yomichan.crossFrame.invoke(this._parentFrameId, 'Frontend.getPageInfo', {}));              } catch (e) {                  // NOP              } diff --git a/ext/js/app/popup-factory.js b/ext/js/app/popup-factory.js index 95587162..126f229c 100644 --- a/ext/js/app/popup-factory.js +++ b/ext/js/app/popup-factory.js @@ -43,21 +43,21 @@ class PopupFactory {      prepare() {          this._frameOffsetForwarder.prepare();          yomichan.crossFrame.registerHandlers([ -            ['getOrCreatePopup',     {async: true,  handler: this._onApiGetOrCreatePopup.bind(this)}], -            ['setOptionsContext',    {async: true,  handler: this._onApiSetOptionsContext.bind(this)}], -            ['hide',                 {async: false, handler: this._onApiHide.bind(this)}], -            ['isVisible',            {async: true,  handler: this._onApiIsVisibleAsync.bind(this)}], -            ['setVisibleOverride',   {async: true,  handler: this._onApiSetVisibleOverride.bind(this)}], -            ['clearVisibleOverride', {async: true,  handler: this._onApiClearVisibleOverride.bind(this)}], -            ['containsPoint',        {async: true,  handler: this._onApiContainsPoint.bind(this)}], -            ['showContent',          {async: true,  handler: this._onApiShowContent.bind(this)}], -            ['setCustomCss',         {async: false, handler: this._onApiSetCustomCss.bind(this)}], -            ['clearAutoPlayTimer',   {async: false, handler: this._onApiClearAutoPlayTimer.bind(this)}], -            ['setContentScale',      {async: false, handler: this._onApiSetContentScale.bind(this)}], -            ['updateTheme',          {async: false, handler: this._onApiUpdateTheme.bind(this)}], -            ['setCustomOuterCss',    {async: false, handler: this._onApiSetCustomOuterCss.bind(this)}], -            ['popup.getFrameSize',   {async: true,  handler: this._onApiGetFrameSize.bind(this)}], -            ['popup.setFrameSize',   {async: true,  handler: this._onApiSetFrameSize.bind(this)}] +            ['PopupFactory.getOrCreatePopup',     {async: true,  handler: this._onApiGetOrCreatePopup.bind(this)}], +            ['PopupFactory.setOptionsContext',    {async: true,  handler: this._onApiSetOptionsContext.bind(this)}], +            ['PopupFactory.hide',                 {async: false, handler: this._onApiHide.bind(this)}], +            ['PopupFactory.isVisible',            {async: true,  handler: this._onApiIsVisibleAsync.bind(this)}], +            ['PopupFactory.setVisibleOverride',   {async: true,  handler: this._onApiSetVisibleOverride.bind(this)}], +            ['PopupFactory.clearVisibleOverride', {async: true,  handler: this._onApiClearVisibleOverride.bind(this)}], +            ['PopupFactory.containsPoint',        {async: true,  handler: this._onApiContainsPoint.bind(this)}], +            ['PopupFactory.showContent',          {async: true,  handler: this._onApiShowContent.bind(this)}], +            ['PopupFactory.setCustomCss',         {async: false, handler: this._onApiSetCustomCss.bind(this)}], +            ['PopupFactory.clearAutoPlayTimer',   {async: false, handler: this._onApiClearAutoPlayTimer.bind(this)}], +            ['PopupFactory.setContentScale',      {async: false, handler: this._onApiSetContentScale.bind(this)}], +            ['PopupFactory.updateTheme',          {async: false, handler: this._onApiUpdateTheme.bind(this)}], +            ['PopupFactory.setCustomOuterCss',    {async: false, handler: this._onApiSetCustomOuterCss.bind(this)}], +            ['PopupFactory.getFrameSize',         {async: true,  handler: this._onApiGetFrameSize.bind(this)}], +            ['PopupFactory.setFrameSize',         {async: true,  handler: this._onApiSetFrameSize.bind(this)}]          ]);      } @@ -149,7 +149,7 @@ class PopupFactory {                  throw new Error('Invalid frameId');              }              const useFrameOffsetForwarder = (parentPopupId === null); -            ({id, depth, frameId} = await yomichan.crossFrame.invoke(frameId, 'getOrCreatePopup', { +            ({id, depth, frameId} = await yomichan.crossFrame.invoke(frameId, 'PopupFactory.getOrCreatePopup', {                  id,                  parentPopupId,                  frameId, diff --git a/ext/js/app/popup-proxy.js b/ext/js/app/popup-proxy.js index 3e95ff2a..7d9d41b0 100644 --- a/ext/js/app/popup-proxy.js +++ b/ext/js/app/popup-proxy.js @@ -129,7 +129,7 @@ class PopupProxy extends EventDispatcher {       * @returns {Promise<void>}       */      setOptionsContext(optionsContext) { -        return this._invokeSafe('setOptionsContext', {id: this._id, optionsContext}); +        return this._invokeSafe('PopupFactory.setOptionsContext', {id: this._id, optionsContext});      }      /** @@ -138,7 +138,7 @@ class PopupProxy extends EventDispatcher {       * @returns {Promise<void>}       */      hide(changeFocus) { -        return this._invokeSafe('hide', {id: this._id, changeFocus}); +        return this._invokeSafe('PopupFactory.hide', {id: this._id, changeFocus});      }      /** @@ -146,7 +146,7 @@ class PopupProxy extends EventDispatcher {       * @returns {Promise<boolean>} `true` if the popup is visible, `false` otherwise.       */      isVisible() { -        return this._invokeSafe('isVisible', {id: this._id}, false); +        return this._invokeSafe('PopupFactory.isVisible', {id: this._id}, false);      }      /** @@ -157,7 +157,7 @@ class PopupProxy extends EventDispatcher {       *   or null if the override wasn't assigned.       */      setVisibleOverride(value, priority) { -        return this._invokeSafe('setVisibleOverride', {id: this._id, value, priority}, null); +        return this._invokeSafe('PopupFactory.setVisibleOverride', {id: this._id, value, priority}, null);      }      /** @@ -166,7 +166,7 @@ class PopupProxy extends EventDispatcher {       * @returns {Promise<boolean>} `true` if the override existed and was removed, `false` otherwise.       */      clearVisibleOverride(token) { -        return this._invokeSafe('clearVisibleOverride', {id: this._id, token}, false); +        return this._invokeSafe('PopupFactory.clearVisibleOverride', {id: this._id, token}, false);      }      /** @@ -180,7 +180,7 @@ class PopupProxy extends EventDispatcher {              await this._updateFrameOffset();              [x, y] = this._applyFrameOffset(x, y);          } -        return await this._invokeSafe('containsPoint', {id: this._id, x, y}, false); +        return await this._invokeSafe('PopupFactory.containsPoint', {id: this._id, x, y}, false);      }      /** @@ -195,7 +195,7 @@ class PopupProxy extends EventDispatcher {              await this._updateFrameOffset();              [elementRect.x, elementRect.y] = this._applyFrameOffset(elementRect.x, elementRect.y);          } -        return await this._invokeSafe('showContent', {id: this._id, details, displayDetails}); +        return await this._invokeSafe('PopupFactory.showContent', {id: this._id, details, displayDetails});      }      /** @@ -204,7 +204,7 @@ class PopupProxy extends EventDispatcher {       * @returns {Promise<void>}       */      setCustomCss(css) { -        return this._invokeSafe('setCustomCss', {id: this._id, css}); +        return this._invokeSafe('PopupFactory.setCustomCss', {id: this._id, css});      }      /** @@ -212,7 +212,7 @@ class PopupProxy extends EventDispatcher {       * @returns {Promise<void>}       */      clearAutoPlayTimer() { -        return this._invokeSafe('clearAutoPlayTimer', {id: this._id}); +        return this._invokeSafe('PopupFactory.clearAutoPlayTimer', {id: this._id});      }      /** @@ -221,7 +221,7 @@ class PopupProxy extends EventDispatcher {       * @returns {Promise<void>}       */      setContentScale(scale) { -        return this._invokeSafe('setContentScale', {id: this._id, scale}); +        return this._invokeSafe('PopupFactory.setContentScale', {id: this._id, scale});      }      /** @@ -238,7 +238,7 @@ class PopupProxy extends EventDispatcher {       * @returns {Promise<void>}       */      updateTheme() { -        return this._invokeSafe('updateTheme', {id: this._id}); +        return this._invokeSafe('PopupFactory.updateTheme', {id: this._id});      }      /** @@ -249,7 +249,7 @@ class PopupProxy extends EventDispatcher {       * @returns {Promise<void>}       */      setCustomOuterCss(css, useWebExtensionApi) { -        return this._invokeSafe('setCustomOuterCss', {id: this._id, css, useWebExtensionApi}); +        return this._invokeSafe('PopupFactory.setCustomOuterCss', {id: this._id, css, useWebExtensionApi});      }      /** @@ -266,7 +266,7 @@ class PopupProxy extends EventDispatcher {       * @returns {Promise<{width: number, height: number, valid: boolean}>} The size and whether or not it is valid.       */      getFrameSize() { -        return this._invokeSafe('popup.getFrameSize', {id: this._id}, {width: 0, height: 0, valid: false}); +        return this._invokeSafe('PopupFactory.getFrameSize', {id: this._id}, {width: 0, height: 0, valid: false});      }      /** @@ -276,7 +276,7 @@ class PopupProxy extends EventDispatcher {       * @returns {Promise<boolean>} `true` if the size assignment was successful, `false` otherwise.       */      setFrameSize(width, height) { -        return this._invokeSafe('popup.setFrameSize', {id: this._id, width, height}); +        return this._invokeSafe('PopupFactory.setFrameSize', {id: this._id, width, height});      }      // Private diff --git a/ext/js/app/popup-window.js b/ext/js/app/popup-window.js index 8f1a8355..e84b050a 100644 --- a/ext/js/app/popup-window.js +++ b/ext/js/app/popup-window.js @@ -117,7 +117,7 @@ class PopupWindow extends EventDispatcher {       * @returns {Promise<void>}       */      setOptionsContext(optionsContext) { -        return this._invoke(false, 'setOptionsContext', {id: this._id, optionsContext}); +        return this._invoke(false, 'Display.setOptionsContext', {id: this._id, optionsContext});      }      /** @@ -174,7 +174,7 @@ class PopupWindow extends EventDispatcher {       */      async showContent(_details, displayDetails) {          if (displayDetails === null) { return; } -        await this._invoke(true, 'setContent', {id: this._id, details: displayDetails}); +        await this._invoke(true, 'Display.setContent', {id: this._id, details: displayDetails});      }      /** @@ -182,14 +182,14 @@ class PopupWindow extends EventDispatcher {       * @param {string} css The CSS rules.       */      setCustomCss(css) { -        return this._invoke(false, 'setCustomCss', {id: this._id, css}); +        return this._invoke(false, 'Display.setCustomCss', {id: this._id, css});      }      /**       * Stops the audio auto-play timer, if one has started.       */      clearAutoPlayTimer() { -        return this._invoke(false, 'clearAutoPlayTimer', {id: this._id}); +        return this._invoke(false, 'Display.clearAutoPlayTimer', {id: this._id});      }      /** diff --git a/ext/js/app/popup.js b/ext/js/app/popup.js index 8454dcb1..acaf6e15 100644 --- a/ext/js/app/popup.js +++ b/ext/js/app/popup.js @@ -161,7 +161,7 @@ class Popup extends EventDispatcher {       */      async setOptionsContext(optionsContext) {          await this._setOptionsContext(optionsContext); -        await this._invokeSafe('setOptionsContext', {optionsContext}); +        await this._invokeSafe('Display.setOptionsContext', {optionsContext});      }      /** @@ -245,7 +245,7 @@ class Popup extends EventDispatcher {          }          if (displayDetails !== null) { -            this._invokeSafe('setContent', {details: displayDetails}); +            this._invokeSafe('Display.setContent', {details: displayDetails});          }      } @@ -254,14 +254,14 @@ class Popup extends EventDispatcher {       * @param {string} css The CSS rules.       */      setCustomCss(css) { -        this._invokeSafe('setCustomCss', {css}); +        this._invokeSafe('Display.setCustomCss', {css});      }      /**       * Stops the audio auto-play timer, if one has started.       */      clearAutoPlayTimer() { -        this._invokeSafe('clearAutoPlayTimer'); +        this._invokeSafe('Display.clearAutoPlayTimer');      }      /** @@ -271,7 +271,7 @@ class Popup extends EventDispatcher {      setContentScale(scale) {          this._contentScale = scale;          this._frame.style.fontSize = `${scale}px`; -        this._invokeSafe('setContentScale', {scale}); +        this._invokeSafe('Display.setContentScale', {scale});      }      /** @@ -411,7 +411,7 @@ class Popup extends EventDispatcher {          await frameClient.connect(this._frame, this._targetOrigin, this._frameId, setupFrame);          // Configure -        await this._invokeSafe('configure', { +        await this._invokeSafe('Display.configure', {              depth: this._depth,              parentPopupId: this._id,              parentFrameId: this._frameId, @@ -569,7 +569,7 @@ class Popup extends EventDispatcher {          if (this._visibleValue === value) { return; }          this._visibleValue = value;          this._frame.style.setProperty('visibility', value ? 'visible' : 'hidden', 'important'); -        this._invokeSafe('visibilityChanged', {value}); +        this._invokeSafe('Display.visibilityChanged', {value});      }      _focusParent() { @@ -627,7 +627,7 @@ class Popup extends EventDispatcher {      }      _onExtensionUnloaded() { -        this._invokeWindow('extensionUnloaded'); +        this._invokeWindow('Display.extensionUnloaded');      }      _getFrameParentElement() { diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js index 098bc3ab..ca2f5f16 100644 --- a/ext/js/background/backend.js +++ b/ext/js/background/backend.js @@ -227,8 +227,8 @@ class Backend {              this._clipboardMonitor.on('change', this._onClipboardTextChange.bind(this)); -            this._sendMessageAllTabsIgnoreResponse('backendReady', {}); -            this._sendMessageIgnoreResponse({action: 'backendReady', params: {}}); +            this._sendMessageAllTabsIgnoreResponse('Yomichan.backendReady', {}); +            this._sendMessageIgnoreResponse({action: 'Yomichan.backendReady', params: {}});          } catch (e) {              log.error(e);              throw e; @@ -367,7 +367,7 @@ class Backend {      }      _onZoomChange({tabId, oldZoomFactor, newZoomFactor}) { -        this._sendMessageTabIgnoreResponse(tabId, {action: 'zoomChanged', params: {oldZoomFactor, newZoomFactor}}); +        this._sendMessageTabIgnoreResponse(tabId, {action: 'Yomichan.zoomChanged', params: {oldZoomFactor, newZoomFactor}});      }      _onPermissionsChanged() { @@ -383,7 +383,7 @@ class Backend {      _onApiRequestBackendReadySignal(_params, sender) {          // tab ID isn't set in background (e.g. browser_action) -        const data = {action: 'backendReady', params: {}}; +        const data = {action: 'Yomichan.backendReady', params: {}};          if (typeof sender.tab === 'undefined') {              this._sendMessageIgnoreResponse(data);              return false; @@ -895,7 +895,7 @@ class Backend {          await this._sendMessageTabPromise(              tab.id, -            {action: 'setMode', params: {mode: 'popup'}}, +            {action: 'SearchDisplayController.setMode', params: {mode: 'popup'}},              {frameId: 0}          ); @@ -909,7 +909,7 @@ class Backend {              try {                  const mode = await this._sendMessageTabPromise(                      tab.id, -                    {action: 'getMode', params: {}}, +                    {action: 'SearchDisplayController.getMode', params: {}},                      {frameId: 0}                  );                  return mode === 'popup'; @@ -969,7 +969,7 @@ class Backend {      _updateSearchQuery(tabId, text, animate) {          return this._sendMessageTabPromise(              tabId, -            {action: 'updateSearchQuery', params: {text, animate}}, +            {action: 'SearchDisplayController.updateSearchQuery', params: {text, animate}},              {frameId: 0}          );      } @@ -991,7 +991,7 @@ class Backend {              this._clipboardMonitor.stop();          } -        this._sendMessageAllTabsIgnoreResponse('optionsUpdated', {source}); +        this._sendMessageAllTabsIgnoreResponse('Yomichan.optionsUpdated', {source});      }      _getOptionsFull(useSchema=false) { @@ -1425,7 +1425,7 @@ class Backend {          try {              const {url} = await this._sendMessageTabPromise(                  tabId, -                {action: 'getUrl', params: {}}, +                {action: 'Yomichan.getUrl', params: {}},                  {frameId: 0}              );              if (typeof url === 'string') { @@ -1582,7 +1582,7 @@ class Backend {              chrome.runtime.onMessage.addListener(onMessage); -            this._sendMessageTabPromise(tabId, {action: 'isReady'}, {frameId}) +            this._sendMessageTabPromise(tabId, {action: 'Yomichan.isReady'}, {frameId})                  .then(                      (value) => {                          if (!value) { return; } @@ -1685,7 +1685,7 @@ class Backend {          let token = null;          try {              if (typeof tabId === 'number' && typeof frameId === 'number') { -                const action = 'setAllVisibleOverride'; +                const action = 'Frontend.setAllVisibleOverride';                  const params = {value: false, priority: 0, awaitFrame: true};                  token = await this._sendMessageTabPromise(tabId, {action, params}, {frameId});              } @@ -1702,7 +1702,7 @@ class Backend {              });          } finally {              if (token !== null) { -                const action = 'clearAllVisibleOverride'; +                const action = 'Frontend.clearAllVisibleOverride';                  const params = {token};                  try {                      await this._sendMessageTabPromise(tabId, {action, params}, {frameId}); @@ -1946,7 +1946,7 @@ class Backend {      _triggerDatabaseUpdated(type, cause) {          this._translator.clearDatabaseCaches(); -        this._sendMessageAllTabsIgnoreResponse('databaseUpdated', {type, cause}); +        this._sendMessageAllTabsIgnoreResponse('Yomichan.databaseUpdated', {type, cause});      }      async _saveOptions(source) { diff --git a/ext/js/display/display-audio.js b/ext/js/display/display-audio.js index 7b481034..c75423b3 100644 --- a/ext/js/display/display-audio.js +++ b/ext/js/display/display-audio.js @@ -64,7 +64,7 @@ class DisplayAudio {              ['playAudioFromSource', this._onHotkeyActionPlayAudioFromSource.bind(this)]          ]);          this._display.registerDirectMessageHandlers([ -            ['clearAutoPlayTimer', {async: false, handler: this._onMessageClearAutoPlayTimer.bind(this)}] +            ['Display.clearAutoPlayTimer', {async: false, handler: this._onMessageClearAutoPlayTimer.bind(this)}]          ]);          this._display.on('optionsUpdated', this._onOptionsUpdated.bind(this));          this._display.on('contentClear', this._onContentClear.bind(this)); diff --git a/ext/js/display/display-resizer.js b/ext/js/display/display-resizer.js index 9fd56045..5512317a 100644 --- a/ext/js/display/display-resizer.js +++ b/ext/js/display/display-resizer.js @@ -128,7 +128,7 @@ class DisplayResizer {          const {parentPopupId} = this._display;          if (parentPopupId === null) { return; } -        const size = await this._display.invokeParentFrame('popup.getFrameSize', {id: parentPopupId}); +        const size = await this._display.invokeParentFrame('PopupFactory.getFrameSize', {id: parentPopupId});          if (this._token !== token) { return; }          this._startSize = size;      } @@ -158,7 +158,7 @@ class DisplayResizer {          height += y - this._startOffset.y;          width = Math.max(Math.max(0, handleSize.width), width);          height = Math.max(Math.max(0, handleSize.height), height); -        await this._display.invokeParentFrame('popup.setFrameSize', {id: parentPopupId, width, height}); +        await this._display.invokeParentFrame('PopupFactory.setFrameSize', {id: parentPopupId, width, height});      }      _getTouch(touchList, identifier) { diff --git a/ext/js/display/display.js b/ext/js/display/display.js index caa1ce10..697e735f 100644 --- a/ext/js/display/display.js +++ b/ext/js/display/display.js @@ -128,15 +128,15 @@ class Display extends EventDispatcher {              ['previousEntryDifferentDictionary', () => { this._focusEntryWithDifferentDictionary(-1, true); }]          ]);          this.registerDirectMessageHandlers([ -            ['setOptionsContext',  {async: false, handler: this._onMessageSetOptionsContext.bind(this)}], -            ['setContent',         {async: false, handler: this._onMessageSetContent.bind(this)}], -            ['setCustomCss',       {async: false, handler: this._onMessageSetCustomCss.bind(this)}], -            ['setContentScale',    {async: false, handler: this._onMessageSetContentScale.bind(this)}], -            ['configure',          {async: true,  handler: this._onMessageConfigure.bind(this)}], -            ['visibilityChanged',  {async: false, handler: this._onMessageVisibilityChanged.bind(this)}] +            ['Display.setOptionsContext', {async: false, handler: this._onMessageSetOptionsContext.bind(this)}], +            ['Display.setContent',        {async: false, handler: this._onMessageSetContent.bind(this)}], +            ['Display.setCustomCss',      {async: false, handler: this._onMessageSetCustomCss.bind(this)}], +            ['Display.setContentScale',   {async: false, handler: this._onMessageSetContentScale.bind(this)}], +            ['Display.configure',         {async: true,  handler: this._onMessageConfigure.bind(this)}], +            ['Display.visibilityChanged', {async: false, handler: this._onMessageVisibilityChanged.bind(this)}]          ]);          this.registerWindowMessageHandlers([ -            ['extensionUnloaded', {async: false, handler: this._onMessageExtensionUnloaded.bind(this)}] +            ['Display.extensionUnloaded', {async: false, handler: this._onMessageExtensionUnloaded.bind(this)}]          ]);      } @@ -393,7 +393,7 @@ class Display extends EventDispatcher {      close() {          switch (this._pageType) {              case 'popup': -                this.invokeContentOrigin('closePopup'); +                this.invokeContentOrigin('Frontend.closePopup');                  break;              case 'search':                  this._closeTab(); @@ -1359,7 +1359,7 @@ class Display extends EventDispatcher {                  {                      let text;                      try { -                        text = await this.invokeContentOrigin('getSelectionText'); +                        text = await this.invokeContentOrigin('Frontend.getSelectionText');                      } catch (e) {                          break;                      } @@ -1367,7 +1367,7 @@ class Display extends EventDispatcher {                  }                  break;              default: -                await this.invokeContentOrigin('copySelection'); +                await this.invokeContentOrigin('Frontend.copySelection');                  break;          }      } diff --git a/ext/js/display/search-display-controller.js b/ext/js/display/search-display-controller.js index c929ceaa..10373597 100644 --- a/ext/js/display/search-display-controller.js +++ b/ext/js/display/search-display-controller.js @@ -64,9 +64,9 @@ class SearchDisplayController {              ['focusSearchBox', this._onActionFocusSearchBox.bind(this)]          ]);          this._registerMessageHandlers([ -            ['getMode', {async: false, handler: this._onMessageGetMode.bind(this)}], -            ['setMode', {async: false, handler: this._onMessageSetMode.bind(this)}], -            ['updateSearchQuery', {async: false, handler: this._onExternalSearchUpdate.bind(this)}] +            ['SearchDisplayController.getMode',           {async: false, handler: this._onMessageGetMode.bind(this)}], +            ['SearchDisplayController.setMode',           {async: false, handler: this._onMessageSetMode.bind(this)}], +            ['SearchDisplayController.updateSearchQuery', {async: false, handler: this._onExternalSearchUpdate.bind(this)}]          ]);          this._updateClipboardMonitorEnabled(); diff --git a/ext/js/input/hotkey-handler.js b/ext/js/input/hotkey-handler.js index 6c63aebb..90cae462 100644 --- a/ext/js/input/hotkey-handler.js +++ b/ext/js/input/hotkey-handler.js @@ -43,7 +43,7 @@ class HotkeyHandler extends EventDispatcher {          this._isPrepared = true;          this._updateEventHandlers();          yomichan.crossFrame.registerHandlers([ -            ['hotkeyHandler.forwardHotkey', {async: false, handler: this._onMessageForwardHotkey.bind(this)}] +            ['HotkeyHandler.forwardHotkey', {async: false, handler: this._onMessageForwardHotkey.bind(this)}]          ]);      } diff --git a/ext/js/pages/settings/popup-preview-controller.js b/ext/js/pages/settings/popup-preview-controller.js index 2a47d385..9a00c845 100644 --- a/ext/js/pages/settings/popup-preview-controller.js +++ b/ext/js/pages/settings/popup-preview-controller.js @@ -52,16 +52,16 @@ class PopupPreviewController {      }      _onCustomCssChange() { -        this._invoke('setCustomCss', {css: this._customCss.value}); +        this._invoke('PopupPreviewFrame.setCustomCss', {css: this._customCss.value});      }      _onCustomOuterCssChange() { -        this._invoke('setCustomOuterCss', {css: this._customOuterCss.value}); +        this._invoke('PopupPreviewFrame.setCustomOuterCss', {css: this._customOuterCss.value});      }      _onOptionsContextChange() {          const optionsContext = this._settingsController.getOptionsContext(); -        this._invoke('updateOptionsContext', {optionsContext}); +        this._invoke('PopupPreviewFrame.updateOptionsContext', {optionsContext});      }      _invoke(action, params) { diff --git a/ext/js/pages/settings/popup-preview-frame.js b/ext/js/pages/settings/popup-preview-frame.js index 638dd414..2b29d5b9 100644 --- a/ext/js/pages/settings/popup-preview-frame.js +++ b/ext/js/pages/settings/popup-preview-frame.js @@ -38,10 +38,10 @@ class PopupPreviewFrame {          this._targetOrigin = chrome.runtime.getURL('/').replace(/\/$/, '');          this._windowMessageHandlers = new Map([ -            ['setText',              this._onSetText.bind(this)], -            ['setCustomCss',         this._setCustomCss.bind(this)], -            ['setCustomOuterCss',    this._setCustomOuterCss.bind(this)], -            ['updateOptionsContext', this._updateOptionsContext.bind(this)] +            ['PopupPreviewFrame.setText',              this._onSetText.bind(this)], +            ['PopupPreviewFrame.setCustomCss',         this._setCustomCss.bind(this)], +            ['PopupPreviewFrame.setCustomOuterCss',    this._setCustomOuterCss.bind(this)], +            ['PopupPreviewFrame.updateOptionsContext', this._updateOptionsContext.bind(this)]          ]);      } diff --git a/ext/js/yomichan.js b/ext/js/yomichan.js index 33e84df1..b597f818 100644 --- a/ext/js/yomichan.js +++ b/ext/js/yomichan.js @@ -74,12 +74,12 @@ class Yomichan extends EventDispatcher {          this._isBackendReadyPromiseResolve = resolve;          this._messageHandlers = new Map([ -            ['isReady',         {async: false, handler: this._onMessageIsReady.bind(this)}], -            ['backendReady',    {async: false, handler: this._onMessageBackendReady.bind(this)}], -            ['getUrl',          {async: false, handler: this._onMessageGetUrl.bind(this)}], -            ['optionsUpdated',  {async: false, handler: this._onMessageOptionsUpdated.bind(this)}], -            ['databaseUpdated', {async: false, handler: this._onMessageDatabaseUpdated.bind(this)}], -            ['zoomChanged',     {async: false, handler: this._onMessageZoomChanged.bind(this)}] +            ['Yomichan.isReady',         {async: false, handler: this._onMessageIsReady.bind(this)}], +            ['Yomichan.backendReady',    {async: false, handler: this._onMessageBackendReady.bind(this)}], +            ['Yomichan.getUrl',          {async: false, handler: this._onMessageGetUrl.bind(this)}], +            ['Yomichan.optionsUpdated',  {async: false, handler: this._onMessageOptionsUpdated.bind(this)}], +            ['Yomichan.databaseUpdated', {async: false, handler: this._onMessageDatabaseUpdated.bind(this)}], +            ['Yomichan.zoomChanged',     {async: false, handler: this._onMessageZoomChanged.bind(this)}]          ]);      } |