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(runtime): a project declares runtime tuning, and a build ships background shader compilation and on-demand drawing with the quality level off
yhhd5ea61f589f4
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex e91a49ce0..8e427fa80 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -14,12 +14,18 @@ published separately; it ships inside the editor.## [Unreleased]+### Added++- **The engine's runtime tuning is a project setting.** Project Settings → Game → Runtime sets how a scene switch fades (duration and colour), how far one frame may advance the game and how many fixed steps it may catch up, how long an asset may take to load and how soon a failed one is tried again, how much memory the texture, audio and device-loss caches keep, the text canvas size and the default font family. They were reachable only from code (`RuntimeConfig`) and no project file could carry them. The project holds `features.runtime` with only what differs from the engine's own values (`RUNTIME_BUILD_DEFAULTS`), a build ships the same block, and `initRuntime` applies it before the first asset loads on the web, desktop, native, mini-game and playable targets and in Play. The edit viewport keeps the engine's values.+- **Rows for the choices that could only be written into the project file.** Under Rendering: compile shaders in the background, warm them up behind the loading screen and how long to wait, draw only changing frames and how many frames to keep after a change, each level's anti-aliasing (MSAA or temporal; the MSAA count is hidden where temporal ignores it) and its depth pre-pass. Under Game → Display: the render resolution (screen, design resolution or integer multiple). Under the web build: the servers the page may connect to, each checked by the parser the export uses. `check-project-settings` now reads the keys of `QualityConfig`, `QualityProfile` and `RuntimeBuildConfig` and fails a key that has no row and no stated reason, which is how these went unnoticed behind the one row the block had.+### Changed- **The profiler's tables sort by their column header.** Click a column of the cost tree or the systems list to order it by name or by time, and again to reverse it; the choice is remembered. Ranking by time moved a name whenever two systems passed each other, which is every few frames on a live window, so a reader could not follow one; by name the rows stay where they are. The systems list names twelve systems instead of five, so the members change less often too.### Fixed+- **Background shader compilation, the warm-up and on-demand drawing reach a build whose quality level is Off.** A build dropped the whole `quality` block when the level was Off, though these three choices hold whatever the level: a project that switched `asyncShaderCompile`, `prewarmShaders` or `renderOnDemand` on read them in the editor and shipped a game that ignored them. The block now ships when any of them is on.- **A terrain and a streamed world run on the Android and iOS templates.** The terrain's layer textures were refused on a device (it has no wasm heap to copy them through), and a chunked world's maker threw on every tick because QuickJS has no `AbortController`. The layers now go over as bytes, as every other texture does, and the world uses a handle of its own where the host has none.## [0.96.0] - 2026-10-27diff --git a/desktop b/desktopindex 06051146b..2f3864a33 160000--- a/desktop+++ b/desktop@@ -1 +1 @@-Subproject commit 06051146b513a8b50b8dbf3999e101e207c8e90f+Subproject commit 2f3864a33aa17affb40430c74f5e84f93705a935diff --git a/docs/TERRAIN_WATER_GPU_COST.md b/docs/TERRAIN_WATER_GPU_COST.mdindex 087db52a4..7e1345d5f 100644--- a/docs/TERRAIN_WATER_GPU_COST.md+++ b/docs/TERRAIN_WATER_GPU_COST.md@@ -491,7 +491,7 @@- **并行是真的。**把同一个 3.2 秒的程序复制 6 份:一份份等是 19.2 s,全部发出去再等是 5.1 s,发出去只要 1 ms,轮询 `COMPLETION_STATUS_KHR` 期间页面一直在响应(1100 次定时器)。机器 20 个核。- **只做"延迟链接"不够。**材质变体是一帧一个、创建完马上要画的,没有重叠(43.5 s 对 49.8 s);要**让帧别等**:没好的程序,画它的绘制先跳过(`GfxDevice::setSkipPendingPrograms`)。材质着色器、后处理着色器、默认网格着色器、网格变体都是排队创建,第一个要用的才等(`GfxShaderSource::deferLink`、`Shader::whenLinked`)。- **试过没用的:**把阴影采样改成 `textureLod`(想让 ANGLE 不展开循环)——编译反而慢了一个数量级(单个程序 37 到 82 s),已还原。哪些代码贡献最多(剪掉实验):阴影接收约 60%(10.9 s → 4.4 s),地形 8 层混合循环约 55%(10.9 → 5.0 s);灯循环只占一成多。减小这些着色器本身还能再省,没做。-- 选项默认关,和动态分辨率一样是显式开启:开了以后第一次看到的画面会有东西"长出来"。+- 选项默认关,和动态分辨率一样是显式开启:开了以后第一次看到的画面会有东西"长出来"。编辑器里在项目设置 → 渲染 → "着色器编译"(后台编译、启动页预热、预热超时);画质档位为"关闭"时同样生效——打包时只要其中任何一项开着,`quality` 块就会随游戏发出。- **预热:**`quality.prewarmShaders`(配 `asyncShaderCompile`)在启动页后面把第一个场景画到没有着色器在编译为止再打开(`warmShaders(app)`,上限 `prewarmTimeoutMs`,默认 30 s),打开时是完整画面。预备好的场景(`readyRenderPrograms`)也等编译队列清空才报告就绪。- **编译成本再削:**平铺光源没有阴影图,`shadeLight` 加了 `shadow3D` 参数,平铺那处调用传 `false`,编译器把那份拷贝里的阴影滤波整段丢掉:受光着色器首次链接合计 −23%(模型着色器约 −40%),运行时无变化。把循环合并成动态循环能再省 40% 编译,但模型段多 ~1 ms,没要。- **三种方式在示例包上的实测**(Chrome、D3D11,关掉着色器磁盘缓存,首次访问,1280x720,像玩家一样直接打开,`output/prewarm-probe.mjs` 的做法):同步:19.8 s 才出画面,之后 25 s 里最长一帧 9.1 s,16 帧超 50 ms;`asyncShaderCompile`:2.4 s 出画面,画面逐步长全,40 帧超 50 ms、最长 513 ms;`asyncShaderCompile` + `prewarmShaders`:启动页停到 20.0 s(同步的等待时间,但页面一直在响应、启动页进度在走),打开即完整画面,之后 25 s 里 0 帧超 50 ms,最长 22.9 ms。diff --git a/docs/astro/src/data/apiStability.generated.json b/docs/astro/src/data/apiStability.generated.jsonindex f264a9098..f7782f2e8 100644--- a/docs/astro/src/data/apiStability.generated.json+++ b/docs/astro/src/data/apiStability.generated.json@@ -3,10 +3,10 @@"counts": {"public": 115,"beta": 171,- "experimental": 2642,+ "experimental": 2650,"deprecated": 3},- "total": 2928,+ "total": 2936,"subsystems": [{"id": "mobile-controls",diff --git a/pipeline/src/project/format.ts b/pipeline/src/project/format.tsindex 7513cc694..3bae1a080 100644--- a/pipeline/src/project/format.ts+++ b/pipeline/src/project/format.ts@@ -19,8 +19,8 @@*/import {- parseAudioProjectConfig, parseQualityConfig, THEME_COLOR_ROLES,- type AudioProjectConfig, type QualityConfig,+ parseAudioProjectConfig, parseQualityConfig, parseRuntimeBuildConfig, THEME_COLOR_ROLES,+ type AudioProjectConfig, type QualityConfig, type RuntimeBuildConfig,} from 'esengine';import { normalizePlatform, type ExportPlatform } from './platforms';import { cspConnectSources } from '../export/cspConnect';@@ -200,6 +200,11 @@ export interface ProjectFeatures {};/** Project mixer state (bus volumes / custom buses / effects / duck rules). */audio?: AudioProjectConfig;+ /**+ * Runtime tuning: the scene transition, how far one frame may advance the simulation, how long an asset may take, and the budgets of the+ * texture, audio and device-loss caches. Holds only what differs from the engine's own values (see `RUNTIME_BUILD_DEFAULTS`); absence is the default.+ */+ runtime?: RuntimeBuildConfig;ui?: {/** Built-in widget theme. Only 'light' persists; dark (the default) is* expressed by absence — like rendering.colorSpace. */@@ -868,6 +873,10 @@ export function parseManifest(raw: unknown): ProjectManifest {// project that asked for one and shipped the default instead, silently.if (audio.buses || audio.maxVoices !== undefined) features.audio = audio;}+ if (f.runtime && typeof f.runtime === 'object') {+ const runtime = parseRuntimeBuildConfig(f.runtime);+ if (Object.keys(runtime).length > 0) features.runtime = runtime;+ }if (f.ui && typeof f.ui === 'object') {const u = f.ui as Record<string, unknown>;const ui: NonNullable<ProjectFeatures['ui']> = {};diff --git a/pipeline/src/project/runtimeConfig.ts b/pipeline/src/project/runtimeConfig.tsindex 1fec2efe5..966aecb22 100644--- a/pipeline/src/project/runtimeConfig.ts+++ b/pipeline/src/project/runtimeConfig.ts@@ -26,9 +26,9 @@* fails the build when a field in this shape is not carried by every consumer —* or is not listed there as a declared, reasoned gap.*/-import { parseQualityConfig } from 'esengine';+import { parseQualityConfig, parseRuntimeBuildConfig } from 'esengine';import type {- AudioProjectConfig, PackagedGameConfig, Physics2DPluginConfig, QualityConfig,+ AudioProjectConfig, PackagedGameConfig, Physics2DPluginConfig, QualityConfig, RuntimeBuildConfig,} from 'esengine';import { resolveScreenFit, SORTING_LAYER_COUNT, type ProjectFeatures, type ProjectManifest, type ProjectPackaging } from './format';@@ -62,6 +62,8 @@ export interface RuntimeProjectConfig {physicsConfig: Physics2DPluginConfig;/** Mixer state: bus volumes, custom buses, effects, duck rules. */audioConfig: AudioProjectConfig;+ /** Runtime tuning the project declared — only what differs from the engine's own values, so `{}` is the default. */+ runtime: RuntimeBuildConfig;/** Built-in widget theme; 'dark' is the default. */uiTheme: 'dark' | 'light';/** Theme colour overrides (role → #rrggbbaa), possibly empty. */@@ -153,6 +155,7 @@ export function runtimeConfigOf(physicsEnabled: f?.physics?.enabled ?? false,physicsConfig: physicsConfigOf(f),audioConfig: f?.audio ?? {},+ runtime: parseRuntimeBuildConfig(f?.runtime),uiTheme: f?.ui?.theme === 'light' ? 'light' : 'dark',uiThemeColors: f?.ui?.colors ?? {},ySortLayers: layerMask(f?.rendering?.ySortLayers),@@ -184,7 +187,7 @@ export type PackagedRuntimeFields = Pick<'ySortLayers' | 'depthLayers' | 'colorSpace' | 'outputTransform' | 'renderBackend' | 'screenFit'| 'msaaSamples' | 'quality'| 'uiTheme' | 'uiThemeColors'- | 'physicsEnabled' | 'physicsConfig' | 'audioConfig' | 'achievements' | 'steamAppId'+ | 'physicsEnabled' | 'physicsConfig' | 'audioConfig' | 'achievements' | 'steamAppId' | 'runtime'>;/**@@ -203,7 +206,9 @@ export function packagedRuntimeFields(rc: RuntimeProjectConfig): PackagedRuntime...(rc.colorSpace === 'linear' ? { colorSpace: rc.colorSpace } : {}),...(rc.outputTransform !== 'none' ? { outputTransform: rc.outputTransform } : {}),...(rc.msaaSamples !== 4 ? { msaaSamples: rc.msaaSamples } : {}),- ...(rc.quality.mode !== 'off' ? { quality: rc.quality } : {}),+ // The block also carries three delivery choices that have nothing to do with a quality level (compile shaders in the background, warm them up+ // behind the splash, draw only changing frames); with the level off they must still ship, or the switch is read from a project and never reaches a game.+ ...(qualityShips(rc.quality) ? { quality: rc.quality } : {}),...(rc.renderBackend === 'webgpu' ? { renderBackend: rc.renderBackend } : {}),// ALWAYS, even with the fit off (`scaleMode < 0`): it carries the design// resolution, which is what a desktop window opens at. One representation, or@@ -220,11 +225,18 @@ export function packagedRuntimeFields(rc: RuntimeProjectConfig): PackagedRuntime...(rc.audioConfig.buses?.length || rc.audioConfig.maxVoices !== undefined|| Object.keys(rc.audioConfig.loadTypes ?? {}).length > 0? { audioConfig: rc.audioConfig } : {}),+ ...(Object.keys(rc.runtime).length > 0 ? { runtime: rc.runtime } : {}),...(rc.achievements.length ? { achievements: rc.achievements } : {}),...(rc.steamAppId > 0 ? { steamAppId: rc.steamAppId } : {}),};}+/** Whether a build has anything to be told about quality: a level, or one of the delivery choices that hold whatever the level. */+export function qualityShips(quality: QualityConfig): boolean {+ return quality.mode !== 'off' || quality.asyncShaderCompile === true+ || quality.prewarmShaders === true || quality.renderOnDemand === true;+}+/** Whether the world config is exactly what a runtime would default to anyway. */function isDefaultPhysics(config: Physics2DPluginConfig): boolean {return JSON.stringify(config) === JSON.stringify(DEFAULT_PHYSICS_CONFIG);diff --git a/pipeline/tests/runtime-config.test.ts b/pipeline/tests/runtime-config.test.tsindex eb197a372..0f14eaf58 100644--- a/pipeline/tests/runtime-config.test.ts+++ b/pipeline/tests/runtime-config.test.ts@@ -189,3 +189,38 @@ describe('how an audio clip loads', () => {});});+describe('the quality block that ships with the level off', () => {+ it('carries a delivery choice, because it holds whatever the level', () => {+ for (const choice of [{ asyncShaderCompile: true }, { prewarmShaders: true }, { renderOnDemand: true }]) {+ const rc = runtimeConfigOf({ features: { rendering: { quality: { mode: 'off', ...choice } } } });+ expect(packagedRuntimeFields(rc).quality).toEqual(rc.quality);+ expect(packagedRuntimeFields(rc).quality?.mode).toBe('off');+ }+ });+ it('still leaves the block out when nothing in it is on', () => {+ const rc = runtimeConfigOf({ features: { rendering: { quality: { mode: 'off', targetFps: 30 } } } });+ expect(packagedRuntimeFields(rc)).not.toHaveProperty('quality');+ });+});++describe('the runtime tuning', () => {+ it('is empty for a project that declares nothing, and ships nothing', () => {+ const rc = runtimeConfigOf({});+ expect(rc.runtime).toEqual({});+ expect(packagedRuntimeFields(rc)).not.toHaveProperty('runtime');+ });+ it('ships only what differs from the engine, held to its range', () => {+ const rc = runtimeConfigOf({ features: { runtime: {+ maxDeltaTime: 0.25, // the engine's own value: absence is how a default is written+ assetLoadTimeout: 60000, textureCacheBudget: 128 * 1024 * 1024, maxFixedSteps: 1000, sceneTransitionColor: '#FF0000',+ } } });+ expect(rc.runtime).toEqual({+ assetLoadTimeout: 60000, textureCacheBudget: 128 * 1024 * 1024, maxFixedSteps: 64, sceneTransitionColor: '#ff0000',+ });+ expect(packagedRuntimeFields(rc).runtime).toEqual(rc.runtime);+ });+ it('drops a field of the wrong type instead of inventing a value', () => {+ const rc = runtimeConfigOf({ features: { runtime: { maxDeltaTime: '1', defaultFontFamily: 5, sceneTransitionColor: 'red' } as never } });+ expect(rc.runtime).toEqual({});+ });+});diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.mdindex 6254402eb..7fd7515c3 100644--- a/sdk/etc/index.api.md+++ b/sdk/etc/index.api.md@@ -1,7 +1,7 @@# API surface — esengine/index<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 115 public · 159 beta · 1898 experimental · 3 deprecated+Symbols: 115 public · 159 beta · 1906 experimental · 3 deprecated## ABI_LAYOUT_HASH — const @experimental```@@ -3156,6 +3156,13 @@ pixels: Uint8Array<ArrayBufferLike>width: number```+## DeferredRecord — interface @experimental+```+id: number+overrides: PrefabOverride[]+prefab: string+```+## Device — const @experimental```{ capabilities: () => DeviceCapabilities; state: () => DeviceState; motion: { start: (options?: MotionOptions) => Promise<DeviceResult>; stop: () => Promise<DeviceResult>; onChange: (handler: (sample: MotionSample) => void) => () => void; }; vibrate: (options?: VibrationOptions) => Promise<DeviceResult>; keepScreenOn: (enabled: boolean) => Promise<DeviceResult>; fullscreen: (enabled: boolean, target?: unknown) => Promise<DeviceResult>; pointerLock: (enabled: boolean, target?: unknown) => Promise<DeviceResult>; onChange: (handler: (state: DeviceState) => void) => () => void; dispose: () => void; }@@ -4163,6 +4170,7 @@ enabled: boolean## FlattenContext — interface @experimental```allocateId: () => number+deferred: DeferredRecord[] | undefineddepth: number | undefinedloadPrefab: (path: string) => PrefabData | nullvisited: Set<string> | undefined@@ -4988,6 +4996,7 @@ static prototype: InputState```assetBaseUrl: string | undefinedassets: Assets | undefined+expandDeferred: boolean | undefinedoverrides: PrefabOverride[] | undefinedparent: number | undefined```@@ -6147,6 +6156,7 @@ physicsConfig: Physics2DPluginConfig | undefinedphysicsEnabled: boolean | undefinedquality: QualityConfig | undefinedrenderBackend: "webgl2" | "webgpu" | undefined+runtime: RuntimeBuildConfig | undefinedscenes: { name: string; path: string; }[] | undefinedscreenFit: { designWidth: number; designHeight: number; scaleMode: number; matchWidthOrHeight: number; } | undefinedscripts: string | undefined@@ -6177,6 +6187,24 @@ slot: numberused: number```+## PageDef — interface @experimental+```+mount: number | (() => Entity) | undefined+onClose: "keep" | "destroy" | undefined+overrides: PrefabOverride[] | undefined+parent: number | (() => Entity) | undefined+prefab: string+```++## PageHandle — interface @experimental+```+find: (name: string) => Entity | undefined+has: (name: string) => boolean+id: string+names: () => IterableIterator<string>+root: number+```+## PageImage — interface @experimental```heights: Uint8Array<ArrayBufferLike>@@ -7142,6 +7170,7 @@ persistUpdateKey: string | undefinedphysicsConfig: Physics2DPluginConfig | undefinedphysicsEnabled: boolean | undefinedremoteRoot: string | undefined+runtime: RuntimeBuildConfig | undefinedsceneData: SceneDatauiTheme: "light" | "dark" | undefineduiThemeOverrides: ThemeOverrides | undefined@@ -7170,6 +7199,7 @@ manifest: AddressableManifest | null | undefinedmodule: ESEngineModulephysicsConfig: Physics2DPluginConfig | undefinedphysicsEnabled: boolean | undefined+runtime: RuntimeBuildConfig | undefinedscenes: { name: string; data: SceneData; }[]uiTheme: "light" | "dark" | undefineduiThemeOverrides: ThemeOverrides | undefined@@ -7849,6 +7879,11 @@ ReadonlyMap<string, string>ReadonlySet<string>```+## RUNTIME_BUILD_DEFAULTS — const @experimental+```+Readonly<Required<RuntimeBuildConfig>>+```+## ReadableWorld — type @experimental```Pick<World, 'valid' | 'has' | 'get'>@@ -8335,6 +8370,7 @@ physicsConfig: Physics2DPluginConfig | undefinedphysicsEnabled: boolean | undefinedphysicsModule: PhysicsWasmModule | null | undefinedremoteRoot: string | undefined+runtime: RuntimeBuildConfig | undefinedscenes: { name: string; data?: SceneData; path?: string; }[]screenFit: { designWidth: number; designHeight: number; scaleMode: number; matchWidthOrHeight: number; } | undefinedsource: RuntimeAssetSource@@ -8578,6 +8614,7 @@ unbindPostProcess: (camera: Entity) => void## SceneData — interface @experimental```+deferredInstances: DeferredRecord[] | undefinedentities: SceneEntityData[]generator: string | undefinedname: string@@ -11530,6 +11567,23 @@ position: number | undefinedwidth: Dimension | undefined```+## UIPages — class @experimental+```+close: (id: string) => void+has: (id: string) => boolean+isBuilt: (id: string) => boolean+isOpen: (id: string) => boolean+onBuilt: (listener: (page: PageHandle) => void) => () => void+open: (id: string) => Promise<PageHandle>+page: (id: string) => PageHandle | null+preload: (id: string) => Promise<void>+register: (id: string, def: PageDef) => void+registerDeferred: (entity: Entity, onClose?: PageDef["onClose"]) => string | null+registerDeferredAll: (root?: Entity, onClose?: PageDef["onClose"]) => string[]+static new (world_: World, assets_: Assets): UIPages+static prototype: UIPages+```+## UIPlugin — class @experimental```attachScrollContainer: (entity: Entity, container: ScrollContainer) => void@@ -13676,6 +13730,16 @@ PluralSelector(level: QualityLevel): QualityProfile```+## deferredEntities — function @experimental+```+(world: World): Entity[]+```++## deferredRecord — function @experimental+```+(world: World, entity: Entity): DeferredRecord | undefined+```+## defineBehavior — function @experimental```<S extends object>(name: string, def: BehaviorDef<S>): ComponentDef<S>@@ -14008,12 +14072,12 @@ EventBindingPlugin## expandEntry — function @experimental```-(prefab: PrefabData, entry: PrefabInstanceEntry, allocateId: () => number, loadPrefab?: SyncPrefabResolver): { entities: ProcessedEntity[]; rootId: number; unresolved: PrefabOverride[]; }+(prefab: PrefabData, entry: PrefabInstanceEntry, allocateId: () => number, loadPrefab?: SyncPrefabResolver, deferred?: DeferredRecord[]): { entities: ProcessedEntity[]; rootId: number; unresolved: PrefabOverride[]; }```## expandInstance — function @experimental```-(prefab: PrefabData, delta: PrefabInstanceDelta, allocateId: () => number, loadPrefab?: SyncPrefabResolver): { entities: ProcessedEntity[]; rootId: number; unresolved: PrefabOverride[]; }+(prefab: PrefabData, delta: PrefabInstanceDelta, allocateId: () => number, loadPrefab?: SyncPrefabResolver, deferred?: DeferredRecord[]): { entities: ProcessedEntity[]; rootId: number; unresolved: PrefabOverride[]; }```## extendPlatform — function @experimental@@ -14893,7 +14957,7 @@ MeshRendererPlugin## packagedRuntimeInit — function @experimental```-(config: Pick<PackagedGameConfig, "physicsEnabled" | "physicsConfig" | "audioConfig" | "uiTheme" | "uiThemeColors" | "achievements" | "steamAppId" | "screenFit" | "aot" | "debugChannel">): { physicsEnabled?: boolean; physicsConfig?: Physics2DPluginConfig; audioConfig?: AudioProjectConfig; uiTheme?: "light"; uiThemeOverrides?: ThemeOverrides; achievements?: string[]; steamAppId?: number; screenFit?: PackagedGameConfig["screenFit"]; aot?: PackagedGameConfig["aot"]; debugChannel?: DebugChannelConfig; }+(config: Pick<PackagedGameConfig, "physicsEnabled" | "physicsConfig" | "audioConfig" | "uiTheme" | "uiThemeColors" | "achievements" | "steamAppId" | "screenFit" | "aot" | "debugChannel" | "runtime">): { physicsEnabled?: boolean; physicsConfig?: Physics2DPluginConfig; audioConfig?: AudioProjectConfig; runtime?: RuntimeBuildConfig; uiTheme?: "light"; uiThemeOverrides?: ThemeOverrides; achievements?: string[]; steamAppId?: number; screenFit?: PackagedGameConfig["screenFit"]; aot?: PackagedGameConfig["aot"]; debugChannel?: DebugChannelConfig; }```## paintWeights — function @experimental@@ -14976,6 +15040,11 @@ MeshRendererPlugin(input: string): RichTextRun[]```+## parseRuntimeBuildConfig — function @experimental+```+(value: unknown): RuntimeBuildConfig+```+## parseSoundEvent — function @beta```(value: unknown): SoundEventAssetdiff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.mdindex cbad5951a..f5beb9a57 100644--- a/sdk/etc/index.native.api.md+++ b/sdk/etc/index.native.api.md@@ -1,7 +1,7 @@# API surface — esengine/index.native<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 115 public · 164 beta · 1917 experimental · 3 deprecated+Symbols: 115 public · 164 beta · 1925 experimental · 3 deprecated## ABI_LAYOUT_HASH — const @experimental```@@ -3164,6 +3164,13 @@ pixels: Uint8Array<ArrayBufferLike>width: number```+## DeferredRecord — interface @experimental+```+id: number+overrides: PrefabOverride[]+prefab: string+```+## Device — const @experimental```{ capabilities: () => DeviceCapabilities; state: () => DeviceState; motion: { start: (options?: MotionOptions) => Promise<DeviceResult>; stop: () => Promise<DeviceResult>; onChange: (handler: (sample: MotionSample) => void) => () => void; }; vibrate: (options?: VibrationOptions) => Promise<DeviceResult>; keepScreenOn: (enabled: boolean) => Promise<DeviceResult>; fullscreen: (enabled: boolean, target?: unknown) => Promise<DeviceResult>; pointerLock: (enabled: boolean, target?: unknown) => Promise<DeviceResult>; onChange: (handler: (state: DeviceState) => void) => () => void; dispose: () => void; }@@ -4171,6 +4178,7 @@ enabled: boolean## FlattenContext — interface @experimental```allocateId: () => number+deferred: DeferredRecord[] | undefineddepth: number | undefinedloadPrefab: (path: string) => PrefabData | nullvisited: Set<string> | undefined@@ -4996,6 +5004,7 @@ static prototype: InputState```assetBaseUrl: string | undefinedassets: Assets | undefined+expandDeferred: boolean | undefinedoverrides: PrefabOverride[] | undefinedparent: number | undefined```@@ -6350,6 +6359,7 @@ physicsConfig: Physics2DPluginConfig | undefinedphysicsEnabled: boolean | undefinedquality: QualityConfig | undefinedrenderBackend: "webgl2" | "webgpu" | undefined+runtime: RuntimeBuildConfig | undefinedscenes: { name: string; path: string; }[] | undefinedscreenFit: { designWidth: number; designHeight: number; scaleMode: number; matchWidthOrHeight: number; } | undefinedscripts: string | undefined@@ -6380,6 +6390,24 @@ slot: numberused: number```+## PageDef — interface @experimental+```+mount: number | (() => Entity) | undefined+onClose: "keep" | "destroy" | undefined+overrides: PrefabOverride[] | undefined+parent: number | (() => Entity) | undefined+prefab: string+```++## PageHandle — interface @experimental+```+find: (name: string) => Entity | undefined+has: (name: string) => boolean+id: string+names: () => IterableIterator<string>+root: number+```+## PageImage — interface @experimental```heights: Uint8Array<ArrayBufferLike>@@ -7345,6 +7373,7 @@ persistUpdateKey: string | undefinedphysicsConfig: Physics2DPluginConfig | undefinedphysicsEnabled: boolean | undefinedremoteRoot: string | undefined+runtime: RuntimeBuildConfig | undefinedsceneData: SceneDatauiTheme: "light" | "dark" | undefineduiThemeOverrides: ThemeOverrides | undefined@@ -7373,6 +7402,7 @@ manifest: AddressableManifest | null | undefinedmodule: ESEngineModulephysicsConfig: Physics2DPluginConfig | undefinedphysicsEnabled: boolean | undefined+runtime: RuntimeBuildConfig | undefinedscenes: { name: string; data: SceneData; }[]uiTheme: "light" | "dark" | undefineduiThemeOverrides: ThemeOverrides | undefined@@ -8062,6 +8092,11 @@ ReadonlyMap<string, string>ReadonlySet<string>```+## RUNTIME_BUILD_DEFAULTS — const @experimental+```+Readonly<Required<RuntimeBuildConfig>>+```+## ReadableWorld — type @experimental```Pick<World, 'valid' | 'has' | 'get'>@@ -8548,6 +8583,7 @@ physicsConfig: Physics2DPluginConfig | undefinedphysicsEnabled: boolean | undefinedphysicsModule: PhysicsWasmModule | null | undefinedremoteRoot: string | undefined+runtime: RuntimeBuildConfig | undefinedscenes: { name: string; data?: SceneData; path?: string; }[]screenFit: { designWidth: number; designHeight: number; scaleMode: number; matchWidthOrHeight: number; } | undefinedsource: RuntimeAssetSource@@ -8791,6 +8827,7 @@ unbindPostProcess: (camera: Entity) => void## SceneData — interface @experimental```+deferredInstances: DeferredRecord[] | undefinedentities: SceneEntityData[]generator: string | undefinedname: string@@ -11743,6 +11780,23 @@ position: number | undefinedwidth: Dimension | undefined```+## UIPages — class @experimental+```+close: (id: string) => void+has: (id: string) => boolean+isBuilt: (id: string) => boolean+isOpen: (id: string) => boolean+onBuilt: (listener: (page: PageHandle) => void) => () => void+open: (id: string) => Promise<PageHandle>+page: (id: string) => PageHandle | null+preload: (id: string) => Promise<void>+register: (id: string, def: PageDef) => void+registerDeferred: (entity: Entity, onClose?: PageDef["onClose"]) => string | null+registerDeferredAll: (root?: Entity, onClose?: PageDef["onClose"]) => string[]+static new (world_: World, assets_: Assets): UIPages+static prototype: UIPages+```+## UIPlugin — class @experimental```attachScrollContainer: (entity: Entity, container: ScrollContainer) => void@@ -13929,6 +13983,16 @@ PluralSelector(level: QualityLevel): QualityProfile```+## deferredEntities — function @experimental+```+(world: World): Entity[]+```++## deferredRecord — function @experimental+```+(world: World, entity: Entity): DeferredRecord | undefined+```+## defineBehavior — function @experimental```<S extends object>(name: string, def: BehaviorDef<S>): ComponentDef<S>@@ -14261,12 +14325,12 @@ EventBindingPlugin## expandEntry — function @experimental```-(prefab: PrefabData, entry: PrefabInstanceEntry, allocateId: () => number, loadPrefab?: SyncPrefabResolver): { entities: ProcessedEntity[]; rootId: number; unresolved: PrefabOverride[]; }+(prefab: PrefabData, entry: PrefabInstanceEntry, allocateId: () => number, loadPrefab?: SyncPrefabResolver, deferred?: DeferredRecord[]): { entities: ProcessedEntity[]; rootId: number; unresolved: PrefabOverride[]; }```## expandInstance — function @experimental```-(prefab: PrefabData, delta: PrefabInstanceDelta, allocateId: () => number, loadPrefab?: SyncPrefabResolver): { entities: ProcessedEntity[]; rootId: number; unresolved: PrefabOverride[]; }+(prefab: PrefabData, delta: PrefabInstanceDelta, allocateId: () => number, loadPrefab?: SyncPrefabResolver, deferred?: DeferredRecord[]): { entities: ProcessedEntity[]; rootId: number; unresolved: PrefabOverride[]; }```## extendPlatform — function @experimental@@ -15156,7 +15220,7 @@ MeshRendererPlugin## packagedRuntimeInit — function @experimental```-(config: Pick<PackagedGameConfig, "physicsEnabled" | "physicsConfig" | "audioConfig" | "uiTheme" | "uiThemeColors" | "achievements" | "steamAppId" | "screenFit" | "aot" | "debugChannel">): { physicsEnabled?: boolean; physicsConfig?: Physics2DPluginConfig; audioConfig?: AudioProjectConfig; uiTheme?: "light"; uiThemeOverrides?: ThemeOverrides; achievements?: string[]; steamAppId?: number; screenFit?: PackagedGameConfig["screenFit"]; aot?: PackagedGameConfig["aot"]; debugChannel?: DebugChannelConfig; }+(config: Pick<PackagedGameConfig, "physicsEnabled" | "physicsConfig" | "audioConfig" | "uiTheme" | "uiThemeColors" | "achievements" | "steamAppId" | "screenFit" | "aot" | "debugChannel" | "runtime">): { physicsEnabled?: boolean; physicsConfig?: Physics2DPluginConfig; audioConfig?: AudioProjectConfig; runtime?: RuntimeBuildConfig; uiTheme?: "light"; uiThemeOverrides?: ThemeOverrides; achievements?: string[]; steamAppId?: number; screenFit?: PackagedGameConfig["screenFit"]; aot?: PackagedGameConfig["aot"]; debugChannel?: DebugChannelConfig; }```## paintWeights — function @experimental@@ -15239,6 +15303,11 @@ MeshRendererPlugin(input: string): RichTextRun[]```+## parseRuntimeBuildConfig — function @experimental+```+(value: unknown): RuntimeBuildConfig+```+## parseSoundEvent — function @beta```(value: unknown): SoundEventAssetdiff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.mdindex 187387b8c..255cf9db6 100644--- a/sdk/etc/index.node.api.md+++ b/sdk/etc/index.node.api.md@@ -1,7 +1,7 @@# API surface — esengine/index.node<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 115 public · 161 beta · 1897 experimental · 3 deprecated+Symbols: 115 public · 161 beta · 1905 experimental · 3 deprecated## ANCHOR_AXES — const @experimental```@@ -3151,6 +3151,13 @@ pixels: Uint8Array<ArrayBufferLike>width: number```+## DeferredRecord — interface @experimental+```+id: number+overrides: PrefabOverride[]+prefab: string+```+## Device — const @experimental```{ capabilities: () => DeviceCapabilities; state: () => DeviceState; motion: { start: (options?: MotionOptions) => Promise<DeviceResult>; stop: () => Promise<DeviceResult>; onChange: (handler: (sample: MotionSample) => void) => () => void; }; vibrate: (options?: VibrationOptions) => Promise<DeviceResult>; keepScreenOn: (enabled: boolean) => Promise<DeviceResult>; fullscreen: (enabled: boolean, target?: unknown) => Promise<DeviceResult>; pointerLock: (enabled: boolean, target?: unknown) => Promise<DeviceResult>; onChange: (handler: (state: DeviceState) => void) => () => void; dispose: () => void; }@@ -4158,6 +4165,7 @@ enabled: boolean## FlattenContext — interface @experimental```allocateId: () => number+deferred: DeferredRecord[] | undefineddepth: number | undefinedloadPrefab: (path: string) => PrefabData | nullvisited: Set<string> | undefined@@ -4983,6 +4991,7 @@ static prototype: InputState```assetBaseUrl: string | undefinedassets: Assets | undefined+expandDeferred: boolean | undefinedoverrides: PrefabOverride[] | undefinedparent: number | undefined```@@ -6142,6 +6151,7 @@ physicsConfig: Physics2DPluginConfig | undefinedphysicsEnabled: boolean | undefinedquality: QualityConfig | undefinedrenderBackend: "webgl2" | "webgpu" | undefined+runtime: RuntimeBuildConfig | undefinedscenes: { name: string; path: string; }[] | undefinedscreenFit: { designWidth: number; designHeight: number; scaleMode: number; matchWidthOrHeight: number; } | undefinedscripts: string | undefined@@ -6172,6 +6182,24 @@ slot: numberused: number```+## PageDef — interface @experimental+```+mount: number | (() => Entity) | undefined+onClose: "keep" | "destroy" | undefined+overrides: PrefabOverride[] | undefined+parent: number | (() => Entity) | undefined+prefab: string+```++## PageHandle — interface @experimental+```+find: (name: string) => Entity | undefined+has: (name: string) => boolean+id: string+names: () => IterableIterator<string>+root: number+```+## PageImage — interface @experimental```heights: Uint8Array<ArrayBufferLike>@@ -7137,6 +7165,7 @@ persistUpdateKey: string | undefinedphysicsConfig: Physics2DPluginConfig | undefinedphysicsEnabled: boolean | undefinedremoteRoot: string | undefined+runtime: RuntimeBuildConfig | undefinedsceneData: SceneDatauiTheme: "light" | "dark" | undefineduiThemeOverrides: ThemeOverrides | undefined@@ -7165,6 +7194,7 @@ manifest: AddressableManifest | null | undefinedmodule: ESEngineModulephysicsConfig: Physics2DPluginConfig | undefinedphysicsEnabled: boolean | undefined+runtime: RuntimeBuildConfig | undefinedscenes: { name: string; data: SceneData; }[]uiTheme: "light" | "dark" | undefineduiThemeOverrides: ThemeOverrides | undefined@@ -7844,6 +7874,11 @@ ReadonlyMap<string, string>ReadonlySet<string>```+## RUNTIME_BUILD_DEFAULTS — const @experimental+```+Readonly<Required<RuntimeBuildConfig>>+```+## ReadableWorld — type @experimental```Pick<World, 'valid' | 'has' | 'get'>@@ -8330,6 +8365,7 @@ physicsConfig: Physics2DPluginConfig | undefinedphysicsEnabled: boolean | undefinedphysicsModule: PhysicsWasmModule | null | undefinedremoteRoot: string | undefined+runtime: RuntimeBuildConfig | undefinedscenes: { name: string; data?: SceneData; path?: string; }[]screenFit: { designWidth: number; designHeight: number; scaleMode: number; matchWidthOrHeight: number; } | undefinedsource: RuntimeAssetSource@@ -8573,6 +8609,7 @@ unbindPostProcess: (camera: Entity) => void## SceneData — interface @experimental```+deferredInstances: DeferredRecord[] | undefinedentities: SceneEntityData[]generator: string | undefinedname: string@@ -11525,6 +11562,23 @@ position: number | undefinedwidth: Dimension | undefined```+## UIPages — class @experimental+```+close: (id: string) => void+has: (id: string) => boolean+isBuilt: (id: string) => boolean+isOpen: (id: string) => boolean+onBuilt: (listener: (page: PageHandle) => void) => () => void+open: (id: string) => Promise<PageHandle>+page: (id: string) => PageHandle | null+preload: (id: string) => Promise<void>+register: (id: string, def: PageDef) => void+registerDeferred: (entity: Entity, onClose?: PageDef["onClose"]) => string | null+registerDeferredAll: (root?: Entity, onClose?: PageDef["onClose"]) => string[]+static new (world_: World, assets_: Assets): UIPages+static prototype: UIPages+```+## UIPlugin — class @experimental```attachScrollContainer: (entity: Entity, container: ScrollContainer) => void@@ -13671,6 +13725,16 @@ PluralSelector(level: QualityLevel): QualityProfile```+## deferredEntities — function @experimental+```+(world: World): Entity[]+```++## deferredRecord — function @experimental+```+(world: World, entity: Entity): DeferredRecord | undefined+```+## defineBehavior — function @experimental```<S extends object>(name: string, def: BehaviorDef<S>): ComponentDef<S>@@ -14003,12 +14067,12 @@ EventBindingPlugin## expandEntry — function @experimental```-(prefab: PrefabData, entry: PrefabInstanceEntry, allocateId: () => number, loadPrefab?: SyncPrefabResolver): { entities: ProcessedEntity[]; rootId: number; unresolved: PrefabOverride[]; }+(prefab: PrefabData, entry: PrefabInstanceEntry, allocateId: () => number, loadPrefab?: SyncPrefabResolver, deferred?: DeferredRecord[]): { entities: ProcessedEntity[]; rootId: number; unresolved: PrefabOverride[]; }```## expandInstance — function @experimental```-(prefab: PrefabData, delta: PrefabInstanceDelta, allocateId: () => number, loadPrefab?: SyncPrefabResolver): { entities: ProcessedEntity[]; rootId: number; unresolved: PrefabOverride[]; }+(prefab: PrefabData, delta: PrefabInstanceDelta, allocateId: () => number, loadPrefab?: SyncPrefabResolver, deferred?: DeferredRecord[]): { entities: ProcessedEntity[]; rootId: number; unresolved: PrefabOverride[]; }```## extendPlatform — function @experimental@@ -14898,7 +14962,7 @@ NodePlatformAdapter## packagedRuntimeInit — function @experimental```-(config: Pick<PackagedGameConfig, "physicsEnabled" | "physicsConfig" | "audioConfig" | "uiTheme" | "uiThemeColors" | "achievements" | "steamAppId" | "screenFit" | "aot" | "debugChannel">): { physicsEnabled?: boolean; physicsConfig?: Physics2DPluginConfig; audioConfig?: AudioProjectConfig; uiTheme?: "light"; uiThemeOverrides?: ThemeOverrides; achievements?: string[]; steamAppId?: number; screenFit?: PackagedGameConfig["screenFit"]; aot?: PackagedGameConfig["aot"]; debugChannel?: DebugChannelConfig; }+(config: Pick<PackagedGameConfig, "physicsEnabled" | "physicsConfig" | "audioConfig" | "uiTheme" | "uiThemeColors" | "achievements" | "steamAppId" | "screenFit" | "aot" | "debugChannel" | "runtime">): { physicsEnabled?: boolean; physicsConfig?: Physics2DPluginConfig; audioConfig?: AudioProjectConfig; runtime?: RuntimeBuildConfig; uiTheme?: "light"; uiThemeOverrides?: ThemeOverrides; achievements?: string[]; steamAppId?: number; screenFit?: PackagedGameConfig["screenFit"]; aot?: PackagedGameConfig["aot"]; debugChannel?: DebugChannelConfig; }```## paintWeights — function @experimental@@ -14981,6 +15045,11 @@ NodePlatformAdapter(input: string): RichTextRun[]```+## parseRuntimeBuildConfig — function @experimental+```+(value: unknown): RuntimeBuildConfig+```+## parseSoundEvent — function @beta```(value: unknown): SoundEventAssetdiff --git a/sdk/etc/logic.api.md b/sdk/etc/logic.api.mdindex ad018c750..41fc2e5e3 100644--- a/sdk/etc/logic.api.md+++ b/sdk/etc/logic.api.md@@ -143,7 +143,7 @@ static prototype: ScriptGraphs## ScriptNodeShape — interface @experimental```-entry: "event" | "start" | "update" | "destroy" | undefined+entry: "destroy" | "event" | "start" | "update" | undefinedexecIn: booleanexecOut: readonly string[]inputs: readonly ScriptPort[]diff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.mdindex 7302b1944..5b9914ae3 100644--- a/sdk/etc/minigame.api.md+++ b/sdk/etc/minigame.api.md@@ -1,7 +1,7 @@# API surface — esengine/minigame<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 115 public · 159 beta · 1919 experimental · 3 deprecated+Symbols: 115 public · 159 beta · 1927 experimental · 3 deprecated## ANCHOR_AXES — const @experimental```@@ -3151,6 +3151,13 @@ pixels: Uint8Array<ArrayBufferLike>width: number```+## DeferredRecord — interface @experimental+```+id: number+overrides: PrefabOverride[]+prefab: string+```+## Device — const @experimental```{ capabilities: () => DeviceCapabilities; state: () => DeviceState; motion: { start: (options?: MotionOptions) => Promise<DeviceResult>; stop: () => Promise<DeviceResult>; onChange: (handler: (sample: MotionSample) => void) => () => void; }; vibrate: (options?: VibrationOptions) => Promise<DeviceResult>; keepScreenOn: (enabled: boolean) => Promise<DeviceResult>; fullscreen: (enabled: boolean, target?: unknown) => Promise<DeviceResult>; pointerLock: (enabled: boolean, target?: unknown) => Promise<DeviceResult>; onChange: (handler: (state: DeviceState) => void) => () => void; dispose: () => void; }@@ -4158,6 +4165,7 @@ enabled: boolean## FlattenContext — interface @experimental```allocateId: () => number+deferred: DeferredRecord[] | undefineddepth: number | undefinedloadPrefab: (path: string) => PrefabData | nullvisited: Set<string> | undefined@@ -4983,6 +4991,7 @@ static prototype: InputState```assetBaseUrl: string | undefinedassets: Assets | undefined+expandDeferred: boolean | undefinedoverrides: PrefabOverride[] | undefinedparent: number | undefined```@@ -6034,6 +6043,7 @@ firstScene: stringhotUpdate: { remoteRoot?: string; persistUpdateKey?: string; } | undefinedphysicsConfig: Physics2DPluginConfig | undefinedphysicsEnabled: boolean | undefined+runtime: RuntimeBuildConfig | undefinedruntimeConfig: RuntimeBuildConfig | undefinedsceneNames: string[]screenFit: { designWidth: number; designHeight: number; scaleMode: number; matchWidthOrHeight: number; } | undefined@@ -6435,6 +6445,7 @@ physicsConfig: Physics2DPluginConfig | undefinedphysicsEnabled: boolean | undefinedquality: QualityConfig | undefinedrenderBackend: "webgl2" | "webgpu" | undefined+runtime: RuntimeBuildConfig | undefinedscenes: { name: string; path: string; }[] | undefinedscreenFit: { designWidth: number; designHeight: number; scaleMode: number; matchWidthOrHeight: number; } | undefinedscripts: string | undefined@@ -6465,6 +6476,24 @@ slot: numberused: number```+## PageDef — interface @experimental+```+mount: number | (() => Entity) | undefined+onClose: "keep" | "destroy" | undefined+overrides: PrefabOverride[] | undefined+parent: number | (() => Entity) | undefined+prefab: string+```++## PageHandle — interface @experimental+```+find: (name: string) => Entity | undefined+has: (name: string) => boolean+id: string+names: () => IterableIterator<string>+root: number+```+## PageImage — interface @experimental```heights: Uint8Array<ArrayBufferLike>@@ -7430,6 +7459,7 @@ persistUpdateKey: string | undefinedphysicsConfig: Physics2DPluginConfig | undefinedphysicsEnabled: boolean | undefinedremoteRoot: string | undefined+runtime: RuntimeBuildConfig | undefinedsceneData: SceneDatauiTheme: "light" | "dark" | undefineduiThemeOverrides: ThemeOverrides | undefined@@ -7458,6 +7488,7 @@ manifest: AddressableManifest | null | undefinedmodule: ESEngineModulephysicsConfig: Physics2DPluginConfig | undefinedphysicsEnabled: boolean | undefined+runtime: RuntimeBuildConfig | undefinedscenes: { name: string; data: SceneData; }[]uiTheme: "light" | "dark" | undefineduiThemeOverrides: ThemeOverrides | undefined@@ -8137,6 +8168,11 @@ ReadonlyMap<string, string>ReadonlySet<string>```+## RUNTIME_BUILD_DEFAULTS — const @experimental+```+Readonly<Required<RuntimeBuildConfig>>+```+## ReadableWorld — type @experimental```Pick<World, 'valid' | 'has' | 'get'>@@ -8623,6 +8659,7 @@ physicsConfig: Physics2DPluginConfig | undefinedphysicsEnabled: boolean | undefinedphysicsModule: PhysicsWasmModule | null | undefinedremoteRoot: string | undefined+runtime: RuntimeBuildConfig | undefinedscenes: { name: string; data?: SceneData; path?: string; }[]screenFit: { designWidth: number; designHeight: number; scaleMode: number; matchWidthOrHeight: number; } | undefinedsource: RuntimeAssetSource@@ -8866,6 +8903,7 @@ unbindPostProcess: (camera: Entity) => void## SceneData — interface @experimental```+deferredInstances: DeferredRecord[] | undefinedentities: SceneEntityData[]generator: string | undefinedname: string@@ -11818,6 +11856,23 @@ position: number | undefinedwidth: Dimension | undefined```+## UIPages — class @experimental+```+close: (id: string) => void+has: (id: string) => boolean+isBuilt: (id: string) => boolean+isOpen: (id: string) => boolean+onBuilt: (listener: (page: PageHandle) => void) => () => void+open: (id: string) => Promise<PageHandle>+page: (id: string) => PageHandle | null+preload: (id: string) => Promise<void>+register: (id: string, def: PageDef) => void+registerDeferred: (entity: Entity, onClose?: PageDef["onClose"]) => string | null+registerDeferredAll: (root?: Entity, onClose?: PageDef["onClose"]) => string[]+static new (world_: World, assets_: Assets): UIPages+static prototype: UIPages+```+## UIPlugin — class @experimental```attachScrollContainer: (entity: Entity, container: ScrollContainer) => void@@ -13975,6 +14030,16 @@ PluralSelector(level: QualityLevel): QualityProfile```+## deferredEntities — function @experimental+```+(world: World): Entity[]+```++## deferredRecord — function @experimental+```+(world: World, entity: Entity): DeferredRecord | undefined+```+## defineBehavior — function @experimental```<S extends object>(name: string, def: BehaviorDef<S>): ComponentDef<S>@@ -14307,12 +14372,12 @@ EventBindingPlugin## expandEntry — function @experimental```-(prefab: PrefabData, entry: PrefabInstanceEntry, allocateId: () => number, loadPrefab?: SyncPrefabResolver): { entities: ProcessedEntity[]; rootId: number; unresolved: PrefabOverride[]; }+(prefab: PrefabData, entry: PrefabInstanceEntry, allocateId: () => number, loadPrefab?: SyncPrefabResolver, deferred?: DeferredRecord[]): { entities: ProcessedEntity[]; rootId: number; unresolved: PrefabOverride[]; }```## expandInstance — function @experimental```-(prefab: PrefabData, delta: PrefabInstanceDelta, allocateId: () => number, loadPrefab?: SyncPrefabResolver): { entities: ProcessedEntity[]; rootId: number; unresolved: PrefabOverride[]; }+(prefab: PrefabData, delta: PrefabInstanceDelta, allocateId: () => number, loadPrefab?: SyncPrefabResolver, deferred?: DeferredRecord[]): { entities: ProcessedEntity[]; rootId: number; unresolved: PrefabOverride[]; }```## extendPlatform — function @experimental@@ -15202,7 +15267,7 @@ MeshRendererPlugin## packagedRuntimeInit — function @experimental```-(config: Pick<PackagedGameConfig, "physicsEnabled" | "physicsConfig" | "audioConfig" | "uiTheme" | "uiThemeColors" | "achievements" | "steamAppId" | "screenFit" | "aot" | "debugChannel">): { physicsEnabled?: boolean; physicsConfig?: Physics2DPluginConfig; audioConfig?: AudioProjectConfig; uiTheme?: "light"; uiThemeOverrides?: ThemeOverrides; achievements?: string[]; steamAppId?: number; screenFit?: PackagedGameConfig["screenFit"]; aot?: PackagedGameConfig["aot"]; debugChannel?: DebugChannelConfig; }+(config: Pick<PackagedGameConfig, "physicsEnabled" | "physicsConfig" | "audioConfig" | "uiTheme" | "uiThemeColors" | "achievements" | "steamAppId" | "screenFit" | "aot" | "debugChannel" | "runtime">): { physicsEnabled?: boolean; physicsConfig?: Physics2DPluginConfig; audioConfig?: AudioProjectConfig; runtime?: RuntimeBuildConfig; uiTheme?: "light"; uiThemeOverrides?: ThemeOverrides; achievements?: string[]; steamAppId?: number; screenFit?: PackagedGameConfig["screenFit"]; aot?: PackagedGameConfig["aot"]; debugChannel?: DebugChannelConfig; }```## paintWeights — function @experimental@@ -15285,6 +15350,11 @@ MeshRendererPlugin(input: string): RichTextRun[]```+## parseRuntimeBuildConfig — function @experimental+```+(value: unknown): RuntimeBuildConfig+```+## parseSoundEvent — function @beta```(value: unknown): SoundEventAssetdiff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.mdindex 4587c440d..e5e9d8ad6 100644--- a/sdk/etc/wechat.api.md+++ b/sdk/etc/wechat.api.md@@ -1,7 +1,7 @@# API surface — esengine/wechat<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 115 public · 159 beta · 1910 experimental · 3 deprecated+Symbols: 115 public · 159 beta · 1918 experimental · 3 deprecated## ANCHOR_AXES — const @experimental```@@ -3151,6 +3151,13 @@ pixels: Uint8Array<ArrayBufferLike>width: number```+## DeferredRecord — interface @experimental+```+id: number+overrides: PrefabOverride[]+prefab: string+```+## Device — const @experimental```{ capabilities: () => DeviceCapabilities; state: () => DeviceState; motion: { start: (options?: MotionOptions) => Promise<DeviceResult>; stop: () => Promise<DeviceResult>; onChange: (handler: (sample: MotionSample) => void) => () => void; }; vibrate: (options?: VibrationOptions) => Promise<DeviceResult>; keepScreenOn: (enabled: boolean) => Promise<DeviceResult>; fullscreen: (enabled: boolean, target?: unknown) => Promise<DeviceResult>; pointerLock: (enabled: boolean, target?: unknown) => Promise<DeviceResult>; onChange: (handler: (state: DeviceState) => void) => () => void; dispose: () => void; }@@ -4158,6 +4165,7 @@ enabled: boolean## FlattenContext — interface @experimental```allocateId: () => number+deferred: DeferredRecord[] | undefineddepth: number | undefinedloadPrefab: (path: string) => PrefabData | nullvisited: Set<string> | undefined@@ -4990,6 +4998,7 @@ static prototype: InputState```assetBaseUrl: string | undefinedassets: Assets | undefined+expandDeferred: boolean | undefinedoverrides: PrefabOverride[] | undefinedparent: number | undefined```@@ -6149,6 +6158,7 @@ physicsConfig: Physics2DPluginConfig | undefinedphysicsEnabled: boolean | undefinedquality: QualityConfig | undefinedrenderBackend: "webgl2" | "webgpu" | undefined+runtime: RuntimeBuildConfig | undefinedscenes: { name: string; path: string; }[] | undefinedscreenFit: { designWidth: number; designHeight: number; scaleMode: number; matchWidthOrHeight: number; } | undefinedscripts: string | undefined@@ -6179,6 +6189,24 @@ slot: numberused: number```+## PageDef — interface @experimental+```+mount: number | (() => Entity) | undefined+onClose: "keep" | "destroy" | undefined+overrides: PrefabOverride[] | undefined+parent: number | (() => Entity) | undefined+prefab: string+```++## PageHandle — interface @experimental+```+find: (name: string) => Entity | undefined+has: (name: string) => boolean+id: string+names: () => IterableIterator<string>+root: number+```+## PageImage — interface @experimental```heights: Uint8Array<ArrayBufferLike>@@ -7144,6 +7172,7 @@ persistUpdateKey: string | undefinedphysicsConfig: Physics2DPluginConfig | undefinedphysicsEnabled: boolean | undefinedremoteRoot: string | undefined+runtime: RuntimeBuildConfig | undefinedsceneData: SceneDatauiTheme: "light" | "dark" | undefineduiThemeOverrides: ThemeOverrides | undefined@@ -7172,6 +7201,7 @@ manifest: AddressableManifest | null | undefinedmodule: ESEngineModulephysicsConfig: Physics2DPluginConfig | undefinedphysicsEnabled: boolean | undefined+runtime: RuntimeBuildConfig | undefinedscenes: { name: string; data: SceneData; }[]uiTheme: "light" | "dark" | undefineduiThemeOverrides: ThemeOverrides | undefined@@ -7851,6 +7881,11 @@ ReadonlyMap<string, string>ReadonlySet<string>```+## RUNTIME_BUILD_DEFAULTS — const @experimental+```+Readonly<Required<RuntimeBuildConfig>>+```+## ReadableWorld — type @experimental```Pick<World, 'valid' | 'has' | 'get'>@@ -8337,6 +8372,7 @@ physicsConfig: Physics2DPluginConfig | undefinedphysicsEnabled: boolean | undefinedphysicsModule: PhysicsWasmModule | null | undefinedremoteRoot: string | undefined+runtime: RuntimeBuildConfig | undefinedscenes: { name: string; data?: SceneData; path?: string; }[]screenFit: { designWidth: number; designHeight: number; scaleMode: number; matchWidthOrHeight: number; } | undefinedsource: RuntimeAssetSource@@ -8580,6 +8616,7 @@ unbindPostProcess: (camera: Entity) => void## SceneData — interface @experimental```+deferredInstances: DeferredRecord[] | undefinedentities: SceneEntityData[]generator: string | undefinedname: string@@ -11532,6 +11569,23 @@ position: number | undefinedwidth: Dimension | undefined```+## UIPages — class @experimental+```+close: (id: string) => void+has: (id: string) => boolean+isBuilt: (id: string) => boolean+isOpen: (id: string) => boolean+onBuilt: (listener: (page: PageHandle) => void) => () => void+open: (id: string) => Promise<PageHandle>+page: (id: string) => PageHandle | null+preload: (id: string) => Promise<void>+register: (id: string, def: PageDef) => void+registerDeferred: (entity: Entity, onClose?: PageDef["onClose"]) => string | null+registerDeferredAll: (root?: Entity, onClose?: PageDef["onClose"]) => string[]+static new (world_: World, assets_: Assets): UIPages+static prototype: UIPages+```+## UIPlugin — class @experimental```attachScrollContainer: (entity: Entity, container: ScrollContainer) => void@@ -12216,6 +12270,7 @@ firstScene: stringhotUpdate: { remoteRoot?: string; persistUpdateKey?: string; } | undefinedphysicsConfig: Physics2DPluginConfig | undefinedphysicsEnabled: boolean | undefined+runtime: RuntimeBuildConfig | undefinedruntimeConfig: RuntimeBuildConfig | undefinedsceneNames: string[]screenFit: { designWidth: number; designHeight: number; scaleMode: number; matchWidthOrHeight: number; } | undefined@@ -13702,6 +13757,16 @@ PluralSelector(level: QualityLevel): QualityProfile```+## deferredEntities — function @experimental+```+(world: World): Entity[]+```++## deferredRecord — function @experimental+```+(world: World, entity: Entity): DeferredRecord | undefined+```+## defineBehavior — function @experimental```<S extends object>(name: string, def: BehaviorDef<S>): ComponentDef<S>@@ -14034,12 +14099,12 @@ EventBindingPlugin## expandEntry — function @experimental```-(prefab: PrefabData, entry: PrefabInstanceEntry, allocateId: () => number, loadPrefab?: SyncPrefabResolver): { entities: ProcessedEntity[]; rootId: number; unresolved: PrefabOverride[]; }+(prefab: PrefabData, entry: PrefabInstanceEntry, allocateId: () => number, loadPrefab?: SyncPrefabResolver, deferred?: DeferredRecord[]): { entities: ProcessedEntity[]; rootId: number; unresolved: PrefabOverride[]; }```## expandInstance — function @experimental```-(prefab: PrefabData, delta: PrefabInstanceDelta, allocateId: () => number, loadPrefab?: SyncPrefabResolver): { entities: ProcessedEntity[]; rootId: number; unresolved: PrefabOverride[]; }+(prefab: PrefabData, delta: PrefabInstanceDelta, allocateId: () => number, loadPrefab?: SyncPrefabResolver, deferred?: DeferredRecord[]): { entities: ProcessedEntity[]; rootId: number; unresolved: PrefabOverride[]; }```## extendPlatform — function @experimental@@ -14929,7 +14994,7 @@ MeshRendererPlugin## packagedRuntimeInit — function @experimental```-(config: Pick<PackagedGameConfig, "physicsEnabled" | "physicsConfig" | "audioConfig" | "uiTheme" | "uiThemeColors" | "achievements" | "steamAppId" | "screenFit" | "aot" | "debugChannel">): { physicsEnabled?: boolean; physicsConfig?: Physics2DPluginConfig; audioConfig?: AudioProjectConfig; uiTheme?: "light"; uiThemeOverrides?: ThemeOverrides; achievements?: string[]; steamAppId?: number; screenFit?: PackagedGameConfig["screenFit"]; aot?: PackagedGameConfig["aot"]; debugChannel?: DebugChannelConfig; }+(config: Pick<PackagedGameConfig, "physicsEnabled" | "physicsConfig" | "audioConfig" | "uiTheme" | "uiThemeColors" | "achievements" | "steamAppId" | "screenFit" | "aot" | "debugChannel" | "runtime">): { physicsEnabled?: boolean; physicsConfig?: Physics2DPluginConfig; audioConfig?: AudioProjectConfig; runtime?: RuntimeBuildConfig; uiTheme?: "light"; uiThemeOverrides?: ThemeOverrides; achievements?: string[]; steamAppId?: number; screenFit?: PackagedGameConfig["screenFit"]; aot?: PackagedGameConfig["aot"]; debugChannel?: DebugChannelConfig; }```## paintWeights — function @experimental@@ -15012,6 +15077,11 @@ MeshRendererPlugin(input: string): RichTextRun[]```+## parseRuntimeBuildConfig — function @experimental+```+(value: unknown): RuntimeBuildConfig+```+## parseSoundEvent — function @beta```(value: unknown): SoundEventAssetdiff --git a/sdk/src/core-sys.ts b/sdk/src/core-sys.tsindex 4ab4d0ab8..8c77eedef 100644--- a/sdk/src/core-sys.ts+++ b/sdk/src/core-sys.ts@@ -351,7 +351,9 @@ export {export {RuntimeConfig,+ RUNTIME_BUILD_DEFAULTS,applyBuildRuntimeConfig,+ parseRuntimeBuildConfig,type RuntimeBuildConfig,} from './defaults';diff --git a/sdk/src/defaults.ts b/sdk/src/defaults.tsindex 5fefc1aec..2fd520a61 100644--- a/sdk/src/defaults.ts+++ b/sdk/src/defaults.ts@@ -77,6 +77,61 @@ export interface RuntimeBuildConfig {retainedBudget?: number;}+/**+ * What every {@link RuntimeBuildConfig} field is when a project says nothing, in the units the config is written in (seconds, milliseconds,+ * bytes, `#rrggbb`). A project block carries only what differs from these, so an untouched project ships the bytes it always did.+ */+export const RUNTIME_BUILD_DEFAULTS: Readonly<Required<RuntimeBuildConfig>> = {+ sceneTransitionDuration: 0.3,+ sceneTransitionColor: '#000000',+ defaultFontFamily: DEFAULT_FONT_FAMILY,+ maxDeltaTime: 0.25,+ maxFixedSteps: 8,+ textCanvasSize: 512,+ assetLoadTimeout: 30000,+ assetFailureCooldown: 5000,+ textureCacheBudget: 64 * 1024 * 1024,+ audioCacheBudget: 32 * 1024 * 1024,+ retainedBudget: 16 * 1024 * 1024,+};++const RUNTIME_BUILD_LIMITS = {+ sceneTransitionDuration: [0, 10, false],+ maxDeltaTime: [0.01, 5, false],+ maxFixedSteps: [1, 64, true],+ textCanvasSize: [64, 4096, true],+ assetLoadTimeout: [1000, 600000, true],+ assetFailureCooldown: [0, 600000, true],+ textureCacheBudget: [0, 4096 * 1024 * 1024, true],+ audioCacheBudget: [0, 1024 * 1024 * 1024, true],+ retainedBudget: [0, 1024 * 1024 * 1024, true],+} as const satisfies Record<string, readonly [min: number, max: number, integer: boolean]>;++/**+ * The runtime tuning a project declared, read from untrusted JSON: a field of the wrong type is dropped, a number is held to its range, and a value+ * equal to its default is dropped too (absence is how a default is written everywhere else in a project). Nothing here invents a value.+ * @experimental+ */+export function parseRuntimeBuildConfig(value: unknown): RuntimeBuildConfig {+ const raw = value !== null && typeof value === 'object' && !Array.isArray(value) ? value as Record<string, unknown> : {};+ const config: RuntimeBuildConfig = {};+ for (const [key, [min, max, integer]] of Object.entries(RUNTIME_BUILD_LIMITS) as [keyof typeof RUNTIME_BUILD_LIMITS, readonly [number, number, boolean]][]) {+ const v = raw[key];+ if (typeof v !== 'number' || !Number.isFinite(v)) continue;+ const held = Math.min(max, Math.max(min, integer ? Math.round(v) : v));+ if (held !== RUNTIME_BUILD_DEFAULTS[key]) config[key] = held;+ }+ const color = raw.sceneTransitionColor;+ if (typeof color === 'string' && /^#[0-9a-f]{6}$/i.test(color) && color.toLowerCase() !== RUNTIME_BUILD_DEFAULTS.sceneTransitionColor) {+ config.sceneTransitionColor = color.toLowerCase();+ }+ const family = raw.defaultFontFamily;+ if (typeof family === 'string' && family.trim() !== '' && family.length <= 200 && family !== RUNTIME_BUILD_DEFAULTS.defaultFontFamily) {+ config.defaultFontFamily = family;+ }+ return config;+}+export function applyBuildRuntimeConfig(app: { setMaxDeltaTime(v: number): void; setMaxFixedSteps(v: number): void }, config: RuntimeBuildConfig): void {if (config.maxDeltaTime !== undefined) {RuntimeConfig.maxDeltaTime = config.maxDeltaTime;diff --git a/sdk/src/runtime/miniGameRuntime.ts b/sdk/src/runtime/miniGameRuntime.tsindex 6dc71d364..90a06d7dd 100644--- a/sdk/src/runtime/miniGameRuntime.ts+++ b/sdk/src/runtime/miniGameRuntime.ts@@ -114,6 +114,8 @@ export interface MiniGameRuntimeConfig {sceneNames: string[];firstScene: string;runtimeConfig?: RuntimeBuildConfig;+ /** The project's runtime tuning (Project Settings → Game → Runtime), applied by `initRuntime` before anything loads. */+ runtime?: RuntimeBuildConfig;/** Install physics even when the scene shows no bodies — a project that* spawns them from script (Project Settings → Physics → Enabled). */physicsEnabled?: boolean;@@ -345,6 +347,7 @@ export async function initMiniGameRuntime(config: MiniGameRuntimeConfig): PromisuiTheme: config.uiTheme,uiThemeOverrides: config.uiThemeOverrides,audioConfig: config.audioConfig,+ runtime: config.runtime,aspectRatio: canvas.width / canvas.height,...(config.aot ? { aot: config.aot } : {}),...(config.debugChannel ? { debugChannel: config.debugChannel } : {}),diff --git a/sdk/src/runtime/packagedRuntime.ts b/sdk/src/runtime/packagedRuntime.tsindex d38df37a4..c3c9fd749 100644--- a/sdk/src/runtime/packagedRuntime.ts+++ b/sdk/src/runtime/packagedRuntime.ts@@ -13,6 +13,7 @@*/import type { QualityConfig } from '../render/quality';+import type { RuntimeBuildConfig } from '../defaults';import type { DebugChannelConfig } from './debugChannelProtocol';import { extractUuid } from '../asset/AssetRegistry';import { platformReadTextFile, platformLoadImagePixels } from '../platform';@@ -104,6 +105,9 @@ export interface PackagedGameConfig {/** Project mixer state: bus volumes, custom buses, effects, duck rules.* Absent ⇒ the default mix. */audioConfig?: AudioProjectConfig;+ /** The runtime tuning the project declared (scene transition, frame limits, asset timeouts, cache budgets).+ * Absent ⇒ the engine's own values; only fields that differ from them are written. */+ runtime?: RuntimeBuildConfig;/** Hot-update delivery: the CDN root `remote`-group assets resolve against +* the storage key an applied update persists under (both optional). */hotUpdate?: { remoteRoot?: string; persistUpdateKey?: string };@@ -234,11 +238,12 @@ export function packagedAppOptions(export function packagedRuntimeInit(config: Pick<PackagedGameConfig,'physicsEnabled' | 'physicsConfig' | 'audioConfig' | 'uiTheme' | 'uiThemeColors'- | 'achievements' | 'steamAppId' | 'screenFit' | 'aot' | 'debugChannel'>,+ | 'achievements' | 'steamAppId' | 'screenFit' | 'aot' | 'debugChannel' | 'runtime'>,): {physicsEnabled?: boolean;physicsConfig?: Physics2DPluginConfig;audioConfig?: AudioProjectConfig;+ runtime?: RuntimeBuildConfig;uiTheme?: 'light';uiThemeOverrides?: ThemeOverrides;achievements?: string[];@@ -251,6 +256,7 @@ export function packagedRuntimeInit(physicsEnabled: config.physicsEnabled,physicsConfig: config.physicsConfig,audioConfig: config.audioConfig,+ runtime: config.runtime,uiTheme: config.uiTheme,uiThemeOverrides: parseThemeOverrides(config.uiThemeColors),achievements: config.achievements,diff --git a/sdk/src/runtime/playRealmRuntime.ts b/sdk/src/runtime/playRealmRuntime.tsindex d55a507d1..7f6e8265d 100644--- a/sdk/src/runtime/playRealmRuntime.ts+++ b/sdk/src/runtime/playRealmRuntime.ts@@ -30,6 +30,7 @@ import { ManifestModel, type AddressableManifest } from '../asset/AddressableManimport type { SceneData } from '../scene/scene';import type { Physics2DPluginConfig } from '../physics/PhysicsTypes';import type { AudioProjectConfig } from '../audio/AudioProjectConfig';+import type { RuntimeBuildConfig } from '../defaults';import { fetchDecodePixels } from '../asset/imageDecode';import { applyAssetRefResolvers } from './packagedRuntime';import { extractUuid, UUID_REF_PREFIX } from '../asset/AssetRegistry';@@ -89,6 +90,8 @@ export interface PlayRealmRuntimeConfig {uiThemeOverrides?: ThemeOverrides;/** Project-declared mixer state (bus volumes / effects / duck rules). */audioConfig?: AudioProjectConfig;+ /** The project's runtime tuning (Project Settings → Game → Runtime), so Play runs under what ships. */+ runtime?: RuntimeBuildConfig;/** The project's declared achievement ids — Play checks an unlock against the* same set a shipped build does, so a typo is found here. */achievements?: string[];@@ -252,6 +255,7 @@ export async function initPlayRealmRuntime(config: PlayRealmRuntimeConfig): PromuiTheme: config.uiTheme,uiThemeOverrides: config.uiThemeOverrides,audioConfig: config.audioConfig,+ runtime: config.runtime,achievements: config.achievements,// Physics (and spine) are acquired from app.sideModules — the fetch host// createWebApp built from this realm's wasmBaseUrl.diff --git a/sdk/src/runtime/playableRuntime.ts b/sdk/src/runtime/playableRuntime.tsindex dad5a5415..5f002063a 100644--- a/sdk/src/runtime/playableRuntime.ts+++ b/sdk/src/runtime/playableRuntime.ts@@ -14,6 +14,7 @@ import type { App } from '../app/app';import { setAppHostPaused } from '../app/app';import type { ESEngineModule } from '../wasm';import type { AudioProjectConfig } from '../audio/AudioProjectConfig';+import type { RuntimeBuildConfig } from '../defaults';import { initRuntime } from './runtimeLoader';import type { ThemeOverrides } from '../ui';import type { RuntimeAssetSource } from './runtimeAssets';@@ -54,6 +55,8 @@ export interface PlayableRuntimeConfig {uiThemeOverrides?: ThemeOverrides;/** Project-declared mixer state (bus volumes / effects / duck rules). */audioConfig?: AudioProjectConfig;+ /** The project's runtime tuning (Project Settings → Game → Runtime). */+ runtime?: RuntimeBuildConfig;/** Bitmask of render layers (0..31) that y-sort within the layer (Project Settings → Rendering). */ySortLayers?: number;/** Bitmask of render layers (0..31) that resolve by real depth (2.5D). */@@ -160,6 +163,7 @@ export async function initPlayableRuntime(config: PlayableRuntimeConfig): PromisuiTheme: config.uiTheme,uiThemeOverrides: config.uiThemeOverrides,audioConfig: config.audioConfig,+ runtime: config.runtime,aspectRatio: config.canvas.width / config.canvas.height,});diff --git a/sdk/src/runtime/runtimeLoader.ts b/sdk/src/runtime/runtimeLoader.tsindex 73b1fb18c..5bf689a55 100644--- a/sdk/src/runtime/runtimeLoader.ts+++ b/sdk/src/runtime/runtimeLoader.ts@@ -35,7 +35,7 @@ import type { RenderReadiness } from '../render/renderReadiness';import { WorldStreaming } from '../residency/WorldStreamer';import { persistentEntityRows } from '../residency/identity';import type { WorldManifest } from '../residency/cells';-import { DEFAULT_GRAVITY, DEFAULT_FIXED_TIMESTEP } from '../defaults';+import { DEFAULT_GRAVITY, DEFAULT_FIXED_TIMESTEP, applyBuildRuntimeConfig, type RuntimeBuildConfig } from '../defaults';import { SpriteAnimation } from '../animation/SpriteAnimator';import { Audio } from '../audio/Audio';import { Achievements } from '../services/achievements';@@ -782,6 +782,9 @@ export interface RuntimeInitConfig {/** Project-declared mixer state (bus volumes / custom buses / effects / duck* rules) — threaded from the editor's audio config, applied once at boot. */audioConfig?: AudioProjectConfig;+ /** The project's runtime tuning (scene transition, frame limits, asset timeouts, cache budgets). Applied before anything loads, so the+ * first asset already runs under it. */+ runtime?: RuntimeBuildConfig;/** Project-declared UI theme; see {@link LoadRuntimeSceneOptions.uiTheme}. */uiTheme?: 'dark' | 'light';/** Project-declared theme token overrides; see {@link LoadRuntimeSceneOptions.uiThemeOverrides}. */@@ -811,6 +814,9 @@ export async function initRuntime(config: RuntimeInitConfig): Promise<void> {flushPendingRegistrations(app);+ // First: the asset timeouts and cache budgets are read by the very first load below.+ if (config.runtime) applyBuildRuntimeConfig(app, config.runtime);+// After the project's components are registered (the manifest names them)// and before any exists (its rows must be in the memory the module reads).// A module that disagrees with this engine or project throws here.diff --git a/sdk/tests/runtime-build-config.test.ts b/sdk/tests/runtime-build-config.test.tsnew file mode 100644index 000000000..c9fbb79b2--- /dev/null+++ b/sdk/tests/runtime-build-config.test.ts@@ -0,0 +1,67 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file The runtime tuning a project can declare: what the parser keeps, and that the defaults it compares against are the engine's own.+ */+import { describe, it, expect } from 'vitest';+import { RUNTIME_BUILD_DEFAULTS, RuntimeConfig, parseRuntimeBuildConfig } from '../src/defaults';+import { packagedRuntimeInit } from '../src/runtime/packagedRuntime';++describe('packagedRuntimeInit', () => {+ it('hands the declared tuning to initRuntime, which is where every host applies it', () => {+ const runtime = { assetLoadTimeout: 60000 };+ expect(packagedRuntimeInit({ runtime }).runtime).toBe(runtime);+ expect(packagedRuntimeInit({}).runtime).toBeUndefined();+ });+});++describe('RUNTIME_BUILD_DEFAULTS', () => {+ it('are what the engine starts with, so "differs from the default" means differs from what runs', () => {+ const { sceneTransitionColor, ...numbers } = RUNTIME_BUILD_DEFAULTS;+ expect(sceneTransitionColor).toBe('#000000');+ expect(RuntimeConfig.sceneTransitionColor).toEqual({ r: 0, g: 0, b: 0, a: 1 });+ for (const [key, value] of Object.entries(numbers)) {+ expect((RuntimeConfig as Record<string, unknown>)[key], key).toBe(value);+ }+ });+});++describe('parseRuntimeBuildConfig', () => {+ it('keeps nothing for nothing, and for anything that is not an object', () => {+ expect(parseRuntimeBuildConfig(undefined)).toEqual({});+ expect(parseRuntimeBuildConfig(null)).toEqual({});+ expect(parseRuntimeBuildConfig([1, 2])).toEqual({});+ expect(parseRuntimeBuildConfig('x')).toEqual({});+ });++ it('drops a value equal to the default, since absence is how a default is written', () => {+ expect(parseRuntimeBuildConfig({ ...RUNTIME_BUILD_DEFAULTS })).toEqual({});+ });++ it('holds a number to its range and an integer field to whole numbers', () => {+ expect(parseRuntimeBuildConfig({ maxFixedSteps: 0, assetLoadTimeout: 5, textureCacheBudget: -1 })).toEqual({+ maxFixedSteps: 1, assetLoadTimeout: 1000, textureCacheBudget: 0,+ });+ expect(parseRuntimeBuildConfig({ maxFixedSteps: 12.6 })).toEqual({ maxFixedSteps: 13 });+ expect(parseRuntimeBuildConfig({ maxDeltaTime: 99 })).toEqual({ maxDeltaTime: 5 });+ expect(parseRuntimeBuildConfig({ maxDeltaTime: 0.5 })).toEqual({ maxDeltaTime: 0.5 });+ });++ it('drops a field of the wrong type or a non-finite number', () => {+ expect(parseRuntimeBuildConfig({+ maxDeltaTime: '1', maxFixedSteps: Number.NaN, textCanvasSize: Infinity, defaultFontFamily: 4, sceneTransitionColor: 'red',+ })).toEqual({});+ });++ it('takes a six-digit colour in lower case and refuses one with alpha', () => {+ expect(parseRuntimeBuildConfig({ sceneTransitionColor: '#FFAA00' })).toEqual({ sceneTransitionColor: '#ffaa00' });+ expect(parseRuntimeBuildConfig({ sceneTransitionColor: '#ffaa0080' })).toEqual({});+ });++ it('takes a font family unless it is blank, absurdly long or the engine\'s own', () => {+ expect(parseRuntimeBuildConfig({ defaultFontFamily: 'Noto Sans SC' })).toEqual({ defaultFontFamily: 'Noto Sans SC' });+ expect(parseRuntimeBuildConfig({ defaultFontFamily: ' ' })).toEqual({});+ expect(parseRuntimeBuildConfig({ defaultFontFamily: 'x'.repeat(201) })).toEqual({});+ expect(parseRuntimeBuildConfig({ defaultFontFamily: 'Arial' })).toEqual({});+ });+});diff --git a/tools/check-project-settings.mjs b/tools/check-project-settings.mjsindex 4fde9447b..1678cbdaa 100644--- a/tools/check-project-settings.mjs+++ b/tools/check-project-settings.mjs@@ -55,6 +55,8 @@ const FORMAT = 'pipeline/src/project/format.ts';const STORE = 'desktop/src/project/ProjectStore.ts';/** Where a project setting becomes a row a creator can see. */const SETTINGS = 'desktop/src/settings/projectSettings.ts';+/** The rows built from a block's own keys live beside it; they count as the same surface. */+const SETTINGS_FILES = [SETTINGS, 'desktop/src/settings/qualitySettings.ts', 'desktop/src/settings/runtimeSettings.ts'];/*** Where each field of RuntimeProjectConfig has to show up, and the reason when@@ -100,6 +102,10 @@ const DECLARED_GAPS = {uiThemeColors: {editor: 'applied together with uiTheme (one applyWidgetTheme call takes both)',},+ runtime: {+ editor: 'the edit viewport keeps the engine\'s own timeouts, budgets and frame limits so authoring behaves the same in every project; '+ + 'Play and a shipped build run under the declared values (initRuntime applies them before the first load)',+ },};/** The feature branch in the manifest parser each field is read from. */@@ -109,6 +115,7 @@ const PARSE_KEY = {physicsEnabled: 'p.enabled',physicsConfig: 'physics',audioConfig: 'parseAudioProjectConfig',+ runtime: 'parseRuntimeBuildConfig',uiTheme: 'u.theme',uiThemeColors: 'u.colors',ySortLayers: 'r.ySortLayers',@@ -132,6 +139,7 @@ const AUTHORING = {physicsEnabled: { ui: 'project.physics.enabled' },physicsConfig: { ui: ['project.physics.gravityX', 'project.physics.gravityY', 'project.physics.fixedTimestep'] },audioConfig: { ui: ['project.audio.maxVoices', 'project.audio.buses', 'project.audio.effects'] },+ runtime: { ui: ['project.runtime.'] },uiTheme: { ui: 'project.ui.theme' },uiThemeColors: { ui: 'project.ui.color.' },ySortLayers: { ui: 'project.rendering.ySortLayers' },@@ -154,7 +162,7 @@ function runtimeConfigFields(src) {const runtimeSrc = read(RUNTIME_CONFIG);const formatSrc = read(FORMAT);const storeSrc = read(STORE);-const settingsSrc = read(SETTINGS);+const settingsSrc = SETTINGS_FILES.map(read).join(String.fromCharCode(10));const fields = runtimeConfigFields(runtimeSrc);if (fields.length === 0) {@@ -240,6 +248,103 @@ for (const field of fields) {}}++/**+ * The blocks inside a RuntimeProjectConfig field. A field passing the transport questions above says nothing about the keys it holds: `quality`+ * has one row for its level and thirty keys. Each block's keys are read from its interface and must say how a creator reaches them.+ *+ * `ui` is the settings id, looked for in the settings sources; an id built in a loop from the key (`project.rendering.quality.${row.key}`)+ * counts when its prefix is built that way and the key is named. `manual` and `internal` carry a reason; `owed` is debt.+ */+const BLOCKS = [+ {+ name: 'QualityConfig', file: 'sdk/src/render/quality.ts',+ keys: {+ mode: { ui: 'project.rendering.quality' },+ targetFps: { ui: 'project.rendering.qualityTargetFps' },+ dynamicResolution: { ui: 'project.rendering.dynamicResolution' },+ asyncShaderCompile: { ui: 'project.rendering.quality.asyncShaderCompile' },+ prewarmShaders: { ui: 'project.rendering.quality.prewarmShaders' },+ prewarmTimeoutMs: { ui: 'project.rendering.quality.prewarmTimeoutMs' },+ renderOnDemand: { ui: 'project.rendering.quality.renderOnDemand' },+ renderOnDemandTail: { ui: 'project.rendering.quality.renderOnDemandTail' },+ profiles: { ui: 'project.rendering.quality.renderScale' },+ deviceRules: { ui: 'project.rendering.qualityDeviceRules' },+ },+ },+ {+ name: 'QualityProfile', file: 'sdk/src/render/quality.ts',+ keys: {+ renderScale: { ui: 'project.rendering.quality.renderScale' },+ minRenderScale: { ui: 'project.rendering.quality.minRenderScale' },+ msaaSamples: { ui: 'project.rendering.quality.msaaSamples' },+ antialiasing: { ui: 'project.rendering.quality.antialiasing' },+ shadowAtlasSize: { ui: 'project.rendering.quality.shadowAtlasSize' },+ shadowCellSize: { ui: 'project.rendering.quality.shadowCellSize' },+ shadowCascades: { ui: 'project.rendering.quality.shadowCascades' },+ shadowDistance: { ui: 'project.rendering.quality.shadowDistance' },+ detailScale: { ui: 'project.rendering.quality.detailScale' },+ particleLimit: { ui: 'project.rendering.quality.particleLimit' },+ planarReflectionScale: { ui: 'project.rendering.quality.planarReflectionScale' },+ planarReflectionMaxSize: { ui: 'project.rendering.quality.planarReflectionMaxSize' },+ planarReflectionUpdatesPerSecond: { ui: 'project.rendering.quality.planarReflectionUpdatesPerSecond' },+ depthPrepass: { ui: 'project.rendering.quality.depthPrepass' },+ postProcess: { ui: 'project.rendering.quality.postProcess' },+ ssao: { ui: 'project.rendering.quality.effects' },+ waterWaves: { ui: 'project.rendering.quality.waterWaves' },+ waterRippleCells: { ui: 'project.rendering.quality.waterRippleCells' },+ waterDisplacement: { ui: 'project.rendering.quality.waterDisplacement' },+ waterMirror: { ui: 'project.rendering.quality.waterMirror' },+ waterCaustics: { ui: 'project.rendering.quality.waterCaustics' },+ skipEffects: { ui: 'project.rendering.quality.effects' },+ },+ },+ {+ name: 'RuntimeBuildConfig', file: 'sdk/src/defaults.ts',+ keys: Object.fromEntries([+ 'sceneTransitionDuration', 'sceneTransitionColor', 'defaultFontFamily', 'maxDeltaTime', 'maxFixedSteps', 'textCanvasSize',+ 'assetLoadTimeout', 'assetFailureCooldown', 'textureCacheBudget', 'audioCacheBudget', 'retainedBudget',+ ].map((k) => [k, { ui: `project.runtime.${k}` }])),+ },+];++/** The member names of an interface, from its source text. */+function interfaceKeys(src, name) {+ const at = src.indexOf(`export interface ${name} {`);+ if (at < 0) return null;+ const body = src.slice(at);+ const end = body.indexOf(String.fromCharCode(10) + '}');+ return [...body.slice(0, end).matchAll(/^ {4}(\w+)\??:/gm)].map((m) => m[1]);+}++/** Whether a settings id is registered: quoted as it stands, or built in a loop from its last segment under the same prefix. */+function rowRegistered(id) {+ if (settingsSrc.includes(`'${id}'`)) return true;+ const dot = id.lastIndexOf('.');+ const prefix = id.slice(0, dot + 1);+ const key = id.slice(dot + 1);+ return settingsSrc.includes(`\`${prefix}\${`) && settingsSrc.includes(`'${key}'`);+}++for (const block of BLOCKS) {+ const keys = interfaceKeys(read(block.file), block.name);+ if (!keys) { problems.push(`${block.name}: not found in ${block.file} — has it moved?`); continue; }+ for (const key of keys) {+ const answer = block.keys[key];+ if (!answer) {+ problems.push(`${block.name}.${key} says nothing about authoring — add it to BLOCKS in tools/check-project-settings.mjs `+ + 'with the settings row that sets it, or a manual / internal reason, or record it as owed');+ continue;+ }+ if (answer.ui && !rowRegistered(answer.ui)) problems.push(`${block.name}.${key} claims the row ${answer.ui}, which no settings file registers`);+ if (answer.owed) owed.push(` ${block.name}.${key} → ${answer.owed}`);+ if ((answer.manual || answer.internal) === '') problems.push(`${block.name}.${key} declares a reason that is empty`);+ }+ for (const key of Object.keys(block.keys)) {+ if (!keys.includes(key)) problems.push(`${block.name}.${key} is declared here and no longer in the interface — remove the entry`);+ }+}+/*** Settings a creator can WRITE that are not RuntimeProjectConfig fields, so the* transport questions above never see them. An authoring surface proves onlydiff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex d6d665ce7..0876a9242 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -3110,4 +3110,8 @@ export const NOTED = {{"note":"The medium level uses it"},"fix(ci): the net modules build no TextEncoder at load, the API snapshots take the new surface, the retained-text harness reads its cases under node":{"internal":"Repairs the build: a module made a TextEncoder when the SDK loaded, which a native host does not have, and the API snapshots and one C++ harness's data path were out of date."},+ "feat(runtime): a project declares runtime tuning, and a build ships background shader compilation and on-demand drawing with the quality level off":+ {"note":"The engine's runtime tuning is a project setting."},+ "feat(editor): rows for background shader compilation, on-demand drawing, a level's smoothing, render resolution and server origins":+ {"note":"Rows for the choices that could only be written into the project file."},};