Browse Source

fix(nc-gui): initWorker logic and remove unused code

pull/6721/head
աɨռɢӄաօռɢ 1 year ago
parent
commit
d522775e6c
  1. 23
      packages/nc-gui/utils/workerUtils.ts

23
packages/nc-gui/utils/workerUtils.ts

@ -1,27 +1,16 @@
import getCrossOriginWorkerURL from 'crossoriginworker' 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) { export async function initWorker(url: string) {
let worker: Worker | null = null let worker: Worker | null = null
try { try {
if (/^https?:\/\//.test(url)) {
const workerURL = await getCrossOriginWorkerURL(url) const workerURL = await getCrossOriginWorkerURL(url)
worker = new Worker(workerURL) worker = new Worker(workerURL)
// if (/^https?:\/\/'/.test(url)) { } else {
// // const worker_url = getWorkerURL(url) worker = new Worker(url, {
// // worker = new Worker(worker_url) type: 'module',
// // URL.revokeObjectURL(worker_url) })
// } else { }
// worker = new Worker(url, {
// type: 'module',
// })
// }
} catch (e) { } catch (e) {
console.error(e) console.error(e)
} }

Loading…
Cancel
Save