Browse Source

Merge pull request #6721 from nocodb/fix/init-worker

fix(nc-gui): initWorker logic and remove unused code
pull/6714/head
աӄա 1 year ago committed by GitHub
parent
commit
45de46fe0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 27
      packages/nc-gui/utils/workerUtils.ts

27
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 {
const workerURL = await getCrossOriginWorkerURL(url) if (/^https?:\/\//.test(url)) {
worker = new Worker(workerURL) const workerURL = await getCrossOriginWorkerURL(url)
// if (/^https?:\/\/'/.test(url)) { worker = new Worker(workerURL)
// // const worker_url = getWorkerURL(url) } else {
// // worker = new Worker(worker_url) worker = new Worker(url, {
// // URL.revokeObjectURL(worker_url) type: 'module',
// } else { })
// worker = new Worker(url, { }
// type: 'module',
// })
// }
} catch (e) { } catch (e) {
console.error(e) console.error(e)
} }

Loading…
Cancel
Save