Skip to content

Commit

Permalink
WorkerMessageDef: Rename answer to expectedAnswer
Browse files Browse the repository at this point in the history
  • Loading branch information
kaisalmen committed Oct 1, 2024
1 parent d24bfe8 commit f868abf
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/wtd-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wtd-core",
"version": "4.0.0",
"version": "4.0.1",
"license": "MIT",
"type": "module",
"main": "./dist/index.js",
Expand Down
6 changes: 3 additions & 3 deletions packages/wtd-core/src/ComChannelEndpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface WorkerMessageDef {
message: WorkerMessage;
transferables?: Transferable[];
copyTransferables?: boolean;
answer?: string;
expectedAnswer?: string;
awaitAnswer?: boolean;
}

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/wtd-core/src/offscreen/MainEventProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion packages/wtd-core/src/offscreen/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
};

Expand Down
4 changes: 2 additions & 2 deletions packages/wtd-core/src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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);
};
Expand Down
4 changes: 2 additions & 2 deletions packages/wtd-three-ext/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wtd-three-ext",
"version": "4.0.0",
"version": "4.0.1",
"license": "MIT",
"type": "module",
"main": "./dist/index.js",
Expand Down Expand Up @@ -45,7 +45,7 @@
"npm": "10.8.3"
},
"dependencies": {
"wtd-core": "~4.0.0",
"wtd-core": "~4.0.1",
"three": "~0.169.0"
},
"devDependencies": {
Expand Down

0 comments on commit f868abf

Please sign in to comment.