diff --git a/src/worker-script/browser/index.js b/src/worker-script/browser/index.js index 06fd336..2e177a8 100644 --- a/src/worker-script/browser/index.js +++ b/src/worker-script/browser/index.js @@ -29,4 +29,5 @@ worker.setAdapter({ gunzip, fetch: () => {}, ...cache, + isWebWorker: typeof window === 'undefined' && typeof importScripts === 'function', }); diff --git a/src/worker-script/index.js b/src/worker-script/index.js index 5166ab8..6034cc6 100644 --- a/src/worker-script/index.js +++ b/src/worker-script/index.js @@ -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' : ''}`);