@internetarchive/bookreader 5.0.0-101 → 5.0.0-102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BookReader/474.js +1 -1
- package/BookReader/474.js.map +1 -1
- package/BookReader/BookReader.css +71 -8
- package/BookReader/BookReader.js +1 -1
- package/BookReader/BookReader.js.LICENSE.txt +1 -1
- package/BookReader/BookReader.js.map +1 -1
- package/BookReader/ia-bookreader-bundle.js +52 -52
- package/BookReader/ia-bookreader-bundle.js.LICENSE.txt +7 -1
- package/BookReader/ia-bookreader-bundle.js.map +1 -1
- package/BookReader/icons/1up.svg +1 -1
- package/BookReader/icons/2up.svg +1 -1
- package/BookReader/icons/advance.svg +1 -1
- package/BookReader/icons/chevron-right.svg +1 -1
- package/BookReader/icons/close-circle-dark.svg +1 -1
- package/BookReader/icons/close-circle.svg +1 -1
- package/BookReader/icons/fullscreen.svg +1 -1
- package/BookReader/icons/fullscreen_exit.svg +1 -1
- package/BookReader/icons/hamburger.svg +1 -1
- package/BookReader/icons/left-arrow.svg +1 -1
- package/BookReader/icons/magnify-minus.svg +1 -1
- package/BookReader/icons/magnify-plus.svg +1 -1
- package/BookReader/icons/magnify.svg +1 -1
- package/BookReader/icons/pause.svg +1 -1
- package/BookReader/icons/play.svg +1 -1
- package/BookReader/icons/playback-speed.svg +1 -1
- package/BookReader/icons/read-aloud.svg +1 -1
- package/BookReader/icons/review.svg +1 -1
- package/BookReader/icons/slider-toggle.svg +1 -0
- package/BookReader/icons/thumbnails.svg +1 -1
- package/BookReader/icons/voice.svg +1 -1
- package/BookReader/icons/volume-full.svg +1 -1
- package/BookReader/images/BRicons.svg +2 -2
- package/BookReader/images/books_graphic.svg +1 -1
- package/BookReader/images/icon_book.svg +1 -1
- package/BookReader/images/icon_bookmark.svg +1 -1
- package/BookReader/images/icon_gear.svg +1 -1
- package/BookReader/images/icon_hamburger.svg +1 -1
- package/BookReader/images/icon_home.svg +1 -1
- package/BookReader/images/icon_info.svg +1 -1
- package/BookReader/images/icon_one_page.svg +1 -1
- package/BookReader/images/icon_pause.svg +1 -1
- package/BookReader/images/icon_play.svg +1 -1
- package/BookReader/images/icon_playback-rate.svg +1 -1
- package/BookReader/images/icon_search_button.svg +1 -1
- package/BookReader/images/icon_share.svg +1 -1
- package/BookReader/images/icon_skip-back.svg +1 -1
- package/BookReader/images/icon_speaker.svg +1 -1
- package/BookReader/images/icon_speaker_open.svg +1 -1
- package/BookReader/images/icon_thumbnails.svg +1 -1
- package/BookReader/images/icon_toc.svg +1 -1
- package/BookReader/images/icon_two_pages.svg +1 -1
- package/BookReader/images/marker_chap-off.svg +1 -1
- package/BookReader/images/marker_chap-on.svg +1 -1
- package/BookReader/images/marker_srch-on.svg +1 -1
- package/BookReader/images/translate.svg +1 -1
- package/BookReader/jquery-3.js +1 -1
- package/BookReader/plugins/plugin.archive_analytics.js +1 -1
- package/BookReader/plugins/plugin.archive_analytics.js.map +1 -1
- package/BookReader/plugins/plugin.autoplay.js +1 -1
- package/BookReader/plugins/plugin.autoplay.js.map +1 -1
- package/BookReader/plugins/plugin.chapters.js +2 -2
- package/BookReader/plugins/plugin.chapters.js.LICENSE.txt +1 -1
- package/BookReader/plugins/plugin.chapters.js.map +1 -1
- package/BookReader/plugins/plugin.experiments.js +1 -1
- package/BookReader/plugins/plugin.experiments.js.LICENSE.txt +1 -1
- package/BookReader/plugins/plugin.experiments.js.map +1 -1
- package/BookReader/plugins/plugin.iframe.js +1 -1
- package/BookReader/plugins/plugin.iframe.js.map +1 -1
- package/BookReader/plugins/plugin.iiif.js +1 -1
- package/BookReader/plugins/plugin.iiif.js.map +1 -1
- package/BookReader/plugins/plugin.resume.js +1 -1
- package/BookReader/plugins/plugin.resume.js.map +1 -1
- package/BookReader/plugins/plugin.search.js +1 -1
- package/BookReader/plugins/plugin.search.js.LICENSE.txt +1 -1
- package/BookReader/plugins/plugin.search.js.map +1 -1
- package/BookReader/plugins/plugin.text_selection.js +1 -1
- package/BookReader/plugins/plugin.text_selection.js.LICENSE.txt +1 -1
- package/BookReader/plugins/plugin.text_selection.js.map +1 -1
- package/BookReader/plugins/plugin.translate.js +4 -4
- package/BookReader/plugins/plugin.translate.js.LICENSE.txt +1 -1
- package/BookReader/plugins/plugin.translate.js.map +1 -1
- package/BookReader/plugins/plugin.tts.js +1 -1
- package/BookReader/plugins/plugin.tts.js.LICENSE.txt +1 -1
- package/BookReader/plugins/plugin.tts.js.map +1 -1
- package/BookReader/plugins/plugin.url.js +1 -1
- package/BookReader/plugins/plugin.url.js.map +1 -1
- package/BookReader/plugins/plugin.vendor-fullscreen.js +1 -1
- package/BookReader/plugins/plugin.vendor-fullscreen.js.map +1 -1
- package/BookReader/plugins/translator-worker.js +1 -1
- package/BookReader/plugins/translator-worker.js.map +1 -1
- package/BookReader/webcomponents-bundle.js +1 -1
- package/BookReader/webcomponents-bundle.js.map +1 -1
- package/package.json +20 -20
- package/src/BookNavigator/search/search-results.js +84 -63
- package/src/BookNavigator/visual-adjustments/visual-adjustments-provider.js +4 -4
- package/src/BookNavigator/visual-adjustments/visual-adjustments.js +77 -59
- package/src/BookReader/Navbar/Navbar.js +54 -71
- package/src/BookReader/options.js +6 -0
- package/src/BookReader.js +12 -0
- package/src/assets/icons/slider-toggle.svg +1 -0
- package/src/css/_BRnav.scss +57 -4
- package/src/css/_icons.scss +7 -0
- package/src/plugins/plugin.text_selection.js +9 -0
- package/src/plugins/search/plugin.search.js +4 -0
- package/src/plugins/search/utils.js +8 -1
- package/src/plugins/search/view.js +1 -1
package/BookReader/474.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(){"use strict";var e={};"undefined"==typeof self&&(global.Module=e,global.self=new class{#e;constructor(){const{parentPort:e}=require("node:worker_threads");this.#e=e}addEventListener(e,t){this.#e.on(e,
|
|
1
|
+
!function(){"use strict";var e={};"undefined"==typeof self&&(global.Module=e,global.self=new class{#e;constructor(){const{parentPort:e}=require("node:worker_threads");this.#e=e}addEventListener(e,t){this.#e.on(e,e=>t({data:e}))}postMessage(e){this.#e.postMessage(e)}importScripts(...e){const{readFileSync:t}=require("node:fs"),{join:n}=require("node:path");for(let r of e){const e=t(n(__dirname,r),{encoding:"utf-8"});eval.call(global,e)}}async fetch(e,t){if("file:"===e.protocol){const{readFile:t}=require("node:fs/promises"),n=await t(e.pathname),r=new Blob([n]);return new Response(r,{status:200,statusText:"OK",headers:{"Content-Type":"application/wasm","Content-Length":r.size.toString()}})}return await fetch(e,t)}get location(){return new URL(`file://${__filename}`)}});class t{static parse(e){const t={};return e.split("\n").reduce((e,n,r)=>{let s;if(s=n.match(/^\s*-\s+(.+?)$/))Array.isArray(t[e])||(t[e]=t[e].trim()?[t[e]]:[]),t[e].push(s[1].trim());else if(s=n.match(/^\s*([A-Za-z0-9_][A-Za-z0-9_-]*):\s*(.*)$/))e=s[1],t[e]=s[2].trim();else if(n.trim())throw Error(`Could not parse line ${r+1}: "${n}"`);return e},null),t}static stringify(e){return Object.entries(e).reduce((e,[t,n])=>{let r="";return r=Array.isArray(n)?n.map(e=>`\n - ${e}`).join(""):("number"==typeof n||"boolean"==typeof n||n.match(/^\d*(\.\d+)?$/),`${n}`),`${e}${t}: ${r}\n`},"")}}class n{static GEMM_TO_FALLBACK_FUNCTIONS_MAP={int8_prepare_a:"int8PrepareAFallback",int8_prepare_b:"int8PrepareBFallback",int8_prepare_b_from_transposed:"int8PrepareBFromTransposedFallback",int8_prepare_b_from_quantized_transposed:"int8PrepareBFromQuantizedTransposedFallback",int8_prepare_bias:"int8PrepareBiasFallback",int8_multiply_and_add_bias:"int8MultiplyAndAddBiasFallback",int8_select_columns_of_b:"int8SelectColumnsOfBFallback"};static NATIVE_INT_GEMM="mozIntGemm";constructor(e){}async initialize(e){this.options=e||{},this.models=new Map,this.module=await this.loadModule(),this.service=await this.loadTranslationService()}linkNativeIntGemm(e){if(!WebAssembly.mozIntGemm)return console.warn("Native gemm requested but not available, falling back to embedded gemm"),this.linkFallbackIntGemm(e);const t=new WebAssembly.Instance(WebAssembly.mozIntGemm(),{"":{memory:e.env.memory}});return Array.from(Object.keys(n.GEMM_TO_FALLBACK_FUNCTIONS_MAP)).every(e=>t.exports[e])?t.exports:(console.warn("Native gemm is missing expected functions, falling back to embedded gemm"),this.linkFallbackIntGemm(e))}linkFallbackIntGemm(t){const r=Object.entries(n.GEMM_TO_FALLBACK_FUNCTIONS_MAP).map(([t,n])=>[t,(...t)=>e.asm[n](...t)]);return Object.fromEntries(r)}loadModule(){return new Promise(async(t,n)=>{try{const r=await self.fetch(new URL("./bergamot-translator-worker.wasm",self.location));Object.assign(e,{instantiateWasm:(e,t)=>{try{WebAssembly.instantiateStreaming(r,{...e,wasm_gemm:this.options.useNativeIntGemm?this.linkNativeIntGemm(e):this.linkFallbackIntGemm(e)}).then(({instance:e})=>t(e)).catch(n)}catch(e){n(e)}return{}},onRuntimeInitialized:()=>{t(e)}}),self.Module=e,self.importScripts("bergamot-translator-worker.js")}catch(e){n(e)}})}loadTranslationService(){return new this.module.BlockingService({cacheSize:Math.max(this.options.cacheSize||0,0)})}hasTranslationModel({from:e,to:t}){const n=JSON.stringify({from:e,to:t});return this.models.has(n)}loadTranslationModel({from:e,to:n},r){const s=r.vocabs.filter((e,t,n)=>!n.slice(0,t).includes(e)),[a,i,o,...l]=[this.prepareAlignedMemoryFromBuffer(r.model,256),this.prepareAlignedMemoryFromBuffer(r.shortlist,64),r.qualityModel?this.prepareAlignedMemoryFromBuffer(r.qualityModel,64):null,...s.map(e=>this.prepareAlignedMemoryFromBuffer(e,64))],m=new this.module.AlignedMemoryList;l.forEach(e=>m.push_back(e));let c=t.parse("\n beam-size: 1\n normalize: 1.0\n word-penalty: 0\n cpu-threads: 0\n gemm-precision: int8shiftAlphaAll\n skip-cost: true\n ");r.config&&Object.assign(c,r.config),"int8"===c["gemm-precision"]&&(c["gemm-precision"]="int8shiftAll"),Object.assign(c,t.parse("\n alignment: soft\n quiet: true\n quiet-translation: true\n max-length-break: 128\n mini-batch-words: 1024\n workspace: 128\n max-length-factor: 2.0\n "));const d=JSON.stringify({from:e,to:n});this.models.set(d,new this.module.TranslationModel(t.stringify(c),a,i,m,o))}freeTranslationModel({from:e,to:t}){const n=JSON.stringify({from:e,to:t});if(!this.models.has(n))return;const r=this.models.get(n);this.models.delete(n),r.delete()}prepareAlignedMemoryFromBuffer(e,t){const n=new Int8Array(e),r=new this.module.AlignedMemory(n.byteLength,t);return r.getByteArrayView().set(n),r}translate({models:e,texts:t}){let n=new this.module.VectorString;t.forEach(({text:e})=>n.push_back(e));let r=new this.module.VectorResponseOptions;t.forEach(({html:e,qualityScores:t})=>r.push_back({alignment:!1,html:e,qualityScores:t}));const s=e.map(({from:e,to:t})=>{const n=JSON.stringify({from:e,to:t});return this.models.get(n)}),a=e.length>1?this.service.translateViaPivoting(...s,n,r):this.service.translate(...s,n,r);n.delete(),r.delete();const i=t.map((e,t)=>({target:{text:a.get(t).getTranslatedText()}}));return a.delete(),i}}function r(e){return{name:e.name,message:e.message,stack:e.stack}}const s=new n;self.addEventListener("message",async function({data:{id:e,name:t,args:n}}){e||console.error("Received message without id",arguments[0]);try{if("function"!=typeof s[t])throw TypeError(`worker[${t}] is not a function`);const r=await Promise.resolve(Reflect.apply(s[t],s,n));self.postMessage({id:e,result:r})}catch(t){self.postMessage({id:e,error:r(t)})}})}();
|
|
2
2
|
//# sourceMappingURL=474.js.map
|
package/BookReader/474.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"474.js","mappings":"yBAKA,IAAIA,EAAS,CAAC,EAMM,oBAATC,OACPC,OAAOF,OAASA,EAEhBE,OAAOD,KAAO,IAAI,MAEd,GAEA,WAAAE,GACI,MAAM,WAACC,GAAcC,QAAkC,uBACvDC,MAAK,EAAQF,CACjB,CAOA,gBAAAG,CAAiBC,EAAWC,GACxBH,MAAK,EAAMI,GAAGF,GAAYG,GAASF,EAAS,CAACE,UACjD,CAMA,WAAAC,CAAYC,GACRP,MAAK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,QAAQuF,wBAAwBH,EAAmBP,EAAO1H,GAC/DpB,KAAKiE,QAAQ2E,aAAaS,EAAmBP,EAAO1H,GAE1D0H,EAAMT,SACNjH,EAAQiH,SAKR,MAAMoB,EAAeZ,EAAMrF,KAAI,CAACkG,EAAG/G,KAAM,CACrCgH,OAAQ,CACJX,KAAMM,EAAUlB,IAAIzF,GAAGiH,yBAM/B,OAFAN,EAAUjB,SAEHoB,CACX,EAaJ,SAASI,EAAWC,GAChB,MAAO,CACH3E,KAAM2E,EAAM3E,KACZ5E,QAASuJ,EAAMvJ,QACfwJ,MAAOD,EAAMC,MAErB,CAIA,MAAMC,EAAS,IAAItG,EAEnB/D,KAAKM,iBAAiB,WAAWsF,gBAAgBlF,MAAM,GAAC4J,EAAE,KAAE9E,EAAI,KAAEC,KACzD6E,GACD3F,QAAQwF,MAAM,8BAA+BI,UAAU,IAE3D,IACI,GAA4B,mBAAjBF,EAAO7E,GACd,MAAMgF,UAAU,UAAUhF,wBAI9B,MAAMiF,QAAe9E,QAAQE,QAAQ6E,QAAQC,MAAMN,EAAO7E,GAAO6E,EAAQ5E,IACzEzF,KAAKW,YAAY,CAAC2J,KAAIG,UAC1B,CAAE,MAAON,GACLnK,KAAKW,YAAY,CACb2J,KACAH,MAAOD,EAAWC,IAE1B,CACJ,G","sources":["webpack://@internetarchive/bookreader/./node_modules/@internetarchive/bergamot-translator/worker/translator-worker.js"],"sourcesContent":["/**\n * Wrapper around the dirty bits of Bergamot's WASM bindings.\n */\n\n// Global because importScripts is global.\nvar Module = {};\n\n/**\n * node.js compatibility: Fake GlobalWorkerScope that emulates being inside a\n * WebWorker\n */\nif (typeof self === 'undefined') {\n global.Module = Module;\n\n global.self = new class GlobalWorkerScope {\n /** @type {import(\"node:worker_threads\").MessagePort} */\n #port;\n\n constructor() {\n const {parentPort} = require(/* webpackIgnore: true */ 'node:worker_threads');\n this.#port = parentPort;\n }\n\n /**\n * Add event listener to listen for messages posted to the worker.\n * @param {string} eventName\n * @param {(object)} callback\n */\n addEventListener(eventName, callback) {\n this.#port.on(eventName, (data) => callback({data}));\n }\n\n /**\n * Post message outside, to the owner of the Worker.\n * @param {any} message\n */\n postMessage(message) {\n this.#port.postMessage(message);\n }\n\n /**\n * @param {...string} scripts - Paths to scripts to import in that order\n */\n importScripts(...scripts) {\n const {readFileSync} = require(/* webpackIgnore: true */ 'node:fs');\n const {join} = require(/* webpackIgnore: true */ 'node:path');\n for (let pathname of scripts) {\n const script = readFileSync(join(__dirname, pathname), {encoding: 'utf-8'});\n eval.call(global, script);\n }\n }\n\n /**\n * Adds support for local file urls. Assumes anything that doesn't start\n * with \"http\" to be a local path.\n * @param {string} url - path or url\n * @param {object?} options - See `fetch()` options\n * @return {Promise<Response>}\n */\n async fetch(url, options) {\n if (url.protocol === 'file:') {\n const {readFile} = require(/* webpackIgnore: true */ 'node:fs/promises');\n const buffer = await readFile(url.pathname);\n const blob = new Blob([buffer]);\n return new Response(blob, {\n status: 200,\n statusText: 'OK',\n headers: {\n 'Content-Type': 'application/wasm',\n 'Content-Length': blob.size.toString()\n }\n });\n }\n\n return await fetch(url, options);\n }\n\n get location() {\n return new URL(`file://${__filename}`);\n }\n }\n}\n\nclass YAML {\n /**\n * Parses YAML into dictionary. Does not interpret types, all values are a\n * string or a list of strings. No support for objects other than the top\n * level.\n * @param {string} yaml\n * @return {{[string]: string | string[]}}\n */\n static parse(yaml) {\n const out = {};\n\n yaml.split('\\n').reduce((key, line, i) => {\n let match;\n if (match = line.match(/^\\s*-\\s+(.+?)$/)) {\n if (!Array.isArray(out[key]))\n out[key] = out[key].trim() ? [out[key]] : [];\n out[key].push(match[1].trim());\n }\n else if (match = line.match(/^\\s*([A-Za-z0-9_][A-Za-z0-9_-]*):\\s*(.*)$/)) {\n key = match[1];\n out[key] = match[2].trim();\n }\n else if (!line.trim()) {\n // whitespace, ignore\n }\n else {\n throw Error(`Could not parse line ${i+1}: \"${line}\"`);\n }\n return key;\n }, null);\n\n return out;\n }\n\n /**\n * Turns an object into a YAML string. No support for objects, only simple\n * types and lists of simple types.\n * @param {{[string]: string | number | boolean | string[]}} data\n * @return {string}\n */\n static stringify(data) {\n return Object.entries(data).reduce((str, [key, value]) => {\n let valstr = '';\n if (Array.isArray(value))\n valstr = value.map(val => `\\n - ${val}`).join('');\n else if (typeof value === 'number' || typeof value === 'boolean' || value.match(/^\\d*(\\.\\d+)?$/))\n valstr = `${value}`;\n else\n valstr = `${value}`; // Quote?\n\n return `${str}${key}: ${valstr}\\n`;\n }, '');\n }\n}\n\n/**\n * Wrapper around the bergamot-translator exported module that hides the need\n * of working with C++ style data structures and does model management.\n */\nclass BergamotTranslatorWorker {\n /**\n * Map of expected symbol -> name of fallback symbol for functions that can\n * be swizzled for a faster implementation. Firefox Nightly makes use of\n * this.\n */\n static GEMM_TO_FALLBACK_FUNCTIONS_MAP = {\n 'int8_prepare_a': 'int8PrepareAFallback',\n 'int8_prepare_b': 'int8PrepareBFallback',\n 'int8_prepare_b_from_transposed': 'int8PrepareBFromTransposedFallback',\n 'int8_prepare_b_from_quantized_transposed': 'int8PrepareBFromQuantizedTransposedFallback',\n 'int8_prepare_bias': 'int8PrepareBiasFallback',\n 'int8_multiply_and_add_bias': 'int8MultiplyAndAddBiasFallback',\n 'int8_select_columns_of_b': 'int8SelectColumnsOfBFallback'\n };\n\n /**\n * Name of module exported by Firefox Nightly that exports an optimised\n * implementation of the symbols mentioned above.\n */\n static NATIVE_INT_GEMM = 'mozIntGemm';\n\n /**\n * Empty because we can't do async constructors yet. It is the\n * responsibility of whoever owns this WebWorker to call `initialize()`.\n */\n constructor(options) {}\n\n /**\n * Instantiates a new translation worker with optional options object.\n * If this call succeeds, the WASM runtime is loaded and ready.\n * \n * Available options are:\n * useNativeIntGemm: {true | false} defaults to false. If true, it will\n * attempt to link to the intgemm module available in\n * Firefox Nightly which makes translations much faster.\n * cacheSize: {Number} defaults to 0 which disables translation\n * cache entirely. Note that this is a theoretical\n * upper bound. In practice it will use about 1/3th of\n * the cache specified here. 2^14 is not a bad starting\n * value.\n * @param {{useNativeIntGemm: boolean, cacheSize: number}} options\n */\n async initialize(options) {\n this.options = options || {};\n this.models = new Map(); // Map<str,Promise<TranslationModel>>\n this.module = await this.loadModule();\n this.service = await this.loadTranslationService();\n }\n\n /**\n * Tries to load native IntGEMM module for bergamot-translator. If that\n * fails because it or any of the expected functions is not available, it\n * falls back to using the naive implementations that come with the wasm\n * binary itself through `linkFallbackIntGemm()`.\n * @param {{env: {memory: WebAssembly.Memory}}} info\n * @return {{[method:string]: (...any) => any}}\n */\n linkNativeIntGemm(info) {\n if (!WebAssembly['mozIntGemm']) {\n console.warn('Native gemm requested but not available, falling back to embedded gemm');\n return this.linkFallbackIntGemm(info);\n }\n\n const instance = new WebAssembly.Instance(WebAssembly['mozIntGemm'](), {\n '': {memory: info['env']['memory']}\n });\n\n if (!Array.from(Object.keys(BergamotTranslatorWorker.GEMM_TO_FALLBACK_FUNCTIONS_MAP)).every(fun => instance.exports[fun])) {\n console.warn('Native gemm is missing expected functions, falling back to embedded gemm');\n return this.linkFallbackIntGemm(info);\n }\n\n return instance.exports;\n }\n\n /**\n * Links intgemm functions that are already available in the wasm binary,\n * but just exports them under the name that is expected by\n * bergamot-translator.\n * @param {{env: {memory: WebAssembly.Memory}}} info\n * @return {{[method:string]: (...any) => any}}\n */\n linkFallbackIntGemm(info) {\n const mapping = Object.entries(BergamotTranslatorWorker.GEMM_TO_FALLBACK_FUNCTIONS_MAP).map(([key, name]) => {\n return [key, (...args) => Module['asm'][name](...args)]\n });\n\n return Object.fromEntries(mapping);\n }\n\n /**\n * Internal method. Reads and instantiates the WASM binary. Returns a\n * promise for the exported Module object that contains all the classes\n * and functions exported by bergamot-translator.\n * @return {Promise<BergamotTranslator>}\n */\n loadModule() {\n return new Promise(async (resolve, reject) => {\n try {\n const response = await self.fetch(new URL('./bergamot-translator-worker.wasm', self.location));\n\n Object.assign(Module, {\n instantiateWasm: (info, accept) => {\n try {\n WebAssembly.instantiateStreaming(response, {\n ...info,\n 'wasm_gemm': this.options.useNativeIntGemm\n ? this.linkNativeIntGemm(info)\n : this.linkFallbackIntGemm(info)\n }).then(({instance}) => accept(instance)).catch(reject);\n } catch (err) {\n reject(err);\n }\n return {};\n },\n onRuntimeInitialized: () => {\n resolve(Module);\n }\n });\n\n // Emscripten glue code. Webpack et al. should not mangle the `Module` property name!\n self.Module = Module;\n self.importScripts('bergamot-translator-worker.js');\n } catch (err) {\n reject(err);\n }\n });\n }\n\n /**\n * Internal method. Instantiates a BlockingService()\n * @return {BergamotTranslator.BlockingService}\n */\n loadTranslationService() {\n return new this.module.BlockingService({\n cacheSize: Math.max(this.options.cacheSize || 0, 0)\n });\n }\n\n /**\n * Returns whether a model has already been loaded in this worker. Marked\n * async because the message passing interface we use expects async methods.\n * @param {{from:string, to:string}}\n * @return boolean\n */ \n hasTranslationModel({from,to}) {\n const key = JSON.stringify({from,to});\n return this.models.has(key);\n }\n\n /**\n * Loads a translation model from a set of file buffers. After this, the\n * model is available to translate with and `hasTranslationModel()` will\n * return true for this pair.\n * @param {{from:string, to:string}}\n * @param {{\n * model: ArrayBuffer,\n * shortlist: ArrayBuffer,\n * vocabs: ArrayBuffer[],\n * qualityModel: ArrayBuffer?,\n * config?: {\n * [key:string]: string\n * }\n * }} buffers\n */ \n loadTranslationModel({from, to}, buffers) {\n // This because service_bindings.cpp:prepareVocabsSmartMemories :(\n const uniqueVocabs = buffers.vocabs.filter((vocab, index, vocabs) => {\n return !vocabs.slice(0, index).includes(vocab);\n });\n\n const [modelMemory, shortlistMemory, qualityModel, ...vocabMemory] = [\n this.prepareAlignedMemoryFromBuffer(buffers.model, 256),\n this.prepareAlignedMemoryFromBuffer(buffers.shortlist, 64),\n buffers.qualityModel // optional quality model\n ? this.prepareAlignedMemoryFromBuffer(buffers.qualityModel, 64)\n : null,\n ...uniqueVocabs.map(vocab => this.prepareAlignedMemoryFromBuffer(vocab, 64))\n ];\n\n const vocabs = new this.module.AlignedMemoryList();\n vocabMemory.forEach(vocab => vocabs.push_back(vocab));\n\n // Defaults\n let modelConfig = YAML.parse(`\n beam-size: 1\n normalize: 1.0\n word-penalty: 0\n cpu-threads: 0\n gemm-precision: int8shiftAlphaAll\n skip-cost: true\n `);\n\n if (buffers.config)\n Object.assign(modelConfig, buffers.config);\n\n // WASM marian is only compiled with support for shiftedAll.\n if (modelConfig['gemm-precision'] === 'int8')\n modelConfig['gemm-precision'] = 'int8shiftAll';\n\n // Override these\n Object.assign(modelConfig, YAML.parse(`\n alignment: soft\n quiet: true\n quiet-translation: true\n max-length-break: 128\n mini-batch-words: 1024\n workspace: 128\n max-length-factor: 2.0\n `));\n\n const key = JSON.stringify({from,to});\n this.models.set(key, new this.module.TranslationModel(YAML.stringify(modelConfig), modelMemory, shortlistMemory, vocabs, qualityModel));\n }\n\n /**\n * Frees up memory used by old translation model. Does nothing if model is\n * already deleted.\n * @param {{from:string, to:string}}\n */\n freeTranslationModel({from, to}) {\n const key = JSON.stringify({from,to});\n \n if (!this.models.has(key))\n return;\n \n const model = this.models.get(key);\n this.models.delete(key);\n\n model.delete();\n }\n\n /**\n * Internal function. Copies the data from an ArrayBuffer into memory that\n * can be used inside the WASM vm by Marian.\n * @param {{ArrayBuffer}} buffer\n * @param {number} alignmentSize\n * @return {BergamotTranslator.AlignedMemory}\n */\n prepareAlignedMemoryFromBuffer(buffer, alignmentSize) {\n const bytes = new Int8Array(buffer);\n const memory = new this.module.AlignedMemory(bytes.byteLength, alignmentSize);\n memory.getByteArrayView().set(bytes);\n return memory;\n }\n\n /**\n * Public. Does actual translation work. You have to make sure that the\n * models necessary for translating text are already loaded before calling\n * this method. Returns a promise with translation responses.\n * @param {{models: {from:string, to:string}[], texts: {text: string, html: boolean}[]}}\n * @return {Promise<{target: {text: string}}[]>}\n */\n translate({models, texts}) {\n // Convert texts array into a std::vector<std::string>.\n let input = new this.module.VectorString();\n texts.forEach(({text}) => input.push_back(text));\n\n // Extracts the texts[].html options into ResponseOption objects\n let options = new this.module.VectorResponseOptions();\n texts.forEach(({html, qualityScores}) => options.push_back({alignment: false, html, qualityScores}));\n\n // Turn our model names into a list of TranslationModel pointers\n const translationModels = models.map(({from,to}) => {\n const key = JSON.stringify({from,to});\n return this.models.get(key);\n });\n\n // translate the input, which is a vector<String>; the result is a vector<Response>\n const responses = models.length > 1\n ? this.service.translateViaPivoting(...translationModels, input, options)\n : this.service.translate(...translationModels, input, options);\n \n input.delete();\n options.delete();\n\n // Convert the Response WASM wrappers into native JavaScript types we\n // can send over the 'wire' (message passing) in the same format as we\n // use in bergamot-translator.\n const translations = texts.map((_, i) => ({\n target: {\n text: responses.get(i).getTranslatedText()\n }\n }));\n\n responses.delete();\n\n return translations;\n }\n}\n\n/**\n * Because you can't put an Error object in a message. But you can post a\n * generic object!\n * @param {Error} error\n * @return {{\n * name: string?,\n * message: string?,\n * stack: string?\n * }}\n */\nfunction cloneError(error) {\n return {\n name: error.name,\n message: error.message,\n stack: error.stack\n };\n}\n\n// (Constructor doesn't really do anything, we need to call `initialize()`\n// first before using it. That happens from outside the worker.)\nconst worker = new BergamotTranslatorWorker();\n\nself.addEventListener('message', async function({data: {id, name, args}}) {\n if (!id)\n console.error('Received message without id', arguments[0]);\n\n try {\n if (typeof worker[name] !== 'function')\n throw TypeError(`worker[${name}] is not a function`);\n\n // Using `Promise.resolve` to await any promises that worker[name]\n // possibly returns.\n const result = await Promise.resolve(Reflect.apply(worker[name], worker, args));\n self.postMessage({id, result});\n } catch (error) {\n self.postMessage({\n id,\n error: cloneError(error)\n })\n }\n});\n"],"names":["Module","self","global","constructor","parentPort","require","this","addEventListener","eventName","callback","on","data","postMessage","message","importScripts","scripts","readFileSync","join","pathname","script","__dirname","encoding","eval","call","fetch","url","options","protocol","readFile","buffer","blob","Blob","Response","status","statusText","headers","size","toString","location","URL","__filename","YAML","parse","yaml","out","split","reduce","key","line","i","match","Array","isArray","trim","push","Error","stringify","Object","entries","str","value","valstr","map","val","BergamotTranslatorWorker","static","initialize","models","Map","module","loadModule","service","loadTranslationService","linkNativeIntGemm","info","WebAssembly","console","warn","linkFallbackIntGemm","instance","Instance","memory","from","keys","GEMM_TO_FALLBACK_FUNCTIONS_MAP","every","fun","exports","mapping","name","args","fromEntries","Promise","async","resolve","reject","response","assign","instantiateWasm","accept","instantiateStreaming","useNativeIntGemm","then","catch","err","onRuntimeInitialized","BlockingService","cacheSize","Math","max","hasTranslationModel","to","JSON","has","loadTranslationModel","buffers","uniqueVocabs","vocabs","filter","vocab","index","slice","includes","modelMemory","shortlistMemory","qualityModel","vocabMemory","prepareAlignedMemoryFromBuffer","model","shortlist","AlignedMemoryList","forEach","push_back","modelConfig","config","set","TranslationModel","freeTranslationModel","get","delete","alignmentSize","bytes","Int8Array","AlignedMemory","byteLength","getByteArrayView","translate","texts","input","VectorString","text","VectorResponseOptions","html","qualityScores","alignment","translationModels","responses","length","translateViaPivoting","translations","_","target","getTranslatedText","cloneError","error","stack","worker","id","arguments","TypeError","result","Reflect","apply"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"474.js","mappings":"yBAKA,IAAIA,EAAS,CAAC,EAMM,oBAATC,OACPC,OAAOF,OAASA,EAEhBE,OAAOD,KAAO,IAAI,MAEd,GAEA,WAAAE,GACI,MAAM,WAACC,GAAcC,QAAkC,uBACvDC,MAAK,EAAQF,CACjB,CAOA,gBAAAG,CAAiBC,EAAWC,GACxBH,MAAK,EAAMI,GAAGF,EAAYG,GAASF,EAAS,CAACE,SACjD,CAMA,WAAAC,CAAYC,GACRP,MAAK,EAAMM,YAAYC,EAC3B,CAKA,aAAAC,IAAiBC,GACb,MAAM,aAACC,GAAgBX,QAAkC,YACnD,KAACY,GAAQZ,QAAkC,aACjD,IAAK,IAAIa,KAAYH,EAAS,CAC1B,MAAMI,EAASH,EAAaC,EAAKG,UAAWF,GAAW,CAACG,SAAU,UAClEC,KAAKC,KAAKrB,OAAQiB,EACtB,CACJ,CASA,WAAMK,CAAMC,EAAKC,GACb,GAAqB,UAAjBD,EAAI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M3E,KACZ5E,QAASuJ,EAAMvJ,QACfwJ,MAAOD,EAAMC,MAErB,CAIA,MAAMC,EAAS,IAAItG,EAEnB/D,KAAKM,iBAAiB,UAAWsF,gBAAgBlF,MAAM,GAAC4J,EAAE,KAAE9E,EAAI,KAAEC,KACzD6E,GACD3F,QAAQwF,MAAM,8BAA+BI,UAAU,IAE3D,IACI,GAA4B,mBAAjBF,EAAO7E,GACd,MAAMgF,UAAU,UAAUhF,wBAI9B,MAAMiF,QAAe9E,QAAQE,QAAQ6E,QAAQC,MAAMN,EAAO7E,GAAO6E,EAAQ5E,IACzEzF,KAAKW,YAAY,CAAC2J,KAAIG,UAC1B,CAAE,MAAON,GACLnK,KAAKW,YAAY,CACb2J,KACAH,MAAOD,EAAWC,IAE1B,CACJ,E","sources":["webpack://@internetarchive/bookreader/./node_modules/@internetarchive/bergamot-translator/worker/translator-worker.js"],"sourcesContent":["/**\n * Wrapper around the dirty bits of Bergamot's WASM bindings.\n */\n\n// Global because importScripts is global.\nvar Module = {};\n\n/**\n * node.js compatibility: Fake GlobalWorkerScope that emulates being inside a\n * WebWorker\n */\nif (typeof self === 'undefined') {\n global.Module = Module;\n\n global.self = new class GlobalWorkerScope {\n /** @type {import(\"node:worker_threads\").MessagePort} */\n #port;\n\n constructor() {\n const {parentPort} = require(/* webpackIgnore: true */ 'node:worker_threads');\n this.#port = parentPort;\n }\n\n /**\n * Add event listener to listen for messages posted to the worker.\n * @param {string} eventName\n * @param {(object)} callback\n */\n addEventListener(eventName, callback) {\n this.#port.on(eventName, (data) => callback({data}));\n }\n\n /**\n * Post message outside, to the owner of the Worker.\n * @param {any} message\n */\n postMessage(message) {\n this.#port.postMessage(message);\n }\n\n /**\n * @param {...string} scripts - Paths to scripts to import in that order\n */\n importScripts(...scripts) {\n const {readFileSync} = require(/* webpackIgnore: true */ 'node:fs');\n const {join} = require(/* webpackIgnore: true */ 'node:path');\n for (let pathname of scripts) {\n const script = readFileSync(join(__dirname, pathname), {encoding: 'utf-8'});\n eval.call(global, script);\n }\n }\n\n /**\n * Adds support for local file urls. Assumes anything that doesn't start\n * with \"http\" to be a local path.\n * @param {string} url - path or url\n * @param {object?} options - See `fetch()` options\n * @return {Promise<Response>}\n */\n async fetch(url, options) {\n if (url.protocol === 'file:') {\n const {readFile} = require(/* webpackIgnore: true */ 'node:fs/promises');\n const buffer = await readFile(url.pathname);\n const blob = new Blob([buffer]);\n return new Response(blob, {\n status: 200,\n statusText: 'OK',\n headers: {\n 'Content-Type': 'application/wasm',\n 'Content-Length': blob.size.toString()\n }\n });\n }\n\n return await fetch(url, options);\n }\n\n get location() {\n return new URL(`file://${__filename}`);\n }\n }\n}\n\nclass YAML {\n /**\n * Parses YAML into dictionary. Does not interpret types, all values are a\n * string or a list of strings. No support for objects other than the top\n * level.\n * @param {string} yaml\n * @return {{[string]: string | string[]}}\n */\n static parse(yaml) {\n const out = {};\n\n yaml.split('\\n').reduce((key, line, i) => {\n let match;\n if (match = line.match(/^\\s*-\\s+(.+?)$/)) {\n if (!Array.isArray(out[key]))\n out[key] = out[key].trim() ? [out[key]] : [];\n out[key].push(match[1].trim());\n }\n else if (match = line.match(/^\\s*([A-Za-z0-9_][A-Za-z0-9_-]*):\\s*(.*)$/)) {\n key = match[1];\n out[key] = match[2].trim();\n }\n else if (!line.trim()) {\n // whitespace, ignore\n }\n else {\n throw Error(`Could not parse line ${i+1}: \"${line}\"`);\n }\n return key;\n }, null);\n\n return out;\n }\n\n /**\n * Turns an object into a YAML string. No support for objects, only simple\n * types and lists of simple types.\n * @param {{[string]: string | number | boolean | string[]}} data\n * @return {string}\n */\n static stringify(data) {\n return Object.entries(data).reduce((str, [key, value]) => {\n let valstr = '';\n if (Array.isArray(value))\n valstr = value.map(val => `\\n - ${val}`).join('');\n else if (typeof value === 'number' || typeof value === 'boolean' || value.match(/^\\d*(\\.\\d+)?$/))\n valstr = `${value}`;\n else\n valstr = `${value}`; // Quote?\n\n return `${str}${key}: ${valstr}\\n`;\n }, '');\n }\n}\n\n/**\n * Wrapper around the bergamot-translator exported module that hides the need\n * of working with C++ style data structures and does model management.\n */\nclass BergamotTranslatorWorker {\n /**\n * Map of expected symbol -> name of fallback symbol for functions that can\n * be swizzled for a faster implementation. Firefox Nightly makes use of\n * this.\n */\n static GEMM_TO_FALLBACK_FUNCTIONS_MAP = {\n 'int8_prepare_a': 'int8PrepareAFallback',\n 'int8_prepare_b': 'int8PrepareBFallback',\n 'int8_prepare_b_from_transposed': 'int8PrepareBFromTransposedFallback',\n 'int8_prepare_b_from_quantized_transposed': 'int8PrepareBFromQuantizedTransposedFallback',\n 'int8_prepare_bias': 'int8PrepareBiasFallback',\n 'int8_multiply_and_add_bias': 'int8MultiplyAndAddBiasFallback',\n 'int8_select_columns_of_b': 'int8SelectColumnsOfBFallback'\n };\n\n /**\n * Name of module exported by Firefox Nightly that exports an optimised\n * implementation of the symbols mentioned above.\n */\n static NATIVE_INT_GEMM = 'mozIntGemm';\n\n /**\n * Empty because we can't do async constructors yet. It is the\n * responsibility of whoever owns this WebWorker to call `initialize()`.\n */\n constructor(options) {}\n\n /**\n * Instantiates a new translation worker with optional options object.\n * If this call succeeds, the WASM runtime is loaded and ready.\n * \n * Available options are:\n * useNativeIntGemm: {true | false} defaults to false. If true, it will\n * attempt to link to the intgemm module available in\n * Firefox Nightly which makes translations much faster.\n * cacheSize: {Number} defaults to 0 which disables translation\n * cache entirely. Note that this is a theoretical\n * upper bound. In practice it will use about 1/3th of\n * the cache specified here. 2^14 is not a bad starting\n * value.\n * @param {{useNativeIntGemm: boolean, cacheSize: number}} options\n */\n async initialize(options) {\n this.options = options || {};\n this.models = new Map(); // Map<str,Promise<TranslationModel>>\n this.module = await this.loadModule();\n this.service = await this.loadTranslationService();\n }\n\n /**\n * Tries to load native IntGEMM module for bergamot-translator. If that\n * fails because it or any of the expected functions is not available, it\n * falls back to using the naive implementations that come with the wasm\n * binary itself through `linkFallbackIntGemm()`.\n * @param {{env: {memory: WebAssembly.Memory}}} info\n * @return {{[method:string]: (...any) => any}}\n */\n linkNativeIntGemm(info) {\n if (!WebAssembly['mozIntGemm']) {\n console.warn('Native gemm requested but not available, falling back to embedded gemm');\n return this.linkFallbackIntGemm(info);\n }\n\n const instance = new WebAssembly.Instance(WebAssembly['mozIntGemm'](), {\n '': {memory: info['env']['memory']}\n });\n\n if (!Array.from(Object.keys(BergamotTranslatorWorker.GEMM_TO_FALLBACK_FUNCTIONS_MAP)).every(fun => instance.exports[fun])) {\n console.warn('Native gemm is missing expected functions, falling back to embedded gemm');\n return this.linkFallbackIntGemm(info);\n }\n\n return instance.exports;\n }\n\n /**\n * Links intgemm functions that are already available in the wasm binary,\n * but just exports them under the name that is expected by\n * bergamot-translator.\n * @param {{env: {memory: WebAssembly.Memory}}} info\n * @return {{[method:string]: (...any) => any}}\n */\n linkFallbackIntGemm(info) {\n const mapping = Object.entries(BergamotTranslatorWorker.GEMM_TO_FALLBACK_FUNCTIONS_MAP).map(([key, name]) => {\n return [key, (...args) => Module['asm'][name](...args)]\n });\n\n return Object.fromEntries(mapping);\n }\n\n /**\n * Internal method. Reads and instantiates the WASM binary. Returns a\n * promise for the exported Module object that contains all the classes\n * and functions exported by bergamot-translator.\n * @return {Promise<BergamotTranslator>}\n */\n loadModule() {\n return new Promise(async (resolve, reject) => {\n try {\n const response = await self.fetch(new URL('./bergamot-translator-worker.wasm', self.location));\n\n Object.assign(Module, {\n instantiateWasm: (info, accept) => {\n try {\n WebAssembly.instantiateStreaming(response, {\n ...info,\n 'wasm_gemm': this.options.useNativeIntGemm\n ? this.linkNativeIntGemm(info)\n : this.linkFallbackIntGemm(info)\n }).then(({instance}) => accept(instance)).catch(reject);\n } catch (err) {\n reject(err);\n }\n return {};\n },\n onRuntimeInitialized: () => {\n resolve(Module);\n }\n });\n\n // Emscripten glue code. Webpack et al. should not mangle the `Module` property name!\n self.Module = Module;\n self.importScripts('bergamot-translator-worker.js');\n } catch (err) {\n reject(err);\n }\n });\n }\n\n /**\n * Internal method. Instantiates a BlockingService()\n * @return {BergamotTranslator.BlockingService}\n */\n loadTranslationService() {\n return new this.module.BlockingService({\n cacheSize: Math.max(this.options.cacheSize || 0, 0)\n });\n }\n\n /**\n * Returns whether a model has already been loaded in this worker. Marked\n * async because the message passing interface we use expects async methods.\n * @param {{from:string, to:string}}\n * @return boolean\n */ \n hasTranslationModel({from,to}) {\n const key = JSON.stringify({from,to});\n return this.models.has(key);\n }\n\n /**\n * Loads a translation model from a set of file buffers. After this, the\n * model is available to translate with and `hasTranslationModel()` will\n * return true for this pair.\n * @param {{from:string, to:string}}\n * @param {{\n * model: ArrayBuffer,\n * shortlist: ArrayBuffer,\n * vocabs: ArrayBuffer[],\n * qualityModel: ArrayBuffer?,\n * config?: {\n * [key:string]: string\n * }\n * }} buffers\n */ \n loadTranslationModel({from, to}, buffers) {\n // This because service_bindings.cpp:prepareVocabsSmartMemories :(\n const uniqueVocabs = buffers.vocabs.filter((vocab, index, vocabs) => {\n return !vocabs.slice(0, index).includes(vocab);\n });\n\n const [modelMemory, shortlistMemory, qualityModel, ...vocabMemory] = [\n this.prepareAlignedMemoryFromBuffer(buffers.model, 256),\n this.prepareAlignedMemoryFromBuffer(buffers.shortlist, 64),\n buffers.qualityModel // optional quality model\n ? this.prepareAlignedMemoryFromBuffer(buffers.qualityModel, 64)\n : null,\n ...uniqueVocabs.map(vocab => this.prepareAlignedMemoryFromBuffer(vocab, 64))\n ];\n\n const vocabs = new this.module.AlignedMemoryList();\n vocabMemory.forEach(vocab => vocabs.push_back(vocab));\n\n // Defaults\n let modelConfig = YAML.parse(`\n beam-size: 1\n normalize: 1.0\n word-penalty: 0\n cpu-threads: 0\n gemm-precision: int8shiftAlphaAll\n skip-cost: true\n `);\n\n if (buffers.config)\n Object.assign(modelConfig, buffers.config);\n\n // WASM marian is only compiled with support for shiftedAll.\n if (modelConfig['gemm-precision'] === 'int8')\n modelConfig['gemm-precision'] = 'int8shiftAll';\n\n // Override these\n Object.assign(modelConfig, YAML.parse(`\n alignment: soft\n quiet: true\n quiet-translation: true\n max-length-break: 128\n mini-batch-words: 1024\n workspace: 128\n max-length-factor: 2.0\n `));\n\n const key = JSON.stringify({from,to});\n this.models.set(key, new this.module.TranslationModel(YAML.stringify(modelConfig), modelMemory, shortlistMemory, vocabs, qualityModel));\n }\n\n /**\n * Frees up memory used by old translation model. Does nothing if model is\n * already deleted.\n * @param {{from:string, to:string}}\n */\n freeTranslationModel({from, to}) {\n const key = JSON.stringify({from,to});\n \n if (!this.models.has(key))\n return;\n \n const model = this.models.get(key);\n this.models.delete(key);\n\n model.delete();\n }\n\n /**\n * Internal function. Copies the data from an ArrayBuffer into memory that\n * can be used inside the WASM vm by Marian.\n * @param {{ArrayBuffer}} buffer\n * @param {number} alignmentSize\n * @return {BergamotTranslator.AlignedMemory}\n */\n prepareAlignedMemoryFromBuffer(buffer, alignmentSize) {\n const bytes = new Int8Array(buffer);\n const memory = new this.module.AlignedMemory(bytes.byteLength, alignmentSize);\n memory.getByteArrayView().set(bytes);\n return memory;\n }\n\n /**\n * Public. Does actual translation work. You have to make sure that the\n * models necessary for translating text are already loaded before calling\n * this method. Returns a promise with translation responses.\n * @param {{models: {from:string, to:string}[], texts: {text: string, html: boolean}[]}}\n * @return {Promise<{target: {text: string}}[]>}\n */\n translate({models, texts}) {\n // Convert texts array into a std::vector<std::string>.\n let input = new this.module.VectorString();\n texts.forEach(({text}) => input.push_back(text));\n\n // Extracts the texts[].html options into ResponseOption objects\n let options = new this.module.VectorResponseOptions();\n texts.forEach(({html, qualityScores}) => options.push_back({alignment: false, html, qualityScores}));\n\n // Turn our model names into a list of TranslationModel pointers\n const translationModels = models.map(({from,to}) => {\n const key = JSON.stringify({from,to});\n return this.models.get(key);\n });\n\n // translate the input, which is a vector<String>; the result is a vector<Response>\n const responses = models.length > 1\n ? this.service.translateViaPivoting(...translationModels, input, options)\n : this.service.translate(...translationModels, input, options);\n \n input.delete();\n options.delete();\n\n // Convert the Response WASM wrappers into native JavaScript types we\n // can send over the 'wire' (message passing) in the same format as we\n // use in bergamot-translator.\n const translations = texts.map((_, i) => ({\n target: {\n text: responses.get(i).getTranslatedText()\n }\n }));\n\n responses.delete();\n\n return translations;\n }\n}\n\n/**\n * Because you can't put an Error object in a message. But you can post a\n * generic object!\n * @param {Error} error\n * @return {{\n * name: string?,\n * message: string?,\n * stack: string?\n * }}\n */\nfunction cloneError(error) {\n return {\n name: error.name,\n message: error.message,\n stack: error.stack\n };\n}\n\n// (Constructor doesn't really do anything, we need to call `initialize()`\n// first before using it. That happens from outside the worker.)\nconst worker = new BergamotTranslatorWorker();\n\nself.addEventListener('message', async function({data: {id, name, args}}) {\n if (!id)\n console.error('Received message without id', arguments[0]);\n\n try {\n if (typeof worker[name] !== 'function')\n throw TypeError(`worker[${name}] is not a function`);\n\n // Using `Promise.resolve` to await any promises that worker[name]\n // possibly returns.\n const result = await Promise.resolve(Reflect.apply(worker[name], worker, args));\n self.postMessage({id, result});\n } catch (error) {\n self.postMessage({\n id,\n error: cloneError(error)\n })\n }\n});\n"],"names":["Module","self","global","constructor","parentPort","require","this","addEventListener","eventName","callback","on","data","postMessage","message","importScripts","scripts","readFileSync","join","pathname","script","__dirname","encoding","eval","call","fetch","url","options","protocol","readFile","buffer","blob","Blob","Response","status","statusText","headers","size","toString","location","URL","__filename","YAML","parse","yaml","out","split","reduce","key","line","i","match","Array","isArray","trim","push","Error","stringify","Object","entries","str","value","valstr","map","val","BergamotTranslatorWorker","static","initialize","models","Map","module","loadModule","service","loadTranslationService","linkNativeIntGemm","info","WebAssembly","console","warn","linkFallbackIntGemm","instance","Instance","memory","from","keys","GEMM_TO_FALLBACK_FUNCTIONS_MAP","every","fun","exports","mapping","name","args","fromEntries","Promise","async","resolve","reject","response","assign","instantiateWasm","accept","instantiateStreaming","useNativeIntGemm","then","catch","err","onRuntimeInitialized","BlockingService","cacheSize","Math","max","hasTranslationModel","to","JSON","has","loadTranslationModel","buffers","uniqueVocabs","vocabs","filter","vocab","index","slice","includes","modelMemory","shortlistMemory","qualityModel","vocabMemory","prepareAlignedMemoryFromBuffer","model","shortlist","AlignedMemoryList","forEach","push_back","modelConfig","config","set","TranslationModel","freeTranslationModel","get","delete","alignmentSize","bytes","Int8Array","AlignedMemory","byteLength","getByteArrayView","translate","texts","input","VectorString","text","VectorResponseOptions","html","qualityScores","alignment","translationModels","responses","length","translateViaPivoting","translations","_","target","getTranslatedText","cloneError","error","stack","worker","id","arguments","TypeError","result","Reflect","apply"],"sourceRoot":""}
|
|
@@ -89,18 +89,22 @@
|
|
|
89
89
|
line-height: 1.2;
|
|
90
90
|
-webkit-text-size-adjust: none;
|
|
91
91
|
/* Some helper functional css utilities */
|
|
92
|
-
/* Desktop-only */
|
|
93
|
-
/* Element-level rules */
|
|
94
92
|
}
|
|
95
93
|
.BookReader .larger, .BRfloat .larger {
|
|
96
94
|
font-size: 1.2em;
|
|
97
95
|
}
|
|
96
|
+
.BookReader, .BRfloat {
|
|
97
|
+
/* Desktop-only */
|
|
98
|
+
}
|
|
98
99
|
@media (min-width: 801px) {
|
|
99
100
|
.BookReader .mv20-lg, .BRfloat .mv20-lg {
|
|
100
101
|
margin-top: 20px;
|
|
101
102
|
margin-bottom: 20px;
|
|
102
103
|
}
|
|
103
104
|
}
|
|
105
|
+
.BookReader, .BRfloat {
|
|
106
|
+
/* Element-level rules */
|
|
107
|
+
}
|
|
104
108
|
.BookReader h3, .BRfloat h3 {
|
|
105
109
|
font-size: 20px;
|
|
106
110
|
font-weight: 700;
|
|
@@ -1207,7 +1211,6 @@ i.BRicon {
|
|
|
1207
1211
|
/* Theming */
|
|
1208
1212
|
background-color: #333;
|
|
1209
1213
|
color: white;
|
|
1210
|
-
/* Full mobile styles */
|
|
1211
1214
|
}
|
|
1212
1215
|
.BRnav a {
|
|
1213
1216
|
color: white;
|
|
@@ -1238,6 +1241,9 @@ i.BRicon {
|
|
|
1238
1241
|
display: block;
|
|
1239
1242
|
border: 3px solid rgba(255, 255, 255, 0.3);
|
|
1240
1243
|
}
|
|
1244
|
+
.BRnav {
|
|
1245
|
+
/* Full mobile styles */
|
|
1246
|
+
}
|
|
1241
1247
|
@media (max-width: 800px) {
|
|
1242
1248
|
.BRnav {
|
|
1243
1249
|
height: 34px;
|
|
@@ -1260,11 +1266,15 @@ i.BRicon {
|
|
|
1260
1266
|
box-sizing: content-box;
|
|
1261
1267
|
border-radius: 10px;
|
|
1262
1268
|
cursor: pointer;
|
|
1263
|
-
/* handle active state for touch */
|
|
1264
1269
|
}
|
|
1265
1270
|
.BRpager.ui-slider.ui-widget.ui-widget-content {
|
|
1266
1271
|
border: none;
|
|
1267
1272
|
}
|
|
1273
|
+
.BRpager.ui-slider.ui-slider-docked {
|
|
1274
|
+
height: 1px;
|
|
1275
|
+
width: 100%;
|
|
1276
|
+
margin: 0px;
|
|
1277
|
+
}
|
|
1268
1278
|
.BRpager.ui-slider .ui-slider-horizontal .ui-slider-handle,
|
|
1269
1279
|
.BRpager.ui-slider .ui-slider-handle {
|
|
1270
1280
|
position: absolute;
|
|
@@ -1280,6 +1290,9 @@ i.BRicon {
|
|
|
1280
1290
|
height: 100%;
|
|
1281
1291
|
border-radius: 10px;
|
|
1282
1292
|
}
|
|
1293
|
+
.BRpager.ui-slider {
|
|
1294
|
+
/* handle active state for touch */
|
|
1295
|
+
}
|
|
1283
1296
|
.touch .BRpager.ui-slider .ui-slider-handle.ui-state-active {
|
|
1284
1297
|
width: 24px;
|
|
1285
1298
|
height: 24px;
|
|
@@ -1299,10 +1312,10 @@ i.BRicon {
|
|
|
1299
1312
|
|
|
1300
1313
|
.BRcurrentpage {
|
|
1301
1314
|
display: inline-block;
|
|
1302
|
-
text-align:
|
|
1315
|
+
text-align: left;
|
|
1303
1316
|
padding: 0 0 0 0;
|
|
1304
1317
|
font-size: 12px;
|
|
1305
|
-
margin-left:
|
|
1318
|
+
margin-left: 15px;
|
|
1306
1319
|
margin-right: 10px;
|
|
1307
1320
|
line-height: 1;
|
|
1308
1321
|
}
|
|
@@ -1352,7 +1365,6 @@ i.BRicon {
|
|
|
1352
1365
|
display: none;
|
|
1353
1366
|
}
|
|
1354
1367
|
.BRpager.ui-slider {
|
|
1355
|
-
height: 10px;
|
|
1356
1368
|
top: 12px;
|
|
1357
1369
|
}
|
|
1358
1370
|
}
|
|
@@ -1368,6 +1380,48 @@ i.BRicon {
|
|
|
1368
1380
|
background-position: -1384px center;
|
|
1369
1381
|
}
|
|
1370
1382
|
|
|
1383
|
+
.BRnavMobile {
|
|
1384
|
+
box-sizing: content-box;
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
.BRnavMobile.docked {
|
|
1388
|
+
height: 0px;
|
|
1389
|
+
border: none;
|
|
1390
|
+
}
|
|
1391
|
+
.BRnavMobile.docked .BRcontrols .scrubber .BRpager.ui-slider {
|
|
1392
|
+
top: -1px;
|
|
1393
|
+
}
|
|
1394
|
+
.BRnavMobile.docked .ui-slider,
|
|
1395
|
+
.BRnavMobile.docked .ui-slider-range {
|
|
1396
|
+
height: 2px;
|
|
1397
|
+
border-radius: 0px;
|
|
1398
|
+
}
|
|
1399
|
+
.BRnavMobile.docked .BRnavpos {
|
|
1400
|
+
margin: 0px;
|
|
1401
|
+
}
|
|
1402
|
+
.BRnavMobile.docked .scrubber {
|
|
1403
|
+
margin: 0px;
|
|
1404
|
+
padding: 0px;
|
|
1405
|
+
height: 0px;
|
|
1406
|
+
}
|
|
1407
|
+
.BRnavMobile.docked .controls {
|
|
1408
|
+
padding: 0px;
|
|
1409
|
+
background-color: transparent;
|
|
1410
|
+
}
|
|
1411
|
+
.BRnavMobile.docked .BRnavline {
|
|
1412
|
+
display: none;
|
|
1413
|
+
}
|
|
1414
|
+
.BRnavMobile.docked .ui-slider-handle {
|
|
1415
|
+
display: none;
|
|
1416
|
+
}
|
|
1417
|
+
.BRnavMobile.docked button {
|
|
1418
|
+
display: none;
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
.BRnavMobile.hide {
|
|
1422
|
+
display: none;
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1371
1425
|
/**
|
|
1372
1426
|
* BRtoolbar is the top control bar (eg header)
|
|
1373
1427
|
*/
|
|
@@ -1863,9 +1917,15 @@ ia-bookreader .BRtoolbar {
|
|
|
1863
1917
|
background-image: url("icons/close-circle-dark.svg");
|
|
1864
1918
|
}
|
|
1865
1919
|
|
|
1920
|
+
.icon-toggle-slider {
|
|
1921
|
+
background-size: 25px;
|
|
1922
|
+
width: 25px;
|
|
1923
|
+
height: 25px;
|
|
1924
|
+
background-image: url("icons/slider-toggle.svg");
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1866
1927
|
.BRcontrols {
|
|
1867
1928
|
width: 100%;
|
|
1868
|
-
/* BookReader defaults overrides */
|
|
1869
1929
|
}
|
|
1870
1930
|
.BRcontrols .BRtooltip {
|
|
1871
1931
|
display: none;
|
|
@@ -2080,6 +2140,9 @@ ia-bookreader .BRtoolbar {
|
|
|
2080
2140
|
padding: 0;
|
|
2081
2141
|
}
|
|
2082
2142
|
}
|
|
2143
|
+
.BRcontrols {
|
|
2144
|
+
/* BookReader defaults overrides */
|
|
2145
|
+
}
|
|
2083
2146
|
.BRcontrols .BRnavline {
|
|
2084
2147
|
top: -4px;
|
|
2085
2148
|
}
|