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
docs(changelog): the notes name what this round shrank and what now judges it
esenginea137e77b8b7a
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 5a69aa8ef..c42933d76 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,6 +12,57 @@ Version numbers here track the **Estella release** — the engine + editor + SDKshipped together, matching the Git tags and GitHub Releases. The SDK is notpublished separately; it ships inside the editor.+## [Unreleased]++### Added++- **A playable ad now fits the networks it is made for.** The single-file+ transport inlined its engine as plain base64 — a +33% tax on a payload that is+ mostly a 1.5MB wasm — and never minified the bundle, because the CLI had no+ flag to ask for it and only the editor's Shipping configuration passed one.+ Every payload is deflated before encoding now (the engine module goes 2.056MB+ → 0.597MB), side modules inflate on first use rather than at boot, and the+ target minifies unless told otherwise. `hello-world` packages at 1.38MB+ against 2.82MB before, `video-puzzle` at 1.78MB and `spine-demo` at 1.91MB —+ all three under Meta's 2MB cap, which nothing in the corpus had ever met.+ Every package was launched and compared: platformer and spine-demo are+ identical to the pixel, and spine-demo also matches its own web export, which+ shares none of this path.++ The decoder is the engine's own rather than `DecompressionStream`, which+ landed in Safari 16.4: a playable that white-screens on an older WebView is+ worse than a larger one, since the impression is paid for either way. One path+ runs on every device, so every device runs what the tests run.++- **`estella.mjs export --minify`**, for the targets whose default it is not.++### Changed++- `EmbeddedSideModuleEntry` carries decoded bytes (`glue`, `wasm`) rather than+ base64 strings. How a payload survived a trip inside an HTML file is the host+ page's business; with the SDK naming the encoding, the transport could not+ change without changing the SDK. @experimental, and its only consumer is the+ playable host.++### Fixed++- **A playable's size report described an empty directory.** The report excludes+ each package written inside the output dir, since an .apk sits beside the+ loose files it was made from and counting both doubles the build — and it+ excluded the uploaded file on the same rule. For every other target that was+ merely redundant, but a playable's `index.html` repackages nothing and nothing+ else is in the directory, so excluding it excluded everything. On the one+ target where size is a hard cap, an export could say "over by 64%" without+ naming a byte of where it went. It now reports what the assembly joined, so a+ playable composes in the same vocabulary as the web and WeChat builds.++- **The golden chain never weighed what it packaged.** `verify-golden` gets a+ `size` stage holding every pair to the limits its own export reports, so+ Meta's 2MB and WeChat's 4MB are judged by a criterion rather than by whoever+ reads the output. With it in place `startup-size` stops being a declared gap —+ it was one because the runtime floor exceeded the cap — and the corpus+ certifies 38/39 capabilities.+## [0.57.0] - 2026-08-24### Addeddiff --git a/pipeline/src/export/exportPlayable.ts b/pipeline/src/export/exportPlayable.tsindex 2fbe5529f..ab443e266 100644--- a/pipeline/src/export/exportPlayable.ts+++ b/pipeline/src/export/exportPlayable.ts@@ -76,15 +76,9 @@ const inlineSafe = (s: string): string => s.replace(/<\/script/gi, '<\\/script')/*** A binary payload on its way into an HTML file: deflated, then base64.*- * Base64 costs +33% over the bytes it carries, and the bytes are wasm — which- * deflates to under a third. Compressing before encoding is worth more than any- * denser encoding could be: the engine's own module goes 1.542MB → 2.056MB- * encoded raw, against 0.597MB encoded this way.- *- * `n` is the original length, so the decoder allocates once and a stream that- * does not fill it exactly is caught here rather than at some later use. Raw- * deflate: `inflateRaw` is the only reader, and a wrapper's checksum would only- * re-answer what instantiating the module answers immediately after.+ * Deflating first beats any denser encoding — the engine module is 2.056MB+ * encoded raw, 0.597MB this way. `n` is the length before deflating, so the+ * decoder allocates once and catches a short stream.*/interface PackedBytes {/** base64 of the raw-deflated bytes. */@@ -205,16 +199,10 @@ export async function exportPlayable(opts: {* reaches the ad-network profile, which may declare it to the platform. */orientation?: ScreenOrientation;/**- * Defaults to ON here, unlike every other target.- *- * A playable exists to be uploaded to an ad network under a hard byte cap;- * there is no dev build of one, and shipping it unminified spent 0.31MB of a- * 2MB budget on whitespace. Verified as a no-op on what it draws: the same- * platformer package minified and not is identical to the pixel (frame- * distance 0.0000, against a 0.06 tolerance).- *- * An explicit `false` is still honoured — the editor's Development- * configuration passes one.+ * Defaults to ON here, unlike every other target: a playable is uploaded+ * under a hard byte cap and has no dev build, and unminified spent 0.31MB of+ * a 2MB budget on whitespace. A no-op on what it draws (measured: identical+ * to the pixel). An explicit `false` is still honoured.*/minify?: boolean;/** The project's runtime settings, derived once by `runtimeConfigOf`; the page@@ -233,12 +221,9 @@ export async function exportPlayable(opts: {const errors: string[] = [];await mkdir(absOut, { recursive: true });const cookDir = path.join(absOut, '.playable-cook');- // What each span of the finished file costs, under the path those bytes would- // carry if this target shipped them loose — so a playable's composition reads- // in the same vocabulary as the web and WeChat ones, rather than being one- // opaque file. Filled where the bytes are JOINED: a reader that parsed the- // finished HTML back apart would be a second account of the same- // concatenation, and the one that drifts.+ // What each span costs, under the path those bytes would carry shipped loose,+ // so a playable composes in the same vocabulary as web and WeChat. Filled+ // where the bytes are JOINED — reading the finished HTML back would drift.const spans: { path: string; bytes: number }[] = [];// 1. Cook reachable assets to a temp dir (everything ends up inlined → removed after).@@ -271,8 +256,7 @@ export async function exportPlayable(opts: {const key = `@uuid:${e.uuid}`;assets[key] = `data:${mimeOf(e.path)};base64,${buf.toString('base64')}`;pathMap[e.sourcePath ?? e.path] = key;- // The data URL, not the file: base64 is what this asset actually costs the- // package, and the +33% is the thing a developer is being asked to see.+ // The data URL, not the file: base64 is what the asset costs the package.spans.push({ path: e.path, bytes: assets[key].length });}} catch (err) {@@ -372,9 +356,8 @@ export async function exportPlayable(opts: {await rm(cookDir, { recursive: true, force: true });const htmlBytes = (await stat(outFile)).size;- // The page itself, plus the JSON scaffolding around the spans above (each- // asset's key and quotes, the small globals). Derived rather than summed so- // the parts always add up to the file, whatever else the assembly gains.+ // The page, plus the JSON scaffolding around the spans. Derived rather than+ // summed, so the parts add up to the file whatever the assembly gains later.const inlined = spans.reduce((n, s) => n + s.bytes, 0);spans.push({ path: 'index.html', bytes: Math.max(0, htmlBytes - inlined) });diff --git a/pipeline/src/export/sizeReport.ts b/pipeline/src/export/sizeReport.tsindex 9f420924d..b8190de2a 100644--- a/pipeline/src/export/sizeReport.ts+++ b/pipeline/src/export/sizeReport.ts@@ -278,10 +278,8 @@ export async function measureBuild(opts: {* Absolute path to the single uploaded file, when the target makes one.** Weighed on its own; it does NOT exclude itself from the directory totals.- * A deliverable that repackages loose files is already in {@link packages},- * and the playable's is not a repackaging at all — its `index.html` IS the- * build, so excluding it left the composition of the one target where size is- * a hard cap reading as an empty directory.+ * One that repackages loose files is already in {@link packages}, and the+ * playable's `index.html` IS the build — excluding it emptied the report.*/deliverable?: string;/**@@ -300,13 +298,9 @@ export async function measureBuild(opts: {packages?: readonly string[];/*** A single-file target's file, and what it is made of — each span under the- * path those bytes would carry loose. The file is replaced by its spans, so a- * playable is composed in the same vocabulary as every other target instead of- * weighing in as one nameless `other`.- *- * The producer supplies these, because the assembly is where the bytes are- * joined and it already knows; parsing the finished file back apart would be a- * second account of the same concatenation.+ * path those bytes would carry loose. The file is replaced by its spans, so+ * it composes like every other target instead of weighing in as one nameless+ * `other`. Supplied by the assembly, which is where the bytes are joined.*/inlineOf?: { file: string; parts: readonly { path: string; bytes: number }[] };}): Promise<BuildSizeReport> {diff --git a/pipeline/src/runtime/playableHost.ts b/pipeline/src/runtime/playableHost.tsindex 1dc2274ae..adcf73332 100644--- a/pipeline/src/runtime/playableHost.ts+++ b/pipeline/src/runtime/playableHost.ts@@ -23,11 +23,9 @@ import { inflateRaw } from './inflate';type EngineFactory = (opts?: Record<string, unknown>) => Promise<EngineModule>;// Inlined by exportPlayable as <script> globals (kept out of the bundle so the-// large base64 blobs aren't re-parsed as code). The glue is the WEB esengine.js-// (ESM) text; the wasm is esengine.wasm. __SIDE_MODULES__ holds glue+wasm for-// exactly the optional modules (physics/spine) the scene uses — the exporter ran-// the runtime's gating scan to pick them. Every one of them is `PackedBytes`:-// raw-deflated, then base64.+// large blobs aren't re-parsed as code). __SIDE_MODULES__ holds exactly the+// optional modules the scene uses, chosen by the runtime's own gating scan.+// Each payload is raw-deflated then base64 — see PackedBytes in exportPlayable.interface PackedBytes { z: string; n: number }declare const __ENGINE_GLUE__: PackedBytes;declare const __ENGINE_WASM__: PackedBytes;@@ -58,11 +56,9 @@ const unpackText = (p: PackedBytes): string => new TextDecoder().decode(unpack(p/*** The inlined side-module registry, decoded on first use.*- * Lazily because the scan that chose these modules asks what the CONTENT could- * reach, not what a given run does: a scene that can spawn a Spine skeleton- * carries the runtime whether or not it spawns one. Inflating all of them at- * boot would spend that cost on every play, and these are the big ones —- * basis is 1MB before deflating.+ * Lazy because the scan that chose these asks what the CONTENT could reach, not+ * what a run does: a scene that CAN spawn a Spine skeleton carries the runtime+ * either way, and basis is 1MB before deflating.*/function unpackSideModules(): EmbeddedSideModuleRegistry {if (typeof __SIDE_MODULES__ === 'undefined') return {};@@ -135,10 +131,7 @@ async function boot(): Promise<void> {...packagedAppOptions(runtimeConfig),getViewportSize: () => ({ width: canvas.width, height: canvas.height }),// Physics + spine resolve from the inlined registry (no fetch). Unpacked- // here rather than inside the SDK: how these bytes survived a trip inside an- // HTML file is this page's business, and the SDK takes them decoded.- // Lazily, because a module the scene never asks for should not be paid for- // at boot — spine and basis are ~1MB each before deflating.+ // here rather than in the SDK: the transport is this page's business.sideModules: createEmbeddedSideModuleHost(unpackSideModules()),});setEditorMode(false);diff --git a/pipeline/tests/export-playable.test.ts b/pipeline/tests/export-playable.test.tsindex d7fe61c14..260d6814e 100644--- a/pipeline/tests/export-playable.test.ts+++ b/pipeline/tests/export-playable.test.ts@@ -20,13 +20,14 @@ import { inflateRaw } from '../src/runtime/inflate';/*** Read an inlined payload back out of the page, the way the host does.*- * The engine and every side module travel deflated-then-base64 (see PackedBytes- * in exportPlayable), so "the bytes are in the file" cannot be asked by looking- * for their base64 — that only ever held while the transport was plain. Asking- * it through the decoder is the stronger question anyway: it says the bytes- * arrived AND that what shipped can be turned back into them.+ * Payloads travel deflated, so looking for their base64 asks nothing. Through+ * the decoder is the stronger question: the bytes arrived AND what shipped can+ * be turned back into them.*/-function inlinedText(html: string, global: string, pick?: (v: never) => { z: string; n: number }): string {+type Packed = { z: string; n: number };+type PackedModules = Record<string, { glue: Packed; wasm: Packed }>;++function inlinedText(html: string, global: string, pick?: (v: PackedModules) => Packed): string {const at = html.indexOf(`window.${global}=`);if (at < 0) throw new Error(`${global} is not in the page`);const json = html.slice(at + `window.${global}=`.length);@@ -34,8 +35,8 @@ function inlinedText(html: string, global: string, pick?: (v: never) => { z: str// `;` that leaves the JSON balanced — JSON.parse of the prefix finds it.for (let end = json.indexOf(';'); end > 0; end = json.indexOf(';', end + 1)) {try {- const value = JSON.parse(json.slice(0, end));- const packed = pick ? pick(value) : value;+ const value: unknown = JSON.parse(json.slice(0, end));+ const packed = pick ? pick(value as PackedModules) : (value as Packed);const raw = Uint8Array.from(atob(packed.z), (c) => c.charCodeAt(0));return new TextDecoder().decode(inflateRaw(raw, packed.n));} catch { /* that `;` was inside the JSON — try the next one */ }@@ -97,12 +98,9 @@ describe('exportGame (playable)', () => {outDir: out,title: 'Playable Demo',platform: 'playable',- // Structure is what this asserts, so it reads the unminified shape. The- // stub SDK below exports `defineComponent(){}` — an empty function, and- // esbuild is right to drop a call to one, which takes `SpawnMarker` with- // it. The real SDK's writes a registry, so the same project keeps its- // components minified (verified on platformer: identical to the pixel).- // The default is asserted on its own, below.+ // Structure, so the unminified shape. The stub SDK's `defineComponent(){}`+ // is empty, and esbuild is right to drop a call to one — taking+ // `SpawnMarker` with it. The real SDK's writes a registry. Default below.minify: false,});@@ -138,11 +136,9 @@ describe('exportGame (playable)', () => {expect(html).not.toContain('screen.orientation');}, 60_000);- // A playable is uploaded to an ad network under a hard byte cap and there is no- // dev build of one, so this target minifies unless told not to — the opposite- // default from every other. Shipping it unminified spent 0.31MB of a 2MB budget- // on whitespace, and the CLI had no flag to say otherwise, so every packaged- // playable CI ever weighed was the unshipped shape.+ // No dev build of a playable exists, so this target minifies unless told not+ // to — the opposite default from every other. Unminified spent 0.31MB of a+ // 2MB budget on whitespace.it('minifies by default, and still honours an explicit no', async () => {const run = async (minify: boolean | undefined, dir: string): Promise<number> => {const res = await exportGame({diff --git a/pipeline/tests/inflate.test.ts b/pipeline/tests/inflate.test.tsindex 7589b46af..2f60f8ba6 100644--- a/pipeline/tests/inflate.test.ts+++ b/pipeline/tests/inflate.test.ts@@ -133,10 +133,9 @@ describe.skipIf(!existsSync(engine))('inflateRaw — the payloads that ship', ()const started = performance.now();inflateRaw(deflated, bytes.length);const ms = performance.now() - started;- // Measured ~16ms for 1.5MB on a development machine (~95 MB/s). The ceiling- // is deliberately an order of magnitude above that: what it guards against- // is a rewrite that drops to something unusable on a phone, not the spread- // between one machine and another — which is all a tight bound would time.+ // ~16ms for 1.5MB here (~95 MB/s); the ceiling sits an order of magnitude+ // above so it catches a rewrite gone unusable, not the spread between+ // machines — which is all a tight bound would time.expect(ms).toBeLessThan(500);});});diff --git a/pipeline/tests/size-report.test.ts b/pipeline/tests/size-report.test.tsindex 8a8635845..f94e812b3 100644--- a/pipeline/tests/size-report.test.ts+++ b/pipeline/tests/size-report.test.ts@@ -243,12 +243,9 @@ describe('measuring a build on disk', () => {});it('still weighs the single file a playable ships, which is the build rather than a copy of it', async () => {- // The playable's whole output is one index.html — nothing sits loose beside- // it to double-count, so the repackaging rule that covers an .apk does not- // apply. Excluding it left byKind, largest and fileCount empty on the ONE- // target whose size is a hard cap, so the export could say "over by 64%" and- // not one byte of where it went. Note there is no `packages` here: that is- // the shape, and it is what the two cases above never exercise.+ // One index.html, nothing loose beside it to double-count, so the .apk+ // repackaging rule does not apply. Note there is no `packages` here — the+ // shape the two cases above never exercise.await write('index.html', 3_444_304);const report = await measureBuild({root: dir,diff --git a/sdk/src/sideModules/embeddedHost.ts b/sdk/src/sideModules/embeddedHost.tsindex 28667fab4..0f137a203 100644--- a/sdk/src/sideModules/embeddedHost.ts+++ b/sdk/src/sideModules/embeddedHost.ts@@ -9,12 +9,9 @@* registry that lacks a module the scene needs is an export bug, not a* silent runtime degrade.*- * How those bytes were ENCODED to survive the trip inside an HTML file- * is the host page's business, not this module's: they arrive already- * decoded. They used to arrive base64, which put one page's transport- * decision in the SDK and meant a change to it (they are deflated now,- * which is worth ~1MB of an ad network's 2MB cap) could not be made- * without changing this file too.+ * Bytes arrive DECODED: how they survived the trip inside an HTML file+ * is the host page's business, and naming an encoding here would put+ * one page's transport decision in the SDK.*/import { createSideModuleHost, instantiateFromGlueText, type SideModuleHost } from './host';import type { SideModuleId } from './registry';diff --git a/tools/goldenProjects.mjs b/tools/goldenProjects.mjsindex 40677b51a..627f92927 100644--- a/tools/goldenProjects.mjs+++ b/tools/goldenProjects.mjs@@ -280,13 +280,9 @@ export const GOLDEN = [},{id: 'video-puzzle',- // `startup-size` was a declared gap until the playable transport stopped- // spending a third of the budget on base64: the runtime floor was 2.8MB- // against a 2MB cap, so no project could have carried the claim. It is- // 1.38MB for an empty project now, and this one packages at 1.78MB — so the- // claim is carried by the biggest playable in the corpus rather than the- // smallest thing that would pass. What JUDGES it is the `size` stage, which- // holds every target to the limits its own export reports.+ // `startup-size` was a declared gap while the runtime floor (2.8MB) exceeded+ // the 2MB cap; it is 1.38MB empty now and this packages at 1.78MB — the+ // biggest playable in the corpus, not the smallest thing that would pass.certifies: ['single-file', 'startup-size'],targets: ['playable', 'web'],tier: 'nightly',diff --git a/tools/verify-golden.mjs b/tools/verify-golden.mjsindex 33efdab64..a75450478 100644--- a/tools/verify-golden.mjs+++ b/tools/verify-golden.mjs@@ -219,11 +219,8 @@ const fmtMB = (bytes) => `${(bytes / 1024 / 1024).toFixed(2)}MB`;/*** The limits the export judged itself against, from the report it already* writes. Read rather than recomputed: the pipeline owns what a package weighs- * and which limits are in force (an ad network's profile, a project's own- * budget), and a second opinion here is the one that drifts.- *- * An unreadable report yields nothing rather than failing — a target that- * declares no limit writes no verdicts, which is not the same as being over one.+ * and which limits are in force, and a second opinion here is the one that+ * drifts. No verdicts is not the same as being over one.*/function readSizeVerdicts(reportPath) {try {@@ -257,13 +254,9 @@ for (const { id, target } of pairs) {continue;}- // A package that does not fit is one nobody can ship, and until now nothing in- // this chain asked. The measurement existed and the CLI could already enforce- // it, so the limits a target declares — Meta's 2MB index.html, WeChat's 4MB- // main package — were judged only by whoever happened to read the output.- // Left as a stage rather than an export flag so a build that is over still- // launches and reports everything else it can, the way an over-tolerance- // parity does.+ // A package that does not fit is one nobody can ship. A stage rather than an+ // export flag, so a build that is over still launches and reports everything+ // else it can — the way an over-tolerance parity does.for (const verdict of readSizeVerdicts(sizeReport)) {const ok = verdict.status !== 'over';results.push({