Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add worker init config string #4855

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/core/src/types/const/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,5 @@ export const DEFAULT_SLIDE = {
};

export const SHEET_EDITOR_UNITS = [DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DOCS_ZEN_EDITOR_UNIT_ID_KEY, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY];

export const WORKER_CONFIG_INIT_KEY = 'WORKER_CONFIG_INIT_KEY';
5 changes: 3 additions & 2 deletions packages/rpc/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import type {
IUniverRPCMainThreadConfig,
IUniverRPCWorkerThreadConfig,
} from './controllers/config.schema';
import { IConfigService, Inject, Injector, merge, Plugin } from '@univerjs/core';
import { IConfigService, Inject, Injector, merge, Plugin, WORKER_CONFIG_INIT_KEY } from '@univerjs/core';
import {
defaultPluginMainThreadConfig,
defaultPluginWorkerThreadConfig,
Expand Down Expand Up @@ -80,7 +80,8 @@ export class UniverRPCMainThreadPlugin extends Plugin {
throw new Error('[UniverRPCMainThreadPlugin]: The workerURL is required for the RPC main thread plugin.');
}

const worker = workerURL instanceof Worker ? workerURL : new Worker(workerURL);
const initConfig = this._configService.getConfig<string>(WORKER_CONFIG_INIT_KEY);
const worker = workerURL instanceof Worker ? workerURL : new Worker(initConfig?.length ? `${workerURL}?${initConfig}` : workerURL);
this._internalWorker = workerURL instanceof Worker ? null : worker;

const messageProtocol = createWebWorkerMessagePortOnMain(worker);
Expand Down