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

@@ -1,90 +0,0 @@
import { singleton, invoke, type IService } from '@esengine/editor-runtime';
/**
* 文件系统服务
* 封装所有文件读写操作,使用通用后端命令
*/
@singleton()
export class FileSystemService implements IService {
/**
* 读取行为树文件
*/
async readBehaviorTreeFile(filePath: string): Promise<string> {
try {
return await invoke<string>('read_file_content', { path: filePath });
} catch (error) {
throw new Error(`Failed to read file ${filePath}: ${error}`);
}
}
/**
* 写入行为树文件
*/
async writeBehaviorTreeFile(filePath: string, content: string): Promise<void> {
try {
await invoke('write_file_content', { path: filePath, content });
} catch (error) {
throw new Error(`Failed to write file ${filePath}: ${error}`);
}
}
/**
* 读取全局黑板配置
* 业务逻辑在前端,后端只提供通用文件操作
*/
async readGlobalBlackboard(projectPath: string): Promise<string> {
try {
const configPath = `${projectPath}/.ecs/global-blackboard.json`;
const exists = await invoke<boolean>('path_exists', { path: configPath });
if (!exists) {
return JSON.stringify({ version: '1.0', variables: [] });
}
return await invoke<string>('read_file_content', { path: configPath });
} catch (error) {
throw new Error(`Failed to read global blackboard: ${error}`);
}
}
/**
* 写入全局黑板配置
* 业务逻辑在前端,后端只提供通用文件操作
*/
async writeGlobalBlackboard(projectPath: string, content: string): Promise<void> {
try {
const ecsDir = `${projectPath}/.ecs`;
const configPath = `${ecsDir}/global-blackboard.json`;
// 创建 .ecs 目录(如果不存在)
const dirExists = await invoke<boolean>('path_exists', { path: ecsDir });
if (!dirExists) {
await invoke('create_directory', { path: ecsDir });
}
await invoke('write_file_content', { path: configPath, content });
} catch (error) {
throw new Error(`Failed to write global blackboard: ${error}`);
}
}
async writeTextFile(filePath: string, content: string): Promise<void> {
try {
await invoke('write_file_content', { path: filePath, content });
} catch (error) {
throw new Error(`Failed to write text file ${filePath}: ${error}`);
}
}
async writeBinaryFile(filePath: string, data: Uint8Array): Promise<void> {
try {
await invoke('write_binary_file', { filePath, content: Array.from(data) });
} catch (error) {
throw new Error(`Failed to write binary file ${filePath}: ${error}`);
}
}
dispose(): void {
// 文件系统服务无需清理资源
}
}