another attempt at constructor error

This commit is contained in:
Ryan Di 2025-04-01 17:21:22 +11:00
parent c428a8a7b8
commit 87732874c6
3 changed files with 27 additions and 14 deletions

View file

@ -25,7 +25,10 @@ export default defineConfig(({ mode }) => {
alias: [ alias: [
{ {
find: /^@excalidraw\/common$/, find: /^@excalidraw\/common$/,
replacement: path.resolve(__dirname, "../packages/common/src/index.ts"), replacement: path.resolve(
__dirname,
"../packages/common/src/index.ts",
),
}, },
{ {
find: /^@excalidraw\/common\/(.*?)/, find: /^@excalidraw\/common\/(.*?)/,
@ -33,7 +36,10 @@ export default defineConfig(({ mode }) => {
}, },
{ {
find: /^@excalidraw\/element$/, find: /^@excalidraw\/element$/,
replacement: path.resolve(__dirname, "../packages/element/src/index.ts"), replacement: path.resolve(
__dirname,
"../packages/element/src/index.ts",
),
}, },
{ {
find: /^@excalidraw\/element\/(.*?)/, find: /^@excalidraw\/element\/(.*?)/,
@ -41,7 +47,10 @@ export default defineConfig(({ mode }) => {
}, },
{ {
find: /^@excalidraw\/excalidraw$/, find: /^@excalidraw\/excalidraw$/,
replacement: path.resolve(__dirname, "../packages/excalidraw/index.tsx"), replacement: path.resolve(
__dirname,
"../packages/excalidraw/index.tsx",
),
}, },
{ {
find: /^@excalidraw\/excalidraw\/(.*?)/, find: /^@excalidraw\/excalidraw\/(.*?)/,
@ -57,7 +66,10 @@ export default defineConfig(({ mode }) => {
}, },
{ {
find: /^@excalidraw\/utils$/, find: /^@excalidraw\/utils$/,
replacement: path.resolve(__dirname, "../packages/utils/src/index.ts"), replacement: path.resolve(
__dirname,
"../packages/utils/src/index.ts",
),
}, },
{ {
find: /^@excalidraw\/utils\/(.*?)/, find: /^@excalidraw\/utils\/(.*?)/,

View file

@ -29,10 +29,10 @@ import { type AnimationFrameHandler } from "../animation-frame-handler";
import { AnimatedTrail } from "../animated-trail"; import { AnimatedTrail } from "../animated-trail";
import LassoWorker from "./lasso-worker.ts?worker";
import { LassoWorkerPolyfill } from "./lasso-worker-polyfill"; import { LassoWorkerPolyfill } from "./lasso-worker-polyfill";
import { WorkerUrl } from "./lasso-worker.chunk";
import type App from "../components/App"; import type App from "../components/App";
import type { LassoWorkerInput, LassoWorkerOutput } from "./types"; import type { LassoWorkerInput, LassoWorkerOutput } from "./types";
@ -67,7 +67,7 @@ export class LassoTrail extends AnimatedTrail {
}); });
} }
startPath(x: number, y: number, keepPreviousSelection = false) { async startPath(x: number, y: number, keepPreviousSelection = false) {
// clear any existing trails just in case // clear any existing trails just in case
this.endPath(); this.endPath();
@ -86,10 +86,11 @@ export class LassoTrail extends AnimatedTrail {
} }
try { try {
this.worker = if (typeof Worker !== "undefined" && WorkerUrl) {
typeof Worker !== "undefined" this.worker = new Worker(WorkerUrl, { type: "module" });
? new LassoWorker() } else {
: new LassoWorkerPolyfill(); this.worker = new LassoWorkerPolyfill();
}
this.worker.onmessage = (event: MessageEvent<LassoWorkerOutput>) => { this.worker.onmessage = (event: MessageEvent<LassoWorkerOutput>) => {
const { selectedElementIds } = event.data; const { selectedElementIds } = event.data;

View file

@ -2,7 +2,9 @@ import { updateSelection } from "./utils";
import type { LassoWorkerInput } from "./types"; import type { LassoWorkerInput } from "./types";
const ctx = self as unknown as Worker; export const WorkerUrl: URL | undefined = import.meta.url
? new URL(import.meta.url)
: undefined;
// variables to track processing state and latest input data // variables to track processing state and latest input data
// for "backpressure" purposes // for "backpressure" purposes
@ -70,5 +72,3 @@ const processInputData = () => {
} }
} }
}; };
export default ctx;