Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat: Add TypeScript SDK with WASM bridge

esengineba79ee3bac86
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ffe350ef3..9d8d4a491 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -84,25 +84,12 @@ target_include_directories(esengine
target_link_libraries(esengine PUBLIC glm)
-# Emscripten-specific settings
+# Emscripten-specific settings (link flags are in cmake/Emscripten.cmake)
if(ES_BUILD_WEB OR ES_BUILD_WXGAME)
target_compile_definitions(esengine PUBLIC ES_PLATFORM_WEB)
-
- set(EMSCRIPTEN_LINK_FLAGS
- -sUSE_WEBGL2=1
- -sFULL_ES3=1
- -sALLOW_MEMORY_GROWTH=1
- "-sEXPORTED_FUNCTIONS=['_main','_es_init','_es_update','_es_render','_es_on_touch']"
- "-sEXPORTED_RUNTIME_METHODS=['ccall','cwrap']"
- )
-
if(ES_BUILD_WXGAME)
target_compile_definitions(esengine PUBLIC ES_PLATFORM_WXGAME)
- list(APPEND EMSCRIPTEN_LINK_FLAGS -sENVIRONMENT=web)
endif()
-
- string(REPLACE ";" " " EMSCRIPTEN_LINK_FLAGS_STR "${EMSCRIPTEN_LINK_FLAGS}")
- set_target_properties(esengine PROPERTIES LINK_FLAGS "${EMSCRIPTEN_LINK_FLAGS_STR}")
endif()
# Compiler warnings
diff --git a/cmake/Emscripten.cmake b/cmake/Emscripten.cmake
index 4c6600170..aca696b34 100644
--- a/cmake/Emscripten.cmake
+++ b/cmake/Emscripten.cmake
@@ -23,6 +23,9 @@ set(ES_EMSCRIPTEN_LINK_FLAGS
-sALLOW_MEMORY_GROWTH=1
-sNO_EXIT_RUNTIME=1
-sASSERTIONS=1
+ # EMSCRIPTEN_KEEPALIVE functions are auto-exported, only need to add stdlib functions
+ "-sEXPORTED_FUNCTIONS=['_malloc','_free']"
+ "-sEXPORTED_RUNTIME_METHODS=['ccall','cwrap','HEAPF32','HEAPU8','HEAPU32']"
)
# Debug-specific flags
diff --git a/sdk/.gitignore b/sdk/.gitignore
new file mode 100644
index 000000000..008f9b555
--- /dev/null
+++ b/sdk/.gitignore
@@ -0,0 +1,23 @@
+# Dependencies
+node_modules/
+
+# Build output
+dist/
+
+# TypeScript compiled files in src (should not exist)
+src/**/*.js
+src/**/*.js.map
+src/**/*.d.ts
+
+# Example build outputs (keep esengine.js and wasm for demo)
+examples/**/*.js
+!examples/**/rollup.config.js
+examples/**/*.js.map
+
+# IDE
+.vscode/
+.idea/
+
+# OS
+.DS_Store
+Thumbs.db
diff --git a/sdk/examples/hello-game/index.html b/sdk/examples/hello-game/index.html
new file mode 100644
index 000000000..90a728478
--- /dev/null
+++ b/sdk/examples/hello-game/index.html
@@ -0,0 +1,69 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
+ <title>Hello ESEngine</title>
+ <style>
+ * {
+ margin: 0;
+ padding: 0;
+ box-sizing: border-box;
+ }
+
+ html, body {
+ width: 100%;
+ height: 100%;
+ overflow: hidden;
+ background: #1a1a2e;
+ }
+
+ body {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
+ }
+
+ h1 {
+ color: #e94560;
+ margin-bottom: 20px;
+ font-size: 24px;
+ }
+
+ #game-canvas {
+ border: 2px solid #e94560;
+ border-radius: 4px;
+ background: #16213e;
+ touch-action: none;
+ }
+
+ .instructions {
+ color: #a8a8a8;
+ margin-top: 20px;
+ font-size: 14px;
+ text-align: center;
+ }
+
+ .instructions kbd {
+ background: #2a2a4e;
+ padding: 2px 8px;
+ border-radius: 4px;
+ color: #e94560;
+ }
+ </style>
+</head>
+<body>
+ <h1>ESEngine TypeScript SDK Demo</h1>
+ <canvas id="canvas" width="800" height="600"></canvas>
+ <div class="instructions">
+ <p>Use <kbd>W</kbd><kbd>A</kbd><kbd>S</kbd><kbd>D</kbd> or <kbd>↑</kbd><kbd>←</kbd><kbd>↓</kbd><kbd>→</kbd> to move</p>
+ <p>Touch/click to move towards that position</p>
+ <p>Press <kbd>ESC</kbd> to quit</p>
+ </div>
+
+ <!-- For development, use the bundled SDK -->
+ <script type="module" src="./index.js"></script>
+</body>
+</html>
diff --git a/sdk/examples/hello-game/index.ts b/sdk/examples/hello-game/index.ts
new file mode 100644
index 000000000..3e13d8d32
--- /dev/null
+++ b/sdk/examples/hello-game/index.ts
@@ -0,0 +1,218 @@
+/**
+ * ESEngine SDK - Hello Game Example
+ *
+ * A simple example demonstrating the TypeScript SDK usage.
+ */
+
+import {
+ Application,
+ Registry,
+ Transform,
+ Sprite,
+ Velocity,
+ TransformType,
+ SpriteType,
+ VelocityType,
+ createTransform,
+ createSprite,
+ createVelocity,
+ Renderer,
+ Input,
+ KeyCode,
+ TouchType,
+ TouchPoint,
+ color,
+ vec2,
+} from '../../src/index';
+
+/**
+ * A simple game with a moving player square.
+ */
+class HelloGame extends Application {
+ private player: number = 0;
+ private speed: number = 200;
+
+ protected onInit(): void {
+ console.log('HelloGame initialized!');
+
+ const registry = this.getRegistry();
+
+ // Create player entity
+ this.player = registry.create();
+
+ // Add Transform component
+ registry.emplace(
+ this.player,
+ TransformType,
+ createTransform({ x: this.getWidth() / 2, y: this.getHeight() / 2 })
+ );
+
+ // Add Sprite component
+ registry.emplace(
+ this.player,
+ SpriteType,
+ createSprite(0, { color: { r: 1, g: 0.3, b: 0.3, a: 1 }, size: { x: 50, y: 50 } })
+ );
+
+ // Add Velocity component
+ registry.emplace(this.player, VelocityType, createVelocity());
+
+ // Create some background entities
+ for (let i = 0; i < 5; i++) {
+ const entity = registry.create();
+ registry.emplace(
+ entity,
+ TransformType,
+ createTransform({
+ x: Math.random() * this.getWidth(),
+ y: Math.random() * this.getHeight(),
+ })
+ );
+ registry.emplace(
+ entity,
+ SpriteType,
+ createSprite(0, {
+ color: {
+ r: Math.random() * 0.5 + 0.5,
+ g: Math.random() * 0.5 + 0.5,
+ b: Math.random() * 0.5 + 0.5,
+ a: 0.8,
+ },
+ size: { x: 30 + Math.random() * 20, y: 30 + Math.random() * 20 },
+ })
+ );
+ }
+
+ // Set clear color
+ Renderer.setClearColor(color(0.1, 0.1, 0.15, 1));
+ }
+
+ protected onUpdate(dt: number): void {
+ const registry = this.getRegistry();
+
+ // Handle input
+ const velocity = registry.get<Velocity>(this.player, VelocityType);
+
+ // Reset velocity
+ velocity.linear.x = 0;
+ velocity.linear.y = 0;
+
+ // Keyboard input
+ if (Input.isKeyDown(KeyCode.W) || Input.isKeyDown(KeyCode.Up)) {
+ velocity.linear.y = -this.speed;
+ }
+ if (Input.isKeyDown(KeyCode.S) || Input.isKeyDown(KeyCode.Down)) {
+ velocity.linear.y = this.speed;
+ }
+ if (Input.isKeyDown(KeyCode.A) || Input.isKeyDown(KeyCode.Left)) {
+ velocity.linear.x = -this.speed;
+ }
+ if (Input.isKeyDown(KeyCode.D) || Input.isKeyDown(KeyCode.Right)) {
+ velocity.linear.x = this.speed;
+ }
+
+ // Touch input - move towards touch position
+ if (Input.isTouchDown()) {
+ const touchPos = Input.getTouchPosition();
+ const transform = registry.get<Transform>(this.player, TransformType);
+
+ const dx = touchPos.x - transform.position.x;
+ const dy = touchPos.y - transform.position.y;
+ const dist = Math.sqrt(dx * dx + dy * dy);
+
+ if (dist > 10) {
+ velocity.linear.x = (dx / dist) * this.speed;
+ velocity.linear.y = (dy / dist) * this.speed;
+ }
+ }
+
+ // Quit on Escape
+ if (Input.isKeyPressed(KeyCode.Escape)) {
+ this.quit();
+ }
+
+ // Update positions based on velocity
+ registry.view2<Transform, Velocity>(TransformType, VelocityType).each(
+ (entity, transform, vel) => {
+ transform.position.x += vel.linear.x * dt;
+ transform.position.y += vel.linear.y * dt;
+
+ // Keep player on screen
+ if (entity === this.player) {
+ transform.position.x = Math.max(
+ 25,
+ Math.min(this.getWidth() - 25, transform.position.x)
+ );
+ transform.position.y = Math.max(
+ 25,
+ Math.min(this.getHeight() - 25, transform.position.y)
+ );
+ }
+ }
+ );
+ }
+
+ protected onRender(): void {
+ const registry = this.getRegistry();
+
+ // Clear screen
+ Renderer.clear();
+
+ // Set up orthographic projection
+ const projection = Renderer.createOrtho2D(
+ this.getWidth() * this.getPlatform().getDevicePixelRatio(),
+ this.getHeight() * this.getPlatform().getDevicePixelRatio()
+ );
+ Renderer.beginScene(projection);
+
+ // Render all sprites
+ registry.view2<Transform, Sprite>(TransformType, SpriteType).each(
+ (entity, transform, sprite) => {
+ const pos = vec2(
+ transform.position.x * this.getPlatform().getDevicePixelRatio(),
+ transform.position.y * this.getPlatform().getDevicePixelRatio()
+ );
+ const size = vec2(
+ sprite.size.x * this.getPlatform().getDevicePixelRatio(),
+ sprite.size.y * this.getPlatform().getDevicePixelRatio()
+ );
+
+ // Center the quad
+ Renderer.drawQuad(
+ { x: pos.x - size.x / 2, y: pos.y - size.y / 2 },
+ size,
+ sprite.color
+ );
+ }
+ );
+
+ Renderer.endScene();
+ }
+
+ protected onTouch(type: TouchType, point: TouchPoint): void {
+ if (type === TouchType.Begin) {
+ console.log(`Touch started at (${point.x}, ${point.y})`);
+ }
+ }
+
+ protected onKey(key: KeyCode, pressed: boolean): void {
+ if (pressed) {
+ console.log(`Key pressed: ${key}`);
+ }
+ }
+
+ protected onShutdown(): void {
+ console.log('HelloGame shutdown');
+ }
+}
+
+// Start the game with C++ WASM renderer
+const game = new HelloGame({
+ title: 'Hello ESEngine',
+ width: 800,
+ height: 600,
+ canvas: 'canvas', // Must match C++ selector "#canvas"
+ wasmPath: './esengine.js',
+});
+
+game.run();
diff --git a/sdk/examples/hello-game/rollup.config.js b/sdk/examples/hello-game/rollup.config.js
new file mode 100644
index 000000000..5708f4aeb
--- /dev/null
+++ b/sdk/examples/hello-game/rollup.config.js
@@ -0,0 +1,16 @@
+import typescript from '@rollup/plugin-typescript';
+
+export default {
+ input: 'index.ts',
+ output: {
+ file: 'index.js',
+ format: 'esm',
+ sourcemap: true,
+ },
+ plugins: [
+ typescript({
+ tsconfig: './tsconfig.json',
+ declaration: false,
+ }),
+ ],
+};
diff --git a/sdk/examples/hello-game/tsconfig.json b/sdk/examples/hello-game/tsconfig.json
new file mode 100644
index 000000000..14f6736d5
--- /dev/null
+++ b/sdk/examples/hello-game/tsconfig.json
@@ -0,0 +1,15 @@
+{
+ "compilerOptions": {
+ "target": "ES2020",
+ "module": "ESNext",
+ "lib": ["ES2020", "DOM"],
+ "strict": true,
+ "moduleResolution": "node",
+ "esModuleInterop": true,
+ "skipLibCheck": true,
+ "outDir": ".",
+ "rootDir": "../.."
+ },
+ "include": ["*.ts", "../../src/**/*.ts"],
+ "exclude": ["node_modules"]
+}
diff --git a/sdk/package-lock.json b/sdk/package-lock.json
new file mode 100644
index 000000000..609f2b111
--- /dev/null
+++ b/sdk/package-lock.json
@@ -0,0 +1,1224 @@
+{
+ "name": "@esengine/sdk",
+ "version": "0.1.0",
+ "lockfileVersion": 3,
+ "requires": true,
+ "packages": {
+ "": {
+ "name": "@esengine/sdk",
+ "version": "0.1.0",
+ "license": "MIT",
+ "devDependencies": {
+ "@rollup/plugin-typescript": "^11.1.5",
+ "rimraf": "^5.0.5",
+ "rollup": "^4.9.0",
+ "rollup-plugin-dts": "^6.1.0",
+ "tslib": "^2.6.2",
+ "typescript": "^5.3.0"
+ }
+ },
+ "node_modules/@babel/code-frame": {
+ "version": "7.28.6",
+ "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.28.6.tgz",
+ "integrity": "sha512-JYgintcMjRiCvS8mMECzaEn+m3PfoQiyqukOMCCVQtoJGYJw8j/8LBJEiqkHLkfwCcs74E3pbAUFNg7d9VNJ+Q==",
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "dependencies": {
+ "@babel/helper-validator-identifier": "^7.28.5",
+ "js-tokens": "^4.0.0",
+ "picocolors": "^1.1.1"
+ },
+ "engines": {
+ "node": ">=6.9.0"
+ }
+ },
+ "node_modules/@babel/helper-validator-identifier": {
+ "version": "7.28.5",
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz",
+ "integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==",
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "engines": {
+ "node": ">=6.9.0"
+ }
+ },
+ "node_modules/@isaacs/cliui": {
+ "version": "8.0.2",
+ "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz",
+ "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==",
+ "dev": true,
+ "license": "ISC",
+ "dependencies": {
+ "string-width": "^5.1.2",
+ "string-width-cjs": "npm:string-width@^4.2.0",
+ "strip-ansi": "^7.0.1",
+ "strip-ansi-cjs": "npm:strip-ansi@^6.0.1",
+ "wrap-ansi": "^8.1.0",
+ "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/@jridgewell/sourcemap-codec": {
+ "version": "1.5.5",
+ "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz",
+ "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/@pkgjs/parseargs": {
+ "version": "0.11.0",
+ "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz",
+ "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==",
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "engines": {
+ "node": ">=14"
+ }
+ },
+ "node_modules/@rollup/plugin-typescript": {
+ "version": "11.1.6",
+ "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-11.1.6.tgz",
+ "integrity": "sha512-R92yOmIACgYdJ7dJ97p4K69I8gg6IEHt8M7dUBxN3W6nrO8uUxX5ixl0yU/N3aZTi8WhPuICvOHXQvF6FaykAA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@rollup/pluginutils": "^5.1.0",
+ "resolve": "^1.22.1"
+ },
+ "engines": {
+ "node": ">=14.0.0"
+ },
+ "peerDependencies": {
+ "rollup": "^2.14.0||^3.0.0||^4.0.0",
+ "tslib": "*",
+ "typescript": ">=3.7.0"
+ },
+ "peerDependenciesMeta": {
+ "rollup": {
+ "optional": true
+ },
+ "tslib": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@rollup/pluginutils": {
+ "version": "5.3.0",
+ "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.3.0.tgz",
+ "integrity": "sha512-5EdhGZtnu3V88ces7s53hhfK5KSASnJZv8Lulpc04cWO3REESroJXg73DFsOmgbU2BhwV0E20bu2IDZb3VKW4Q==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@types/estree": "^1.0.0",
+ "estree-walker": "^2.0.2",
+ "picomatch": "^4.0.2"
+ },
+ "engines": {
+ "node": ">=14.0.0"
+ },
+ "peerDependencies": {
+ "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0"
+ },
+ "peerDependenciesMeta": {
+ "rollup": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@rollup/rollup-android-arm-eabi": {
+ "version": "4.56.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.56.0.tgz",
+ "integrity": "sha512-LNKIPA5k8PF1+jAFomGe3qN3bbIgJe/IlpDBwuVjrDKrJhVWywgnJvflMt/zkbVNLFtF1+94SljYQS6e99klnw==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "android"
+ ]
+ },
+ "node_modules/@rollup/rollup-android-arm64": {
+ "version": "4.56.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.56.0.tgz",
+ "integrity": "sha512-lfbVUbelYqXlYiU/HApNMJzT1E87UPGvzveGg2h0ktUNlOCxKlWuJ9jtfvs1sKHdwU4fzY7Pl8sAl49/XaEk6Q==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "android"
+ ]
+ },
+ "node_modules/@rollup/rollup-darwin-arm64": {
+ "version": "4.56.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.56.0.tgz",
+ "integrity": "sha512-EgxD1ocWfhoD6xSOeEEwyE7tDvwTgZc8Bss7wCWe+uc7wO8G34HHCUH+Q6cHqJubxIAnQzAsyUsClt0yFLu06w==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ]
+ },
+ "node_modules/@rollup/rollup-darwin-x64": {
+ "version": "4.56.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.56.0.tgz",
+ "integrity": "sha512-1vXe1vcMOssb/hOF8iv52A7feWW2xnu+c8BV4t1F//m9QVLTfNVpEdja5ia762j/UEJe2Z1jAmEqZAK42tVW3g==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ]
+ },
+ "node_modules/@rollup/rollup-freebsd-arm64": {
+ "version": "4.56.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.56.0.tgz",
+ "integrity": "sha512-bof7fbIlvqsyv/DtaXSck4VYQ9lPtoWNFCB/JY4snlFuJREXfZnm+Ej6yaCHfQvofJDXLDMTVxWscVSuQvVWUQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "freebsd"
+ ]
+ },
+ "node_modules/@rollup/rollup-freebsd-x64": {
+ "version": "4.56.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.56.0.tgz",
+ "integrity": "sha512-KNa6lYHloW+7lTEkYGa37fpvPq+NKG/EHKM8+G/g9WDU7ls4sMqbVRV78J6LdNuVaeeK5WB9/9VAFbKxcbXKYg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "freebsd"
+ ]
+ },
+ "node_modules/@rollup/rollup-linux-arm-gnueabihf": {
+ "version": "4.56.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.56.0.tgz",
+ "integrity": "sha512-E8jKK87uOvLrrLN28jnAAAChNq5LeCd2mGgZF+fGF5D507WlG/Noct3lP/QzQ6MrqJ5BCKNwI9ipADB6jyiq2A==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/@rollup/rollup-linux-arm-musleabihf": {
+ "version": "4.56.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.56.0.tgz",
+ "integrity": "sha512-jQosa5FMYF5Z6prEpTCCmzCXz6eKr/tCBssSmQGEeozA9tkRUty/5Vx06ibaOP9RCrW1Pvb8yp3gvZhHwTDsJw==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/@rollup/rollup-linux-arm64-gnu": {
+ "version": "4.56.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.56.0.tgz",
+ "integrity": "sha512-uQVoKkrC1KGEV6udrdVahASIsaF8h7iLG0U0W+Xn14ucFwi6uS539PsAr24IEF9/FoDtzMeeJXJIBo5RkbNWvQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/@rollup/rollup-linux-arm64-musl": {
+ "version": "4.56.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.56.0.tgz",
+ "integrity": "sha512-vLZ1yJKLxhQLFKTs42RwTwa6zkGln+bnXc8ueFGMYmBTLfNu58sl5/eXyxRa2RarTkJbXl8TKPgfS6V5ijNqEA==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/@rollup/rollup-linux-loong64-gnu": {
+ "version": "4.56.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.56.0.tgz",
+ "integrity": "sha512-FWfHOCub564kSE3xJQLLIC/hbKqHSVxy8vY75/YHHzWvbJL7aYJkdgwD/xGfUlL5UV2SB7otapLrcCj2xnF1dg==",
+ "cpu": [
+ "loong64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/@rollup/rollup-linux-loong64-musl": {
+ "version": "4.56.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.56.0.tgz",
+ "integrity": "sha512-z1EkujxIh7nbrKL1lmIpqFTc/sr0u8Uk0zK/qIEFldbt6EDKWFk/pxFq3gYj4Bjn3aa9eEhYRlL3H8ZbPT1xvA==",
+ "cpu": [
+ "loong64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/@rollup/rollup-linux-ppc64-gnu": {
+ "version": "4.56.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.56.0.tgz",
+ "integrity": "sha512-iNFTluqgdoQC7AIE8Q34R3AuPrJGJirj5wMUErxj22deOcY7XwZRaqYmB6ZKFHoVGqRcRd0mqO+845jAibKCkw==",
+ "cpu": [
+ "ppc64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/@rollup/rollup-linux-ppc64-musl": {
+ "version": "4.56.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.56.0.tgz",
+ "integrity": "sha512-MtMeFVlD2LIKjp2sE2xM2slq3Zxf9zwVuw0jemsxvh1QOpHSsSzfNOTH9uYW9i1MXFxUSMmLpeVeUzoNOKBaWg==",
+ "cpu": [
+ "ppc64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/@rollup/rollup-linux-riscv64-gnu": {
+ "version": "4.56.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.56.0.tgz",
+ "integrity": "sha512-in+v6wiHdzzVhYKXIk5U74dEZHdKN9KH0Q4ANHOTvyXPG41bajYRsy7a8TPKbYPl34hU7PP7hMVHRvv/5aCSew==",
+ "cpu": [
+ "riscv64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/@rollup/rollup-linux-riscv64-musl": {
+ "version": "4.56.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.56.0.tgz",
+ "integrity": "sha512-yni2raKHB8m9NQpI9fPVwN754mn6dHQSbDTwxdr9SE0ks38DTjLMMBjrwvB5+mXrX+C0npX0CVeCUcvvvD8CNQ==",
+ "cpu": [
+ "riscv64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/@rollup/rollup-linux-s390x-gnu": {
+ "version": "4.56.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.56.0.tgz",
+ "integrity": "sha512-zhLLJx9nQPu7wezbxt2ut+CI4YlXi68ndEve16tPc/iwoylWS9B3FxpLS2PkmfYgDQtosah07Mj9E0khc3Y+vQ==",
+ "cpu": [
+ "s390x"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/@rollup/rollup-linux-x64-gnu": {
+ "version": "4.56.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.56.0.tgz",
+ "integrity": "sha512-MVC6UDp16ZSH7x4rtuJPAEoE1RwS8N4oK9DLHy3FTEdFoUTCFVzMfJl/BVJ330C+hx8FfprA5Wqx4FhZXkj2Kw==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/@rollup/rollup-linux-x64-musl": {
+ "version": "4.56.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.56.0.tgz",
+ "integrity": "sha512-ZhGH1eA4Qv0lxaV00azCIS1ChedK0V32952Md3FtnxSqZTBTd6tgil4nZT5cU8B+SIw3PFYkvyR4FKo2oyZIHA==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/@rollup/rollup-openbsd-x64": {
+ "version": "4.56.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.56.0.tgz",
+ "integrity": "sha512-O16XcmyDeFI9879pEcmtWvD/2nyxR9mF7Gs44lf1vGGx8Vg2DRNx11aVXBEqOQhWb92WN4z7fW/q4+2NYzCbBA==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "openbsd"
+ ]
+ },
+ "node_modules/@rollup/rollup-openharmony-arm64": {
+ "version": "4.56.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.56.0.tgz",
+ "integrity": "sha512-LhN/Reh+7F3RCgQIRbgw8ZMwUwyqJM+8pXNT6IIJAqm2IdKkzpCh/V9EdgOMBKuebIrzswqy4ATlrDgiOwbRcQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "openharmony"
+ ]
+ },
+ "node_modules/@rollup/rollup-win32-arm64-msvc": {
+ "version": "4.56.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.56.0.tgz",
+ "integrity": "sha512-kbFsOObXp3LBULg1d3JIUQMa9Kv4UitDmpS+k0tinPBz3watcUiV2/LUDMMucA6pZO3WGE27P7DsfaN54l9ing==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ]
+ },
+ "node_modules/@rollup/rollup-win32-ia32-msvc": {
+ "version": "4.56.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.56.0.tgz",
+ "integrity": "sha512-vSSgny54D6P4vf2izbtFm/TcWYedw7f8eBrOiGGecyHyQB9q4Kqentjaj8hToe+995nob/Wv48pDqL5a62EWtg==",
+ "cpu": [
+ "ia32"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ]
+ },
+ "node_modules/@rollup/rollup-win32-x64-gnu": {
+ "version": "4.56.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.56.0.tgz",
+ "integrity": "sha512-FeCnkPCTHQJFbiGG49KjV5YGW/8b9rrXAM2Mz2kiIoktq2qsJxRD5giEMEOD2lPdgs72upzefaUvS+nc8E3UzQ==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ]
+ },
+ "node_modules/@rollup/rollup-win32-x64-msvc": {
+ "version": "4.56.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.56.0.tgz",
+ "integrity": "sha512-H8AE9Ur/t0+1VXujj90w0HrSOuv0Nq9r1vSZF2t5km20NTfosQsGGUXDaKdQZzwuLts7IyL1fYT4hM95TI9c4g==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ]
+ },
+ "node_modules/@types/estree": {
+ "version": "1.0.8",
+ "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz",
+ "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/ansi-regex": {
+ "version": "6.2.2",
+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.2.tgz",
+ "integrity": "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/ansi-regex?sponsor=1"
+ }
+ },
+ "node_modules/ansi-styles": {
+ "version": "6.2.3",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz",
+ "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/ansi-styles?sponsor=1"
+ }
+ },
+ "node_modules/balanced-match": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
+ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/brace-expansion": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz",
+ "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "balanced-match": "^1.0.0"
+ }
+ },
+ "node_modules/color-convert": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
+ "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "color-name": "~1.1.4"
+ },
+ "engines": {
+ "node": ">=7.0.0"
+ }
+ },
+ "node_modules/color-name": {
+ "version": "1.1.4",
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
+ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/cross-spawn": {
+ "version": "7.0.6",
+ "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
+ "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "path-key": "^3.1.0",
+ "shebang-command": "^2.0.0",
+ "which": "^2.0.1"
+ },
+ "engines": {
+ "node": ">= 8"
+ }
+ },
+ "node_modules/eastasianwidth": {
+ "version": "0.2.0",
+ "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz",
+ "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/emoji-regex": {
+ "version": "9.2.2",
+ "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz",
+ "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/estree-walker": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz",
+ "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/foreground-child": {
+ "version": "3.3.1",
+ "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz",
+ "integrity": "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==",
+ "dev": true,
+ "license": "ISC",
+ "dependencies": {
+ "cross-spawn": "^7.0.6",
+ "signal-exit": "^4.0.1"
+ },
+ "engines": {
+ "node": ">=14"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/isaacs"
+ }
+ },
+ "node_modules/fsevents": {
+ "version": "2.3.3",
+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
+ "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
+ "dev": true,
+ "hasInstallScript": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
+ }
+ },
+ "node_modules/function-bind": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
+ "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
+ "dev": true,
+ "license": "MIT",
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/glob": {
+ "version": "10.5.0",
+ "resolved": "https://registry.npmjs.org/glob/-/glob-10.5.0.tgz",
+ "integrity": "sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==",
+ "dev": true,
+ "license": "ISC",
+ "dependencies": {
+ "foreground-child": "^3.1.0",
+ "jackspeak": "^3.1.2",
+ "minimatch": "^9.0.4",
+ "minipass": "^7.1.2",
+ "package-json-from-dist": "^1.0.0",
+ "path-scurry": "^1.11.1"
+ },
+ "bin": {
+ "glob": "dist/esm/bin.mjs"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/isaacs"
+ }
+ },
+ "node_modules/hasown": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
+ "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "function-bind": "^1.1.2"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/is-core-module": {
+ "version": "2.16.1",
+ "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz",
+ "integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "hasown": "^2.0.2"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/is-fullwidth-code-point": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
+ "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/isexe": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
+ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
+ "dev": true,
+ "license": "ISC"
+ },
+ "node_modules/jackspeak": {
+ "version": "3.4.3",
+ "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz",
+ "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==",
+ "dev": true,
+ "license": "BlueOak-1.0.0",
+ "dependencies": {
+ "@isaacs/cliui": "^8.0.2"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/isaacs"
+ },
+ "optionalDependencies": {
+ "@pkgjs/parseargs": "^0.11.0"
+ }
+ },
+ "node_modules/js-tokens": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
+ "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
+ "dev": true,
+ "license": "MIT",
+ "optional": true
+ },
+ "node_modules/lru-cache": {
+ "version": "10.4.3",
+ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz",
+ "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==",
+ "dev": true,
+ "license": "ISC"
+ },
+ "node_modules/magic-string": {
+ "version": "0.30.21",
+ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",
+ "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@jridgewell/sourcemap-codec": "^1.5.5"
+ }
+ },
+ "node_modules/minimatch": {
+ "version": "9.0.5",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz",
+ "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==",
+ "dev": true,
+ "license": "ISC",
+ "dependencies": {
+ "brace-expansion": "^2.0.1"
+ },
+ "engines": {
+ "node": ">=16 || 14 >=14.17"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/isaacs"
+ }
+ },
+ "node_modules/minipass": {
+ "version": "7.1.2",
+ "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz",
+ "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==",
+ "dev": true,
+ "license": "ISC",
+ "engines": {
+ "node": ">=16 || 14 >=14.17"
+ }
+ },
+ "node_modules/package-json-from-dist": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz",
+ "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==",
+ "dev": true,
+ "license": "BlueOak-1.0.0"
+ },
+ "node_modules/path-key": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
+ "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/path-parse": {
+ "version": "1.0.7",
+ "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
+ "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/path-scurry": {
+ "version": "1.11.1",
+ "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz",
+ "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==",
+ "dev": true,
+ "license": "BlueOak-1.0.0",
+ "dependencies": {
+ "lru-cache": "^10.2.0",
+ "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0"
+ },
+ "engines": {
+ "node": ">=16 || 14 >=14.18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/isaacs"
+ }
+ },
+ "node_modules/picocolors": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
+ "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
+ "dev": true,
+ "license": "ISC",
+ "optional": true
+ },
+ "node_modules/picomatch": {
+ "version": "4.0.3",
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz",
+ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/jonschlinkert"
+ }
+ },
+ "node_modules/resolve": {
+ "version": "1.22.11",
+ "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.11.tgz",
+ "integrity": "sha512-RfqAvLnMl313r7c9oclB1HhUEAezcpLjz95wFH4LVuhk9JF/r22qmVP9AMmOU4vMX7Q8pN8jwNg/CSpdFnMjTQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "is-core-module": "^2.16.1",
+ "path-parse": "^1.0.7",
+ "supports-preserve-symlinks-flag": "^1.0.0"
+ },
+ "bin": {
+ "resolve": "bin/resolve"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/rimraf": {
+ "version": "5.0.10",
+ "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.10.tgz",
+ "integrity": "sha512-l0OE8wL34P4nJH/H2ffoaniAokM2qSmrtXHmlpvYr5AVVX8msAyW0l8NVJFDxlSK4u3Uh/f41cQheDVdnYijwQ==",
+ "dev": true,
+ "license": "ISC",
+ "dependencies": {
+ "glob": "^10.3.7"
+ },
+ "bin": {
+ "rimraf": "dist/esm/bin.mjs"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/isaacs"
+ }
+ },
+ "node_modules/rollup": {
+ "version": "4.56.0",
+ "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.56.0.tgz",
+ "integrity": "sha512-9FwVqlgUHzbXtDg9RCMgodF3Ua4Na6Gau+Sdt9vyCN4RhHfVKX2DCHy3BjMLTDd47ITDhYAnTwGulWTblJSDLg==",
+ "dev": true,
+ "license": "MIT",
+ "peer": true,
+ "dependencies": {
+ "@types/estree": "1.0.8"
+ },
+ "bin": {
+ "rollup": "dist/bin/rollup"
+ },
+ "engines": {
+ "node": ">=18.0.0",
+ "npm": ">=8.0.0"
+ },
+ "optionalDependencies": {
+ "@rollup/rollup-android-arm-eabi": "4.56.0",
+ "@rollup/rollup-android-arm64": "4.56.0",
+ "@rollup/rollup-darwin-arm64": "4.56.0",
+ "@rollup/rollup-darwin-x64": "4.56.0",
+ "@rollup/rollup-freebsd-arm64": "4.56.0",
+ "@rollup/rollup-freebsd-x64": "4.56.0",
+ "@rollup/rollup-linux-arm-gnueabihf": "4.56.0",
+ "@rollup/rollup-linux-arm-musleabihf": "4.56.0",
+ "@rollup/rollup-linux-arm64-gnu": "4.56.0",
+ "@rollup/rollup-linux-arm64-musl": "4.56.0",
+ "@rollup/rollup-linux-loong64-gnu": "4.56.0",
+ "@rollup/rollup-linux-loong64-musl": "4.56.0",
+ "@rollup/rollup-linux-ppc64-gnu": "4.56.0",
+ "@rollup/rollup-linux-ppc64-musl": "4.56.0",
+ "@rollup/rollup-linux-riscv64-gnu": "4.56.0",
+ "@rollup/rollup-linux-riscv64-musl": "4.56.0",
+ "@rollup/rollup-linux-s390x-gnu": "4.56.0",
+ "@rollup/rollup-linux-x64-gnu": "4.56.0",
+ "@rollup/rollup-linux-x64-musl": "4.56.0",
+ "@rollup/rollup-openbsd-x64": "4.56.0",
+ "@rollup/rollup-openharmony-arm64": "4.56.0",
+ "@rollup/rollup-win32-arm64-msvc": "4.56.0",
+ "@rollup/rollup-win32-ia32-msvc": "4.56.0",
+ "@rollup/rollup-win32-x64-gnu": "4.56.0",
+ "@rollup/rollup-win32-x64-msvc": "4.56.0",
+ "fsevents": "~2.3.2"
+ }
+ },
+ "node_modules/rollup-plugin-dts": {
+ "version": "6.3.0",
+ "resolved": "https://registry.npmjs.org/rollup-plugin-dts/-/rollup-plugin-dts-6.3.0.tgz",
+ "integrity": "sha512-d0UrqxYd8KyZ6i3M2Nx7WOMy708qsV/7fTHMHxCMCBOAe3V/U7OMPu5GkX8hC+cmkHhzGnfeYongl1IgiooddA==",
+ "dev": true,
+ "license": "LGPL-3.0-only",
+ "dependencies": {
+ "magic-string": "^0.30.21"
+ },
+ "engines": {
+ "node": ">=16"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/Swatinem"
+ },
+ "optionalDependencies": {
+ "@babel/code-frame": "^7.27.1"
+ },
+ "peerDependencies": {
+ "rollup": "^3.29.4 || ^4",
+ "typescript": "^4.5 || ^5.0"
+ }
+ },
+ "node_modules/shebang-command": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
+ "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "shebang-regex": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/shebang-regex": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
+ "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/signal-exit": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz",
+ "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==",
+ "dev": true,
+ "license": "ISC",
+ "engines": {
+ "node": ">=14"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/isaacs"
+ }
+ },
+ "node_modules/string-width": {
+ "version": "5.1.2",
+ "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz",
+ "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "eastasianwidth": "^0.2.0",
+ "emoji-regex": "^9.2.2",
+ "strip-ansi": "^7.0.1"
+ },
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/string-width-cjs": {
+ "name": "string-width",
+ "version": "4.2.3",
+ "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
+ "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "emoji-regex": "^8.0.0",
+ "is-fullwidth-code-point": "^3.0.0",
+ "strip-ansi": "^6.0.1"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/string-width-cjs/node_modules/ansi-regex": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
+ "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/string-width-cjs/node_modules/emoji-regex": {
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
+ "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/string-width-cjs/node_modules/strip-ansi": {
+ "version": "6.0.1",
+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
+ "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "ansi-regex": "^5.0.1"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/strip-ansi": {
+ "version": "7.1.2",
+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.2.tgz",
+ "integrity": "sha512-gmBGslpoQJtgnMAvOVqGZpEz9dyoKTCzy2nfz/n8aIFhN/jCE/rCmcxabB6jOOHV+0WNnylOxaxBQPSvcWklhA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "ansi-regex": "^6.0.1"
+ },
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/strip-ansi?sponsor=1"
+ }
+ },
+ "node_modules/strip-ansi-cjs": {
+ "name": "strip-ansi",
+ "version": "6.0.1",
+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
+ "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "ansi-regex": "^5.0.1"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/strip-ansi-cjs/node_modules/ansi-regex": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
+ "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/supports-preserve-symlinks-flag": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",
+ "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/tslib": {
+ "version": "2.8.1",
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
+ "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
+ "dev": true,
+ "license": "0BSD",
+ "peer": true
+ },
+ "node_modules/typescript": {
+ "version": "5.9.3",
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
+ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "peer": true,
+ "bin": {
+ "tsc": "bin/tsc",
+ "tsserver": "bin/tsserver"
+ },
+ "engines": {
+ "node": ">=14.17"
+ }
+ },
+ "node_modules/which": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
+ "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
+ "dev": true,
+ "license": "ISC",
+ "dependencies": {
+ "isexe": "^2.0.0"
+ },
+ "bin": {
+ "node-which": "bin/node-which"
+ },
+ "engines": {
+ "node": ">= 8"
+ }
+ },
+ "node_modules/wrap-ansi": {
+ "version": "8.1.0",
+ "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz",
+ "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "ansi-styles": "^6.1.0",
+ "string-width": "^5.0.1",
+ "strip-ansi": "^7.0.1"
+ },
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/wrap-ansi?sponsor=1"
+ }
+ },
+ "node_modules/wrap-ansi-cjs": {
+ "name": "wrap-ansi",
+ "version": "7.0.0",
+ "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
+ "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "ansi-styles": "^4.0.0",
+ "string-width": "^4.1.0",
+ "strip-ansi": "^6.0.0"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/wrap-ansi?sponsor=1"
+ }
+ },
+ "node_modules/wrap-ansi-cjs/node_modules/ansi-regex": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
+ "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/wrap-ansi-cjs/node_modules/ansi-styles": {
+ "version": "4.3.0",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
+ "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "color-convert": "^2.0.1"
+ },
+ "engines": {
+ "node": ">=8"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/ansi-styles?sponsor=1"
+ }
+ },
+ "node_modules/wrap-ansi-cjs/node_modules/emoji-regex": {
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
+ "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/wrap-ansi-cjs/node_modules/string-width": {
+ "version": "4.2.3",
+ "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
+ "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "emoji-regex": "^8.0.0",
+ "is-fullwidth-code-point": "^3.0.0",
+ "strip-ansi": "^6.0.1"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/wrap-ansi-cjs/node_modules/strip-ansi": {
+ "version": "6.0.1",
+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
+ "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "ansi-regex": "^5.0.1"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ }
+ }
+}
diff --git a/sdk/package.json b/sdk/package.json
new file mode 100644
index 000000000..8dc322a7d
--- /dev/null
+++ b/sdk/package.json
@@ -0,0 +1,40 @@
+{
+ "name": "@esengine/sdk",
+ "version": "0.1.0",
+ "type": "module",
+ "description": "TypeScript SDK for ESEngine - A lightweight 2D game engine for Web and WeChat MiniGames",
+ "main": "dist/esengine.cjs.js",
+ "module": "dist/esengine.esm.js",
+ "types": "dist/index.d.ts",
+ "files": [
+ "dist"
+ ],
+ "scripts": {
+ "build": "rollup -c",
+ "watch": "rollup -c -w",
+ "clean": "rimraf dist",
+ "prepublishOnly": "npm run clean && npm run build"
+ },
+ "keywords": [
+ "game-engine",
+ "ecs",
+ "webgl",
+ "wechat-minigame",
+ "typescript"
+ ],
+ "author": "ESEngine Team",
+ "license": "MIT",
+ "devDependencies": {
+ "@rollup/plugin-typescript": "^11.1.5",
+ "rimraf": "^5.0.5",
+ "rollup": "^4.9.0",
+ "rollup-plugin-dts": "^6.1.0",
+ "tslib": "^2.6.2",
+ "typescript": "^5.3.0"
+ },
+ "peerDependencies": {},
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/esengine/esengine.git"
+ }
+}
diff --git a/sdk/rollup.config.js b/sdk/rollup.config.js
new file mode 100644
index 000000000..9d96a413f
--- /dev/null
+++ b/sdk/rollup.config.js
@@ -0,0 +1,46 @@
+import typescript from '@rollup/plugin-typescript';
+import dts from 'rollup-plugin-dts';
+
+const input = 'src/index.ts';
+
+export default [
+ // ESM build
+ {
+ input,
+ output: {
+ file: 'dist/esengine.esm.js',
+ format: 'esm',
+ sourcemap: true,
+ },
+ plugins: [
+ typescript({
+ tsconfig: './tsconfig.json',
+ declaration: false,
+ }),
+ ],
+ },
+ // CommonJS build
+ {
+ input,
+ output: {
+ file: 'dist/esengine.cjs.js',
+ format: 'cjs',
+ sourcemap: true,
+ },
+ plugins: [
+ typescript({
+ tsconfig: './tsconfig.json',
+ declaration: false,
+ }),
+ ],
+ },
+ // Type declarations
+ {
+ input,
+ output: {
+ file: 'dist/index.d.ts',
+ format: 'esm',
+ },
+ plugins: [dts()],
+ },
+];
diff --git a/sdk/src/core/Application.ts b/sdk/src/core/Application.ts
new file mode 100644
index 000000000..9f6cafa4b
--- /dev/null
+++ b/sdk/src/core/Application.ts
@@ -0,0 +1,372 @@
+/**
+ * ESEngine TypeScript SDK - Application Base Class
+ *
+ * Provides the main entry point and lifecycle management for games.
+ */
+
+import {
+ ApplicationConfig,
+ TouchType,
+ TouchPoint,
+ KeyCode,
+ RendererBackend,
+} from './Types';
+import { loadWasmModule, isWasmLoaded, WasmLoadOptions } from './WasmBridge';
+import { Registry } from '../ecs/Registry';
+import { SystemGroup } from '../ecs/System';
+import { Input } from '../input/Input';
+import { Platform, PlatformConfig } from '../platform/Platform';
+import { Renderer, RendererMode } from '../renderer/Renderer';
+
+/**
+ * Application - Base class for games.
+ * Extend this class and override lifecycle methods to create your game.
+ */
+export abstract class Application {
+ private static instance: Application | null = null;
+
+ protected config: Required<ApplicationConfig>;
+ protected platform: Platform;
+ protected registry: Registry;
+ protected systems: SystemGroup;
+ protected running: boolean = false;
+ protected deltaTime: number = 0;
+ protected animationFrameId: number = 0;
+ protected rendererMode: RendererMode = RendererMode.Native;
+
+ constructor(config: ApplicationConfig = {}) {
+ if (Application.instance) {
+ throw new Error('Only one Application instance can exist');
+ }
+ Application.instance = this;
+
+ // Determine renderer backend
+ const hasWasm = !!config.wasmPath;
+ const requestedBackend = config.renderer ?? (hasWasm ? RendererBackend.Wasm : RendererBackend.Native);
+
+ // Warn if Wasm requested but no path provided
+ if (requestedBackend === RendererBackend.Wasm && !hasWasm) {
+ console.warn(
+ '[ESEngine] Wasm backend requested but wasmPath not provided. ' +
+ 'Falling back to Native. Provide wasmPath for C++ rendering.'
+ );
+ }
+
+ // Apply default configuration
+ this.config = {
+ title: config.title ?? 'ESEngine Application',
+ width: config.width ?? 800,
+ height: config.height ?? 600,
+ canvas: config.canvas ?? undefined as unknown as HTMLCanvasElement,
+ vsync: config.vsync ?? true,
+ wasmPath: config.wasmPath ?? '',
+ renderer: requestedBackend,
+ };
+
+ // Initialize systems
+ this.registry = new Registry();
+ this.systems = new SystemGroup();
+
+ // Create platform
+ this.platform = Platform.create();
+ }
+
+ /**
+ * Get the singleton application instance.
+ */
+ static get(): Application {
+ if (!Application.instance) {
+ throw new Error('No Application instance exists');
+ }
+ return Application.instance;
+ }
+
+ /**
+ * Start the application main loop.
+ * This is an async method that loads WASM if configured.
+ */
+ async run(): Promise<void> {
+ if (this.running) return;
+
+ // For WASM mode, we need to set up canvas first, then load WASM
+ // because Emscripten needs the canvas to create WebGL context
+ let canvas: HTMLCanvasElement | null = null;
+
+ // Get or create canvas element
+ if (this.config.canvas) {
+ if (typeof this.config.canvas === 'string') {
+ canvas = document.getElementById(this.config.canvas) as HTMLCanvasElement;
+ } else {
+ canvas = this.config.canvas;
+ }
+ }
+
+ if (!canvas && typeof document !== 'undefined') {
+ canvas = document.createElement('canvas');
+ canvas.id = 'esengine-canvas';
+ document.body.appendChild(canvas);
+ }
+
+ // Set canvas size
+ if (canvas) {
+ const dpr = window.devicePixelRatio ?? 1;
+ canvas.width = this.config.width * dpr;
+ canvas.height = this.config.height * dpr;
+ canvas.style.width = `${this.config.width}px`;
+ canvas.style.height = `${this.config.height}px`;
+ }
+
+ // Load WASM module if configured for Wasm backend
+ if (this.config.renderer === RendererBackend.Wasm && this.config.wasmPath) {
+ try {
+ console.log('[ESEngine] Loading WASM module...');
+ const wasmOptions: WasmLoadOptions | undefined = canvas ? {
+ canvas,
+ width: this.config.width,
+ height: this.config.height,
+ } : undefined;
+ await loadWasmModule(this.config.wasmPath, wasmOptions);
+ this.rendererMode = RendererMode.Wasm;
+ console.log('[ESEngine] WASM module loaded, using C++ renderer');
+ } catch (error) {
+ console.error('[ESEngine] Failed to load WASM module:', error);
+ console.warn('[ESEngine] Falling back to Native renderer');
+ this.rendererMode = RendererMode.Native;
+ }
+ } else {
+ this.rendererMode = RendererMode.Native;
+ if (this.config.renderer === RendererBackend.Wasm) {
+ console.warn('[ESEngine] Using Native renderer (no wasmPath configured)');
+ }
+ }
+
+ // Initialize platform (skip GL context creation if using WASM)
+ const isWasmMode = this.rendererMode === RendererMode.Wasm;
+ const platformConfig: PlatformConfig = {
+ width: this.config.width,
+ height: this.config.height,
+ canvas: canvas ?? this.config.canvas,
+ skipGLContext: isWasmMode, // Don't create GL context - C++ owns it
+ };
+
+ if (!this.platform.initialize(platformConfig)) {
+ console.error('Failed to initialize platform');
+ return;
+ }
+
+ // Initialize input
+ Input.init();
+
+ // Set up platform callbacks
+ this.platform.setTouchCallback((type, point) => {
+ Input.onTouchEvent(type, point);
+ this.onTouch(type, point);
+ });
+
+ this.platform.setKeyCallback((key, pressed) => {
+ Input.onKeyEvent(key, pressed);
+ this.onKey(key, pressed);
+ });
+
+ this.platform.setResizeCallback((width, height) => {
+ this.config.width = width;
+ this.config.height = height;
+ this.onResize(width, height);
+ });
+
+ // Initialize renderer with appropriate mode
+ if (isWasmMode) {
+ // WASM mode: C++ handles WebGL, no TypeScript GL context needed
+ Renderer.init(null, this.rendererMode);
+ } else {
+ // Native mode: TypeScript handles WebGL
+ const gl = this.platform.getGL();
+ if (gl) {
+ Renderer.init(gl, this.rendererMode);
+ Renderer.setViewport(
+ 0,
+ 0,
+ this.config.width * this.platform.getDevicePixelRatio(),
+ this.config.height * this.platform.getDevicePixelRatio()
+ );
+ }
+ }
+
+ // Initialize systems
+ this.systems.init(this.registry);
+
+ // Call user initialization
+ this.onInit();
+
+ // Start game loop
+ this.running = true;
+ this.gameLoop();
+ }
+
+ /**
+ * Request the application to quit.
+ */
+ quit(): void {
+ this.running = false;
+ }
+
+ /**
+ * Get the platform instance.
+ */
+ getPlatform(): Platform {
+ return this.platform;
+ }
+
+ /**
+ * Get the ECS registry.
+ */
+ getRegistry(): Registry {
+ return this.registry;
+ }
+
+ /**
+ * Get the system group.
+ */
+ getSystems(): SystemGroup {
+ return this.systems;
+ }
+
+ /**
+ * Get the window width.
+ */
+ getWidth(): number {
+ return this.config.width;
+ }
+
+ /**
+ * Get the window height.
+ */
+ getHeight(): number {
+ return this.config.height;
+ }
+
+ /**
+ * Get the time since last frame.
+ */
+ getDeltaTime(): number {
+ return this.deltaTime;
+ }
+
+ /**
+ * Check if the application is running.
+ */
+ isRunning(): boolean {
+ return this.running;
+ }
+
+ /**
+ * Check if using WASM renderer.
+ */
+ isUsingWasm(): boolean {
+ return this.rendererMode === RendererMode.Wasm && isWasmLoaded();
+ }
+
+ // ========== Lifecycle Methods (Override in subclass) ==========
+
+ /**
+ * Called once when the application initializes.
+ */
+ protected onInit(): void {}
+
+ /**
+ * Called every frame to update game logic.
+ */
+ protected onUpdate(deltaTime: number): void {}
+
+ /**
+ * Called every frame to render the game.
+ */
+ protected onRender(): void {}
+
+ /**
+ * Called when the application shuts down.
+ */
+ protected onShutdown(): void {}
+
+ /**
+ * Called when a touch event occurs.
+ */
+ protected onTouch(type: TouchType, point: TouchPoint): void {}
+
+ /**
+ * Called when a key event occurs.
+ */
+ protected onKey(key: KeyCode, pressed: boolean): void {}
+
+ /**
+ * Called when the window is resized.
+ */
+ protected onResize(width: number, height: number): void {}
+
+ // ========== Private Methods ==========
+
+ private gameLoop = (): void => {
+ if (!this.running) {
+ this.shutdown();
+ return;
+ }
+
+ // Poll events and update timing
+ this.platform.pollEvents();
+ this.deltaTime = this.platform.getDeltaTime();
+
+ // Update input state
+ Input.update();
+
+ // Begin frame
+ Renderer.beginFrame();
+
+ // Update systems
+ this.systems.update(this.registry, this.deltaTime);
+
+ // Update game
+ this.onUpdate(this.deltaTime);
+
+ // Render game
+ this.onRender();
+
+ // End frame
+ Renderer.endFrame();
+
+ // Swap buffers
+ this.platform.swapBuffers();
+
+ // Request next frame
+ if (typeof requestAnimationFrame !== 'undefined') {
+ this.animationFrameId = requestAnimationFrame(this.gameLoop);
+ } else {
+ // Fallback for environments without requestAnimationFrame
+ setTimeout(this.gameLoop, 16);
+ }
+ };
+
+ private shutdown(): void {
+ // Cancel animation frame
+ if (this.animationFrameId) {
+ cancelAnimationFrame(this.animationFrameId);
+ }
+
+ // Call user shutdown
+ this.onShutdown();
+
+ // Shutdown systems
+ this.systems.shutdown(this.registry);
+
+ // Shutdown renderer
+ Renderer.shutdown();
+
+ // Shutdown input
+ Input.shutdown();
+
+ // Shutdown platform
+ this.platform.shutdown();
+
+ // Clear singleton
+ Application.instance = null;
+ }
+}
diff --git a/sdk/src/core/Types.ts b/sdk/src/core/Types.ts
new file mode 100644
index 000000000..bad3e041a
--- /dev/null
+++ b/sdk/src/core/Types.ts
@@ -0,0 +1,212 @@
+/**
+ * ESEngine TypeScript SDK - Core Type Definitions
+ *
+ * Provides fundamental types used throughout the engine.
+ */
+
+// Entity type - unique identifier for game objects
+export type Entity = number;
+
+// Invalid entity constant
+export const INVALID_ENTITY: Entity = 0xffffffff;
+
+// Component type identifier
+export type ComponentType = number;
+
+// 2D Vector
+export interface Vec2 {
+ x: number;
+ y: number;
+}
+
+// 3D Vector
+export interface Vec3 {
+ x: number;
+ y: number;
+ z: number;
+}
+
+// 4D Vector
+export interface Vec4 {
+ x: number;
+ y: number;
+ z: number;
+ w: number;
+}
+
+// RGBA Color (0-1 range)
+export interface Color {
+ r: number;
+ g: number;
+ b: number;
+ a: number;
+}
+
+// Matrix 4x4 (column-major, compatible with WebGL)
+export type Mat4 = Float32Array;
+
+// Touch event types
+export enum TouchType {
+ Begin = 0,
+ Move = 1,
+ End = 2,
+ Cancel = 3,
+}
+
+// Touch point data
+export interface TouchPoint {
+ id: number;
+ x: number;
+ y: number;
+}
+
+// Keyboard key codes
+export enum KeyCode {
+ Unknown = 0,
+
+ // Special keys
+ Backspace = 8,
+ Tab = 9,
+ Enter = 13,
+ Shift = 16,
+ Control = 17,
+ Alt = 18,
+ Escape = 27,
+ Space = 32,
+
+ // Arrow keys
+ Left = 37,
+ Up = 38,
+ Right = 39,
+ Down = 40,
+
+ // Number keys
+ Digit0 = 48,
+ Digit1 = 49,
+ Digit2 = 50,
+ Digit3 = 51,
+ Digit4 = 52,
+ Digit5 = 53,
+ Digit6 = 54,
+ Digit7 = 55,
+ Digit8 = 56,
+ Digit9 = 57,
+
+ // Letter keys
+ A = 65,
+ B = 66,
+ C = 67,
+ D = 68,
+ E = 69,
+ F = 70,
+ G = 71,
+ H = 72,
+ I = 73,
+ J = 74,
+ K = 75,
+ L = 76,
+ M = 77,
+ N = 78,
+ O = 79,
+ P = 80,
+ Q = 81,
+ R = 82,
+ S = 83,
+ T = 84,
+ U = 85,
+ V = 86,
+ W = 87,
+ X = 88,
+ Y = 89,
+ Z = 90,
+}
+
+// Renderer mode
+export enum RendererBackend {
+ /** Use C++ WASM backend (recommended for production) */
+ Wasm = 'wasm',
+ /** Use pure TypeScript/WebGL (fallback, no WASM required) */
+ Native = 'native',
+}
+
+// Application configuration
+export interface ApplicationConfig {
+ title?: string;
+ width?: number;
+ height?: number;
+ canvas?: HTMLCanvasElement | string;
+ vsync?: boolean;
+ /** Path to WASM module (e.g., 'esengine.js'). Required for Wasm backend. */
+ wasmPath?: string;
+ /** Renderer backend. Defaults to Wasm if wasmPath is provided, otherwise Native. */
+ renderer?: RendererBackend;
+}
+
+// Renderer statistics
+export interface RendererStats {
+ drawCalls: number;
+ triangleCount: number;
+ vertexCount: number;
+}
+
+// Utility functions for creating vectors and colors
+export function vec2(x: number = 0, y: number = 0): Vec2 {
+ return { x, y };
+}
+
+export function vec3(x: number = 0, y: number = 0, z: number = 0): Vec3 {
+ return { x, y, z };
+}
+
+export function vec4(
+ x: number = 0,
+ y: number = 0,
+ z: number = 0,
+ w: number = 0
+): Vec4 {
+ return { x, y, z, w };
+}
+
+export function color(
+ r: number = 1,
+ g: number = 1,
+ b: number = 1,
+ a: number = 1
+): Color {
+ return { r, g, b, a };
+}
+
+// Create identity matrix
+export function mat4Identity(): Mat4 {
+ const m = new Float32Array(16);
+ m[0] = 1;
+ m[5] = 1;
+ m[10] = 1;
+ m[15] = 1;
+ return m;
+}
+
+// Create orthographic projection matrix
+export function mat4Ortho(
+ left: number,
+ right: number,
+ bottom: number,
+ top: number,
+ near: number,
+ far: number
+): Mat4 {
+ const m = new Float32Array(16);
+ const lr = 1 / (left - right);
+ const bt = 1 / (bottom - top);
+ const nf = 1 / (near - far);
+
+ m[0] = -2 * lr;
+ m[5] = -2 * bt;
+ m[10] = 2 * nf;
+ m[12] = (left + right) * lr;
+ m[13] = (top + bottom) * bt;
+ m[14] = (far + near) * nf;
+ m[15] = 1;
+
+ return m;
+}
diff --git a/sdk/src/core/WasmBridge.ts b/sdk/src/core/WasmBridge.ts
new file mode 100644
index 000000000..c1158ca7f
--- /dev/null
+++ b/sdk/src/core/WasmBridge.ts
@@ -0,0 +1,221 @@
+/**
+ * ESEngine TypeScript SDK - WASM Bridge
+ *
+ * Provides interface for interacting with the C++ WASM module.
+ */
+
+/**
+ * ESEngine WASM Module interface.
+ * Defines the functions exported from the C++ code.
+ */
+export interface ESEngineModule {
+ // Memory management
+ HEAPF32: Float32Array;
+ HEAPU8: Uint8Array;
+ HEAPU32: Uint32Array;
+ _malloc(size: number): number;
+ _free(ptr: number): void;
+
+ // Core lifecycle
+ _es_init(width: number, height: number): void;
+ _es_update(deltaTime: number): void;
+ _es_render(): void;
+ _es_shutdown(): void;
+
+ // Input handling
+ _es_on_touch(type: number, x: number, y: number): void;
+ _es_on_key?(keyCode: number, pressed: number): void;
+
+ // Renderer
+ _es_renderer_clear?(r: number, g: number, b: number, a: number): void;
+ _es_renderer_begin_scene?(vpMatrixPtr: number): void;
+ _es_renderer_end_scene?(): void;
+ _es_renderer_draw_quad?(
+ x: number,
+ y: number,
+ w: number,
+ h: number,
+ r: number,
+ g: number,
+ b: number,
+ a: number
+ ): void;
+ _es_renderer_draw_quad_textured?(
+ x: number,
+ y: number,
+ w: number,
+ h: number,
+ texId: number,
+ r: number,
+ g: number,
+ b: number,
+ a: number
+ ): void;
+
+ // Emscripten canvas/context
+ canvas?: HTMLCanvasElement;
+
+ // Runtime methods
+ ccall(
+ name: string,
+ returnType: string | null,
+ argTypes: string[],
+ args: unknown[]
+ ): unknown;
+ cwrap(
+ name: string,
+ returnType: string | null,
+ argTypes: string[]
+ ): (...args: unknown[]) => unknown;
+}
+
+/**
+ * WASM load options.
+ */
+export interface WasmLoadOptions {
+ canvas: HTMLCanvasElement;
+ width: number;
+ height: number;
+}
+
+/**
+ * Global reference to the loaded WASM module.
+ */
+let wasmModule: ESEngineModule | null = null;
+
+/**
+ * Check if WASM module is loaded.
+ */
+export function isWasmLoaded(): boolean {
+ return wasmModule !== null;
+}
+
+/**
+ * Get the loaded WASM module.
+ * Throws if module is not loaded.
+ */
+export function getWasmModule(): ESEngineModule {
+ if (!wasmModule) {
+ throw new Error('WASM module not loaded. Call loadWasmModule first.');
+ }
+ return wasmModule;
+}
+
+/**
+ * Set the WASM module reference.
+ * Called when the module is loaded externally.
+ */
+export function setWasmModule(module: ESEngineModule): void {
+ wasmModule = module;
+}
+
+/**
+ * Load the WASM module from the specified path.
+ *
+ * @param wasmPath Path to the .js loader file (e.g., 'esengine.js')
+ * @param options Canvas and dimensions for WebGL context
+ * @returns Promise that resolves to the loaded module
+ */
+export async function loadWasmModule(
+ wasmPath: string,
+ options?: WasmLoadOptions
+): Promise<ESEngineModule> {
+ if (wasmModule) {
+ return wasmModule;
+ }
+
+ return new Promise((resolve, reject) => {
+ // Create Module configuration
+ // Emscripten will add exports like _malloc, _free to this object
+ const moduleConfig: Partial<ESEngineModule> & Record<string, unknown> = {
+ // Pass canvas element to Emscripten so it can create WebGL context
+ canvas: options?.canvas,
+ locateFile: (path: string) => {
+ // Handle .wasm file location
+ if (path.endsWith('.wasm')) {
+ const basePath = wasmPath.substring(0, wasmPath.lastIndexOf('/') + 1);
+ return basePath + path;
+ }
+ return path;
+ },
+ print: (text: string) => console.log('[ESEngine C++]', text),
+ printErr: (text: string) => console.error('[ESEngine C++]', text),
+ };
+
+ // onRuntimeInitialized is called after all exports are attached to moduleConfig
+ moduleConfig.onRuntimeInitialized = () => {
+ // moduleConfig now has _malloc, _free, etc. attached by Emscripten
+ wasmModule = moduleConfig as ESEngineModule;
+
+ // Initialize C++ renderer if options provided
+ if (options && wasmModule._es_init) {
+ wasmModule._es_init(options.width, options.height);
+ }
+
+ resolve(wasmModule);
+ };
+
+ // Set global Module before loading script
+ (window as unknown as { Module: unknown }).Module = moduleConfig;
+
+ // Load the WASM loader script
+ const script = document.createElement('script');
+ script.src = wasmPath;
+ script.onerror = () => reject(new Error(`Failed to load WASM module: ${wasmPath}`));
+ document.head.appendChild(script);
+ });
+}
+
+/**
+ * Initialize C++ renderer (call after WASM is loaded).
+ */
+export function initWasmRenderer(width: number, height: number): void {
+ const module = getWasmModule();
+ if (module._es_init) {
+ module._es_init(width, height);
+ }
+}
+
+/**
+ * Allocate memory in WASM heap and copy a Float32Array.
+ */
+export function allocFloat32Array(data: Float32Array): number {
+ const module = getWasmModule();
+ const ptr = module._malloc(data.length * 4);
+ module.HEAPF32.set(data, ptr >> 2);
+ return ptr;
+}
+
+/**
+ * Allocate memory in WASM heap and copy a Uint8Array.
+ */
+export function allocUint8Array(data: Uint8Array): number {
+ const module = getWasmModule();
+ const ptr = module._malloc(data.length);
+ module.HEAPU8.set(data, ptr);
+ return ptr;
+}
+
+/**
+ * Free previously allocated WASM memory.
+ */
+export function freePtr(ptr: number): void {
+ if (ptr && wasmModule) {
+ wasmModule._free(ptr);
+ }
+}
+
+/**
+ * Execute a callback with a temporary Float32Array allocation.
+ */
+export function withFloat32Array<T>(
+ data: Float32Array,
+ callback: (ptr: number) => T
+): T {
+ const ptr = allocFloat32Array(data);
+ try {
+ return callback(ptr);
+ } finally {
+ freePtr(ptr);
+ }
+}
diff --git a/sdk/src/ecs/Components.ts b/sdk/src/ecs/Components.ts
new file mode 100644
index 000000000..e3303af27
--- /dev/null
+++ b/sdk/src/ecs/Components.ts
@@ -0,0 +1,143 @@
+/**
+ * ESEngine TypeScript SDK - Built-in Components
+ *
+ * Provides standard component types for common game functionality.
+ */
+
+import { Vec2, Vec3, Color, color, vec3 } from '../core/Types';
+
+/**
+ * Transform component - Position, rotation, and scale in world space.
+ */
+export interface Transform {
+ position: Vec3;
+ rotation: Vec3; // Euler angles in radians
+ scale: Vec3;
+}
+
+/**
+ * Create a new Transform with default values.
+ */
+export function createTransform(
+ position: Partial<Vec3> = {},
+ rotation: Partial<Vec3> = {},
+ scale: Partial<Vec3> = {}
+): Transform {
+ return {
+ position: { x: position.x ?? 0, y: position.y ?? 0, z: position.z ?? 0 },
+ rotation: { x: rotation.x ?? 0, y: rotation.y ?? 0, z: rotation.z ?? 0 },
+ scale: { x: scale.x ?? 1, y: scale.y ?? 1, z: scale.z ?? 1 },
+ };
+}
+
+/**
+ * Velocity component - Linear and angular velocity.
+ */
+export interface Velocity {
+ linear: Vec3; // Units per second
+ angular: Vec3; // Radians per second
+}
+
+/**
+ * Create a new Velocity with default values.
+ */
+export function createVelocity(
+ linear: Partial<Vec3> = {},
+ angular: Partial<Vec3> = {}
+): Velocity {
+ return {
+ linear: { x: linear.x ?? 0, y: linear.y ?? 0, z: linear.z ?? 0 },
+ angular: { x: angular.x ?? 0, y: angular.y ?? 0, z: angular.z ?? 0 },
+ };
+}
+
+/**
+ * Sprite component - Visual representation for 2D rendering.
+ */
+export interface Sprite {
+ textureId: number;
+ color: Color;
+ size: Vec2;
+ uvOffset: Vec2;
+ uvScale: Vec2;
+ layer: number;
+}
+
+/**
+ * Create a new Sprite with default values.
+ */
+export function createSprite(
+ textureId: number = 0,
+ options: {
+ color?: Partial<Color>;
+ size?: Partial<Vec2>;
+ uvOffset?: Partial<Vec2>;
+ uvScale?: Partial<Vec2>;
+ layer?: number;
+ } = {}
+): Sprite {
+ return {
+ textureId,
+ color: {
+ r: options.color?.r ?? 1,
+ g: options.color?.g ?? 1,
+ b: options.color?.b ?? 1,
+ a: options.color?.a ?? 1,
+ },
+ size: { x: options.size?.x ?? 1, y: options.size?.y ?? 1 },
+ uvOffset: { x: options.uvOffset?.x ?? 0, y: options.uvOffset?.y ?? 0 },
+ uvScale: { x: options.uvScale?.x ?? 1, y: options.uvScale?.y ?? 1 },
+ layer: options.layer ?? 0,
+ };
+}
+
+/**
+ * Name component - Human-readable identifier.
+ */
+export interface Name {
+ value: string;
+}
+
+/**
+ * Create a new Name component.
+ */
+export function createName(value: string): Name {
+ return { value };
+}
+
+/**
+ * Tag components - Empty marker components for filtering.
+ */
+export interface Active {}
+export interface Visible {}
+export interface Static {}
+
+/**
+ * Create an Active tag.
+ */
+export function createActive(): Active {
+ return {};
+}
+
+/**
+ * Create a Visible tag.
+ */
+export function createVisible(): Visible {
+ return {};
+}
+
+/**
+ * Create a Static tag.
+ */
+export function createStatic(): Static {
+ return {};
+}
+
+// Component type symbols for type identification
+export const TransformType = Symbol('Transform');
+export const VelocityType = Symbol('Velocity');
+export const SpriteType = Symbol('Sprite');
+export const NameType = Symbol('Name');
+export const ActiveType = Symbol('Active');
+export const VisibleType = Symbol('Visible');
+export const StaticType = Symbol('Static');
diff --git a/sdk/src/ecs/Entity.ts b/sdk/src/ecs/Entity.ts
new file mode 100644
index 000000000..8406ab97d
--- /dev/null
+++ b/sdk/src/ecs/Entity.ts
@@ -0,0 +1,44 @@
+/**
+ * ESEngine TypeScript SDK - Entity Management
+ *
+ * Provides entity creation and validation utilities.
+ */
+
+import { Entity, INVALID_ENTITY } from '../core/Types';
+
+// Entity ID generation
+let nextEntityId: Entity = 0;
+const recycledIds: Entity[] = [];
+
+/**
+ * Generate a new entity ID.
+ * Reuses recycled IDs when available.
+ */
+export function generateEntityId(): Entity {
+ if (recycledIds.length > 0) {
+ return recycledIds.pop()!;
+ }
+ return nextEntityId++;
+}
+
+/**
+ * Recycle an entity ID for reuse.
+ */
+export function recycleEntityId(entity: Entity): void {
+ recycledIds.push(entity);
+}
+
+/**
+ * Check if an entity ID is valid (not INVALID_ENTITY).
+ */
+export function isValidEntity(entity: Entity): boolean {
+ return entity !== INVALID_ENTITY;
+}
+
+/**
+ * Reset entity ID generation (for testing).
+ */
+export function resetEntityIds(): void {
+ nextEntityId = 0;
+ recycledIds.length = 0;
+}
diff --git a/sdk/src/ecs/Registry.ts b/sdk/src/ecs/Registry.ts
new file mode 100644
index 000000000..0bcee1f05
--- /dev/null
+++ b/sdk/src/ecs/Registry.ts
@@ -0,0 +1,314 @@
+/**
+ * ESEngine TypeScript SDK - ECS Registry
+ *
+ * Central registry for managing entities and components.
+ * Uses sparse set storage for efficient component access.
+ */
+
+import { Entity, INVALID_ENTITY } from '../core/Types';
+import { generateEntityId, recycleEntityId, isValidEntity } from './Entity';
+import { View, View2, View3, View4 } from './View';
+
+// Component pool type
+type ComponentPool<T> = Map<Entity, T>;
+
+// Component type identifier
+type ComponentKey = symbol | string;
+
+/**
+ * Registry - Central manager for entities and components.
+ */
+export class Registry {
+ private entities: Set<Entity> = new Set();
+ private componentPools: Map<ComponentKey, ComponentPool<unknown>> = new Map();
+ private entityComponents: Map<Entity, Set<ComponentKey>> = new Map();
+
+ /**
+ * Create a new entity.
+ */
+ create(): Entity {
+ const entity = generateEntityId();
+ this.entities.add(entity);
+ this.entityComponents.set(entity, new Set());
+ return entity;
+ }
+
+ /**
+ * Create multiple entities at once.
+ */
+ createMany(count: number): Entity[] {
+ const entities: Entity[] = [];
+ for (let i = 0; i < count; i++) {
+ entities.push(this.create());
+ }
+ return entities;
+ }
+
+ /**
+ * Destroy an entity and all its components.
+ */
+ destroy(entity: Entity): void {
+ if (!this.valid(entity)) return;
+
+ // Remove all components
+ const components = this.entityComponents.get(entity);
+ if (components) {
+ for (const key of components) {
+ const pool = this.componentPools.get(key);
+ if (pool) {
+ pool.delete(entity);
+ }
+ }
+ }
+
+ // Remove entity
+ this.entities.delete(entity);
+ this.entityComponents.delete(entity);
+ recycleEntityId(entity);
+ }
+
+ /**
+ * Check if an entity is valid (exists in the registry).
+ */
+ valid(entity: Entity): boolean {
+ return isValidEntity(entity) && this.entities.has(entity);
+ }
+
+ /**
+ * Get the number of entities in the registry.
+ */
+ entityCount(): number {
+ return this.entities.size;
+ }
+
+ /**
+ * Add a component to an entity.
+ *
+ * @param entity The entity to add the component to
+ * @param key The component type identifier (symbol or string)
+ * @param component The component data
+ * @returns The component that was added
+ */
+ emplace<T>(entity: Entity, key: ComponentKey, component: T): T {
+ if (!this.valid(entity)) {
+ throw new Error(`Cannot add component to invalid entity: ${entity}`);
+ }
+
+ let pool = this.componentPools.get(key) as ComponentPool<T> | undefined;
+ if (!pool) {
+ pool = new Map<Entity, T>();
+ this.componentPools.set(key, pool as ComponentPool<unknown>);
+ }
+
+ pool.set(entity, component);
+ this.entityComponents.get(entity)!.add(key);
+
+ return component;
+ }
+
+ /**
+ * Add or replace a component on an entity.
+ */
+ emplaceOrReplace<T>(entity: Entity, key: ComponentKey, component: T): T {
+ return this.emplace(entity, key, component);
+ }
+
+ /**
+ * Remove a component from an entity.
+ */
+ remove(entity: Entity, key: ComponentKey): void {
+ if (!this.valid(entity)) return;
+
+ const pool = this.componentPools.get(key);
+ if (pool) {
+ pool.delete(entity);
+ }
+
+ const components = this.entityComponents.get(entity);
+ if (components) {
+ components.delete(key);
+ }
+ }
+
+ /**
+ * Get a component from an entity.
+ * Throws if the entity doesn't have the component.
+ */
+ get<T>(entity: Entity, key: ComponentKey): T {
+ const component = this.tryGet<T>(entity, key);
+ if (component === undefined) {
+ throw new Error(
+ `Entity ${entity} does not have component: ${String(key)}`
+ );
+ }
+ return component;
+ }
+
+ /**
+ * Try to get a component from an entity.
+ * Returns undefined if the entity doesn't have the component.
+ */
+ tryGet<T>(entity: Entity, key: ComponentKey): T | undefined {
+ if (!this.valid(entity)) return undefined;
+
+ const pool = this.componentPools.get(key) as ComponentPool<T> | undefined;
+ if (!pool) return undefined;
+
+ return pool.get(entity);
+ }
+
+ /**
+ * Get a component or add it if it doesn't exist.
+ */
+ getOrEmplace<T>(
+ entity: Entity,
+ key: ComponentKey,
+ defaultComponent: T
+ ): T {
+ const existing = this.tryGet<T>(entity, key);
+ if (existing !== undefined) {
+ return existing;
+ }
+ return this.emplace(entity, key, defaultComponent);
+ }
+
+ /**
+ * Check if an entity has a component.
+ */
+ has(entity: Entity, key: ComponentKey): boolean {
+ if (!this.valid(entity)) return false;
+
+ const pool = this.componentPools.get(key);
+ return pool !== undefined && pool.has(entity);
+ }
+
+ /**
+ * Check if an entity has all of the specified components.
+ */
+ hasAll(entity: Entity, ...keys: ComponentKey[]): boolean {
+ return keys.every((key) => this.has(entity, key));
+ }
+
+ /**
+ * Check if an entity has any of the specified components.
+ */
+ hasAny(entity: Entity, ...keys: ComponentKey[]): boolean {
+ return keys.some((key) => this.has(entity, key));
+ }
+
+ /**
+ * Create a view for entities with a single component.
+ */
+ view<T>(key: ComponentKey): View<T> {
+ const pool = this.getOrCreatePool<T>(key);
+ const entities = new Set<Entity>();
+
+ for (const entity of this.entities) {
+ if (pool.has(entity)) {
+ entities.add(entity);
+ }
+ }
+
+ return new View(pool, entities);
+ }
+
+ /**
+ * Create a view for entities with two components.
+ */
+ view2<T1, T2>(key1: ComponentKey, key2: ComponentKey): View2<T1, T2> {
+ const pool1 = this.getOrCreatePool<T1>(key1);
+ const pool2 = this.getOrCreatePool<T2>(key2);
+ const entities = new Set<Entity>();
+
+ for (const entity of this.entities) {
+ if (pool1.has(entity) && pool2.has(entity)) {
+ entities.add(entity);
+ }
+ }
+
+ return new View2(pool1, pool2, entities);
+ }
+
+ /**
+ * Create a view for entities with three components.
+ */
+ view3<T1, T2, T3>(
+ key1: ComponentKey,
+ key2: ComponentKey,
+ key3: ComponentKey
+ ): View3<T1, T2, T3> {
+ const pool1 = this.getOrCreatePool<T1>(key1);
+ const pool2 = this.getOrCreatePool<T2>(key2);
+ const pool3 = this.getOrCreatePool<T3>(key3);
+ const entities = new Set<Entity>();
+
+ for (const entity of this.entities) {
+ if (pool1.has(entity) && pool2.has(entity) && pool3.has(entity)) {
+ entities.add(entity);
+ }
+ }
+
+ return new View3(pool1, pool2, pool3, entities);
+ }
+
+ /**
+ * Create a view for entities with four components.
+ */
+ view4<T1, T2, T3, T4>(
+ key1: ComponentKey,
+ key2: ComponentKey,
+ key3: ComponentKey,
+ key4: ComponentKey
+ ): View4<T1, T2, T3, T4> {
+ const pool1 = this.getOrCreatePool<T1>(key1);
+ const pool2 = this.getOrCreatePool<T2>(key2);
+ const pool3 = this.getOrCreatePool<T3>(key3);
+ const pool4 = this.getOrCreatePool<T4>(key4);
+ const entities = new Set<Entity>();
+
+ for (const entity of this.entities) {
+ if (
+ pool1.has(entity) &&
+ pool2.has(entity) &&
+ pool3.has(entity) &&
+ pool4.has(entity)
+ ) {
+ entities.add(entity);
+ }
+ }
+
+ return new View4(pool1, pool2, pool3, pool4, entities);
+ }
+
+ /**
+ * Execute a callback for each entity with the specified component.
+ */
+ each<T>(key: ComponentKey, callback: (entity: Entity, component: T) => void): void {
+ this.view<T>(key).each(callback);
+ }
+
+ /**
+ * Clear all entities and components.
+ */
+ clear(): void {
+ this.entities.clear();
+ this.componentPools.clear();
+ this.entityComponents.clear();
+ }
+
+ /**
+ * Get all entities in the registry.
+ */
+ getAllEntities(): Entity[] {
+ return Array.from(this.entities);
+ }
+
+ private getOrCreatePool<T>(key: ComponentKey): ComponentPool<T> {
+ let pool = this.componentPools.get(key) as ComponentPool<T> | undefined;
+ if (!pool) {
+ pool = new Map<Entity, T>();
+ this.componentPools.set(key, pool as ComponentPool<unknown>);
+ }
+ return pool;
+ }
+}
diff --git a/sdk/src/ecs/System.ts b/sdk/src/ecs/System.ts
new file mode 100644
index 000000000..d46f9688c
--- /dev/null
+++ b/sdk/src/ecs/System.ts
@@ -0,0 +1,152 @@
+/**
+ * ESEngine TypeScript SDK - System Management
+ *
+ * Provides base classes for game systems and system groups.
+ */
+
+import { Registry } from './Registry';
+
+/**
+ * System base class - Override to create game systems.
+ */
+export abstract class System {
+ private enabled: boolean = true;
+ private priority: number = 0;
+
+ /**
+ * Called when the system is initialized.
+ */
+ init(registry: Registry): void {}
+
+ /**
+ * Called every frame to update game state.
+ */
+ abstract update(registry: Registry, deltaTime: number): void;
+
+ /**
+ * Called when the system is shut down.
+ */
+ shutdown(registry: Registry): void {}
+
+ /**
+ * Enable or disable the system.
+ */
+ setEnabled(enabled: boolean): void {
+ this.enabled = enabled;
+ }
+
+ /**
+ * Check if the system is enabled.
+ */
+ isEnabled(): boolean {
+ return this.enabled;
+ }
+
+ /**
+ * Set the system priority (higher = runs first).
+ */
+ setPriority(priority: number): void {
+ this.priority = priority;
+ }
+
+ /**
+ * Get the system priority.
+ */
+ getPriority(): number {
+ return this.priority;
+ }
+}
+
+/**
+ * SystemGroup - Manages a collection of systems.
+ */
+export class SystemGroup {
+ private systems: System[] = [];
+ private initialized: boolean = false;
+
+ /**
+ * Add a system to the group.
+ */
+ addSystem(system: System): void {
+ this.systems.push(system);
+ this.sortSystems();
+ }
+
+ /**
+ * Create and add a system to the group.
+ */
+ createSystem<T extends System>(
+ SystemClass: new (...args: unknown[]) => T,
+ ...args: unknown[]
+ ): T {
+ const system = new SystemClass(...args);
+ this.addSystem(system);
+ return system;
+ }
+
+ /**
+ * Remove a system from the group.
+ */
+ removeSystem(system: System): boolean {
+ const index = this.systems.indexOf(system);
+ if (index !== -1) {
+ this.systems.splice(index, 1);
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Initialize all systems in the group.
+ */
+ init(registry: Registry): void {
+ if (this.initialized) return;
+
+ for (const system of this.systems) {
+ system.init(registry);
+ }
+ this.initialized = true;
+ }
+
+ /**
+ * Update all enabled systems in the group.
+ */
+ update(registry: Registry, deltaTime: number): void {
+ for (const system of this.systems) {
+ if (system.isEnabled()) {
+ system.update(registry, deltaTime);
+ }
+ }
+ }
+
+ /**
+ * Shut down all systems in the group.
+ */
+ shutdown(registry: Registry): void {
+ if (!this.initialized) return;
+
+ // Shutdown in reverse order
+ for (let i = this.systems.length - 1; i >= 0; i--) {
+ this.systems[i].shutdown(registry);
+ }
+ this.initialized = false;
+ }
+
+ /**
+ * Get all systems in the group.
+ */
+ getSystems(): readonly System[] {
+ return this.systems;
+ }
+
+ /**
+ * Get the number of systems in the group.
+ */
+ getSystemCount(): number {
+ return this.systems.length;
+ }
+
+ private sortSystems(): void {
+ this.systems.sort((a, b) => b.getPriority() - a.getPriority());
+ }
+}
diff --git a/sdk/src/ecs/View.ts b/sdk/src/ecs/View.ts
new file mode 100644
index 000000000..323de71c3
--- /dev/null
+++ b/sdk/src/ecs/View.ts
@@ -0,0 +1,275 @@
+/**
+ * ESEngine TypeScript SDK - Component View
+ *
+ * Provides efficient querying and iteration over entities with specific components.
+ */
+
+import { Entity } from '../core/Types';
+
+// Component storage type
+type ComponentPool<T> = Map<Entity, T>;
+
+/**
+ * View for querying entities with a single component type.
+ */
+export class View<T> {
+ private pool: ComponentPool<T>;
+ private entities: Set<Entity>;
+
+ constructor(pool: ComponentPool<T>, entities: Set<Entity>) {
+ this.pool = pool;
+ this.entities = entities;
+ }
+
+ /**
+ * Iterate over all entities in the view.
+ */
+ *[Symbol.iterator](): Iterator<[Entity, T]> {
+ for (const entity of this.entities) {
+ const component = this.pool.get(entity);
+ if (component !== undefined) {
+ yield [entity, component];
+ }
+ }
+ }
+
+ /**
+ * Execute a callback for each entity in the view.
+ */
+ each(callback: (entity: Entity, component: T) => void): void {
+ for (const [entity, component] of this) {
+ callback(entity, component);
+ }
+ }
+
+ /**
+ * Check if the view is empty.
+ */
+ empty(): boolean {
+ return this.entities.size === 0;
+ }
+
+ /**
+ * Get the number of entities in the view (hint, may be inaccurate).
+ */
+ sizeHint(): number {
+ return this.entities.size;
+ }
+
+ /**
+ * Get component for a specific entity.
+ */
+ get(entity: Entity): T | undefined {
+ return this.pool.get(entity);
+ }
+}
+
+/**
+ * View for querying entities with two component types.
+ */
+export class View2<T1, T2> {
+ private pool1: ComponentPool<T1>;
+ private pool2: ComponentPool<T2>;
+ private entities: Set<Entity>;
+
+ constructor(
+ pool1: ComponentPool<T1>,
+ pool2: ComponentPool<T2>,
+ entities: Set<Entity>
+ ) {
+ this.pool1 = pool1;
+ this.pool2 = pool2;
+ this.entities = entities;
+ }
+
+ /**
+ * Iterate over all entities in the view.
+ */
+ *[Symbol.iterator](): Iterator<[Entity, T1, T2]> {
+ for (const entity of this.entities) {
+ const c1 = this.pool1.get(entity);
+ const c2 = this.pool2.get(entity);
+ if (c1 !== undefined && c2 !== undefined) {
+ yield [entity, c1, c2];
+ }
+ }
+ }
+
+ /**
+ * Execute a callback for each entity in the view.
+ */
+ each(callback: (entity: Entity, c1: T1, c2: T2) => void): void {
+ for (const [entity, c1, c2] of this) {
+ callback(entity, c1, c2);
+ }
+ }
+
+ /**
+ * Check if the view is empty.
+ */
+ empty(): boolean {
+ return this.sizeHint() === 0;
+ }
+
+ /**
+ * Get the number of entities in the view (hint, may be inaccurate).
+ */
+ sizeHint(): number {
+ // Return the minimum of both pools
+ let count = 0;
+ for (const entity of this.entities) {
+ if (this.pool1.has(entity) && this.pool2.has(entity)) {
+ count++;
+ }
+ }
+ return count;
+ }
+}
+
+/**
+ * View for querying entities with three component types.
+ */
+export class View3<T1, T2, T3> {
+ private pool1: ComponentPool<T1>;
+ private pool2: ComponentPool<T2>;
+ private pool3: ComponentPool<T3>;
+ private entities: Set<Entity>;
+
+ constructor(
+ pool1: ComponentPool<T1>,
+ pool2: ComponentPool<T2>,
+ pool3: ComponentPool<T3>,
+ entities: Set<Entity>
+ ) {
+ this.pool1 = pool1;
+ this.pool2 = pool2;
+ this.pool3 = pool3;
+ this.entities = entities;
+ }
+
+ /**
+ * Iterate over all entities in the view.
+ */
+ *[Symbol.iterator](): Iterator<[Entity, T1, T2, T3]> {
+ for (const entity of this.entities) {
+ const c1 = this.pool1.get(entity);
+ const c2 = this.pool2.get(entity);
+ const c3 = this.pool3.get(entity);
+ if (c1 !== undefined && c2 !== undefined && c3 !== undefined) {
+ yield [entity, c1, c2, c3];
+ }
+ }
+ }
+
+ /**
+ * Execute a callback for each entity in the view.
+ */
+ each(callback: (entity: Entity, c1: T1, c2: T2, c3: T3) => void): void {
+ for (const [entity, c1, c2, c3] of this) {
+ callback(entity, c1, c2, c3);
+ }
+ }
+
+ /**
+ * Check if the view is empty.
+ */
+ empty(): boolean {
+ return this.sizeHint() === 0;
+ }
+
+ /**
+ * Get the number of entities in the view (hint, may be inaccurate).
+ */
+ sizeHint(): number {
+ let count = 0;
+ for (const entity of this.entities) {
+ if (
+ this.pool1.has(entity) &&
+ this.pool2.has(entity) &&
+ this.pool3.has(entity)
+ ) {
+ count++;
+ }
+ }
+ return count;
+ }
+}
+
+/**
+ * View for querying entities with four component types.
+ */
+export class View4<T1, T2, T3, T4> {
+ private pool1: ComponentPool<T1>;
+ private pool2: ComponentPool<T2>;
+ private pool3: ComponentPool<T3>;
+ private pool4: ComponentPool<T4>;
+ private entities: Set<Entity>;
+
+ constructor(
+ pool1: ComponentPool<T1>,
+ pool2: ComponentPool<T2>,
+ pool3: ComponentPool<T3>,
+ pool4: ComponentPool<T4>,
+ entities: Set<Entity>
+ ) {
+ this.pool1 = pool1;
+ this.pool2 = pool2;
+ this.pool3 = pool3;
+ this.pool4 = pool4;
+ this.entities = entities;
+ }
+
+ /**
+ * Iterate over all entities in the view.
+ */
+ *[Symbol.iterator](): Iterator<[Entity, T1, T2, T3, T4]> {
+ for (const entity of this.entities) {
+ const c1 = this.pool1.get(entity);
+ const c2 = this.pool2.get(entity);
+ const c3 = this.pool3.get(entity);
+ const c4 = this.pool4.get(entity);
+ if (
+ c1 !== undefined &&
+ c2 !== undefined &&
+ c3 !== undefined &&
+ c4 !== undefined
+ ) {
+ yield [entity, c1, c2, c3, c4];
+ }
+ }
+ }
+
+ /**
+ * Execute a callback for each entity in the view.
+ */
+ each(callback: (entity: Entity, c1: T1, c2: T2, c3: T3, c4: T4) => void): void {
+ for (const [entity, c1, c2, c3, c4] of this) {
+ callback(entity, c1, c2, c3, c4);
+ }
+ }
+
+ /**
+ * Check if the view is empty.
+ */
+ empty(): boolean {
+ return this.sizeHint() === 0;
+ }
+
+ /**
+ * Get the number of entities in the view (hint, may be inaccurate).
+ */
+ sizeHint(): number {
+ let count = 0;
+ for (const entity of this.entities) {
+ if (
+ this.pool1.has(entity) &&
+ this.pool2.has(entity) &&
+ this.pool3.has(entity) &&
+ this.pool4.has(entity)
+ ) {
+ count++;
+ }
+ }
+ return count;
+ }
+}
diff --git a/sdk/src/index.ts b/sdk/src/index.ts
new file mode 100644
index 000000000..28543a4a9
--- /dev/null
+++ b/sdk/src/index.ts
@@ -0,0 +1,123 @@
+/**
+ * ESEngine TypeScript SDK
+ *
+ * A lightweight 2D game engine for Web and WeChat MiniGames.
+ */
+
+// Core types and utilities
+export {
+ Entity,
+ INVALID_ENTITY,
+ ComponentType,
+ Vec2,
+ Vec3,
+ Vec4,
+ Color,
+ Mat4,
+ TouchType,
+ TouchPoint,
+ KeyCode,
+ ApplicationConfig,
+ RendererStats,
+ RendererBackend,
+ vec2,
+ vec3,
+ vec4,
+ color,
+ mat4Identity,
+ mat4Ortho,
+} from './core/Types';
+
+// Application
+export { Application } from './core/Application';
+
+// WASM Bridge
+export {
+ ESEngineModule,
+ WasmLoadOptions,
+ isWasmLoaded,
+ getWasmModule,
+ setWasmModule,
+ loadWasmModule,
+ initWasmRenderer,
+ allocFloat32Array,
+ allocUint8Array,
+ freePtr,
+ withFloat32Array,
+} from './core/WasmBridge';
+
+// ECS - Entity
+export {
+ generateEntityId,
+ recycleEntityId,
+ isValidEntity,
+ resetEntityIds,
+} from './ecs/Entity';
+
+// ECS - Registry
+export { Registry } from './ecs/Registry';
+
+// ECS - Components
+export {
+ Transform,
+ Velocity,
+ Sprite,
+ Name,
+ Active,
+ Visible,
+ Static,
+ createTransform,
+ createVelocity,
+ createSprite,
+ createName,
+ createActive,
+ createVisible,
+ createStatic,
+ TransformType,
+ VelocityType,
+ SpriteType,
+ NameType,
+ ActiveType,
+ VisibleType,
+ StaticType,
+} from './ecs/Components';
+
+// ECS - View
+export { View, View2, View3, View4 } from './ecs/View';
+
+// ECS - System
+export { System, SystemGroup } from './ecs/System';
+
+// Math utilities
+export {
+ PI,
+ TWO_PI,
+ HALF_PI,
+ DEG_TO_RAD,
+ RAD_TO_DEG,
+ clamp,
+ lerp,
+ toRadians,
+ toDegrees,
+ Vec2Math,
+ Vec3Math,
+ Mat4Math,
+} from './math/Math';
+
+// Input
+export { Input } from './input/Input';
+
+// Platform
+export {
+ Platform,
+ PlatformCapabilities,
+ PlatformConfig,
+ TouchCallback,
+ KeyCallback,
+ ResizeCallback,
+} from './platform/Platform';
+export { WebPlatform } from './platform/WebPlatform';
+export { WxPlatform } from './platform/WxPlatform';
+
+// Renderer
+export { Renderer, RendererMode, DrawQuadOptions } from './renderer/Renderer';
diff --git a/sdk/src/input/Input.ts b/sdk/src/input/Input.ts
new file mode 100644
index 000000000..ba7dc5e6b
--- /dev/null
+++ b/sdk/src/input/Input.ts
@@ -0,0 +1,294 @@
+/**
+ * ESEngine TypeScript SDK - Input Management
+ *
+ * Provides unified input handling for touch and keyboard.
+ */
+
+import { Vec2, KeyCode, TouchType, TouchPoint, vec2 } from '../core/Types';
+
+// Touch state
+interface TouchState {
+ id: number;
+ position: Vec2;
+ startPosition: Vec2;
+ isDown: boolean;
+ justPressed: boolean;
+ justReleased: boolean;
+}
+
+// Key state
+interface KeyState {
+ isDown: boolean;
+ justPressed: boolean;
+ justReleased: boolean;
+}
+
+/**
+ * Input - Static class for input management.
+ */
+export class Input {
+ private static touches: Map<number, TouchState> = new Map();
+ private static keys: Map<KeyCode, KeyState> = new Map();
+ private static mousePosition: Vec2 = { x: 0, y: 0 };
+ private static mouseButtons: Map<number, KeyState> = new Map();
+ private static initialized: boolean = false;
+
+ /**
+ * Initialize the input system.
+ */
+ static init(): void {
+ if (this.initialized) return;
+ this.touches.clear();
+ this.keys.clear();
+ this.mouseButtons.clear();
+ this.initialized = true;
+ }
+
+ /**
+ * Shut down the input system.
+ */
+ static shutdown(): void {
+ this.touches.clear();
+ this.keys.clear();
+ this.mouseButtons.clear();
+ this.initialized = false;
+ }
+
+ /**
+ * Update input state. Call once per frame after processing events.
+ */
+ static update(): void {
+ // Reset "just" states for touches
+ for (const touch of this.touches.values()) {
+ touch.justPressed = false;
+ touch.justReleased = false;
+ }
+
+ // Remove released touches
+ for (const [id, touch] of this.touches) {
+ if (!touch.isDown && !touch.justReleased) {
+ this.touches.delete(id);
+ }
+ }
+
+ // Reset "just" states for keys
+ for (const key of this.keys.values()) {
+ key.justPressed = false;
+ key.justReleased = false;
+ }
+
+ // Reset "just" states for mouse buttons
+ for (const button of this.mouseButtons.values()) {
+ button.justPressed = false;
+ button.justReleased = false;
+ }
+ }
+
+ // ========== Touch Input ==========
+
+ /**
+ * Handle touch event from platform.
+ */
+ static onTouchEvent(type: TouchType, point: TouchPoint): void {
+ let touch = this.touches.get(point.id);
+
+ switch (type) {
+ case TouchType.Begin:
+ touch = {
+ id: point.id,
+ position: { x: point.x, y: point.y },
+ startPosition: { x: point.x, y: point.y },
+ isDown: true,
+ justPressed: true,
+ justReleased: false,
+ };
+ this.touches.set(point.id, touch);
+ break;
+
+ case TouchType.Move:
+ if (touch) {
+ touch.position = { x: point.x, y: point.y };
+ }
+ break;
+
+ case TouchType.End:
+ case TouchType.Cancel:
+ if (touch) {
+ touch.position = { x: point.x, y: point.y };
+ touch.isDown = false;
+ touch.justReleased = true;
+ }
+ break;
+ }
+ }
+
+ /**
+ * Check if a touch is currently down.
+ */
+ static isTouchDown(index: number = 0): boolean {
+ const touch = this.getTouchByIndex(index);
+ return touch !== undefined && touch.isDown;
+ }
+
+ /**
+ * Check if a touch just started this frame.
+ */
+ static isTouchPressed(index: number = 0): boolean {
+ const touch = this.getTouchByIndex(index);
+ return touch !== undefined && touch.justPressed;
+ }
+
+ /**
+ * Check if a touch just ended this frame.
+ */
+ static isTouchReleased(index: number = 0): boolean {
+ const touch = this.getTouchByIndex(index);
+ return touch !== undefined && touch.justReleased;
+ }
+
+ /**
+ * Get the current touch position.
+ */
+ static getTouchPosition(index: number = 0): Vec2 {
+ const touch = this.getTouchByIndex(index);
+ return touch ? { ...touch.position } : { x: 0, y: 0 };
+ }
+
+ /**
+ * Get the touch delta from start position.
+ */
+ static getTouchDelta(index: number = 0): Vec2 {
+ const touch = this.getTouchByIndex(index);
+ if (!touch) return { x: 0, y: 0 };
+ return {
+ x: touch.position.x - touch.startPosition.x,
+ y: touch.position.y - touch.startPosition.y,
+ };
+ }
+
+ /**
+ * Get the number of active touches.
+ */
+ static getTouchCount(): number {
+ let count = 0;
+ for (const touch of this.touches.values()) {
+ if (touch.isDown) count++;
+ }
+ return count;
+ }
+
+ private static getTouchByIndex(index: number): TouchState | undefined {
+ let i = 0;
+ for (const touch of this.touches.values()) {
+ if (i === index) return touch;
+ i++;
+ }
+ return undefined;
+ }
+
+ // ========== Keyboard Input ==========
+
+ /**
+ * Handle key event from platform.
+ */
+ static onKeyEvent(key: KeyCode, pressed: boolean): void {
+ let state = this.keys.get(key);
+
+ if (!state) {
+ state = { isDown: false, justPressed: false, justReleased: false };
+ this.keys.set(key, state);
+ }
+
+ if (pressed && !state.isDown) {
+ state.isDown = true;
+ state.justPressed = true;
+ } else if (!pressed && state.isDown) {
+ state.isDown = false;
+ state.justReleased = true;
+ }
+ }
+
+ /**
+ * Check if a key is currently down.
+ */
+ static isKeyDown(key: KeyCode): boolean {
+ const state = this.keys.get(key);
+ return state !== undefined && state.isDown;
+ }
+
+ /**
+ * Check if a key was just pressed this frame.
+ */
+ static isKeyPressed(key: KeyCode): boolean {
+ const state = this.keys.get(key);
+ return state !== undefined && state.justPressed;
+ }
+
+ /**
+ * Check if a key was just released this frame.
+ */
+ static isKeyReleased(key: KeyCode): boolean {
+ const state = this.keys.get(key);
+ return state !== undefined && state.justReleased;
+ }
+
+ // ========== Mouse Input ==========
+
+ /**
+ * Handle mouse move event from platform.
+ */
+ static onMouseMove(x: number, y: number): void {
+ this.mousePosition = { x, y };
+ }
+
+ /**
+ * Handle mouse button event from platform.
+ */
+ static onMouseButton(button: number, pressed: boolean): void {
+ let state = this.mouseButtons.get(button);
+
+ if (!state) {
+ state = { isDown: false, justPressed: false, justReleased: false };
+ this.mouseButtons.set(button, state);
+ }
+
+ if (pressed && !state.isDown) {
+ state.isDown = true;
+ state.justPressed = true;
+ } else if (!pressed && state.isDown) {
+ state.isDown = false;
+ state.justReleased = true;
+ }
+ }
+
+ /**
+ * Get the current mouse position.
+ */
+ static getMousePosition(): Vec2 {
+ return { ...this.mousePosition };
+ }
+
+ /**
+ * Check if a mouse button is currently down.
+ */
+ static isMouseButtonDown(button: number = 0): boolean {
+ const state = this.mouseButtons.get(button);
+ return state !== undefined && state.isDown;
+ }
+
+ /**
+ * Check if a mouse button was just pressed.
+ */
+ static isMouseButtonPressed(button: number = 0): boolean {
+ const state = this.mouseButtons.get(button);
+ return state !== undefined && state.justPressed;
+ }
+
+ /**
+ * Check if a mouse button was just released.
+ */
+ static isMouseButtonReleased(button: number = 0): boolean {
+ const state = this.mouseButtons.get(button);
+ return state !== undefined && state.justReleased;
+ }
+}
diff --git a/sdk/src/math/Math.ts b/sdk/src/math/Math.ts
new file mode 100644
index 000000000..9dbd1869a
--- /dev/null
+++ b/sdk/src/math/Math.ts
@@ -0,0 +1,312 @@
+/**
+ * ESEngine TypeScript SDK - Math Utilities
+ *
+ * Provides common math operations for game development.
+ */
+
+import { Vec2, Vec3, Vec4, Mat4, mat4Identity } from '../core/Types';
+
+// Constants
+export const PI = Math.PI;
+export const TWO_PI = Math.PI * 2;
+export const HALF_PI = Math.PI / 2;
+export const DEG_TO_RAD = Math.PI / 180;
+export const RAD_TO_DEG = 180 / Math.PI;
+
+/**
+ * Clamp a value between min and max.
+ */
+export function clamp(value: number, min: number, max: number): number {
+ return Math.min(Math.max(value, min), max);
+}
+
+/**
+ * Linear interpolation between two values.
+ */
+export function lerp(a: number, b: number, t: number): number {
+ return a + (b - a) * t;
+}
+
+/**
+ * Convert degrees to radians.
+ */
+export function toRadians(degrees: number): number {
+ return degrees * DEG_TO_RAD;
+}
+
+/**
+ * Convert radians to degrees.
+ */
+export function toDegrees(radians: number): number {
+ return radians * RAD_TO_DEG;
+}
+
+// ========== Vec2 Operations ==========
+
+export namespace Vec2Math {
+ export function add(a: Vec2, b: Vec2): Vec2 {
+ return { x: a.x + b.x, y: a.y + b.y };
+ }
+
+ export function sub(a: Vec2, b: Vec2): Vec2 {
+ return { x: a.x - b.x, y: a.y - b.y };
+ }
+
+ export function mul(v: Vec2, scalar: number): Vec2 {
+ return { x: v.x * scalar, y: v.y * scalar };
+ }
+
+ export function div(v: Vec2, scalar: number): Vec2 {
+ return { x: v.x / scalar, y: v.y / scalar };
+ }
+
+ export function dot(a: Vec2, b: Vec2): number {
+ return a.x * b.x + a.y * b.y;
+ }
+
+ export function length(v: Vec2): number {
+ return Math.sqrt(v.x * v.x + v.y * v.y);
+ }
+
+ export function lengthSquared(v: Vec2): number {
+ return v.x * v.x + v.y * v.y;
+ }
+
+ export function normalize(v: Vec2): Vec2 {
+ const len = length(v);
+ if (len === 0) return { x: 0, y: 0 };
+ return { x: v.x / len, y: v.y / len };
+ }
+
+ export function distance(a: Vec2, b: Vec2): number {
+ return length(sub(b, a));
+ }
+
+ export function lerp(a: Vec2, b: Vec2, t: number): Vec2 {
+ return {
+ x: a.x + (b.x - a.x) * t,
+ y: a.y + (b.y - a.y) * t,
+ };
+ }
+}
+
+// ========== Vec3 Operations ==========
+
+export namespace Vec3Math {
+ export function add(a: Vec3, b: Vec3): Vec3 {
+ return { x: a.x + b.x, y: a.y + b.y, z: a.z + b.z };
+ }
+
+ export function sub(a: Vec3, b: Vec3): Vec3 {
+ return { x: a.x - b.x, y: a.y - b.y, z: a.z - b.z };
+ }
+
+ export function mul(v: Vec3, scalar: number): Vec3 {
+ return { x: v.x * scalar, y: v.y * scalar, z: v.z * scalar };
+ }
+
+ export function div(v: Vec3, scalar: number): Vec3 {
+ return { x: v.x / scalar, y: v.y / scalar, z: v.z / scalar };
+ }
+
+ export function dot(a: Vec3, b: Vec3): number {
+ return a.x * b.x + a.y * b.y + a.z * b.z;
+ }
+
+ export function cross(a: Vec3, b: Vec3): Vec3 {
+ return {
+ x: a.y * b.z - a.z * b.y,
+ y: a.z * b.x - a.x * b.z,
+ z: a.x * b.y - a.y * b.x,
+ };
+ }
+
+ export function length(v: Vec3): number {
+ return Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
+ }
+
+ export function lengthSquared(v: Vec3): number {
+ return v.x * v.x + v.y * v.y + v.z * v.z;
+ }
+
+ export function normalize(v: Vec3): Vec3 {
+ const len = length(v);
+ if (len === 0) return { x: 0, y: 0, z: 0 };
+ return { x: v.x / len, y: v.y / len, z: v.z / len };
+ }
+
+ export function distance(a: Vec3, b: Vec3): number {
+ return length(sub(b, a));
+ }
+
+ export function lerp(a: Vec3, b: Vec3, t: number): Vec3 {
+ return {
+ x: a.x + (b.x - a.x) * t,
+ y: a.y + (b.y - a.y) * t,
+ z: a.z + (b.z - a.z) * t,
+ };
+ }
+}
+
+// ========== Mat4 Operations ==========
+
+export namespace Mat4Math {
+ /**
+ * Multiply two 4x4 matrices.
+ */
+ export function multiply(a: Mat4, b: Mat4): Mat4 {
+ const result = new Float32Array(16);
+
+ for (let i = 0; i < 4; i++) {
+ for (let j = 0; j < 4; j++) {
+ result[i * 4 + j] =
+ a[i * 4 + 0] * b[0 * 4 + j] +
+ a[i * 4 + 1] * b[1 * 4 + j] +
+ a[i * 4 + 2] * b[2 * 4 + j] +
+ a[i * 4 + 3] * b[3 * 4 + j];
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Create a translation matrix.
+ */
+ export function translate(x: number, y: number, z: number): Mat4 {
+ const m = mat4Identity();
+ m[12] = x;
+ m[13] = y;
+ m[14] = z;
+ return m;
+ }
+
+ /**
+ * Create a scale matrix.
+ */
+ export function scale(x: number, y: number, z: number): Mat4 {
+ const m = new Float32Array(16);
+ m[0] = x;
+ m[5] = y;
+ m[10] = z;
+ m[15] = 1;
+ return m;
+ }
+
+ /**
+ * Create a rotation matrix around the Z axis.
+ */
+ export function rotateZ(angle: number): Mat4 {
+ const m = mat4Identity();
+ const c = Math.cos(angle);
+ const s = Math.sin(angle);
+ m[0] = c;
+ m[1] = s;
+ m[4] = -s;
+ m[5] = c;
+ return m;
+ }
+
+ /**
+ * Create a rotation matrix around the X axis.
+ */
+ export function rotateX(angle: number): Mat4 {
+ const m = mat4Identity();
+ const c = Math.cos(angle);
+ const s = Math.sin(angle);
+ m[5] = c;
+ m[6] = s;
+ m[9] = -s;
+ m[10] = c;
+ return m;
+ }
+
+ /**
+ * Create a rotation matrix around the Y axis.
+ */
+ export function rotateY(angle: number): Mat4 {
+ const m = mat4Identity();
+ const c = Math.cos(angle);
+ const s = Math.sin(angle);
+ m[0] = c;
+ m[2] = -s;
+ m[8] = s;
+ m[10] = c;
+ return m;
+ }
+
+ /**
+ * Create an orthographic projection matrix.
+ */
+ export function ortho(
+ left: number,
+ right: number,
+ bottom: number,
+ top: number,
+ near: number,
+ far: number
+ ): Mat4 {
+ const m = new Float32Array(16);
+ const lr = 1 / (left - right);
+ const bt = 1 / (bottom - top);
+ const nf = 1 / (near - far);
+
+ m[0] = -2 * lr;
+ m[5] = -2 * bt;
+ m[10] = 2 * nf;
+ m[12] = (left + right) * lr;
+ m[13] = (top + bottom) * bt;
+ m[14] = (far + near) * nf;
+ m[15] = 1;
+
+ return m;
+ }
+
+ /**
+ * Create a perspective projection matrix.
+ */
+ export function perspective(
+ fov: number,
+ aspect: number,
+ near: number,
+ far: number
+ ): Mat4 {
+ const m = new Float32Array(16);
+ const f = 1.0 / Math.tan(fov / 2);
+ const nf = 1 / (near - far);
+
+ m[0] = f / aspect;
+ m[5] = f;
+ m[10] = (far + near) * nf;
+ m[11] = -1;
+ m[14] = 2 * far * near * nf;
+
+ return m;
+ }
+
+ /**
+ * Create a look-at view matrix.
+ */
+ export function lookAt(eye: Vec3, target: Vec3, up: Vec3): Mat4 {
+ const z = Vec3Math.normalize(Vec3Math.sub(eye, target));
+ const x = Vec3Math.normalize(Vec3Math.cross(up, z));
+ const y = Vec3Math.cross(z, x);
+
+ const m = new Float32Array(16);
+ m[0] = x.x;
+ m[1] = y.x;
+ m[2] = z.x;
+ m[4] = x.y;
+ m[5] = y.y;
+ m[6] = z.y;
+ m[8] = x.z;
+ m[9] = y.z;
+ m[10] = z.z;
+ m[12] = -Vec3Math.dot(x, eye);
+ m[13] = -Vec3Math.dot(y, eye);
+ m[14] = -Vec3Math.dot(z, eye);
+ m[15] = 1;
+
+ return m;
+ }
+}
diff --git a/sdk/src/platform/Platform.ts b/sdk/src/platform/Platform.ts
new file mode 100644
index 000000000..d9f13d24f
--- /dev/null
+++ b/sdk/src/platform/Platform.ts
@@ -0,0 +1,191 @@
+/**
+ * ESEngine TypeScript SDK - Platform Abstraction
+ *
+ * Defines the interface for platform-specific implementations.
+ */
+
+import { TouchType, TouchPoint, KeyCode } from '../core/Types';
+
+/**
+ * Platform capabilities.
+ */
+export interface PlatformCapabilities {
+ hasTouch: boolean;
+ hasKeyboard: boolean;
+ hasMouse: boolean;
+ hasWebGL2: boolean;
+}
+
+/**
+ * Platform configuration.
+ */
+export interface PlatformConfig {
+ width: number;
+ height: number;
+ canvas?: HTMLCanvasElement | string;
+ devicePixelRatio?: number;
+ /** Skip WebGL context creation (used when WASM creates the context) */
+ skipGLContext?: boolean;
+}
+
+/**
+ * Touch event callback type.
+ */
+export type TouchCallback = (type: TouchType, point: TouchPoint) => void;
+
+/**
+ * Key event callback type.
+ */
+export type KeyCallback = (key: KeyCode, pressed: boolean) => void;
+
+/**
+ * Resize event callback type.
+ */
+export type ResizeCallback = (width: number, height: number) => void;
+
+/**
+ * Platform - Abstract interface for platform implementations.
+ */
+export abstract class Platform {
+ protected touchCallback: TouchCallback | null = null;
+ protected keyCallback: KeyCallback | null = null;
+ protected resizeCallback: ResizeCallback | null = null;
+
+ /**
+ * Initialize the platform.
+ */
+ abstract initialize(config: PlatformConfig): boolean;
+
+ /**
+ * Shut down the platform.
+ */
+ abstract shutdown(): void;
+
+ /**
+ * Poll for input events.
+ */
+ abstract pollEvents(): void;
+
+ /**
+ * Swap display buffers (for double buffering).
+ */
+ abstract swapBuffers(): void;
+
+ /**
+ * Get the current time in seconds.
+ */
+ abstract getTime(): number;
+
+ /**
+ * Get the time since last frame in seconds.
+ */
+ abstract getDeltaTime(): number;
+
+ /**
+ * Get the window width in pixels.
+ */
+ abstract getWindowWidth(): number;
+
+ /**
+ * Get the window height in pixels.
+ */
+ abstract getWindowHeight(): number;
+
+ /**
+ * Get the aspect ratio (width / height).
+ */
+ getAspectRatio(): number {
+ const height = this.getWindowHeight();
+ return height > 0 ? this.getWindowWidth() / height : 1;
+ }
+
+ /**
+ * Get the device pixel ratio.
+ */
+ abstract getDevicePixelRatio(): number;
+
+ /**
+ * Check if the platform is still running.
+ */
+ abstract isRunning(): boolean;
+
+ /**
+ * Request the platform to quit.
+ */
+ abstract requestQuit(): void;
+
+ /**
+ * Get the WebGL rendering context.
+ */
+ abstract getGL(): WebGLRenderingContext | WebGL2RenderingContext | null;
+
+ /**
+ * Get the canvas element.
+ */
+ abstract getCanvas(): HTMLCanvasElement | null;
+
+ /**
+ * Get platform capabilities.
+ */
+ abstract getCapabilities(): PlatformCapabilities;
+
+ /**
+ * Set the touch event callback.
+ */
+ setTouchCallback(callback: TouchCallback | null): void {
+ this.touchCallback = callback;
+ }
+
+ /**
+ * Set the key event callback.
+ */
+ setKeyCallback(callback: KeyCallback | null): void {
+ this.keyCallback = callback;
+ }
+
+ /**
+ * Set the resize event callback.
+ */
+ setResizeCallback(callback: ResizeCallback | null): void {
+ this.resizeCallback = callback;
+ }
+
+ private static platformFactory: (() => Platform) | null = null;
+
+ /**
+ * Register a platform factory function.
+ * This is called by platform implementations to register themselves.
+ */
+ static registerFactory(factory: () => Platform): void {
+ Platform.platformFactory = factory;
+ }
+
+ /**
+ * Create the appropriate platform for the current environment.
+ * The platform must be registered first via registerFactory.
+ */
+ static create(): Platform {
+ if (Platform.platformFactory) {
+ return Platform.platformFactory();
+ }
+
+ // Auto-detect and throw helpful error
+ if (typeof wx !== 'undefined' && typeof wx.createCanvas === 'function') {
+ throw new Error('WeChat MiniGame detected. Import WxPlatform and register it.');
+ } else if (typeof window !== 'undefined' && typeof document !== 'undefined') {
+ throw new Error('Web browser detected. Import WebPlatform and register it.');
+ } else {
+ throw new Error('Unsupported platform');
+ }
+ }
+}
+
+// Type declaration for WeChat MiniGame API (minimal)
+declare const wx: {
+ createCanvas: () => HTMLCanvasElement;
+ getSystemInfoSync: () => {
+ windowWidth: number;
+ windowHeight: number;
+ pixelRatio: number;
+ };
+} | undefined;
diff --git a/sdk/src/platform/WebPlatform.ts b/sdk/src/platform/WebPlatform.ts
new file mode 100644
index 000000000..2e5e69419
--- /dev/null
+++ b/sdk/src/platform/WebPlatform.ts
@@ -0,0 +1,284 @@
+/**
+ * ESEngine TypeScript SDK - Web Platform Implementation
+ *
+ * Platform implementation for standard web browsers.
+ */
+
+import { TouchType, TouchPoint, KeyCode } from '../core/Types';
+import { Platform, PlatformConfig, PlatformCapabilities } from './Platform';
+
+/**
+ * WebPlatform - Web browser platform implementation.
+ */
+export class WebPlatform extends Platform {
+ private canvas: HTMLCanvasElement | null = null;
+ private gl: WebGLRenderingContext | WebGL2RenderingContext | null = null;
+ private running: boolean = false;
+ private width: number = 0;
+ private height: number = 0;
+ private dpr: number = 1;
+ private startTime: number = 0;
+ private lastTime: number = 0;
+ private deltaTime: number = 0;
+ private capabilities: PlatformCapabilities;
+
+ constructor() {
+ super();
+ this.capabilities = {
+ hasTouch: false,
+ hasKeyboard: true,
+ hasMouse: true,
+ hasWebGL2: false,
+ };
+ }
+
+ initialize(config: PlatformConfig): boolean {
+ // Get or create canvas
+ if (config.canvas) {
+ if (typeof config.canvas === 'string') {
+ this.canvas = document.getElementById(config.canvas) as HTMLCanvasElement;
+ if (!this.canvas) {
+ console.error(`Canvas element not found: ${config.canvas}`);
+ return false;
+ }
+ } else {
+ this.canvas = config.canvas;
+ }
+ } else {
+ this.canvas = document.createElement('canvas');
+ document.body.appendChild(this.canvas);
+ }
+
+ // Set up dimensions
+ this.dpr = config.devicePixelRatio ?? window.devicePixelRatio ?? 1;
+ this.width = config.width;
+ this.height = config.height;
+ this.canvas.width = this.width * this.dpr;
+ this.canvas.height = this.height * this.dpr;
+ this.canvas.style.width = `${this.width}px`;
+ this.canvas.style.height = `${this.height}px`;
+
+ // Get WebGL context (skip if WASM creates it)
+ if (!config.skipGLContext) {
+ this.gl = this.canvas.getContext('webgl2') as WebGL2RenderingContext;
+ if (this.gl) {
+ this.capabilities.hasWebGL2 = true;
+ } else {
+ this.gl = this.canvas.getContext('webgl') as WebGLRenderingContext;
+ if (!this.gl) {
+ console.error('WebGL not supported');
+ return false;
+ }
+ }
+ } else {
+ // When using WASM, the C++ code creates and manages the WebGL context
+ this.capabilities.hasWebGL2 = true; // WASM uses WebGL2
+ }
+
+ // Check touch support
+ this.capabilities.hasTouch = 'ontouchstart' in window;
+
+ // Set up event listeners
+ this.setupEventListeners();
+
+ // Initialize timing
+ this.startTime = performance.now() / 1000;
+ this.lastTime = this.startTime;
+ this.running = true;
+
+ return true;
+ }
+
+ shutdown(): void {
+ this.removeEventListeners();
+ this.running = false;
+ this.gl = null;
+ this.canvas = null;
+ }
+
+ pollEvents(): void {
+ // Events are handled asynchronously via callbacks
+ const now = performance.now() / 1000;
+ this.deltaTime = now - this.lastTime;
+ this.lastTime = now;
+ }
+
+ swapBuffers(): void {
+ // WebGL automatically swaps buffers
+ }
+
+ getTime(): number {
+ return performance.now() / 1000 - this.startTime;
+ }
+
+ getDeltaTime(): number {
+ return this.deltaTime;
+ }
+
+ getWindowWidth(): number {
+ return this.width;
+ }
+
+ getWindowHeight(): number {
+ return this.height;
+ }
+
+ getDevicePixelRatio(): number {
+ return this.dpr;
+ }
+
+ isRunning(): boolean {
+ return this.running;
+ }
+
+ requestQuit(): void {
+ this.running = false;
+ }
+
+ getGL(): WebGLRenderingContext | WebGL2RenderingContext | null {
+ return this.gl;
+ }
+
+ getCanvas(): HTMLCanvasElement | null {
+ return this.canvas;
+ }
+
+ getCapabilities(): PlatformCapabilities {
+ return { ...this.capabilities };
+ }
+
+ private setupEventListeners(): void {
+ if (!this.canvas) return;
+
+ // Touch events
+ this.canvas.addEventListener('touchstart', this.handleTouchStart);
+ this.canvas.addEventListener('touchmove', this.handleTouchMove);
+ this.canvas.addEventListener('touchend', this.handleTouchEnd);
+ this.canvas.addEventListener('touchcancel', this.handleTouchCancel);
+
+ // Mouse events (emulate touch)
+ this.canvas.addEventListener('mousedown', this.handleMouseDown);
+ this.canvas.addEventListener('mousemove', this.handleMouseMove);
+ this.canvas.addEventListener('mouseup', this.handleMouseUp);
+
+ // Keyboard events
+ window.addEventListener('keydown', this.handleKeyDown);
+ window.addEventListener('keyup', this.handleKeyUp);
+
+ // Resize event
+ window.addEventListener('resize', this.handleResize);
+ }
+
+ private removeEventListeners(): void {
+ if (!this.canvas) return;
+
+ this.canvas.removeEventListener('touchstart', this.handleTouchStart);
+ this.canvas.removeEventListener('touchmove', this.handleTouchMove);
+ this.canvas.removeEventListener('touchend', this.handleTouchEnd);
+ this.canvas.removeEventListener('touchcancel', this.handleTouchCancel);
+ this.canvas.removeEventListener('mousedown', this.handleMouseDown);
+ this.canvas.removeEventListener('mousemove', this.handleMouseMove);
+ this.canvas.removeEventListener('mouseup', this.handleMouseUp);
+
+ window.removeEventListener('keydown', this.handleKeyDown);
+ window.removeEventListener('keyup', this.handleKeyUp);
+ window.removeEventListener('resize', this.handleResize);
+ }
+
+ private getCanvasPosition(clientX: number, clientY: number): { x: number; y: number } {
+ if (!this.canvas) return { x: 0, y: 0 };
+ const rect = this.canvas.getBoundingClientRect();
+ // Return logical coordinates (CSS pixels), not physical pixels
+ // Game logic should use logical coords, only convert to physical in rendering
+ return {
+ x: clientX - rect.left,
+ y: clientY - rect.top,
+ };
+ }
+
+ private handleTouchStart = (e: TouchEvent): void => {
+ e.preventDefault();
+ for (let i = 0; i < e.changedTouches.length; i++) {
+ const touch = e.changedTouches[i];
+ const pos = this.getCanvasPosition(touch.clientX, touch.clientY);
+ const point: TouchPoint = { id: touch.identifier, x: pos.x, y: pos.y };
+ this.touchCallback?.(TouchType.Begin, point);
+ }
+ };
+
+ private handleTouchMove = (e: TouchEvent): void => {
+ e.preventDefault();
+ for (let i = 0; i < e.changedTouches.length; i++) {
+ const touch = e.changedTouches[i];
+ const pos = this.getCanvasPosition(touch.clientX, touch.clientY);
+ const point: TouchPoint = { id: touch.identifier, x: pos.x, y: pos.y };
+ this.touchCallback?.(TouchType.Move, point);
+ }
+ };
+
+ private handleTouchEnd = (e: TouchEvent): void => {
+ e.preventDefault();
+ for (let i = 0; i < e.changedTouches.length; i++) {
+ const touch = e.changedTouches[i];
+ const pos = this.getCanvasPosition(touch.clientX, touch.clientY);
+ const point: TouchPoint = { id: touch.identifier, x: pos.x, y: pos.y };
+ this.touchCallback?.(TouchType.End, point);
+ }
+ };
+
+ private handleTouchCancel = (e: TouchEvent): void => {
+ e.preventDefault();
+ for (let i = 0; i < e.changedTouches.length; i++) {
+ const touch = e.changedTouches[i];
+ const pos = this.getCanvasPosition(touch.clientX, touch.clientY);
+ const point: TouchPoint = { id: touch.identifier, x: pos.x, y: pos.y };
+ this.touchCallback?.(TouchType.Cancel, point);
+ }
+ };
+
+ private handleMouseDown = (e: MouseEvent): void => {
+ const pos = this.getCanvasPosition(e.clientX, e.clientY);
+ const point: TouchPoint = { id: 0, x: pos.x, y: pos.y };
+ this.touchCallback?.(TouchType.Begin, point);
+ };
+
+ private handleMouseMove = (e: MouseEvent): void => {
+ const pos = this.getCanvasPosition(e.clientX, e.clientY);
+ const point: TouchPoint = { id: 0, x: pos.x, y: pos.y };
+ this.touchCallback?.(TouchType.Move, point);
+ };
+
+ private handleMouseUp = (e: MouseEvent): void => {
+ const pos = this.getCanvasPosition(e.clientX, e.clientY);
+ const point: TouchPoint = { id: 0, x: pos.x, y: pos.y };
+ this.touchCallback?.(TouchType.End, point);
+ };
+
+ private handleKeyDown = (e: KeyboardEvent): void => {
+ const keyCode = this.mapKeyCode(e.keyCode);
+ this.keyCallback?.(keyCode, true);
+ };
+
+ private handleKeyUp = (e: KeyboardEvent): void => {
+ const keyCode = this.mapKeyCode(e.keyCode);
+ this.keyCallback?.(keyCode, false);
+ };
+
+ private handleResize = (): void => {
+ this.resizeCallback?.(window.innerWidth, window.innerHeight);
+ };
+
+ private mapKeyCode(code: number): KeyCode {
+ // Most key codes map directly
+ if (code in KeyCode) {
+ return code as KeyCode;
+ }
+ return KeyCode.Unknown;
+ }
+}
+
+// Auto-register WebPlatform when imported in browser environment
+// Check is done after class definition to ensure WebPlatform is available
+if (typeof window !== 'undefined' && typeof document !== 'undefined') {
+ Platform.registerFactory(() => new WebPlatform());
+}
diff --git a/sdk/src/platform/WxPlatform.ts b/sdk/src/platform/WxPlatform.ts
new file mode 100644
index 000000000..f427ae1f0
--- /dev/null
+++ b/sdk/src/platform/WxPlatform.ts
@@ -0,0 +1,229 @@
+/**
+ * ESEngine TypeScript SDK - WeChat MiniGame Platform Implementation
+ *
+ * Platform implementation for WeChat MiniGame environment.
+ */
+
+import { TouchType, TouchPoint } from '../core/Types';
+import { Platform, PlatformConfig, PlatformCapabilities } from './Platform';
+
+// WeChat MiniGame API types
+declare const wx: {
+ createCanvas: () => HTMLCanvasElement;
+ getSystemInfoSync: () => {
+ windowWidth: number;
+ windowHeight: number;
+ pixelRatio: number;
+ platform: string;
+ brand: string;
+ model: string;
+ };
+ onTouchStart: (callback: (res: WxTouchEvent) => void) => void;
+ onTouchMove: (callback: (res: WxTouchEvent) => void) => void;
+ onTouchEnd: (callback: (res: WxTouchEvent) => void) => void;
+ onTouchCancel: (callback: (res: WxTouchEvent) => void) => void;
+ offTouchStart: (callback: (res: WxTouchEvent) => void) => void;
+ offTouchMove: (callback: (res: WxTouchEvent) => void) => void;
+ offTouchEnd: (callback: (res: WxTouchEvent) => void) => void;
+ offTouchCancel: (callback: (res: WxTouchEvent) => void) => void;
+};
+
+interface WxTouch {
+ identifier: number;
+ clientX: number;
+ clientY: number;
+}
+
+interface WxTouchEvent {
+ touches: WxTouch[];
+ changedTouches: WxTouch[];
+ timeStamp: number;
+}
+
+/**
+ * WxPlatform - WeChat MiniGame platform implementation.
+ */
+export class WxPlatform extends Platform {
+ private canvas: HTMLCanvasElement | null = null;
+ private gl: WebGLRenderingContext | WebGL2RenderingContext | null = null;
+ private running: boolean = false;
+ private width: number = 0;
+ private height: number = 0;
+ private dpr: number = 1;
+ private startTime: number = 0;
+ private lastTime: number = 0;
+ private deltaTime: number = 0;
+ private capabilities: PlatformCapabilities;
+
+ constructor() {
+ super();
+ this.capabilities = {
+ hasTouch: true,
+ hasKeyboard: false,
+ hasMouse: false,
+ hasWebGL2: false,
+ };
+ }
+
+ initialize(config: PlatformConfig): boolean {
+ // Get system info
+ const systemInfo = wx.getSystemInfoSync();
+ this.dpr = config.devicePixelRatio ?? systemInfo.pixelRatio;
+
+ // Create canvas
+ this.canvas = wx.createCanvas();
+
+ // Set up dimensions
+ this.width = config.width || systemInfo.windowWidth;
+ this.height = config.height || systemInfo.windowHeight;
+ this.canvas.width = this.width * this.dpr;
+ this.canvas.height = this.height * this.dpr;
+
+ // Get WebGL context
+ this.gl = this.canvas.getContext('webgl2') as WebGL2RenderingContext;
+ if (this.gl) {
+ this.capabilities.hasWebGL2 = true;
+ } else {
+ this.gl = this.canvas.getContext('webgl') as WebGLRenderingContext;
+ if (!this.gl) {
+ console.error('WebGL not supported');
+ return false;
+ }
+ }
+
+ // Set up event listeners
+ this.setupEventListeners();
+
+ // Initialize timing
+ this.startTime = Date.now() / 1000;
+ this.lastTime = this.startTime;
+ this.running = true;
+
+ return true;
+ }
+
+ shutdown(): void {
+ this.removeEventListeners();
+ this.running = false;
+ this.gl = null;
+ this.canvas = null;
+ }
+
+ pollEvents(): void {
+ const now = Date.now() / 1000;
+ this.deltaTime = now - this.lastTime;
+ this.lastTime = now;
+ }
+
+ swapBuffers(): void {
+ // WeChat handles buffer swapping
+ }
+
+ getTime(): number {
+ return Date.now() / 1000 - this.startTime;
+ }
+
+ getDeltaTime(): number {
+ return this.deltaTime;
+ }
+
+ getWindowWidth(): number {
+ return this.width;
+ }
+
+ getWindowHeight(): number {
+ return this.height;
+ }
+
+ getDevicePixelRatio(): number {
+ return this.dpr;
+ }
+
+ isRunning(): boolean {
+ return this.running;
+ }
+
+ requestQuit(): void {
+ this.running = false;
+ }
+
+ getGL(): WebGLRenderingContext | WebGL2RenderingContext | null {
+ return this.gl;
+ }
+
+ getCanvas(): HTMLCanvasElement | null {
+ return this.canvas;
+ }
+
+ getCapabilities(): PlatformCapabilities {
+ return { ...this.capabilities };
+ }
+
+ private setupEventListeners(): void {
+ wx.onTouchStart(this.handleTouchStart);
+ wx.onTouchMove(this.handleTouchMove);
+ wx.onTouchEnd(this.handleTouchEnd);
+ wx.onTouchCancel(this.handleTouchCancel);
+ }
+
+ private removeEventListeners(): void {
+ wx.offTouchStart(this.handleTouchStart);
+ wx.offTouchMove(this.handleTouchMove);
+ wx.offTouchEnd(this.handleTouchEnd);
+ wx.offTouchCancel(this.handleTouchCancel);
+ }
+
+ private handleTouchStart = (e: WxTouchEvent): void => {
+ for (const touch of e.changedTouches) {
+ const point: TouchPoint = {
+ id: touch.identifier,
+ x: touch.clientX * this.dpr,
+ y: touch.clientY * this.dpr,
+ };
+ this.touchCallback?.(TouchType.Begin, point);
+ }
+ };
+
+ private handleTouchMove = (e: WxTouchEvent): void => {
+ for (const touch of e.changedTouches) {
+ const point: TouchPoint = {
+ id: touch.identifier,
+ x: touch.clientX * this.dpr,
+ y: touch.clientY * this.dpr,
+ };
+ this.touchCallback?.(TouchType.Move, point);
+ }
+ };
+
+ private handleTouchEnd = (e: WxTouchEvent): void => {
+ for (const touch of e.changedTouches) {
+ const point: TouchPoint = {
+ id: touch.identifier,
+ x: touch.clientX * this.dpr,
+ y: touch.clientY * this.dpr,
+ };
+ this.touchCallback?.(TouchType.End, point);
+ }
+ };
+
+ private handleTouchCancel = (e: WxTouchEvent): void => {
+ for (const touch of e.changedTouches) {
+ const point: TouchPoint = {
+ id: touch.identifier,
+ x: touch.clientX * this.dpr,
+ y: touch.clientY * this.dpr,
+ };
+ this.touchCallback?.(TouchType.Cancel, point);
+ }
+ };
+}
+
+// Auto-register WxPlatform when imported in WeChat MiniGame environment
+// Check is done after class definition to ensure WxPlatform is available
+try {
+ if (typeof wx !== 'undefined' && typeof wx.createCanvas === 'function') {
+ Platform.registerFactory(() => new WxPlatform());
+ }
+} catch {
+ // Ignore errors in environments where wx is not available
+}
diff --git a/sdk/src/renderer/Renderer.ts b/sdk/src/renderer/Renderer.ts
new file mode 100644
index 000000000..196c883da
--- /dev/null
+++ b/sdk/src/renderer/Renderer.ts
@@ -0,0 +1,471 @@
+/**
+ * ESEngine TypeScript SDK - Renderer
+ *
+ * Provides rendering functionality using either native WebGL or WASM backend.
+ */
+
+import { Vec2, Vec3, Color, Mat4, RendererStats, mat4Identity, mat4Ortho } from '../core/Types';
+import { isWasmLoaded, getWasmModule, withFloat32Array } from '../core/WasmBridge';
+
+/**
+ * Renderer mode - determines which backend to use.
+ */
+export enum RendererMode {
+ /** Use native WebGL (TypeScript implementation) */
+ Native = 'native',
+ /** Use WASM backend (C++ implementation) */
+ Wasm = 'wasm',
+}
+
+/**
+ * Quad drawing options.
+ */
+export interface DrawQuadOptions {
+ position: Vec2 | Vec3;
+ size: Vec2;
+ color?: Color;
+ textureId?: number;
+ rotation?: number;
+}
+
+/**
+ * Renderer - Static class for 2D rendering.
+ */
+export class Renderer {
+ private static gl: WebGLRenderingContext | WebGL2RenderingContext | null = null;
+ private static mode: RendererMode = RendererMode.Native;
+ private static initialized: boolean = false;
+ private static viewProjection: Mat4 = mat4Identity();
+ private static clearColor: Color = { r: 0, g: 0, b: 0, a: 1 };
+ private static stats: RendererStats = { drawCalls: 0, triangleCount: 0, vertexCount: 0 };
+
+ // Native rendering resources
+ private static quadShader: WebGLProgram | null = null;
+ private static quadVAO: WebGLVertexArrayObject | null = null;
+ private static quadVBO: WebGLBuffer | null = null;
+ private static quadIBO: WebGLBuffer | null = null;
+
+ /**
+ * Initialize the renderer.
+ * @param gl WebGL context (null for WASM mode where C++ owns the context)
+ * @param mode Renderer mode
+ */
+ static init(gl: WebGLRenderingContext | WebGL2RenderingContext | null, mode: RendererMode = RendererMode.Native): void {
+ if (this.initialized) return;
+
+ this.gl = gl;
+ this.mode = mode;
+
+ if (mode === RendererMode.Native && gl) {
+ this.initNative();
+ }
+
+ this.initialized = true;
+ }
+
+ /**
+ * Shut down the renderer.
+ */
+ static shutdown(): void {
+ if (!this.initialized) return;
+
+ if (this.mode === RendererMode.Native) {
+ this.shutdownNative();
+ }
+
+ this.gl = null;
+ this.initialized = false;
+ }
+
+ /**
+ * Begin a new frame.
+ */
+ static beginFrame(): void {
+ this.resetStats();
+ }
+
+ /**
+ * End the current frame.
+ */
+ static endFrame(): void {
+ // Flush any pending operations
+ }
+
+ /**
+ * Set the viewport.
+ */
+ static setViewport(x: number, y: number, width: number, height: number): void {
+ if (!this.gl) return;
+ this.gl.viewport(x, y, width, height);
+ }
+
+ /**
+ * Set the clear color.
+ */
+ static setClearColor(color: Color): void {
+ this.clearColor = { ...color };
+ if (this.gl) {
+ this.gl.clearColor(color.r, color.g, color.b, color.a);
+ }
+ }
+
+ /**
+ * Clear the screen.
+ */
+ static clear(): void {
+ if (!this.gl) return;
+
+ if (this.mode === RendererMode.Wasm && isWasmLoaded()) {
+ const module = getWasmModule();
+ if (module._es_renderer_clear) {
+ module._es_renderer_clear(
+ this.clearColor.r,
+ this.clearColor.g,
+ this.clearColor.b,
+ this.clearColor.a
+ );
+ return;
+ }
+ }
+
+ this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT);
+ }
+
+ /**
+ * Begin a scene with the given view-projection matrix.
+ */
+ static beginScene(viewProjection: Mat4): void {
+ this.viewProjection = viewProjection;
+
+ if (this.mode === RendererMode.Wasm && isWasmLoaded()) {
+ const module = getWasmModule();
+ if (module._es_renderer_begin_scene) {
+ withFloat32Array(viewProjection, (ptr) => {
+ module._es_renderer_begin_scene!(ptr);
+ });
+ return;
+ }
+ }
+
+ // Native mode - set shader uniform
+ if (this.quadShader && this.gl) {
+ this.gl.useProgram(this.quadShader);
+ const loc = this.gl.getUniformLocation(this.quadShader, 'u_ViewProjection');
+ this.gl.uniformMatrix4fv(loc, false, viewProjection);
+ }
+ }
+
+ /**
+ * End the current scene.
+ */
+ static endScene(): void {
+ if (this.mode === RendererMode.Wasm && isWasmLoaded()) {
+ const module = getWasmModule();
+ if (module._es_renderer_end_scene) {
+ module._es_renderer_end_scene();
+ }
+ }
+ }
+
+ /**
+ * Draw a colored quad.
+ */
+ static drawQuad(position: Vec2 | Vec3, size: Vec2, color: Color): void {
+ const x = position.x;
+ const y = position.y;
+ const z = 'z' in position ? position.z : 0;
+
+ if (this.mode === RendererMode.Wasm && isWasmLoaded()) {
+ const module = getWasmModule();
+ if (module._es_renderer_draw_quad) {
+ module._es_renderer_draw_quad(
+ x, y, size.x, size.y,
+ color.r, color.g, color.b, color.a
+ );
+ this.stats.drawCalls++;
+ this.stats.triangleCount += 2;
+ this.stats.vertexCount += 4;
+ return;
+ }
+ }
+
+ // Native drawing
+ this.drawQuadNative(x, y, z, size.x, size.y, color, -1);
+ }
+
+ /**
+ * Draw a textured quad.
+ */
+ static drawTexturedQuad(
+ position: Vec2 | Vec3,
+ size: Vec2,
+ textureId: number,
+ tintColor: Color = { r: 1, g: 1, b: 1, a: 1 }
+ ): void {
+ const x = position.x;
+ const y = position.y;
+ const z = 'z' in position ? position.z : 0;
+
+ if (this.mode === RendererMode.Wasm && isWasmLoaded()) {
+ const module = getWasmModule();
+ if (module._es_renderer_draw_quad_textured) {
+ module._es_renderer_draw_quad_textured(
+ x, y, size.x, size.y, textureId,
+ tintColor.r, tintColor.g, tintColor.b, tintColor.a
+ );
+ this.stats.drawCalls++;
+ this.stats.triangleCount += 2;
+ this.stats.vertexCount += 4;
+ return;
+ }
+ }
+
+ // Native drawing
+ this.drawQuadNative(x, y, z, size.x, size.y, tintColor, textureId);
+ }
+
+ /**
+ * Get renderer statistics.
+ */
+ static getStats(): RendererStats {
+ return { ...this.stats };
+ }
+
+ /**
+ * Reset renderer statistics.
+ */
+ static resetStats(): void {
+ this.stats = { drawCalls: 0, triangleCount: 0, vertexCount: 0 };
+ }
+
+ /**
+ * Create an orthographic projection for 2D rendering.
+ */
+ static createOrtho2D(width: number, height: number): Mat4 {
+ return mat4Ortho(0, width, height, 0, -1, 1);
+ }
+
+ // ========== Native WebGL Implementation ==========
+
+ private static initNative(): void {
+ const gl = this.gl;
+ if (!gl) return;
+
+ // Create shader program
+ this.quadShader = this.createShaderProgram(QUAD_VERTEX_SHADER, QUAD_FRAGMENT_SHADER);
+
+ // Create quad geometry
+ const vertices = new Float32Array([
+ // Position (x, y) // UV
+ 0.0, 0.0, 0.0, 0.0,
+ 1.0, 0.0, 1.0, 0.0,
+ 1.0, 1.0, 1.0, 1.0,
+ 0.0, 1.0, 0.0, 1.0,
+ ]);
+
+ const indices = new Uint16Array([0, 1, 2, 2, 3, 0]);
+
+ // Check for WebGL2
+ const gl2 = gl as WebGL2RenderingContext;
+ if (typeof gl2.createVertexArray === 'function') {
+ this.quadVAO = gl2.createVertexArray();
+ gl2.bindVertexArray(this.quadVAO);
+ }
+
+ // Create VBO
+ this.quadVBO = gl.createBuffer();
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.quadVBO);
+ gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW);
+
+ // Create IBO
+ this.quadIBO = gl.createBuffer();
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.quadIBO);
+ gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW);
+
+ // Set up vertex attributes
+ const stride = 4 * 4; // 4 floats * 4 bytes
+ gl.enableVertexAttribArray(0);
+ gl.vertexAttribPointer(0, 2, gl.FLOAT, false, stride, 0);
+ gl.enableVertexAttribArray(1);
+ gl.vertexAttribPointer(1, 2, gl.FLOAT, false, stride, 2 * 4);
+
+ if (typeof gl2.bindVertexArray === 'function') {
+ gl2.bindVertexArray(null);
+ }
+
+ // Enable blending
+ gl.enable(gl.BLEND);
+ gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
+ }
+
+ private static shutdownNative(): void {
+ const gl = this.gl;
+ if (!gl) return;
+
+ if (this.quadShader) {
+ gl.deleteProgram(this.quadShader);
+ this.quadShader = null;
+ }
+
+ if (this.quadVBO) {
+ gl.deleteBuffer(this.quadVBO);
+ this.quadVBO = null;
+ }
+
+ if (this.quadIBO) {
+ gl.deleteBuffer(this.quadIBO);
+ this.quadIBO = null;
+ }
+
+ const gl2 = gl as WebGL2RenderingContext;
+ if (this.quadVAO && typeof gl2.deleteVertexArray === 'function') {
+ gl2.deleteVertexArray(this.quadVAO);
+ this.quadVAO = null;
+ }
+ }
+
+ private static drawQuadNative(
+ x: number,
+ y: number,
+ z: number,
+ w: number,
+ h: number,
+ color: Color,
+ textureId: number
+ ): void {
+ const gl = this.gl;
+ if (!gl || !this.quadShader) return;
+
+ gl.useProgram(this.quadShader);
+
+ // Set uniforms
+ const uTransform = gl.getUniformLocation(this.quadShader, 'u_Transform');
+ const uColor = gl.getUniformLocation(this.quadShader, 'u_Color');
+ const uUseTexture = gl.getUniformLocation(this.quadShader, 'u_UseTexture');
+
+ // Simple transform: translate and scale
+ const transform = new Float32Array([
+ w, 0, 0, 0,
+ 0, h, 0, 0,
+ 0, 0, 1, 0,
+ x, y, z, 1,
+ ]);
+
+ gl.uniformMatrix4fv(uTransform, false, transform);
+ gl.uniform4f(uColor, color.r, color.g, color.b, color.a);
+ gl.uniform1i(uUseTexture, textureId >= 0 ? 1 : 0);
+
+ // Bind texture if needed
+ if (textureId >= 0) {
+ gl.activeTexture(gl.TEXTURE0);
+ gl.bindTexture(gl.TEXTURE_2D, textureId as unknown as WebGLTexture);
+ const uTexture = gl.getUniformLocation(this.quadShader, 'u_Texture');
+ gl.uniform1i(uTexture, 0);
+ }
+
+ // Draw
+ const gl2 = gl as WebGL2RenderingContext;
+ if (this.quadVAO && typeof gl2.bindVertexArray === 'function') {
+ gl2.bindVertexArray(this.quadVAO);
+ } else {
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.quadVBO);
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.quadIBO);
+ gl.enableVertexAttribArray(0);
+ gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 16, 0);
+ gl.enableVertexAttribArray(1);
+ gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 16, 8);
+ }
+
+ gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);
+
+ if (typeof gl2.bindVertexArray === 'function') {
+ gl2.bindVertexArray(null);
+ }
+
+ this.stats.drawCalls++;
+ this.stats.triangleCount += 2;
+ this.stats.vertexCount += 4;
+ }
+
+ private static createShaderProgram(vertexSource: string, fragmentSource: string): WebGLProgram | null {
+ const gl = this.gl;
+ if (!gl) return null;
+
+ const vertexShader = this.compileShader(gl.VERTEX_SHADER, vertexSource);
+ const fragmentShader = this.compileShader(gl.FRAGMENT_SHADER, fragmentSource);
+
+ if (!vertexShader || !fragmentShader) return null;
+
+ const program = gl.createProgram();
+ if (!program) return null;
+
+ gl.attachShader(program, vertexShader);
+ gl.attachShader(program, fragmentShader);
+ gl.linkProgram(program);
+
+ if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
+ console.error('Shader program link error:', gl.getProgramInfoLog(program));
+ gl.deleteProgram(program);
+ return null;
+ }
+
+ gl.deleteShader(vertexShader);
+ gl.deleteShader(fragmentShader);
+
+ return program;
+ }
+
+ private static compileShader(type: number, source: string): WebGLShader | null {
+ const gl = this.gl;
+ if (!gl) return null;
+
+ const shader = gl.createShader(type);
+ if (!shader) return null;
+
+ gl.shaderSource(shader, source);
+ gl.compileShader(shader);
+
+ if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
+ console.error('Shader compile error:', gl.getShaderInfoLog(shader));
+ gl.deleteShader(shader);
+ return null;
+ }
+
+ return shader;
+ }
+}
+
+// ========== Shader Sources ==========
+
+const QUAD_VERTEX_SHADER = `
+attribute vec2 a_Position;
+attribute vec2 a_TexCoord;
+
+uniform mat4 u_ViewProjection;
+uniform mat4 u_Transform;
+
+varying vec2 v_TexCoord;
+
+void main() {
+ v_TexCoord = a_TexCoord;
+ gl_Position = u_ViewProjection * u_Transform * vec4(a_Position, 0.0, 1.0);
+}
+`;
+
+const QUAD_FRAGMENT_SHADER = `
+precision mediump float;
+
+varying vec2 v_TexCoord;
+
+uniform vec4 u_Color;
+uniform sampler2D u_Texture;
+uniform int u_UseTexture;
+
+void main() {
+ if (u_UseTexture == 1) {
+ gl_FragColor = texture2D(u_Texture, v_TexCoord) * u_Color;
+ } else {
+ gl_FragColor = u_Color;
+ }
+}
+`;
diff --git a/sdk/tsconfig.json b/sdk/tsconfig.json
new file mode 100644
index 000000000..9637731eb
--- /dev/null
+++ b/sdk/tsconfig.json
@@ -0,0 +1,23 @@
+{
+ "compilerOptions": {
+ "target": "ES2020",
+ "module": "ESNext",
+ "lib": ["ES2020", "DOM"],
+ "declaration": true,
+ "strict": true,
+ "noImplicitAny": true,
+ "strictNullChecks": true,
+ "noImplicitReturns": true,
+ "noFallthroughCasesInSwitch": true,
+ "moduleResolution": "node",
+ "esModuleInterop": true,
+ "skipLibCheck": true,
+ "forceConsistentCasingInFileNames": true,
+ "outDir": "dist",
+ "rootDir": "src",
+ "sourceMap": true,
+ "resolveJsonModule": true
+ },
+ "include": ["src/**/*"],
+ "exclude": ["node_modules", "dist", "examples"]
+}
diff --git a/src/esengine/platform/web/WebPlatform.cpp b/src/esengine/platform/web/WebPlatform.cpp
index 015f40e94..0c7f4b6f4 100644
--- a/src/esengine/platform/web/WebPlatform.cpp
+++ b/src/esengine/platform/web/WebPlatform.cpp
@@ -1,6 +1,9 @@
#include "../Platform.hpp"
#include "../../core/Log.hpp"
#include "../../renderer/Renderer.hpp"
+#include "../../math/Math.hpp"
+
+#include <cstring>
#ifdef ES_PLATFORM_WEB
#include <emscripten.h>
@@ -33,13 +36,20 @@ public:
attrs.premultipliedAlpha = true;
attrs.preserveDrawingBuffer = false;
+ // Create WebGL context for canvas with id="canvas"
context_ = emscripten_webgl_create_context("#canvas", &attrs);
+ ES_LOG_INFO("WebGL context creation result: {}", context_);
if (context_ <= 0) {
- ES_LOG_ERROR("Failed to create WebGL context");
+ ES_LOG_ERROR("Failed to create WebGL context, error: {}", context_);
return false;
}
- emscripten_webgl_make_context_current(context_);
+ EMSCRIPTEN_RESULT res = emscripten_webgl_make_context_current(context_);
+ ES_LOG_INFO("Make context current result: {}", res);
+ if (res != EMSCRIPTEN_RESULT_SUCCESS) {
+ ES_LOG_ERROR("Failed to make WebGL context current, error: {}", res);
+ return false;
+ }
// Set canvas size
emscripten_set_canvas_element_size("#canvas", width, height);
@@ -312,5 +322,52 @@ void es_on_touch(int type, float x, float y) {
(void)y;
}
+EMSCRIPTEN_KEEPALIVE
+void es_on_key(int keyCode, int pressed) {
+ // Key handling would be forwarded to the application
+ (void)keyCode;
+ (void)pressed;
+}
+
+EMSCRIPTEN_KEEPALIVE
+void es_renderer_clear(float r, float g, float b, float a) {
+ esengine::Renderer::setClearColor(glm::vec4(r, g, b, a));
+ esengine::Renderer::clear();
+}
+
+EMSCRIPTEN_KEEPALIVE
+void es_renderer_begin_scene(float* vpMatrix) {
+ if (vpMatrix) {
+ glm::mat4 vp;
+ std::memcpy(&vp[0][0], vpMatrix, 16 * sizeof(float));
+ esengine::Renderer::beginScene(vp);
+ }
+}
+
+EMSCRIPTEN_KEEPALIVE
+void es_renderer_end_scene() {
+ esengine::Renderer::endScene();
+}
+
+EMSCRIPTEN_KEEPALIVE
+void es_renderer_draw_quad(float x, float y, float w, float h, float r, float g, float b, float a) {
+ esengine::Renderer::drawQuad(
+ glm::vec2(x, y),
+ glm::vec2(w, h),
+ glm::vec4(r, g, b, a)
+ );
+}
+
+EMSCRIPTEN_KEEPALIVE
+void es_renderer_draw_quad_textured(float x, float y, float w, float h, unsigned int texId, float r, float g, float b, float a) {
+ // TODO: Implement textured quad drawing with texture ID
+ (void)texId;
+ esengine::Renderer::drawQuad(
+ glm::vec2(x, y),
+ glm::vec2(w, h),
+ glm::vec4(r, g, b, a)
+ );
+}
+
} // extern "C"
#endif