Browse Source

Fix fetch when running in electron webview

pull/489/head
Cédric Couton 4 years ago
parent
commit
3f98fdeb0f
  1. 1
      src/worker-script/browser/index.js
  2. 2
      src/worker-script/index.js

1
src/worker-script/browser/index.js

@ -29,4 +29,5 @@ worker.setAdapter({ @@ -29,4 +29,5 @@ worker.setAdapter({
gunzip,
fetch: () => {},
...cache,
isWebWorker: typeof window === 'undefined' && typeof importScripts === 'function',
});

2
src/worker-script/index.js

@ -99,7 +99,7 @@ const loadLanguage = async ({ @@ -99,7 +99,7 @@ const loadLanguage = async ({
}
if (path !== null) {
const resp = await (isWebWorker ? fetch : adapter.fetch)(`${path}/${lang}.traineddata${gzip ? '.gz' : ''}`);
const resp = await (isWebWorker || adapter.isWebWorker ? fetch : adapter.fetch)(`${path}/${lang}.traineddata${gzip ? '.gz' : ''}`);
data = await resp.arrayBuffer();
} else {
data = await adapter.readCache(`${langPath}/${lang}.traineddata${gzip ? '.gz' : ''}`);

Loading…
Cancel
Save