App
Defined in: app/app.ts:156
Accessors
Section titled “Accessors”compiledSystemCount
Section titled “compiledSystemCount”Get Signature
Section titled “Get Signature”get compiledSystemCount():
number
Defined in: app/app.ts:1072
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.
Returns
Section titled “Returns”number
compiledSystems
Section titled “compiledSystems”Get Signature
Section titled “Get Signature”get compiledSystems():
object
Defined in: app/app.ts:819
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.
Returns
Section titled “Returns”object
readonlycalls:number
installed
Section titled “installed”
readonlyinstalled: readonlystring[]
isPhysicsReady
Section titled “isPhysicsReady”Get Signature
Section titled “Get Signature”get isPhysicsReady():
boolean
Defined in: app/app.ts:708
Returns
Section titled “Returns”boolean
pipeline
Section titled “pipeline”Get Signature
Section titled “Get Signature”get pipeline():
RenderPipeline|null
Defined in: app/app.ts:683
Returns
Section titled “Returns”RenderPipeline | null
sideModules
Section titled “sideModules”Get Signature
Section titled “Get Signature”get sideModules():
SideModuleHost|null
Defined in: app/app.ts:269
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.
Returns
Section titled “Returns”SideModuleHost | null
spineInitPromise
Section titled “spineInitPromise”Get Signature
Section titled “Get Signature”get spineInitPromise():
Promise<unknown> |undefined
Defined in: app/app.ts:691
Returns
Section titled “Returns”Promise<unknown> | undefined
Set Signature
Section titled “Set Signature”set spineInitPromise(
p):void
Defined in: app/app.ts:695
Parameters
Section titled “Parameters”Promise<unknown> | undefined
Returns
Section titled “Returns”void
subsystems
Section titled “subsystems”Get Signature
Section titled “Get Signature”get subsystems():
SubsystemRegistry
Defined in: app/app.ts:262
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.
Returns
Section titled “Returns”Get Signature
Section titled “Get Signature”get world():
World
Defined in: app/app.ts:717
Returns
Section titled “Returns”Methods
Section titled “Methods”addEvent()
Section titled “addEvent()”addEvent<
T>(event):this
Defined in: app/app.ts:368
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”EventDef<T>
Returns
Section titled “Returns”this
addPlugin()
Section titled “addPlugin()”addPlugin(
plugin):this
Defined in: app/app.ts:285
Parameters
Section titled “Parameters”plugin
Section titled “plugin”Returns
Section titled “Returns”this
addPlugins()
Section titled “addPlugins()”addPlugins(
plugins):this
Defined in: app/app.ts:277
Parameters
Section titled “Parameters”plugins
Section titled “plugins”Plugin[]
Returns
Section titled “Returns”this
addStartupSystem()
Section titled “addStartupSystem()”addStartupSystem(
system):this
Defined in: app/app.ts:487
Parameters
Section titled “Parameters”system
Section titled “system”Returns
Section titled “Returns”this
addSystem()
Section titled “addSystem()”addSystem(
system):this
Defined in: app/app.ts:457
Parameters
Section titled “Parameters”system
Section titled “system”Returns
Section titled “Returns”this
addSystemSet()
Section titled “addSystemSet()”addSystemSet(
set):this
Defined in: app/app.ts:611
Shortcut for addSystemSetToSchedule(Schedule.Update, set).
Parameters
Section titled “Parameters”Returns
Section titled “Returns”this
addSystemSetToSchedule()
Section titled “addSystemSetToSchedule()”addSystemSetToSchedule(
schedule,set):this
Defined in: app/app.ts:573
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.
Parameters
Section titled “Parameters”schedule
Section titled “schedule”Returns
Section titled “Returns”this
addSystemToSchedule()
Section titled “addSystemToSchedule()”addSystemToSchedule(
schedule,system,options?):this
Defined in: app/app.ts:416
Register system onto schedule, adding ordering to its declared edges.
profileDomain attributes systems registered after an async plugin build
returns; otherwise the current build context supplies it.
Parameters
Section titled “Parameters”schedule
Section titled “schedule”system
Section titled “system”options?
Section titled “options?”profileDomain?
Section titled “profileDomain?”string
runAfter?
Section titled “runAfter?”string[]
runBefore?
Section titled “runBefore?”string[]
runIf?
Section titled “runIf?”Returns
Section titled “Returns”this
enableStats()
Section titled “enableStats()”enableStats():
this
Defined in: app/app.ts:899
Returns
Section titled “Returns”this
getEntityCount()
Section titled “getEntityCount()”getEntityCount():
number
Defined in: app/app.ts:1002
Returns
Section titled “Returns”number
getFixedTimestep()
Section titled “getFixedTimestep()”getFixedTimestep():
number
Defined in: app/app.ts:836
The fixed-update timestep (seconds) — the FixedUpdate / physics cadence.
Returns
Section titled “Returns”number
getFrameCosts()
Section titled “getFrameCosts()”getFrameCosts():
FrameCosts|null
Defined in: app/app.ts:938
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.
Returns
Section titled “Returns”FrameCosts | null
getFrameScopes()
Section titled “getFrameScopes()”getFrameScopes():
ReadonlyMap<string,number> |null
Defined in: app/app.ts:926
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.
Returns
Section titled “Returns”ReadonlyMap<string, number> | null
getFrameTiming()
Section titled “getFrameTiming()”getFrameTiming():
Readonly<{frameMs:number;seq:number; }> |null
Defined in: app/app.ts:916
Completed frame interval before simulation speed or delta clamping.
Returns
Section titled “Returns”Readonly<{ frameMs: number; seq: number; }> | null
getPhaseTimings()
Section titled “getPhaseTimings()”getPhaseTimings():
ReadonlyMap<string,number> |null
Defined in: app/app.ts:911
Returns
Section titled “Returns”ReadonlyMap<string, number> | null
getPlaySpeed()
Section titled “getPlaySpeed()”getPlaySpeed():
number
Defined in: app/app.ts:891
Returns
Section titled “Returns”number
getPlugin()
Section titled “getPlugin()”getPlugin<
T>(ctor):T|undefined
Defined in: app/app.ts:255
Type Parameters
Section titled “Type Parameters”T extends Plugin
Parameters
Section titled “Parameters”new (…args) => T
Returns
Section titled “Returns”T | undefined
getRegisteredResourceNames()
Section titled “getRegisteredResourceNames()”getRegisteredResourceNames():
string[]
Defined in: app/app.ts:1036
Returns
Section titled “Returns”string[]
getResource()
Section titled “getResource()”getResource<
T>(resource):T
Defined in: app/app.ts:1015
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”resource
Section titled “resource”ResourceDef<T>
Returns
Section titled “Returns”T
getResourceByName()
Section titled “getResourceByName()”getResourceByName(
name):unknown
Defined in: app/app.ts:1023
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”unknown
getResourceChangeTick()
Section titled “getResourceChangeTick()”getResourceChangeTick(
name):number
Defined in: app/app.ts:1031
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”number
getResourceEntries()
Section titled “getResourceEntries()”getResourceEntries(): [
string,unknown][]
Defined in: app/app.ts:1045
Every resource this app holds, as [name, value] — what an inspector
shows. Includes the slots only a read has materialised, which
getRegisteredResourceNames (insert-only) does not.
Returns
Section titled “Returns”[string, unknown][]
getSystemTimings()
Section titled “getSystemTimings()”getSystemTimings():
ReadonlyMap<string,number> |null
Defined in: app/app.ts:907
Returns
Section titled “Returns”ReadonlyMap<string, number> | null
getTargetFrameRate()
Section titled “getTargetFrameRate()”getTargetFrameRate():
number
Defined in: app/app.ts:887
Returns
Section titled “Returns”number
hasResource()
Section titled “hasResource()”hasResource<
T>(resource):boolean
Defined in: app/app.ts:1019
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”resource
Section titled “resource”ResourceDef<T>
Returns
Section titled “Returns”boolean
holdExecution()
Section titled “holdExecution()”holdExecution(): () =>
void
Defined in: app/app.ts:1186
Hold frame execution without changing the game’s own pause state.
Returns
Section titled “Returns”() => void
hotSwapSystems()
Section titled “hotSwapSystems()”hotSwapSystems(
incoming):boolean
Defined in: app/app.ts:504
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.
Parameters
Section titled “Parameters”incoming
Section titled “incoming”readonly object[]
Returns
Section titled “Returns”boolean
insertResource()
Section titled “insertResource()”insertResource<
T>(resource,value):this
Defined in: app/app.ts:1010
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”resource
Section titled “resource”ResourceDef<T>
T
Returns
Section titled “Returns”this
installCompiledSystems()
Section titled “installCompiledSystems()”installCompiledSystems(
source,manifest):Promise<number>
Defined in: app/app.ts:1082
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.
Parameters
Section titled “Parameters”source
Section titled “source”string | BufferSource
manifest
Section titled “manifest”Returns
Section titled “Returns”Promise<number>
isExecutionHeld()
Section titled “isExecutionHeld()”isExecutionHeld():
boolean
Defined in: app/app.ts:1213
Returns
Section titled “Returns”boolean
isPaused()
Section titled “isPaused()”isPaused():
boolean
Defined in: app/app.ts:869
Returns
Section titled “Returns”boolean
measureFrameScope()
Section titled “measureFrameScope()”measureFrameScope<
T>(name,fn,options?):T
Defined in: app/app.ts:969
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.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”string
() => T
options?
Section titled “options?”remainder?
Section titled “remainder?”Returns
Section titled “Returns”T
onError()
Section titled “onError()”onError(
handler):this
Defined in: app/app.ts:850
Parameters
Section titled “Parameters”handler
Section titled “handler”(error, systemName) => void
Returns
Section titled “Returns”this
onExecutionChange()
Section titled “onExecutionChange()”onExecutionChange(
callback): () =>void
Defined in: app/app.ts:1216
Observe execution holds, including the initial state. Media/timer owners can cooperate here.
Parameters
Section titled “Parameters”callback
Section titled “callback”(held) => void
Returns
Section titled “Returns”() => void
onFrameEnd()
Section titled “onFrameEnd()”onFrameEnd(
fn): () =>void
Defined in: app/app.ts:994
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.
Parameters
Section titled “Parameters”(dtMs) => void
Returns
Section titled “Returns”() => void
onSystemError()
Section titled “onSystemError()”onSystemError(
handler):this
Defined in: app/app.ts:855
Parameters
Section titled “Parameters”handler
Section titled “handler”(error, systemName?) => "pause" | "continue"
Returns
Section titled “Returns”this
onWasmError()
Section titled “onWasmError()”onWasmError(
handler):this
Defined in: app/app.ts:860
Parameters
Section titled “Parameters”handler
Section titled “handler”(error, context) => void
Returns
Section titled “Returns”this
quit()
Section titled “quit()”quit(
options?):void
Defined in: app/app.ts:1374
Parameters
Section titled “Parameters”options?
Section titled “options?”keepRenderer?
Section titled “keepRenderer?”boolean
Returns
Section titled “Returns”void
registerScene()
Section titled “registerScene()”registerScene(
config):this
Defined in: app/app.ts:1053
Parameters
Section titled “Parameters”config
Section titled “config”Returns
Section titled “Returns”this
removeSystem()
Section titled “removeSystem()”removeSystem(
systemId):boolean
Defined in: app/app.ts:615
Parameters
Section titled “Parameters”systemId
Section titled “systemId”symbol
Returns
Section titled “Returns”boolean
run():
Promise<void>
Defined in: app/app.ts:1290
Returns
Section titled “Returns”Promise<void>
scheduleAmbiguities()
Section titled “scheduleAmbiguities()”scheduleAmbiguities(
schedule):Ambiguity[]
Defined in: app/app.ts:1692
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.
Parameters
Section titled “Parameters”schedule
Section titled “schedule”Returns
Section titled “Returns”scheduleBatches()
Section titled “scheduleBatches()”scheduleBatches(
schedule):string[][]
Defined in: app/app.ts:1704
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.
Parameters
Section titled “Parameters”schedule
Section titled “schedule”Returns
Section titled “Returns”string[][]
setFixedTimestep()
Section titled “setFixedTimestep()”setFixedTimestep(
timestep):this
Defined in: app/app.ts:830
Parameters
Section titled “Parameters”timestep
Section titled “timestep”number
Returns
Section titled “Returns”this
setInitialScene()
Section titled “setInitialScene()”setInitialScene(
name):this
Defined in: app/app.ts:1058
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”this
setMaxDeltaTime()
Section titled “setMaxDeltaTime()”setMaxDeltaTime(
v):this
Defined in: app/app.ts:840
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”this
setMaxFixedSteps()
Section titled “setMaxFixedSteps()”setMaxFixedSteps(
v):this
Defined in: app/app.ts:845
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”this
setPaused()
Section titled “setPaused()”setPaused(
paused):void
Defined in: app/app.ts:865
Parameters
Section titled “Parameters”paused
Section titled “paused”boolean
Returns
Section titled “Returns”void
setPipeline()
Section titled “setPipeline()”setPipeline(
pipeline):void
Defined in: app/app.ts:687
Parameters
Section titled “Parameters”pipeline
Section titled “pipeline”Returns
Section titled “Returns”void
setPlaySpeed()
Section titled “setPlaySpeed()”setPlaySpeed(
speed):void
Defined in: app/app.ts:878
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
setSideModules()
Section titled “setSideModules()”setSideModules(
host):void
Defined in: app/app.ts:273
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
setTargetFrameRate()
Section titled “setTargetFrameRate()”setTargetFrameRate(
fps):void
Defined in: app/app.ts:882
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
stepFrame()
Section titled “stepFrame()”stepFrame():
void
Defined in: app/app.ts:873
Returns
Section titled “Returns”void
stepFrames()
Section titled “stepFrames()”stepFrames(
frames?,dt?):Promise<void>
Defined in: app/app.ts:1254
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.
Parameters
Section titled “Parameters”frames?
Section titled “frames?”number = 1
number = ...
Returns
Section titled “Returns”Promise<void>
tick()
Section titled “tick()”tick(
delta):Promise<void>
Defined in: app/app.ts:1174
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”Promise<void>
useCompiledSystems()
Section titled “useCompiledSystems()”useCompiledSystems(
opts):Promise<void>
Defined in: app/app.ts:729
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.
Parameters
Section titled “Parameters”manifest
Section titled “manifest”BufferSource
Returns
Section titled “Returns”Promise<void>
waitForPhysics()
Section titled “waitForPhysics()”waitForPhysics():
Promise<void>
Defined in: app/app.ts:699
Returns
Section titled “Returns”Promise<void>
staticnew():App
Defined in: app/app.ts:247
Returns
Section titled “Returns”App