From eb0f52ecb590ea7d5d06254b7dfc8256e8f0a00c Mon Sep 17 00:00:00 2001 From: yuding <1023798085@qq.com> Date: Sat, 28 Feb 2026 10:08:42 +0800 Subject: [PATCH] refactor(bim-engine): create ManagerRegistry instance and inject into managers BimEngine now instantiates its own ManagerRegistry and passes it to all managers during initialization. Each BimEngine instance is fully isolated. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus --- src/bim-engine.ts | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/bim-engine.ts b/src/bim-engine.ts index 940b862..59d59f8 100644 --- a/src/bim-engine.ts +++ b/src/bim-engine.ts @@ -56,7 +56,7 @@ export class BimEngine { if (!el) throw new Error('Container not found'); this.container = el; - this.registry = ManagerRegistry.getInstance(); + this.registry = new ManagerRegistry(); if (options?.locale) localeManager.setLocale(options.locale); if (options?.theme) { @@ -103,20 +103,20 @@ export class BimEngine { this.registry.container = this.container; this.registry.wrapper = this.wrapper; - this.engine = new EngineManager(this.wrapper); - this.dialog = new DialogManager(this.wrapper); - this.toolbar = new ToolbarManager(this.wrapper); - this.buttonGroup = new ButtonGroupManager(this.wrapper); - this.rightKey = new RightKeyManager(this.wrapper); - this.constructTreeBtn = new ConstructTreeManagerBtn(this.wrapper); + this.engine = new EngineManager(this.wrapper, this.registry); + this.dialog = new DialogManager(this.wrapper, this.registry); + this.toolbar = new ToolbarManager(this.wrapper, this.registry); + this.buttonGroup = new ButtonGroupManager(this.wrapper, this.registry); + this.rightKey = new RightKeyManager(this.wrapper, this.registry); + this.constructTreeBtn = new ConstructTreeManagerBtn(this.wrapper, this.registry); - this.measure = new MeasureDialogManager(); - this.sectionPlane = new SectionPlaneDialogManager(); - this.sectionAxis = new SectionAxisDialogManager(); - this.sectionBox = new SectionBoxDialogManager(); - this.walkControl = new WalkControlManager(); + this.measure = new MeasureDialogManager(this.registry); + this.sectionPlane = new SectionPlaneDialogManager(this.registry); + this.sectionAxis = new SectionAxisDialogManager(this.registry); + this.sectionBox = new SectionBoxDialogManager(this.registry); + this.walkControl = new WalkControlManager(this.registry); this.walkControl.init(); - this.engineInfo = new EngineInfoDialogManager(); + this.engineInfo = new EngineInfoDialogManager(this.registry); this.engineInfo.init(); this.registry.engine3d = this.engine; @@ -133,11 +133,11 @@ export class BimEngine { this.registry.walkControl = this.walkControl; this.registry.engineInfo = this.engineInfo; - this.componentDetail = new ComponentDetailManager(); + this.componentDetail = new ComponentDetailManager(this.registry); this.registry.componentDetail = this.componentDetail; this.componentDetail.init(); - this.aiChat = new AiChatManager(); + this.aiChat = new AiChatManager(this.registry); this.registry.aiChat = this.aiChat; this.aiChat.init(); @@ -167,6 +167,6 @@ export class BimEngine { this.walkControl?.destroy(); this.aiChat?.destroy(); this.container.innerHTML = ''; - ManagerRegistry.reset(); + this.registry.reset(); } }