Feature/editor optimization (#251)

* refactor: 编辑器/运行时架构拆分与构建系统升级

* feat(core): 层级系统重构与UI变换矩阵修复

* refactor: 移除 ecs-components 聚合包并修复跨包组件查找问题

* fix(physics): 修复跨包组件类引用问题

* feat: 统一运行时架构与浏览器运行支持

* feat(asset): 实现浏览器运行时资产加载系统

* fix: 修复文档、CodeQL安全问题和CI类型检查错误

* fix: 修复文档、CodeQL安全问题和CI类型检查错误

* fix: 修复文档、CodeQL安全问题、CI类型检查和测试错误

* test: 补齐核心模块测试用例,修复CI构建配置

* fix: 修复测试用例中的类型错误和断言问题

* fix: 修复 turbo build:npm 任务的依赖顺序问题

* fix: 修复 CI 构建错误并优化构建性能
This commit is contained in:
YHH
2025-12-01 22:28:51 +08:00
committed by GitHub
parent 189714c727
commit b42a7b4e43
468 changed files with 18301 additions and 9075 deletions

View File

@@ -1,71 +1,29 @@
/**
* 插件加载器接口
* Plugin loader interfaces
* 编辑器模块接口
* Editor module interfaces
*
* 定义编辑器专用的模块接口和 UI 描述符类型。
* Define editor-specific module interfaces and UI descriptor types.
*/
import type { IScene, ServiceContainer, ComponentRegistry } from '@esengine/ecs-framework';
import type { PluginDescriptor } from './PluginDescriptor';
import type { ServiceContainer } from '@esengine/ecs-framework';
/**
* 系统创建上下文
* System creation context
*/
export interface SystemContext {
/** 是否为编辑器模式 | Is editor mode */
isEditor: boolean;
// 从 PluginDescriptor 重新导出(来源于 engine-core
export type {
PluginCategory,
LoadingPhase,
ModuleType,
ModuleDescriptor,
PluginDependency,
PluginDescriptor,
SystemContext,
IRuntimeModule,
IPlugin
} from './PluginDescriptor';
/** 引擎桥接(如有) | Engine bridge (if available) */
engineBridge?: any;
/** 渲染系统(如有) | Render system (if available) */
renderSystem?: any;
/** 其他已创建的系统引用 | Other created system references */
[key: string]: any;
}
/**
* 运行时模块加载器
* Runtime module loader
*/
export interface IRuntimeModuleLoader {
/**
* 注册组件到 ComponentRegistry
* Register components to ComponentRegistry
*/
registerComponents(registry: typeof ComponentRegistry): void;
/**
* 注册服务到 ServiceContainer
* Register services to ServiceContainer
*/
registerServices?(services: ServiceContainer): void;
/**
* 为场景创建系统
* Create systems for scene
*/
createSystems?(scene: IScene, context: SystemContext): void;
/**
* 所有系统创建完成后调用
* 用于处理跨插件的系统依赖关系
* Called after all systems are created, used for cross-plugin system dependencies
*/
onSystemsCreated?(scene: IScene, context: SystemContext): void;
/**
* 模块初始化完成回调
* Module initialization complete callback
*/
onInitialize?(): Promise<void>;
/**
* 模块销毁回调
* Module destroy callback
*/
onDestroy?(): void;
}
// ============================================================================
// UI 描述符类型 | UI Descriptor Types
// ============================================================================
/**
* 面板位置
@@ -146,8 +104,8 @@ export interface ToolbarItemDescriptor {
}
/**
* 组件检视器提供者(简化版)
* Component inspector provider (simplified)
* 组件检视器提供者
* Component inspector provider
*/
export interface ComponentInspectorProviderDef {
/** 组件类型名 | Component type name */
@@ -235,6 +193,33 @@ export interface ISerializer<T = any> {
deserialize(data: Uint8Array): T;
}
/**
* 文件创建模板
* File creation template
*/
export interface FileCreationTemplate {
/** 模板ID | Template ID */
id: string;
/** 标签 | Label */
label: string;
/** 扩展名 | Extension */
extension: string;
/** 图标 | Icon */
icon?: string;
/** 分类 | Category */
category?: string;
/**
* 获取文件内容 | Get file content
* @param fileName 文件名(不含路径,含扩展名)
* @returns 文件内容字符串
*/
getContent: (fileName: string) => string | Promise<string>;
}
// ============================================================================
// 编辑器模块接口 | Editor Module Interface
// ============================================================================
/**
* 编辑器模块加载器
* Editor module loader
@@ -327,43 +312,22 @@ export interface IEditorModuleLoader {
setLocale?(locale: string): void;
}
/**
* 统一插件加载器
* Unified plugin loader
*/
export interface IPluginLoader {
/** 插件描述符 | Plugin descriptor */
readonly descriptor: PluginDescriptor;
/** 运行时模块(可选) | Runtime module (optional) */
readonly runtimeModule?: IRuntimeModuleLoader;
/** 编辑器模块(可选) | Editor module (optional) */
readonly editorModule?: IEditorModuleLoader;
}
// ============================================================================
// 类型别名(向后兼容)| Type Aliases (backward compatibility)
// ============================================================================
/**
* 文件创建模板
* File creation template
* IPluginLoader 类型别名
*
* 插件通过 getContent 提供文件内容,编辑器负责写入文件
* 这样可以避免插件直接访问文件系统带来的权限问题。
* @deprecated 使用 IPlugin 代替。IPluginLoader 只是 IPlugin 的别名
* @deprecated Use IPlugin instead. IPluginLoader is just an alias for IPlugin.
*/
export interface FileCreationTemplate {
/** 模板ID | Template ID */
id: string;
/** 标签 | Label */
label: string;
/** 扩展名 | Extension */
extension: string;
/** 图标 | Icon */
icon?: string;
/** 分类 | Category */
category?: string;
/**
* 获取文件内容 | Get file content
* @param fileName 文件名(不含路径,含扩展名)
* @returns 文件内容字符串
*/
getContent: (fileName: string) => string | Promise<string>;
}
export type { IPlugin as IPluginLoader } from './PluginDescriptor';
/**
* IRuntimeModuleLoader 类型别名
*
* @deprecated 使用 IRuntimeModule 代替。
* @deprecated Use IRuntimeModule instead.
*/
export type { IRuntimeModule as IRuntimeModuleLoader } from './PluginDescriptor';

View File

@@ -1,155 +1,23 @@
/**
* 插件系统类型定义
* Plugin system type definitions
* 插件描述符类型
* Plugin descriptor types
*
* 从 @esengine/engine-core 重新导出基础类型,并添加编辑器专用类型。
* Re-export base types from @esengine/engine-core, and add editor-specific types.
*/
/**
* 插件类别
* Plugin category
*/
export type PluginCategory =
| 'core' // 核心功能 | Core functionality
| 'rendering' // 渲染相关 | Rendering
| 'ui' // UI 系统 | UI System
| 'ai' // AI/行为树 | AI/Behavior
| 'physics' // 物理引擎 | Physics
| 'audio' // 音频系统 | Audio
| 'networking' // 网络功能 | Networking
| 'tools' // 工具/编辑器扩展 | Tools/Editor extensions
| 'scripting' // 脚本/蓝图 | Scripting/Blueprint
| 'content'; // 内容/资源 | Content/Assets
/**
* 加载阶段 - 控制插件模块的加载顺序
* Loading phase - controls the loading order of plugin modules
*/
export type LoadingPhase =
| 'earliest' // 最早加载(核心模块) | Earliest (core modules)
| 'preDefault' // 默认之前 | Before default
| 'default' // 默认阶段 | Default phase
| 'postDefault' // 默认之后 | After default
| 'postEngine'; // 引擎初始化后 | After engine init
/**
* 模块类型
* Module type
*/
export type ModuleType = 'runtime' | 'editor';
/**
* 模块描述符 - 描述插件内的一个模块
* Module descriptor - describes a module within a plugin
*/
export interface ModuleDescriptor {
/** 模块名称 | Module name */
name: string;
/** 模块类型 | Module type */
type: ModuleType;
/** 加载阶段 | Loading phase */
loadingPhase?: LoadingPhase;
/** 模块入口文件(相对路径) | Module entry file (relative path) */
entry?: string;
// ===== 运行时模块配置 | Runtime module config =====
/** 导出的组件类名列表 | Exported component class names */
components?: string[];
/** 导出的系统类名列表 | Exported system class names */
systems?: string[];
/** 导出的服务类名列表 | Exported service class names */
services?: string[];
// ===== 编辑器模块配置 | Editor module config =====
/** 注册的面板ID列表 | Registered panel IDs */
panels?: string[];
/** 注册的检视器类型列表 | Registered inspector types */
inspectors?: string[];
/** 注册的 Gizmo 提供者列表 | Registered Gizmo providers */
gizmoProviders?: string[];
/** 注册的编译器列表 | Registered compilers */
compilers?: string[];
/** 注册的文件处理器扩展名 | Registered file handler extensions */
fileHandlers?: string[];
}
/**
* 插件依赖
* Plugin dependency
*/
export interface PluginDependency {
/** 依赖的插件ID | Dependent plugin ID */
id: string;
/** 版本要求semver | Version requirement (semver) */
version?: string;
/** 是否可选 | Optional */
optional?: boolean;
}
/**
* 插件描述符 - 对应 plugin.json 文件
* Plugin descriptor - corresponds to plugin.json
*/
export interface PluginDescriptor {
/** 插件唯一标识符,如 "@esengine/tilemap" | Unique plugin ID */
id: string;
/** 显示名称 | Display name */
name: string;
/** 版本号 | Version */
version: string;
/** 描述 | Description */
description?: string;
/** 作者 | Author */
author?: string;
/** 许可证 | License */
license?: string;
/** 插件类别 | Plugin category */
category: PluginCategory;
/** 标签(用于搜索) | Tags (for search) */
tags?: string[];
/** 图标Lucide 图标名) | Icon (Lucide icon name) */
icon?: string;
/** 是否默认启用 | Enabled by default */
enabledByDefault: boolean;
/** 是否可以包含内容资产 | Can contain content assets */
canContainContent: boolean;
/** 是否为引擎内置插件 | Is engine built-in plugin */
isEnginePlugin: boolean;
/** 是否为核心插件(不可禁用) | Is core plugin (cannot be disabled) */
isCore?: boolean;
/** 模块列表 | Module list */
modules: ModuleDescriptor[];
/** 依赖列表 | Dependency list */
dependencies?: PluginDependency[];
/** 平台要求 | Platform requirements */
platforms?: ('web' | 'desktop' | 'mobile')[];
}
// 从 engine-core 重新导出所有插件相关类型
export type {
PluginCategory,
LoadingPhase,
ModuleType,
ModuleDescriptor,
PluginDependency,
PluginDescriptor,
SystemContext,
IRuntimeModule,
IPlugin
} from '@esengine/engine-core';
/**
* 插件状态

File diff suppressed because it is too large Load Diff