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

@@ -43,7 +43,6 @@
"@esengine/asset-system": "workspace:*",
"@esengine/asset-system-editor": "workspace:*",
"@esengine/engine-core": "workspace:*",
"@esengine/plugin-types": "workspace:*",
"@tauri-apps/api": "^2.2.0",
"@babel/core": "^7.28.3",
"@babel/plugin-transform-nullish-coalescing-operator": "^7.27.1",

View File

@@ -15,7 +15,7 @@ export type {
LoadingPhase,
SystemContext,
IRuntimeModule,
IPlugin,
IRuntimePlugin,
ModuleManifest,
ModuleCategory,
ModulePlatform,
@@ -309,17 +309,17 @@ export interface IEditorModuleLoader extends IEditorModuleBase {
// 编辑器插件类型 | Editor Plugin Type
// ============================================================================
import type { IPlugin } from './PluginDescriptor';
import type { IRuntimePlugin } from './PluginDescriptor';
/**
* 编辑器插件类型
* Editor plugin type
*
* 这是开发编辑器插件时应使用的类型。
* 它是 IPlugin 的特化版本editorModule 类型为 IEditorModuleLoader。
* 它是 IRuntimePlugin 的特化版本editorModule 类型为 IEditorModuleLoader。
*
* This is the type to use when developing editor plugins.
* It's a specialized version of IPlugin with editorModule typed as IEditorModuleLoader.
* It's a specialized version of IRuntimePlugin with editorModule typed as IEditorModuleLoader.
*
* @example
* ```typescript
@@ -337,4 +337,4 @@ import type { IPlugin } from './PluginDescriptor';
* };
* ```
*/
export type IEditorPlugin = IPlugin<IEditorModuleLoader>;
export type IEditorPlugin = IRuntimePlugin<IEditorModuleLoader>;

View File

@@ -6,10 +6,6 @@
* Re-export base types from @esengine/engine-core.
*/
// 从 engine-core 导入类型
// Import types from engine-core
import type { IRuntimePlugin as IRuntimePluginBase } from '@esengine/engine-core';
// 从 engine-core 重新导出所有类型
// 包括 IEditorModuleBase原来在 plugin-types 中定义,现在统一从 engine-core 导出)
export type {
@@ -24,9 +20,6 @@ export type {
IEditorModuleBase
} from '@esengine/engine-core';
/** @deprecated Use IRuntimePlugin instead */
export type IPlugin<TEditorModule = unknown> = IRuntimePluginBase<TEditorModule>;
/**
* 插件状态
* Plugin state

View File

@@ -7,7 +7,7 @@ import { createLogger, GlobalComponentRegistry } from '@esengine/ecs-framework';
import type { IScene, ServiceContainer, IService } from '@esengine/ecs-framework';
import type {
ModuleManifest,
IPlugin,
IRuntimePlugin,
ModuleCategory,
PluginState
} from './PluginDescriptor';
@@ -22,7 +22,7 @@ import { UIRegistry } from '../Services/UIRegistry';
import { MessageHub } from '../Services/MessageHub';
import { moduleRegistry } from '../Services/Module/ModuleRegistry';
import { SerializerRegistry } from '../Services/SerializerRegistry';
import { ComponentRegistry as EditorComponentRegistry } from '../Services/ComponentRegistry';
import { EditorComponentRegistry } from '../Services/ComponentRegistry';
const logger = createLogger('PluginManager');
@@ -64,7 +64,7 @@ export interface NormalizedManifest {
*/
export interface NormalizedPlugin {
manifest: NormalizedManifest;
runtimeModule?: IPlugin['runtimeModule'];
runtimeModule?: IRuntimePlugin['runtimeModule'];
editorModule?: IEditorModuleLoader;
}
@@ -196,7 +196,7 @@ export class PluginManager implements IService {
* 标准化模块清单,填充默认值
* Normalize module manifest, fill in defaults
*/
private normalizePlugin(input: IPlugin): NormalizedPlugin {
private normalizePlugin(input: IRuntimePlugin): NormalizedPlugin {
const m = input.manifest;
return {
manifest: {
@@ -229,10 +229,10 @@ export class PluginManager implements IService {
* 注册插件
* Register plugin
*
* 接受任何符合 IPlugin 接口的插件,内部会标准化所有字段。
* Accepts any plugin conforming to IPlugin interface, normalizes all fields internally.
* 接受任何符合 IRuntimePlugin 接口的插件,内部会标准化所有字段。
* Accepts any plugin conforming to IRuntimePlugin interface, normalizes all fields internally.
*/
register(plugin: IPlugin): void {
register(plugin: IRuntimePlugin): void {
if (!plugin) {
logger.error('Cannot register plugin: plugin is null or undefined');
return;

View File

@@ -14,10 +14,17 @@ export interface ComponentTypeInfo {
}
/**
* 管理编辑器中可用的组件类型
* 编辑器组件注册表
* Editor Component Registry
*
* 管理编辑器中可用的组件类型元数据(名称、分类、图标等)。
* 与 ECS 核心的 ComponentRegistry管理组件位掩码不同。
*
* Manages component type metadata (name, category, icon, etc.) for the editor.
* Different from the ECS core ComponentRegistry (which manages component bitmasks).
*/
@Injectable()
export class ComponentRegistry implements IService {
export class EditorComponentRegistry implements IService {
private components: Map<string, ComponentTypeInfo> = new Map();
public dispose(): void {