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(export): a mini-game entry raises the host indicator on its first line

esengine2e6ecb4c1d49
diff --git a/CHANGELOG.md b/CHANGELOG.md
index de5a3a318..e18edac00 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,8 @@ published separately; it ships inside the editor.
### Added
+- **A mini-game says it is starting before it parses the game.** The host's loading indicator only appeared once `initMiniGameRuntime` ran, which is after the entry has required a megabyte of bundle — the longest silent stretch of a cold start. The generated entry now raises it on its first line.
+
- **The start screen is yours: a logo, a background and a minimum display time.** The exported page has shown real boot progress for a while, but always as the game's name on the engine's own dark ground. A project can now put its logo there — inlined into the page, because an image fetched over the network arrives in the same window the engine does, with nothing left to cover — pick the colour behind it, and hold the screen for a minimum time, so a boot that finishes in 120ms stops flashing a bar that appears and vanishes. The page also emits `esengine:bootprogress` and `esengine:firstframe`, which a portal's own loading screen can listen for before the game's bundle has run.
- **The build dialog states a platform's size caps before you package.** They were reported only after a package existed, in the size panel, so the ceiling a build had to fit under was visible only once it was too late to plan around — and the difference matters: a package that fits WeChat's 30MB is 10MB over Douyin's 20MB. Each target's caps now sit under its description, and hovering them gives the platform's own wording rather than our paraphrase. A platform a project defines itself states the caps it declared.
diff --git a/pipeline/src/export/miniGameExportProfile.ts b/pipeline/src/export/miniGameExportProfile.ts
index be381c543..3ba16841d 100644
--- a/pipeline/src/export/miniGameExportProfile.ts
+++ b/pipeline/src/export/miniGameExportProfile.ts
@@ -108,9 +108,15 @@ ${requires}
const bundle = require('./game-bundle.js');
bundle.boot(engineFactory, sideModuleFactories);`;
if (!ctx.engineSubpackage) {
+ // Before the bundle is REQUIRED: the runtime's own indicator cannot
+ // cover a wait that ends when the runtime arrives. Guarded, like every
+ // other call to it — an indicator must not take a boot down.
+ const notice = ctx.hostGlobal
+ ? `try { ${ctx.hostGlobal}.showLoading({ title: 'Starting 0%', mask: true }); } catch (e) {}\n`
+ : '';
return `'use strict';
// Generated by Estella exportGame (MiniGame entry).
-${boot}
+${notice}${boot}
`;
}
// The host fetches the engine binary before anything can instantiate it, and
diff --git a/pipeline/tests/export-douyin.test.ts b/pipeline/tests/export-douyin.test.ts
index aa4cffc29..f1caf6cd7 100644
--- a/pipeline/tests/export-douyin.test.ts
+++ b/pipeline/tests/export-douyin.test.ts
@@ -129,6 +129,18 @@ describe('exportGame (douyin)', () => {
expect(res.errors.join('\n')).toContain('build -t wechat');
}, 180_000);
+ it('says it is starting BEFORE it parses a megabyte of game code', () => {
+ // The runtime's own indicator cannot cover this wait: it only appears once
+ // the bundle it is waiting for has been required.
+ const entry = readFileSync(path.join(out, 'game.js'), 'utf8');
+ const notice = entry.indexOf('showLoading');
+ const bundle = entry.indexOf("require('./game-bundle.js')");
+ expect(notice).toBeGreaterThan(-1);
+ expect(notice).toBeLessThan(bundle);
+ // …and it must not be the thing that takes a boot down.
+ expect(entry).toContain('try {');
+ });
+
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/tools/releaseNotes.mjs b/tools/releaseNotes.mjs
index 0e4156694..03dd1915b 100644
--- a/tools/releaseNotes.mjs
+++ b/tools/releaseNotes.mjs
@@ -700,6 +700,8 @@ export const NOTED = {
{ internal: "the editor's preview page names the same subpaths it always did" },
'fix(settings): the module page reads the same asset table the build installs from':
{ note: 'The Engine Modules page no longer calls a module unused that the build then carries.' },
+ 'feat(export): a mini-game entry raises the host indicator on its first line':
+ { note: 'A mini-game says it is starting before it parses the game.' },
"feat(export): the start screen carries the project's logo, colour and hold":
{ note: 'The start screen is yours: a logo, a background and a minimum display time.' },
'feat(build): a target states its size caps before you package':