MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / spawnCrossOriginWorker

Function spawnCrossOriginWorker

runtime/src/index.js:148–156  ·  view source on GitHub ↗
(workerUrl)

Source from the content-addressed store, hash-verified

146
147/* Blob URL inherits the page's origin -> sidesteps Chromium's cross-origin block; the imported module then loads under CORS (Cloudflare Pages OK by default). `Function.toString` keeps the bootstrap as real JS in source. */
148function spawnCrossOriginWorker(workerUrl) {
149 const source = `(${crossOriginBootstrap.toString()})(${JSON.stringify(workerUrl)});`;
150 const blob = new Blob([source], { type: 'application/javascript' });
151 const blobUrl = URL.createObjectURL(blob);
152 const worker = new Worker(blobUrl, { type: 'module' });
153 // Defer revoke a tick; some browsers race it against the module fetch.
154 setTimeout(() => URL.revokeObjectURL(blobUrl), 0);
155 return worker;
156}

Callers 1

createWorkerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected