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 mini-game takes the engine build a mini-game host can load
esengine27e81e23bd48
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 3fab30901..7c982201a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -14,6 +14,10 @@ published separately; it ships inside the editor.## [Unreleased]+### Fixed++- **A Douyin package could not start.** It shipped the browser engine artifact, which is an ES module, and a mini-game host loads its JavaScript with `require` — so `game.js` threw `SyntaxError: Unexpected token 'export'` on its first line and the package never reached a frame. Every mini-game host takes the same engine build, and now every mini-game target asks for it: the two built-in vendors, and a platform a project defines itself, which had the same browser default. The export also refuses an ES module engine by reading the file rather than trusting its name, since the name was the thing that was wrong.+### Changed- **A dialog's title now looks like one.** The editor's type scale stopped at 14px and useddiff --git a/desktop b/desktopindex 9d673159d..8418686ce 160000--- a/desktop+++ b/desktop@@ -1 +1 @@-Subproject commit 9d673159d10fa602c64574afe76a41d675bb3f23+Subproject commit 8418686ced3e07e0c87d3c3623bfff19590870a0diff --git a/pipeline/bin/estella.mjs b/pipeline/bin/estella.mjsindex 71887079f..1454f67f1 100644--- a/pipeline/bin/estella.mjs+++ b/pipeline/bin/estella.mjs@@ -565,11 +565,11 @@ function projectSettings(projectDir) {/*** The engine runtime for this target. The build tree is preferred over the copy* synced into the editor's public/, so a machine that built the engine and never- * built the editor can still package. WeChat's is a different build (WXWebAssembly- * glue) — handing it the web one produces a package that cannot boot on a device.+ * built the editor can still package. A mini-game takes a different build of the+ * same engine — handing it the web one is a syntax error at the first `require`.*/function engineRuntimeDir(platform) {- const dirs = platform === 'wechat'+ const dirs = fmt.isMiniGamePlatform(platform)? [path.join(REPO, 'build', 'wasm', 'wechat'), path.join(REPO, 'desktop', 'public', 'wasm-wechat')]: [path.join(REPO, 'build', 'wasm', 'web'), path.join(REPO, 'desktop', 'public', 'wasm')];return firstExisting(dirs) ?? dirs[dirs.length - 1];diff --git a/pipeline/src/export/exportMiniGame.ts b/pipeline/src/export/exportMiniGame.tsindex 2e1c21bbf..b88bb4109 100644--- a/pipeline/src/export/exportMiniGame.ts+++ b/pipeline/src/export/exportMiniGame.ts@@ -47,7 +47,7 @@ import { breakdownOf, type ModuleBytes } from './bundleBreakdown';import { esengineAlias } from '../bundle/esengineResolve';import { explainBundleErrors, type BundleMessage } from '../bundle/bundleDiagnostics';import { scanSideModuleIds, sideModuleFiles, textureDecoderBytes } from '../bundle/sideModuleScan';-import { OPEN_DATA_DIR } from './miniGameExportProfile';+import { OPEN_DATA_DIR, isEsModule } from './miniGameExportProfile';import { loadProjectModules, sideModuleDeclarations, stageProjectModules } from './projectModules';import { buildCompiledSystems, type BuildMode } from '../bundle/buildCompiledSystems';import { resolveEmcc, runEmcc } from '../bundle/emccPath';@@ -288,8 +288,7 @@ export async function exportMiniGame(profile: MiniGameExportProfile, opts: {// 0. The generated entry unconditionally requires the engine glue, so a// missing vendor runtime cannot produce a runnable package — fail before- // cooking. Require by its ACTUAL name in the wasm dir (the -t wechat- // build emits esengine.wxgame.js; a web-aligned build, esengine.js).+ // cooking. By its ACTUAL name in the wasm dir; see MINIGAME_ENGINE_GLUE.const engineGlueFile = profile.engineGlueCandidates.find((f) => existsSync(path.join(opts.wasmDir, f)));if (!engineGlueFile) {@@ -306,6 +305,17 @@ export async function exportMiniGame(profile: MiniGameExportProfile, opts: {return { ok: false, platform: profile.id, outDir: absOut, included: 0, warnings, errors };}+ // ...and it has to be a build this host can load. The browser artifact throws+ // `Unexpected token 'export'` at the entry's first line: a package that exports+ // clean, installs, and never reaches a frame.+ if (isEsModule(await readFile(path.join(opts.wasmDir, engineGlueFile), 'utf8'))) {+ errors.push(+ `${path.join(opts.wasmDir, engineGlueFile)} is an ES module, and a ${profile.id} package requires its engine — `+ + `build the mini-game engine with \`node build-tools/cli.js build -t ${profile.wasmBuildHint}\``,+ );+ return { ok: false, platform: profile.id, outDir: absOut, included: 0, warnings, errors };+ }+await mkdir(absOut, { recursive: true });// Every switchable scene ships; the exporter's caller (exportGame) discoversdiff --git a/pipeline/src/export/miniGameExportProfile.ts b/pipeline/src/export/miniGameExportProfile.tsindex 18278cf92..be381c543 100644--- a/pipeline/src/export/miniGameExportProfile.ts+++ b/pipeline/src/export/miniGameExportProfile.ts@@ -53,6 +53,25 @@ export interface MiniGameConfigContext {*/export const OPEN_DATA_DIR = 'open-data';+/**+ * The engine build EVERY mini-game host takes, and the `build -t` that makes it:+ * these runtimes load JS through `require`, and the browser artifact is an ES+ * module. The filename says WeChat only because WeChat came first — the glue+ * names no vendor API, so `wx` and `tt` run the same bytes.+ */+export const MINIGAME_ENGINE_GLUE: readonly string[] = ['esengine.wxgame.js', 'esengine.js'];+export const MINIGAME_ENGINE_BUILD = 'wechat';++/**+ * Whether this glue is the ES module build, which no mini-game host can load.+ *+ * Read off the artifact, not the filename — the filename is what was wrong.+ * Emscripten emits `export default` in an ESM build and never in a CommonJS one.+ */+export function isEsModule(glue: string): boolean {+ return /\bexport\s+default\b/.test(glue);+}+/** Vendor-neutral facts the pipeline computes, handed to the entry emitter. */export interface MiniGameEntryContext {/** Optional modules the shipped scenes need (physics/spine/basis/videodec). */@@ -242,13 +261,11 @@ export const wechatExportProfile: MiniGameExportProfile = {sdkLeanEntryFile: 'index.wechat.lean.js',runtimeInit: 'initWeChatRuntime',platformInit: 'initWeChatPlatform',- // Require by the ACTUAL name in the wasm dir: the -t wechat build emits- // esengine.wxgame.js; a web-aligned build, esengine.js.- engineGlueCandidates: ['esengine.wxgame.js', 'esengine.js'],+ engineGlueCandidates: MINIGAME_ENGINE_GLUE,// Real-device WeChat rejects es2020 syntax (`??`, `?.`) even though devtools// accepts it; es2017 down-levels those while keeping async/await.esTarget: 'es2017',- wasmBuildHint: 'wechat',+ wasmBuildHint: MINIGAME_ENGINE_BUILD,hostGlobal: 'wx',sideModuleBuildTargets: WECHAT_MODULE_BUILD_TARGET,// Script + config WeChat's packer compiles itself; every OTHER staged custom@@ -318,12 +335,13 @@ export const douyinExportProfile: MiniGameExportProfile = {sdkEntryFile: 'index.minigame.js',runtimeInit: 'initMiniGameRuntime',runtimeProfileHost: 'douyinPlatformProfile',- // No Douyin-specific engine build: the web artifact is what a `tt` host runs.- engineGlueCandidates: ['esengine.js'],+ // No Douyin-specific engine build — and no web one either: the mini-game+ // build is the family's, see MINIGAME_ENGINE_GLUE.+ engineGlueCandidates: MINIGAME_ENGINE_GLUE,// Same floor as WeChat until a device says otherwise — down-levelling costs// nothing and a syntax error on a phone costs a release.esTarget: 'es2017',- wasmBuildHint: 'web',+ wasmBuildHint: MINIGAME_ENGINE_BUILD,hostGlobal: 'tt',sideModuleBuildTargets: {},// Assumed to match WeChat, not read from a Douyin doc: script and config arediff --git a/pipeline/src/export/platformCatalog.ts b/pipeline/src/export/platformCatalog.tsindex 8e9d6393b..ad277ee8a 100644--- a/pipeline/src/export/platformCatalog.ts+++ b/pipeline/src/export/platformCatalog.ts@@ -34,7 +34,7 @@ import { BUILTIN_PLATFORMS, DESKTOP_OSES, compileTargetFor, desktopTemplateFor,import { promisesCompilation } from '../bundle/buildCompiledSystems';import { resolveNativeTemplate } from './nativeTemplates';import { templateId } from '../../../build-tools/utils/nativeTemplate.js';-import type { MiniGameExportProfile, MiniGameConfigContext } from './miniGameExportProfile';+import { MINIGAME_ENGINE_BUILD, MINIGAME_ENGINE_GLUE, type MiniGameExportProfile, type MiniGameConfigContext } from './miniGameExportProfile';/** Where a project keeps its own platform profiles. */export const PROJECT_PLATFORM_DIR = path.join('.esengine', 'platforms');@@ -43,8 +43,10 @@ export const PROJECT_PLATFORM_DIR = path.join('.esengine', 'platforms');export interface PlatformRuntimeDirs {/** Web/playable engine runtime (esengine.js + esengine.wasm). */web: string;- /** WeChat engine runtime (esengine.wxgame.js + .wasm). */- wechat: string;+ /** The mini-game engine runtime every vendor takes — see MINIGAME_ENGINE_GLUE.+ * The directory is what makes a package's engine CommonJS; the filename in it+ * is only a name, and a project's own vendor dir may use either. */+ minigame: string;}/** What the renderer needs to draw one platform row. Serializable by construction. */@@ -112,9 +114,13 @@ function builtinReadiness(: { ready: false, prereq: { kind: 'runtime-missing', dir: posix(dirs.web), looked: ['esengine.js'], command: 'node build-tools/cli.js build -t web' } };case 'wechat':- return has(dirs.wechat, 'esengine.wxgame.js') || has(dirs.wechat, 'esengine.js')+ case 'douyin':+ // One probe for the family: they run the same engine build, so a machine+ // ready for one is ready for the other — and answering otherwise offers a+ // build command that produces a file the target already has.+ return MINIGAME_ENGINE_GLUE.some((g) => has(dirs.minigame, g))? { ready: true }- : { ready: false, prereq: { kind: 'runtime-missing', dir: posix(dirs.wechat), looked: ['esengine.wxgame.js'], command: 'node build-tools/cli.js build -t wechat' } };+ : { ready: false, prereq: { kind: 'runtime-missing', dir: posix(dirs.minigame), looked: [...MINIGAME_ENGINE_GLUE], command: `node build-tools/cli.js build -t ${MINIGAME_ENGINE_BUILD}` } };case 'android':// The runtime template is the whole prerequisite: the APK is assembled and@@ -148,16 +154,16 @@ function builtinReadiness(/*** Everything a mini-game export profile needs when the project did not say.- * Defaults describe a STANDARD host: the vendor-neutral SDK entry, the standard- * `WebAssembly` engine glue, and the generic entry above. A project platform- * that matches those supplies only `id`, `label` and `emitConfigFiles`.+ * Defaults describe a STANDARD host: the vendor-neutral SDK entry, the engine+ * build every mini-game host takes, and the generic entry above. A project+ * platform that matches those supplies only `id`, `label` and `emitConfigFiles`.*/export const MINIGAME_PROFILE_DEFAULTS = {sdkEntryFile: 'index.minigame.js',runtimeInit: 'initMiniGameRuntime',- engineGlueCandidates: ['esengine.js'] as readonly string[],+ engineGlueCandidates: MINIGAME_ENGINE_GLUE,esTarget: 'es2017' as const,- wasmBuildHint: 'web',+ wasmBuildHint: MINIGAME_ENGINE_BUILD,sideModuleBuildTargets: {} as Readonly<Record<string, string>>,nativeSuffixes: new Set(['.js', '.json']) as ReadonlySet<string>,// A project's own vendor publishes neither a whitelist nor an API global, so@@ -190,7 +196,7 @@ export interface ProjectPlatformModule extends Partial<MiniGameExportProfile>, Pblurb?: string;defaultOut?: string;/** Engine runtime dir for this platform, relative to the project root.- * Absent → the editor's web runtime. */+ * Absent → the mini-game runtime the editor ships. */wasmDir?: string;/*** Project-relative module whose default export is the RUNTIME@@ -522,7 +528,7 @@ export async function loadProjectPlatform(root: string, id: string, dirs: Platfoconst profile = { ...MINIGAME_PROFILE_DEFAULTS, ...mod, runtimeProfileModule } as MiniGameExportProfile;const wasmDir = mod.wasmDir? (path.isAbsolute(mod.wasmDir) ? mod.wasmDir : path.join(root, mod.wasmDir))- : dirs.web;+ : dirs.minigame;return { profile, wasmDir, defaultOut: mod.defaultOut ?? `dist-${id}` };}return null;@@ -661,7 +667,7 @@ export async function listPlatforms(if (mod.kind === 'playable') continue;const wasmDir = mod.wasmDir? (path.isAbsolute(mod.wasmDir) ? mod.wasmDir : path.join(root, mod.wasmDir))- : dirs.web;+ : dirs.minigame;// A runtime half that points nowhere is caught here rather than on a device:// the export would bundle fine and then fail to resolve the import.if (mod.runtimeProfile) {diff --git a/pipeline/src/project/platforms.ts b/pipeline/src/project/platforms.tsindex 243dec341..e710766b3 100644--- a/pipeline/src/project/platforms.ts+++ b/pipeline/src/project/platforms.ts@@ -56,6 +56,20 @@ export function isNativePlatform(platform: ExportPlatform): platform is NativePlreturn (NATIVE_PLATFORMS as readonly string[]).includes(platform);}+/**+ * The targets that ship as a mini-game: a CommonJS package plus a vendor global.+ *+ * They share an engine build the way the native targets share a runtime. A+ * project's own vendor is one of these without appearing here, so that build+ * lives in the family's export defaults rather than behind this list.+ */+export const MINIGAME_PLATFORMS = ['wechat', 'douyin'] as const;+export type MiniGamePlatform = (typeof MINIGAME_PLATFORMS)[number];++export function isMiniGamePlatform(platform: ExportPlatform): platform is MiniGamePlatform {+ return (MINIGAME_PLATFORMS as readonly string[]).includes(platform);+}+/*** The desktop OSes one `desktop` target is assembled for — per-OS where the* platform id is not, because the binaries are.diff --git a/pipeline/tests/export-douyin.test.ts b/pipeline/tests/export-douyin.test.tsindex 1e0b7abc0..aa4cffc29 100644--- a/pipeline/tests/export-douyin.test.ts+++ b/pipeline/tests/export-douyin.test.ts@@ -4,8 +4,9 @@* @file Douyin MiniGame export — that a second vendor needed no second pipeline.* Asserts the four things that are Douyin's and not WeChat's: the config* file it writes, the host it names, the entry that installs a platform- * rather than assuming one, and the caps it is judged against.- * (Boot correctness is a device's to answer — see RM-032.)+ * rather than assuming one, and the caps it is judged against — plus the+ * one thing it shares with WeChat and got wrong: which engine build a+ * mini-game host can load at all.*/import { describe, it, expect, beforeAll, afterAll } from 'vitest';import { runtimeConfigOf } from '../src/project/runtimeConfig';@@ -41,10 +42,11 @@ beforeAll(() => {mkdirSync(path.join(root, '_sdk', 'douyin'), { recursive: true });writeFileSync(path.join(root, '_sdk', 'douyin', 'index.js'),'export const douyinProfile = { id: "douyin", hostLabel: "\\u6296\\u97f3" };\n');- // The web engine artifact: Douyin has no build of its own.+ // The MINI-GAME engine artifact, under the name that build emits: Douyin has+ // no build of its own and cannot take the browser one, which is an ES module.mkdirSync(path.join(root, '_wasm'), { recursive: true });- writeFileSync(path.join(root, '_wasm', 'esengine.js'), 'module.exports = () => Promise.resolve({});');- writeFileSync(path.join(root, '_wasm', 'esengine.wasm'), 'wasmbytes');+ writeFileSync(path.join(root, '_wasm', 'esengine.wxgame.js'), 'module.exports = () => Promise.resolve({});');+ writeFileSync(path.join(root, '_wasm', 'esengine.wxgame.wasm'), 'wasmbytes');out = path.join(root, 'dist-douyin');}, 60_000);@@ -94,6 +96,39 @@ describe('exportGame (douyin)', () => {expect(bundle).toContain('douyin');});+ it('requires the mini-game engine build, which is the one a `tt` host can load', () => {+ // Douyin shipped the browser artifact for its first two versions: the package+ // built clean, installed, and died on `require` with `Unexpected token+ // 'export'` before the first frame. The entry names what it got.+ expect(readFileSync(path.join(out, 'game.js'), 'utf8'))+ .toContain("require('./wasm/esengine.wxgame.js')");+ });++ it('refuses to package an ES module engine rather than shipping a dead one', async () => {+ const esmRoot = path.join(root, '_esm-wasm');+ mkdirSync(esmRoot, { recursive: true });+ // The browser artifact, by the shape that makes it one — under the name a+ // hand-assembled vendor dir tends to use, so only the CONTENT can catch it.+ writeFileSync(path.join(esmRoot, 'esengine.js'), 'const M = () => {};\nexport default M;\n');+ writeFileSync(path.join(esmRoot, 'esengine.wasm'), 'wasmbytes');+ const res = await exportGame({+ root,+ entryScene: 'scenes/main.esscene',+ hostsDir: path.resolve(__dirname, '../src/runtime'),+ sdkDistDir: path.join(root, '_sdk'),+ wasmDir: esmRoot,+ outDir: path.join(root, 'dist-douyin-esm'),+ title: 'My Game',+ platform: 'douyin',+ orientation: 'landscape',+ runtime: runtimeConfigOf({ designResolution: { width: 1280, height: 720 } }),+ });+ expect(res.ok).toBe(false);+ expect(res.errors.join('\n')).toContain('is an ES module');+ // And it says what to run, since the fix is a build and not a setting.+ expect(res.errors.join('\n')).toContain('build -t wechat');+ }, 180_000);+it('is judged against Douyin\'s caps, which are not WeChat\'s', () => {const budgets = builtinSizeBudgets('douyin');const total = budgets.find((b) => b.scope === 'total');diff --git a/pipeline/tests/export-project-platform.test.ts b/pipeline/tests/export-project-platform.test.tsindex 827ba78cc..de533c188 100644--- a/pipeline/tests/export-project-platform.test.ts+++ b/pipeline/tests/export-project-platform.test.ts@@ -85,7 +85,7 @@ afterAll(() => rmSync(root, { recursive: true, force: true, maxRetries: 10, retrdescribe('exportGame — a platform the project defines', () => {it('packages through the mini-game pipeline and joins the vendor\'s two halves', async () => {- const platform = await loadProjectPlatform(root, 'acme-play', { web: path.join(root, '_wasm'), wechat: path.join(root, '_wasm') });+ const platform = await loadProjectPlatform(root, 'acme-play', { web: path.join(root, '_wasm'), minigame: path.join(root, '_wasm') });expect(platform).not.toBeNull();const res = await exportGame({@@ -133,7 +133,7 @@ describe('exportGame — a platform the project defines', () => {it('omits the install when the project installs its own platform', async () => {// Same vendor, minus the runtimeProfile link: the game is then responsible// for calling installMiniGamePlatform itself, so the entry must not guess.- const bare = { ...(await loadProjectPlatform(root, 'acme-play', { web: path.join(root, '_wasm'), wechat: path.join(root, '_wasm') }))!.profile };+ const bare = { ...(await loadProjectPlatform(root, 'acme-play', { web: path.join(root, '_wasm'), minigame: path.join(root, '_wasm') }))!.profile };delete (bare as { runtimeProfileModule?: string }).runtimeProfileModule;const outBare = path.join(root, 'dist-bare');diff --git a/pipeline/tests/native-template.test.ts b/pipeline/tests/native-template.test.tsindex 623b2bde9..39072527d 100644--- a/pipeline/tests/native-template.test.ts+++ b/pipeline/tests/native-template.test.ts@@ -288,7 +288,7 @@ describe('downloading a template from a release', () => {});describe('the iOS row reports what is missing', () => {- const dirs = () => ({ web: path.join(scratch, 'web'), wechat: path.join(scratch, 'wx') });+ const dirs = () => ({ web: path.join(scratch, 'web'), minigame: path.join(scratch, 'wx') });const iosRow = async () => (await listPlatforms(null, dirs(), VERSION, NO_TOOLCHAINS)).find((r) => r.id === 'ios')!;it('asks for the runtime template before anything about Xcode', async () => {diff --git a/pipeline/tests/platform-catalog.test.ts b/pipeline/tests/platform-catalog.test.tsindex 37d43976e..98f7ad7ae 100644--- a/pipeline/tests/platform-catalog.test.ts+++ b/pipeline/tests/platform-catalog.test.ts@@ -27,7 +27,7 @@ let wxDir: string;* against it exactly, so the tests own both ends of that comparison. */const VERSION = '9.9.9';-const dirs = () => ({ web: webDir, wechat: wxDir });+const dirs = () => ({ web: webDir, minigame: wxDir });/** The catalog with the machine facts this file owns. A machine with NEITHER* compiler is deliberate: a project that marks nothing `@compiled` must be@@ -91,6 +91,16 @@ describe('listPlatforms — built-in readiness is probed', () => {expect((await platforms(root)).find((r) => r.id === 'wechat')?.ready).toBe(true);});+ it('answers for every mini-game vendor from the one engine build they share', async () => {+ // One build, one probe: a vendor with no probe of its own reports ready and+ // then exports a package with an engine it cannot load.+ expect((await platforms(root)).find((r) => r.id === 'douyin')?.ready).toBe(false);+ writeFileSync(path.join(wxDir, 'esengine.wxgame.js'), '//');+ const rows = await platforms(root);+ expect(rows.find((r) => r.id === 'douyin')?.ready).toBe(true);+ expect(rows.find((r) => r.id === 'wechat')?.ready).toBe(true);+ });+it('reports paths with forward slashes, whatever the platform separator', async () => {const wx = (await platforms(root)).find((r) => r.id === 'wechat');expect((wx?.prereq as { dir?: string } | undefined)?.dir).not.toContain('\\');@@ -103,7 +113,7 @@ describe('listPlatforms — platforms the project defines', () => {id: 'acme', label: 'ACME Play', blurb: 'ACME package.', defaultOut: 'dist-acme',emitConfigFiles: () => [{ file: 'game.json', content: '{}' }],};`);- writeFileSync(path.join(webDir, 'esengine.js'), '//');+ writeFileSync(path.join(wxDir, 'esengine.wxgame.js'), '//');const rows = await platforms(root);const acme = rows.find((r) => r.id === 'acme');@@ -111,7 +121,7 @@ describe('listPlatforms — platforms the project defines', () => {expect(acme!.source).toBe('project');expect(acme!.label).toBe('ACME Play');expect(acme!.defaultOut).toBe('dist-acme');- // No wasmDir of its own → the editor's web runtime, which exists here.+ // No wasmDir of its own → the mini-game runtime, which exists here.expect(acme!.ready).toBe(true);});@@ -184,7 +194,7 @@ describe('createProjectPlatform — scaffolding', () => {expect(runtime).toContain('instantiateWasm');// What was scaffolded is immediately a real platform.- writeFileSync(path.join(webDir, 'esengine.js'), '//');+ writeFileSync(path.join(wxDir, 'esengine.wxgame.js'), '//');const rows = await platforms(root);const acme = rows.find((r) => r.id === 'acme-play');expect(acme?.source).toBe('project');@@ -234,7 +244,9 @@ describe('loadProjectPlatform — the profile handed to exportMiniGame', () => {// Defaulted — a standard mini-game host needs none of these spelled out.expect(p.sdkEntryFile).toBe('index.minigame.js');expect(p.runtimeInit).toBe('initMiniGameRuntime');- expect(p.engineGlueCandidates).toEqual(['esengine.js']);+ // The engine build every mini-game host takes, under either of its names —+ // NOT the browser artifact, which a `require` cannot even parse.+ expect(p.engineGlueCandidates).toEqual(['esengine.wxgame.js', 'esengine.js']);expect(p.esTarget).toBe('es2017');expect(p.subpackageDir).toBe('subpackages');expect(typeof p.emitEntry).toBe('function');@@ -264,12 +276,15 @@ describe('loadProjectPlatform — the profile handed to exportMiniGame', () => {.toEqual([{ file: 'game.json', content: '{"t":"T"}' }]);});- it('resolves wasmDir against the project root, defaulting to the web runtime', async () => {+ // A project's own vendor is a mini-game host like the built-in ones, so saying+ // nothing gets it their engine build — the browser one is an ES module its+ // package cannot require at all.+ it('resolves wasmDir against the project root, defaulting to the mini-game runtime', async () => {writePlatform('a.mjs', `export default { id: 'a', label: 'A', wasmDir: 'rt/a', emitConfigFiles: () => [] };`);writePlatform('b.mjs', `export default { id: 'b', label: 'B', emitConfigFiles: () => [] };`);expect((await loadProjectPlatform(root, 'a', dirs()))!.wasmDir).toBe(path.join(root, 'rt', 'a'));- expect((await loadProjectPlatform(root, 'b', dirs()))!.wasmDir).toBe(webDir);+ expect((await loadProjectPlatform(root, 'b', dirs()))!.wasmDir).toBe(wxDir);expect((await loadProjectPlatform(root, 'b', dirs()))!.defaultOut).toBe('dist-b');});@@ -311,7 +326,7 @@ describe('loadProjectPlatform — the profile handed to exportMiniGame', () => {writePlatform('acme.mjs', `export default {id: 'acme', label: 'A', runtimeProfile: 'src/rt', emitConfigFiles: () => [],};`);- writeFileSync(path.join(webDir, 'esengine.js'), '//');+ writeFileSync(path.join(wxDir, 'esengine.wxgame.js'), '//');const acme = (await platforms(root)).find((r) => r.id === 'acme');expect(acme!.error).toBeUndefined();expect(acme!.ready).toBe(true);diff --git a/tools/check-golden.mjs b/tools/check-golden.mjsindex 262ac2b5c..920a89f09 100644--- a/tools/check-golden.mjs+++ b/tools/check-golden.mjs@@ -18,6 +18,7 @@ import {GOLDEN, CAPABILITIES, KNOWN_GAPS, EVIDENCE, TIERS, TARGETS,SHIPPED, CENSUS_FLOOR, shippedGround, EVIDENCE_FORMATS, NOT_EVIDENCE_FORMATS,atTier, uncoveredCapabilities, nonGoldenExamples, projectDir, parityFor, interactFor,+ ROOT,} from './goldenProjects.mjs';import { CRITERIA } from './releaseGate.mjs';@@ -76,6 +77,22 @@ const SCHEDULED = CRITERIA.map((c) => c.answeredBy ?? '').join('\n');// 1. Every golden id is a project that exists and declares a scene to open.const seen = new Set();+// The engine's own list of targets, so a platform it gained cannot be one no+// golden project is allowed to name — which is how Douyin shipped as a built-in+// target while this file would have rejected a project that certified it.+{+ const src = readFileSync(path.join(ROOT, 'pipeline', 'src', 'project', 'platforms.ts'), 'utf8');+ const block = /BUILTIN_PLATFORMS: readonly BuiltinPlatform\[\] = \[([\s\S]*?)\];/.exec(src);+ if (!block) fail('no BUILTIN_PLATFORMS in pipeline/src/project/platforms.ts — the list moved');+ else {+ const engine = [...block[1].matchAll(/'([a-z0-9]+)'/g)].map(([, p]) => p);+ const missing = engine.filter((p) => !TARGETS.includes(p));+ if (missing.length) {+ fail(`the engine builds ${missing.join(', ')}, which no golden project may name — add to TARGETS`);+ }+ }+}+for (const g of GOLDEN) {if (seen.has(g.id)) fail(`"${g.id}" is listed twice`);seen.add(g.id);diff --git a/tools/goldenProjects.mjs b/tools/goldenProjects.mjsindex b88665f34..bf8c87134 100644--- a/tools/goldenProjects.mjs+++ b/tools/goldenProjects.mjs@@ -26,7 +26,7 @@ const EXAMPLES = path.join(ROOT, 'examples');export const TIERS = ['pr', 'nightly', 'release'];/** Export targets a golden project can be asked to package + launch for. */-export const TARGETS = ['web', 'playable', 'desktop', 'wechat', 'android', 'ios'];+export const TARGETS = ['web', 'playable', 'desktop', 'wechat', 'douyin', 'android', 'ios'];/*** How far a packaged frame may sit from the editor's frame of the same game.@@ -846,7 +846,10 @@ export const GOLDEN = [{id: 'input-actions',certifies: ['input'],- targets: ['web', 'desktop', 'wechat'],+ // Two vendors from one project: the export is a profile over one family, and+ // only a second vendor's real boot shows what the family got wrong. They take+ // the same engine build, so the second costs no extra wasm build.+ targets: ['web', 'desktop', 'wechat', 'douyin'],tier: 'release',interact: { keys: ['KeyD'], frames: 40 },},diff --git a/tools/launchers/minigameHost.mjs b/tools/launchers/minigameHost.mjsindex 2fe878f5c..84bd9c53f 100644--- a/tools/launchers/minigameHost.mjs+++ b/tools/launchers/minigameHost.mjs@@ -155,6 +155,11 @@ export const HOST_PAGE = (entry) => `<!doctype html>};globalThis.wx = wx;+ // The same object under Douyin's name: it answers the same shape for+ // everything the engine uses, and its profile supplies no wasm override. What+ // this page cannot answer for either vendor is the real base library.+ globalThis.tt = wx;+ globalThis.TTWebAssembly = globalThis.WXWebAssembly;globalThis.GameGlobal = globalThis;globalThis.canvas = screenCanvas;diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex 7c6c7d072..a97a473ed 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -698,6 +698,10 @@ export const NOTED = {{ internal: "a manual page's import line, following the move it documents" },'refactor(play): the play realm asks for the whole import map by name':{ internal: "the editor's preview page names the same subpaths it always did" },+ 'fix(export): a mini-game takes the engine build a mini-game host can load':+ { note: 'A Douyin package could not start.' },+ 'fix(export): every mini-game target gets the mini-game engine runtime':+ { note: 'A Douyin package could not start.' },'fix(export): a module the project forced in brings its binary too':{ note: "Forcing a module in now ships its wasm binary too, not just its JavaScript." },'feat(project): a build target can answer differently about a module':diff --git a/tools/verify-golden.mjs b/tools/verify-golden.mjsindex 8ae728d7a..9019ba31e 100644--- a/tools/verify-golden.mjs+++ b/tools/verify-golden.mjs@@ -44,9 +44,10 @@ const WORK = flag('work', path.join(ROOT, '.golden'));const NO_PARITY = argv.includes('--no-parity');/** Targets this runner owns; the rest belong to the native/desktop verifiers.* A mini-game needs its vendor's globals, so it goes through its own launcher. */-const OWNED = new Set(['web', 'playable', 'wechat']);+const OWNED = new Set(['web', 'playable', 'wechat', 'douyin']);+const MINIGAME = new Set(['wechat', 'douyin']);const LAUNCHER = (target) => path.join(ROOT, 'tools', 'launchers',- target === 'wechat' ? 'launch-minigame.mjs' : 'launch-export.mjs');+ MINIGAME.has(target) ? 'launch-minigame.mjs' : 'launch-export.mjs');/** Targets whose surface this runner can size to the editor's, which is what* makes a frame comparable at all. Measured on one project: web 0.0009,* playable 0.0027, wechat 0.0027 — the packaging wrapper is not what differs. */