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
feat(export): the start screen carries the project's logo, colour and hold
esengine317ed1dcb434
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex f16fc84bd..de5a3a318 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -16,6 +16,8 @@ published separately; it ships inside the editor.### Added+- **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.### Fixeddiff --git a/desktop b/desktopindex 34ec0018e..2525bf9af 160000--- a/desktop+++ b/desktop@@ -1 +1 @@-Subproject commit 34ec0018e88718ff193e92cfedd8a722b23d5a07+Subproject commit 2525bf9af0d91b3f54850b0e09f5bf0d3f9b8925diff --git a/pipeline/src/export/exportGame.ts b/pipeline/src/export/exportGame.tsindex b47e77e1a..eba57bdf9 100644--- a/pipeline/src/export/exportGame.ts+++ b/pipeline/src/export/exportGame.ts@@ -53,7 +53,7 @@ import { resolveEmcc, runEmcc } from '../bundle/emccPath';import { findHostCC } from '../../../compiler/src/hostCC';import { explainBundleErrors, type BundleMessage } from '../bundle/bundleDiagnostics';import { orientationCss, orientationOverlayHtml, orientationLockScript, orientationLockCspHash, type ScreenOrientation } from './orientationHtml';-import { splashCss, splashHtml } from './splash';+import { PAGE_BACKGROUND, splashCss, splashHtml, type SplashLook } from './splash';import { emitIosXcodeProject, type IosProjectSources } from '../../../build-tools/utils/iosProject.js';import { emitAndroidGradleProject } from '../../../build-tools/utils/gradleProject.js';import { androidTemplateSources } from '../../../build-tools/utils/nativeTemplate.js';@@ -290,14 +290,12 @@ function externalEngineImports(metafile: { outputs: Record<string, { imports?: {return [...found];}-/** The page's ground, and what the start screen fades out over: the same colour on- * both sides, or the fade flashes through to white between them. */-const PAGE_BACKGROUND = '#0e121b';-/** The web host page. `orientation` pins the canvas to a screen orientation (rotate-* to-fit overlay + best-effort lock) — set for the mobile-facing web target, omitted* for desktop (the Electron shell sizes its own window). */-function indexHtml(title: string, map: EngineImportMap, orientation?: ScreenOrientation): string {+function indexHtml(+ title: string, map: EngineImportMap, look: SplashLook, orientation?: ScreenOrientation,+): string {// Every inline script on this page needs its hash listed, or the browser blocks it.const inlineScripts = [map.cspHash, ...(orientation ? [orientationLockCspHash(orientation)] : [])].map((h) => `'${h}'`)@@ -317,13 +315,13 @@ function indexHtml(title: string, map: EngineImportMap, orientation?: ScreenOrie* { margin: 0; padding: 0; box-sizing: border-box; }html, body { width: 100%; height: 100%; overflow: hidden; background: ${PAGE_BACKGROUND}; }#canvas { display: block; width: 100%; height: 100%; touch-action: none; }- ${splashCss(PAGE_BACKGROUND)}+ ${splashCss(look.background ?? PAGE_BACKGROUND)}${orientation ? orientationCss(orientation) : ''}</style></head><body><canvas id="canvas"></canvas>- ${splashHtml(title)}+ ${splashHtml(title, look)}${orientation ? orientationOverlayHtml(orientation) : ''}${orientation ? orientationLockScript(orientation) : ''}<script type="module" src="./game.js"></script>@@ -332,6 +330,39 @@ function indexHtml(title: string, map: EngineImportMap, orientation?: ScreenOrie`;}+/** Image types a start screen can inline, by extension. A format the page cannot+ * decode is a broken image over the whole first screen, so the list is closed. */+const SPLASH_MIME: Readonly<Record<string, string>> = {+ '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg',+ '.webp': 'image/webp', '.svg': 'image/svg+xml', '.gif': 'image/gif',+};++/**+ * The start screen the page will carry, with the logo INLINED.+ *+ * Inlined rather than staged: an image that needs its own request arrives in the+ * same window the engine does, so a logo meant to cover the wait would appear+ * only once there was nothing left to cover.+ */+async function splashLook(+ root: string, splash: ProjectPackaging['splash'], warnings: string[],+): Promise<SplashLook> {+ const look: SplashLook = { minMs: splash?.minMs, background: splash?.background };+ if (!splash?.logo) return look;+ const file = path.join(root, splash.logo);+ const mime = SPLASH_MIME[path.extname(splash.logo).toLowerCase()];+ if (!mime) {+ warnings.push(`The splash logo ${splash.logo} is not an image the page can inline — shown as the game's title instead.`);+ return look;+ }+ if (!existsSync(file)) {+ warnings.push(`The splash logo ${splash.logo} does not exist — shown as the game's title instead.`);+ return look;+ }+ look.logo = `data:${mime};base64,${(await readFile(file)).toString('base64')}`;+ return look;+}+/** A filesystem-safe slug for the app id / package name. *//** Bind every `esengine` import to what the host already evaluated: a native* build has no module loader, and a second copy would put a game's tokens in@@ -507,6 +538,8 @@ export interface ExportGameOptions {/** `packaging.sizeBudget[platform]` — the project's own package-size ceiling in* bytes, replacing whatever limit the target declares. See sizeBudget.ts. */sizeBudgetBytes?: number;+ /** How the page's start screen should look; see SplashPackaging. */+ splash?: ProjectPackaging['splash'];}/**@@ -982,7 +1015,11 @@ async function produceExport(opts: ExportGameOptions): Promise<ExportGameResult>// reports work nothing did.if (!nativeContent) {progress({ phase: 'Writing host page' });- await writeFile(path.join(payloadDir, 'index.html'), indexHtml(title, engineMap, platform === 'web' ? orientation : undefined));+ const look = await splashLook(opts.root, opts.splash, warnings);+ await writeFile(+ path.join(payloadDir, 'index.html'),+ indexHtml(title, engineMap, look, platform === 'web' ? orientation : undefined),+ );}// Typed against the SDK's contract, so a field the runtimes read can never be// spelled differently here — the two sides share one declaration.diff --git a/pipeline/src/export/sizeHistory.ts b/pipeline/src/export/sizeHistory.tsindex d0717029f..7083a3e9a 100644--- a/pipeline/src/export/sizeHistory.ts+++ b/pipeline/src/export/sizeHistory.ts@@ -62,6 +62,8 @@ export const PACKAGING_SIZE_ROLE: Readonly<Record<string, keyof SizeSettings | 'appId: 'inert',icon: 'content',achievements: 'inert',+ // A logo is inlined into the page, so choosing one changes what ships.+ splash: 'content',platforms: 'content',};diff --git a/pipeline/src/export/splash.ts b/pipeline/src/export/splash.tsindex f4d4958a9..92c887859 100644--- a/pipeline/src/export/splash.ts+++ b/pipeline/src/export/splash.ts@@ -17,18 +17,37 @@ import { BOOT_STAGES, BOOT_TOTAL, type BootStage } from '../../../sdk/src/runtimexport { BOOT_STAGES, type BootStage };+/**+ * The page's ground, and what the start screen fades out over. One colour for+ * both, or the fade flashes through to white between them — which is why the+ * page and this file cannot each name their own.+ */+export const PAGE_BACKGROUND = '#0e121b';+/** Ids the page and the runtime agree on; `es-` so a game's own markup cannot collide. */const ROOT = 'es-splash';const BAR = 'es-splash-bar';const LABEL = 'es-splash-label';+/** What the project said the start screen should look like. */+export interface SplashLook {+ /** The logo as a data: URI — inlined by the export, since an image fetched+ * after the engine has nothing left to cover. */+ logo?: string;+ /** Shortest time on screen, in ms. */+ minMs?: number;+ /** CSS colour behind it; the page's own when the project said nothing. */+ background?: string;+}+/*** The start screen's CSS. `background` matches the page so the fade lands on the* same colour the canvas clears to, rather than flashing through to white.*/export function splashCss(background: string): string {return (- `#${ROOT}{position:fixed;inset:0;z-index:20;display:flex;flex-direction:column;`+ `#${ROOT} .es-splash-logo{max-width:min(220px,46vw);max-height:30vh;object-fit:contain;}`+ + `#${ROOT}{position:fixed;inset:0;z-index:20;display:flex;flex-direction:column;`+ `align-items:center;justify-content:center;gap:18px;background:${background};`+ "color:#c7d0e0;font:500 14px/1.5 system-ui,-apple-system,'Segoe UI',sans-serif;"+ 'transition:opacity .35s ease;padding:24px;text-align:center;}'@@ -46,11 +65,18 @@ export function splashCss(background: string): string {);}-/** The start screen's markup — no script of its own, so the page adds no CSP hash. */-export function splashHtml(title: string): string {+/** The start screen's markup — no script of its own, so the page adds no CSP hash.+ * `minMs` rides on a data attribute for the same reason. */+export function splashHtml(title: string, look: SplashLook = {}): string {const safe = title.replace(/[&<>]/g, (c) => ({ '&': '&', '<': '<', '>': '>' }[c] as string));- return `<div id="${ROOT}" role="status" aria-live="polite">`- + `<div class="es-splash-title">${safe}</div>`+ const hold = look.minMs ? ` data-min-ms="${Math.round(look.minMs)}"` : '';+ // A game with a logo shows the logo; the title is then the alt text rather+ // than a second heading saying the same thing.+ const mark = look.logo+ ? `<img class="es-splash-logo" src="${look.logo}" alt="${safe}">`+ : `<div class="es-splash-title">${safe}</div>`;+ return `<div id="${ROOT}" role="status" aria-live="polite"${hold}>`+ + mark+ `<div class="es-splash-track"><div id="${BAR}"></div></div>`+ `<div id="${LABEL}">${BOOT_STAGES[0].says}…</div>`+ '</div>';@@ -65,19 +91,38 @@ export interface Splash {}/**- * Drive the page's start screen, or nothing when the page has none.+ * The events a page outside the bundle listens for — a portal SDK's own loading+ * screen. DOM events, not a global: a listener must be added BEFORE the bundle+ * runs, and the page carries no script of ours to define one on. `progress` is+ * 0..1 and never goes backwards.+ */+export const BOOT_PROGRESS_EVENT = 'esengine:bootprogress';+export const FIRST_FRAME_EVENT = 'esengine:firstframe';++/**+ * Drive the page's start screen and announce the boot.*- * A host that predates this (or a playable, which is sized by an SDK container- * and has no room for one) simply has no element, and boot proceeds untouched —- * the start screen must never be a thing a boot can fail on.+ * Always returns: a playable is sized by an SDK container and carries no start+ * screen, but a portal around it still wants the events. A boot must never be a+ * thing the start screen can fail.*/-export function attachSplash(doc: Document = document): Splash | null {+export function attachSplash(doc: Document = document): Splash {const root = doc.getElementById(ROOT);- if (!root) return null;- const bar = doc.getElementById(BAR);- const label = doc.getElementById(LABEL);+ const bar = root && doc.getElementById(BAR);+ const label = root && doc.getElementById(LABEL);+ const showUntil = Date.now() + Number(root?.getAttribute('data-min-ms') ?? 0);let done = 0;+ let finished = false;const seen = new Set<BootStage>();+ const announce = (type: string, detail: unknown): void => {+ const view = doc.defaultView;+ if (view) view.dispatchEvent(new view.CustomEvent(type, { detail }));+ };+ const fade = (): void => {+ if (!root?.isConnected) return;+ root.classList.add('es-splash-gone');+ setTimeout(() => root.remove(), 400);+ };return {reach(stage) {// Idempotent by stage, not additive: a retried leg must not push the bar@@ -85,16 +130,23 @@ export function attachSplash(doc: Document = document): Splash | null {if (seen.has(stage)) return;seen.add(stage);done += BOOT_STAGES.find((s) => s.id === stage)?.weight ?? 0;- if (bar) bar.style.width = `${Math.min(100, Math.round((done / BOOT_TOTAL) * 100))}%`;+ const progress = Math.min(1, done / BOOT_TOTAL);+ if (bar) bar.style.width = `${Math.round(progress * 100)}%`;const at = BOOT_STAGES.findIndex((s) => s.id === stage);const next = BOOT_STAGES[at + 1];if (label && next) label.textContent = `${next.says}…`;+ announce(BOOT_PROGRESS_EVENT, { stage, progress });},done() {- if (!root.isConnected) return;+ if (finished) return;+ finished = true;if (bar) bar.style.width = '100%';- root.classList.add('es-splash-gone');- setTimeout(() => root.remove(), 400);+ announce(FIRST_FRAME_EVENT, {});+ // A boot that finished in 120ms would otherwise flash a bar that appears+ // and vanishes, which reads as a glitch rather than as loading.+ const wait = showUntil - Date.now();+ if (wait > 0) setTimeout(fade, wait);+ else fade();},};}diff --git a/pipeline/src/project/format.ts b/pipeline/src/project/format.tsindex 022eb95cd..ce695686a 100644--- a/pipeline/src/project/format.ts+++ b/pipeline/src/project/format.ts@@ -375,6 +375,8 @@ export interface ProjectPackaging {* a store would accept and silently drop.*/achievements?: string[];+ /** The start screen the page shows before the engine has arrived. */+ splash?: SplashPackaging;/** Per-platform packaging config: each target's slice of the app identity, plus* whatever only it has (a WeChat appid, an Android versionCode). */platforms?: {@@ -387,6 +389,27 @@ export interface ProjectPackaging {};}+/**+ * What the exported page shows while the engine is still arriving.+ *+ * The screen itself is not optional — a blank page during a 1.7MB download is+ * the failure this exists to prevent — so these only say what it LOOKS like.+ */+export interface SplashPackaging {+ /** Project-relative image, inlined into the page so it needs no request of+ * its own: a logo that arrives after the engine has nothing left to cover. */+ logo?: string;+ /** CSS colour behind it. Absent ⇒ the page's own background, so the fade+ * lands on the colour the canvas clears to instead of flashing white. */+ background?: string;+ /**+ * Shortest time the screen stays up, in ms. A boot that finishes in 120ms+ * otherwise shows a bar that appears and vanishes, which reads as a glitch+ * rather than as loading. 0 ⇒ fade the moment the first frame is ready.+ */+ minMs?: number;+}+/** Committed project identity + config (`project.esproject`). */export interface ProjectManifest {/** Manifest schema version (migration-aware; rejects newer than supported). */@@ -766,6 +789,19 @@ export function parseManifest(raw: unknown): ProjectManifest {.filter(Boolean))];if (ids.length > 0) pkg.achievements = ids;}+ if (p.splash && typeof p.splash === 'object') {+ const sp = p.splash as Record<string, unknown>;+ const splash: SplashPackaging = {};+ if (typeof sp.logo === 'string' && sp.logo.trim()) splash.logo = sp.logo.trim();+ if (typeof sp.background === 'string' && sp.background.trim()) splash.background = sp.background.trim();+ // A negative hold is not a hold, and a very long one is a game nobody+ // reaches; both are dropped rather than clamped, so the page keeps its own+ // default instead of obeying a number that was never meant.+ if (typeof sp.minMs === 'number' && sp.minMs >= 0 && sp.minMs <= 10_000) {+ splash.minMs = Math.round(sp.minMs);+ }+ if (Object.keys(splash).length > 0) pkg.splash = splash;+ }if (p.platforms && typeof p.platforms === 'object') {const pl = p.platforms as Record<string, unknown>;const platforms: NonNullable<ProjectPackaging['platforms']> = {};diff --git a/pipeline/src/project/runtimeConfig.ts b/pipeline/src/project/runtimeConfig.tsindex fcbac046f..e1a5bd9f1 100644--- a/pipeline/src/project/runtimeConfig.ts+++ b/pipeline/src/project/runtimeConfig.ts@@ -246,6 +246,8 @@ export interface PackagingOptions {excludeScenes: string[];sourcemap: boolean;appIcon: string | undefined;+ /** How the page's start screen should look; see SplashPackaging. */+ splash: ProjectPackaging['splash'];}export function packagingOptionsOf(manifest: Pick<ProjectManifest, 'packaging' | 'features'>): PackagingOptions {@@ -263,6 +265,7 @@ export function packagingOptionsOf(manifest: Pick<ProjectManifest, 'packaging' |// word the dialog uses for the same choice.sourcemap: p?.sourceMaps ?? (p?.config === 'development'),appIcon: p?.icon,+ splash: p?.splash,};}diff --git a/pipeline/tests/export-splash.test.ts b/pipeline/tests/export-splash.test.tsnew file mode 100644index 000000000..25b0ec2cf--- /dev/null+++ b/pipeline/tests/export-splash.test.ts@@ -0,0 +1,108 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file The start screen the exported page carries.+ *+ * It has to be on screen before `game.js` is even fetched, so everything it+ * needs is IN the page — a logo that arrives over the network arrives in the+ * same window the engine does, with nothing left to cover.+ */+import { describe, it, expect, beforeAll, afterAll } from 'vitest';+import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, rmSync } from 'node:fs';+import { tmpdir } from 'node:os';+import path from 'node:path';+import { exportGame } from '../src/export/exportGame';+import { runtimeConfigOf } from '../src/project/runtimeConfig';+import type { ProjectPackaging } from '../src/project/format';+import { writeFakeSdkDist } from './fixtures/fakeSdkDist';++let root: string;+const TEX = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa';+const SCN = 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb';+const meta = (uuid: string, type: string) => JSON.stringify({ uuid, version: '2.0', type, importer: {} });+/** A one-pixel PNG, so the inlined bytes are a real image rather than a string. */+const PNG = Buffer.from(+ 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==',+ 'base64',+);++beforeAll(() => {+ root = mkdtempSync(path.join(tmpdir(), 'estella-export-splash-'));+ mkdirSync(path.join(root, 'assets'), { recursive: true });+ writeFileSync(path.join(root, 'assets', 'hero.png'), PNG);+ writeFileSync(path.join(root, 'assets', 'hero.png.meta'), meta(TEX, 'texture'));+ writeFileSync(path.join(root, 'assets', 'logo.png'), PNG);+ mkdirSync(path.join(root, 'scenes'), { recursive: true });+ writeFileSync(+ path.join(root, 'scenes', 'main.esscene'),+ JSON.stringify({ version: '1.0', name: 'Main', entities: [{ id: 0, components: [{ type: 'Sprite', data: { texture: `@uuid:${TEX}` } }] }] }),+ );+ writeFileSync(path.join(root, 'scenes', 'main.esscene.meta'), meta(SCN, 'scene'));+ writeFakeSdkDist(path.join(root, '_sdk'), {+ 'index.js': 'export function initWebRuntime(){return Promise.resolve();}\n',+ });+ mkdirSync(path.join(root, '_wasm'), { recursive: true });+ writeFileSync(path.join(root, '_wasm', 'esengine.js'), 'const M=()=>{};\nexport default M;\n');+ writeFileSync(path.join(root, '_wasm', 'esengine.wasm'), 'wasmbytes');+}, 60_000);++afterAll(() => rmSync(root, { recursive: true, force: true, maxRetries: 10, retryDelay: 50 }));++/** Export for web and hand back the page plus whatever the build said about it. */+async function page(splash?: ProjectPackaging['splash']): Promise<{ html: string; warnings: string[] }> {+ const outDir = path.join(root, `dist-${Math.random().toString(36).slice(2)}`);+ const res = await exportGame({+ root,+ entryScene: 'scenes/main.esscene',+ hostsDir: path.resolve(__dirname, '../src/runtime'),+ sdkDistDir: path.join(root, '_sdk'),+ wasmDir: path.join(root, '_wasm'),+ outDir,+ title: 'My Game',+ platform: 'web',+ runtime: runtimeConfigOf({ designResolution: { width: 800, height: 600 } }),+ splash,+ });+ expect(res.ok, res.errors.join('\n')).toBe(true);+ return { html: readFileSync(path.join(outDir, 'index.html'), 'utf8'), warnings: res.warnings };+}++describe('the exported page’s start screen', () => {+ it('is there with nothing configured, showing the game’s name', async () => {+ const { html } = await page();+ expect(html).toContain('id="es-splash"');+ expect(html).toContain('My Game');+ expect(html).not.toContain('class="es-splash-logo"');+ }, 180_000);++ it('carries the logo IN the page, not as a request that races the engine', async () => {+ const { html, warnings } = await page({ logo: 'assets/logo.png' });+ expect(warnings.join('\n')).not.toContain('logo');+ expect(html).toContain('class="es-splash-logo"');+ expect(html).toContain(`src="data:image/png;base64,${PNG.toString('base64')}"`);+ // The path itself must not survive into the page: a start screen that+ // fetches its own logo is the failure this inlining exists to prevent.+ expect(html).not.toContain('assets/logo.png');+ }, 180_000);++ it('says so and ships anyway when the logo is not there', async () => {+ const { html, warnings } = await page({ logo: 'assets/missing.png' });+ expect(warnings.join('\n')).toContain('assets/missing.png');+ // Still a start screen, still the game's name — a bad path must not leave+ // the player watching a blank page.+ expect(html).toContain('id="es-splash"');+ expect(html).toContain('My Game');+ }, 180_000);++ it('refuses a file the page could not decode, rather than a broken first screen', async () => {+ const { html, warnings } = await page({ logo: 'assets/hero.tga' });+ expect(warnings.join('\n')).toContain('assets/hero.tga');+ expect(html).not.toContain('class="es-splash-logo"');+ }, 180_000);++ it('holds for as long as the project asked, and paints the colour it asked for', async () => {+ const { html } = await page({ background: '#102030', minMs: 800 });+ expect(html).toContain('data-min-ms="800"');+ expect(html).toContain('#102030');+ }, 180_000);+});diff --git a/pipeline/tests/splash-screen.test.ts b/pipeline/tests/splash-screen.test.tsnew file mode 100644index 000000000..97f17ac24--- /dev/null+++ b/pipeline/tests/splash-screen.test.ts@@ -0,0 +1,60 @@+// @vitest-environment jsdom+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file The start screen's own behaviour, which the page's markup only sets up.+ *+ * A file of its own because jsdom is: the export tests next door bundle with+ * esbuild, and a DOM in that process breaks it.+ */+import { describe, it, expect } from 'vitest';+import { BOOT_STAGES, BOOT_PROGRESS_EVENT, FIRST_FRAME_EVENT, attachSplash } from '../src/export/splash';++describe('driving the start screen', () => {+ const mount = (attrs = ''): Document => {+ document.body.innerHTML = `<div id="es-splash"${attrs}>`+ + '<div class="es-splash-track"><div id="es-splash-bar"></div></div>'+ + '<div id="es-splash-label"></div></div>';+ return document;+ };++ it('announces every stage it reaches, and never goes backwards', () => {+ const seen: { stage: string; progress: number }[] = [];+ window.addEventListener(BOOT_PROGRESS_EVENT, (e) => seen.push((e as CustomEvent).detail));+ const splash = attachSplash(mount());+ for (const s of BOOT_STAGES) splash.reach(s.id);+ // Re-reaching one must not push the bar past what actually finished.+ splash.reach(BOOT_STAGES[0].id);++ expect(seen.map((s) => s.stage)).toEqual(BOOT_STAGES.map((s) => s.id));+ expect(seen.map((s) => s.progress)).toEqual([...seen.map((s) => s.progress)].sort((a, b) => a - b));+ expect(seen[seen.length - 1].progress).toBe(1);+ });++ it('says when the first frame is up, even on a page with no start screen', () => {+ document.body.innerHTML = '';+ let frames = 0;+ window.addEventListener(FIRST_FRAME_EVENT, () => { frames += 1; });+ const splash = attachSplash(document);+ splash.done();+ splash.done();+ // A playable is sized by an SDK container and carries no screen; the portal+ // around it still has to be told the game is drawing.+ expect(frames).toBe(1);+ });++ it('holds a fast boot on screen for as long as the project asked', async () => {+ const doc = mount(' data-min-ms="120"');+ const splash = attachSplash(doc);+ splash.done();+ expect(doc.getElementById('es-splash')?.classList.contains('es-splash-gone')).toBe(false);+ await new Promise((r) => setTimeout(r, 200));+ expect(doc.getElementById('es-splash')?.classList.contains('es-splash-gone')).toBe(true);+ });++ it('fades at once when the project asked for no hold', () => {+ const doc = mount();+ attachSplash(doc).done();+ expect(doc.getElementById('es-splash')?.classList.contains('es-splash-gone')).toBe(true);+ });+});diff --git a/tools/launchers/launch-export.mjs b/tools/launchers/launch-export.mjsindex 37504f445..f9ced587e 100644--- a/tools/launchers/launch-export.mjs+++ b/tools/launchers/launch-export.mjs@@ -309,12 +309,19 @@ const SCENE = flag('scene', '');}// A start screen that outlived its boot covers the game with something that- // looks like a game still loading, and every other check here passes. Faded,- // not removed: `done()` drops the node 400ms later, long after boot ended.- const splashLeft = await win.webContents.executeJavaScript(- "(() => { const e = document.getElementById('es-splash');"- + " return !!e && !e.classList.contains('es-splash-gone'); })()",- ).catch(() => false);+ // looks like a game still loading, and every other check here passes. The+ // deadline is the PAGE's (`data-min-ms`), not a fixed wait of ours.+ const splashLeft = await (async () => {+ const still = () => win.webContents.executeJavaScript(+ "(() => { const e = document.getElementById('es-splash');"+ + " return e && !e.classList.contains('es-splash-gone')"+ + " ? Number(e.getAttribute('data-min-ms') || 0) : -1; })()",+ ).catch(() => -1);+ const hold = await still();+ if (hold <= 0) return hold === 0;+ await new Promise((r) => setTimeout(r, hold + 200));+ return (await still()) >= 0;+ })();const image = await win.webContents.capturePage();if (OUT) await writeFile(OUT, image.toPNG());diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex c22ef5d5a..0e4156694 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): 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':{ note: "The build dialog states a platform's size caps before you package." },'fix(export): a mini-game takes the engine build a mini-game host can load':