App
Defined in: app/app.ts:131
Accessors
Section titled “Accessors”compiledSystemCount
Section titled “compiledSystemCount”Get Signature
Section titled “Get Signature”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.
Returns
Section titled “Returns”number
compiledSystems
Section titled “compiledSystems”Get Signature
Section titled “Get Signature”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.
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:604
Returns
Section titled “Returns”boolean
pipeline
Section titled “pipeline”Get Signature
Section titled “Get Signature”get pipeline():
RenderPipeline|null
Defined in: app/app.ts:579
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: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.
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:587
Returns
Section titled “Returns”Promise<unknown> | undefined
Set Signature
Section titled “Set Signature”set spineInitPromise(
p):void
Defined in: app/app.ts:591
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: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.
Returns
Section titled “Returns”Get Signature
Section titled “Get Signature”get world():
World
Defined in: app/app.ts:613
Returns
Section titled “Returns”Methods
Section titled “Methods”addEvent()
Section titled “addEvent()”addEvent<
T>(event):this
Defined in: app/app.ts:305
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:248
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:240
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:406
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:376
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:526
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: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.
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: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.
Parameters
Section titled “Parameters”schedule
Section titled “schedule”system
Section titled “system”options?
Section titled “options?”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:754
Returns
Section titled “Returns”this
getEntityCount()
Section titled “getEntityCount()”getEntityCount():
number
Defined in: app/app.ts:852
Returns
Section titled “Returns”number
getFixedTimestep()
Section titled “getFixedTimestep()”getFixedTimestep():
number
Defined in: app/app.ts:693
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: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.
Returns
Section titled “Returns”FrameCosts | null
getFrameScopes()
Section titled “getFrameScopes()”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.
Returns
Section titled “Returns”ReadonlyMap<string, number> | null
getPhaseTimings()
Section titled “getPhaseTimings()”getPhaseTimings():
ReadonlyMap<string,number> |null
Defined in: app/app.ts:766
Returns
Section titled “Returns”ReadonlyMap<string, number> | null
getPlaySpeed()
Section titled “getPlaySpeed()”getPlaySpeed():
number
Defined in: app/app.ts:746
Returns
Section titled “Returns”number
getPlugin()
Section titled “getPlugin()”getPlugin<
T>(ctor):T|undefined
Defined in: app/app.ts:218
Type Parameters
Section titled “Type Parameters”T extends Plugin
Parameters
Section titled “Parameters”(…args) => T
Returns
Section titled “Returns”T | undefined
getRegisteredResourceNames()
Section titled “getRegisteredResourceNames()”getRegisteredResourceNames():
string[]
Defined in: app/app.ts:886
Returns
Section titled “Returns”string[]
getResource()
Section titled “getResource()”getResource<
T>(resource):T
Defined in: app/app.ts:865
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:873
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”unknown
getResourceChangeTick()
Section titled “getResourceChangeTick()”getResourceChangeTick(
name):number
Defined in: app/app.ts:881
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”number
getSystemTimings()
Section titled “getSystemTimings()”getSystemTimings():
ReadonlyMap<string,number> |null
Defined in: app/app.ts:762
Returns
Section titled “Returns”ReadonlyMap<string, number> | null
getTargetFrameRate()
Section titled “getTargetFrameRate()”getTargetFrameRate():
number
Defined in: app/app.ts:742
Returns
Section titled “Returns”number
hasResource()
Section titled “hasResource()”hasResource<
T>(resource):boolean
Defined in: app/app.ts:869
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”resource
Section titled “resource”ResourceDef<T>
Returns
Section titled “Returns”boolean
hotSwapSystems()
Section titled “hotSwapSystems()”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.
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:860
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: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.
Parameters
Section titled “Parameters”source
Section titled “source”string | BufferSource
manifest
Section titled “manifest”Returns
Section titled “Returns”Promise<number>
isPaused()
Section titled “isPaused()”isPaused():
boolean
Defined in: app/app.ts:726
Returns
Section titled “Returns”boolean
measureFrameScope()
Section titled “measureFrameScope()”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.
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:707
Parameters
Section titled “Parameters”handler
Section titled “handler”(error, systemName) => void
Returns
Section titled “Returns”this
onFrameEnd()
Section titled “onFrameEnd()”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.
Parameters
Section titled “Parameters”(dtMs) => void
Returns
Section titled “Returns”() => void
onSystemError()
Section titled “onSystemError()”onSystemError(
handler):this
Defined in: app/app.ts:712
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:717
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:1084
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:894
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:530
Parameters
Section titled “Parameters”systemId
Section titled “systemId”symbol
Returns
Section titled “Returns”boolean
run():
Promise<void>
Defined in: app/app.ts:1038
Returns
Section titled “Returns”Promise<void>
scheduleAmbiguities()
Section titled “scheduleAmbiguities()”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.
Parameters
Section titled “Parameters”schedule
Section titled “schedule”Returns
Section titled “Returns”scheduleBatches()
Section titled “scheduleBatches()”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.
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:687
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:899
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”this
setMaxDeltaTime()
Section titled “setMaxDeltaTime()”setMaxDeltaTime(
v):this
Defined in: app/app.ts:697
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”this
setMaxFixedSteps()
Section titled “setMaxFixedSteps()”setMaxFixedSteps(
v):this
Defined in: app/app.ts:702
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”this
setPaused()
Section titled “setPaused()”setPaused(
paused):void
Defined in: app/app.ts:722
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:583
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:734
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
setSideModules()
Section titled “setSideModules()”setSideModules(
host):void
Defined in: app/app.ts:236
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
setTargetFrameRate()
Section titled “setTargetFrameRate()”setTargetFrameRate(
fps):void
Defined in: app/app.ts:738
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
stepFrame()
Section titled “stepFrame()”stepFrame():
void
Defined in: app/app.ts:730
Returns
Section titled “Returns”void
stepFrames()
Section titled “stepFrames()”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.
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:992
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”Promise<void>
useCompiledSystems()
Section titled “useCompiledSystems()”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.
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:595
Returns
Section titled “Returns”Promise<void>
staticnew():App
Defined in: app/app.ts:210
Returns
Section titled “Returns”App