From 037e6f7c156ff113293fd455ffd3022ca4d8e0af Mon Sep 17 00:00:00 2001 From: linonetwo Date: Thu, 8 Jun 2023 22:01:55 +0800 Subject: [PATCH] fix: get worker by workspace id --- src/services/native/index.ts | 4 ++-- src/services/native/interface.ts | 4 ++-- src/services/wiki/wikiWorker.ts | 5 +++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/services/native/index.ts b/src/services/native/index.ts index db69ab8f..2b60bd9e 100644 --- a/src/services/native/index.ts +++ b/src/services/native/index.ts @@ -102,8 +102,8 @@ export class NativeService implements INativeService { return toFilePath; } - public executeZxScript$(zxWorkerArguments: IZxFileInput, wikiFolderLocation?: string): Observable { - const zxWorker = this.wikiService.getWorker(wikiFolderLocation ?? this.workspaceService.getActiveWorkspaceSync()?.wikiFolderLocation ?? ''); + public executeZxScript$(zxWorkerArguments: IZxFileInput, workspaceID?: string): Observable { + const zxWorker = this.wikiService.getWorker(workspaceID ?? this.workspaceService.getActiveWorkspaceSync()?.id ?? ''); if (zxWorker === undefined) { const error = new ZxNotInitializedError(); return new Observable((observer) => { diff --git a/src/services/native/interface.ts b/src/services/native/interface.ts index 75c0cb45..ad880b6a 100644 --- a/src/services/native/interface.ts +++ b/src/services/native/interface.ts @@ -29,9 +29,9 @@ export interface INativeService { /** * Execute zx script in a wiki worker and get result. * @param zxWorkerArguments - * @param wikiFolderLocation Each wiki has its own worker, we use wiki's folder path to determine which worker to use. If not provided, will use current active workspace's wiki's path + * @param workspaceID Each wiki has its own worker, we use wiki's workspaceID to determine which worker to use. If not provided, will use current active workspace's ID */ - executeZxScript$(zxWorkerArguments: IZxFileInput, wikiFolderLocation?: string): Observable; + executeZxScript$(zxWorkerArguments: IZxFileInput, workspaceID?: string): Observable; getLocalHostUrlWithActualInfo(urlToReplace: string, workspaceID: string): Promise; handleFileProtocol(request: { url: string }, callback: (response: string) => void): Promise; log(level: string, message: string, meta?: Record): Promise; diff --git a/src/services/wiki/wikiWorker.ts b/src/services/wiki/wikiWorker.ts index d60211f8..c252ef24 100644 --- a/src/services/wiki/wikiWorker.ts +++ b/src/services/wiki/wikiWorker.ts @@ -217,6 +217,9 @@ function executeZxScript(file: IZxFileInput, zxPath: string): Observable { // if there are multiple console.log, their output will be concatenated into this stdout. And some of them are not intended to be executed. We use TW_SCRIPT_SEPARATOR to allow user determine the range they want to execute in the $tw context. const message = String(stdout); @@ -228,11 +231,13 @@ function executeZxScript(file: IZxFileInput, zxPath: string): Observable