From d522775e6c50dd6a4650f6957b1e0500e735499d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D5=A1=C9=A8=D5=BC=C9=A2=D3=84=D5=A1=D6=85=D5=BC=C9=A2?= Date: Wed, 18 Oct 2023 13:08:49 +0800 Subject: [PATCH] fix(nc-gui): initWorker logic and remove unused code --- packages/nc-gui/utils/workerUtils.ts | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/packages/nc-gui/utils/workerUtils.ts b/packages/nc-gui/utils/workerUtils.ts index c0620e946b..de748ce24e 100644 --- a/packages/nc-gui/utils/workerUtils.ts +++ b/packages/nc-gui/utils/workerUtils.ts @@ -1,27 +1,16 @@ import getCrossOriginWorkerURL from 'crossoriginworker' -// Returns a blob:// URL which points -// to a javascript file which will call -// importScripts with the given URL -export function getWorkerURL(url: string) { - const content = `importScripts( "${url}" );` - return URL.createObjectURL(new Blob([content], { type: 'text/javascript' })) -} - export async function initWorker(url: string) { let worker: Worker | null = null try { - const workerURL = await getCrossOriginWorkerURL(url) - worker = new Worker(workerURL) - // if (/^https?:\/\/'/.test(url)) { - // // const worker_url = getWorkerURL(url) - // // worker = new Worker(worker_url) - // // URL.revokeObjectURL(worker_url) - // } else { - // worker = new Worker(url, { - // type: 'module', - // }) - // } + if (/^https?:\/\//.test(url)) { + const workerURL = await getCrossOriginWorkerURL(url) + worker = new Worker(workerURL) + } else { + worker = new Worker(url, { + type: 'module', + }) + } } catch (e) { console.error(e) }