From 978d029dab7a86f68d4d6a3ff4af8698a8f76985 Mon Sep 17 00:00:00 2001 From: Andreas Hell Date: Sat, 6 Apr 2024 22:31:50 +0200 Subject: [PATCH] Fixed webworker startup bc elkjs hidden dependency --- .gitignore | 2 ++ examples/workflow-server-bundled/package.json | 2 +- packages/layout-elk/src/di.config.ts | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 8bf753c..be44adc 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,5 @@ report.xml wf-glsp-server-node.js wf-glsp-server-node.js.map +wf-glsp-server-webworker.js +wf-glsp-server-webworker.js.map \ No newline at end of file diff --git a/examples/workflow-server-bundled/package.json b/examples/workflow-server-bundled/package.json index 10a213e..e291068 100644 --- a/examples/workflow-server-bundled/package.json +++ b/examples/workflow-server-bundled/package.json @@ -41,7 +41,7 @@ "wf-glsp-server-node.js.map" ], "scripts": { - "clean": "rimraf wf-glsp-server-node.js wf-glsp-server-node.js.map", + "clean": "rimraf wf-glsp-server-node.js wf-glsp-server-node.js.map wf-glsp-server-webworker.js wf-glsp-server-webworker.js.map", "start": "node --enable-source-maps ./wf-glsp-server-node.js --port 5007", "start:websocket": "node --enable-source-maps ./wf-glsp-server-node.js -w --port 8081", "watch": "tsc -w" diff --git a/packages/layout-elk/src/di.config.ts b/packages/layout-elk/src/di.config.ts index 41954b4..24fbcdb 100644 --- a/packages/layout-elk/src/di.config.ts +++ b/packages/layout-elk/src/di.config.ts @@ -82,7 +82,11 @@ export function configureELKLayoutModule(options: ElkModuleOptions): ContainerMo const elkFactory: ElkFactory = () => new ElkConstructor({ algorithms: options.algorithms, - defaultLayoutOptions: options.defaultLayoutOptions + defaultLayoutOptions: options.defaultLayoutOptions, + // The node implementation relied on elkjs' `FakeWorker` to set the `workerFactory`. + // However, since the required file is dynamically loaded and not available in a web-worker context, + // it needs to be mocked manually. + workerFactory: () => ({ postMessage: () => {} }) as unknown as Worker }); bind(ElkFactory).toConstantValue(elkFactory);