From 53754a5a698b67b093e4b7171cb4f401741bb231 Mon Sep 17 00:00:00 2001 From: Martti Malmi Date: Tue, 9 Jan 2024 10:11:45 +0200 Subject: [PATCH] fix build --- .../system/src/worker/system-worker-script.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/system/src/worker/system-worker-script.ts b/packages/system/src/worker/system-worker-script.ts index c8dd52f5..94786e94 100644 --- a/packages/system/src/worker/system-worker-script.ts +++ b/packages/system/src/worker/system-worker-script.ts @@ -1,22 +1,22 @@ /// import { NostrSystem, NostrsystemProps } from "../nostr-system"; -import { NostrSystemMessage, NostrSystemCommand } from "."; +import { WorkerMessage, WorkerCommand } from "."; let system: NostrSystem | undefined; -function reply(id: string, type: NostrSystemCommand, data: T) { +function reply(id: string, type: WorkerCommand, data: T) { globalThis.postMessage({ id, type, data, - } as NostrSystemMessage); + } as WorkerMessage); } function okReply(id: string, message?: string) { - reply(id, NostrSystemCommand.OkResponse, message); + reply(id, WorkerCommand.OkResponse, message); } function errorReply(id: string, message: string) { - reply(id, NostrSystemCommand.ErrorResponse, message); + reply(id, WorkerCommand.ErrorResponse, message); } function checkInitialized() { if (system === undefined) { @@ -25,11 +25,11 @@ function checkInitialized() { } globalThis.onmessage = async ev => { - const data = ev.data as { id: string; type: NostrSystemCommand }; + const data = ev.data as { id: string; type: WorkerCommand }; try { switch (data.type) { - case NostrSystemCommand.Init: { - const cmd = ev.data as NostrSystemMessage; + case WorkerCommand.Init: { + const cmd = ev.data as WorkerMessage; if (system === undefined) { system = new NostrSystem(cmd.data); await system.Init(); @@ -39,9 +39,9 @@ globalThis.onmessage = async ev => { } break; } - case NostrSystemCommand.ConnectRelay: { + case WorkerCommand.ConnectRelay: { checkInitialized(); - const cmd = ev.data as NostrSystemMessage<[string, { read: boolean; write: boolean }]>; + const cmd = ev.data as WorkerMessage<[string, { read: boolean; write: boolean }]>; await system?.ConnectToRelay(cmd.data[0], cmd.data[1]); okReply(data.id, "Connected"); break;