Skip to content

App

Defined in: app/app.ts:131

get compiledSystemCount(): number

Defined in: app/app.ts:913

How many compiled twins this App runs. Zero unless a build installed some, which is the whole of the mode policy — and the one number that tells a shipped AOT build apart from a shipped interpreted one from outside.

number


get compiledSystems(): object

Defined in: app/app.ts:676

Which systems this App is running compiled, and how many twin calls have happened. installed without calls rising means the module loaded and nothing dispatched to it — which no differential can report, because the closure it replaced computes the same answer.

object

readonly calls: number

readonly installed: readonly string[]


get isPhysicsReady(): boolean

Defined in: app/app.ts:604

boolean


get pipeline(): RenderPipeline | null

Defined in: app/app.ts:579

RenderPipeline | null


get sideModules(): SideModuleHost | null

Defined in: app/app.ts:232

The realm’s optional-native-module acquirer (physics, spine). Physics and spine pull their wasm from here, so a realm wires its transport once (fetch / inlined / WeChat) and every subsystem follows.

SideModuleHost | null


get spineInitPromise(): Promise<unknown> | undefined

Defined in: app/app.ts:587

Promise<unknown> | undefined

set spineInitPromise(p): void

Defined in: app/app.ts:591

Promise<unknown> | undefined

void


get subsystems(): SubsystemRegistry

Defined in: app/app.ts:225

Subsystem lifecycle registry (“which modules loaded/ready/stepping/errored”). Named plugins auto-register in addPlugin; async plugins (physics) drive their own initializing→ready/error transitions.

SubsystemRegistry


get world(): World

Defined in: app/app.ts:613

World

addEvent<T>(event): this

Defined in: app/app.ts:305

T

EventDef<T>

this


addPlugin(plugin): this

Defined in: app/app.ts:248

Plugin

this


addPlugins(plugins): this

Defined in: app/app.ts:240

Plugin[]

this


addStartupSystem(system): this

Defined in: app/app.ts:406

SystemDef

this


addSystem(system): this

Defined in: app/app.ts:376

SystemDef

this


addSystemSet(set): this

Defined in: app/app.ts:526

Shortcut for addSystemSetToSchedule(Schedule.Update, set).

SystemSet

this


addSystemSetToSchedule(schedule, set): this

Defined in: app/app.ts:492

Register every system in set onto schedule. Each member gets the set’s runIf, and the set’s runBefore / runAfter edges on top of any it declared itself; members keep the order they were listed in. Other systems may reference the set’s name in their own ordering, and the scheduler expands those references to every member.

Schedule

SystemSet

this


addSystemToSchedule(schedule, system, options?): this

Defined in: app/app.ts:353

Register system onto schedule. Ordering given here is added to whatever the definition already declared, so a system can carry its own edges and still be constrained further at the registration site.

Schedule

SystemDef

string[]

string[]

RunCondition

this


enableStats(): this

Defined in: app/app.ts:754

this


getEntityCount(): number

Defined in: app/app.ts:852

number


getFixedTimestep(): number

Defined in: app/app.ts:693

The fixed-update timestep (seconds) — the FixedUpdate / physics cadence.

number


getFrameCosts(): FrameCosts | null

Defined in: app/app.ts:788

This frame’s costs with the attribution a profile tree needs: which domain owns each system, which system each scope ran inside. Null when stats are off. Feed to buildFrameProfile, which is where the tree is derived.

FrameCosts | null


getFrameScopes(): ReadonlyMap<string, number> | null

Defined in: app/app.ts:776

Sub-frame CPU scopes recorded this frame via measureFrameScope — the finer breakdown within a single system, keyed by scope name. Null when stats aren’t enabled. Sibling of getSystemTimings / getPhaseTimings; surfaces as the profiler’s js.* rows.

ReadonlyMap<string, number> | null


getPhaseTimings(): ReadonlyMap<string, number> | null

Defined in: app/app.ts:766

ReadonlyMap<string, number> | null


getPlaySpeed(): number

Defined in: app/app.ts:746

number


getPlugin<T>(ctor): T | undefined

Defined in: app/app.ts:218

T extends Plugin

(…args) => T

T | undefined


getRegisteredResourceNames(): string[]

Defined in: app/app.ts:886

string[]


getResource<T>(resource): T

Defined in: app/app.ts:865

T

ResourceDef<T>

T


getResourceByName(name): unknown

Defined in: app/app.ts:873

string

unknown


getResourceChangeTick(name): number

Defined in: app/app.ts:881

string

number


getSystemTimings(): ReadonlyMap<string, number> | null

Defined in: app/app.ts:762

ReadonlyMap<string, number> | null


getTargetFrameRate(): number

Defined in: app/app.ts:742

number


hasResource<T>(resource): boolean

Defined in: app/app.ts:869

T

ResourceDef<T>

boolean


hotSwapSystems(incoming): boolean

Defined in: app/app.ts:423

Hot-swap the project’s (user-authored) system function bodies in place, keeping the live World/Registry/entities — the state-preserving hot-reload fast path (RC10 P3). incoming is the freshly re-imported bundle’s drained systems.

Returns false when the structure changed — a user system was added, removed, or renamed, or a schedule’s user-system count differs — because the running systems then no longer line up with the new code, so the caller must full-reload instead. Builtin/plugin systems (those with an owning subsystem) are never touched. The match validates fully before mutating, so a rejected swap leaves the scheduler untouched (no torn half-swap). Component identity is stable by name (see component.ts), so the new functions’ queries resolve to the live storage.

readonly object[]

boolean


insertResource<T>(resource, value): this

Defined in: app/app.ts:860

T

ResourceDef<T>

T

this


installCompiledSystems(source, manifest): Promise<number>

Defined in: app/app.ts:923

Install the compiled twins a build produced, and answer how many (docs/REARCH_AOT.md §9). Call it BEFORE any component exists — a twin reads rows in the ENGINE’s memory, and refuses rather than move rows already allocated elsewhere, or trust a module built for other offsets.

string | BufferSource

AotManifest

Promise<number>


isPaused(): boolean

Defined in: app/app.ts:726

boolean


measureFrameScope<T>(name, fn, options?): T

Defined in: app/app.ts:819

Time fn as a named sub-frame scope (accumulated if the name repeats in a frame). A no-op passthrough when stats are off, so shipped games pay only a single branch. Use it to split a heavy system into attributable pieces.

remainder: 'wait' declares that whatever time is left under this scope once its native scopes are subtracted is CPU blocked, not work — the swapchain block a GPU submit absorbs, or an await. The profiler keeps such time out of every cost total instead of reporting it as a hotspot.

T

string

() => T

ScopeRemainder

T


onError(handler): this

Defined in: app/app.ts:707

(error, systemName) => void

this


onFrameEnd(fn): () => void

Defined in: app/app.ts:844

Observe the end of every frame, once its systems have run and its timings are final. Returns a disposer.

A broadcast, not a slot: a recorder and a game’s own budget alarm both watch without either taking the hook from the other.

(dtMs) => void

() => void


onSystemError(handler): this

Defined in: app/app.ts:712

(error, systemName?) => "pause" | "continue"

this


onWasmError(handler): this

Defined in: app/app.ts:717

(error, context) => void

this


quit(options?): void

Defined in: app/app.ts:1084

boolean

void


registerScene(config): this

Defined in: app/app.ts:894

SceneConfig

this


removeSystem(systemId): boolean

Defined in: app/app.ts:530

symbol

boolean


run(): Promise<void>

Defined in: app/app.ts:1038

Promise<void>


scheduleAmbiguities(schedule): Ambiguity[]

Defined in: app/app.ts:1365

Pairs of systems in schedule that touch the same data with nothing saying which runs first, so their order is whatever registration and the sort happened to produce.

Schedule

Ambiguity[]


scheduleBatches(schedule): string[][]

Defined in: app/app.ts:1377

schedule grouped into batches that could run at the same time — how much of it is inherently sequential. A measurement: the schedule starts systems in sorted order, overlapping only what awaits. See parallelBatches.

Schedule

string[][]


setFixedTimestep(timestep): this

Defined in: app/app.ts:687

number

this


setInitialScene(name): this

Defined in: app/app.ts:899

string

this


setMaxDeltaTime(v): this

Defined in: app/app.ts:697

number

this


setMaxFixedSteps(v): this

Defined in: app/app.ts:702

number

this


setPaused(paused): void

Defined in: app/app.ts:722

boolean

void


setPipeline(pipeline): void

Defined in: app/app.ts:583

RenderPipeline

void


setPlaySpeed(speed): void

Defined in: app/app.ts:734

number

void


setSideModules(host): void

Defined in: app/app.ts:236

SideModuleHost

void


setTargetFrameRate(fps): void

Defined in: app/app.ts:738

number

void


stepFrame(): void

Defined in: app/app.ts:730

void


stepFrames(frames?, dt?): Promise<void>

Defined in: app/app.ts:1015

Advance exactly frames frames of exactly dt seconds, with the rAF loop held off for the duration — “let the game run a bit”, made reproducible.

The loop it replaces is wall-clock and browser-scheduled: a backgrounded tab is throttled to about one frame a second, so an observer that steps by waiting sees a frozen game and concludes the game is broken. Worse, there was no other door — a driver that needed the next 30 frames of simulation had to reach for runFrame_, and reaching for a private method is a thing that keeps working until the day it doesn’t.

A PAUSED app still steps here: advancing frame by frame is exactly what stepping a paused game means. The pause (and the loop) are restored afterwards, with the clock re-based so the first resumed frame is not handed the whole excursion as its delta.

number = 1

number = ...

Promise<void>


tick(delta): Promise<void>

Defined in: app/app.ts:992

number

Promise<void>


useCompiledSystems(opts): Promise<void>

Defined in: app/app.ts:625

Run the compiled twins a build produced instead of the systems’ closures. Call it BEFORE the world has any pooled component: the rows must be in the memory the module reads. Refuses rather than degrades — a module built for other offsets reads a different field, which is not an error.

AotHost

AotManifest

BufferSource

Promise<void>


waitForPhysics(): Promise<void>

Defined in: app/app.ts:595

Promise<void>


static new(): App

Defined in: app/app.ts:210

App