Files
esengine/packages/editor-core/src/Plugin/IPluginLoader.ts
YHH 63f006ab62 feat: 添加跨平台运行时、资产系统和UI适配功能 (#256)
* feat(platform-common): 添加WASM加载器和环境检测API

* feat(rapier2d): 新增Rapier2D WASM绑定包

* feat(physics-rapier2d): 添加跨平台WASM加载器

* feat(asset-system): 添加运行时资产目录和bundle格式

* feat(asset-system-editor): 新增编辑器资产管理包

* feat(editor-core): 添加构建系统和模块管理

* feat(editor-app): 重构浏览器预览使用import maps

* feat(platform-web): 添加BrowserRuntime和资产读取

* feat(engine): 添加材质系统和着色器管理

* feat(material): 新增材质系统和着色器编辑器

* feat(tilemap): 增强tilemap编辑器和动画系统

* feat(modules): 添加module.json配置

* feat(core): 添加module.json和类型定义更新

* chore: 更新依赖和构建配置

* refactor(plugins): 更新插件模板使用ModuleManifest

* chore: 添加第三方依赖库

* chore: 移除BehaviourTree-ai和ecs-astar子模块

* docs: 更新README和文档主题样式

* fix: 修复Rust文档测试和添加rapier2d WASM绑定

* fix(tilemap-editor): 修复画布高DPI屏幕分辨率适配问题

* feat(ui): 添加UI屏幕适配系统(CanvasScaler/SafeArea)

* fix(ecs-engine-bindgen): 添加缺失的ecs-framework-math依赖

* fix: 添加缺失的包依赖修复CI构建

* fix: 修复CodeQL检测到的代码问题

* fix: 修复构建错误和缺失依赖

* fix: 修复类型检查错误

* fix(material-system): 修复tsconfig配置支持TypeScript项目引用

* fix(editor-core): 修复Rollup构建配置添加tauri external

* fix: 修复CodeQL检测到的代码问题

* fix: 修复CodeQL检测到的代码问题
2025-12-03 22:15:22 +08:00

333 lines
8.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 编辑器模块接口
* Editor module interfaces
*
* 定义编辑器专用的模块接口和 UI 描述符类型。
* Define editor-specific module interfaces and UI descriptor types.
*/
import type { ServiceContainer } from '@esengine/ecs-framework';
// 从 PluginDescriptor 重新导出(来源于 engine-core
export type {
LoadingPhase,
SystemContext,
IRuntimeModule,
IPlugin,
ModuleManifest,
ModuleCategory,
ModulePlatform,
ModuleExports
} from './PluginDescriptor';
// ============================================================================
// UI 描述符类型 | UI Descriptor Types
// ============================================================================
/**
* 面板位置
* Panel position
*/
export enum PanelPosition {
Left = 'left',
Right = 'right',
Bottom = 'bottom',
Center = 'center'
}
/**
* 面板描述符
* Panel descriptor
*/
export interface PanelDescriptor {
/** 面板ID | Panel ID */
id: string;
/** 面板标题 | Panel title */
title: string;
/** 面板图标 | Panel icon */
icon?: string;
/** 面板位置 | Panel position */
position: PanelPosition;
/** 渲染组件 | Render component */
component?: any;
/** 渲染函数 | Render function */
render?: () => any;
/** 默认大小 | Default size */
defaultSize?: number;
/** 是否可调整大小 | Is resizable */
resizable?: boolean;
/** 是否可关闭 | Is closable */
closable?: boolean;
/** 排序权重 | Order weight */
order?: number;
/** 是否为动态面板 | Is dynamic panel */
isDynamic?: boolean;
}
/**
* 菜单项描述符
* Menu item descriptor
*/
export interface MenuItemDescriptor {
/** 菜单ID | Menu ID */
id: string;
/** 菜单标签 | Menu label */
label: string;
/** 父菜单ID | Parent menu ID */
parentId?: string;
/** 图标 | Icon */
icon?: string;
/** 快捷键 | Shortcut */
shortcut?: string;
/** 执行函数 | Execute function */
execute?: () => void;
/** 子菜单 | Submenu items */
children?: MenuItemDescriptor[];
}
/**
* 工具栏项描述符
* Toolbar item descriptor
*/
export interface ToolbarItemDescriptor {
/** 工具栏项ID | Toolbar item ID */
id: string;
/** 标签 | Label */
label: string;
/** 图标 | Icon */
icon: string;
/** 提示 | Tooltip */
tooltip?: string;
/** 执行函数 | Execute function */
execute: () => void;
}
/**
* 组件检视器提供者
* Component inspector provider
*/
export interface ComponentInspectorProviderDef {
/** 组件类型名 | Component type name */
componentType: string;
/** 优先级 | Priority */
priority?: number;
/** 渲染函数 | Render function */
render: (component: any, entity: any, onChange: (key: string, value: any) => void) => any;
}
/**
* Gizmo 提供者注册
* Gizmo provider registration
*/
export interface GizmoProviderRegistration {
/** 组件类型 | Component type */
componentType: any;
/** 获取 Gizmo 数据 | Get gizmo data */
getGizmoData: (component: any, entity: any, isSelected: boolean) => any[];
}
/**
* 文件操作处理器
* File action handler
*/
export interface FileActionHandler {
/** 支持的文件扩展名 | Supported file extensions */
extensions: string[];
/** 双击处理 | Double click handler */
onDoubleClick?: (filePath: string) => void | Promise<void>;
/** 打开处理 | Open handler */
onOpen?: (filePath: string) => void | Promise<void>;
/** 获取上下文菜单 | Get context menu */
getContextMenuItems?: (filePath: string, parentPath: string) => any[];
}
/**
* 实体创建模板
* Entity creation template
*/
export interface EntityCreationTemplate {
/** 模板ID | Template ID */
id: string;
/** 标签 | Label */
label: string;
/** 图标组件 | Icon component */
icon?: any;
/** 分类 | Category */
category?: string;
/** 排序权重 | Order weight */
order?: number;
/** 创建函数 | Create function */
create: (parentEntityId?: number) => number | Promise<number>;
}
/**
* 组件操作
* Component action
*/
export interface ComponentAction {
/** 操作ID | Action ID */
id: string;
/** 组件名 | Component name */
componentName: string;
/** 标签 | Label */
label: string;
/** 图标 | Icon */
icon?: any;
/** 排序权重 | Order weight */
order?: number;
/** 执行函数 | Execute function */
execute: (component: any, entity: any) => void | Promise<void>;
}
/**
* 序列化器接口
* Serializer interface
*/
export interface ISerializer<T = any> {
/** 获取支持的类型 | Get supported type */
getSupportedType(): string;
/** 序列化数据 | Serialize data */
serialize(data: T): Uint8Array;
/** 反序列化数据 | Deserialize data */
deserialize(data: Uint8Array): T;
}
/**
* 文件创建模板
* File creation template
*/
export interface FileCreationTemplate {
/** 模板ID | Template ID */
id: string;
/** 标签 | Label */
label: string;
/** 扩展名 | Extension */
extension: string;
/** 图标 | Icon */
icon?: string;
/** 分类 | Category */
category?: string;
/**
* 获取文件内容 | Get file content
* @param fileName 文件名(不含路径,含扩展名)
* @returns 文件内容字符串
*/
getContent: (fileName: string) => string | Promise<string>;
}
// ============================================================================
// 编辑器模块接口 | Editor Module Interface
// ============================================================================
/**
* 编辑器模块加载器
* Editor module loader
*/
export interface IEditorModuleLoader {
/**
* 安装编辑器模块
* Install editor module
*/
install(services: ServiceContainer): Promise<void>;
/**
* 卸载编辑器模块
* Uninstall editor module
*/
uninstall?(): Promise<void>;
/**
* 返回面板描述列表
* Get panel descriptors
*/
getPanels?(): PanelDescriptor[];
/**
* 返回菜单项列表
* Get menu items
*/
getMenuItems?(): MenuItemDescriptor[];
/**
* 返回工具栏项列表
* Get toolbar items
*/
getToolbarItems?(): ToolbarItemDescriptor[];
/**
* 返回检视器提供者列表
* Get inspector providers
*/
getInspectorProviders?(): ComponentInspectorProviderDef[];
/**
* 返回 Gizmo 提供者列表
* Get gizmo providers
*/
getGizmoProviders?(): GizmoProviderRegistration[];
/**
* 返回文件操作处理器列表
* Get file action handlers
*/
getFileActionHandlers?(): FileActionHandler[];
/**
* 返回实体创建模板列表
* Get entity creation templates
*/
getEntityCreationTemplates?(): EntityCreationTemplate[];
/**
* 返回组件操作列表
* Get component actions
*/
getComponentActions?(): ComponentAction[];
/**
* 返回文件创建模板列表
* Get file creation templates
*/
getFileCreationTemplates?(): FileCreationTemplate[];
// ===== 生命周期钩子 | Lifecycle hooks =====
/** 编辑器就绪 | Editor ready */
onEditorReady?(): void | Promise<void>;
/** 项目打开 | Project open */
onProjectOpen?(projectPath: string): void | Promise<void>;
/** 项目关闭 | Project close */
onProjectClose?(): void | Promise<void>;
/** 场景加载 | Scene loaded */
onSceneLoaded?(scenePath: string): void;
/** 场景保存前 | Before scene save */
onSceneSaving?(scenePath: string): boolean | void;
/** 设置语言 | Set locale */
setLocale?(locale: string): void;
}
// ============================================================================
// 类型别名(向后兼容)| Type Aliases (backward compatibility)
// ============================================================================
/**
* IPluginLoader 类型别名
*
* @deprecated 使用 IPlugin 代替。IPluginLoader 只是 IPlugin 的别名。
* @deprecated Use IPlugin instead. IPluginLoader is just an alias for IPlugin.
*/
export type { IPlugin as IPluginLoader } from './PluginDescriptor';
/**
* IRuntimeModuleLoader 类型别名
*
* @deprecated 使用 IRuntimeModule 代替。
* @deprecated Use IRuntimeModule instead.
*/
export type { IRuntimeModule as IRuntimeModuleLoader } from './PluginDescriptor';