refactor: 类型安全与接口清理 (#311)

* refactor: 分解 IEngineBridge 为单一职责接口

- 新增 ITextureService, IDynamicAtlasService, ICoordinateService, IRenderConfigService
- 移除 EngineBridgeToken,改用具体服务 Token
- 更新 camera, ui, particle 等模块使用新接口
- 优化装饰器类型安全,使用 Symbol-based metadata 访问模式

* refactor: 删除 plugin-types 包,统一 createServiceToken 实现

- 移动 IEditorModuleBase 接口到 engine-core
- 移除 engine-core 和 editor-core 对 plugin-types 的依赖
- 删除冗余的 plugin-types 包
- 统一使用 core 中基于 Symbol.for() 的 createServiceToken

* refactor: 统一 IPlugin 接口,移除 deprecated 别名

- 移除 engine-core、editor-core、runtime-core 中的 IPlugin 别名
- 模块插件统一使用 IRuntimePlugin(运行时)或 IEditorPlugin(编辑器)
- 保留 core 包中的 IPlugin 作为 ECS 核心插件接口(不同概念)
- 更新所有消费方使用正确的类型

* refactor: 重命名 editor-core ComponentRegistry 为 EditorComponentRegistry

- 消除与 core 包 ComponentRegistry(ECS 位掩码管理)的命名歧义
- editor-core 的 EditorComponentRegistry 专用于编辑器组件元数据
- 更新所有编辑器包使用新名称
This commit is contained in:
YHH
2025-12-19 17:48:18 +08:00
committed by GitHub
parent ecdb8f2021
commit e24c850568
51 changed files with 492 additions and 623 deletions

View File

@@ -6,6 +6,12 @@
import type { SpriteRenderData, TextureLoadRequest, EngineStats, CameraConfig } from '../types';
import type { ITextureEngineBridge } from '@esengine/asset-system';
import type { GameEngine } from '../wasm/es_engine';
import type {
ITextureService,
IDynamicAtlasService,
ICoordinateService,
IRenderConfigService
} from '@esengine/engine-core';
/**
* Engine bridge configuration.
@@ -43,7 +49,7 @@ export interface EngineBridgeConfig {
* bridge.render();
* ```
*/
export class EngineBridge implements ITextureEngineBridge {
export class EngineBridge implements ITextureEngineBridge, ITextureService, IDynamicAtlasService, ICoordinateService, IRenderConfigService {
private engine: GameEngine | null = null;
private config: Required<EngineBridgeConfig>;
private initialized = false;

View File

@@ -8,12 +8,20 @@
// Service tokens and interfaces (谁定义接口,谁导出 Token)
export {
RenderSystemToken,
EngineBridgeToken,
EngineIntegrationToken,
// 新的单一职责服务令牌 | New single-responsibility service tokens
TextureServiceToken,
DynamicAtlasServiceToken,
CoordinateServiceToken,
RenderConfigServiceToken,
// 接口类型 | Interface types
type IRenderSystem,
type IEngineBridge,
type IEngineIntegration,
type IRenderDataProvider
type IRenderDataProvider,
type ITextureService,
type IDynamicAtlasService,
type ICoordinateService,
type IRenderConfigService
} from './tokens';
export { EngineBridge } from './core/EngineBridge';

View File

@@ -4,12 +4,31 @@
*/
import { createServiceToken } from '@esengine/ecs-framework';
import { EngineBridgeToken as CoreEngineBridgeToken, type IEngineBridge as CoreIEngineBridge } from '@esengine/engine-core';
import {
TextureServiceToken,
DynamicAtlasServiceToken,
CoordinateServiceToken,
RenderConfigServiceToken,
type ITextureService,
type IDynamicAtlasService,
type ICoordinateService,
type IRenderConfigService
} from '@esengine/engine-core';
import type { IRenderDataProvider as InternalIRenderDataProvider } from './systems/EngineRenderSystem';
// 从 engine-core 重新导出 | Re-export from engine-core
export { CoreEngineBridgeToken as EngineBridgeToken };
export type { CoreIEngineBridge as IEngineBridge };
export {
TextureServiceToken,
DynamicAtlasServiceToken,
CoordinateServiceToken,
RenderConfigServiceToken
};
export type {
ITextureService,
IDynamicAtlasService,
ICoordinateService,
IRenderConfigService
};
export type IRenderDataProvider = InternalIRenderDataProvider;