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

@@ -0,0 +1,152 @@
/**
* Platform Adapter Interface
* 平台适配器接口
*
* 定义不同平台(编辑器、浏览器、原生)需要实现的适配器接口
* Defines the adapter interface that different platforms need to implement
*/
/**
* 资源路径解析器
* Asset path resolver
*/
export interface IPathResolver {
/**
* 解析资源路径为可加载的 URL
* Resolve asset path to a loadable URL
*/
resolve(path: string): string;
}
/**
* 平台能力标识
* Platform capability flags
*/
export interface PlatformCapabilities {
/** 是否支持文件系统访问 / Supports file system access */
fileSystem: boolean;
/** 是否支持热重载 / Supports hot reload */
hotReload: boolean;
/** 是否支持 Gizmo 显示 / Supports gizmo display */
gizmos: boolean;
/** 是否支持网格显示 / Supports grid display */
grid: boolean;
/** 是否支持场景编辑 / Supports scene editing */
sceneEditing: boolean;
}
/**
* 平台适配器配置
* Platform adapter configuration
*/
export interface PlatformAdapterConfig {
/** Canvas 元素 ID */
canvasId: string;
/** 初始宽度 */
width?: number;
/** 初始高度 */
height?: number;
/** 是否为编辑器模式 */
isEditor?: boolean;
}
/**
* 平台适配器接口
* Platform adapter interface
*
* 不同平台通过实现此接口来提供平台特定的功能
* Different platforms implement this interface to provide platform-specific functionality
*/
export interface IPlatformAdapter {
/**
* 平台名称
* Platform name
*/
readonly name: string;
/**
* 平台能力
* Platform capabilities
*/
readonly capabilities: PlatformCapabilities;
/**
* 路径解析器
* Path resolver
*/
readonly pathResolver: IPathResolver;
/**
* 初始化平台
* Initialize platform
*/
initialize(config: PlatformAdapterConfig): Promise<void>;
/**
* 获取 WASM 模块
* Get WASM module
*
* 不同平台可能以不同方式加载 WASM
* Different platforms may load WASM in different ways
*/
getWasmModule(): Promise<any>;
/**
* 获取 Canvas 元素
* Get canvas element
*/
getCanvas(): HTMLCanvasElement | null;
/**
* 调整视口大小
* Resize viewport
*/
resize(width: number, height: number): void;
/**
* 获取当前视口尺寸
* Get current viewport size
*/
getViewportSize(): { width: number; height: number };
/**
* 是否为编辑器模式
* Whether in editor mode
*/
isEditorMode(): boolean;
/**
* 设置是否显示网格(仅编辑器模式有效)
* Set whether to show grid (only effective in editor mode)
*/
setShowGrid?(show: boolean): void;
/**
* 设置是否显示 Gizmos仅编辑器模式有效
* Set whether to show gizmos (only effective in editor mode)
*/
setShowGizmos?(show: boolean): void;
/**
* 释放资源
* Dispose resources
*/
dispose(): void;
}
/**
* 默认路径解析器(直接返回路径)
* Default path resolver (returns path as-is)
*/
export class DefaultPathResolver implements IPathResolver {
resolve(path: string): string {
// 如果已经是 URL直接返回
if (path.startsWith('http://') ||
path.startsWith('https://') ||
path.startsWith('data:') ||
path.startsWith('blob:')) {
return path;
}
return path;
}
}