From b656c90ba163ba184763698e29e672d7f98ecda5 Mon Sep 17 00:00:00 2001 From: ShittyKopper Date: Thu, 28 Dec 2023 17:00:27 +0300 Subject: [PATCH] feat: alt text ocr models are currently downloaded from cdn.jsdelivr.net, didn't want to bundle them in as to not bloat the repo and images, but it shouldn't be *that* hard to do that if desired (they're like 2-10 MBs per language anyway) --- locales/en-US.yml | 5 + locales/index.d.ts | 109 ++++++++++++++ locales/ja-JP.yml | 112 +++++++++++++- packages/frontend/package.json | 4 +- .../components/MkFileCaptionEditWindow.vue | 69 ++++++++- pnpm-lock.yaml | 142 ++++++++++++------ scripts/build-assets.mjs | 10 ++ 7 files changed, 403 insertions(+), 48 deletions(-) diff --git a/locales/en-US.yml b/locales/en-US.yml index c1e39778b..4d25b8e52 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -2472,3 +2472,8 @@ _dataSaver: _code: title: "Code highlighting" description: "If code highlighting notations are used in MFM, etc., they will not load until tapped. Syntax highlighting requires downloading the highlight definition files for each programming language. Therefore, disabling the automatic loading of these files is expected to reduce the amount of communication data." + +_ocr: + button: OCR + existingWarning: Existing caption will be overwritten + dataWarning: OCR may require additional downloads diff --git a/locales/index.d.ts b/locales/index.d.ts index dd2f34a69..4f7999fd5 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -2648,6 +2648,115 @@ export interface Locale { "description": string; }; }; + "_ocr": { + "button": string; + "existingWarning": string; + "dataWarning": string; + "languages": { + "afr": string; + "amh": string; + "ara": string; + "asm": string; + "aze": string; + "aze_cyrl": string; + "bel": string; + "ben": string; + "bod": string; + "bos": string; + "bul": string; + "cat": string; + "ceb": string; + "ces": string; + "chi_sim": string; + "chi_tra": string; + "chr": string; + "cym": string; + "dan": string; + "deu": string; + "dzo": string; + "ell": string; + "eng": string; + "enm": string; + "epo": string; + "est": string; + "eus": string; + "fas": string; + "fin": string; + "fra": string; + "frk": string; + "frm": string; + "gle": string; + "glg": string; + "grc": string; + "guj": string; + "hat": string; + "heb": string; + "hin": string; + "hrv": string; + "hun": string; + "iku": string; + "ind": string; + "isl": string; + "ita": string; + "ita_old": string; + "jav": string; + "jpn": string; + "kan": string; + "kat": string; + "kat_old": string; + "kaz": string; + "khm": string; + "kir": string; + "kor": string; + "kur": string; + "lao": string; + "lat": string; + "lav": string; + "lit": string; + "mal": string; + "mar": string; + "mkd": string; + "mlt": string; + "msa": string; + "mya": string; + "nep": string; + "nld": string; + "nor": string; + "ori": string; + "pan": string; + "pol": string; + "por": string; + "pus": string; + "ron": string; + "rus": string; + "san": string; + "sin": string; + "slk": string; + "slv": string; + "spa": string; + "spa_old": string; + "sqi": string; + "srp": string; + "srp_latn": string; + "swa": string; + "swe": string; + "syr": string; + "tam": string; + "tel": string; + "tgk": string; + "tgl": string; + "tha": string; + "tir": string; + "tur": string; + "uig": string; + "ukr": string; + "urd": string; + "uzb": string; + "uzb_cyrl": string; + "vie": string; + "yid": string; + }; + }; } declare const locales: { [lang: string]: Locale; diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index b632fbad6..5baf5b2e0 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -2516,7 +2516,7 @@ _dataRequest: warn: "データのリクエストは3日ごとにしかできない。" text: "データのダウンロードが完了すると、このアカウントに登録されているEメールアドレスにEメールが送信されます。" button: "リクエスト" - + _dataSaver: _media: title: "メディアの読み込み" @@ -2530,3 +2530,113 @@ _dataSaver: _code: title: "コードハイライト" description: "MFMなどでコードハイライト記法が使われている場合、タップするまで読み込まれなくなります。コードハイライトではハイライトする言語ごとにその定義ファイルを読み込む必要がありますが、それらが自動で読み込まれなくなるため、通信量の削減が見込めます。" + +_ocr: + button: OCR + existingWarning: 既存のキャプションは上書きされる + dataWarning: OCRは追加ダウンロードが必要な場合があります。 + + # https://tesseract-ocr.github.io/tessdoc/Data-Files#data-files-for-version-400-november-29-2016 + languages: + afr: Afrikaans + amh: Amharic + ara: Arabic + asm: Assamese + aze: Azerbaijani + aze_cyrl: Azerbaijani - Cyrillic + bel: Belarusian + ben: Bengali + bod: Tibetan + bos: Bosnian + bul: Bulgarian + cat: Catalan; Valencian + ceb: Cebuano + ces: Czech + chi_sim: Chinese - Simplified + chi_tra: Chinese - Traditional + chr: Cherokee + cym: Welsh + dan: Danish + deu: German + dzo: Dzongkha + ell: Greek, Modern (1453-) + eng: English + enm: English, Middle (1100-1500) + epo: Esperanto + est: Estonian + eus: Basque + fas: Persian + fin: Finnish + fra: French + frk: German Fraktur + frm: French, Middle (ca. 1400-1600) + gle: Irish + glg: Galician + grc: Greek, Ancient (-1453) + guj: Gujarati + hat: Haitian; Haitian Creole + heb: Hebrew + hin: Hindi + hrv: Croatian + hun: Hungarian + iku: Inuktitut + ind: Indonesian + isl: Icelandic + ita: Italian + ita_old: Italian - Old + jav: Javanese + jpn: Japanese + kan: Kannada + kat: Georgian + kat_old: Georgian - Old + kaz: Kazakh + khm: Central Khmer + kir: Kirghiz; Kyrgyz + kor: Korean + kur: Kurdish + lao: Lao + lat: Latin + lav: Latvian + lit: Lithuanian + mal: Malayalam + mar: Marathi + mkd: Macedonian + mlt: Maltese + msa: Malay + mya: Burmese + nep: Nepali + nld: Dutch; Flemish + nor: Norwegian + ori: Oriya + pan: Panjabi; Punjabi + pol: Polish + por: Portuguese + pus: Pushto; Pashto + ron: Romanian; Moldavian; Moldovan + rus: Russian + san: Sanskrit + sin: Sinhala; Sinhalese + slk: Slovak + slv: Slovenian + spa: Spanish; Castilian + spa_old: Spanish; Castilian - Old + sqi: Albanian + srp: Serbian + srp_latn: Serbian - Latin + swa: Swahili + swe: Swedish + syr: Syriac + tam: Tamil + tel: Telugu + tgk: Tajik + tgl: Tagalog + tha: Thai + tir: Tigrinya + tur: Turkish + uig: Uighur; Uyghur + ukr: Ukrainian + urd: Urdu + uzb: Uzbek + uzb_cyrl: Uzbek - Cyrillic + vie: Vietnamese + yid: Yiddish diff --git a/packages/frontend/package.json b/packages/frontend/package.json index 496a083aa..b6cf6fba3 100644 --- a/packages/frontend/package.json +++ b/packages/frontend/package.json @@ -19,12 +19,12 @@ "dependencies": { "@discordapp/twemoji": "15.0.2", "@github/webauthn-json": "2.1.1", + "@phosphor-icons/web": "^2.0.3", "@rollup/plugin-json": "6.1.0", "@rollup/plugin-replace": "5.0.5", "@rollup/pluginutils": "5.1.0", "@sharkey/sfm-js": "0.24.1", "@syuilo/aiscript": "0.16.0", - "@phosphor-icons/web": "^2.0.3", "@twemoji/parser": "15.0.0", "@vitejs/plugin-vue": "4.5.2", "@vue/compiler-sfc": "3.3.12", @@ -61,6 +61,7 @@ "sass": "1.69.5", "shiki": "0.14.7", "strict-event-emitter-types": "2.0.0", + "tesseract.js": "^5.0.4", "textarea-caret": "3.1.0", "three": "0.159.0", "throttle-debounce": "5.0.0", @@ -129,6 +130,7 @@ "storybook": "7.6.5", "storybook-addon-misskey-theme": "github:misskey-dev/storybook-addon-misskey-theme", "summaly": "github:misskey-dev/summaly", + "tesseract.js-core": "v5.0.0", "vite-plugin-turbosnap": "1.0.3", "vitest": "0.34.6", "vitest-fetch-mock": "0.2.2", diff --git a/packages/frontend/src/components/MkFileCaptionEditWindow.vue b/packages/frontend/src/components/MkFileCaptionEditWindow.vue index b799fb944..647386bf8 100644 --- a/packages/frontend/src/components/MkFileCaptionEditWindow.vue +++ b/packages/frontend/src/components/MkFileCaptionEditWindow.vue @@ -7,7 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only + {{ i18n.ts._ocr.button }} +
+ + + + {{ i18n.ts._ocr.button }} +
@@ -27,10 +34,15 @@ SPDX-License-Identifier: AGPL-3.0-only + + diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 62cf9ef9a..49c9d4b3c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -786,6 +786,9 @@ importers: strict-event-emitter-types: specifier: 2.0.0 version: 2.0.0 + tesseract.js: + specifier: ^5.0.4 + version: 5.0.4 textarea-caret: specifier: 3.1.0 version: 3.1.0 @@ -985,6 +988,9 @@ importers: summaly: specifier: github:misskey-dev/summaly version: github.com/misskey-dev/summaly/d2a3e07205c3c9769bc5a7b42031c8884b5a25c8 + tesseract.js-core: + specifier: v5.0.0 + version: 5.0.0 vite-plugin-turbosnap: specifier: 1.0.3 version: 1.0.3 @@ -1889,7 +1895,7 @@ packages: '@babel/traverse': 7.23.4 '@babel/types': 7.23.4 convert-source-map: 2.0.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) gensync: 1.0.0-beta.2 json5: 2.2.3 semver: 6.3.1 @@ -2011,7 +2017,7 @@ packages: '@babel/core': 7.23.3 '@babel/helper-compilation-targets': 7.23.6 '@babel/helper-plugin-utils': 7.22.5 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) lodash.debounce: 4.0.8 resolve: 1.22.8 transitivePeerDependencies: @@ -3263,7 +3269,7 @@ packages: '@babel/helper-split-export-declaration': 7.22.6 '@babel/parser': 7.23.4 '@babel/types': 7.23.4 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) globals: 11.12.0 transitivePeerDependencies: - supports-color @@ -4143,7 +4149,7 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: ajv: 6.12.6 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) espree: 9.6.1 globals: 13.23.0 ignore: 5.3.0 @@ -4160,7 +4166,7 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: ajv: 6.12.6 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) espree: 9.6.1 globals: 13.23.0 ignore: 5.3.0 @@ -4431,7 +4437,7 @@ packages: engines: {node: '>=10.10.0'} dependencies: '@humanwhocodes/object-schema': 2.0.1 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) minimatch: 3.1.2 transitivePeerDependencies: - supports-color @@ -4956,7 +4962,7 @@ packages: '@open-draft/until': 1.0.3 '@types/debug': 4.1.7 '@xmldom/xmldom': 0.8.6 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) headers-polyfill: 3.2.5 outvariant: 1.4.0 strict-event-emitter: 0.2.8 @@ -8245,7 +8251,7 @@ packages: '@typescript-eslint/type-utils': 6.11.0(eslint@8.53.0)(typescript@5.3.3) '@typescript-eslint/utils': 6.11.0(eslint@8.53.0)(typescript@5.3.3) '@typescript-eslint/visitor-keys': 6.11.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) eslint: 8.53.0 graphemer: 1.4.0 ignore: 5.3.0 @@ -8274,7 +8280,7 @@ packages: '@typescript-eslint/type-utils': 6.12.0(eslint@8.54.0)(typescript@5.1.6) '@typescript-eslint/utils': 6.12.0(eslint@8.54.0)(typescript@5.1.6) '@typescript-eslint/visitor-keys': 6.12.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) eslint: 8.54.0 graphemer: 1.4.0 ignore: 5.3.0 @@ -8303,7 +8309,7 @@ packages: '@typescript-eslint/type-utils': 6.14.0(eslint@8.56.0)(typescript@5.3.3) '@typescript-eslint/utils': 6.14.0(eslint@8.56.0)(typescript@5.3.3) '@typescript-eslint/visitor-keys': 6.14.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) eslint: 8.56.0 graphemer: 1.4.0 ignore: 5.3.0 @@ -8329,7 +8335,7 @@ packages: '@typescript-eslint/types': 6.11.0 '@typescript-eslint/typescript-estree': 6.11.0(typescript@5.3.3) '@typescript-eslint/visitor-keys': 6.11.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) eslint: 8.53.0 typescript: 5.3.3 transitivePeerDependencies: @@ -8350,7 +8356,7 @@ packages: '@typescript-eslint/types': 6.12.0 '@typescript-eslint/typescript-estree': 6.12.0(typescript@5.1.6) '@typescript-eslint/visitor-keys': 6.12.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) eslint: 8.54.0 typescript: 5.1.6 transitivePeerDependencies: @@ -8371,7 +8377,7 @@ packages: '@typescript-eslint/types': 6.14.0 '@typescript-eslint/typescript-estree': 6.14.0(typescript@5.3.3) '@typescript-eslint/visitor-keys': 6.14.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) eslint: 8.56.0 typescript: 5.3.3 transitivePeerDependencies: @@ -8414,7 +8420,7 @@ packages: dependencies: '@typescript-eslint/typescript-estree': 6.11.0(typescript@5.3.3) '@typescript-eslint/utils': 6.11.0(eslint@8.53.0)(typescript@5.3.3) - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) eslint: 8.53.0 ts-api-utils: 1.0.3(typescript@5.3.3) typescript: 5.3.3 @@ -8434,7 +8440,7 @@ packages: dependencies: '@typescript-eslint/typescript-estree': 6.12.0(typescript@5.1.6) '@typescript-eslint/utils': 6.12.0(eslint@8.54.0)(typescript@5.1.6) - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) eslint: 8.54.0 ts-api-utils: 1.0.3(typescript@5.1.6) typescript: 5.1.6 @@ -8454,7 +8460,7 @@ packages: dependencies: '@typescript-eslint/typescript-estree': 6.14.0(typescript@5.3.3) '@typescript-eslint/utils': 6.14.0(eslint@8.56.0)(typescript@5.3.3) - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) eslint: 8.56.0 ts-api-utils: 1.0.3(typescript@5.3.3) typescript: 5.3.3 @@ -8488,7 +8494,7 @@ packages: dependencies: '@typescript-eslint/types': 6.11.0 '@typescript-eslint/visitor-keys': 6.11.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) globby: 11.1.0 is-glob: 4.0.3 semver: 7.5.4 @@ -8509,7 +8515,7 @@ packages: dependencies: '@typescript-eslint/types': 6.12.0 '@typescript-eslint/visitor-keys': 6.12.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) globby: 11.1.0 is-glob: 4.0.3 semver: 7.5.4 @@ -8530,7 +8536,7 @@ packages: dependencies: '@typescript-eslint/types': 6.14.0 '@typescript-eslint/visitor-keys': 6.14.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) globby: 11.1.0 is-glob: 4.0.3 semver: 7.5.4 @@ -8969,7 +8975,7 @@ packages: resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==} engines: {node: '>= 6.0.0'} dependencies: - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) transitivePeerDependencies: - supports-color @@ -8977,7 +8983,7 @@ packages: resolution: {integrity: sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==} engines: {node: '>= 14'} dependencies: - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) transitivePeerDependencies: - supports-color dev: false @@ -9374,7 +9380,7 @@ packages: resolution: {integrity: sha512-TAlMYvOuwGyLK3PfBb5WKBXZmXz2fVCgv23d6zZFdle/q3gPjmxBaeuC0pY0Dzs5PWMSgfqqEZkrye19GlDTgw==} dependencies: archy: 1.0.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) fastq: 1.15.0 transitivePeerDependencies: - supports-color @@ -9624,6 +9630,10 @@ packages: resolution: {integrity: sha512-cRygWd7kGBQO3VEhPiTgq4Wc43ctsM+o46urrmPOiuAe+07fzlSB9OJVdpgDL0jPqXUVQ9ht7aq7kxOeJHRK+w==} dev: false + /bmp-js@0.1.0: + resolution: {integrity: sha512-vHdS19CnY3hwiNdkaqk93DvjVLfbEcI8mys4UjuWrlX1haDmroo8o4xCzh4wD6DGV6HxRCyauwhHRqMTfERtjw==} + dev: false + /bn.js@4.12.0: resolution: {integrity: sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==} dev: false @@ -10829,7 +10839,6 @@ packages: dependencies: ms: 2.1.2 supports-color: 5.5.0 - dev: true /debug@4.3.4(supports-color@8.1.1): resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} @@ -10842,6 +10851,7 @@ packages: dependencies: ms: 2.1.2 supports-color: 8.1.1 + dev: true /decamelize-keys@1.1.1: resolution: {integrity: sha512-WiPxgEirIV0/eIOMcnFBA3/IJZAZqKnwAwWyvvdi4lsr1WCN22nhdf/3db3DoZcUjTV2SqfzIwNyp6y2xs3nmg==} @@ -11054,7 +11064,7 @@ packages: hasBin: true dependencies: address: 1.2.2 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) transitivePeerDependencies: - supports-color dev: true @@ -11375,7 +11385,7 @@ packages: peerDependencies: esbuild: '>=0.12 <1' dependencies: - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) esbuild: 0.18.17 transitivePeerDependencies: - supports-color @@ -11657,7 +11667,7 @@ packages: ajv: 6.12.6 chalk: 4.1.2 cross-spawn: 7.0.3 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) doctrine: 3.0.0 escape-string-regexp: 4.0.0 eslint-scope: 7.2.2 @@ -11704,7 +11714,7 @@ packages: ajv: 6.12.6 chalk: 4.1.2 cross-spawn: 7.0.3 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) doctrine: 3.0.0 escape-string-regexp: 4.0.0 eslint-scope: 7.2.2 @@ -11751,7 +11761,7 @@ packages: ajv: 6.12.6 chalk: 4.1.2 cross-spawn: 7.0.3 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) doctrine: 3.0.0 escape-string-regexp: 4.0.0 eslint-scope: 7.2.2 @@ -12389,7 +12399,7 @@ packages: debug: optional: true dependencies: - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) /for-each@0.3.3: resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==} @@ -13038,7 +13048,7 @@ packages: engines: {node: '>= 14'} dependencies: agent-base: 7.1.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) transitivePeerDependencies: - supports-color dev: false @@ -13079,7 +13089,7 @@ packages: engines: {node: '>= 6.0.0'} dependencies: agent-base: 5.1.1 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) transitivePeerDependencies: - supports-color dev: true @@ -13089,7 +13099,7 @@ packages: engines: {node: '>= 6'} dependencies: agent-base: 6.0.2 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) transitivePeerDependencies: - supports-color @@ -13098,7 +13108,7 @@ packages: engines: {node: '>= 14'} dependencies: agent-base: 7.1.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) transitivePeerDependencies: - supports-color dev: false @@ -13108,7 +13118,7 @@ packages: engines: {node: '>= 14'} dependencies: agent-base: 7.1.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) transitivePeerDependencies: - supports-color dev: false @@ -13258,7 +13268,7 @@ packages: dependencies: '@ioredis/commands': 1.2.0 cluster-key-slot: 1.1.2 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) denque: 2.1.0 lodash.defaults: 4.2.0 lodash.isarguments: 3.1.0 @@ -13387,6 +13397,10 @@ packages: hasBin: true dev: true + /is-electron@2.2.2: + resolution: {integrity: sha512-FO/Rhvz5tuw4MCWkpMzHFKWD2LsfHzIb7i6MdPYZ/KW7AlxawyLkqdy+jPZP1WubqEADE3O4FUENlJHDfQASRg==} + dev: false + /is-expression@4.0.0: resolution: {integrity: sha512-zMIXX63sxzG3XrkHkrAPvm/OVZVSCPNkwMHU8oTX7/U3AL78I0QXCEICXUM13BIa8TYGZ68PiTKfQz3yaTNr4A==} dependencies: @@ -13586,6 +13600,10 @@ packages: engines: {node: '>=10'} dev: true + /is-url@1.2.4: + resolution: {integrity: sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww==} + dev: false + /is-weakmap@2.0.1: resolution: {integrity: sha512-NSBR4kH5oVj1Uwvv970ruUkCV7O1mzgVFO4/rev2cLRda9Tm9HrL70ZPut4rOHgY0FNrUu9BCbXA2sdQ+x0chA==} dev: true @@ -13687,7 +13705,7 @@ packages: resolution: {integrity: sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==} engines: {node: '>=10'} dependencies: - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) istanbul-lib-coverage: 3.2.0 source-map: 0.6.1 transitivePeerDependencies: @@ -14363,7 +14381,7 @@ packages: resolution: {integrity: sha512-pJ4XLQP4Q9HTxl6RVDLJ8Cyh1uitSs0CzDBAz1uoJ4sRD/Bk7cFSXL1FUXDW3zJ7YnfliJx6eu8Jn283bpZ4Yg==} engines: {node: '>=10'} dependencies: - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) rfdc: 1.3.0 uri-js: 4.4.1 transitivePeerDependencies: @@ -15720,6 +15738,11 @@ packages: yargs-parser: 21.1.1 dev: true + /opencollective-postinstall@2.0.3: + resolution: {integrity: sha512-8AV/sCtuzUeTo8gQK5qDZzARrulB3egtLzFgteqB2tcT4Mw7B8Kt7JcDHmltjz6FOAHsvTevk70gZEbhM4ZS9Q==} + hasBin: true + dev: false + /opentype.js@0.4.11: resolution: {integrity: sha512-GthxucX/6aftfLdeU5Ho7o7zmQcC8uVtqdcelVq12X++ndxwBZG8Xb5rFEKT7nEcWDD2P1x+TNuJ70jtj1Mbpw==} hasBin: true @@ -16881,7 +16904,7 @@ packages: engines: {node: '>=8.16.0'} dependencies: '@types/mime-types': 2.1.4 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) extract-zip: 1.7.0 https-proxy-agent: 4.0.0 mime: 2.6.0 @@ -17864,7 +17887,7 @@ packages: dependencies: '@hapi/hoek': 10.0.1 '@hapi/wreck': 18.0.1 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) joi: 17.7.0 transitivePeerDependencies: - supports-color @@ -18064,7 +18087,7 @@ packages: engines: {node: '>= 14'} dependencies: agent-base: 7.1.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) socks: 2.7.1 transitivePeerDependencies: - supports-color @@ -18217,7 +18240,7 @@ packages: arg: 5.0.2 bluebird: 3.7.2 check-more-types: 2.24.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) execa: 5.1.1 lazy-ass: 1.6.0 ps-tree: 1.2.0 @@ -18619,6 +18642,27 @@ packages: commander: 2.20.3 source-map-support: 0.5.21 + /tesseract.js-core@5.0.0: + resolution: {integrity: sha512-lJur5LzjinW5VYMKlVNnBU2JPLpO+A9VqAYBeuV+ZgH0hKvsnm+536Yyp+/zRTBdLe7D6Kok0FN9g+TE4J8qGA==} + + /tesseract.js@5.0.4: + resolution: {integrity: sha512-GCIoSQMZlvTP2AaHrjUOH29/oyO7ZyHVe+BhTexEcO7/nDClRVDRjl2sYJLOWSSNbTDrm5q2m1+gfaf3lUrZ5Q==} + requiresBuild: true + dependencies: + bmp-js: 0.1.0 + idb-keyval: 6.2.1 + is-electron: 2.2.2 + is-url: 1.2.4 + node-fetch: 2.7.0 + opencollective-postinstall: 2.0.3 + regenerator-runtime: 0.13.11 + tesseract.js-core: 5.0.0 + wasm-feature-detect: 1.6.1 + zlibjs: 0.3.1 + transitivePeerDependencies: + - encoding + dev: false + /test-exclude@6.0.0: resolution: {integrity: sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==} engines: {node: '>=8'} @@ -19124,7 +19168,7 @@ packages: chalk: 4.1.2 cli-highlight: 2.1.11 date-fns: 2.30.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) dotenv: 16.0.3 glob: 8.1.0 ioredis: 5.3.2 @@ -19483,7 +19527,7 @@ packages: hasBin: true dependencies: cac: 6.7.14 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) mlly: 1.4.0 pathe: 1.1.1 picocolors: 1.0.0 @@ -19595,7 +19639,7 @@ packages: acorn-walk: 8.2.0 cac: 6.7.14 chai: 4.3.10 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) happy-dom: 10.0.3 local-pkg: 0.4.3 magic-string: 0.30.3 @@ -19675,7 +19719,7 @@ packages: peerDependencies: eslint: '>=6.0.0' dependencies: - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4(supports-color@5.5.0) eslint: 8.56.0 eslint-scope: 7.2.2 eslint-visitor-keys: 3.4.3 @@ -19765,6 +19809,10 @@ packages: makeerror: 1.0.12 dev: true + /wasm-feature-detect@1.6.1: + resolution: {integrity: sha512-R1i9ED8UlLu/foILNB1ck9XS63vdtqU/tP1MCugVekETp/ySCrBZRk5I/zI67cI1wlQYeSonNm1PLjDHZDNg6g==} + dev: false + /watchpack@2.4.0: resolution: {integrity: sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg==} engines: {node: '>=10.13.0'} @@ -20199,6 +20247,10 @@ packages: readable-stream: 3.6.0 dev: false + /zlibjs@0.3.1: + resolution: {integrity: sha512-+J9RrgTKOmlxFSDHo0pI1xM6BLVUv+o0ZT9ANtCxGkjIVCCUdx9alUF8Gm+dGLKbkkkidWIHFDZHDMpfITt4+w==} + dev: false + github.com/aiscript-dev/aiscript-vscode/b5a8aa0ad927831a0b867d1c183460a14e6c48cd: resolution: {tarball: https://codeload.github.com/aiscript-dev/aiscript-vscode/tar.gz/b5a8aa0ad927831a0b867d1c183460a14e6c48cd} name: aiscript-vscode diff --git a/scripts/build-assets.mjs b/scripts/build-assets.mjs index 22f0871ca..91a76773e 100644 --- a/scripts/build-assets.mjs +++ b/scripts/build-assets.mjs @@ -42,6 +42,15 @@ async function copyFrontendShikiAssets() { await fs.cp('./packages/frontend/node_modules/shiki/themes', './built/_frontend_dist_/shiki/themes', { dereference: true, recursive: true }); } +async function copyFrontendTesseractAssets() { + // https://github.com/naptha/tesseract.js/blob/master/docs/local-installation.md + await fs.cp('./packages/frontend/node_modules/tesseract.js/dist/worker.min.js', './built/_frontend_dist_/tesseract/worker.min.js', { dereference: true, recursive: true }); + await fs.cp('./packages/frontend/node_modules/tesseract.js-core/tesseract-core.wasm.js', './built/_frontend_dist_/tesseract/core/tesseract-core.wasm.js', { dereference: true, recursive: true }); + await fs.cp('./packages/frontend/node_modules/tesseract.js-core/tesseract-core-simd.wasm.js', './built/_frontend_dist_/tesseract/core/tesseract-core-simd.wasm.js', { dereference: true, recursive: true }); + await fs.cp('./packages/frontend/node_modules/tesseract.js-core/tesseract-core-lstm.wasm.js', './built/_frontend_dist_/tesseract/core/tesseract-core-lstm.wasm.js', { dereference: true, recursive: true }); + await fs.cp('./packages/frontend/node_modules/tesseract.js-core/tesseract-core-simd-lstm.wasm.js', './built/_frontend_dist_/tesseract/core/tesseract-core-simd-lstm.wasm.js', { dereference: true, recursive: true }); +} + async function copyBackendViews() { await fs.cp('./packages/backend/src/server/web/views', './packages/backend/built/server/web/views', { recursive: true }); } @@ -82,6 +91,7 @@ async function build() { copyFrontendTablerIcons(), copyFrontendLocales(), copyFrontendShikiAssets(), + copyFrontendTesseractAssets(), copyBackendViews(), buildBackendScript(), buildBackendStyle(),