A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
fix: resolve broken imports and circular dependency after service refactor
esengine62c40daa7b1a
diff --git a/desktop/src/panel-window.ts b/desktop/src/panel-window.tsindex 361f55b1a..f1f6095e2 100644--- a/desktop/src/panel-window.ts+++ b/desktop/src/panel-window.ts@@ -4,15 +4,17 @@ import {setPlatformAdapter,setEditorContext,getPanel,- registerBuiltinEditors,- registerBuiltinSchemas,- registerBuiltinPanels,getAssetDatabase,type PanelInstance,- isOutputAppendable,+ EditorContainer,+ setEditorContainer,+ builtinPlugins,+ getOutputService,RemoteEditorStore,CHANNEL_OUTPUT,type OutputMessage,+ tokens,+ type ServiceToken,} from '@esengine/editor';import { TauriPlatformAdapter } from './TauriPlatformAdapter';import { nativeFS, nativeShell } from './native-fs';@@ -37,11 +39,20 @@ async function init(): Promise<void> {version,});- registerBuiltinEditors();- registerBuiltinSchemas();- registerBuiltinPanels({});+ const iocContainer = new EditorContainer();+ setEditorContainer(iocContainer);const projectPath = params.get('projectPath');+ const pluginCtx = { registrar: iocContainer, projectPath };+ for (const plugin of builtinPlugins) {+ plugin.register(pluginCtx);+ }++ const store = new RemoteEditorStore(panelId);+ await store.connect();+ const storeToken = tokens.EDITOR_STORE as ServiceToken<RemoteEditorStore>;+ iocContainer.provide(storeToken, 'default', store);+if (projectPath) {const projectDir = projectPath.replace(/[/\\][^/\\]+$/, '');const db = getAssetDatabase();@@ -62,22 +73,20 @@ async function init(): Promise<void> {document.title = desc.title;- const store = new RemoteEditorStore(panelId);- await store.connect();-let panelInstance: PanelInstance | null = null;try {- panelInstance = desc.factory(container, store as any);+ const result = desc.factory(container);+ panelInstance = result.instance;} catch (err) {console.error(`Failed to create panel "${panelId}":`, err);container.textContent = `Failed to load panel: ${(err as Error).message}`;return;}- if (panelId === 'output' && panelInstance && isOutputAppendable(panelInstance)) {- const outputPanel = panelInstance;+ if (panelId === 'output') {+ const outputService = getOutputService();await listen<OutputMessage>(CHANNEL_OUTPUT, (event) => {- outputPanel.appendOutput(event.payload.text, event.payload.type);+ outputService.appendOutput(event.payload.text, event.payload.type);});}diff --git a/editor/src/index.ts b/editor/src/index.tsindex f1470b1de..e0f358a95 100644--- a/editor/src/index.ts+++ b/editor/src/index.ts@@ -385,7 +385,9 @@ export {export {type PluginRegistrar,+ ServiceToken,EditorContainer,+ setEditorContainer,getEditorContainer,} from './container';@@ -396,6 +398,8 @@ export * as tokens from './container/tokens';// =============================================================================export type { EditorPlugin, EditorPluginContext } from './plugins/EditorPlugin';+export { builtinPlugins } from './plugins';+export { OutputService, getOutputService } from './services';// =============================================================================// SDK Re-exportsdiff --git a/editor/src/panels/builtinPanels.ts b/editor/src/panels/builtinPanels.tsindex 763a9f27f..382509c73 100644--- a/editor/src/panels/builtinPanels.ts+++ b/editor/src/panels/builtinPanels.ts@@ -11,6 +11,7 @@ import { ProfilerPanel } from './profiler/ProfilerPanel';import { TimelinePanel } from './timeline/TimelinePanel';import { icons } from '../utils/icons';import { getEditorStore } from '../store';+import { getSceneService } from '../services';const PANEL_ICON_SIZE = 14;@@ -66,15 +67,12 @@ export function registerBuiltinPanels(registrar: PluginRegistrar, options: Builtposition: 'bottom',order: 0,defaultVisible: true,- factory: (c) => {- const { getSceneService } = require('../services');- return {- instance: new ContentBrowserPanel(c, getEditorStore(), {- projectPath: options.projectPath,- onOpenScene: (path: string) => getSceneService().openSceneFromPath(path),- }),- };- },+ factory: (c) => ({+ instance: new ContentBrowserPanel(c, getEditorStore(), {+ projectPath: options.projectPath,+ onOpenScene: (path: string) => getSceneService().openSceneFromPath(path),+ }),+ }),});registerPanel({diff --git a/editor/src/services/PlayModeService.ts b/editor/src/services/PlayModeService.tsindex 61f78b0b8..0a3497b6e 100644--- a/editor/src/services/PlayModeService.ts+++ b/editor/src/services/PlayModeService.ts@@ -6,7 +6,7 @@ import { getEditorStore, type SceneSnapshot } from '../store/EditorStore';import { getSharedRenderContext } from '../renderer/SharedRenderContext';import { ScriptInjector } from './ScriptInjector';import { getEditorContext } from '../context/EditorContext';-import { getScriptService } from './index';+import { SCRIPT_SERVICE } from '../container/tokens';import { getAssetDatabase, isUUID } from '../asset';export interface EntityComponentData {@@ -271,7 +271,8 @@ export class PlayModeService {const app = ctx.app_;if (!app) return;- const compiledCode = getScriptService().getCompiledScripts();+ const scriptService = getEditorContainer().get(SCRIPT_SERVICE, 'default')!;+ const compiledCode = scriptService.getCompiledScripts();if (!compiledCode) return;this.scriptInjector_ = new ScriptInjector();