Skip to content

Commit

Permalink
yomichan -> yomitan
Browse files Browse the repository at this point in the history
  • Loading branch information
aiborii committed Nov 11, 2023
1 parent dae8245 commit c413416
Show file tree
Hide file tree
Showing 70 changed files with 274 additions and 274 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@
},
{
"files": [
"ext/js/yomichan.js"
"ext/js/yomitan.js"
],
"globals": {
"chrome": "writable"
Expand Down Expand Up @@ -417,7 +417,7 @@
{
"files": [
"ext/js/core.js",
"ext/js/yomichan.js",
"ext/js/yomitan.js",
"ext/js/accessibility/accessibility-controller.js",
"ext/js/background/backend.js",
"ext/js/background/profile-conditions-util.js",
Expand Down
8 changes: 4 additions & 4 deletions ext/js/app/content-script-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@

import {log} from '../core.js';
import {HotkeyHandler} from '../input/hotkey-handler.js';
import {yomichan} from '../yomichan.js';
import {yomitan} from '../yomitan.js';
import {Frontend} from './frontend.js';
import {PopupFactory} from './popup-factory.js';

(async () => {
try {
await yomichan.prepare();
await yomitan.prepare();

const {tabId, frameId} = await yomichan.api.frameInformationGet();
const {tabId, frameId} = await yomitan.api.frameInformationGet();
if (typeof frameId !== 'number') {
throw new Error('Failed to get frameId');
}
Expand All @@ -51,7 +51,7 @@ import {PopupFactory} from './popup-factory.js';
});
await frontend.prepare();

yomichan.ready();
yomitan.ready();
} catch (e) {
log.error(e);
}
Expand Down
34 changes: 17 additions & 17 deletions ext/js/app/frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {TextSourceElement} from '../dom/text-source-element.js';
import {TextSourceRange} from '../dom/text-source-range.js';
import {HotkeyHandler} from '../input/hotkey-handler.js';
import {TextScanner} from '../language/text-scanner.js';
import {yomichan} from '../yomichan.js';
import {yomitan} from '../yomitan.js';
import {PopupFactory} from './popup-factory.js';
import {Popup} from './popup.js';

Expand Down Expand Up @@ -137,7 +137,7 @@ export class Frontend {
async prepare() {
await this.updateOptions();
try {
const {zoomFactor} = await yomichan.api.getZoom();
const {zoomFactor} = await yomitan.api.getZoom();
this._pageZoomFactor = zoomFactor;
} catch (e) {
// Ignore exceptions which may occur due to being on an unsupported page (e.g. about:blank)
Expand All @@ -154,15 +154,15 @@ export class Frontend {
visualViewport.addEventListener('resize', this._onVisualViewportResize.bind(this));
}

yomichan.on('optionsUpdated', this.updateOptions.bind(this));
yomichan.on('zoomChanged', this._onZoomChanged.bind(this));
yomichan.on('closePopups', this._onClosePopups.bind(this));
yomitan.on('optionsUpdated', this.updateOptions.bind(this));
yomitan.on('zoomChanged', this._onZoomChanged.bind(this));
yomitan.on('closePopups', this._onClosePopups.bind(this));
chrome.runtime.onMessage.addListener(this._onRuntimeMessage.bind(this));

this._textScanner.on('clear', this._onTextScannerClear.bind(this));
this._textScanner.on('searched', this._onSearched.bind(this));

yomichan.crossFrame.registerHandlers([
yomitan.crossFrame.registerHandlers([
['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)}],
Expand Down Expand Up @@ -208,7 +208,7 @@ export class Frontend {
try {
await this._updateOptionsInternal();
} catch (e) {
if (!yomichan.isExtensionUnloaded) {
if (!yomitan.isExtensionUnloaded) {
throw e;
}
}
Expand Down Expand Up @@ -319,7 +319,7 @@ export class Frontend {
const scanningOptions = this._options.scanning;

if (error !== null) {
if (yomichan.isExtensionUnloaded) {
if (yomitan.isExtensionUnloaded) {
if (textSource !== null && !passive) {
this._showExtensionUnloaded(textSource);
}
Expand Down Expand Up @@ -388,7 +388,7 @@ export class Frontend {

async _updateOptionsInternal() {
const optionsContext = await this._getOptionsContext();
const options = await yomichan.api.optionsGet(optionsContext);
const options = await yomitan.api.optionsGet(optionsContext);
const {scanning: scanningOptions, sentenceParsing: sentenceParsingOptions} = options;
this._options = options;

Expand Down Expand Up @@ -520,7 +520,7 @@ export class Frontend {
return await this._getDefaultPopup();
}

const {popupId} = await yomichan.crossFrame.invoke(targetFrameId, 'Frontend.getPopupInfo');
const {popupId} = await yomitan.crossFrame.invoke(targetFrameId, 'Frontend.getPopupInfo');
if (popupId === null) {
return null;
}
Expand Down Expand Up @@ -559,7 +559,7 @@ export class Frontend {
try {
return this._popup !== null && await this._popup.containsPoint(x, y);
} catch (e) {
if (!yomichan.isExtensionUnloaded) {
if (!yomitan.isExtensionUnloaded) {
throw e;
}
return false;
Expand Down Expand Up @@ -625,7 +625,7 @@ export class Frontend {
Promise.resolve()
);
this._lastShowPromise.catch((error) => {
if (yomichan.isExtensionUnloaded) { return; }
if (yomitan.isExtensionUnloaded) { return; }
log.error(error);
});
return this._lastShowPromise;
Expand Down Expand Up @@ -677,9 +677,9 @@ export class Frontend {
_signalFrontendReady(targetFrameId=null) {
const params = {frameId: this._frameId};
if (targetFrameId === null) {
yomichan.api.broadcastTab('frontendReady', params);
yomitan.api.broadcastTab('frontendReady', params);
} else {
yomichan.api.sendMessageToFrame(targetFrameId, 'frontendReady', params);
yomitan.api.sendMessageToFrame(targetFrameId, 'frontendReady', params);
}
}

Expand Down Expand Up @@ -716,7 +716,7 @@ export class Frontend {
}

chrome.runtime.onMessage.addListener(onMessage);
yomichan.api.broadcastTab('Frontend.requestReadyBroadcast', {frameId: this._frameId});
yomitan.api.broadcastTab('Frontend.requestReadyBroadcast', {frameId: this._frameId});
});
}

Expand All @@ -742,7 +742,7 @@ export class Frontend {
let documentTitle = document.title;
if (this._useProxyPopup) {
try {
({url, documentTitle} = await yomichan.crossFrame.invoke(this._parentFrameId, 'Frontend.getPageInfo', {}));
({url, documentTitle} = await yomitan.crossFrame.invoke(this._parentFrameId, 'Frontend.getPageInfo', {}));
} catch (e) {
// NOP
}
Expand Down Expand Up @@ -788,7 +788,7 @@ export class Frontend {

async _prepareGoogleDocs() {
if (typeof GoogleDocsUtil !== 'undefined') { return; }
await yomichan.api.loadExtensionScripts([
await yomitan.api.loadExtensionScripts([
'/js/accessibility/google-docs-util.js'
]);
if (typeof GoogleDocsUtil === 'undefined') { return; }
Expand Down
6 changes: 3 additions & 3 deletions ext/js/app/popup-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import {FrameOffsetForwarder} from '../comm/frame-offset-forwarder.js';
import {generateId} from '../core.js';
import {yomichan} from '../yomichan.js';
import {yomitan} from '../yomitan.js';
import {PopupProxy} from './popup-proxy.js';
import {PopupWindow} from './popup-window.js';
import {Popup} from './popup.js';
Expand All @@ -43,7 +43,7 @@ export class PopupFactory {
*/
prepare() {
this._frameOffsetForwarder.prepare();
yomichan.crossFrame.registerHandlers([
yomitan.crossFrame.registerHandlers([
['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)}],
Expand Down Expand Up @@ -151,7 +151,7 @@ export class PopupFactory {
throw new Error('Invalid frameId');
}
const useFrameOffsetForwarder = (parentPopupId === null);
({id, depth, frameId} = await yomichan.crossFrame.invoke(frameId, 'PopupFactory.getOrCreatePopup', {
({id, depth, frameId} = await yomitan.crossFrame.invoke(frameId, 'PopupFactory.getOrCreatePopup', {
id,
parentPopupId,
frameId,
Expand Down
6 changes: 3 additions & 3 deletions ext/js/app/popup-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import {FrameOffsetForwarder} from '../comm/frame-offset-forwarder.js';
import {EventDispatcher, log} from '../core.js';
import {yomichan} from '../yomichan.js';
import {yomitan} from '../yomitan.js';
import {Popup} from './popup.js';

/**
Expand Down Expand Up @@ -294,14 +294,14 @@ export class PopupProxy extends EventDispatcher {
// Private

_invoke(action, params={}) {
return yomichan.crossFrame.invoke(this._frameId, action, params);
return yomitan.crossFrame.invoke(this._frameId, action, params);
}

async _invokeSafe(action, params={}, defaultReturnValue) {
try {
return await this._invoke(action, params);
} catch (e) {
if (!yomichan.isExtensionUnloaded) { throw e; }
if (!yomitan.isExtensionUnloaded) { throw e; }
return defaultReturnValue;
}
}
Expand Down
14 changes: 7 additions & 7 deletions ext/js/app/popup-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

import {EventDispatcher} from '../core.js';
import {yomichan} from '../yomichan.js';
import {yomitan} from '../yomitan.js';
import {Popup} from './popup.js';

/**
Expand Down Expand Up @@ -138,7 +138,7 @@ export class PopupWindow extends EventDispatcher {
* @returns {Promise<boolean>} `true` if the popup is visible, `false` otherwise.
*/
async isVisible() {
return (this._popupTabId !== null && await yomichan.api.isTabSearchPopup(this._popupTabId));
return (this._popupTabId !== null && await yomitan.api.isTabSearchPopup(this._popupTabId));
}

/**
Expand Down Expand Up @@ -263,16 +263,16 @@ export class PopupWindow extends EventDispatcher {
// Private

async _invoke(open, action, params={}, defaultReturnValue) {
if (yomichan.isExtensionUnloaded) {
if (yomitan.isExtensionUnloaded) {
return defaultReturnValue;
}

const frameId = 0;
if (this._popupTabId !== null) {
try {
return await yomichan.crossFrame.invokeTab(this._popupTabId, frameId, 'popupMessage', {action, params});
return await yomitan.crossFrame.invokeTab(this._popupTabId, frameId, 'popupMessage', {action, params});
} catch (e) {
if (yomichan.isExtensionUnloaded) {
if (yomitan.isExtensionUnloaded) {
open = false;
}
}
Expand All @@ -283,9 +283,9 @@ export class PopupWindow extends EventDispatcher {
return defaultReturnValue;
}

const {tabId} = await yomichan.api.getOrCreateSearchPopup({focus: 'ifCreated'});
const {tabId} = await yomitan.api.getOrCreateSearchPopup({focus: 'ifCreated'});
this._popupTabId = tabId;

return await yomichan.crossFrame.invokeTab(this._popupTabId, frameId, 'popupMessage', {action, params});
return await yomitan.crossFrame.invokeTab(this._popupTabId, frameId, 'popupMessage', {action, params});
}
}
10 changes: 5 additions & 5 deletions ext/js/app/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {FrameClient} from '../comm/frame-client.js';
import {DynamicProperty, EventDispatcher, EventListenerCollection, deepEqual} from '../core.js';
import {DocumentUtil} from '../dom/document-util.js';
import {dynamicLoader} from '../script/dynamic-loader.js';
import {yomichan} from '../yomichan.js';
import {yomitan} from '../yomitan.js';
import {ThemeController} from './theme-controller.js';

/**
Expand Down Expand Up @@ -208,7 +208,7 @@ export class Popup extends EventDispatcher {
this._frame.addEventListener('scroll', (e) => e.stopPropagation());
this._frame.addEventListener('load', this._onFrameLoad.bind(this));
this._visible.on('change', this._onVisibleChange.bind(this));
yomichan.on('extensionUnloaded', this._onExtensionUnloaded.bind(this));
yomitan.on('extensionUnloaded', this._onExtensionUnloaded.bind(this));
this._onVisibleChange({value: this.isVisibleSync()});
this._themeController.prepare();
}
Expand Down Expand Up @@ -626,14 +626,14 @@ export class Popup extends EventDispatcher {
if (this._frameClient === null || !this._frameClient.isConnected() || contentWindow === null) { return; }

const message = this._frameClient.createMessage({action, params});
return await yomichan.crossFrame.invoke(this._frameClient.frameId, 'popupMessage', message);
return await yomitan.crossFrame.invoke(this._frameClient.frameId, 'popupMessage', message);
}

async _invokeSafe(action, params={}, defaultReturnValue) {
try {
return await this._invoke(action, params);
} catch (e) {
if (!yomichan.isExtensionUnloaded) { throw e; }
if (!yomitan.isExtensionUnloaded) { throw e; }
return defaultReturnValue;
}
}
Expand Down Expand Up @@ -884,7 +884,7 @@ export class Popup extends EventDispatcher {

async _setOptionsContext(optionsContext) {
this._optionsContext = optionsContext;
const options = await yomichan.api.optionsGet(optionsContext);
const options = await yomitan.api.optionsGet(optionsContext);
const {general} = options;
this._themeController.theme = general.popupTheme;
this._themeController.outerTheme = general.popupOuterTheme;
Expand Down
Loading

0 comments on commit c413416

Please sign in to comment.