mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-05 01:38:44 +00:00
Trying a shared worker work around.
This commit is contained in:
1 parent
1fe0296d73
commit
eca27e263a
1 file changed
+8
-7
@@ -3,7 +3,7 @@ import {
|
||||
SharedWorkerResponse,
|
||||
} from "~/KonvaApp/WorkerPrimitives/SharedWorkerBase";
|
||||
import { ResponseType } from "~/KonvaApp/WorkerPrimitives/SharedWorkerBase";
|
||||
|
||||
import diffusionWorkerURL from "~/KonvaApp/SharedWorkers/Diffusion/DiffusionSharedWorker.ts?worker&url";
|
||||
export class DiffusionSharedWorkerClient<
|
||||
DiffusionSharedWorkerItemData,
|
||||
DiffusionSharedWorkerResponseData,
|
||||
@@ -32,12 +32,13 @@ export class DiffusionSharedWorkerClient<
|
||||
type: "module",
|
||||
});
|
||||
} else {
|
||||
this.sharedWorker = new SharedWorker(
|
||||
new URL(workerPath, import.meta.url),
|
||||
{
|
||||
type: "module",
|
||||
},
|
||||
);
|
||||
// in production this is a work around .. https://github.com/vitejs/vite/issues/13680
|
||||
const js = `import ${JSON.stringify(new URL(diffusionWorkerURL, import.meta.url))}`;
|
||||
const blob = new Blob([js], { type: "application/javascript" });
|
||||
const objURL = URL.createObjectURL(blob);
|
||||
this.sharedWorker = new SharedWorker(new URL(objURL, import.meta.url), {
|
||||
type: "module",
|
||||
});
|
||||
}
|
||||
this.port = this.sharedWorker.port;
|
||||
this.port.onmessage = this.onMessage.bind(this);
|
||||
|
||||
Reference in new issue
Block a user