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

@@ -8,7 +8,8 @@
import { Entity, Component } from '@esengine/ecs-framework';
import { MessageHub, EntityStoreService } from '@esengine/editor-core';
import { TransformComponent, SpriteComponent, SpriteAnimatorComponent } from '@esengine/ecs-components';
import { TransformComponent } from '@esengine/engine-core';
import { SpriteComponent, SpriteAnimatorComponent } from '@esengine/sprite';
import { EngineService } from './EngineService';
export class EditorEngineSync {

File diff suppressed because it is too large Load Diff

View File

@@ -18,7 +18,10 @@ import { EntityStoreService, MessageHub } from '@esengine/editor-core';
import * as editorRuntime from '@esengine/editor-runtime';
import * as ecsFramework from '@esengine/ecs-framework';
import * as behaviorTree from '@esengine/behavior-tree';
import * as ecsComponents from '@esengine/ecs-components';
import * as engineCore from '@esengine/engine-core';
import * as sprite from '@esengine/sprite';
import * as camera from '@esengine/camera';
import * as audio from '@esengine/audio';
// 存储服务实例引用(在初始化时设置)
let entityStoreInstance: EntityStoreService | null = null;
@@ -29,7 +32,10 @@ const SDK_MODULES = {
'@esengine/editor-runtime': editorRuntime,
'@esengine/ecs-framework': ecsFramework,
'@esengine/behavior-tree': behaviorTree,
'@esengine/ecs-components': ecsComponents,
'@esengine/engine-core': engineCore,
'@esengine/sprite': sprite,
'@esengine/camera': camera,
'@esengine/audio': audio,
} as const;
// 全局变量名称映射(用于插件构建配置)
@@ -37,7 +43,10 @@ export const SDK_GLOBALS = {
'@esengine/editor-runtime': '__ESENGINE__.editorRuntime',
'@esengine/ecs-framework': '__ESENGINE__.ecsFramework',
'@esengine/behavior-tree': '__ESENGINE__.behaviorTree',
'@esengine/ecs-components': '__ESENGINE__.ecsComponents',
'@esengine/engine-core': '__ESENGINE__.engineCore',
'@esengine/sprite': '__ESENGINE__.sprite',
'@esengine/camera': '__ESENGINE__.camera',
'@esengine/audio': '__ESENGINE__.audio',
} as const;
/**
@@ -62,7 +71,10 @@ interface ESEngineGlobal {
editorRuntime: typeof editorRuntime;
ecsFramework: typeof ecsFramework;
behaviorTree: typeof behaviorTree;
ecsComponents: typeof ecsComponents;
engineCore: typeof engineCore;
sprite: typeof sprite;
camera: typeof camera;
audio: typeof audio;
require: (moduleName: string) => any;
api: IPluginAPI;
}
@@ -117,7 +129,10 @@ export class PluginSDKRegistry {
editorRuntime,
ecsFramework,
behaviorTree,
ecsComponents,
engineCore,
sprite,
camera,
audio,
require: this.requireModule.bind(this),
api: pluginAPI,
};

View File

@@ -70,7 +70,7 @@ type AdvancedProfilerDataListener = (data: AdvancedProfilerDataPayload) => void;
export class ProfilerService {
private ws: WebSocket | null = null;
private isServerRunning = false;
private wsPort: string;
private wsPort: number;
private listeners: Set<ProfilerDataListener> = new Set();
private advancedListeners: Set<AdvancedProfilerDataListener> = new Set();
private currentData: ProfilerData | null = null;
@@ -82,7 +82,7 @@ export class ProfilerService {
constructor() {
const settings = SettingsService.getInstance();
this.wsPort = settings.get('profiler.port', '8080');
this.wsPort = settings.get('profiler.port', 8080);
this.autoStart = settings.get('profiler.autoStart', true);
this.startServerCheck();
@@ -97,8 +97,9 @@ export class ProfilerService {
private listenToSettingsChanges(): void {
window.addEventListener('settings:changed', ((event: CustomEvent) => {
const newPort = event.detail['profiler.port'];
if (newPort && newPort !== this.wsPort) {
this.wsPort = newPort;
if (newPort !== undefined && Number(newPort) !== this.wsPort) {
console.log(`[ProfilerService] Port changed from ${this.wsPort} to ${newPort}`);
this.wsPort = Number(newPort);
this.reconnectWithNewPort();
}
}) as EventListener);
@@ -247,8 +248,8 @@ export class ProfilerService {
private async startServer(): Promise<void> {
try {
const port = parseInt(this.wsPort);
await invoke<string>('start_profiler_server', { port });
console.log(`[ProfilerService] Starting server on port ${this.wsPort}`);
await invoke<string>('start_profiler_server', { port: this.wsPort });
this.isServerRunning = true;
} catch (error) {
// Ignore "already running" error - it's expected in some cases
@@ -300,7 +301,7 @@ export class ProfilerService {
try {
const message = JSON.parse(event.data);
if (message.type === 'debug_data' && message.data) {
this.handleDebugData(message.data);
this.handleDebugData(message.data, message.advancedProfiler);
} else if (message.type === 'get_raw_entity_list_response' && message.data) {
this.handleRawEntityListResponse(message.data);
} else if (message.type === 'get_entity_details_response' && message.data) {
@@ -338,7 +339,7 @@ export class ProfilerService {
}
}
private handleDebugData(debugData: any): void {
private handleDebugData(debugData: any, advancedProfiler?: any): void {
const performance = debugData.performance;
if (!performance) return;
@@ -380,18 +381,25 @@ export class ProfilerService {
this.notifyListeners(this.currentData);
// 通知高级监听器原始数据
this.lastRawData = {
performance: debugData.performance,
systems: {
systemsInfo: systems.map(sys => ({
name: sys.name,
executionTime: sys.executionTime,
entityCount: sys.entityCount,
averageTime: sys.averageTime
}))
}
};
// 如果有高级性能数据,优先使用它
if (advancedProfiler) {
this.lastRawData = {
advancedProfiler
};
} else {
// 否则使用传统数据
this.lastRawData = {
performance: debugData.performance,
systems: {
systemsInfo: systems.map(sys => ({
name: sys.name,
executionTime: sys.executionTime,
entityCount: sys.entityCount,
averageTime: sys.averageTime
}))
}
};
}
this.notifyAdvancedListeners(this.lastRawData);
// 请求完整的实体列表