diff options
author | Darius Jahandarie <djahandarie@gmail.com> | 2023-11-09 13:30:31 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-09 13:30:31 +0000 |
commit | 5c5a167b4792af379cdacf633513cebf20728cd2 (patch) | |
tree | 5b6be3620a557d0b9177047003f6d742d9d2a32d /ext/js/comm | |
parent | b64f51c3b13a46af4dd7f1e43048ac19c781ca7b (diff) | |
parent | 0f4d36938fd0d844f548aa5a7f7e7842df8dfb41 (diff) |
Merge pull request #307 from themoeway/modernize
Modernize codebase
Diffstat (limited to 'ext/js/comm')
-rw-r--r-- | ext/js/comm/anki-connect.js | 7 | ||||
-rw-r--r-- | ext/js/comm/api.js | 4 | ||||
-rw-r--r-- | ext/js/comm/clipboard-monitor.js | 4 | ||||
-rw-r--r-- | ext/js/comm/clipboard-reader.js | 6 | ||||
-rw-r--r-- | ext/js/comm/cross-frame-api.js | 5 | ||||
-rw-r--r-- | ext/js/comm/frame-ancestry-handler.js | 5 | ||||
-rw-r--r-- | ext/js/comm/frame-client.js | 4 | ||||
-rw-r--r-- | ext/js/comm/frame-endpoint.js | 5 | ||||
-rw-r--r-- | ext/js/comm/frame-offset-forwarder.js | 7 | ||||
-rw-r--r-- | ext/js/comm/mecab.js | 4 |
10 files changed, 32 insertions, 19 deletions
diff --git a/ext/js/comm/anki-connect.js b/ext/js/comm/anki-connect.js index b5e4d16d..09838ea5 100644 --- a/ext/js/comm/anki-connect.js +++ b/ext/js/comm/anki-connect.js @@ -16,14 +16,13 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -/* global - * AnkiUtil - */ +import {isObject} from '../core.js'; +import {AnkiUtil} from '../data/anki-util.js'; /** * This class controls communication with Anki via the AnkiConnect plugin. */ -class AnkiConnect { +export class AnkiConnect { /** * Creates a new instance. */ diff --git a/ext/js/comm/api.js b/ext/js/comm/api.js index 72d2ba07..8e5cd5cc 100644 --- a/ext/js/comm/api.js +++ b/ext/js/comm/api.js @@ -16,7 +16,9 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -class API { +import {deferPromise, deserializeError, isObject} from '../core.js'; + +export class API { constructor(yomichan) { this._yomichan = yomichan; } diff --git a/ext/js/comm/clipboard-monitor.js b/ext/js/comm/clipboard-monitor.js index fbf56432..c5046046 100644 --- a/ext/js/comm/clipboard-monitor.js +++ b/ext/js/comm/clipboard-monitor.js @@ -16,7 +16,9 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -class ClipboardMonitor extends EventDispatcher { +import {EventDispatcher} from '../core.js'; + +export class ClipboardMonitor extends EventDispatcher { constructor({japaneseUtil, clipboardReader}) { super(); this._japaneseUtil = japaneseUtil; diff --git a/ext/js/comm/clipboard-reader.js b/ext/js/comm/clipboard-reader.js index 1ea507b8..8139cc11 100644 --- a/ext/js/comm/clipboard-reader.js +++ b/ext/js/comm/clipboard-reader.js @@ -16,14 +16,12 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -/* global - * MediaUtil - */ +import {MediaUtil} from '../media/media-util.js'; /** * Class which can read text and images from the clipboard. */ -class ClipboardReader { +export class ClipboardReader { /** * Creates a new instances of a clipboard reader. * @param {object} details Details about how to set up the instance. diff --git a/ext/js/comm/cross-frame-api.js b/ext/js/comm/cross-frame-api.js index fb2a1718..c7d9ae68 100644 --- a/ext/js/comm/cross-frame-api.js +++ b/ext/js/comm/cross-frame-api.js @@ -16,6 +16,9 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ +import {EventDispatcher, EventListenerCollection, deserializeError, invokeMessageHandler, log, serializeError} from '../core.js'; +import {yomichan} from '../yomichan.js'; + class CrossFrameAPIPort extends EventDispatcher { constructor(otherTabId, otherFrameId, port, messageHandlers) { super(); @@ -217,7 +220,7 @@ class CrossFrameAPIPort extends EventDispatcher { } } -class CrossFrameAPI { +export class CrossFrameAPI { constructor() { this._ackTimeout = 3000; // 3 seconds this._responseTimeout = 10000; // 10 seconds diff --git a/ext/js/comm/frame-ancestry-handler.js b/ext/js/comm/frame-ancestry-handler.js index c2e79733..1934c4ac 100644 --- a/ext/js/comm/frame-ancestry-handler.js +++ b/ext/js/comm/frame-ancestry-handler.js @@ -16,13 +16,16 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ +import {generateId} from '../core.js'; +import {yomichan} from '../yomichan.js'; + /** * This class is used to return the ancestor frame IDs for the current frame. * This is a workaround to using the `webNavigation.getAllFrames` API, which * would require an additional permission that is otherwise unnecessary. * It is also used to track the correlation between child frame elements and their IDs. */ -class FrameAncestryHandler { +export class FrameAncestryHandler { /** * Creates a new instance. * @param {number} frameId The frame ID of the current frame the instance is instantiated in. diff --git a/ext/js/comm/frame-client.js b/ext/js/comm/frame-client.js index 46b1f502..0ca37feb 100644 --- a/ext/js/comm/frame-client.js +++ b/ext/js/comm/frame-client.js @@ -16,7 +16,9 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -class FrameClient { +import {deferPromise, generateId, isObject} from '../core.js'; + +export class FrameClient { constructor() { this._secret = null; this._token = null; diff --git a/ext/js/comm/frame-endpoint.js b/ext/js/comm/frame-endpoint.js index dad9f40e..0e8a5c00 100644 --- a/ext/js/comm/frame-endpoint.js +++ b/ext/js/comm/frame-endpoint.js @@ -16,7 +16,10 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -class FrameEndpoint { +import {EventListenerCollection, generateId, isObject} from '../core.js'; +import {yomichan} from '../yomichan.js'; + +export class FrameEndpoint { constructor() { this._secret = generateId(16); this._token = null; diff --git a/ext/js/comm/frame-offset-forwarder.js b/ext/js/comm/frame-offset-forwarder.js index 87c6a9ce..5eea2ba6 100644 --- a/ext/js/comm/frame-offset-forwarder.js +++ b/ext/js/comm/frame-offset-forwarder.js @@ -16,11 +16,10 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -/* global - * FrameAncestryHandler - */ +import {yomichan} from '../yomichan.js'; +import {FrameAncestryHandler} from './frame-ancestry-handler.js'; -class FrameOffsetForwarder { +export class FrameOffsetForwarder { constructor(frameId) { this._frameId = frameId; this._frameAncestryHandler = new FrameAncestryHandler(frameId); diff --git a/ext/js/comm/mecab.js b/ext/js/comm/mecab.js index bdc8c588..50f13ddf 100644 --- a/ext/js/comm/mecab.js +++ b/ext/js/comm/mecab.js @@ -16,11 +16,13 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ +import {EventListenerCollection} from '../core.js'; + /** * This class is used to connect Yomichan to a native component that is * used to parse text into individual terms. */ -class Mecab { +export class Mecab { /** * The resulting data from an invocation of `parseText`. * @typedef {object} ParseResult |