Feature/runtime cdn and plugin loader (#240)

* feat(ui): 完善 UI 布局系统和编辑器可视化工具

* refactor: 移除 ModuleRegistry,统一使用 PluginManager 插件系统

* fix: 修复 CodeQL 警告并提升测试覆盖率

* refactor: 分离运行时入口点,解决 runtime bundle 包含 React 的问题

* fix(ci): 添加 editor-core 和 editor-runtime 到 CI 依赖构建步骤

* docs: 完善 ServiceContainer 文档,新增 Symbol.for 模式和 @InjectProperty 说明

* fix(ci): 修复 type-check 失败问题

* fix(ci): 修复类型检查失败问题

* fix(ci): 修复类型检查失败问题

* fix(ci): behavior-tree 构建添加 @tauri-apps 外部依赖

* fix(ci): behavior-tree 添加 @tauri-apps/plugin-fs 类型依赖

* fix(ci): platform-web 添加缺失的 behavior-tree 依赖

* fix(lint): 移除正则表达式中不必要的转义字符
This commit is contained in:
YHH
2025-11-27 20:42:46 +08:00
committed by GitHub
parent 71869b1a58
commit 107439d70c
367 changed files with 10661 additions and 12473 deletions

View File

@@ -12,10 +12,12 @@
"types": "./src/index.ts",
"import": "./src/index.ts"
}
}
},
"./plugin.json": "./plugin.json"
},
"files": [
"bin/**/*"
"bin/**/*",
"plugin.json"
],
"keywords": [
"ecs",

View File

@@ -0,0 +1,20 @@
{
"id": "@esengine/ecs-components",
"name": "Core Components",
"version": "1.0.0",
"description": "Transform, Sprite, Camera 等核心组件",
"category": "core",
"loadingPhase": "preDefault",
"enabledByDefault": true,
"canContainContent": false,
"isEnginePlugin": true,
"modules": [
{
"name": "CoreRuntime",
"type": "runtime",
"entry": "./src/index.ts"
}
],
"dependencies": [],
"icon": "Settings"
}

View File

@@ -0,0 +1,130 @@
/**
* Core Components Plugin
* 核心组件插件
*
* 提供基础的 Transform、Sprite、Camera 等核心组件
* 这是一个核心插件,不可禁用
*/
import type { ComponentRegistry as ComponentRegistryType, IScene, ServiceContainer } from '@esengine/ecs-framework';
// Components
import { TransformComponent } from './TransformComponent';
import { SpriteComponent } from './SpriteComponent';
import { SpriteAnimatorComponent } from './SpriteAnimatorComponent';
import { CameraComponent } from './CameraComponent';
// Systems
import { SpriteAnimatorSystem } from './systems/SpriteAnimatorSystem';
/**
* 系统创建上下文
*/
export interface SystemContext {
isEditor: boolean;
engineBridge?: any;
renderSystem?: any;
[key: string]: any;
}
/**
* 插件描述符类型
*/
export interface PluginDescriptor {
id: string;
name: string;
version: string;
description?: string;
category?: string;
loadingPhase?: string;
enabledByDefault?: boolean;
canContainContent?: boolean;
isEnginePlugin?: boolean;
modules?: Array<{
name: string;
type: string;
entry: string;
}>;
dependencies?: Array<{
id: string;
version?: string;
}>;
icon?: string;
}
/**
* 运行时模块加载器接口
*/
export interface IRuntimeModuleLoader {
registerComponents(registry: typeof ComponentRegistryType): void;
registerServices?(services: ServiceContainer): void;
createSystems?(scene: IScene, context: SystemContext): void;
onInitialize?(): Promise<void>;
onDestroy?(): void;
}
/**
* 插件加载器接口
*/
export interface IPluginLoader {
readonly descriptor: PluginDescriptor;
readonly runtimeModule?: IRuntimeModuleLoader;
readonly editorModule?: any;
}
/**
* 核心组件运行时模块
*/
export class CoreRuntimeModule implements IRuntimeModuleLoader {
registerComponents(registry: typeof ComponentRegistryType): void {
registry.register(TransformComponent);
registry.register(SpriteComponent);
registry.register(SpriteAnimatorComponent);
registry.register(CameraComponent);
}
createSystems(scene: IScene, context: SystemContext): void {
const animatorSystem = new SpriteAnimatorSystem();
if (context.isEditor) {
animatorSystem.enabled = false;
}
scene.addSystem(animatorSystem);
context.animatorSystem = animatorSystem;
}
}
/**
* 插件描述符
*/
const descriptor: PluginDescriptor = {
id: '@esengine/ecs-components',
name: 'Core Components',
version: '1.0.0',
description: 'Transform, Sprite, Camera 等核心组件',
category: 'core',
loadingPhase: 'preDefault',
enabledByDefault: true,
canContainContent: false,
isEnginePlugin: true,
modules: [
{
name: 'CoreRuntime',
type: 'runtime',
entry: './src/index.ts'
}
],
icon: 'Settings'
};
/**
* 核心组件插件
*/
export const CorePlugin: IPluginLoader = {
descriptor,
runtimeModule: new CoreRuntimeModule(),
};
export default CorePlugin;

View File

@@ -16,4 +16,8 @@ export { BoxColliderComponent } from './BoxColliderComponent';
export { CircleColliderComponent } from './CircleColliderComponent';
// 音频
export { AudioSourceComponent } from './AudioSourceComponent';
export { AudioSourceComponent } from './AudioSourceComponent';
// Plugin (unified plugin system)
export { CorePlugin, CoreRuntimeModule } from './CorePlugin';
export type { SystemContext, PluginDescriptor, IRuntimeModuleLoader, IPluginLoader } from './CorePlugin';

View File

@@ -35,7 +35,8 @@
"resolveJsonModule": true
},
"include": [
"src/**/*"
"src/**/*",
"plugin.json"
],
"exclude": [
"node_modules",