summaryrefslogtreecommitdiff
path: root/ext/js/background
diff options
context:
space:
mode:
authorDarius Jahandarie <djahandarie@gmail.com>2023-11-04 18:45:57 +0900
committerDarius Jahandarie <djahandarie@gmail.com>2023-11-04 18:45:57 +0900
commitef79eab44bfd000792c610b968b5ceefd41e76a0 (patch)
tree48b04f30f6248caedbd880801aa49402a9e8066a /ext/js/background
parent376151096431d4362e4baaacf0cef4a534e169f7 (diff)
Modernize codebase
- Use ES modules - Remove vendored libs and build them from npm using esbuild - Switch from JSZip to zip.js
Diffstat (limited to 'ext/js/background')
-rw-r--r--ext/js/background/backend.js46
-rw-r--r--ext/js/background/background-main.js5
-rw-r--r--ext/js/background/offscreen-main.js4
-rw-r--r--ext/js/background/offscreen.js8
-rw-r--r--ext/js/background/profile-conditions-util.js6
-rw-r--r--ext/js/background/request-builder.js2
-rw-r--r--ext/js/background/script-manager.js3
7 files changed, 35 insertions, 39 deletions
diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js
index 8e8e6945..cccfcbb3 100644
--- a/ext/js/background/backend.js
+++ b/ext/js/background/backend.js
@@ -16,34 +16,34 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-/* global
- * AccessibilityController
- * AnkiConnect
- * AnkiUtil
- * ArrayBufferUtil
- * AudioDownloader
- * ClipboardMonitor
- * ClipboardReader
- * DictionaryDatabase
- * Environment
- * JapaneseUtil
- * Mecab
- * MediaUtil
- * ObjectPropertyAccessor
- * OptionsUtil
- * PermissionsUtil
- * ProfileConditionsUtil
- * RequestBuilder
- * ScriptManager
- * Translator
- * wanakana
- */
+import * as wanakana from '../../lib/wanakana.js';
+import {AccessibilityController} from '../accessibility/accessibility-controller.js';
+import {AnkiConnect} from '../comm/anki-connect.js';
+import {ClipboardMonitor} from '../comm/clipboard-monitor.js';
+import {ClipboardReader} from '../comm/clipboard-reader.js';
+import {Mecab} from '../comm/mecab.js';
+import {clone, deferPromise, deserializeError, generateId, invokeMessageHandler, isObject, log, promiseTimeout, serializeError} from '../core.js';
+import {AnkiUtil} from '../data/anki-util.js';
+import {OptionsUtil} from '../data/options-util.js';
+import {PermissionsUtil} from '../data/permissions-util.js';
+import {ArrayBufferUtil} from '../data/sandbox/array-buffer-util.js';
+import {Environment} from '../extension/environment.js';
+import {ObjectPropertyAccessor} from '../general/object-property-accessor.js';
+import {DictionaryDatabase} from '../language/dictionary-database.js';
+import {JapaneseUtil} from '../language/sandbox/japanese-util.js';
+import {Translator} from '../language/translator.js';
+import {AudioDownloader} from '../media/audio-downloader.js';
+import {MediaUtil} from '../media/media-util.js';
+import {yomichan} from '../yomichan.js';
+import {ProfileConditionsUtil} from './profile-conditions-util.js';
+import {RequestBuilder} from './request-builder.js';
+import {ScriptManager} from './script-manager.js';
/**
* This class controls the core logic of the extension, including API calls
* and various forms of communication between browser tabs and external applications.
*/
-class Backend {
+export class Backend {
/**
* Creates a new instance.
*/
diff --git a/ext/js/background/background-main.js b/ext/js/background/background-main.js
index 3b1d42eb..6c30aa7a 100644
--- a/ext/js/background/background-main.js
+++ b/ext/js/background/background-main.js
@@ -16,9 +16,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-/* global
- * Backend
- */
+import {yomichan} from '../yomichan.js';
+import {Backend} from './backend.js';
(() => {
yomichan.prepare(true);
diff --git a/ext/js/background/offscreen-main.js b/ext/js/background/offscreen-main.js
index 808e7766..dcbf978f 100644
--- a/ext/js/background/offscreen-main.js
+++ b/ext/js/background/offscreen-main.js
@@ -16,9 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-/* global
- * Offscreen
- */
+import {Offscreen} from './offscreen.js';
(() => {
new Offscreen();
diff --git a/ext/js/background/offscreen.js b/ext/js/background/offscreen.js
index bc41d189..c37cdedc 100644
--- a/ext/js/background/offscreen.js
+++ b/ext/js/background/offscreen.js
@@ -16,15 +16,15 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-/* global
- * ClipboardReader
- */
+import {ClipboardReader} from '../comm/clipboard-reader.js';
+import {invokeMessageHandler} from '../core.js';
+import {yomichan} from '../yomichan.js';
/**
* This class controls the core logic of the extension, including API calls
* and various forms of communication between browser tabs and external applications.
*/
-class Offscreen {
+export class Offscreen {
/**
* Creates a new instance.
*/
diff --git a/ext/js/background/profile-conditions-util.js b/ext/js/background/profile-conditions-util.js
index 1e2c01f8..55b287d7 100644
--- a/ext/js/background/profile-conditions-util.js
+++ b/ext/js/background/profile-conditions-util.js
@@ -16,14 +16,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-/* global
- * JsonSchema
- */
+import {JsonSchema} from '../data/json-schema.js';
/**
* Utility class to help processing profile conditions.
*/
-class ProfileConditionsUtil {
+export class ProfileConditionsUtil {
/**
* A group of conditions.
* @typedef {object} ProfileConditionGroup
diff --git a/ext/js/background/request-builder.js b/ext/js/background/request-builder.js
index 7ee89539..f4f685be 100644
--- a/ext/js/background/request-builder.js
+++ b/ext/js/background/request-builder.js
@@ -20,7 +20,7 @@
* This class is used to generate `fetch()` requests on the background page
* with additional controls over anonymity and error handling.
*/
-class RequestBuilder {
+export class RequestBuilder {
/**
* A progress callback for a fetch read.
* @callback ProgressCallback
diff --git a/ext/js/background/script-manager.js b/ext/js/background/script-manager.js
index 694b64db..3671b854 100644
--- a/ext/js/background/script-manager.js
+++ b/ext/js/background/script-manager.js
@@ -16,10 +16,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+import {isObject} from '../core.js';
/**
* This class is used to manage script injection into content tabs.
*/
-class ScriptManager {
+export class ScriptManager {
/**
* Creates a new instance of the class.
*/