Files
esengine/packages/engine/platform-common/src/IPlatformSubsystems.ts

848 lines
19 KiB
TypeScript
Raw Normal View History

/**
*
*
*/
// ============================================================================
// Canvas/渲染子系统
// ============================================================================
/**
* Canvas
*/
/**
* Canvas Web
*/
export interface CanvasContextAttributes {
alpha?: boolean | number;
antialias?: boolean;
depth?: boolean;
stencil?: boolean;
premultipliedAlpha?: boolean;
preserveDrawingBuffer?: boolean;
failIfMajorPerformanceCaveat?: boolean;
powerPreference?: 'default' | 'high-performance' | 'low-power';
antialiasSamples?: number;
}
export interface IPlatformCanvas {
width: number;
height: number;
getContext(contextType: '2d' | 'webgl' | 'webgl2', contextAttributes?: CanvasContextAttributes): RenderingContext | null;
toDataURL(): string;
toTempFilePath?(options: TempFilePathOptions): void;
}
/**
* Image
*/
export interface IPlatformImage {
src: string;
width: number;
height: number;
onload: (() => void) | null;
onerror: ((error: any) => void) | null;
}
/**
*
*/
export interface TempFilePathOptions {
x?: number;
y?: number;
width?: number;
height?: number;
destWidth?: number;
destHeight?: number;
fileType?: 'png' | 'jpg';
quality?: number;
success?: (res: { tempFilePath: string }) => void;
fail?: (error: any) => void;
complete?: () => void;
}
/**
* Canvas
*/
export interface IPlatformCanvasSubsystem {
/**
* Canvas Canvas
*/
createCanvas(width?: number, height?: number): IPlatformCanvas;
/**
*
*/
createImage(): IPlatformImage;
/**
* ImageData
*/
createImageData?(width: number, height: number): ImageData;
/**
*
*/
getScreenWidth(): number;
/**
*
*/
getScreenHeight(): number;
/**
*
*/
getDevicePixelRatio(): number;
}
// ============================================================================
// 音频子系统
// ============================================================================
/**
*
*/
export interface IPlatformAudioContext {
src: string;
autoplay: boolean;
loop: boolean;
volume: number;
duration: number;
currentTime: number;
paused: boolean;
buffered: number;
play(): void;
pause(): void;
stop(): void;
seek(position: number): void;
destroy(): void;
onPlay(callback: () => void): void;
onPause(callback: () => void): void;
onStop(callback: () => void): void;
onEnded(callback: () => void): void;
onError(callback: (error: { errCode: number; errMsg: string }) => void): void;
onTimeUpdate(callback: () => void): void;
onCanplay(callback: () => void): void;
onSeeking(callback: () => void): void;
onSeeked(callback: () => void): void;
offPlay(callback: () => void): void;
offPause(callback: () => void): void;
offStop(callback: () => void): void;
offEnded(callback: () => void): void;
offError(callback: (error: { errCode: number; errMsg: string }) => void): void;
offTimeUpdate(callback: () => void): void;
}
/**
*
*/
export interface IPlatformAudioSubsystem {
/**
*
*/
createAudioContext(options?: { useWebAudioImplement?: boolean }): IPlatformAudioContext;
/**
*
*/
getSupportedFormats(): string[];
/**
*
*/
setInnerAudioOption?(options: {
mixWithOther?: boolean;
obeyMuteSwitch?: boolean;
speakerOn?: boolean;
}): Promise<void>;
}
// ============================================================================
// 存储子系统
// ============================================================================
/**
*
*/
export interface StorageInfo {
keys: string[];
currentSize: number;
limitSize: number;
}
/**
*
*/
export interface IPlatformStorageSubsystem {
/**
*
*/
getStorageSync<T = any>(key: string): T | undefined;
/**
*
*/
setStorageSync<T = any>(key: string, value: T): void;
/**
*
*/
removeStorageSync(key: string): void;
/**
*
*/
clearStorageSync(): void;
/**
*
*/
getStorageInfoSync(): StorageInfo;
/**
*
*/
getStorage<T = any>(key: string): Promise<T | undefined>;
/**
*
*/
setStorage<T = any>(key: string, value: T): Promise<void>;
/**
*
*/
removeStorage(key: string): Promise<void>;
/**
*
*/
clearStorage(): Promise<void>;
}
// ============================================================================
// 网络子系统
// ============================================================================
/**
*
*/
export interface RequestConfig {
url: string;
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'TRACE' | 'CONNECT';
data?: any;
header?: Record<string, string>;
timeout?: number;
dataType?: 'json' | 'text' | 'arraybuffer';
responseType?: 'text' | 'arraybuffer';
}
/**
*
*/
export interface RequestResponse<T = any> {
data: T;
statusCode: number;
header: Record<string, string>;
}
/**
*
*/
export interface IDownloadTask {
abort(): void;
onProgressUpdate(callback: (res: {
progress: number;
totalBytesWritten: number;
totalBytesExpectedToWrite: number;
}) => void): void;
offProgressUpdate(callback: Function): void;
}
/**
*
*/
export interface IUploadTask {
abort(): void;
onProgressUpdate(callback: (res: {
progress: number;
totalBytesSent: number;
totalBytesExpectedToSend: number;
}) => void): void;
offProgressUpdate(callback: Function): void;
}
/**
* WebSocket
*/
export interface IPlatformWebSocket {
send(data: string | ArrayBuffer): void;
close(code?: number, reason?: string): void;
onOpen(callback: (res: { header: Record<string, string> }) => void): void;
onClose(callback: (res: { code: number; reason: string }) => void): void;
onError(callback: (error: any) => void): void;
onMessage(callback: (res: { data: string | ArrayBuffer }) => void): void;
}
/**
*
*/
export interface IPlatformNetworkSubsystem {
/**
*
*/
request<T = any>(config: RequestConfig): Promise<RequestResponse<T>>;
/**
*
*/
downloadFile(options: {
url: string;
filePath?: string;
header?: Record<string, string>;
timeout?: number;
}): Promise<{ tempFilePath: string; filePath?: string; statusCode: number }> & IDownloadTask;
/**
*
*/
uploadFile(options: {
url: string;
filePath: string;
name: string;
header?: Record<string, string>;
formData?: Record<string, any>;
timeout?: number;
}): Promise<{ data: string; statusCode: number }> & IUploadTask;
/**
* WebSocket
*/
connectSocket(options: {
url: string;
header?: Record<string, string>;
protocols?: string[];
timeout?: number;
}): IPlatformWebSocket;
/**
*
*/
getNetworkType(): Promise<'wifi' | '2g' | '3g' | '4g' | '5g' | 'unknown' | 'none'>;
/**
*
*/
onNetworkStatusChange(callback: (res: {
isConnected: boolean;
networkType: string;
}) => void): void;
/**
*
*/
offNetworkStatusChange(callback: Function): void;
}
// ============================================================================
// 输入子系统
// ============================================================================
/**
*
feat(engine-core): 添加统一输入系统 (#282) * perf(core): 优化 EntitySystem 迭代性能,添加 CommandBuffer 延迟命令 ReactiveQuery 快照优化: - 添加快照机制,避免每帧拷贝数组 - 只在实体列表变化时创建新快照 - 静态场景下多个系统共享同一快照 CommandBuffer 延迟命令系统: - 支持延迟添加/移除组件、销毁实体、设置实体激活状态 - 每个系统拥有独立的 commands 属性 - 命令在帧末统一执行,避免迭代过程中修改实体列表 Scene 更新: - 在 lateUpdate 后自动刷新所有系统的命令缓冲区 文档: - 更新系统文档,添加 CommandBuffer 使用说明 * fix(ci): upgrade first-interaction action to v1.3.0 Fix Docker build failure in welcome workflow. * fix(ci): upgrade pnpm/action-setup to v4 and fix unused import - Upgrade pnpm/action-setup@v2 to v4 in all workflow files - Remove unused CommandType import in CommandBuffer.test.ts * fix(ci): remove duplicate pnpm version specification * feat(engine-core): 添加统一输入系统 添加完整的输入系统,支持平台抽象: - IPlatformInputSubsystem: 扩展接口支持键盘/鼠标/滚轮事件 - WebInputSubsystem: 浏览器实现,支持事件绑定/解绑 - InputManager: 全局输入状态管理器(键盘、鼠标、触摸) - InputSystem: ECS 系统,连接平台事件到 InputManager - GameRuntime 集成: 自动创建 InputSystem 并绑定平台子系统 使用方式: ```typescript import { Input, MouseButton } from '@esengine/engine-core'; if (Input.isKeyDown('KeyW')) { /* 移动 */ } if (Input.isKeyJustPressed('Space')) { /* 跳跃 */ } if (Input.isMouseButtonDown(MouseButton.Left)) { /* 射击 */ } ``` * fix(runtime-core): 添加缺失的 platform-common 依赖 * fix(runtime-core): 移除 platform-web 依赖避免循环依赖 * fix(runtime-core): 使用工厂函数注入 InputSubsystem 避免循环依赖 - BrowserPlatformAdapter 通过 inputSubsystemFactory 配置接收输入子系统 - 在 IPlatformInputSubsystem 接口添加可选的 dispose 方法 - 移除对 @esengine/platform-web 的直接依赖
2025-12-05 18:15:50 +08:00
* Touch point information
*/
export interface TouchInfo {
identifier: number;
x: number;
y: number;
force?: number;
}
/**
*
feat(engine-core): 添加统一输入系统 (#282) * perf(core): 优化 EntitySystem 迭代性能,添加 CommandBuffer 延迟命令 ReactiveQuery 快照优化: - 添加快照机制,避免每帧拷贝数组 - 只在实体列表变化时创建新快照 - 静态场景下多个系统共享同一快照 CommandBuffer 延迟命令系统: - 支持延迟添加/移除组件、销毁实体、设置实体激活状态 - 每个系统拥有独立的 commands 属性 - 命令在帧末统一执行,避免迭代过程中修改实体列表 Scene 更新: - 在 lateUpdate 后自动刷新所有系统的命令缓冲区 文档: - 更新系统文档,添加 CommandBuffer 使用说明 * fix(ci): upgrade first-interaction action to v1.3.0 Fix Docker build failure in welcome workflow. * fix(ci): upgrade pnpm/action-setup to v4 and fix unused import - Upgrade pnpm/action-setup@v2 to v4 in all workflow files - Remove unused CommandType import in CommandBuffer.test.ts * fix(ci): remove duplicate pnpm version specification * feat(engine-core): 添加统一输入系统 添加完整的输入系统,支持平台抽象: - IPlatformInputSubsystem: 扩展接口支持键盘/鼠标/滚轮事件 - WebInputSubsystem: 浏览器实现,支持事件绑定/解绑 - InputManager: 全局输入状态管理器(键盘、鼠标、触摸) - InputSystem: ECS 系统,连接平台事件到 InputManager - GameRuntime 集成: 自动创建 InputSystem 并绑定平台子系统 使用方式: ```typescript import { Input, MouseButton } from '@esengine/engine-core'; if (Input.isKeyDown('KeyW')) { /* 移动 */ } if (Input.isKeyJustPressed('Space')) { /* 跳跃 */ } if (Input.isMouseButtonDown(MouseButton.Left)) { /* 射击 */ } ``` * fix(runtime-core): 添加缺失的 platform-common 依赖 * fix(runtime-core): 移除 platform-web 依赖避免循环依赖 * fix(runtime-core): 使用工厂函数注入 InputSubsystem 避免循环依赖 - BrowserPlatformAdapter 通过 inputSubsystemFactory 配置接收输入子系统 - 在 IPlatformInputSubsystem 接口添加可选的 dispose 方法 - 移除对 @esengine/platform-web 的直接依赖
2025-12-05 18:15:50 +08:00
* Touch event
*/
export interface TouchEvent {
touches: TouchInfo[];
changedTouches: TouchInfo[];
timeStamp: number;
}
/**
*
feat(engine-core): 添加统一输入系统 (#282) * perf(core): 优化 EntitySystem 迭代性能,添加 CommandBuffer 延迟命令 ReactiveQuery 快照优化: - 添加快照机制,避免每帧拷贝数组 - 只在实体列表变化时创建新快照 - 静态场景下多个系统共享同一快照 CommandBuffer 延迟命令系统: - 支持延迟添加/移除组件、销毁实体、设置实体激活状态 - 每个系统拥有独立的 commands 属性 - 命令在帧末统一执行,避免迭代过程中修改实体列表 Scene 更新: - 在 lateUpdate 后自动刷新所有系统的命令缓冲区 文档: - 更新系统文档,添加 CommandBuffer 使用说明 * fix(ci): upgrade first-interaction action to v1.3.0 Fix Docker build failure in welcome workflow. * fix(ci): upgrade pnpm/action-setup to v4 and fix unused import - Upgrade pnpm/action-setup@v2 to v4 in all workflow files - Remove unused CommandType import in CommandBuffer.test.ts * fix(ci): remove duplicate pnpm version specification * feat(engine-core): 添加统一输入系统 添加完整的输入系统,支持平台抽象: - IPlatformInputSubsystem: 扩展接口支持键盘/鼠标/滚轮事件 - WebInputSubsystem: 浏览器实现,支持事件绑定/解绑 - InputManager: 全局输入状态管理器(键盘、鼠标、触摸) - InputSystem: ECS 系统,连接平台事件到 InputManager - GameRuntime 集成: 自动创建 InputSystem 并绑定平台子系统 使用方式: ```typescript import { Input, MouseButton } from '@esengine/engine-core'; if (Input.isKeyDown('KeyW')) { /* 移动 */ } if (Input.isKeyJustPressed('Space')) { /* 跳跃 */ } if (Input.isMouseButtonDown(MouseButton.Left)) { /* 射击 */ } ``` * fix(runtime-core): 添加缺失的 platform-common 依赖 * fix(runtime-core): 移除 platform-web 依赖避免循环依赖 * fix(runtime-core): 使用工厂函数注入 InputSubsystem 避免循环依赖 - BrowserPlatformAdapter 通过 inputSubsystemFactory 配置接收输入子系统 - 在 IPlatformInputSubsystem 接口添加可选的 dispose 方法 - 移除对 @esengine/platform-web 的直接依赖
2025-12-05 18:15:50 +08:00
* Touch event handler
*/
export type TouchHandler = (event: TouchEvent) => void;
feat(engine-core): 添加统一输入系统 (#282) * perf(core): 优化 EntitySystem 迭代性能,添加 CommandBuffer 延迟命令 ReactiveQuery 快照优化: - 添加快照机制,避免每帧拷贝数组 - 只在实体列表变化时创建新快照 - 静态场景下多个系统共享同一快照 CommandBuffer 延迟命令系统: - 支持延迟添加/移除组件、销毁实体、设置实体激活状态 - 每个系统拥有独立的 commands 属性 - 命令在帧末统一执行,避免迭代过程中修改实体列表 Scene 更新: - 在 lateUpdate 后自动刷新所有系统的命令缓冲区 文档: - 更新系统文档,添加 CommandBuffer 使用说明 * fix(ci): upgrade first-interaction action to v1.3.0 Fix Docker build failure in welcome workflow. * fix(ci): upgrade pnpm/action-setup to v4 and fix unused import - Upgrade pnpm/action-setup@v2 to v4 in all workflow files - Remove unused CommandType import in CommandBuffer.test.ts * fix(ci): remove duplicate pnpm version specification * feat(engine-core): 添加统一输入系统 添加完整的输入系统,支持平台抽象: - IPlatformInputSubsystem: 扩展接口支持键盘/鼠标/滚轮事件 - WebInputSubsystem: 浏览器实现,支持事件绑定/解绑 - InputManager: 全局输入状态管理器(键盘、鼠标、触摸) - InputSystem: ECS 系统,连接平台事件到 InputManager - GameRuntime 集成: 自动创建 InputSystem 并绑定平台子系统 使用方式: ```typescript import { Input, MouseButton } from '@esengine/engine-core'; if (Input.isKeyDown('KeyW')) { /* 移动 */ } if (Input.isKeyJustPressed('Space')) { /* 跳跃 */ } if (Input.isMouseButtonDown(MouseButton.Left)) { /* 射击 */ } ``` * fix(runtime-core): 添加缺失的 platform-common 依赖 * fix(runtime-core): 移除 platform-web 依赖避免循环依赖 * fix(runtime-core): 使用工厂函数注入 InputSubsystem 避免循环依赖 - BrowserPlatformAdapter 通过 inputSubsystemFactory 配置接收输入子系统 - 在 IPlatformInputSubsystem 接口添加可选的 dispose 方法 - 移除对 @esengine/platform-web 的直接依赖
2025-12-05 18:15:50 +08:00
/**
*
* Keyboard event information
*/
export interface KeyboardEventInfo {
/** 按键代码 (如 'KeyW', 'Space', 'ArrowUp') | Key code */
code: string;
/** 按键值 (如 'w', ' ', 'ArrowUp') | Key value */
key: string;
/** Alt 键是否按下 | Alt key pressed */
altKey: boolean;
/** Ctrl 键是否按下 | Ctrl key pressed */
ctrlKey: boolean;
/** Shift 键是否按下 | Shift key pressed */
shiftKey: boolean;
/** Meta 键是否按下 (Windows/Command) | Meta key pressed */
metaKey: boolean;
/** 是否重复触发 | Is repeat */
repeat: boolean;
/** 时间戳 | Timestamp */
timeStamp: number;
}
/**
*
* Keyboard event handler
*/
export type KeyboardHandler = (event: KeyboardEventInfo) => void;
/**
*
* Mouse button enum
*/
export enum MouseButton {
/** 左键 | Left button */
Left = 0,
/** 中键 | Middle button */
Middle = 1,
/** 右键 | Right button */
Right = 2
}
/**
*
* Mouse event information
*/
export interface MouseEventInfo {
/** X 坐标 | X coordinate */
x: number;
/** Y 坐标 | Y coordinate */
y: number;
/** 相对上次的 X 偏移 | X movement delta */
movementX: number;
/** 相对上次的 Y 偏移 | Y movement delta */
movementY: number;
/** 按下的按钮 | Button pressed */
button: MouseButton;
/** 所有按下的按钮位掩码 | Buttons bitmask */
buttons: number;
/** Alt 键是否按下 | Alt key pressed */
altKey: boolean;
/** Ctrl 键是否按下 | Ctrl key pressed */
ctrlKey: boolean;
/** Shift 键是否按下 | Shift key pressed */
shiftKey: boolean;
/** Meta 键是否按下 | Meta key pressed */
metaKey: boolean;
/** 时间戳 | Timestamp */
timeStamp: number;
}
/**
*
* Mouse wheel event information
*/
export interface WheelEventInfo {
/** X 坐标 | X coordinate */
x: number;
/** Y 坐标 | Y coordinate */
y: number;
/** X 轴滚动量 | Delta X */
deltaX: number;
/** Y 轴滚动量 | Delta Y */
deltaY: number;
/** Z 轴滚动量 | Delta Z */
deltaZ: number;
/** 时间戳 | Timestamp */
timeStamp: number;
}
/**
*
* Mouse event handler
*/
export type MouseHandler = (event: MouseEventInfo) => void;
/**
*
* Mouse wheel event handler
*/
export type WheelHandler = (event: WheelEventInfo) => void;
/**
*
feat(engine-core): 添加统一输入系统 (#282) * perf(core): 优化 EntitySystem 迭代性能,添加 CommandBuffer 延迟命令 ReactiveQuery 快照优化: - 添加快照机制,避免每帧拷贝数组 - 只在实体列表变化时创建新快照 - 静态场景下多个系统共享同一快照 CommandBuffer 延迟命令系统: - 支持延迟添加/移除组件、销毁实体、设置实体激活状态 - 每个系统拥有独立的 commands 属性 - 命令在帧末统一执行,避免迭代过程中修改实体列表 Scene 更新: - 在 lateUpdate 后自动刷新所有系统的命令缓冲区 文档: - 更新系统文档,添加 CommandBuffer 使用说明 * fix(ci): upgrade first-interaction action to v1.3.0 Fix Docker build failure in welcome workflow. * fix(ci): upgrade pnpm/action-setup to v4 and fix unused import - Upgrade pnpm/action-setup@v2 to v4 in all workflow files - Remove unused CommandType import in CommandBuffer.test.ts * fix(ci): remove duplicate pnpm version specification * feat(engine-core): 添加统一输入系统 添加完整的输入系统,支持平台抽象: - IPlatformInputSubsystem: 扩展接口支持键盘/鼠标/滚轮事件 - WebInputSubsystem: 浏览器实现,支持事件绑定/解绑 - InputManager: 全局输入状态管理器(键盘、鼠标、触摸) - InputSystem: ECS 系统,连接平台事件到 InputManager - GameRuntime 集成: 自动创建 InputSystem 并绑定平台子系统 使用方式: ```typescript import { Input, MouseButton } from '@esengine/engine-core'; if (Input.isKeyDown('KeyW')) { /* 移动 */ } if (Input.isKeyJustPressed('Space')) { /* 跳跃 */ } if (Input.isMouseButtonDown(MouseButton.Left)) { /* 射击 */ } ``` * fix(runtime-core): 添加缺失的 platform-common 依赖 * fix(runtime-core): 移除 platform-web 依赖避免循环依赖 * fix(runtime-core): 使用工厂函数注入 InputSubsystem 避免循环依赖 - BrowserPlatformAdapter 通过 inputSubsystemFactory 配置接收输入子系统 - 在 IPlatformInputSubsystem 接口添加可选的 dispose 方法 - 移除对 @esengine/platform-web 的直接依赖
2025-12-05 18:15:50 +08:00
* Input subsystem interface
*/
export interface IPlatformInputSubsystem {
feat(engine-core): 添加统一输入系统 (#282) * perf(core): 优化 EntitySystem 迭代性能,添加 CommandBuffer 延迟命令 ReactiveQuery 快照优化: - 添加快照机制,避免每帧拷贝数组 - 只在实体列表变化时创建新快照 - 静态场景下多个系统共享同一快照 CommandBuffer 延迟命令系统: - 支持延迟添加/移除组件、销毁实体、设置实体激活状态 - 每个系统拥有独立的 commands 属性 - 命令在帧末统一执行,避免迭代过程中修改实体列表 Scene 更新: - 在 lateUpdate 后自动刷新所有系统的命令缓冲区 文档: - 更新系统文档,添加 CommandBuffer 使用说明 * fix(ci): upgrade first-interaction action to v1.3.0 Fix Docker build failure in welcome workflow. * fix(ci): upgrade pnpm/action-setup to v4 and fix unused import - Upgrade pnpm/action-setup@v2 to v4 in all workflow files - Remove unused CommandType import in CommandBuffer.test.ts * fix(ci): remove duplicate pnpm version specification * feat(engine-core): 添加统一输入系统 添加完整的输入系统,支持平台抽象: - IPlatformInputSubsystem: 扩展接口支持键盘/鼠标/滚轮事件 - WebInputSubsystem: 浏览器实现,支持事件绑定/解绑 - InputManager: 全局输入状态管理器(键盘、鼠标、触摸) - InputSystem: ECS 系统,连接平台事件到 InputManager - GameRuntime 集成: 自动创建 InputSystem 并绑定平台子系统 使用方式: ```typescript import { Input, MouseButton } from '@esengine/engine-core'; if (Input.isKeyDown('KeyW')) { /* 移动 */ } if (Input.isKeyJustPressed('Space')) { /* 跳跃 */ } if (Input.isMouseButtonDown(MouseButton.Left)) { /* 射击 */ } ``` * fix(runtime-core): 添加缺失的 platform-common 依赖 * fix(runtime-core): 移除 platform-web 依赖避免循环依赖 * fix(runtime-core): 使用工厂函数注入 InputSubsystem 避免循环依赖 - BrowserPlatformAdapter 通过 inputSubsystemFactory 配置接收输入子系统 - 在 IPlatformInputSubsystem 接口添加可选的 dispose 方法 - 移除对 @esengine/platform-web 的直接依赖
2025-12-05 18:15:50 +08:00
// ========== 触摸事件 | Touch events ==========
/**
*
feat(engine-core): 添加统一输入系统 (#282) * perf(core): 优化 EntitySystem 迭代性能,添加 CommandBuffer 延迟命令 ReactiveQuery 快照优化: - 添加快照机制,避免每帧拷贝数组 - 只在实体列表变化时创建新快照 - 静态场景下多个系统共享同一快照 CommandBuffer 延迟命令系统: - 支持延迟添加/移除组件、销毁实体、设置实体激活状态 - 每个系统拥有独立的 commands 属性 - 命令在帧末统一执行,避免迭代过程中修改实体列表 Scene 更新: - 在 lateUpdate 后自动刷新所有系统的命令缓冲区 文档: - 更新系统文档,添加 CommandBuffer 使用说明 * fix(ci): upgrade first-interaction action to v1.3.0 Fix Docker build failure in welcome workflow. * fix(ci): upgrade pnpm/action-setup to v4 and fix unused import - Upgrade pnpm/action-setup@v2 to v4 in all workflow files - Remove unused CommandType import in CommandBuffer.test.ts * fix(ci): remove duplicate pnpm version specification * feat(engine-core): 添加统一输入系统 添加完整的输入系统,支持平台抽象: - IPlatformInputSubsystem: 扩展接口支持键盘/鼠标/滚轮事件 - WebInputSubsystem: 浏览器实现,支持事件绑定/解绑 - InputManager: 全局输入状态管理器(键盘、鼠标、触摸) - InputSystem: ECS 系统,连接平台事件到 InputManager - GameRuntime 集成: 自动创建 InputSystem 并绑定平台子系统 使用方式: ```typescript import { Input, MouseButton } from '@esengine/engine-core'; if (Input.isKeyDown('KeyW')) { /* 移动 */ } if (Input.isKeyJustPressed('Space')) { /* 跳跃 */ } if (Input.isMouseButtonDown(MouseButton.Left)) { /* 射击 */ } ``` * fix(runtime-core): 添加缺失的 platform-common 依赖 * fix(runtime-core): 移除 platform-web 依赖避免循环依赖 * fix(runtime-core): 使用工厂函数注入 InputSubsystem 避免循环依赖 - BrowserPlatformAdapter 通过 inputSubsystemFactory 配置接收输入子系统 - 在 IPlatformInputSubsystem 接口添加可选的 dispose 方法 - 移除对 @esengine/platform-web 的直接依赖
2025-12-05 18:15:50 +08:00
* Listen for touch start
*/
onTouchStart(handler: TouchHandler): void;
/**
*
feat(engine-core): 添加统一输入系统 (#282) * perf(core): 优化 EntitySystem 迭代性能,添加 CommandBuffer 延迟命令 ReactiveQuery 快照优化: - 添加快照机制,避免每帧拷贝数组 - 只在实体列表变化时创建新快照 - 静态场景下多个系统共享同一快照 CommandBuffer 延迟命令系统: - 支持延迟添加/移除组件、销毁实体、设置实体激活状态 - 每个系统拥有独立的 commands 属性 - 命令在帧末统一执行,避免迭代过程中修改实体列表 Scene 更新: - 在 lateUpdate 后自动刷新所有系统的命令缓冲区 文档: - 更新系统文档,添加 CommandBuffer 使用说明 * fix(ci): upgrade first-interaction action to v1.3.0 Fix Docker build failure in welcome workflow. * fix(ci): upgrade pnpm/action-setup to v4 and fix unused import - Upgrade pnpm/action-setup@v2 to v4 in all workflow files - Remove unused CommandType import in CommandBuffer.test.ts * fix(ci): remove duplicate pnpm version specification * feat(engine-core): 添加统一输入系统 添加完整的输入系统,支持平台抽象: - IPlatformInputSubsystem: 扩展接口支持键盘/鼠标/滚轮事件 - WebInputSubsystem: 浏览器实现,支持事件绑定/解绑 - InputManager: 全局输入状态管理器(键盘、鼠标、触摸) - InputSystem: ECS 系统,连接平台事件到 InputManager - GameRuntime 集成: 自动创建 InputSystem 并绑定平台子系统 使用方式: ```typescript import { Input, MouseButton } from '@esengine/engine-core'; if (Input.isKeyDown('KeyW')) { /* 移动 */ } if (Input.isKeyJustPressed('Space')) { /* 跳跃 */ } if (Input.isMouseButtonDown(MouseButton.Left)) { /* 射击 */ } ``` * fix(runtime-core): 添加缺失的 platform-common 依赖 * fix(runtime-core): 移除 platform-web 依赖避免循环依赖 * fix(runtime-core): 使用工厂函数注入 InputSubsystem 避免循环依赖 - BrowserPlatformAdapter 通过 inputSubsystemFactory 配置接收输入子系统 - 在 IPlatformInputSubsystem 接口添加可选的 dispose 方法 - 移除对 @esengine/platform-web 的直接依赖
2025-12-05 18:15:50 +08:00
* Listen for touch move
*/
onTouchMove(handler: TouchHandler): void;
/**
*
feat(engine-core): 添加统一输入系统 (#282) * perf(core): 优化 EntitySystem 迭代性能,添加 CommandBuffer 延迟命令 ReactiveQuery 快照优化: - 添加快照机制,避免每帧拷贝数组 - 只在实体列表变化时创建新快照 - 静态场景下多个系统共享同一快照 CommandBuffer 延迟命令系统: - 支持延迟添加/移除组件、销毁实体、设置实体激活状态 - 每个系统拥有独立的 commands 属性 - 命令在帧末统一执行,避免迭代过程中修改实体列表 Scene 更新: - 在 lateUpdate 后自动刷新所有系统的命令缓冲区 文档: - 更新系统文档,添加 CommandBuffer 使用说明 * fix(ci): upgrade first-interaction action to v1.3.0 Fix Docker build failure in welcome workflow. * fix(ci): upgrade pnpm/action-setup to v4 and fix unused import - Upgrade pnpm/action-setup@v2 to v4 in all workflow files - Remove unused CommandType import in CommandBuffer.test.ts * fix(ci): remove duplicate pnpm version specification * feat(engine-core): 添加统一输入系统 添加完整的输入系统,支持平台抽象: - IPlatformInputSubsystem: 扩展接口支持键盘/鼠标/滚轮事件 - WebInputSubsystem: 浏览器实现,支持事件绑定/解绑 - InputManager: 全局输入状态管理器(键盘、鼠标、触摸) - InputSystem: ECS 系统,连接平台事件到 InputManager - GameRuntime 集成: 自动创建 InputSystem 并绑定平台子系统 使用方式: ```typescript import { Input, MouseButton } from '@esengine/engine-core'; if (Input.isKeyDown('KeyW')) { /* 移动 */ } if (Input.isKeyJustPressed('Space')) { /* 跳跃 */ } if (Input.isMouseButtonDown(MouseButton.Left)) { /* 射击 */ } ``` * fix(runtime-core): 添加缺失的 platform-common 依赖 * fix(runtime-core): 移除 platform-web 依赖避免循环依赖 * fix(runtime-core): 使用工厂函数注入 InputSubsystem 避免循环依赖 - BrowserPlatformAdapter 通过 inputSubsystemFactory 配置接收输入子系统 - 在 IPlatformInputSubsystem 接口添加可选的 dispose 方法 - 移除对 @esengine/platform-web 的直接依赖
2025-12-05 18:15:50 +08:00
* Listen for touch end
*/
onTouchEnd(handler: TouchHandler): void;
/**
*
feat(engine-core): 添加统一输入系统 (#282) * perf(core): 优化 EntitySystem 迭代性能,添加 CommandBuffer 延迟命令 ReactiveQuery 快照优化: - 添加快照机制,避免每帧拷贝数组 - 只在实体列表变化时创建新快照 - 静态场景下多个系统共享同一快照 CommandBuffer 延迟命令系统: - 支持延迟添加/移除组件、销毁实体、设置实体激活状态 - 每个系统拥有独立的 commands 属性 - 命令在帧末统一执行,避免迭代过程中修改实体列表 Scene 更新: - 在 lateUpdate 后自动刷新所有系统的命令缓冲区 文档: - 更新系统文档,添加 CommandBuffer 使用说明 * fix(ci): upgrade first-interaction action to v1.3.0 Fix Docker build failure in welcome workflow. * fix(ci): upgrade pnpm/action-setup to v4 and fix unused import - Upgrade pnpm/action-setup@v2 to v4 in all workflow files - Remove unused CommandType import in CommandBuffer.test.ts * fix(ci): remove duplicate pnpm version specification * feat(engine-core): 添加统一输入系统 添加完整的输入系统,支持平台抽象: - IPlatformInputSubsystem: 扩展接口支持键盘/鼠标/滚轮事件 - WebInputSubsystem: 浏览器实现,支持事件绑定/解绑 - InputManager: 全局输入状态管理器(键盘、鼠标、触摸) - InputSystem: ECS 系统,连接平台事件到 InputManager - GameRuntime 集成: 自动创建 InputSystem 并绑定平台子系统 使用方式: ```typescript import { Input, MouseButton } from '@esengine/engine-core'; if (Input.isKeyDown('KeyW')) { /* 移动 */ } if (Input.isKeyJustPressed('Space')) { /* 跳跃 */ } if (Input.isMouseButtonDown(MouseButton.Left)) { /* 射击 */ } ``` * fix(runtime-core): 添加缺失的 platform-common 依赖 * fix(runtime-core): 移除 platform-web 依赖避免循环依赖 * fix(runtime-core): 使用工厂函数注入 InputSubsystem 避免循环依赖 - BrowserPlatformAdapter 通过 inputSubsystemFactory 配置接收输入子系统 - 在 IPlatformInputSubsystem 接口添加可选的 dispose 方法 - 移除对 @esengine/platform-web 的直接依赖
2025-12-05 18:15:50 +08:00
* Listen for touch cancel
*/
onTouchCancel(handler: TouchHandler): void;
/**
*
feat(engine-core): 添加统一输入系统 (#282) * perf(core): 优化 EntitySystem 迭代性能,添加 CommandBuffer 延迟命令 ReactiveQuery 快照优化: - 添加快照机制,避免每帧拷贝数组 - 只在实体列表变化时创建新快照 - 静态场景下多个系统共享同一快照 CommandBuffer 延迟命令系统: - 支持延迟添加/移除组件、销毁实体、设置实体激活状态 - 每个系统拥有独立的 commands 属性 - 命令在帧末统一执行,避免迭代过程中修改实体列表 Scene 更新: - 在 lateUpdate 后自动刷新所有系统的命令缓冲区 文档: - 更新系统文档,添加 CommandBuffer 使用说明 * fix(ci): upgrade first-interaction action to v1.3.0 Fix Docker build failure in welcome workflow. * fix(ci): upgrade pnpm/action-setup to v4 and fix unused import - Upgrade pnpm/action-setup@v2 to v4 in all workflow files - Remove unused CommandType import in CommandBuffer.test.ts * fix(ci): remove duplicate pnpm version specification * feat(engine-core): 添加统一输入系统 添加完整的输入系统,支持平台抽象: - IPlatformInputSubsystem: 扩展接口支持键盘/鼠标/滚轮事件 - WebInputSubsystem: 浏览器实现,支持事件绑定/解绑 - InputManager: 全局输入状态管理器(键盘、鼠标、触摸) - InputSystem: ECS 系统,连接平台事件到 InputManager - GameRuntime 集成: 自动创建 InputSystem 并绑定平台子系统 使用方式: ```typescript import { Input, MouseButton } from '@esengine/engine-core'; if (Input.isKeyDown('KeyW')) { /* 移动 */ } if (Input.isKeyJustPressed('Space')) { /* 跳跃 */ } if (Input.isMouseButtonDown(MouseButton.Left)) { /* 射击 */ } ``` * fix(runtime-core): 添加缺失的 platform-common 依赖 * fix(runtime-core): 移除 platform-web 依赖避免循环依赖 * fix(runtime-core): 使用工厂函数注入 InputSubsystem 避免循环依赖 - BrowserPlatformAdapter 通过 inputSubsystemFactory 配置接收输入子系统 - 在 IPlatformInputSubsystem 接口添加可选的 dispose 方法 - 移除对 @esengine/platform-web 的直接依赖
2025-12-05 18:15:50 +08:00
* Stop listening for touch start
*/
offTouchStart(handler: TouchHandler): void;
/**
*
feat(engine-core): 添加统一输入系统 (#282) * perf(core): 优化 EntitySystem 迭代性能,添加 CommandBuffer 延迟命令 ReactiveQuery 快照优化: - 添加快照机制,避免每帧拷贝数组 - 只在实体列表变化时创建新快照 - 静态场景下多个系统共享同一快照 CommandBuffer 延迟命令系统: - 支持延迟添加/移除组件、销毁实体、设置实体激活状态 - 每个系统拥有独立的 commands 属性 - 命令在帧末统一执行,避免迭代过程中修改实体列表 Scene 更新: - 在 lateUpdate 后自动刷新所有系统的命令缓冲区 文档: - 更新系统文档,添加 CommandBuffer 使用说明 * fix(ci): upgrade first-interaction action to v1.3.0 Fix Docker build failure in welcome workflow. * fix(ci): upgrade pnpm/action-setup to v4 and fix unused import - Upgrade pnpm/action-setup@v2 to v4 in all workflow files - Remove unused CommandType import in CommandBuffer.test.ts * fix(ci): remove duplicate pnpm version specification * feat(engine-core): 添加统一输入系统 添加完整的输入系统,支持平台抽象: - IPlatformInputSubsystem: 扩展接口支持键盘/鼠标/滚轮事件 - WebInputSubsystem: 浏览器实现,支持事件绑定/解绑 - InputManager: 全局输入状态管理器(键盘、鼠标、触摸) - InputSystem: ECS 系统,连接平台事件到 InputManager - GameRuntime 集成: 自动创建 InputSystem 并绑定平台子系统 使用方式: ```typescript import { Input, MouseButton } from '@esengine/engine-core'; if (Input.isKeyDown('KeyW')) { /* 移动 */ } if (Input.isKeyJustPressed('Space')) { /* 跳跃 */ } if (Input.isMouseButtonDown(MouseButton.Left)) { /* 射击 */ } ``` * fix(runtime-core): 添加缺失的 platform-common 依赖 * fix(runtime-core): 移除 platform-web 依赖避免循环依赖 * fix(runtime-core): 使用工厂函数注入 InputSubsystem 避免循环依赖 - BrowserPlatformAdapter 通过 inputSubsystemFactory 配置接收输入子系统 - 在 IPlatformInputSubsystem 接口添加可选的 dispose 方法 - 移除对 @esengine/platform-web 的直接依赖
2025-12-05 18:15:50 +08:00
* Stop listening for touch move
*/
offTouchMove(handler: TouchHandler): void;
/**
*
feat(engine-core): 添加统一输入系统 (#282) * perf(core): 优化 EntitySystem 迭代性能,添加 CommandBuffer 延迟命令 ReactiveQuery 快照优化: - 添加快照机制,避免每帧拷贝数组 - 只在实体列表变化时创建新快照 - 静态场景下多个系统共享同一快照 CommandBuffer 延迟命令系统: - 支持延迟添加/移除组件、销毁实体、设置实体激活状态 - 每个系统拥有独立的 commands 属性 - 命令在帧末统一执行,避免迭代过程中修改实体列表 Scene 更新: - 在 lateUpdate 后自动刷新所有系统的命令缓冲区 文档: - 更新系统文档,添加 CommandBuffer 使用说明 * fix(ci): upgrade first-interaction action to v1.3.0 Fix Docker build failure in welcome workflow. * fix(ci): upgrade pnpm/action-setup to v4 and fix unused import - Upgrade pnpm/action-setup@v2 to v4 in all workflow files - Remove unused CommandType import in CommandBuffer.test.ts * fix(ci): remove duplicate pnpm version specification * feat(engine-core): 添加统一输入系统 添加完整的输入系统,支持平台抽象: - IPlatformInputSubsystem: 扩展接口支持键盘/鼠标/滚轮事件 - WebInputSubsystem: 浏览器实现,支持事件绑定/解绑 - InputManager: 全局输入状态管理器(键盘、鼠标、触摸) - InputSystem: ECS 系统,连接平台事件到 InputManager - GameRuntime 集成: 自动创建 InputSystem 并绑定平台子系统 使用方式: ```typescript import { Input, MouseButton } from '@esengine/engine-core'; if (Input.isKeyDown('KeyW')) { /* 移动 */ } if (Input.isKeyJustPressed('Space')) { /* 跳跃 */ } if (Input.isMouseButtonDown(MouseButton.Left)) { /* 射击 */ } ``` * fix(runtime-core): 添加缺失的 platform-common 依赖 * fix(runtime-core): 移除 platform-web 依赖避免循环依赖 * fix(runtime-core): 使用工厂函数注入 InputSubsystem 避免循环依赖 - BrowserPlatformAdapter 通过 inputSubsystemFactory 配置接收输入子系统 - 在 IPlatformInputSubsystem 接口添加可选的 dispose 方法 - 移除对 @esengine/platform-web 的直接依赖
2025-12-05 18:15:50 +08:00
* Stop listening for touch end
*/
offTouchEnd(handler: TouchHandler): void;
/**
*
feat(engine-core): 添加统一输入系统 (#282) * perf(core): 优化 EntitySystem 迭代性能,添加 CommandBuffer 延迟命令 ReactiveQuery 快照优化: - 添加快照机制,避免每帧拷贝数组 - 只在实体列表变化时创建新快照 - 静态场景下多个系统共享同一快照 CommandBuffer 延迟命令系统: - 支持延迟添加/移除组件、销毁实体、设置实体激活状态 - 每个系统拥有独立的 commands 属性 - 命令在帧末统一执行,避免迭代过程中修改实体列表 Scene 更新: - 在 lateUpdate 后自动刷新所有系统的命令缓冲区 文档: - 更新系统文档,添加 CommandBuffer 使用说明 * fix(ci): upgrade first-interaction action to v1.3.0 Fix Docker build failure in welcome workflow. * fix(ci): upgrade pnpm/action-setup to v4 and fix unused import - Upgrade pnpm/action-setup@v2 to v4 in all workflow files - Remove unused CommandType import in CommandBuffer.test.ts * fix(ci): remove duplicate pnpm version specification * feat(engine-core): 添加统一输入系统 添加完整的输入系统,支持平台抽象: - IPlatformInputSubsystem: 扩展接口支持键盘/鼠标/滚轮事件 - WebInputSubsystem: 浏览器实现,支持事件绑定/解绑 - InputManager: 全局输入状态管理器(键盘、鼠标、触摸) - InputSystem: ECS 系统,连接平台事件到 InputManager - GameRuntime 集成: 自动创建 InputSystem 并绑定平台子系统 使用方式: ```typescript import { Input, MouseButton } from '@esengine/engine-core'; if (Input.isKeyDown('KeyW')) { /* 移动 */ } if (Input.isKeyJustPressed('Space')) { /* 跳跃 */ } if (Input.isMouseButtonDown(MouseButton.Left)) { /* 射击 */ } ``` * fix(runtime-core): 添加缺失的 platform-common 依赖 * fix(runtime-core): 移除 platform-web 依赖避免循环依赖 * fix(runtime-core): 使用工厂函数注入 InputSubsystem 避免循环依赖 - BrowserPlatformAdapter 通过 inputSubsystemFactory 配置接收输入子系统 - 在 IPlatformInputSubsystem 接口添加可选的 dispose 方法 - 移除对 @esengine/platform-web 的直接依赖
2025-12-05 18:15:50 +08:00
* Stop listening for touch cancel
*/
offTouchCancel(handler: TouchHandler): void;
/**
*
feat(engine-core): 添加统一输入系统 (#282) * perf(core): 优化 EntitySystem 迭代性能,添加 CommandBuffer 延迟命令 ReactiveQuery 快照优化: - 添加快照机制,避免每帧拷贝数组 - 只在实体列表变化时创建新快照 - 静态场景下多个系统共享同一快照 CommandBuffer 延迟命令系统: - 支持延迟添加/移除组件、销毁实体、设置实体激活状态 - 每个系统拥有独立的 commands 属性 - 命令在帧末统一执行,避免迭代过程中修改实体列表 Scene 更新: - 在 lateUpdate 后自动刷新所有系统的命令缓冲区 文档: - 更新系统文档,添加 CommandBuffer 使用说明 * fix(ci): upgrade first-interaction action to v1.3.0 Fix Docker build failure in welcome workflow. * fix(ci): upgrade pnpm/action-setup to v4 and fix unused import - Upgrade pnpm/action-setup@v2 to v4 in all workflow files - Remove unused CommandType import in CommandBuffer.test.ts * fix(ci): remove duplicate pnpm version specification * feat(engine-core): 添加统一输入系统 添加完整的输入系统,支持平台抽象: - IPlatformInputSubsystem: 扩展接口支持键盘/鼠标/滚轮事件 - WebInputSubsystem: 浏览器实现,支持事件绑定/解绑 - InputManager: 全局输入状态管理器(键盘、鼠标、触摸) - InputSystem: ECS 系统,连接平台事件到 InputManager - GameRuntime 集成: 自动创建 InputSystem 并绑定平台子系统 使用方式: ```typescript import { Input, MouseButton } from '@esengine/engine-core'; if (Input.isKeyDown('KeyW')) { /* 移动 */ } if (Input.isKeyJustPressed('Space')) { /* 跳跃 */ } if (Input.isMouseButtonDown(MouseButton.Left)) { /* 射击 */ } ``` * fix(runtime-core): 添加缺失的 platform-common 依赖 * fix(runtime-core): 移除 platform-web 依赖避免循环依赖 * fix(runtime-core): 使用工厂函数注入 InputSubsystem 避免循环依赖 - BrowserPlatformAdapter 通过 inputSubsystemFactory 配置接收输入子系统 - 在 IPlatformInputSubsystem 接口添加可选的 dispose 方法 - 移除对 @esengine/platform-web 的直接依赖
2025-12-05 18:15:50 +08:00
* Check if touch supports pressure
*/
supportsPressure?(): boolean;
feat(engine-core): 添加统一输入系统 (#282) * perf(core): 优化 EntitySystem 迭代性能,添加 CommandBuffer 延迟命令 ReactiveQuery 快照优化: - 添加快照机制,避免每帧拷贝数组 - 只在实体列表变化时创建新快照 - 静态场景下多个系统共享同一快照 CommandBuffer 延迟命令系统: - 支持延迟添加/移除组件、销毁实体、设置实体激活状态 - 每个系统拥有独立的 commands 属性 - 命令在帧末统一执行,避免迭代过程中修改实体列表 Scene 更新: - 在 lateUpdate 后自动刷新所有系统的命令缓冲区 文档: - 更新系统文档,添加 CommandBuffer 使用说明 * fix(ci): upgrade first-interaction action to v1.3.0 Fix Docker build failure in welcome workflow. * fix(ci): upgrade pnpm/action-setup to v4 and fix unused import - Upgrade pnpm/action-setup@v2 to v4 in all workflow files - Remove unused CommandType import in CommandBuffer.test.ts * fix(ci): remove duplicate pnpm version specification * feat(engine-core): 添加统一输入系统 添加完整的输入系统,支持平台抽象: - IPlatformInputSubsystem: 扩展接口支持键盘/鼠标/滚轮事件 - WebInputSubsystem: 浏览器实现,支持事件绑定/解绑 - InputManager: 全局输入状态管理器(键盘、鼠标、触摸) - InputSystem: ECS 系统,连接平台事件到 InputManager - GameRuntime 集成: 自动创建 InputSystem 并绑定平台子系统 使用方式: ```typescript import { Input, MouseButton } from '@esengine/engine-core'; if (Input.isKeyDown('KeyW')) { /* 移动 */ } if (Input.isKeyJustPressed('Space')) { /* 跳跃 */ } if (Input.isMouseButtonDown(MouseButton.Left)) { /* 射击 */ } ``` * fix(runtime-core): 添加缺失的 platform-common 依赖 * fix(runtime-core): 移除 platform-web 依赖避免循环依赖 * fix(runtime-core): 使用工厂函数注入 InputSubsystem 避免循环依赖 - BrowserPlatformAdapter 通过 inputSubsystemFactory 配置接收输入子系统 - 在 IPlatformInputSubsystem 接口添加可选的 dispose 方法 - 移除对 @esengine/platform-web 的直接依赖
2025-12-05 18:15:50 +08:00
// ========== 键盘事件 | Keyboard events ==========
/**
*
* Listen for key down
*/
onKeyDown?(handler: KeyboardHandler): void;
/**
*
* Listen for key up
*/
onKeyUp?(handler: KeyboardHandler): void;
/**
*
* Stop listening for key down
*/
offKeyDown?(handler: KeyboardHandler): void;
/**
*
* Stop listening for key up
*/
offKeyUp?(handler: KeyboardHandler): void;
// ========== 鼠标事件 | Mouse events ==========
/**
*
* Listen for mouse move
*/
onMouseMove?(handler: MouseHandler): void;
/**
*
* Listen for mouse down
*/
onMouseDown?(handler: MouseHandler): void;
/**
*
* Listen for mouse up
*/
onMouseUp?(handler: MouseHandler): void;
/**
*
* Listen for mouse wheel
*/
onWheel?(handler: WheelHandler): void;
/**
*
* Stop listening for mouse move
*/
offMouseMove?(handler: MouseHandler): void;
/**
*
* Stop listening for mouse down
*/
offMouseDown?(handler: MouseHandler): void;
/**
*
* Stop listening for mouse up
*/
offMouseUp?(handler: MouseHandler): void;
/**
*
* Stop listening for mouse wheel
*/
offWheel?(handler: WheelHandler): void;
// ========== 输入能力查询 | Input capability queries ==========
/**
*
* Check if keyboard input is supported
*/
supportsKeyboard?(): boolean;
/**
*
* Check if mouse input is supported
*/
supportsMouse?(): boolean;
// ========== 生命周期 | Lifecycle ==========
/**
*
* Dispose resources
*/
dispose?(): void;
}
// ============================================================================
// 文件系统子系统
// ============================================================================
/**
*
*/
export interface FileInfo {
size: number;
createTime: number;
modifyTime?: number;
isDirectory: boolean;
isFile: boolean;
}
/**
*
*/
export interface IPlatformFileSubsystem {
/**
*
*/
readFile(options: {
filePath: string;
encoding?: 'ascii' | 'base64' | 'binary' | 'hex' | 'ucs2' | 'utf-8' | 'utf8';
position?: number;
length?: number;
}): Promise<string | ArrayBuffer>;
/**
*
*/
readFileSync(
filePath: string,
encoding?: 'ascii' | 'base64' | 'binary' | 'hex' | 'ucs2' | 'utf-8' | 'utf8',
position?: number,
length?: number
): string | ArrayBuffer;
/**
*
*/
writeFile(options: {
filePath: string;
data: string | ArrayBuffer;
encoding?: 'ascii' | 'base64' | 'binary' | 'hex' | 'ucs2' | 'utf-8' | 'utf8';
}): Promise<void>;
/**
*
*/
writeFileSync(
filePath: string,
data: string | ArrayBuffer,
encoding?: 'ascii' | 'base64' | 'binary' | 'hex' | 'ucs2' | 'utf-8' | 'utf8'
): void;
/**
*
*/
appendFile(options: {
filePath: string;
data: string | ArrayBuffer;
encoding?: 'ascii' | 'base64' | 'binary' | 'hex' | 'ucs2' | 'utf-8' | 'utf8';
}): Promise<void>;
/**
*
*/
unlink(filePath: string): Promise<void>;
/**
*
*/
mkdir(options: {
dirPath: string;
recursive?: boolean;
}): Promise<void>;
/**
*
*/
rmdir(options: {
dirPath: string;
recursive?: boolean;
}): Promise<void>;
/**
*
*/
readdir(dirPath: string): Promise<string[]>;
/**
*
*/
stat(path: string): Promise<FileInfo>;
/**
* /
*/
access(path: string): Promise<void>;
/**
*
*/
rename(oldPath: string, newPath: string): Promise<void>;
/**
*
*/
copyFile(srcPath: string, destPath: string): Promise<void>;
/**
*
*/
getUserDataPath(): string;
/**
*
*/
unzip?(options: {
zipFilePath: string;
targetPath: string;
}): Promise<void>;
}
// ============================================================================
// WASM 子系统
// ============================================================================
/**
* WASM
*/
export type WASMExports = Record<string, WebAssembly.ExportValue>;
/**
* WASM Web
*/
export type WASMImportValue = WebAssembly.ExportValue | number;
/**
* WASM
*/
export type WASMImports = Record<string, Record<string, WASMImportValue>>;
/**
* WASM
*/
export interface IWASMInstance {
exports: WASMExports;
}
/**
* WASM
*/
export interface IPlatformWASMSubsystem {
/**
* WASM
* @param path WASM
* @param imports
*/
instantiate(path: string, imports?: WASMImports): Promise<IWASMInstance>;
/**
* WASM
*/
isSupported(): boolean;
}
// ============================================================================
// 系统信息
// ============================================================================
/**
*
*/
export interface SystemInfo {
/** 设备品牌 */
brand: string;
/** 设备型号 */
model: string;
/** 设备像素比 */
pixelRatio: number;
/** 屏幕宽度 */
screenWidth: number;
/** 屏幕高度 */
screenHeight: number;
/** 可使用窗口宽度 */
windowWidth: number;
/** 可使用窗口高度 */
windowHeight: number;
/** 状态栏高度 */
statusBarHeight: number;
/** 操作系统及版本 */
system: string;
/** 客户端平台 */
platform: 'ios' | 'android' | 'windows' | 'mac' | 'devtools';
/** 客户端基础库版本 */
SDKVersion: string;
/** 设备性能等级 */
benchmarkLevel: number;
/** 设备内存大小 (MB) */
memorySize?: number;
}