Skip to content

Documentation / @debuffjp/dev / DevSession

Class: DevSession ​

Defined in: dev/src/session.ts:245

Shared dev state for a game: pause/step/speed, frame recording, an activity log and human notes. The overlay, dev hooks and the agent link all use the same session.

Properties ​

activity ​

readonly activity: Activity[] = []

Defined in: dev/src/session.ts:247


agentLastSeenAt ​

agentLastSeenAt: number = Number.NEGATIVE_INFINITY

Defined in: dev/src/session.ts:291

performance.now() of the last agent action (agent link); -Infinity if never.


agentsAttached ​

agentsAttached: number = 0

Defined in: dev/src/session.ts:381

Agents holding an attach connection through the dev server (agent link).


clips ​

readonly clips: DevClips

Defined in: dev/src/session.ts:301

Rolling clip recording (off until turned on), for devlogs and press kits.


errors ​

readonly errors: ExplainedError[] = []

Defined in: dev/src/session.ts:254

Uncaught errors, unhandled rejections and loop errors, explained and de-duplicated (max 50).


eventCounts ​

readonly eventCounts: Record<string, number> = {}

Defined in: dev/src/session.ts:269

How many times the game emitted each event (game.emit) since load.


events ​

readonly events: GameEventRecord[] = []

Defined in: dev/src/session.ts:271

The latest game events with their tick and detail (max 200).


game ​

readonly game: Game

Defined in: dev/src/session.ts:304


notes ​

readonly notes: Note[] = []

Defined in: dev/src/session.ts:248


offscreen ​

readonly offscreen: OffscreenSampler

Defined in: dev/src/session.ts:299

Counts sprites drawn outside the view, one frame in sixty.


pauseOnSpikeMs ​

pauseOnSpikeMs: number = 0

Defined in: dev/src/session.ts:289

Pause automatically when a frame exceeds this many milliseconds (0 = off).


profiler ​

readonly profiler: Profiler

Defined in: dev/src/session.ts:297

myaku: hitches explained (profile()), with debuff's update and render as spans.


recorder ​

readonly recorder: FrameRecorder

Defined in: dev/src/session.ts:246


recording ​

recording: InputRecording | undefined

Defined in: dev/src/session.ts:250

Input recorded since page load, for replays (present once attachInput is called).


typeErrors ​

typeErrors: TypeDiagnostic[] = []

Defined in: dev/src/session.ts:256

Type errors from the dev server's last check, replaced on every check. Empty when type-checking is off.

Accessors ​

agentConnected ​

Get Signature ​

get agentConnected(): boolean

Defined in: dev/src/session.ts:376

An agent acted on this game in the last 30 seconds.

Returns ​

boolean


paused ​

Get Signature ​

get paused(): boolean

Defined in: dev/src/session.ts:371

Returns ​

boolean


pausedBy ​

Get Signature ​

get pausedBy(): string | undefined

Defined in: dev/src/session.ts:276

Who paused the game, or undefined while it's started. Follows the game loop: "game" when game code called game.stop() itself, and undefined again as soon as anything calls game.start().

Returns ​

string | undefined

Methods ​

agentSeen() ​

agentSeen(): void

Defined in: dev/src/session.ts:394

Returns ​

void


attachInput() ​

attachInput(input): void

Defined in: dev/src/session.ts:425

Start recording this input for replays. Idempotent.

Parameters ​

input ​

DrivableInput

Returns ​

void


changed() ​

changed(): void

Defined in: dev/src/session.ts:603

Returns ​

void


checkpoint() ​

checkpoint(): Checkpoint

Defined in: dev/src/session.ts:430

The game's state now, hashed part by part (see Checkpoint).

Returns ​

Checkpoint


clearErrors() ​

clearErrors(): void

Defined in: dev/src/session.ts:584

Forget recorded errors (after fixing them).

Returns ​

void


keepForReload() ​

keepForReload(): void

Defined in: dev/src/session.ts:464

Called just before the dev server reloads the page for a code change: save the session so the new code can replay it to this same tick (state-preserving reload). Running games keep running.

Returns ​

void


known() ​

known(): Replay | undefined

Defined in: dev/src/session.ts:439

Everything known about this session: the pre-rewind timeline while you're still parked where a rewind left you, otherwise what was actually played (any new tick or input branches off the old timeline).

Returns ​

Replay | undefined


log() ​

log(who, action, detail?, undo?): void

Defined in: dev/src/session.ts:589

Parameters ​

who ​

string

action ​

string

detail? ​

string

undo? ​

() => void

Returns ​

void


note() ​

note(text): Note

Defined in: dev/src/session.ts:537

Flag the current moment with a note for an agent to pick up.

Parameters ​

text ​

string

Returns ​

Note


pause() ​

pause(who?, detail?): void

Defined in: dev/src/session.ts:401

Parameters ​

who? ​

string = "you"

detail? ​

string

Returns ​

void


release() ​

release(): void

Defined in: dev/src/session.ts:356

Returns ​

void


restore() ​

restore(request, target): void

Defined in: dev/src/session.ts:472

Finish a rewind or a code reload after the page loads again (see rewind and keepForReload).

Parameters ​

request ​

RewindRequest

target ​

ReplayTarget

Returns ​

void


resume() ​

resume(who?): void

Defined in: dev/src/session.ts:409

Parameters ​

who? ​

string = "you"

Returns ​

void


rewind() ​

rewind(tick): void

Defined in: dev/src/session.ts:452

Go back (or forward, within the known session) to tick: the page reloads and replays its inputs to that tick, so the game's state is exactly what it was, then stays paused there.

Parameters ​

tick ​

number

Returns ​

void


setAgentsAttached() ​

setAgentsAttached(n): void

Defined in: dev/src/session.ts:384

Update attached agents from the dev server; logs connects and disconnects.

Parameters ​

n ​

number

Returns ​

void


setParam() ​

setParam(group, key, value, who?): void

Defined in: dev/src/session.ts:527

Set a param and log it with an undo that restores the previous value.

Parameters ​

group ​

string

key ​

string

value ​

ParamValue

who? ​

string = "you"

Returns ​

void


setSpeed() ​

setSpeed(scale, who?): void

Defined in: dev/src/session.ts:519

Parameters ​

scale ​

number

who? ​

string = "you"

Returns ​

void


step() ​

step(n?, who?): void

Defined in: dev/src/session.ts:418

Advance exactly n fixed steps (pauses first, so the result stays put).

Parameters ​

n? ​

number = 1

who? ​

string = "you"

Returns ​

void


subscribe() ​

subscribe(fn): () => void

Defined in: dev/src/session.ts:596

Subscribe to state changes (pause, log, notes). Returns an unsubscribe function.

Parameters ​

fn ​

() => void

Returns ​

() => void


acquire() ​

static acquire(game): DevSession

Defined in: dev/src/session.ts:346

The session for game, created on first use. Call release() when done.

Parameters ​

game ​

Game

Returns ​

DevSession