From fafa746a632b1907d9cca262f689d7bec4e0f940 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 17 Jul 2021 17:10:25 -0400 Subject: [PATCH] Sandbox script folders (#1837) * Move scripts * Update paths * Fix ordering * Simplify eslint rules --- .eslintrc.json | 28 ++++--------------- dev/translator-vm.js | 6 ++-- docs/templates.md | 2 +- ext/background.html | 4 +-- .../{ => sandbox}/anki-note-data-creator.js | 0 .../{ => sandbox}/pronunciation-generator.js | 0 .../structured-content-generator.js | 0 ext/js/dom/{ => sandbox}/css-style-applier.js | 0 .../{ => sandbox}/dictionary-data-util.js | 0 .../language/{ => sandbox}/japanese-util.js | 0 .../template-renderer-frame-api.js | 0 .../template-renderer-frame-main.js | 0 .../template-renderer-media-provider.js | 0 .../{ => sandbox}/template-renderer.js | 0 ext/popup.html | 8 +++--- ext/search.html | 8 +++--- ext/settings.html | 4 +-- ext/sw.js | 4 +-- ext/template-renderer.html | 18 ++++++------ test/test-anki-note-builder.js | 8 +++--- test/test-japanese-util.js | 2 +- 21 files changed, 37 insertions(+), 55 deletions(-) rename ext/js/data/{ => sandbox}/anki-note-data-creator.js (100%) rename ext/js/display/{ => sandbox}/pronunciation-generator.js (100%) rename ext/js/display/{ => sandbox}/structured-content-generator.js (100%) rename ext/js/dom/{ => sandbox}/css-style-applier.js (100%) rename ext/js/language/{ => sandbox}/dictionary-data-util.js (100%) rename ext/js/language/{ => sandbox}/japanese-util.js (100%) rename ext/js/templates/{ => sandbox}/template-renderer-frame-api.js (100%) rename ext/js/templates/{ => sandbox}/template-renderer-frame-main.js (100%) rename ext/js/templates/{ => sandbox}/template-renderer-media-provider.js (100%) rename ext/js/templates/{ => sandbox}/template-renderer.js (100%) diff --git a/.eslintrc.json b/.eslintrc.json index ad06ff05..3ad61648 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -110,13 +110,7 @@ { "files": [ "ext/js/core.js", - "ext/js/data/anki-note-data-creator.js", - "ext/js/display/pronunciation-generator.js", - "ext/js/display/structured-content-generator.js", - "ext/js/dom/css-style-applier.js", - "ext/js/language/dictionary-data-util.js", - "ext/js/templates/template-renderer.js", - "ext/js/templates/template-renderer-media-provider.js" + "ext/js/**/sandbox/**/*.js" ], "env": { "webextensions": false @@ -126,13 +120,7 @@ "files": ["ext/**/*.js"], "excludedFiles": [ "ext/js/core.js", - "ext/js/data/anki-note-data-creator.js", - "ext/js/display/pronunciation-generator.js", - "ext/js/display/structured-content-generator.js", - "ext/js/dom/css-style-applier.js", - "ext/js/language/dictionary-data-util.js", - "ext/js/templates/template-renderer.js", - "ext/js/templates/template-renderer-media-provider.js" + "ext/js/**/sandbox/**/*.js" ], "globals": { "serializeError": "readonly", @@ -159,13 +147,7 @@ "excludedFiles": [ "ext/js/core.js", "ext/js/yomichan.js", - "ext/js/data/anki-note-data-creator.js", - "ext/js/display/pronunciation-generator.js", - "ext/js/display/structured-content-generator.js", - "ext/js/dom/css-style-applier.js", - "ext/js/language/dictionary-data-util.js", - "ext/js/templates/template-renderer.js", - "ext/js/templates/template-renderer-media-provider.js" + "ext/js/**/sandbox/**/*.js" ], "globals": { "yomichan": "readonly" @@ -217,9 +199,9 @@ "ext/js/general/regex-util.js", "ext/js/general/text-source-map.js", "ext/js/language/deinflector.js", - "ext/js/language/dictionary-data-util.js", "ext/js/language/dictionary-database.js", - "ext/js/language/japanese-util.js", + "ext/js/language/sandbox/dictionary-data-util.js", + "ext/js/language/sandbox/japanese-util.js", "ext/js/language/translator.js", "ext/js/media/audio-downloader.js", "ext/js/media/media-util.js", diff --git a/dev/translator-vm.js b/dev/translator-vm.js index d628608a..742036a8 100644 --- a/dev/translator-vm.js +++ b/dev/translator-vm.js @@ -45,17 +45,17 @@ class TranslatorVM extends DatabaseVM { async prepare(dictionaryDirectory, dictionaryName) { this.execute([ 'js/core.js', - 'js/data/anki-note-data-creator.js', + 'js/data/sandbox/anki-note-data-creator.js', 'js/data/database.js', 'js/data/json-schema.js', 'js/general/cache-map.js', 'js/general/regex-util.js', 'js/general/text-source-map.js', 'js/language/deinflector.js', - 'js/language/dictionary-data-util.js', + 'js/language/sandbox/dictionary-data-util.js', 'js/language/dictionary-importer.js', 'js/language/dictionary-database.js', - 'js/language/japanese-util.js', + 'js/language/sandbox/japanese-util.js', 'js/language/translator.js', 'js/media/media-util.js' ]); diff --git a/docs/templates.md b/docs/templates.md index 28878c87..8ee3bb0c 100644 --- a/docs/templates.md +++ b/docs/templates.md @@ -3,7 +3,7 @@ ## Helpers Yomichan supports several custom Handlebars helpers for rendering templates. -The source code for these templates can be found [here](../ext/js/templates/template-renderer.js). +The source code for these templates can be found [here](../ext/js/templates/sandbox/template-renderer.js). ### `dumpObject` diff --git a/ext/background.html b/ext/background.html index 15cd0b8c..57caa671 100644 --- a/ext/background.html +++ b/ext/background.html @@ -42,9 +42,9 @@ - - + + diff --git a/ext/js/data/anki-note-data-creator.js b/ext/js/data/sandbox/anki-note-data-creator.js similarity index 100% rename from ext/js/data/anki-note-data-creator.js rename to ext/js/data/sandbox/anki-note-data-creator.js diff --git a/ext/js/display/pronunciation-generator.js b/ext/js/display/sandbox/pronunciation-generator.js similarity index 100% rename from ext/js/display/pronunciation-generator.js rename to ext/js/display/sandbox/pronunciation-generator.js diff --git a/ext/js/display/structured-content-generator.js b/ext/js/display/sandbox/structured-content-generator.js similarity index 100% rename from ext/js/display/structured-content-generator.js rename to ext/js/display/sandbox/structured-content-generator.js diff --git a/ext/js/dom/css-style-applier.js b/ext/js/dom/sandbox/css-style-applier.js similarity index 100% rename from ext/js/dom/css-style-applier.js rename to ext/js/dom/sandbox/css-style-applier.js diff --git a/ext/js/language/dictionary-data-util.js b/ext/js/language/sandbox/dictionary-data-util.js similarity index 100% rename from ext/js/language/dictionary-data-util.js rename to ext/js/language/sandbox/dictionary-data-util.js diff --git a/ext/js/language/japanese-util.js b/ext/js/language/sandbox/japanese-util.js similarity index 100% rename from ext/js/language/japanese-util.js rename to ext/js/language/sandbox/japanese-util.js diff --git a/ext/js/templates/template-renderer-frame-api.js b/ext/js/templates/sandbox/template-renderer-frame-api.js similarity index 100% rename from ext/js/templates/template-renderer-frame-api.js rename to ext/js/templates/sandbox/template-renderer-frame-api.js diff --git a/ext/js/templates/template-renderer-frame-main.js b/ext/js/templates/sandbox/template-renderer-frame-main.js similarity index 100% rename from ext/js/templates/template-renderer-frame-main.js rename to ext/js/templates/sandbox/template-renderer-frame-main.js diff --git a/ext/js/templates/template-renderer-media-provider.js b/ext/js/templates/sandbox/template-renderer-media-provider.js similarity index 100% rename from ext/js/templates/template-renderer-media-provider.js rename to ext/js/templates/sandbox/template-renderer-media-provider.js diff --git a/ext/js/templates/template-renderer.js b/ext/js/templates/sandbox/template-renderer.js similarity index 100% rename from ext/js/templates/template-renderer.js rename to ext/js/templates/sandbox/template-renderer.js diff --git a/ext/popup.html b/ext/popup.html index 065bcfa1..1f336943 100644 --- a/ext/popup.html +++ b/ext/popup.html @@ -110,9 +110,9 @@ - - + + @@ -125,8 +125,8 @@ - - + + diff --git a/ext/search.html b/ext/search.html index beceeb18..f32b5412 100644 --- a/ext/search.html +++ b/ext/search.html @@ -94,12 +94,12 @@ - + + - @@ -111,8 +111,8 @@ - - + + diff --git a/ext/settings.html b/ext/settings.html index b45d8c22..9d2d9791 100644 --- a/ext/settings.html +++ b/ext/settings.html @@ -3449,10 +3449,10 @@ - - + + diff --git a/ext/sw.js b/ext/sw.js index a1fb7ea1..6394260e 100644 --- a/ext/sw.js +++ b/ext/sw.js @@ -39,9 +39,9 @@ self.importScripts( '/js/general/regex-util.js', '/js/general/text-source-map.js', '/js/language/deinflector.js', - '/js/language/dictionary-data-util.js', '/js/language/dictionary-database.js', - '/js/language/japanese-util.js', + '/js/language/sandbox/dictionary-data-util.js', + '/js/language/sandbox/japanese-util.js', '/js/language/translator.js', '/js/media/audio-downloader.js', '/js/media/media-util.js', diff --git a/ext/template-renderer.html b/ext/template-renderer.html index a3812b37..9e0769f9 100644 --- a/ext/template-renderer.html +++ b/ext/template-renderer.html @@ -17,16 +17,16 @@ - - - - - - - - + + + + + + + + - + diff --git a/test/test-anki-note-builder.js b/test/test-anki-note-builder.js index 4433e3e6..d6b41c3b 100644 --- a/test/test-anki-note-builder.js +++ b/test/test-anki-note-builder.js @@ -43,10 +43,10 @@ async function createVM() { vm.execute([ 'js/data/anki-note-builder.js', 'js/data/anki-util.js', - 'js/dom/css-style-applier.js', - 'js/display/structured-content-generator.js', - 'js/templates/template-renderer.js', - 'js/templates/template-renderer-media-provider.js', + 'js/dom/sandbox/css-style-applier.js', + 'js/display/sandbox/structured-content-generator.js', + 'js/templates/sandbox/template-renderer.js', + 'js/templates/sandbox/template-renderer-media-provider.js', 'lib/handlebars.min.js' ]); diff --git a/test/test-japanese-util.js b/test/test-japanese-util.js index 82abf50b..bfeac4f5 100644 --- a/test/test-japanese-util.js +++ b/test/test-japanese-util.js @@ -22,7 +22,7 @@ const {VM} = require('../dev/vm'); const vm = new VM(); vm.execute([ 'lib/wanakana.min.js', - 'js/language/japanese-util.js', + 'js/language/sandbox/japanese-util.js', 'js/general/text-source-map.js' ]); const [JapaneseUtil, TextSourceMap, wanakana] = vm.get(['JapaneseUtil', 'TextSourceMap', 'wanakana']);