Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat(sdk): a packaged config is projected once, not restated by every host

yhh92b44f6b7e1d
diff --git a/desktop/src/gameHost.ts b/desktop/src/gameHost.ts
index fe265f3b0..659953a23 100644
--- a/desktop/src/gameHost.ts
+++ b/desktop/src/gameHost.ts
@@ -12,9 +12,10 @@
* (shared with the play realm's import-map work).
*/
import {
- createWebApp, setEditorMode, setPlayMode, parseThemeOverrides, Assets,
+ createWebApp, setEditorMode, setPlayMode, Assets,
indexPackagedManifest, createPackagedAssetSource, applyAssetRefResolvers, initRuntime,
HttpBackend, fetchDecodePixels, registerPackagedSideModules,
+ packagedAppOptions, packagedRuntimeInit,
} from 'esengine';
import type { ESEngineModule, SceneData, AddressableManifest, PackagedGameConfig } from 'esengine';
@@ -78,9 +79,8 @@ async function boot(): Promise<void> {
const app = createWebApp(module, {
renderSurface: { kind: 'gl-context', handle: glHandle },
- ySortLayers: cfg.ySortLayers,
- colorSpace: cfg.colorSpace,
- screenFit: cfg.screenFit,
+ // Everything the config says an App must be BUILT with (see packagedAppOptions).
+ ...packagedAppOptions(cfg),
getViewportSize: () => ({ width: canvas.width, height: canvas.height }),
wasmBaseUrl: wasmBase.replace(/\/$/, ''), // SDK appends "/<file>" — no trailing slash
});
@@ -105,9 +105,9 @@ async function boot(): Promise<void> {
},
};
}
- // physics.wasm sits next to esengine.wasm; the runtime loads it when the scene
- // uses physics. (Runtime-spawned bodies still need a build-time enable flag —
- // a follow-up that cooks features.physics into game.config.json.)
+ // physics.wasm sits next to esengine.wasm; the runtime loads it when a scene
+ // uses physics, or when the project declared physics on for bodies it spawns
+ // from script (packagedRuntimeInit carries that flag).
// The entry scene boots eagerly (already fetched); every other shipped scene
// registers lazily by path, so SceneManager.switchTo('name') fetches it on
// first use — the same registration shape the WeChat runtime uses.
@@ -134,8 +134,8 @@ async function boot(): Promise<void> {
],
firstScene: entryName,
aspectRatio: canvas.width / canvas.height,
- uiTheme: cfg.uiTheme,
- uiThemeOverrides: parseThemeOverrides(cfg.uiThemeColors),
+ // Everything the config APPLIES to a live app: physics, the mixer, the theme.
+ ...packagedRuntimeInit(cfg),
});
app.run();
}
diff --git a/desktop/src/playableHost.ts b/desktop/src/playableHost.ts
index 746c9131a..a54cd8fcf 100644
--- a/desktop/src/playableHost.ts
+++ b/desktop/src/playableHost.ts
@@ -10,7 +10,10 @@
* (play == ship). Nothing is fetched — the whole game is one self-contained
* .html (ad-network ready).
*/
-import { createWebApp, setEditorMode, setPlayMode, initPlayableRuntime, createEmbeddedSideModuleHost, parseThemeOverrides } from 'esengine';
+import {
+ createWebApp, setEditorMode, setPlayMode, initPlayableRuntime, createEmbeddedSideModuleHost,
+ packagedAppOptions, packagedRuntimeInit,
+} from 'esengine';
import type { ESEngineModule as EngineModule, SceneData, EmbeddedSideModuleRegistry } from 'esengine';
import type { PackagedRuntimeFields } from '@/project/runtimeConfig';
@@ -88,9 +91,8 @@ async function boot(): Promise<void> {
const app = createWebApp(module, {
renderSurface: { kind: 'gl-context', handle: glHandle },
// Older exports predate the color-space global; treat it as optional.
- colorSpace: runtimeConfig.colorSpace,
- // Present only when the project opts into a camera fit; absent otherwise.
- screenFit: runtimeConfig.screenFit,
+ // Everything the config says an App must be BUILT with (see packagedAppOptions).
+ ...packagedAppOptions(runtimeConfig),
getViewportSize: () => ({ width: canvas.width, height: canvas.height }),
// Physics + spine resolve from the inlined base64 registry (no fetch).
sideModules: createEmbeddedSideModuleHost(typeof __SIDE_MODULES__ !== 'undefined' ? __SIDE_MODULES__ : {}),
@@ -121,11 +123,8 @@ async function boot(): Promise<void> {
assetPathMap: typeof __GAME_PATHMAP__ !== 'undefined' ? __GAME_PATHMAP__ : undefined,
scenes: __GAME_SCENES__,
firstScene: __GAME_FIRST__,
- ySortLayers: runtimeConfig.ySortLayers,
- // The 2.5D opt-in, which a playable never used to be told at all.
- depthLayers: runtimeConfig.depthLayers,
- uiTheme: runtimeConfig.uiTheme,
- uiThemeOverrides: parseThemeOverrides(runtimeConfig.uiThemeColors),
+ // Everything the config APPLIES to a live app: physics, the mixer, the theme.
+ ...packagedRuntimeInit(runtimeConfig),
});
}
diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.md
index 4cd3718af..9572d2e61 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: 1434 stable · 17 beta · 1 deprecated
+Symbols: 1436 stable · 17 beta · 1 deprecated
## ABI_LAYOUT_HASH — const
```
@@ -4563,10 +4563,13 @@ decodePixels: ((path: string, flip: boolean) => Promise<{ width: number; height:
## PackagedGameConfig — interface
```
+audioConfig: AudioProjectConfig | undefined
colorSpace: "gamma" | "linear" | undefined
depthLayers: number | undefined
entryScene: string
hotUpdate: { remoteRoot?: string; persistUpdateKey?: string; } | undefined
+physicsConfig: PhysicsPluginConfig | undefined
+physicsEnabled: boolean | undefined
scenes: { name: string; path: string; }[] | undefined
screenFit: { designWidth: number; designHeight: number; scaleMode: number; matchWidthOrHeight: number; } | undefined
sideModules: { id: string; file: string; globalName?: string; }[] | undefined
@@ -5167,7 +5170,8 @@ depthLayers: number | undefined
firstScene: string
manifest: AddressableManifest | null | undefined
module: ESEngineModule
-physicsConfig: { gravity?: Vec2; fixedTimestep?: number; subStepCount?: number; } | undefined
+physicsConfig: PhysicsPluginConfig | undefined
+physicsEnabled: boolean | undefined
scenes: { name: string; data: SceneData; }[]
uiTheme: "dark" | "light" | undefined
uiThemeOverrides: ThemeOverrides | undefined
@@ -9993,6 +9997,16 @@ NavPlugin
(tl: number, tr: number, br: number, bl: number): number
```
+## packagedAppOptions — function
+```
+(config: Pick<PackagedGameConfig, "ySortLayers" | "depthLayers" | "colorSpace" | "screenFit">): { ySortLayers?: number; depthLayers?: number; colorSpace?: "gamma" | "linear"; screenFit?: PackagedGameConfig["screenFit"]; }
+```
+
+## packagedRuntimeInit — function
+```
+(config: Pick<PackagedGameConfig, "physicsEnabled" | "physicsConfig" | "audioConfig" | "uiTheme" | "uiThemeColors">): { physicsEnabled?: boolean; physicsConfig?: PhysicsPluginConfig; audioConfig?: AudioProjectConfig; uiTheme?: "light"; uiThemeOverrides?: ThemeOverrides; }
+```
+
## parseActionArg — function
```
(arg: string | undefined, params: readonly AiParamDef[], separator?: string): Record<string, AiParamValue>
diff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.md
index cd3a561d1..72967931c 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: 1453 stable · 22 beta · 1 deprecated
+Symbols: 1455 stable · 22 beta · 1 deprecated
## ABI_LAYOUT_HASH — const
```
@@ -4723,10 +4723,13 @@ decodePixels: ((path: string, flip: boolean) => Promise<{ width: number; height:
## PackagedGameConfig — interface
```
+audioConfig: AudioProjectConfig | undefined
colorSpace: "gamma" | "linear" | undefined
depthLayers: number | undefined
entryScene: string
hotUpdate: { remoteRoot?: string; persistUpdateKey?: string; } | undefined
+physicsConfig: PhysicsPluginConfig | undefined
+physicsEnabled: boolean | undefined
scenes: { name: string; path: string; }[] | undefined
screenFit: { designWidth: number; designHeight: number; scaleMode: number; matchWidthOrHeight: number; } | undefined
sideModules: { id: string; file: string; globalName?: string; }[] | undefined
@@ -5327,7 +5330,8 @@ depthLayers: number | undefined
firstScene: string
manifest: AddressableManifest | null | undefined
module: ESEngineModule
-physicsConfig: { gravity?: Vec2; fixedTimestep?: number; subStepCount?: number; } | undefined
+physicsConfig: PhysicsPluginConfig | undefined
+physicsEnabled: boolean | undefined
scenes: { name: string; data: SceneData; }[]
uiTheme: "dark" | "light" | undefined
uiThemeOverrides: ThemeOverrides | undefined
@@ -10213,6 +10217,16 @@ NavPlugin
(tl: number, tr: number, br: number, bl: number): number
```
+## packagedAppOptions — function
+```
+(config: Pick<PackagedGameConfig, "ySortLayers" | "depthLayers" | "colorSpace" | "screenFit">): { ySortLayers?: number; depthLayers?: number; colorSpace?: "gamma" | "linear"; screenFit?: PackagedGameConfig["screenFit"]; }
+```
+
+## packagedRuntimeInit — function
+```
+(config: Pick<PackagedGameConfig, "physicsEnabled" | "physicsConfig" | "audioConfig" | "uiTheme" | "uiThemeColors">): { physicsEnabled?: boolean; physicsConfig?: PhysicsPluginConfig; audioConfig?: AudioProjectConfig; uiTheme?: "light"; uiThemeOverrides?: ThemeOverrides; }
+```
+
## parseActionArg — function
```
(arg: string | undefined, params: readonly AiParamDef[], separator?: string): Record<string, AiParamValue>
diff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.md
index 02d0b2f42..f24c6ee0a 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: 1433 stable · 19 beta · 1 deprecated
+Symbols: 1435 stable · 19 beta · 1 deprecated
## ANCHOR_AXES — const
```
@@ -4558,10 +4558,13 @@ decodePixels: ((path: string, flip: boolean) => Promise<{ width: number; height:
## PackagedGameConfig — interface
```
+audioConfig: AudioProjectConfig | undefined
colorSpace: "gamma" | "linear" | undefined
depthLayers: number | undefined
entryScene: string
hotUpdate: { remoteRoot?: string; persistUpdateKey?: string; } | undefined
+physicsConfig: PhysicsPluginConfig | undefined
+physicsEnabled: boolean | undefined
scenes: { name: string; path: string; }[] | undefined
screenFit: { designWidth: number; designHeight: number; scaleMode: number; matchWidthOrHeight: number; } | undefined
sideModules: { id: string; file: string; globalName?: string; }[] | undefined
@@ -5162,7 +5165,8 @@ depthLayers: number | undefined
firstScene: string
manifest: AddressableManifest | null | undefined
module: ESEngineModule
-physicsConfig: { gravity?: Vec2; fixedTimestep?: number; subStepCount?: number; } | undefined
+physicsConfig: PhysicsPluginConfig | undefined
+physicsEnabled: boolean | undefined
scenes: { name: string; data: SceneData; }[]
uiTheme: "dark" | "light" | undefined
uiThemeOverrides: ThemeOverrides | undefined
@@ -9998,6 +10002,16 @@ NodePlatformAdapter
(tl: number, tr: number, br: number, bl: number): number
```
+## packagedAppOptions — function
+```
+(config: Pick<PackagedGameConfig, "ySortLayers" | "depthLayers" | "colorSpace" | "screenFit">): { ySortLayers?: number; depthLayers?: number; colorSpace?: "gamma" | "linear"; screenFit?: PackagedGameConfig["screenFit"]; }
+```
+
+## packagedRuntimeInit — function
+```
+(config: Pick<PackagedGameConfig, "physicsEnabled" | "physicsConfig" | "audioConfig" | "uiTheme" | "uiThemeColors">): { physicsEnabled?: boolean; physicsConfig?: PhysicsPluginConfig; audioConfig?: AudioProjectConfig; uiTheme?: "light"; uiThemeOverrides?: ThemeOverrides; }
+```
+
## parseActionArg — function
```
(arg: string | undefined, params: readonly AiParamDef[], separator?: string): Record<string, AiParamValue>
diff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.md
index aea373aeb..7eea47b0d 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: 1454 stable · 17 beta · 1 deprecated
+Symbols: 1456 stable · 17 beta · 1 deprecated
## ANCHOR_AXES — const
```
@@ -4474,7 +4474,8 @@ depthLayers: number | undefined
engineFactory: (opts: unknown) => Promise<ESEngineModule>
engineWasmPath: string
firstScene: string
-physicsConfig: { gravity?: Vec2; fixedTimestep?: number; subStepCount?: number; } | undefined
+physicsConfig: PhysicsPluginConfig | undefined
+physicsEnabled: boolean | undefined
runtimeConfig: RuntimeBuildConfig | undefined
sceneNames: string[]
screenFit: { designWidth: number; designHeight: number; scaleMode: number; matchWidthOrHeight: number; } | undefined
@@ -4802,10 +4803,13 @@ decodePixels: ((path: string, flip: boolean) => Promise<{ width: number; height:
## PackagedGameConfig — interface
```
+audioConfig: AudioProjectConfig | undefined
colorSpace: "gamma" | "linear" | undefined
depthLayers: number | undefined
entryScene: string
hotUpdate: { remoteRoot?: string; persistUpdateKey?: string; } | undefined
+physicsConfig: PhysicsPluginConfig | undefined
+physicsEnabled: boolean | undefined
scenes: { name: string; path: string; }[] | undefined
screenFit: { designWidth: number; designHeight: number; scaleMode: number; matchWidthOrHeight: number; } | undefined
sideModules: { id: string; file: string; globalName?: string; }[] | undefined
@@ -5406,7 +5410,8 @@ depthLayers: number | undefined
firstScene: string
manifest: AddressableManifest | null | undefined
module: ESEngineModule
-physicsConfig: { gravity?: Vec2; fixedTimestep?: number; subStepCount?: number; } | undefined
+physicsConfig: PhysicsPluginConfig | undefined
+physicsEnabled: boolean | undefined
scenes: { name: string; data: SceneData; }[]
uiTheme: "dark" | "light" | undefined
uiThemeOverrides: ThemeOverrides | undefined
@@ -10247,6 +10252,16 @@ NavPlugin
(tl: number, tr: number, br: number, bl: number): number
```
+## packagedAppOptions — function
+```
+(config: Pick<PackagedGameConfig, "ySortLayers" | "depthLayers" | "colorSpace" | "screenFit">): { ySortLayers?: number; depthLayers?: number; colorSpace?: "gamma" | "linear"; screenFit?: PackagedGameConfig["screenFit"]; }
+```
+
+## packagedRuntimeInit — function
+```
+(config: Pick<PackagedGameConfig, "physicsEnabled" | "physicsConfig" | "audioConfig" | "uiTheme" | "uiThemeColors">): { physicsEnabled?: boolean; physicsConfig?: PhysicsPluginConfig; audioConfig?: AudioProjectConfig; uiTheme?: "light"; uiThemeOverrides?: ThemeOverrides; }
+```
+
## parseActionArg — function
```
(arg: string | undefined, params: readonly AiParamDef[], separator?: string): Record<string, AiParamValue>
diff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.md
index 6177d3a3d..67fb132e4 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: 1444 stable · 17 beta · 1 deprecated
+Symbols: 1446 stable · 17 beta · 1 deprecated
## ANCHOR_AXES — const
```
@@ -4565,10 +4565,13 @@ decodePixels: ((path: string, flip: boolean) => Promise<{ width: number; height:
## PackagedGameConfig — interface
```
+audioConfig: AudioProjectConfig | undefined
colorSpace: "gamma" | "linear" | undefined
depthLayers: number | undefined
entryScene: string
hotUpdate: { remoteRoot?: string; persistUpdateKey?: string; } | undefined
+physicsConfig: PhysicsPluginConfig | undefined
+physicsEnabled: boolean | undefined
scenes: { name: string; path: string; }[] | undefined
screenFit: { designWidth: number; designHeight: number; scaleMode: number; matchWidthOrHeight: number; } | undefined
sideModules: { id: string; file: string; globalName?: string; }[] | undefined
@@ -5169,7 +5172,8 @@ depthLayers: number | undefined
firstScene: string
manifest: AddressableManifest | null | undefined
module: ESEngineModule
-physicsConfig: { gravity?: Vec2; fixedTimestep?: number; subStepCount?: number; } | undefined
+physicsConfig: PhysicsPluginConfig | undefined
+physicsEnabled: boolean | undefined
scenes: { name: string; data: SceneData; }[]
uiTheme: "dark" | "light" | undefined
uiThemeOverrides: ThemeOverrides | undefined
@@ -8386,7 +8390,8 @@ depthLayers: number | undefined
engineFactory: (opts: unknown) => Promise<ESEngineModule>
engineWasmPath: string | undefined
firstScene: string
-physicsConfig: { gravity?: Vec2; fixedTimestep?: number; subStepCount?: number; } | undefined
+physicsConfig: PhysicsPluginConfig | undefined
+physicsEnabled: boolean | undefined
runtimeConfig: RuntimeBuildConfig | undefined
sceneNames: string[]
screenFit: { designWidth: number; designHeight: number; scaleMode: number; matchWidthOrHeight: number; } | undefined
@@ -10019,6 +10024,16 @@ NavPlugin
(tl: number, tr: number, br: number, bl: number): number
```
+## packagedAppOptions — function
+```
+(config: Pick<PackagedGameConfig, "ySortLayers" | "depthLayers" | "colorSpace" | "screenFit">): { ySortLayers?: number; depthLayers?: number; colorSpace?: "gamma" | "linear"; screenFit?: PackagedGameConfig["screenFit"]; }
+```
+
+## packagedRuntimeInit — function
+```
+(config: Pick<PackagedGameConfig, "physicsEnabled" | "physicsConfig" | "audioConfig" | "uiTheme" | "uiThemeColors">): { physicsEnabled?: boolean; physicsConfig?: PhysicsPluginConfig; audioConfig?: AudioProjectConfig; uiTheme?: "light"; uiThemeOverrides?: ThemeOverrides; }
+```
+
## parseActionArg — function
```
(arg: string | undefined, params: readonly AiParamDef[], separator?: string): Record<string, AiParamValue>
diff --git a/sdk/src/core-content.ts b/sdk/src/core-content.ts
index 2dbd1c29f..b15e92981 100644
--- a/sdk/src/core-content.ts
+++ b/sdk/src/core-content.ts
@@ -251,6 +251,8 @@ export {
createPackagedAssetSource,
applyAssetRefResolvers,
registerPackagedSideModules,
+ packagedAppOptions,
+ packagedRuntimeInit,
type PackagedAssetIndex,
type PackagedAssetSourceOptions,
type PackagedGameConfig,
diff --git a/sdk/src/runtime/miniGameRuntime.ts b/sdk/src/runtime/miniGameRuntime.ts
index 95c498505..43ca4201e 100644
--- a/sdk/src/runtime/miniGameRuntime.ts
+++ b/sdk/src/runtime/miniGameRuntime.ts
@@ -27,7 +27,7 @@ import {
registerPackagedSideModules,
} from './packagedRuntime';
import { createMiniGameSideModuleHost, type MiniGameSideModuleFactories } from '../sideModules';
-import type { Vec2 } from '../types';
+import type { PhysicsPluginConfig } from '../physics/PhysicsTypes';
import type { SceneData } from '../scene/scene';
import { log } from '../util/logger';
@@ -80,7 +80,13 @@ export interface MiniGameRuntimeConfig {
sceneNames: string[];
firstScene: string;
runtimeConfig?: RuntimeBuildConfig;
- physicsConfig?: { gravity?: Vec2; fixedTimestep?: number; subStepCount?: number };
+ /** Install physics even when the scene shows no bodies — a project that
+ * spawns them from script (Project Settings → Physics → Enabled). */
+ physicsEnabled?: boolean;
+ /** The physics world the project declared: gravity, solver, collision matrix.
+ * The FULL config, not a three-field subset: a collision matrix that reached
+ * Play and not a shipped build is a game that only collides in rehearsal. */
+ physicsConfig?: PhysicsPluginConfig;
/** Project-declared UI theme; 'light' re-skins ThemeStyle-tagged widgets at boot. */
uiTheme?: 'dark' | 'light';
/** Project-declared theme token overrides (partial re-skin over the base). */
@@ -201,6 +207,7 @@ export async function initMiniGameRuntime(config: MiniGameRuntimeConfig): Promis
catalog,
scenes,
firstScene: config.firstScene,
+ physicsEnabled: config.physicsEnabled,
physicsConfig: config.physicsConfig,
uiTheme: config.uiTheme,
uiThemeOverrides: config.uiThemeOverrides,
diff --git a/sdk/src/runtime/packagedRuntime.ts b/sdk/src/runtime/packagedRuntime.ts
index 1ff77a18c..33ee4e7d8 100644
--- a/sdk/src/runtime/packagedRuntime.ts
+++ b/sdk/src/runtime/packagedRuntime.ts
@@ -20,6 +20,9 @@ import { Catalog, atlasCatalogFields, type CatalogEntry } from '../asset/Catalog
import { FileSystemBackend, type Backend } from '../asset/Backend';
import type { ParsedTextureImportSettings } from '../asset/textureImportSettings';
import { Audio } from '../audio/Audio';
+import type { AudioProjectConfig } from '../audio/AudioProjectConfig';
+import type { PhysicsPluginConfig } from '../physics/PhysicsTypes';
+import { parseThemeOverrides, type ThemeOverrides } from '../ui/theme/tokens';
import { VideoPlayer } from '../video/VideoAPI';
import type { App } from '../app/app';
import type { RuntimeAssetSource } from './runtimeAssets';
@@ -48,6 +51,18 @@ export interface PackagedGameConfig {
uiTheme?: 'light';
/** Project theme color overrides (role → #rrggbbaa hex). */
uiThemeColors?: Record<string, string>;
+ /**
+ * Install physics even when the shipped scene shows no bodies — a project
+ * that spawns them from script (Project Settings → Physics → Enabled).
+ * Absent ⇒ physics installs only when a scene actually uses it.
+ */
+ physicsEnabled?: boolean;
+ /** The physics world the project declared: gravity, solver, collision matrix.
+ * Absent ⇒ the engine's own defaults. */
+ physicsConfig?: PhysicsPluginConfig;
+ /** Project mixer state: bus volumes, custom buses, effects, duck rules.
+ * Absent ⇒ the default mix. */
+ audioConfig?: AudioProjectConfig;
/** 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 };
@@ -104,6 +119,57 @@ export function registerPackagedSideModules(config: Pick<PackagedGameConfig, 'si
}
}
+/**
+ * The app options a packaged config declares — everything an App must be built
+ * WITH (shaders compile against the colour space; the layer masks are renderer
+ * state set before the first frame).
+ *
+ * Every host projected these by hand and each list was a chance to miss one: the
+ * web host was still building its App without the 2.5D depth mask after the
+ * export had started shipping it, so a shipped game could carry the setting and
+ * ignore it. One projection, so a field added to the config reaches every realm
+ * that spreads it.
+ */
+export function packagedAppOptions(
+ config: Pick<PackagedGameConfig, 'ySortLayers' | 'depthLayers' | 'colorSpace' | 'screenFit'>,
+): {
+ ySortLayers?: number;
+ depthLayers?: number;
+ colorSpace?: 'gamma' | 'linear';
+ screenFit?: PackagedGameConfig['screenFit'];
+} {
+ return {
+ ySortLayers: config.ySortLayers,
+ depthLayers: config.depthLayers,
+ colorSpace: config.colorSpace,
+ screenFit: config.screenFit,
+ };
+}
+
+/**
+ * The {@link initRuntime} arguments a packaged config declares — everything
+ * applied to a LIVE app rather than baked into its construction. The twin of
+ * {@link packagedAppOptions}; between them a host names the config once.
+ */
+export function packagedRuntimeInit(
+ config: Pick<PackagedGameConfig,
+ 'physicsEnabled' | 'physicsConfig' | 'audioConfig' | 'uiTheme' | 'uiThemeColors'>,
+): {
+ physicsEnabled?: boolean;
+ physicsConfig?: PhysicsPluginConfig;
+ audioConfig?: AudioProjectConfig;
+ uiTheme?: 'light';
+ uiThemeOverrides?: ThemeOverrides;
+} {
+ return {
+ physicsEnabled: config.physicsEnabled,
+ physicsConfig: config.physicsConfig,
+ audioConfig: config.audioConfig,
+ uiTheme: config.uiTheme,
+ uiThemeOverrides: parseThemeOverrides(config.uiThemeColors),
+ };
+}
+
export function catalogFromManifest(manifest: AddressableManifest): Catalog | undefined {
const entries: Record<string, CatalogEntry> = {};
for (const group of Object.values(manifest.groups)) {
diff --git a/sdk/src/runtime/playableRuntime.ts b/sdk/src/runtime/playableRuntime.ts
index 9785cbe2b..2545c8c53 100644
--- a/sdk/src/runtime/playableRuntime.ts
+++ b/sdk/src/runtime/playableRuntime.ts
@@ -18,7 +18,7 @@ import type { ThemeOverrides } from '../ui';
import type { RuntimeAssetSource } from './runtimeAssets';
import { EmbeddedBackend } from '../asset/Backend';
import { ManifestModel, type AddressableManifest } from '../asset/AddressableManifest';
-import type { Vec2 } from '../types';
+import type { PhysicsPluginConfig } from '../physics/PhysicsTypes';
import type { SceneData } from '../scene/scene';
import { Audio } from '../audio/Audio';
import { VideoPlayer } from '../video/VideoAPI';
@@ -38,7 +38,13 @@ export interface PlayableRuntimeConfig {
assetPathMap?: Record<string, string>;
scenes: Array<{ name: string; data: SceneData }>;
firstScene: string;
- physicsConfig?: { gravity?: Vec2; fixedTimestep?: number; subStepCount?: number };
+ /** Install physics even when the scene shows no bodies — a project that
+ * spawns them from script (Project Settings → Physics → Enabled). */
+ physicsEnabled?: boolean;
+ /** The physics world the project declared: gravity, solver, collision matrix.
+ * The FULL config, not a three-field subset: a collision matrix that reached
+ * Play and not a shipped build is a game that only collides in rehearsal. */
+ physicsConfig?: PhysicsPluginConfig;
/** Project-declared UI theme; 'light' re-skins ThemeStyle-tagged widgets at boot. */
uiTheme?: 'dark' | 'light';
/** Project-declared theme token overrides (partial re-skin over the base). */
@@ -146,6 +152,7 @@ export async function initPlayableRuntime(config: PlayableRuntimeConfig): Promis
source,
scenes,
firstScene,
+ physicsEnabled: config.physicsEnabled,
physicsConfig: config.physicsConfig,
uiTheme: config.uiTheme,
uiThemeOverrides: config.uiThemeOverrides,