mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
attempt with dynamic import
This commit is contained in:
parent
a64138311e
commit
68b825f91e
2 changed files with 20 additions and 20 deletions
|
@ -31,8 +31,6 @@ import { AnimatedTrail } from "../animated-trail";
|
|||
|
||||
import { LassoWorkerPolyfill } from "./lasso-worker-polyfill";
|
||||
|
||||
import { WorkerUrl } from "./lasso-worker";
|
||||
|
||||
import type App from "../components/App";
|
||||
import type { LassoWorkerInput, LassoWorkerOutput } from "./types";
|
||||
|
||||
|
@ -85,7 +83,10 @@ export class LassoTrail extends AnimatedTrail {
|
|||
});
|
||||
}
|
||||
|
||||
if (!this.worker) {
|
||||
try {
|
||||
const { WorkerUrl } = await import("./lasso-worker.chunk");
|
||||
|
||||
if (typeof Worker !== "undefined" && WorkerUrl) {
|
||||
this.worker = new Worker(WorkerUrl, { type: "module" });
|
||||
} else {
|
||||
|
@ -104,6 +105,7 @@ export class LassoTrail extends AnimatedTrail {
|
|||
console.error("Failed to start worker", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
selectElementsFromIds = (ids: string[]) => {
|
||||
this.app.setState((prevState) => {
|
||||
|
@ -226,7 +228,5 @@ export class LassoTrail extends AnimatedTrail {
|
|||
this.app.setState({
|
||||
lassoSelection: null,
|
||||
});
|
||||
|
||||
this.worker?.terminate();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue