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(ci): open a mini-game package the way its vendor would

esenginea64afa606d56
diff --git a/desktop/scripts/launch-minigame.mjs b/desktop/scripts/launch-minigame.mjs
new file mode 100644
index 000000000..a983caf5c
--- /dev/null
+++ b/desktop/scripts/launch-minigame.mjs
@@ -0,0 +1,146 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file launch-minigame.mjs — a packaged mini-game starts, and draws.
+ *
+ * The WeChat/Douyin counterpart of launch-export: same two questions (did it
+ * reach a frame, is that frame more than one flat colour), asked of a package
+ * no browser can open on its own. minigameHost supplies the CommonJS loader and
+ * the `wx` global; this serves the export and judges the result.
+ *
+ * It stands in for the vendor, it does not impersonate it — see minigameHost.
+ *
+ * electron desktop/scripts/launch-minigame.mjs --dir <exportDir> [options]
+ * --out <file.png> write the captured frame
+ * --w / --h surface size (default 640x360)
+ * --settle <n> frames to let run before capturing (default 30)
+ * --timeout <ms> how long to wait for the first frame (default 30000)
+ */
+import { app, BrowserWindow } from 'electron';
+import http from 'node:http';
+import { readFile, writeFile } from 'node:fs/promises';
+import { existsSync, readFileSync } from 'node:fs';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { onRendererConsole } from './rendererConsole.mjs';
+import { HOST_PAGE } from './minigameHost.mjs';
+
+app.commandLine.appendSwitch('force-color-profile', 'srgb');
+
+const argv = process.argv.slice(2);
+const flag = (n, d) => {
+ const i = argv.indexOf(`--${n}`);
+ return i >= 0 && argv[i + 1] && !argv[i + 1].startsWith('--') ? argv[i + 1] : d;
+};
+const DIR = path.resolve(flag('dir', ''));
+const OUT = flag('out', '');
+const W = Number(flag('w', '640'));
+const H = Number(flag('h', '360'));
+const SETTLE = Number(flag('settle', '30'));
+const TIMEOUT = Number(flag('timeout', '30000'));
+
+const MIME = {
+ '.js': 'text/javascript', '.json': 'application/json', '.wasm': 'application/wasm',
+ '.png': 'image/png', '.jpg': 'image/jpeg', '.webp': 'image/webp', '.ktx2': 'image/ktx2',
+ '.mp3': 'audio/mpeg', '.ogg': 'audio/ogg', '.wav': 'audio/wav', '.m4a': 'audio/mp4',
+ '.atlas': 'text/plain', '.skel': 'application/octet-stream', '.txt': 'text/plain',
+};
+
+function serve(root, page) {
+ const server = http.createServer(async (req, res) => {
+ try {
+ let rel = decodeURIComponent(new URL(req.url, 'http://x').pathname).replace(/^\/+/, '');
+ if (rel === '' || rel === 'index.html') {
+ res.writeHead(200, { 'content-type': 'text/html' }).end(page);
+ return;
+ }
+ const abs = path.join(root, rel);
+ if (!abs.startsWith(root)) { res.writeHead(403).end(); return; }
+ res.writeHead(200, { 'content-type': MIME[path.extname(abs).toLowerCase()] ?? 'application/octet-stream' })
+ .end(await readFile(abs));
+ } catch {
+ res.writeHead(404).end();
+ }
+ });
+ return new Promise((resolve) => server.listen(0, '127.0.0.1', () => resolve(server)));
+}
+
+function frameIsLive(image) {
+ const { width, height } = image.getSize();
+ const buf = image.toBitmap();
+ const first = [buf[0], buf[1], buf[2]];
+ const step = Math.max(1, Math.floor((width * height) / 4000));
+ for (let p = 0; p < width * height; p += step) {
+ const i = p * 4;
+ if (Math.abs(buf[i] - first[0]) > 8 || Math.abs(buf[i + 1] - first[1]) > 8 || Math.abs(buf[i + 2] - first[2]) > 8) {
+ return true;
+ }
+ }
+ return false;
+}
+
+async function main() {
+ const manifest = path.join(DIR, 'game.json');
+ if (!existsSync(manifest)) {
+ console.error(`✗ no game.json under ${DIR || '(--dir not given)'} — not a mini-game package`);
+ app.exit(2);
+ return;
+ }
+ // The vendor reads the entry from game.json's convention (game.js); assert it
+ // is there rather than letting the loader 404 into a confusing stack.
+ const entry = 'game.js';
+ if (!existsSync(path.join(DIR, entry))) {
+ console.error(`✗ ${entry} is missing — the package has a manifest and no entry`);
+ app.exit(1);
+ return;
+ }
+ JSON.parse(readFileSync(manifest, 'utf8')); // a manifest the vendor cannot parse is a dead package
+
+ const server = await serve(DIR, HOST_PAGE(entry));
+ const base = `http://127.0.0.1:${server.address().port}/`;
+
+ const win = new BrowserWindow({
+ width: W, height: H, useContentSize: true, show: false,
+ webPreferences: { backgroundThrottling: false },
+ });
+
+ const errors = [];
+ const stop = onRendererConsole(win.webContents, (msg) => {
+ if (/\[minigame\] boot failed|uncaught|is not a function|no such file/i.test(msg)) errors.push(msg.slice(0, 400));
+ if (msg.startsWith('[minigame]') || msg.startsWith('[engine]')) console.log(` ${msg}`);
+ });
+ win.webContents.on('render-process-gone', (_e, d) => errors.push(`render process gone: ${d.reason}`));
+
+ await win.loadURL(base);
+ const painted = await win.webContents.executeJavaScript(`
+ new Promise((resolve) => {
+ const deadline = Date.now() + ${TIMEOUT};
+ let frames = 0;
+ const tick = () => {
+ const c = document.querySelector('canvas');
+ if (c && c.width > 0 && c.height > 0) frames++;
+ if (frames >= ${SETTLE}) return resolve(true);
+ if (Date.now() > deadline) return resolve(false);
+ requestAnimationFrame(tick);
+ };
+ requestAnimationFrame(tick);
+ })
+ `).catch((e) => { errors.push(String(e)); return false; });
+
+ const image = await win.webContents.capturePage();
+ if (OUT) await writeFile(OUT, image.toPNG());
+ stop();
+ server.close();
+
+ const live = frameIsLive(image);
+ const ok = painted && live && errors.length === 0;
+ console.log(`${ok ? '✓' : '✗'} ${path.basename(DIR)} (mini-game) — painted=${painted} live=${live} errors=${errors.length}`);
+ for (const e of errors.slice(0, 5)) console.log(` ${e}`);
+ if (painted && !live) console.log(' one flat colour — it started and drew nothing');
+ app.exit(ok ? 0 : 1);
+}
+
+app.whenReady().then(main).catch((e) => {
+ console.error('✗ launch-minigame failed:', e);
+ app.exit(2);
+});
diff --git a/desktop/scripts/minigameHost.mjs b/desktop/scripts/minigameHost.mjs
new file mode 100644
index 000000000..2fe878f5c
--- /dev/null
+++ b/desktop/scripts/minigameHost.mjs
@@ -0,0 +1,217 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file minigameHost.mjs — the page that boots a mini-game package outside its vendor.
+ *
+ * A WeChat/Douyin package is CommonJS plus a `wx`/`tt` global, so no browser
+ * opens one and CI never launched a mini-game build at all. This supplies both,
+ * over http, from the export directory as it shipped.
+ *
+ * What it is NOT: WeChat. It cannot answer how the real base library behaves.
+ * What it does answer is everything between "the exporter returned ok" and "the
+ * game runs" — a file the entry requires and the package does not carry, a wasm
+ * the loader cannot locate, an entry wired to the wrong boot call.
+ *
+ * The shim implements `MiniGameGlobal` (sdk/src/platform/minigame/api.ts), which
+ * the engine documents as "only the subset the engine actually uses" — so it is
+ * written against a declared contract rather than guessed, and check-minigame-host
+ * fails when the contract grows a member the shim has not got.
+ */
+
+/** The page source; `BASE` is substituted with the served root. */
+export const HOST_PAGE = (entry) => `<!doctype html>
+<html><head><meta charset="utf-8"><style>
+ html,body{margin:0;height:100%;background:#000;overflow:hidden}
+ canvas{display:block}
+</style></head><body>
+<script>
+(() => {
+ const log = (m) => console.log('[minigame] ' + m);
+ // Vendor contract: the FIRST createCanvas() hands back the on-screen canvas and
+ // every call after it is offscreen scratch. Hand the engine a fresh offscreen
+ // one instead and the game runs perfectly, drawing where nobody can see.
+ const screenCanvas = document.createElement('canvas');
+ screenCanvas.width = window.innerWidth;
+ screenCanvas.height = window.innerHeight;
+ document.body.appendChild(screenCanvas);
+ let screenTaken = false;
+ const makeCanvas = () => {
+ if (!screenTaken) { screenTaken = true; return screenCanvas; }
+ return document.createElement('canvas');
+ };
+
+ const readAsArrayBuffer = (p) => {
+ const xhr = new XMLHttpRequest();
+ xhr.open('GET', p, false); // sync: readFileSync is synchronous by contract
+ xhr.overrideMimeType('text/plain; charset=x-user-defined');
+ xhr.send(null);
+ if (xhr.status !== 200 && xhr.status !== 0) throw new Error('no such file: ' + p);
+ const s = xhr.responseText;
+ const b = new Uint8Array(s.length);
+ for (let i = 0; i < s.length; i++) b[i] = s.charCodeAt(i) & 0xff;
+ return b.buffer;
+ };
+ const readAsText = (p) => {
+ const xhr = new XMLHttpRequest();
+ xhr.open('GET', p, false);
+ xhr.send(null);
+ if (xhr.status !== 200 && xhr.status !== 0) throw new Error('no such file: ' + p);
+ return xhr.responseText;
+ };
+
+ const fs = {
+ readFileSync: (p, enc) => (enc === 'utf8' || enc === 'utf-8' ? readAsText(p) : readAsArrayBuffer(p)),
+ readFile: (o) => {
+ try { o.success && o.success({ data: fs.readFileSync(o.filePath, o.encoding) }); }
+ catch (e) { o.fail && o.fail({ errMsg: String(e) }); }
+ finally { o.complete && o.complete(); }
+ },
+ accessSync: (p) => { readAsArrayBuffer(p); },
+ access: (o) => {
+ try { fs.accessSync(o.path); o.success && o.success(); }
+ catch (e) { o.fail && o.fail({ errMsg: String(e) }); }
+ finally { o.complete && o.complete(); }
+ },
+ writeFile: (o) => { o.fail && o.fail({ errMsg: 'read-only host' }); o.complete && o.complete(); },
+ writeFileSync: () => { throw new Error('read-only host'); },
+ mkdirSync: () => {},
+ unlinkSync: () => {},
+ rmdirSync: () => {},
+ readdirSync: () => [],
+ statSync: () => ({ size: 0, isDirectory: () => false }),
+ };
+
+ const noop = () => {};
+ const wx = {
+ createCanvas: makeCanvas,
+ createImage: () => new Image(),
+ getFileSystemManager: () => fs,
+ getSystemInfoSync: () => ({
+ pixelRatio: window.devicePixelRatio || 1,
+ language: 'en',
+ windowWidth: window.innerWidth,
+ windowHeight: window.innerHeight,
+ platform: 'devtools',
+ safeArea: { top: 0, bottom: window.innerHeight, left: 0, right: window.innerWidth,
+ width: window.innerWidth, height: window.innerHeight },
+ }),
+ request: (o) => {
+ fetch(o.url).then(async (r) => {
+ const data = o.responseType === 'arraybuffer' ? await r.arrayBuffer() : await r.text();
+ o.success && o.success({ data, statusCode: r.status });
+ }).catch((e) => o.fail && o.fail({ errMsg: String(e) })).finally(() => o.complete && o.complete());
+ },
+ // Audio and sockets are stubs on purpose: a launch smoke asks whether the
+ // package starts and draws, and a silent stub cannot fake either answer.
+ createInnerAudioContext: () => ({
+ play: noop, pause: noop, stop: noop, destroy: noop, seek: noop,
+ onPlay: noop, onPause: noop, onStop: noop, onEnded: noop, onError: noop, onCanplay: noop,
+ offPlay: noop, offPause: noop, offStop: noop, offEnded: noop, offError: noop, offCanplay: noop,
+ src: '', loop: false, volume: 1, autoplay: false, currentTime: 0, duration: 0, paused: true,
+ }),
+ connectSocket: () => ({
+ send: noop, close: noop,
+ onOpen: noop, onClose: noop, onError: noop, onMessage: noop,
+ offOpen: noop, offClose: noop, offError: noop, offMessage: noop,
+ }),
+ onTouchStart: noop, onTouchMove: noop, onTouchEnd: noop,
+ offTouchStart: noop, offTouchMove: noop, offTouchEnd: noop,
+ onTouchCancel: noop, offTouchCancel: noop,
+ // Keyboard: forwarded from the real DOM so a driven run can reach the game.
+ onKeyDown: (cb) => window.addEventListener('keydown', (e) => cb({ code: e.code, key: e.key })),
+ onKeyUp: (cb) => window.addEventListener('keyup', (e) => cb({ code: e.code, key: e.key })),
+ offKeyDown: noop, offKeyUp: noop,
+ onMemoryWarning: noop, offMemoryWarning: noop,
+ onError: noop, offError: noop,
+ onUnhandledRejection: noop, offUnhandledRejection: noop,
+ onShow: noop, onHide: noop, offShow: noop, offHide: noop,
+ onWindowResize: noop, offWindowResize: noop,
+ loadSubpackage: (o) => { o.success && o.success(); o.complete && o.complete(); },
+ // Storage is real (localStorage), not a stub: a game that saves on boot and
+ // reads it back would otherwise take the silent path and look fine.
+ getStorageSync: (k) => { const v = localStorage.getItem(k); return v === null ? '' : JSON.parse(v); },
+ setStorageSync: (k, v) => localStorage.setItem(k, JSON.stringify(v)),
+ removeStorageSync: (k) => localStorage.removeItem(k),
+ getStorageInfoSync: () => ({ keys: Object.keys(localStorage), currentSize: 0, limitSize: 10240 }),
+ setPreferredFramesPerSecond: noop,
+ triggerGC: noop,
+ exitMiniProgram: noop,
+ getLaunchOptionsSync: () => ({ scene: 1001, query: {} }),
+ };
+ // WeChat instantiates wasm from a PACKAGE-RELATIVE PATH, not bytes — the one
+ // place the vendors genuinely diverge (sdk/src/platform/wechat/wasm.ts), and
+ // the reason a browser cannot open one of these packages unaided.
+ const asUrl = (p) => '/' + (String(p)[0] === '/' ? String(p).slice(1) : String(p));
+ globalThis.WXWebAssembly = {
+ instantiate: (pathOrBytes, imports) => (typeof pathOrBytes === 'string'
+ ? fetch(asUrl(pathOrBytes)).then((r) => r.arrayBuffer())
+ .then((b) => WebAssembly.instantiate(b, imports))
+ : WebAssembly.instantiate(pathOrBytes, imports)),
+ compile: (p) => fetch(asUrl(p)).then((r) => r.arrayBuffer()).then((b) => WebAssembly.compile(b)),
+ Memory: WebAssembly.Memory,
+ Table: WebAssembly.Table,
+ Module: WebAssembly.Module,
+ Instance: WebAssembly.Instance,
+ };
+
+ globalThis.wx = wx;
+ globalThis.GameGlobal = globalThis;
+ globalThis.canvas = screenCanvas;
+
+ // The package is CommonJS. A mini-game host resolves relative requires against
+ // the requiring file, so the loader has to carry that directory with it.
+ const modules = new Map();
+ const dirOf = (p) => p.slice(0, p.lastIndexOf('/') + 1);
+ const normalize = (p) => {
+ const out = [];
+ for (const part of p.split('/')) {
+ if (part === '.' || part === '') continue;
+ if (part === '..') out.pop();
+ else out.push(part);
+ }
+ return out.join('/');
+ };
+ function requireFrom(dir, spec) {
+ let file = spec.startsWith('.') ? normalize(dir + spec) : normalize(spec);
+ if (!/\\.(js|json)$/.test(file)) file += '.js';
+ if (modules.has(file)) return modules.get(file).exports;
+ const src = readAsText('/' + file);
+ if (file.endsWith('.json')) {
+ const m = { exports: JSON.parse(src) };
+ modules.set(file, m);
+ return m.exports;
+ }
+ const mod = { exports: {} };
+ modules.set(file, mod);
+ const fn = new Function('module', 'exports', 'require', '__filename', '__dirname', 'wx', 'GameGlobal',
+ src + '\\n//# sourceURL=' + file);
+ fn(mod, mod.exports, (s) => requireFrom(dirOf(file), s), file, dirOf(file), wx, globalThis);
+ return mod.exports;
+ }
+
+ try {
+ log('booting ${entry}');
+ requireFrom('', './${entry}');
+ log('entry returned');
+ } catch (e) {
+ console.error('[minigame] boot failed: ' + (e && e.stack ? e.stack : e));
+ }
+})();
+</script></body></html>`;
+
+/**
+ * Members of `MiniGameGlobal` the shim above provides. Kept beside it so
+ * check-minigame-host can hold the two against the SDK's declaration.
+ */
+export const SHIM_MEMBERS = [
+ 'createCanvas', 'createImage', 'getFileSystemManager', 'request',
+ 'createInnerAudioContext', 'connectSocket', 'getSystemInfoSync',
+ 'onTouchStart', 'onTouchMove', 'onTouchEnd',
+ 'offTouchStart', 'offTouchMove', 'offTouchEnd',
+ 'onTouchCancel', 'offTouchCancel',
+ 'onKeyDown', 'onKeyUp', 'offKeyDown', 'offKeyUp',
+ 'loadSubpackage', 'onMemoryWarning', 'offMemoryWarning',
+ 'onError', 'offError', 'onUnhandledRejection', 'offUnhandledRejection',
+ 'onShow', 'onHide',
+ 'getStorageSync', 'setStorageSync', 'removeStorageSync', 'getStorageInfoSync',
+];
diff --git a/package.json b/package.json
index 2565bf928..7f59e32fa 100644
--- a/package.json
+++ b/package.json
@@ -17,7 +17,7 @@
"emsdk:setup": "node build-tools/toolchain/setup-emsdk.js",
"asset-meta": "node tools/asset-meta.js",
"migrate-asset-refs": "node tools/migrate-asset-refs.js",
- "verify": "pnpm --filter ./sdk exec tsc --noEmit && pnpm --filter @estella/editor exec tsc --noEmit && node tools/api-surface.mjs --check && node tools/check-cycles.mjs && node tools/check-layers.mjs && node tools/check-project-settings.mjs && node tools/check-workflows.mjs && node tools/check-tool-calls.mjs && node tools/check-inspector-door.mjs && node tools/check-dirty-source.mjs && node tools/check-path-sandbox.mjs && node tools/check-key-codes.mjs && node tools/check-comment-style.mjs && node tools/check-cpp-tests.mjs && node tools/check-release-metadata.mjs && node tools/check-golden.mjs && node tools/component-reference.mjs --check",
+ "verify": "pnpm --filter ./sdk exec tsc --noEmit && pnpm --filter @estella/editor exec tsc --noEmit && node tools/api-surface.mjs --check && node tools/check-cycles.mjs && node tools/check-layers.mjs && node tools/check-project-settings.mjs && node tools/check-workflows.mjs && node tools/check-tool-calls.mjs && node tools/check-inspector-door.mjs && node tools/check-dirty-source.mjs && node tools/check-path-sandbox.mjs && node tools/check-key-codes.mjs && node tools/check-comment-style.mjs && node tools/check-cpp-tests.mjs && node tools/check-release-metadata.mjs && node tools/check-golden.mjs && node tools/check-minigame-host.mjs && node tools/component-reference.mjs --check",
"perf": "node tools/perf-guard.mjs --check",
"scale": "node tools/perf-budget.mjs",
"stress-project": "node tools/stress-project.mjs",
diff --git a/tools/check-minigame-host.mjs b/tools/check-minigame-host.mjs
new file mode 100644
index 000000000..92c4f42b9
--- /dev/null
+++ b/tools/check-minigame-host.mjs
@@ -0,0 +1,64 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file check-minigame-host — the stand-in host implements what the engine asks for.
+ *
+ * launch-minigame boots a WeChat/Douyin package against a shim, and a shim is
+ * only worth trusting while it matches the real thing. The engine already says
+ * what the real thing must provide: `MiniGameGlobal` in the SDK is documented as
+ * "only the subset the engine actually uses".
+ *
+ * So the two are held together here. A member added to the interface and not to
+ * the shim would otherwise surface as a package that "fails to launch" in CI —
+ * a harness gap wearing a product bug's clothes, which is the worst way to find
+ * out. Optional members (`name?()`) may be skipped; required ones may not.
+ */
+import { readFileSync } from 'node:fs';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { SHIM_MEMBERS } from '../desktop/scripts/minigameHost.mjs';
+
+const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
+const API = 'sdk/src/platform/minigame/api.ts';
+
+const src = readFileSync(path.join(ROOT, API), 'utf8');
+const block = /export interface MiniGameGlobal\s*\{([\s\S]*?)\n\}/.exec(src);
+if (!block) {
+ console.error(`check-minigame-host: no MiniGameGlobal interface in ${API} — has it moved?`);
+ process.exit(1);
+}
+
+// One member per declaration line: `name(...)` or `name?(...)`. Comment lines and
+// blanks carry no member, so they simply do not match.
+const required = [];
+const optional = [];
+for (const line of block[1].split('\n')) {
+ const m = /^\s{4}([a-zA-Z_][a-zA-Z0-9_]*)(\?)?\s*[(:]/.exec(line);
+ if (!m) continue;
+ (m[2] ? optional : required).push(m[1]);
+}
+
+if (required.length === 0) {
+ console.error('check-minigame-host: parsed no required members — the interface shape changed');
+ process.exit(1);
+}
+
+const shim = new Set(SHIM_MEMBERS);
+const missing = required.filter((n) => !shim.has(n));
+// A shim member the interface has never heard of is dead weight at best, and at
+// worst a name the engine stopped calling while the shim kept pretending.
+const known = new Set([...required, ...optional]);
+const stale = SHIM_MEMBERS.filter((n) => !known.has(n));
+
+if (missing.length || stale.length) {
+ console.error('check-minigame-host: the stand-in host no longer matches the engine.\n');
+ for (const n of missing) console.error(` the engine requires "${n}" and the shim does not provide it`);
+ for (const n of stale) console.error(` the shim provides "${n}", which MiniGameGlobal does not declare`);
+ console.error('\n Both live in desktop/scripts/minigameHost.mjs (SHIM_MEMBERS beside the page).');
+ process.exit(1);
+}
+
+console.log(
+ `check-minigame-host: the stand-in host covers ${required.length} required`
+ + ` and ${SHIM_MEMBERS.length - required.length} optional member(s) of MiniGameGlobal — ok`,
+);
diff --git a/tools/verify-golden.mjs b/tools/verify-golden.mjs
index eab2a7e82..4c0622092 100644
--- a/tools/verify-golden.mjs
+++ b/tools/verify-golden.mjs
@@ -4,9 +4,10 @@
* @file verify-golden.mjs — carry each golden project through package → launch → drive → compare.
*
* The registry says which projects a tier certifies and for which targets; this
- * runs that matrix. Web and playable are driven here because both launch in the
- * Electron already on hand; desktop/android/ios packages are launched by
- * verify-desktop-render and verify-native-boot, which own their toolchains.
+ * runs that matrix. Web, playable and the mini-game targets are driven here
+ * because all three launch in the Electron already on hand; desktop/android/ios
+ * packages go to verify-desktop-render and verify-native-boot, which own their
+ * toolchains.
*
* Reports every pair rather than stopping at the first failure — a release
* argument wants the whole matrix, not the first thing that broke.
@@ -32,8 +33,10 @@ const ONLY = flag('only', '');
const SHOTS = flag('shots', '');
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. */
-const OWNED = new Set(['web', 'playable']);
+/** 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 LAUNCHER = (target) => (target === 'wechat' ? 'launch-minigame.mjs' : 'launch-export.mjs');
const DESKTOP = path.join(ROOT, 'desktop');
if (SHOTS) mkdirSync(SHOTS, { recursive: true });
@@ -118,7 +121,7 @@ for (const { id, target } of pairs) {
const packagePng = SHOTS ? path.join(SHOTS, `${id}-${target}.png`) : path.join(WORK, `${id}-${target}.png`);
const launch = spawnSync('npx', [
- 'electron', path.join('scripts', 'launch-export.mjs'),
+ 'electron', path.join('scripts', LAUNCHER(target)),
'--dir', out, '--out', packagePng,
...(editor ? ['--w', String(editor.w), '--h', String(editor.h)] : []),
], { encoding: 'utf8', cwd: DESKTOP });
@@ -164,7 +167,7 @@ for (const { id, target } of pairs) {
const drivenPng = path.join(WORK, `${id}-${target}-driven.png`);
const drive = spawnSync('npx', [
- 'electron', path.join('scripts', 'launch-export.mjs'),
+ 'electron', path.join('scripts', LAUNCHER(target)),
'--dir', out, '--out', drivenPng,
'--w', String(editor.w), '--h', String(editor.h),
'--input', JSON.stringify({ keys: input.keys, frames: input.frames }),