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.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
fix(export): playable engine runtime — correct glue path, fail-fast, clear error
esengineb1f395c7c35d
diff --git a/desktop/electron/exportPlayable.ts b/desktop/electron/exportPlayable.tsindex b8b2ae11c..abca0d7e6 100644--- a/desktop/electron/exportPlayable.ts+++ b/desktop/electron/exportPlayable.ts@@ -155,10 +155,11 @@ export async function exportPlayable(opts: {errors.push(...(e.errors?.map((x) => x.text) ?? [String(e.message ?? err)]));}- // 5. The SINGLE_FILE glue (global ESEngineModule, wasm embedded).+ // 5. The SINGLE_FILE glue (global ESEngineModule, wasm embedded). Required — a+ // playable can't run without it, so a miss is an ERROR (not a broken bundle).let glue = '';if (existsSync(opts.glueFile)) glue = await readFile(opts.glueFile, 'utf8');- else warnings.push(`single-file engine glue not found: ${opts.glueFile} — run \`node build-tools/cli.js build -t playable\``);+ else errors.push(`single-file engine runtime missing — run \`node build-tools/cli.js build -t playable\` (expected ${opts.glueFile})`);// 6. Assemble the single HTML, then drop the temp cook dir.progress({ phase: 'Assembling HTML' });diff --git a/desktop/electron/main.ts b/desktop/electron/main.tsindex 906469164..c557b8630 100644--- a/desktop/electron/main.ts+++ b/desktop/electron/main.ts@@ -287,13 +287,9 @@ ipcMain.handle(// `node build-tools/cli.js build -t wechat`. Absent → exportWeChat warns.const wechatWasm = [path.join(VITE_PUBLIC, 'wasm-wechat'), path.join(process.env.APP_ROOT!, '..', 'build', 'wasm', 'wechat')].find(existsSync) ?? path.join(VITE_PUBLIC, 'wasm-wechat');- // Playable's SINGLE_FILE glue (esengine.single.js); build it with- // `node build-tools/cli.js build -t playable`. Absent → exportPlayable warns.- const glueFile = [- path.join(VITE_PUBLIC, 'esengine.single.js'),- path.join(process.env.APP_ROOT!, '..', 'build', 'wasm', 'playable', 'esengine.single.js'),- path.join(process.env.APP_ROOT!, '..', 'build-playable', 'sdk', 'esengine.single.js'),- ].find(existsSync) ?? path.join(VITE_PUBLIC, 'esengine.single.js');+ // Playable's SINGLE_FILE glue lives in the wasm runtime dir (sibling of+ // esengine.js), synced there by `build -t playable`. Absent → exportPlayable errors.+ const glueFile = path.join(webWasm, 'esengine.single.js');const plat = manifest.packaging?.platforms;return exportGame({root,diff --git a/desktop/src/playableHost.ts b/desktop/src/playableHost.tsindex 9fefc18d8..079611b3a 100644--- a/desktop/src/playableHost.ts+++ b/desktop/src/playableHost.ts@@ -12,9 +12,9 @@import { createWebApp, setEditorMode, setPlayMode, initPlayableRuntime } from 'esengine';import type { ESEngineModule as EngineModule, SceneData } from 'esengine';-// The SINGLE_FILE glue exposes this global (MODULARIZE + EXPORT_ES6=0 → IIFE),-// wasm embedded, so no locateFile / instantiateWasm wiring is needed here.-declare const ESEngineModule: (opts?: Record<string, unknown>) => Promise<EngineModule>;+// The SINGLE_FILE glue exposes ESEngineModule as a global (MODULARIZE ++// EXPORT_ES6=0), wasm embedded, so no locateFile / instantiateWasm wiring here.+type EngineFactory = (opts?: Record<string, unknown>) => Promise<EngineModule>;// Inlined by exportPlayable as <script> globals (kept out of the bundle so the// large base64 asset blob isn't re-parsed as code).declare const __GAME_ASSETS__: Record<string, string>;@@ -31,7 +31,11 @@ async function boot(): Promise<void> {window.addEventListener('resize', resize);resize();- const module = await ESEngineModule({ canvas });+ const factory = (globalThis as unknown as { ESEngineModule?: EngineFactory }).ESEngineModule;+ if (typeof factory !== 'function') {+ throw new Error('Engine runtime (esengine.single.js) not loaded — rebuild the playable: `node build-tools/cli.js build -t playable`.');+ }+ const module = await factory({ canvas });const gl = canvas.getContext('webgl2', {alpha: false,