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.

chore(export): a vendor claim in a profile says where it came from

esengine1b6fdbbf52a3
diff --git a/pipeline/src/export/miniGameExportProfile.ts b/pipeline/src/export/miniGameExportProfile.ts
index cb50decb0..eaa06c88a 100644
--- a/pipeline/src/export/miniGameExportProfile.ts
+++ b/pipeline/src/export/miniGameExportProfile.ts
@@ -239,6 +239,9 @@ export const wechatExportProfile: MiniGameExportProfile = {
// developers.weixin.qq.com/minigame/dev/guide/base-ability/code-package.html,
// "文件类型": only these may be uploaded.
packerSuffixes: WECHAT_PACKER_SUFFIXES,
+ // developers.weixin.qq.com/minigame/dev/framework/performance/wasm.html:
+ // `WXWebAssembly.instantiate(path)` takes 「.wasm 和 .wasm.br 后缀」 from base
+ // library 2.14.0 — documented rather than probed; the loader cannot be asked.
wasmBrotli: true,
subpackageDir: 'subpackages',
subpackageEntry: 'game.js',
@@ -305,6 +308,9 @@ export const douyinExportProfile: MiniGameExportProfile = {
wasmBuildHint: 'web',
hostGlobal: 'tt',
sideModuleBuildTargets: {},
+ // Assumed to match WeChat, not read from a Douyin doc: script and config are
+ // what a mini-game packer compiles itself everywhere this checkout has looked.
+ // Wrong here means a staged file the runtime cannot read, on a device.
nativeSuffixes: new Set(['.js', '.json']),
// No published list this checkout can cite, so nothing is restaged: staging a
// file under a name the packer does not take is the failure that only shows at
diff --git a/tools/check-minigame-profile-claims.mjs b/tools/check-minigame-profile-claims.mjs
new file mode 100644
index 000000000..6d256659c
--- /dev/null
+++ b/tools/check-minigame-profile-claims.mjs
@@ -0,0 +1,65 @@
+#!/usr/bin/env node
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file A mini-game profile says where each claim about a vendor came from.
+ *
+ * Four of a profile's fields decide what the package CONTAINS on the strength of
+ * what a vendor is said to accept, and getting one wrong fails nowhere near the
+ * mistake: a packer suffix it does not take is refused at upload, a `.wasm.br`
+ * its loader cannot read is a package that boots into nothing, a syntax level
+ * its runtime predates throws on a device, and a suffix wrongly called native
+ * leaves a staged file the runtime cannot open. Every one of those is a build
+ * that goes green.
+ *
+ * So each is answerable: cite the vendor's own page, or say what the value is
+ * assumed from and what it costs if the assumption is wrong. Saying "not
+ * claimed until a device settles it" IS an answer — it is how Douyin ships
+ * without a packer whitelist.
+ *
+ * node tools/check-minigame-profile-claims.mjs
+ */
+import { readFileSync } from 'node:fs';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
+const FILE = 'pipeline/src/export/miniGameExportProfile.ts';
+
+/** The fields whose wrong answer is a package that builds clean and then fails. */
+const CLAIMS = ['esTarget', 'nativeSuffixes', 'packerSuffixes', 'wasmBrotli'];
+
+const src = readFileSync(path.join(ROOT, FILE), 'utf8');
+const profiles = [...src.matchAll(/export const (\w+)ExportProfile: MiniGameExportProfile = \{([\s\S]*?)\n\};/g)];
+
+if (profiles.length === 0) {
+ console.error(`check-minigame-profile-claims: no profiles in ${FILE} — they moved.`);
+ process.exit(1);
+}
+
+const problems = [];
+let answered = 0;
+for (const [, vendor, body] of profiles) {
+ const lines = body.split('\n');
+ for (const field of CLAIMS) {
+ const at = lines.findIndex((l) => new RegExp(`^\\s{4}${field}:`).test(l));
+ // A profile that does not set an optional field claims nothing by it.
+ if (at < 0) continue;
+ let above = at - 1;
+ let reason = 0;
+ while (above >= 0 && /^\s*(\/\/|\*|\/\*)/.test(lines[above])) { reason += 1; above -= 1; }
+ if (reason === 0) {
+ problems.push(`${FILE}: ${vendor}'s ${field} says nothing about where it came from — `
+ + 'cite the vendor, or say what it is assumed from and what a wrong guess costs');
+ } else answered += 1;
+ }
+}
+
+if (problems.length > 0) {
+ for (const p of problems) console.error(` ${p}`);
+ console.error(`check-minigame-profile-claims: ${problems.length} unexplained claim(s).`);
+ process.exit(1);
+}
+
+console.log(`check-minigame-profile-claims: ${profiles.length} profile(s), ${answered} vendor claim(s), `
+ + 'each one sourced or hedged.');
diff --git a/tools/gates.mjs b/tools/gates.mjs
index ad8b46736..1ad393430 100644
--- a/tools/gates.mjs
+++ b/tools/gates.mjs
@@ -262,6 +262,9 @@ export const GATES = [
// A packaging setting the manifest parser does not read is a setting that
// does nothing, in the editor and on a build server alike.
{ id: 'packaging-settings', run: 'node tools/check-packaging-settings.mjs' },
+ // A vendor claim that is wrong fails at upload or on a device, never at
+ // build: so each one cites the vendor or says what it is assumed from.
+ { id: 'minigame-profile-claims', run: 'node tools/check-minigame-profile-claims.mjs' },
{ id: 'comment-style', run: 'node tools/check-comment-style.mjs' },
{ id: 'silent-writes', run: 'node tools/mutation-census.mjs --gate' },
{