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

@@ -6,7 +6,7 @@ import type { IFileAPI } from '../Types/IFileAPI';
const logger = createLogger('ProjectService');
export type ProjectType = 'cocos' | 'laya' | 'unknown';
export type ProjectType = 'esengine' | 'unknown';
export interface ProjectInfo {
path: string;
@@ -15,6 +15,17 @@ export interface ProjectInfo {
configPath?: string;
}
/**
* UI 设计分辨率配置
* UI Design Resolution Configuration
*/
export interface UIDesignResolution {
/** 设计宽度 / Design width */
width: number;
/** 设计高度 / Design height */
height: number;
}
export interface ProjectConfig {
projectType?: ProjectType;
componentsPath?: string;
@@ -22,6 +33,8 @@ export interface ProjectConfig {
buildOutput?: string;
scenesPath?: string;
defaultScene?: string;
/** UI 设计分辨率 / UI design resolution */
uiDesignResolution?: UIDesignResolution;
}
@Injectable()
@@ -47,11 +60,11 @@ export class ProjectService implements IService {
}
const config: ProjectConfig = {
projectType: 'cocos',
projectType: 'esengine',
componentsPath: 'components',
componentPattern: '**/*.ts',
buildOutput: 'temp/editor-components',
scenesPath: 'ecs-scenes',
scenesPath: 'scenes',
defaultScene: 'main.ecs'
};
@@ -176,7 +189,7 @@ export class ProjectService implements IService {
try {
projectInfo.configPath = configPath;
projectInfo.type = 'cocos';
projectInfo.type = 'esengine';
} catch (error) {
logger.warn('No ecs-editor.config.json found, using defaults');
}
@@ -185,14 +198,86 @@ export class ProjectService implements IService {
}
private async loadConfig(configPath: string): Promise<ProjectConfig> {
return {
projectType: 'cocos',
componentsPath: '',
componentPattern: '**/*.ts',
buildOutput: 'temp/editor-components',
scenesPath: 'ecs-scenes',
defaultScene: 'main.ecs'
try {
const content = await this.fileAPI.readFileContent(configPath);
const config = JSON.parse(content) as ProjectConfig;
return {
projectType: config.projectType || 'esengine',
componentsPath: config.componentsPath || '',
componentPattern: config.componentPattern || '**/*.ts',
buildOutput: config.buildOutput || 'temp/editor-components',
scenesPath: config.scenesPath || 'scenes',
defaultScene: config.defaultScene || 'main.ecs',
uiDesignResolution: config.uiDesignResolution
};
} catch (error) {
logger.warn('Failed to load config, using defaults', error);
return {
projectType: 'esengine',
componentsPath: '',
componentPattern: '**/*.ts',
buildOutput: 'temp/editor-components',
scenesPath: 'scenes',
defaultScene: 'main.ecs'
};
}
}
/**
* 保存项目配置
*/
public async saveConfig(): Promise<void> {
if (!this.currentProject?.configPath || !this.projectConfig) {
logger.warn('No project or config to save');
return;
}
try {
const content = JSON.stringify(this.projectConfig, null, 2);
await this.fileAPI.writeFileContent(this.currentProject.configPath, content);
logger.info('Project config saved');
} catch (error) {
logger.error('Failed to save project config', error);
throw error;
}
}
/**
* 更新项目配置
*/
public async updateConfig(updates: Partial<ProjectConfig>): Promise<void> {
if (!this.projectConfig) {
logger.warn('No project config to update');
return;
}
this.projectConfig = {
...this.projectConfig,
...updates
};
await this.saveConfig();
await this.messageHub.publish('project:configUpdated', { config: this.projectConfig });
}
/**
* 获取 UI 设计分辨率
* Get UI design resolution
*
* @returns UI design resolution, defaults to 1920x1080 if not set
*/
public getUIDesignResolution(): UIDesignResolution {
return this.projectConfig?.uiDesignResolution || { width: 1920, height: 1080 };
}
/**
* 设置 UI 设计分辨率
* Set UI design resolution
*
* @param resolution - The new design resolution
*/
public async setUIDesignResolution(resolution: UIDesignResolution): Promise<void> {
await this.updateConfig({ uiDesignResolution: resolution });
}
public dispose(): void {