From 05282fe73df7b2ab94896f2c47132512b386f2b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=8E=E5=A3=B0?= Date: Thu, 19 Sep 2024 15:55:55 +0800 Subject: [PATCH] fix: editor renderer not work --- packages/core/src/api/createEditor.tsx | 4 ++-- packages/core/src/core/editor/modules.ts | 4 ++-- packages/sumi-core/src/server/core/app.ts | 18 +++++++++--------- packages/sumi-core/src/server/index.ts | 9 ++++++++- packages/sumi-core/src/server/search/base.ts | 2 +- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/packages/core/src/api/createEditor.tsx b/packages/core/src/api/createEditor.tsx index ce3bc4fe..4dab65a2 100644 --- a/packages/core/src/api/createEditor.tsx +++ b/packages/core/src/api/createEditor.tsx @@ -30,7 +30,7 @@ import { IAppInstance, IConfig } from './types'; export { BoxPanel, SlotLocation, SlotRenderer, SplitPanel }; -const getDefaultAppConfig = (): IAppOpts => ({ +const getDefaultEditorAppConfig = (): IAppOpts => ({ modules: getModules(), useCdnIcon: true, noExtHost: true, @@ -62,7 +62,7 @@ const getDefaultAppConfig = (): IAppOpts => ({ }); export function createEditor({ appConfig, runtimeConfig }: IConfig): IAppInstance { - const opts = interceptAppOpts(mergeConfig(getDefaultAppConfig(), appConfig), runtimeConfig); + const opts = interceptAppOpts(mergeConfig(getDefaultEditorAppConfig(), appConfig), runtimeConfig); if (!opts.workspaceDir) { throw new Error( diff --git a/packages/core/src/core/editor/modules.ts b/packages/core/src/core/editor/modules.ts index f1066116..3c3b1e06 100644 --- a/packages/core/src/core/editor/modules.ts +++ b/packages/core/src/core/editor/modules.ts @@ -26,7 +26,7 @@ import { WorkspaceModule } from '@opensumi/ide-workspace/lib/browser'; * alex */ import { PluginModule } from '@codeblitzjs/ide-plugin'; -import { ClientModule, ServerModuleCollection } from '@codeblitzjs/ide-sumi-core'; +import { ClientModule, EditorServerModuleCollection } from '@codeblitzjs/ide-sumi-core'; /** * editor special @@ -66,7 +66,7 @@ export const getModules: () => ModuleConstructor[] = () => [ // CodeBlitz ClientModule, PluginModule, - ...ServerModuleCollection, + ...EditorServerModuleCollection, // Editor Special EditorSpecialModule, diff --git a/packages/sumi-core/src/server/core/app.ts b/packages/sumi-core/src/server/core/app.ts index 50f1aaaf..561e487f 100644 --- a/packages/sumi-core/src/server/core/app.ts +++ b/packages/sumi-core/src/server/core/app.ts @@ -111,7 +111,7 @@ export class ServerApp implements IServerApp { public rootFS: RootFS; - private disposeCollection = new DisposableCollection(); + private _disposables = new DisposableCollection(); constructor( opts: IServerAppOpts & { @@ -149,7 +149,7 @@ export class ServerApp implements IServerApp { }; window.addEventListener('unload', handleUnload); - this.disposeCollection.push({ + this._disposables.push({ dispose: () => { window.removeEventListener('unload', handleUnload); }, @@ -191,7 +191,7 @@ export class ServerApp implements IServerApp { try { const runtimeConfig: RuntimeConfig = this.injector.get(RuntimeConfig); this.rootFS = await initializeRootFileSystem(); - this.disposeCollection.push( + this._disposables.push( await initializeHomeFileSystem(this.rootFS, runtimeConfig.scenario), ); @@ -223,8 +223,8 @@ export class ServerApp implements IServerApp { async start() { await this.launch(); await this.initializeContribution(); - const commonChannelPathHandler = this.injector.get(CommonChannelPathHandler); - const handler = new CodeblitzCommonChannelHandler('codeblitz-server', commonChannelPathHandler); + const pathHandler = this.injector.get(CommonChannelPathHandler); + const handler = new CodeblitzCommonChannelHandler('codeblitz-server', pathHandler); const channel = this.injector.get(InMemoryMessageChannel) as InMemoryMessageChannel; handler.receiveConnection(new CodeBlitzConnection(channel.port2)); @@ -236,11 +236,11 @@ export class ServerApp implements IServerApp { dispose: () => {}, }; - commonChannelPathHandler.register(RPCServiceChannelPath, channelHandler); + pathHandler.register(RPCServiceChannelPath, channelHandler); - this.disposeCollection.push({ + this._disposables.push({ dispose: () => { - commonChannelPathHandler.removeHandler(RPCServiceChannelPath, channelHandler); + pathHandler.removeHandler(RPCServiceChannelPath, channelHandler); }, }); @@ -252,7 +252,7 @@ export class ServerApp implements IServerApp { } dispose() { - this.disposeCollection.dispose(); + this._disposables.dispose(); } } diff --git a/packages/sumi-core/src/server/index.ts b/packages/sumi-core/src/server/index.ts index 6f0be113..5eaf1adb 100644 --- a/packages/sumi-core/src/server/index.ts +++ b/packages/sumi-core/src/server/index.ts @@ -1,3 +1,4 @@ +import { ModuleConstructor } from '@opensumi/ide-core-browser'; import { ServerCommonModule } from './core/common.module'; import { ExtensionManagerModule } from './extension-manager'; import { FileSchemeNodeModule } from './file-scheme'; @@ -33,4 +34,10 @@ export const ServerModuleCollection = [ FileSearchModule, SearchModule, ExtensionManagerModule, -]; +] as ModuleConstructor[]; + +const editorDisabledModules = new Set([SearchModule] as ModuleConstructor[]); + +export const EditorServerModuleCollection = ServerModuleCollection.filter((m) => { + return !editorDisabledModules.has(m); +}); diff --git a/packages/sumi-core/src/server/search/base.ts b/packages/sumi-core/src/server/search/base.ts index 3b8f3511..6287ca3f 100644 --- a/packages/sumi-core/src/server/search/base.ts +++ b/packages/sumi-core/src/server/search/base.ts @@ -7,7 +7,7 @@ export { SendClientResult, } from '@opensumi/ide-search/lib/common'; -export const IContentSearchServer = Symbol('ContentSearchService'); +export const IContentSearchServer = Symbol('IContentSearchServer'); export interface IContentSearchServer extends _IContentSearchServer {}