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
perf(sdk): a blank mini-game package no longer carries timelines
yhhea25a635a381
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 75df8ac83..33fd12b70 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -39,7 +39,7 @@ published separately; it ships inside the editor.### Changed-- **A blank mini-game package no longer carries terrain and water.** The mini-game build was shipping 47KB of terrain and 37KB of water code (and its component definitions) in a project that uses neither: the SDK's shared chunks hold every entry's code together, and a bundler cannot drop a top-level `defineComponent(...)` or `new SomePlugin()` it cannot tell is pure. The chunks now keep their `/* @__PURE__ */` annotations (the minifier that removed them is set to mangle names only; consumers minify again), and terrain and water mark what only defines something. A blank WeChat package was 3,345,193 bytes and is now 3,248,459 (97KB less, 79.8% of the 4MB main-package cap down to 77.4%); a project that uses terrain or water installs them as before. A gate (`lean-bundle`) fails if a blank package carries them again.+- **A blank mini-game package no longer carries terrain, water and timelines.** The mini-game build was shipping 47KB of terrain and 37KB of water code (and its component definitions) in a project that uses neither: the SDK's shared chunks hold every entry's code together, and a bundler cannot drop a top-level `defineComponent(...)` or `new SomePlugin()` it cannot tell is pure. The chunks now keep their `/* @__PURE__ */` annotations (the minifier that removed them is set to mangle names only; consumers minify again), and terrain, water and timelines mark what only defines something. A blank WeChat package was 3,345,193 bytes and is now 3,234,518 (111KB less, 79.8% of the 4MB main-package cap down to 77.1%); a project that uses terrain, water or a timeline installs them as before. A gate (`lean-bundle`) fails if a blank package carries them again.- **A multisampled frame is not written out on a tile-based GPU.** The samples of a multisampled target, once resolved and with nothing left to draw on it, the depth of a shadow pass (the map keeps its depth in colour), and the default framebuffer's depth and stencil at the end of a frame are now said not to be needed, which a phone's GPU takes as not writing them to memory. The picture is the same on both backends; it changes nothing measurable on a desktop GPU and is most of a multisampled frame's memory traffic on a phone, which is where it was not measured.- **A sun's shadow map leaves out the casters that shade nothing the camera sees.** A directional light with a fixed reach (`shadowExtent`) draws one map of its whole reach, so every caster in it was drawn however much of it the camera looked at. A caster's shadow is the segment its bounds sweep along the light's rays down to the lowest thing that can receive it; one whose segment stays outside the camera's view is no longer drawn into the map. The picture is the same (a mean difference under half a level on the Terrain & Water example); its shadow pass is 4.0 to 1.7 ms and 4.7 to 1.4 ms at two of its viewpoints on an RTX 3060, and unchanged where the camera sees the whole island. A cascaded sun (no `shadowExtent`) already fits its maps to the view and is as it was; a frame with a planar reflection keeps every caster.- **The sea takes the sun's shadow as one hard edge.** The water lit itself with the sun's full soft shadow (a search for blockers and a filter of up to sixty-four taps), which a surface the sun seldom leaves and whose edge the waves hide does not need; a shader can now set `g_shadowHard` before it lights to read the shadow as the edge a source with no size throws, nine taps, and the water does. The picture is the same to the eye (a mean difference of a quarter of a level on the Terrain & Water example); the water is about 0.5 ms shorter on an RTX 3060.diff --git a/sdk/src/timeline/TimelineControl.ts b/sdk/src/timeline/TimelineControl.tsindex 2a04e5809..3ebae35ac 100644--- a/sdk/src/timeline/TimelineControl.ts+++ b/sdk/src/timeline/TimelineControl.ts@@ -131,4 +131,4 @@ export class TimelineAPI {* Per-App timeline control resource, published by `TimelinePlugin`. Drive* playback as `app.getResource(Timeline).play(entity)`.*/-export const Timeline = defineResource<TimelineAPI>(null!, 'Timeline');+export const Timeline = /* @__PURE__ */ defineResource<TimelineAPI>(null!, 'Timeline');diff --git a/sdk/src/timeline/TimelinePlayerComponent.ts b/sdk/src/timeline/TimelinePlayerComponent.tsindex e8d531166..885f7a658 100644--- a/sdk/src/timeline/TimelinePlayerComponent.ts+++ b/sdk/src/timeline/TimelinePlayerComponent.ts@@ -36,7 +36,7 @@ export function resolveWrapMode(playerWrapMode: string, assetWrapMode: WrapMode)return isWrapModeName(playerWrapMode) ? wrapModeFromName(playerWrapMode) : assetWrapMode;}-export const TimelinePlayer = defineComponent<TimelinePlayerData>('TimelinePlayer', {+export const TimelinePlayer = /* @__PURE__ */ defineComponent<TimelinePlayerData>('TimelinePlayer', {timeline: '',playing: false,speed: 1.0,diff --git a/sdk/src/timeline/TimelinePlugin.ts b/sdk/src/timeline/TimelinePlugin.tsindex c91048c43..6e4a85d92 100644--- a/sdk/src/timeline/TimelinePlugin.ts+++ b/sdk/src/timeline/TimelinePlugin.ts@@ -195,4 +195,4 @@ export class TimelinePlugin implements Plugin {}}-export const timelinePlugin = new TimelinePlugin();+export const timelinePlugin = /* @__PURE__ */ new TimelinePlugin();diff --git a/tools/check-lean-bundle.mjs b/tools/check-lean-bundle.mjsindex c07e4d4b0..c916345f1 100644--- a/tools/check-lean-bundle.mjs+++ b/tools/check-lean-bundle.mjs@@ -23,8 +23,8 @@ import { fileURLToPath } from 'node:url';const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');const require = createRequire(import.meta.url);-/** The most each directory may leave in a blank package, in bytes of the minified bundle. Water keeps what the post-process underwater state needs. */-const CEILING = { terrain: 0, foliage: 0, worldgen: 0, water: 8192 };+/** The most each directory may leave in a blank package, in bytes of the minified bundle. Water keeps what the post-process underwater state needs; timeline, its component definition. */+const CEILING = { terrain: 0, foliage: 0, worldgen: 0, water: 8192, timeline: 1024 };const entry = path.join(ROOT, 'sdk/dist/index.wechat.lean.js');if (!existsSync(entry)) {