From f868abf96529eb970990196bca0d02353a6d4e32 Mon Sep 17 00:00:00 2001 From: Kai Salmen Date: Tue, 1 Oct 2024 15:10:28 +0200 Subject: [PATCH] WorkerMessageDef: Rename answer to expectedAnswer --- CHANGELOG.md | 4 ++++ package-lock.json | 10 +++++----- packages/examples/package.json | 4 ++-- .../src/helloWorld/HelloWorldComChannelEndpoint.ts | 2 +- packages/wtd-core/package.json | 2 +- packages/wtd-core/src/ComChannelEndpoint.ts | 6 +++--- packages/wtd-core/src/offscreen/MainEventProxy.ts | 2 +- packages/wtd-core/src/offscreen/helper.ts | 2 +- packages/wtd-core/src/utilities.ts | 4 ++-- packages/wtd-three-ext/package.json | 4 ++-- 10 files changed, 22 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cee8646..8d70c9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 4.0.1 - 2024-10-01 + +- WorkerMessageDef: Rename answer to expectedAnswer + ## 4.0.0 - 2024-10-01 - ComChannelEndpoint has been extracted from WorkerTask diff --git a/package-lock.json b/package-lock.json index acfd038..1d40b0f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7776,8 +7776,8 @@ "dependencies": { "lil-gui": "~0.19.2", "three": "~0.169.0", - "wtd-core": "~4.0.0", - "wtd-three-ext": "~4.0.0", + "wtd-core": "~4.0.1", + "wtd-three-ext": "~4.0.1", "wwobjloader2": "6.2.1" }, "devDependencies": { @@ -7786,15 +7786,15 @@ } }, "packages/wtd-core": { - "version": "4.0.0", + "version": "4.0.1", "license": "MIT" }, "packages/wtd-three-ext": { - "version": "4.0.0", + "version": "4.0.1", "license": "MIT", "dependencies": { "three": "~0.169.0", - "wtd-core": "~4.0.0" + "wtd-core": "~4.0.1" }, "devDependencies": { "@types/three": "~0.169.0" diff --git a/packages/examples/package.json b/packages/examples/package.json index 7d2d2ec..f325aa0 100644 --- a/packages/examples/package.json +++ b/packages/examples/package.json @@ -19,8 +19,8 @@ "dependencies": { "lil-gui": "~0.19.2", "three": "~0.169.0", - "wtd-core": "~4.0.0", - "wtd-three-ext": "~4.0.0", + "wtd-core": "~4.0.1", + "wtd-three-ext": "~4.0.1", "wwobjloader2": "6.2.1" }, "devDependencies": { diff --git a/packages/examples/src/helloWorld/HelloWorldComChannelEndpoint.ts b/packages/examples/src/helloWorld/HelloWorldComChannelEndpoint.ts index e74e0ca..311f1eb 100644 --- a/packages/examples/src/helloWorld/HelloWorldComChannelEndpoint.ts +++ b/packages/examples/src/helloWorld/HelloWorldComChannelEndpoint.ts @@ -27,7 +27,7 @@ class HelloWorldComChannelEndpointExample { cmd: 'hello_world' }), awaitAnswer: true, - answer: 'hello_world_confirm' + expectedAnswer: 'hello_world_confirm' },); const rawPayload = result.payloads[0] as RawPayload; diff --git a/packages/wtd-core/package.json b/packages/wtd-core/package.json index d062f3b..5386fc7 100644 --- a/packages/wtd-core/package.json +++ b/packages/wtd-core/package.json @@ -1,6 +1,6 @@ { "name": "wtd-core", - "version": "4.0.0", + "version": "4.0.1", "license": "MIT", "type": "module", "main": "./dist/index.js", diff --git a/packages/wtd-core/src/ComChannelEndpoint.ts b/packages/wtd-core/src/ComChannelEndpoint.ts index 024ba85..2e757a3 100644 --- a/packages/wtd-core/src/ComChannelEndpoint.ts +++ b/packages/wtd-core/src/ComChannelEndpoint.ts @@ -25,7 +25,7 @@ export interface WorkerMessageDef { message: WorkerMessage; transferables?: Transferable[]; copyTransferables?: boolean; - answer?: string; + expectedAnswer?: string; awaitAnswer?: boolean; } @@ -123,12 +123,12 @@ export class ComChannelEndpoint { const transferablesToWorker = this.handleTransferables(def); if (def.awaitAnswer === true) { - if (def.answer === undefined) { + if (def.expectedAnswer === undefined) { reject(new Error('No answer name provided. Aborting...')); return; } this.updateAwaitHandlers(message, [{ - name: def.answer, + name: def.expectedAnswer, resolve: [resolve], reject: reject, remove: true, diff --git a/packages/wtd-core/src/offscreen/MainEventProxy.ts b/packages/wtd-core/src/offscreen/MainEventProxy.ts index 32ff1d2..b9aeb09 100644 --- a/packages/wtd-core/src/offscreen/MainEventProxy.ts +++ b/packages/wtd-core/src/offscreen/MainEventProxy.ts @@ -165,7 +165,7 @@ export const registerCanvas = async (workerTask: WorkerTask, canvas: HTMLCanvasE await workerTask.sentMessage({ message: WorkerMessage.fromPayload(new OffscreenPayload({}), OffscreenWorkerCommandRequest.PROXY_START), awaitAnswer: true, - answer: OffscreenWorkerCommandResponse.PROXY_START_COMPLETE + expectedAnswer: OffscreenWorkerCommandResponse.PROXY_START_COMPLETE }); for (const [eventName, instruction] of handlingInstructions.entries()) { diff --git a/packages/wtd-core/src/offscreen/helper.ts b/packages/wtd-core/src/offscreen/helper.ts index 34462c5..9a1caa4 100644 --- a/packages/wtd-core/src/offscreen/helper.ts +++ b/packages/wtd-core/src/offscreen/helper.ts @@ -19,7 +19,7 @@ export const initOffscreenCanvas = async (workerTask: WorkerTask, canvas: HTMLCa message: WorkerMessage.fromPayload(offscreenPayloadRenderer, OffscreenWorkerCommandRequest.INIT_OFFSCREEN_CANVAS), transferables: [offscreenCanvas], awaitAnswer: true, - answer: OffscreenWorkerCommandResponse.INIT_OFFSCREEN_CANVAS_COMPLETE + expectedAnswer: OffscreenWorkerCommandResponse.INIT_OFFSCREEN_CANVAS_COMPLETE }); }; diff --git a/packages/wtd-core/src/utilities.ts b/packages/wtd-core/src/utilities.ts index 890bbd0..0f9d222 100644 --- a/packages/wtd-core/src/utilities.ts +++ b/packages/wtd-core/src/utilities.ts @@ -55,7 +55,7 @@ export const initChannel = async (workerOne: WorkerTask, workerTwo: WorkerTask) message: WorkerMessage.fromPayload(payloadOne, WorkerTaskCommandRequest.INIT_CHANNEL), transferables: [channel.port1], awaitAnswer: true, - answer: WorkerTaskCommandResponse.INIT_CHANNEL_COMPLETE + expectedAnswer: WorkerTaskCommandResponse.INIT_CHANNEL_COMPLETE })); const payloadTwo = new RawPayload({ @@ -65,7 +65,7 @@ export const initChannel = async (workerOne: WorkerTask, workerTwo: WorkerTask) message: WorkerMessage.fromPayload(payloadTwo, WorkerTaskCommandRequest.INIT_CHANNEL), transferables: [channel.port2], awaitAnswer: true, - answer: WorkerTaskCommandResponse.INIT_CHANNEL_COMPLETE + expectedAnswer: WorkerTaskCommandResponse.INIT_CHANNEL_COMPLETE })); return Promise.all(promises); }; diff --git a/packages/wtd-three-ext/package.json b/packages/wtd-three-ext/package.json index 2c16d37..29f8910 100644 --- a/packages/wtd-three-ext/package.json +++ b/packages/wtd-three-ext/package.json @@ -1,6 +1,6 @@ { "name": "wtd-three-ext", - "version": "4.0.0", + "version": "4.0.1", "license": "MIT", "type": "module", "main": "./dist/index.js", @@ -45,7 +45,7 @@ "npm": "10.8.3" }, "dependencies": { - "wtd-core": "~4.0.0", + "wtd-core": "~4.0.1", "three": "~0.169.0" }, "devDependencies": {