2025-11-21 10:03:18 +08:00
|
|
|
/**
|
2025-12-01 22:28:51 +08:00
|
|
|
* @esengine/platform-web
|
|
|
|
|
*
|
2025-12-03 16:20:01 +08:00
|
|
|
* Web/H5 Platform Adapter
|
|
|
|
|
* Web/H5 平台适配器
|
|
|
|
|
*
|
|
|
|
|
* Provides browser-specific implementations:
|
|
|
|
|
* - BrowserRuntime: Main entry point for game builds
|
|
|
|
|
* - BrowserAssetReader: Asset loading via fetch API
|
|
|
|
|
* - Web subsystems: Canvas, Input, Storage, WASM
|
2025-12-01 22:28:51 +08:00
|
|
|
*
|
2025-11-21 10:03:18 +08:00
|
|
|
* @packageDocumentation
|
|
|
|
|
*/
|
|
|
|
|
|
2025-12-03 16:20:01 +08:00
|
|
|
// ============================================
|
|
|
|
|
// Runtime (main entry for game builds)
|
|
|
|
|
// ============================================
|
|
|
|
|
export {
|
|
|
|
|
BrowserRuntime,
|
|
|
|
|
create,
|
|
|
|
|
type RuntimeConfig
|
|
|
|
|
} from './BrowserRuntime';
|
|
|
|
|
|
|
|
|
|
// Default export for convenient usage in game builds
|
|
|
|
|
export { default } from './BrowserRuntime';
|
|
|
|
|
|
|
|
|
|
// Asset reader
|
|
|
|
|
export { BrowserAssetReader } from './BrowserAssetReader';
|
|
|
|
|
|
|
|
|
|
// ============================================
|
|
|
|
|
// Web Platform Subsystems
|
|
|
|
|
// ============================================
|
2025-11-21 10:03:18 +08:00
|
|
|
export { WebCanvasSubsystem } from './subsystems/WebCanvasSubsystem';
|
|
|
|
|
export { WebInputSubsystem } from './subsystems/WebInputSubsystem';
|
|
|
|
|
export { WebStorageSubsystem } from './subsystems/WebStorageSubsystem';
|
|
|
|
|
export { WebWASMSubsystem } from './subsystems/WebWASMSubsystem';
|
|
|
|
|
|
2025-12-03 16:20:01 +08:00
|
|
|
// ============================================
|
|
|
|
|
// Web-specific Systems
|
|
|
|
|
// ============================================
|
2025-12-01 22:28:51 +08:00
|
|
|
export { Canvas2DRenderSystem } from './systems/Canvas2DRenderSystem';
|
2025-11-27 20:42:46 +08:00
|
|
|
|
2025-12-03 16:20:01 +08:00
|
|
|
// ============================================
|
|
|
|
|
// Platform Detection Utilities
|
|
|
|
|
// ============================================
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check if running in web browser
|
|
|
|
|
* 检查是否在浏览器中运行
|
|
|
|
|
*/
|
2025-11-21 10:03:18 +08:00
|
|
|
export function isWebPlatform(): boolean {
|
|
|
|
|
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
|
|
|
}
|
2025-12-01 22:28:51 +08:00
|
|
|
|
2025-12-03 16:20:01 +08:00
|
|
|
/**
|
|
|
|
|
* Get canvas element by ID
|
|
|
|
|
* 根据 ID 获取 canvas 元素
|
|
|
|
|
*/
|
2025-12-01 22:28:51 +08:00
|
|
|
export function getWebCanvas(canvasId: string): HTMLCanvasElement | null {
|
|
|
|
|
return document.getElementById(canvasId) as HTMLCanvasElement | null;
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-03 16:20:01 +08:00
|
|
|
/**
|
|
|
|
|
* Create a new canvas element
|
|
|
|
|
* 创建新的 canvas 元素
|
|
|
|
|
*/
|
2025-12-01 22:28:51 +08:00
|
|
|
export function createWebCanvas(width: number, height: number): HTMLCanvasElement {
|
|
|
|
|
const canvas = document.createElement('canvas');
|
|
|
|
|
canvas.width = width;
|
|
|
|
|
canvas.height = height;
|
|
|
|
|
return canvas;
|
|
|
|
|
}
|