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): a playable exports from the hosts an editor ships
esengine82e42a3f5f01
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 5ed4e2f71..a146514bd 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -350,6 +350,21 @@ published separately; it ships inside the editor.### Fixed+- **The editor packages playable ads again.** Since 0.65 a playable's game+ travels deflated and a small loader starts it, and the exporter looked for that+ loader beside the playable host. The editor exports from the host bundles it+ prebuilds (an installed editor ships no sources), and that prebuild kept its own+ list of hosts, without the loader — so every playable export from the editor+ stopped at "Could not resolve …/hosts/playableLoader.js" (#62). The command line+ and every exporter test bundle the hosts from their sources, where the loader+ was always right there.++ The hosts an export bundles are now named once, in the pipeline, and the+ editor's prebuild takes its entries from that list; an export is told the one+ directory the hosts are in, not a path per host. A test now exports a playable+ from a prebuilt host tree, and an editor check packages the playable-ad+ template through the editor's own export.+- **Two nodes under one id are reported instead of one replacing the other.**Every lookup in a compiled graph is by node id, so a file carrying the same idtwice quietly kept whichever came last, and any wire drawn to either landed ondiff --git a/desktop b/desktopindex d666c90d9..46534f01f 160000--- a/desktop+++ b/desktop@@ -1 +1 @@-Subproject commit d666c90d9e8f8288264728770269cdf62d58bd13+Subproject commit 46534f01f24e237c73e51bdd0a5cd4c7d2a1339cdiff --git a/pipeline/bin/estella.mjs b/pipeline/bin/estella.mjsindex a46cadcec..a9cd951c1 100644--- a/pipeline/bin/estella.mjs+++ b/pipeline/bin/estella.mjs@@ -759,8 +759,7 @@ try {root: opts.projectDir,entryScene,scriptsEntry,- gameHostEntry: path.join(PIPELINE, 'src', 'runtime', 'gameHost.ts'),- playableHostEntry: path.join(PIPELINE, 'src', 'runtime', 'playableHost.ts'),+ hostsDir: path.join(PIPELINE, 'src', 'runtime'),sdkDistDir: path.join(REPO, 'sdk', 'dist'),wasmDir: opts.wasm ? path.resolve(opts.wasm) : engineRuntimeDir(platform),outDir,diff --git a/pipeline/src/bundle/runtimeHosts.ts b/pipeline/src/bundle/runtimeHosts.tsnew file mode 100644index 000000000..f1954d470--- /dev/null+++ b/pipeline/src/bundle/runtimeHosts.ts@@ -0,0 +1,38 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file runtimeHosts.ts — the browser-realm hosts an export bundles, named once.+ *+ * An export re-bundles every host by name from ONE directory: the sources in+ * `pipeline/src/runtime`, or the tree an editor prebuilds from them (a packaged+ * app ships no sources, and esbuild cannot read app.asar). The prebuild takes its+ * entries from this list as well, so a host the exporter asks for is a host the+ * editor ships — two lists kept by hand disagree without either failing to build.+ */+import path from 'node:path';+import { ESENGINE_EXTERNAL } from './esengineResolve';++export const RUNTIME_HOSTS = ['gameHost', 'playableHost', 'playableLoader'] as const;++export type RuntimeHost = (typeof RUNTIME_HOSTS)[number];++/**+ * The esbuild entry for `host` in `hostsDir`. Extensionless on purpose: the sources+ * are `.ts` and a prebuilt tree `.js`, and esbuild resolves either.+ */+export function runtimeHostEntry(hostsDir: string, host: RuntimeHost): string {+ return path.join(hostsDir, host);+}++/** esbuild options that prebuild every runtime host from `sourceDir` into `outdir`. */+export function runtimeHostPrebuild(sourceDir: string, outdir: string) {+ return {+ entryPoints: RUNTIME_HOSTS.map((host) => ({ in: path.join(sourceDir, `${host}.ts`), out: host })),+ outdir,+ bundle: true,+ format: 'esm' as const,+ platform: 'browser' as const,+ target: 'es2020',+ external: ESENGINE_EXTERNAL,+ };+}diff --git a/pipeline/src/export/exportGame.ts b/pipeline/src/export/exportGame.tsindex 93c1d9456..ddc371cc0 100644--- a/pipeline/src/export/exportGame.ts+++ b/pipeline/src/export/exportGame.ts@@ -21,6 +21,7 @@*/import type { BuildOptions, Plugin } from 'esbuild';import { loadEsbuild } from '../bundle/esbuildRuntime';+import { runtimeHostEntry } from '../bundle/runtimeHosts';import { writeFile, readFile, mkdir, cp, readdir, rm } from 'node:fs/promises';import { existsSync } from 'node:fs';import path from 'node:path';@@ -322,6 +323,7 @@ function esengineGlobalPlugin(): Plugin {export interface ExportGameOptions {root: string;+ /** The project-relative scene to boot. */entryScene: string;/** Project-relative scenes dir (manifest layout); default the entry's dir.* Every `.esscene` under it ships as a switchable scene. */@@ -329,10 +331,13 @@ export interface ExportGameOptions {/** Scenes excluded from the build (`packaging.excludeScenes`); the entry* scene always ships. */excludeScenes?: string[];- gameHostEntry: string;+ /** Where every runtime host is (runtimeHosts.ts): `pipeline/src/runtime`, or the+ * tree an editor prebuilt from it, since a packaged app ships no sources. */+ hostsDir: string;/** Project-relative startup entry (e.g. src/main.ts) → bundled to scripts.mjs. */scriptsEntry?: string;sdkDistDir: string;+ /** The engine runtime to copy. */wasmDir: string;outDir: string;/**@@ -350,8 +355,6 @@ export interface ExportGameOptions {atlasTextures?: boolean;title?: string;platform?: ExportPlatform;- /** Playable host source (src/playableHost.ts). */- playableHostEntry?: string;/** The ad network a playable targets (`packaging.platforms.playable.network`),* resolved by the caller since a project can define its own. Absent ⇒ generic. */playableAdProfile?: PlayableAdProfile;@@ -444,17 +447,10 @@ export interface ExportGameOptions {}/**- * Export the open project. `entryScene` is the project-relative scene to boot;- * `gameHostEntry` the game-host esbuild entry — the prebuilt realm-host bundle- * (dist-electron/hosts/gameHost.js; a packaged app ships no src/ and esbuild- * cannot read app.asar) or any source esbuild can reach (tests). `wasmDir` is- * the engine runtime to copy. `platform` selects the target (default web).- *- * Every target's package is WEIGHED here, at the one point they all pass- * through. The pipelines below return early for the mini-game, WeChat and- * playable targets — measuring inside each of them would be four accountings- * that drift, and a platform a project defines for itself would have none at- * all. See sizeReport.ts for what is counted.+ * Export the open project for `platform` (default web). Every target's package is+ * WEIGHED here, the one point they all pass through: measuring inside each early-+ * returning pipeline would be accountings that drift, and a platform a project+ * defines for itself would have none. See sizeReport.ts for what is counted.*/export async function exportGame(opts: ExportGameOptions): Promise<ExportGameResult> {return attachSizeReport(await produceExport(opts), opts);@@ -609,8 +605,7 @@ async function produceExport(opts: ExportGameOptions): Promise<ExportGameResult>root: opts.root,entryScene: opts.entryScene,scriptsEntry: opts.scriptsEntry,- // Default beside the game host, same flavor (prebuilt .js or a source .ts).- playableHostEntry: opts.playableHostEntry ?? path.join(path.dirname(opts.gameHostEntry), `playableHost${path.extname(opts.gameHostEntry)}`),+ hostsDir: opts.hostsDir,sdkDir: opts.sdkDistDir,wasmDir: opts.wasmDir,outDir: opts.outDir,@@ -739,7 +734,7 @@ async function produceExport(opts: ExportGameOptions): Promise<ExportGameResult>const { build } = await loadEsbuild();if (!nativeContent) {progress({ phase: 'Bundling game host' });- const host = await build({ ...common, entryPoints: [opts.gameHostEntry], outfile: path.join(payloadDir, 'game.js') });+ const host = await build({ ...common, entryPoints: [runtimeHostEntry(opts.hostsDir, 'gameHost')], outfile: path.join(payloadDir, 'game.js') });errors.push(...explainBundleErrors(host.errors));}// 3. Project bundle (defineComponent/defineSystem). ESM + esengine external ondiff --git a/pipeline/src/export/exportPlayable.ts b/pipeline/src/export/exportPlayable.tsindex c6f05cb55..bddf24d4e 100644--- a/pipeline/src/export/exportPlayable.ts+++ b/pipeline/src/export/exportPlayable.ts@@ -19,6 +19,7 @@* + fs); IPC wiring in main.ts.*/import { loadEsbuild } from '../bundle/esbuildRuntime';+import { runtimeHostEntry } from '../bundle/runtimeHosts';import {DEFAULT_RUNTIME_CONFIG, packagedRuntimeFields, type RuntimeProjectConfig,} from '../project/runtimeConfig';@@ -93,13 +94,6 @@ function pack(bytes: Uint8Array | Buffer): PackedBytes {return { z: deflateRawSync(bytes, { level: 9 }).toString('base64'), n: bytes.length };}-/** The loader lives beside the host it starts. One option names where the- * runtime's sources are, so a second way of finding them is a second thing to- * keep in step with a move. */-function loaderEntryFor(hostEntry: string): string {- return path.join(path.dirname(hostEntry), `playableLoader${path.extname(hostEntry)}`);-}-/*** The playable page. Deliberately WITHOUT the web export's rotate-to-fit overlay:* inside an ad SDK the container's size is the SDK's business, so `@media@@ -183,7 +177,7 @@ async function collectSideModules(/*** Export the open project as a single-file playable ad. Reuses the shipped WEB* engine runtime (esengine.js glue + esengine.wasm) inlined — no separate- * SINGLE_FILE build. `playableHostEntry` is the host source; `wasmDir` the web wasm dir.+ * SINGLE_FILE build. `hostsDir` holds the runtime hosts; `wasmDir` the web wasm dir.*//** The packaged fields minus what a playable's host cannot serve. */function playableRuntimeFields(rc: Parameters<typeof packagedRuntimeFields>[0]) {@@ -195,7 +189,7 @@ export async function exportPlayable(opts: {root: string;entryScene: string;scriptsEntry?: string;- playableHostEntry: string;+ hostsDir: string;/** Web SDK dist dir — `esengine` is INLINED for playable (no import map), so the* bundle aliases it here (the project root has no esengine to resolve). */sdkDir: string;@@ -287,7 +281,7 @@ export async function exportPlayable(opts: {const scriptsAbs = opts.scriptsEntry ? path.join(opts.root, opts.scriptsEntry) : null;const entrySrc =(scriptsAbs && existsSync(scriptsAbs) ? `import ${JSON.stringify(scriptsAbs)};\n` : '') +- `import ${JSON.stringify(opts.playableHostEntry)};\n`;+ `import ${JSON.stringify(runtimeHostEntry(opts.hostsDir, 'playableHost'))};\n`;let bundle = '';let loader = '';try {@@ -311,7 +305,7 @@ export async function exportPlayable(opts: {// Built apart from the game, because it is the one script the page can still// read: a loader inside the payload it inflates could never start it.const loaded = await build({- entryPoints: [loaderEntryFor(opts.playableHostEntry)],+ entryPoints: [runtimeHostEntry(opts.hostsDir, 'playableLoader')],bundle: true,format: 'iife',platform: 'browser',diff --git a/pipeline/tests/cooked-verify-fixture.test.ts b/pipeline/tests/cooked-verify-fixture.test.tsindex d4ab0c28c..28aacb659 100644--- a/pipeline/tests/cooked-verify-fixture.test.ts+++ b/pipeline/tests/cooked-verify-fixture.test.ts@@ -124,7 +124,7 @@ describe.skipIf(!process.env.ESTELLA_COOK_FIXTURE)('cooked-verify fixture', () =const res = await exportGame({root: SRC,entryScene: 'scenes/main.esscene',- gameHostEntry: path.resolve(HERE, '..', '..', 'pipeline', 'src', 'runtime', 'gameHost.ts'),+ hostsDir: path.resolve(HERE, '..', '..', 'pipeline', 'src', 'runtime'),scriptsEntry: 'src/main.ts',sdkDistDir: path.resolve(HERE, '..', '..', 'sdk', 'dist'),wasmDir: path.resolve(HERE, '..', '..', 'build', 'wasm', 'web'),@@ -139,7 +139,7 @@ describe.skipIf(!process.env.ESTELLA_COOK_FIXTURE)('cooked-verify fixture', () =const interp = await exportGame({root: SRC,entryScene: 'scenes/main.esscene',- gameHostEntry: path.resolve(HERE, '..', '..', 'pipeline', 'src', 'runtime', 'gameHost.ts'),+ hostsDir: path.resolve(HERE, '..', '..', 'pipeline', 'src', 'runtime'),scriptsEntry: 'src/main.ts',sdkDistDir: path.resolve(HERE, '..', '..', 'sdk', 'dist'),wasmDir: path.resolve(HERE, '..', '..', 'build', 'wasm', 'web'),diff --git a/pipeline/tests/export-aot.test.ts b/pipeline/tests/export-aot.test.tsindex 02563016c..df7f29e11 100644--- a/pipeline/tests/export-aot.test.ts+++ b/pipeline/tests/export-aot.test.ts@@ -19,7 +19,7 @@ import { exportGame } from '../src/export/exportGame';import { emccPath } from '../../build-tools/utils/emscripten.js';const HERE = path.dirname(fileURLToPath(import.meta.url));-const GAME_HOST = path.join(HERE, '..', 'src', 'runtime', 'gameHost.ts');+const HOSTS = path.join(HERE, '..', 'src', 'runtime');/** Where an export stages the module, and where the config points at it. */const STAGED = path.join('aot', 'systems.wasm');const EMCC = emccPath();@@ -73,7 +73,7 @@ function setup(files: Record<string, string>): { root: string; out: string } {}const run = (f: { root: string; out: string }) => exportGame({- root: f.root, entryScene: 'scenes/main.esscene', gameHostEntry: GAME_HOST,+ root: f.root, entryScene: 'scenes/main.esscene', hostsDir: HOSTS,scriptsEntry: 'src/main.ts',sdkDistDir: path.join(f.root, '_sdk'), wasmDir: path.join(f.root, '_wasm'),outDir: f.out,diff --git a/pipeline/tests/export-compiled-systems.test.ts b/pipeline/tests/export-compiled-systems.test.tsindex 4dce9d82c..5e39d0165 100644--- a/pipeline/tests/export-compiled-systems.test.ts+++ b/pipeline/tests/export-compiled-systems.test.ts@@ -22,7 +22,7 @@ import { exportGame } from '../src/export/exportGame';import { resolveEmcc } from '../src/bundle/emccPath';const HERE = path.dirname(fileURLToPath(import.meta.url));-const GAME_HOST = path.join(HERE, '..', 'src', 'runtime', 'gameHost.ts');+const HOSTS = path.join(HERE, '..', 'src', 'runtime');const SCN = 'cccccccc-cccc-cccc-cccc-cccccccccccc';const EMCC = resolveEmcc();@@ -85,7 +85,7 @@ function project(source: string | null): { root: string; out: string } {}const run = (f: { root: string; out: string }) => exportGame({- root: f.root, entryScene: 'scenes/main.esscene', gameHostEntry: GAME_HOST,+ root: f.root, entryScene: 'scenes/main.esscene', hostsDir: HOSTS,scriptsEntry: 'src/main.ts',sdkDistDir: path.join(f.root, '_sdk'), wasmDir: path.join(f.root, '_wasm'),outDir: f.out,@@ -95,7 +95,7 @@ const config = (out: string): PackagedGameConfig =>JSON.parse(readFileSync(path.join(out, 'game.config.json'), 'utf8')) as PackagedGameConfig;const runWeChat = (f: { root: string; out: string }) => exportGame({- root: f.root, entryScene: 'scenes/main.esscene', gameHostEntry: 'unused-for-wechat',+ root: f.root, entryScene: 'scenes/main.esscene', hostsDir: 'unused-for-wechat',scriptsEntry: 'src/main.ts', platform: 'wechat', wechatAppid: 'wxTEST0123456789',sdkDistDir: path.join(f.root, '_sdk'), wasmDir: path.join(f.root, '_wasm'),outDir: f.out,diff --git a/pipeline/tests/export-desktop.test.ts b/pipeline/tests/export-desktop.test.tsindex 348d7bdf2..f244d0170 100644--- a/pipeline/tests/export-desktop.test.ts+++ b/pipeline/tests/export-desktop.test.ts@@ -16,7 +16,7 @@ import { fileURLToPath } from 'node:url';import { exportGame } from '../src/export/exportGame';const HERE = path.dirname(fileURLToPath(import.meta.url));-const GAME_HOST = path.join(HERE, '..', '..', 'pipeline', 'src', 'runtime', 'gameHost.ts');+const HOSTS = path.join(HERE, '..', '..', 'pipeline', 'src', 'runtime');let root: string;let out: string;@@ -63,7 +63,7 @@ function fakeTemplate(os: 'macos' | 'windows'): string {const desktopExport = (outDir: string) => ({root,entryScene: 'scenes/main.esscene',- gameHostEntry: GAME_HOST,+ hostsDir: HOSTS,scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'),wasmDir: path.join(root, '_wasm'),@@ -77,7 +77,7 @@ describe('exportGame (desktop)', () => {const res = await exportGame({root,entryScene: 'scenes/main.esscene',- gameHostEntry: GAME_HOST,+ hostsDir: HOSTS,scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'),wasmDir: path.join(root, '_wasm'),@@ -188,7 +188,7 @@ describe('exportGame (desktop)', () => {const res = await exportGame({root,entryScene: 'scenes/main.esscene',- gameHostEntry: GAME_HOST,+ hostsDir: HOSTS,scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'),wasmDir: path.join(root, '_wasm'),diff --git a/pipeline/tests/export-native.test.ts b/pipeline/tests/export-native.test.tsindex 687ddb81b..9fa7a213d 100644--- a/pipeline/tests/export-native.test.ts+++ b/pipeline/tests/export-native.test.ts@@ -15,7 +15,7 @@ import { fileURLToPath } from 'node:url';import { exportGame } from '../src/export/exportGame';const HERE = path.dirname(fileURLToPath(import.meta.url));-const GAME_HOST = path.join(HERE, '..', '..', 'pipeline', 'src', 'runtime', 'gameHost.ts');+const HOSTS = path.join(HERE, '..', '..', 'pipeline', 'src', 'runtime');let root: string;let out: string;@@ -50,7 +50,7 @@ afterAll(() => rmSync(root, { recursive: true, force: true, maxRetries: 10, retrdescribe('exportGame (native app content)', () => {it('ships content only — cooked assets, manifests, scene, config', async () => {const res = await exportGame({- root, entryScene: 'scenes/main.esscene', gameHostEntry: GAME_HOST, scriptsEntry: 'src/main.ts',+ root, entryScene: 'scenes/main.esscene', hostsDir: HOSTS, scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'), wasmDir: path.join(root, '_wasm'), outDir: out,platform: 'android', title: 'NativeGame',});diff --git a/pipeline/tests/export-playable.test.ts b/pipeline/tests/export-playable.test.tsindex 96a8d0f12..a977e8a8c 100644--- a/pipeline/tests/export-playable.test.ts+++ b/pipeline/tests/export-playable.test.ts@@ -15,6 +15,8 @@ import path from 'node:path';import { fileURLToPath } from 'node:url';import { execFileSync } from 'node:child_process';import { exportGame } from '../src/export/exportGame';+import { runtimeHostPrebuild } from '../src/bundle/runtimeHosts';+import { build } from 'esbuild';import { inflateRaw } from '../src/runtime/inflate';/**@@ -45,7 +47,7 @@ function inlinedText(html: string, global: string, pick?: (v: PackedModules) =>}const HERE = path.dirname(fileURLToPath(import.meta.url));-const PLAYABLE_HOST = path.join(HERE, '..', '..', 'pipeline', 'src', 'runtime', 'playableHost.ts');+const HOSTS = path.join(HERE, '..', '..', 'pipeline', 'src', 'runtime');let root: string;let out: string;@@ -90,8 +92,7 @@ describe('exportGame (playable)', () => {const res = await exportGame({root,entryScene: 'scenes/main.esscene',- gameHostEntry: 'unused-for-playable',- playableHostEntry: PLAYABLE_HOST,+ hostsDir: HOSTS,scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'),wasmDir: path.join(root, '_wasm'),@@ -145,6 +146,26 @@ describe('exportGame (playable)', () => {expect(html).not.toContain('screen.orientation');}, 60_000);+ // The editor never bundles the hosts from their sources: a packaged app ships+ // none, so it exports from the tree it prebuilt. Every other test here reads the+ // sources, where a host the prebuild never emitted is still right beside them.+ it('packages from the host tree an editor prebuilds', async () => {+ const prebuilt = path.join(root, '_prebuilt-hosts');+ await build({ ...runtimeHostPrebuild(HOSTS, prebuilt), logLevel: 'silent' });+ const dir = path.join(root, 'dist-prebuilt');+ const res = await exportGame({+ root, entryScene: 'scenes/main.esscene', hostsDir: prebuilt, scriptsEntry: 'src/main.ts',+ sdkDistDir: path.join(root, '_sdk'), wasmDir: path.join(root, '_wasm'),+ outDir: dir, platform: 'playable', minify: false,+ });++ expect(res.errors).toEqual([]);+ const html = readFileSync(path.join(dir, 'index.html'), 'utf8');+ expect(inlinedText(html, '__GAME_BUNDLE__')).toContain('createObjectURL');+ // Outside the payload: the loader is the one script that starts it.+ expect(html).toContain('atob(__GAME_BUNDLE__.z)');+ }, 60_000);+// No dev build of a playable exists, so this target minifies unless told not// to — the opposite default from every other. Unminified spent 0.31MB of a// 2MB budget on whitespace.@@ -153,8 +174,7 @@ describe('exportGame (playable)', () => {const res = await exportGame({root,entryScene: 'scenes/main.esscene',- gameHostEntry: 'unused-for-playable',- playableHostEntry: PLAYABLE_HOST,+ hostsDir: HOSTS,scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'),wasmDir: path.join(root, '_wasm'),@@ -177,8 +197,7 @@ describe('exportGame (playable)', () => {it('injects the ad network profile head + CTA bridge, and warns against ITS limit', async () => {const o = path.join(root, 'dist-playable-network');const res = await exportGame({- root, entryScene: 'scenes/main.esscene', gameHostEntry: 'unused-for-playable',- playableHostEntry: PLAYABLE_HOST, scriptsEntry: 'src/main.ts',+ root, entryScene: 'scenes/main.esscene', hostsDir: HOSTS, scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'), wasmDir: path.join(root, '_wasm'),outDir: o, platform: 'playable',playableAdProfile: {@@ -213,8 +232,7 @@ describe('exportGame (playable)', () => {it('writes playable.zip for a zip-delivery network and measures that', async () => {const o = path.join(root, 'dist-playable-zip');const res = await exportGame({- root, entryScene: 'scenes/main.esscene', gameHostEntry: 'unused-for-playable',- playableHostEntry: PLAYABLE_HOST, scriptsEntry: 'src/main.ts',+ root, entryScene: 'scenes/main.esscene', hostsDir: HOSTS, scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'), wasmDir: path.join(root, '_wasm'),outDir: o, platform: 'playable',playableAdProfile: {@@ -246,8 +264,7 @@ describe('exportGame (playable)', () => {it('injects nothing and keeps the default cap with no network selected', async () => {const o = path.join(root, 'dist-playable-generic');const res = await exportGame({- root, entryScene: 'scenes/main.esscene', gameHostEntry: 'unused-for-playable',- playableHostEntry: PLAYABLE_HOST, scriptsEntry: 'src/main.ts',+ root, entryScene: 'scenes/main.esscene', hostsDir: HOSTS, scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'), wasmDir: path.join(root, '_wasm'),outDir: o, platform: 'playable',});@@ -267,8 +284,7 @@ describe('exportGame (playable)', () => {it('inlines the project camera fit as __GAME_SCREENFIT__ (only when opted in)', async () => {const o = path.join(root, 'dist-playable-fit');const res = await exportGame({- root, entryScene: 'scenes/main.esscene', gameHostEntry: 'unused-for-playable',- playableHostEntry: PLAYABLE_HOST, scriptsEntry: 'src/main.ts',+ root, entryScene: 'scenes/main.esscene', hostsDir: HOSTS, scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'), wasmDir: path.join(root, '_wasm'),outDir: o, platform: 'playable',runtime: runtimeConfigOf({@@ -291,8 +307,7 @@ describe('exportGame (playable)', () => {it('does not pin the page even when the project is portrait', async () => {const o = path.join(root, 'dist-playable-portrait');const res = await exportGame({- root, entryScene: 'scenes/main.esscene', gameHostEntry: 'unused-for-playable',- playableHostEntry: PLAYABLE_HOST, scriptsEntry: 'src/main.ts',+ root, entryScene: 'scenes/main.esscene', hostsDir: HOSTS, scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'), wasmDir: path.join(root, '_wasm'),outDir: o, title: 'Playable Demo', platform: 'playable', orientation: 'portrait',playableAdProfile: {@@ -340,7 +355,7 @@ export function packagedRuntimeInit(c){return c;}\n`);}const run = (r: string, o: string) => exportGame({- root: r, entryScene: 'scenes/main.esscene', gameHostEntry: 'x', playableHostEntry: PLAYABLE_HOST,+ root: r, entryScene: 'scenes/main.esscene', hostsDir: HOSTS,sdkDistDir: path.join(r, '_sdk'), wasmDir: path.join(r, '_wasm'), outDir: o, platform: 'playable',});@@ -353,7 +368,7 @@ export function packagedRuntimeInit(c){return c;}\n`);writeFileSync(path.join(r, 'scenes', 'main.esscene'),JSON.stringify({ version: '1.0', name: 'Main', entities: [{ id: 0, components: [] }] }));const res = await exportGame({- root: r, entryScene: 'scenes/main.esscene', gameHostEntry: 'x', playableHostEntry: PLAYABLE_HOST,+ root: r, entryScene: 'scenes/main.esscene', hostsDir: HOSTS,sdkDistDir: path.join(r, '_sdk'), wasmDir: path.join(r, '_wasm'), outDir: o, platform: 'playable',runtime: runtimeConfigOf({ features: { physics: { enabled: true, gravity: { x: 0, y: -20 } } } }),});@@ -441,7 +456,7 @@ export function packagedRuntimeInit(c){return c;}\n`);}const run = (r: string, o: string) => exportGame({- root: r, entryScene: 'scenes/main.esscene', gameHostEntry: 'x', playableHostEntry: PLAYABLE_HOST,+ root: r, entryScene: 'scenes/main.esscene', hostsDir: HOSTS,sdkDistDir: path.join(r, '_sdk'), wasmDir: path.join(r, '_wasm'), outDir: o, platform: 'playable',});diff --git a/pipeline/tests/export-progress.test.ts b/pipeline/tests/export-progress.test.tsindex f1ea0897b..95f14802c 100644--- a/pipeline/tests/export-progress.test.ts+++ b/pipeline/tests/export-progress.test.ts@@ -13,7 +13,7 @@ import { exportGame } from '../src/export/exportGame';import type { ExportProgress } from '../src/export/exportProgress';const HERE = path.dirname(fileURLToPath(import.meta.url));-const GAME_HOST = path.join(HERE, '..', '..', 'pipeline', 'src', 'runtime', 'gameHost.ts');+const HOSTS = path.join(HERE, '..', '..', 'pipeline', 'src', 'runtime');let root: string;const TEX = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa';@@ -46,7 +46,7 @@ describe('export progress', () => {const res = await exportGame({root,entryScene: 'scenes/main.esscene',- gameHostEntry: GAME_HOST,+ hostsDir: HOSTS,scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'),wasmDir: path.join(root, '_wasm'),@@ -71,7 +71,7 @@ describe('export progress', () => {const res = await exportGame({root,entryScene: 'scenes/main.esscene',- gameHostEntry: GAME_HOST,+ hostsDir: HOSTS,scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'),wasmDir: path.join(root, '_wasm'),diff --git a/pipeline/tests/export-project-platform.test.ts b/pipeline/tests/export-project-platform.test.tsindex 55443031d..827ba78cc 100644--- a/pipeline/tests/export-project-platform.test.ts+++ b/pipeline/tests/export-project-platform.test.ts@@ -91,7 +91,7 @@ describe('exportGame — a platform the project defines', () => {const res = await exportGame({root,entryScene: 'scenes/main.esscene',- gameHostEntry: 'unused',+ hostsDir: 'unused',sdkDistDir: path.join(root, '_sdk'),wasmDir: platform!.wasmDir,outDir: out,@@ -140,7 +140,7 @@ describe('exportGame — a platform the project defines', () => {const res = await exportGame({root,entryScene: 'scenes/main.esscene',- gameHostEntry: 'unused',+ hostsDir: 'unused',sdkDistDir: path.join(root, '_sdk'),wasmDir: path.join(root, '_wasm'),outDir: outBare,diff --git a/pipeline/tests/export-side-modules.test.ts b/pipeline/tests/export-side-modules.test.tsindex f0fbec2dd..ccb8ea2d0 100644--- a/pipeline/tests/export-side-modules.test.ts+++ b/pipeline/tests/export-side-modules.test.ts@@ -13,7 +13,7 @@ import { exportGame } from '../src/export/exportGame';import { runtimeConfigOf } from '../src/project/runtimeConfig';const HERE = path.dirname(fileURLToPath(import.meta.url));-const GAME_HOST = path.join(HERE, '..', '..', 'pipeline', 'src', 'runtime', 'gameHost.ts');+const HOSTS = path.join(HERE, '..', '..', 'pipeline', 'src', 'runtime');const SCN = 'cccccccc-cccc-cccc-cccc-cccccccccccc';const PFB = 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee';@@ -49,7 +49,7 @@ function setup(scene: unknown, extra?: (root: string) => void): Fixture {}const run = (f: Fixture, runtime?: Parameters<typeof exportGame>[0]['runtime']) => exportGame({- root: f.root, entryScene: 'scenes/main.esscene', gameHostEntry: GAME_HOST,+ root: f.root, entryScene: 'scenes/main.esscene', hostsDir: HOSTS,sdkDistDir: path.join(f.root, '_sdk'), wasmDir: path.join(f.root, '_wasm'),outDir: f.out, ...(runtime ? { runtime } : {}),});diff --git a/pipeline/tests/export-source-maps.test.ts b/pipeline/tests/export-source-maps.test.tsindex e9032f71c..eca077196 100644--- a/pipeline/tests/export-source-maps.test.ts+++ b/pipeline/tests/export-source-maps.test.ts@@ -12,7 +12,7 @@ import { fileURLToPath } from 'node:url';import { exportGame } from '../src/export/exportGame';const HERE = path.dirname(fileURLToPath(import.meta.url));-const GAME_HOST = path.join(HERE, '..', '..', 'pipeline', 'src', 'runtime', 'gameHost.ts');+const HOSTS = path.join(HERE, '..', '..', 'pipeline', 'src', 'runtime');const SCN = 'ffffffff-ffff-ffff-ffff-ffffffffffff';const meta = (uuid: string, type: string) => JSON.stringify({ uuid, version: '2.0', type, importer: {} });@@ -39,7 +39,7 @@ function setup(): { root: string; out: string } {}const run = (f: { root: string; out: string }, sourcemap?: boolean) => exportGame({- root: f.root, entryScene: 'scenes/main.esscene', gameHostEntry: GAME_HOST,+ root: f.root, entryScene: 'scenes/main.esscene', hostsDir: HOSTS,sdkDistDir: path.join(f.root, '_sdk'), wasmDir: path.join(f.root, '_wasm'),outDir: f.out, ...(sourcemap === undefined ? {} : { sourcemap }),});diff --git a/pipeline/tests/export-wechat-audio-src.test.ts b/pipeline/tests/export-wechat-audio-src.test.tsindex 9cb564a64..dfd7d1713 100644--- a/pipeline/tests/export-wechat-audio-src.test.ts+++ b/pipeline/tests/export-wechat-audio-src.test.ts@@ -71,7 +71,7 @@ describe('the source a cooked mini-game hands its audio player', () => {const res = await exportGame({root,entryScene: 'scenes/main.esscene',- gameHostEntry: 'unused-for-wechat',+ hostsDir: 'unused-for-wechat',sdkDistDir: path.join(root, '_sdk'),wasmDir: path.join(root, '_wxwasm'),outDir: out,diff --git a/pipeline/tests/export-wechat-read-paths.test.ts b/pipeline/tests/export-wechat-read-paths.test.tsindex 8c0071b78..de5a6a167 100644--- a/pipeline/tests/export-wechat-read-paths.test.ts+++ b/pipeline/tests/export-wechat-read-paths.test.ts@@ -85,7 +85,7 @@ describe('exportGame (wechat) — every asset resolves to a file the package carconst res = await exportGame({root,entryScene: 'scenes/main.esscene',- gameHostEntry: 'unused-for-wechat',+ hostsDir: 'unused-for-wechat',scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'),wasmDir: path.join(root, '_wxwasm'),diff --git a/pipeline/tests/export-wechat-subpackage.test.ts b/pipeline/tests/export-wechat-subpackage.test.tsindex 487f7d24b..a2c50d0e4 100644--- a/pipeline/tests/export-wechat-subpackage.test.ts+++ b/pipeline/tests/export-wechat-subpackage.test.ts@@ -60,7 +60,7 @@ describe('WeChat 分包 declared through asset-groups.json', () => {const res = await exportGame({root,entryScene: 'scenes/main.esscene',- gameHostEntry: 'unused-for-wechat',+ hostsDir: 'unused-for-wechat',scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'),wasmDir: path.join(root, '_wxwasm'),@@ -122,7 +122,7 @@ describe('WeChat 分包 declared through asset-groups.json', () => {const res = await exportGame({root: root2,entryScene: 'scenes/main.esscene',- gameHostEntry: 'unused-for-wechat',+ hostsDir: 'unused-for-wechat',sdkDistDir: path.join(root2, '_sdk'),wasmDir: path.join(root2, '_wxwasm'),outDir: out2,@@ -178,7 +178,7 @@ describe('WeChat 分包 declared through asset-groups.json', () => {const res = await exportGame({root: root2,entryScene: 'scenes/main.esscene',- gameHostEntry: 'unused-for-wechat',+ hostsDir: 'unused-for-wechat',sdkDistDir: path.join(root2, '_sdk'),wasmDir: path.join(root2, '_wxwasm'),outDir: out2,diff --git a/pipeline/tests/export-wechat.test.ts b/pipeline/tests/export-wechat.test.tsindex 439479506..d22ee3af7 100644--- a/pipeline/tests/export-wechat.test.ts+++ b/pipeline/tests/export-wechat.test.ts@@ -58,7 +58,7 @@ describe('exportGame (wechat)', () => {const res = await exportGame({root,entryScene: 'scenes/main.esscene',- gameHostEntry: 'unused-for-wechat',+ hostsDir: 'unused-for-wechat',scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'),wasmDir: path.join(root, '_wxwasm'),@@ -135,7 +135,7 @@ describe('exportGame (wechat)', () => {const res = await exportGame({root,entryScene: 'scenes/main.esscene',- gameHostEntry: 'unused-for-wechat',+ hostsDir: 'unused-for-wechat',scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'),wasmDir: wxDir,@@ -176,7 +176,7 @@ describe('exportGame (wechat)', () => {const res = await exportGame({root,entryScene: 'scenes/main.esscene',- gameHostEntry: 'unused-for-wechat',+ hostsDir: 'unused-for-wechat',scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'),wasmDir: path.join(root, '_wxwasm'),@@ -211,7 +211,7 @@ describe('exportGame (wechat)', () => {const res = await exportGame({root,entryScene: 'scenes/main.esscene',- gameHostEntry: 'unused-for-wechat',+ hostsDir: 'unused-for-wechat',scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'),wasmDir: path.join(root, '_wxwasm'),@@ -251,7 +251,7 @@ describe('exportGame (wechat)', () => {const res = await exportGame({root,entryScene: 'scenes/main.esscene',- gameHostEntry: 'unused-for-wechat',+ hostsDir: 'unused-for-wechat',scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'),wasmDir: path.join(root, '_wxwasm'),@@ -271,7 +271,7 @@ describe('exportGame (wechat)', () => {const res = await exportGame({root,entryScene: 'scenes/main.esscene',- gameHostEntry: 'unused-for-wechat',+ hostsDir: 'unused-for-wechat',scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'),wasmDir: path.join(root, '_no-such-wasm'),@@ -308,7 +308,7 @@ describe('exportGame (wechat)', () => {const res = await exportGame({root,entryScene: 'scenes-spine/spine.esscene',- gameHostEntry: 'unused-for-wechat',+ hostsDir: 'unused-for-wechat',scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'),wasmDir: wxDir,@@ -334,7 +334,7 @@ describe('exportGame (wechat)', () => {const res = await exportGame({root,entryScene: 'scenes-spine/spine.esscene',- gameHostEntry: 'unused-for-wechat',+ hostsDir: 'unused-for-wechat',scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'),wasmDir: path.join(root, '_wxwasm'), // engine only — no spine42@@ -367,7 +367,7 @@ describe('exportGame (wechat)', () => {const res = await exportGame({root,entryScene: 'scenes-ktx2/ktx2.esscene',- gameHostEntry: 'unused-for-wechat',+ hostsDir: 'unused-for-wechat',scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'),wasmDir: wxDir,@@ -395,7 +395,7 @@ describe('exportGame (wechat)', () => {const res = await exportGame({root,entryScene: 'scenes-ktx2/ktx2.esscene',- gameHostEntry: 'unused-for-wechat',+ hostsDir: 'unused-for-wechat',scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'),wasmDir: path.join(root, '_wxwasm'), // engine only — no basis@@ -420,7 +420,7 @@ describe('exportGame (wechat)', () => {const res = await exportGame({root,entryScene: 'scenes/main.esscene',- gameHostEntry: 'unused-for-wechat',+ hostsDir: 'unused-for-wechat',scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'),wasmDir: path.join(root, '_wxwasm'),@@ -438,7 +438,7 @@ describe('exportGame (wechat)', () => {const res = await exportGame({root,entryScene: 'scenes/main.esscene',- gameHostEntry: 'unused-for-wechat',+ hostsDir: 'unused-for-wechat',scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'),wasmDir: path.join(root, '_wxwasm'),@@ -482,7 +482,7 @@ describe('exportGame (wechat)', () => {const res = await exportGame({root,entryScene: 'scenes-multi/main.esscene',- gameHostEntry: 'unused-for-wechat',+ hostsDir: 'unused-for-wechat',scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'),wasmDir: path.join(root, '_wxwasm'),@@ -550,7 +550,7 @@ describe('exportGame (wechat) — open data context', () => {const exportIt = (root: string, out: string) => exportGame({root,entryScene: 'scenes/main.esscene',- gameHostEntry: 'unused-for-wechat',+ hostsDir: 'unused-for-wechat',sdkDistDir: path.join(root, '_sdk'),wasmDir: path.join(root, '_wxwasm'),outDir: out,diff --git a/pipeline/tests/hotupdate-verify-fixture.test.ts b/pipeline/tests/hotupdate-verify-fixture.test.tsindex 3c30d878c..c7edfc936 100644--- a/pipeline/tests/hotupdate-verify-fixture.test.ts+++ b/pipeline/tests/hotupdate-verify-fixture.test.ts@@ -26,7 +26,7 @@ const REDSRC = path.join(ROOT, 'red-src');const opts = (root: string, outDir: string) => ({root,entryScene: 'assets/scenes/main.esscene',- gameHostEntry: path.resolve(HERE, '..', '..', 'pipeline', 'src', 'runtime', 'gameHost.ts'),+ hostsDir: path.resolve(HERE, '..', '..', 'pipeline', 'src', 'runtime'),scriptsEntry: 'src/main.ts',sdkDistDir: path.resolve(HERE, '..', '..', 'sdk', 'dist'),wasmDir: path.resolve(HERE, '..', '..', 'build', 'wasm', 'web'),diff --git a/pipeline/tests/streamed-world-targets.test.ts b/pipeline/tests/streamed-world-targets.test.tsindex 26366ec7a..e70ab972e 100644--- a/pipeline/tests/streamed-world-targets.test.ts+++ b/pipeline/tests/streamed-world-targets.test.ts@@ -38,7 +38,7 @@ describe('targets that cannot ship a cut world', () => {entryScene: 'assets/scenes/main.esscene',outDir: path.join(project, 'out'),platform: 'playable',- gameHostEntry: path.join(project, 'host.ts'),+ hostsDir: path.join(project, 'hosts'),// Never reached: the refusal happens before anything is staged.sdkDistDir: path.join(project, 'sdk'),wasmDir: path.join(project, 'wasm'),diff --git a/pipeline/tests/target-support.test.ts b/pipeline/tests/target-support.test.tsindex 85e3740a0..50455628c 100644--- a/pipeline/tests/target-support.test.ts+++ b/pipeline/tests/target-support.test.ts@@ -22,7 +22,7 @@ import { exportGame } from '../src/export/exportGame';const HERE = path.dirname(fileURLToPath(import.meta.url));const REPO = path.resolve(HERE, '..', '..');-const GAME_HOST = path.join(HERE, '..', '..', 'pipeline', 'src', 'runtime', 'gameHost.ts');+const HOSTS = path.join(HERE, '..', '..', 'pipeline', 'src', 'runtime');describe('collectSubsystems', () => {it('sees components wherever they sit in the document', () => {@@ -133,7 +133,7 @@ describe('exportGame warns about content the target cannot render', () => {afterAll(() => rmSync(root, { recursive: true, force: true, maxRetries: 10, retryDelay: 50 }));const run = (platform: 'android' | 'web', outDir: string) => exportGame({- root, entryScene: 'scenes/main.esscene', gameHostEntry: GAME_HOST,+ root, entryScene: 'scenes/main.esscene', hostsDir: HOSTS,sdkDistDir: path.join(root, '_sdk'), wasmDir: path.join(root, '_wasm'),outDir, platform, title: 'Game',});