# Interface: DevHooks

Defined in: [dev/src/index.ts:96](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L96)

The dev inspection and control surface, available as `window.__DEBUFF_DEV__` in dev builds.
Every method takes and returns JSON-serialisable values so browsers, CLIs and agents can call it.

## Properties

### controlled

> `readonly` **controlled**: `boolean`

Defined in: [dev/src/index.ts:99](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L99)

True when the page was opened with `?debuff-scenario`: the loop is stopped and time only advances via `step`.

***

### version

> `readonly` **version**: `2`

Defined in: [dev/src/index.ts:97](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L97)

## Methods

### capture()

> **capture**(`fit?`, `background?`): `string`

Defined in: [dev/src/index.ts:174](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L174)

PNG data URL of the current frame. With `fit`, the frame is letterboxed into that size: `"social"`
(1200×675, for X and Bluesky posts and link cards) or `[width, height]`, on `background` (default black).

#### Parameters

##### fit?

\[`number`, `number`\] \| `"social"`

##### background?

`string`

#### Returns

`string`

***

### checkpoint()

> **checkpoint**(): `object`

Defined in: [dev/src/index.ts:145](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L145)

The game's state now, hashed part by part, to compare with a replay's `checkpoint` steps.

#### Returns

`object`

##### checkpoint

> **checkpoint**: [`Checkpoint`](../type-aliases/Checkpoint.md)

##### tick

> **tick**: `number`

***

### clips()

> **clips**(`on?`): [`ClipStatus`](ClipStatus.md)

Defined in: [dev/src/index.ts:179](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L179)

Turn rolling clip recording on or off (no argument: just report). While on, `saveClip` keeps the last
few seconds. It runs two video encoders, so leave it off when you aren't capturing.

#### Parameters

##### on?

`boolean`

#### Returns

[`ClipStatus`](ClipStatus.md)

***

### command()

> **command**(`name`, ...`args`): `unknown`

Defined in: [dev/src/index.ts:194](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L194)

Run a game command, e.g. to start a scenario at a checkpoint. Recorded in replays.

#### Parameters

##### name

`string`

##### args

...`unknown`[]

#### Returns

`unknown`

***

### commands()

> **commands**(): `string`[]

Defined in: [dev/src/index.ts:192](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L192)

Names of the commands the game registered with `devTools({ commands })`.

#### Returns

`string`[]

***

### errors()

> **errors**(): [`ExplainedError`](ExplainedError.md)[]

Defined in: [dev/src/index.ts:164](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L164)

Runtime errors since load, explained: `kind` says whose problem it is ("your-code", "debuff-usage",
"debuff-bug", "outside"), `where` points at the game's source, `hint` suggests a next step. Repeats are counted.

#### Returns

[`ExplainedError`](ExplainedError.md)[]

***

### events()

> **events**(`sinceTick?`): [`GameEventRecord`](GameEventRecord.md)[]

Defined in: [dev/src/index.ts:152](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L152)

The latest game events (`game.emit`), oldest first, optionally only those after `sinceTick`.

#### Parameters

##### sinceTick?

`number`

#### Returns

[`GameEventRecord`](GameEventRecord.md)[]

***

### frames()

> **frames**(`n?`): [`FrameSample`](FrameSample.md)[]

Defined in: [dev/src/index.ts:133](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L133)

The latest `n` frame breakdowns (update/render ms, steps, quads, draw calls, long tasks), oldest first.

#### Parameters

##### n?

`number`

#### Returns

[`FrameSample`](FrameSample.md)[]

***

### keepForReload()

> **keepForReload**(): `void`

Defined in: [dev/src/index.ts:157](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L157)

Save the session for a state-preserving reload (the `debuff dev` client calls this just before a
code change reloads the page). After the reload the new code replays it to the same tick.

#### Returns

`void`

***

### luminance()

> **luminance**(`cols`, `rows`, `region?`): `number`[]

Defined in: [dev/src/index.ts:190](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L190)

The current frame's relative luminance (0 black to 1 white, WCAG), averaged over a `cols` × `rows`
grid, row by row. `region` (`[x, y, w, h]` in logical units) samples part of the screen. For flash
and contrast checks in scenarios.

#### Parameters

##### cols

`number`

##### rows

`number`

##### region?

\[`number`, `number`, `number`, `number`\]

#### Returns

`number`[]

***

### notes()

> **notes**(): [`Note`](Note.md)[]

Defined in: [dev/src/index.ts:159](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L159)

Moments the human flagged in the overlay, with the game state at that tick.

#### Returns

[`Note`](Note.md)[]

***

### pad()

> **pad**(`state`): `void`

Defined in: [dev/src/index.ts:129](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L129)

Feed gamepad state (pressed standard-mapping button indices, left stick axes); `null` = no pad, `undefined` = real pads again.

#### Parameters

##### state

[`PadStep`](PadStep.md) \| `null` \| `undefined`

#### Returns

`void`

***

### params()

> **params**(): `Record`\<`string`, [`ParamDescription`](../../core/interfaces/ParamDescription.md)\>

Defined in: [dev/src/index.ts:130](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L130)

#### Returns

`Record`\<`string`, [`ParamDescription`](../../core/interfaces/ParamDescription.md)\>

***

### pause()

> **pause**(): [`DevState`](DevState.md)

Defined in: [dev/src/index.ts:103](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L103)

#### Returns

[`DevState`](DevState.md)

***

### pointerDown()

> **pointerDown**(`x`, `y`, `kind?`): `void`

Defined in: [dev/src/index.ts:119](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L119)

Press the primary pointer at logical coordinates. `kind` (default `"mouse"`) is what the game sees in
`pointer.kind`: a `"touch"` or `"pen"` press is also a contact in `pointer.touches` (id 1), and a mouse
press is only the primary pointer, so a drag never shows up as both.

#### Parameters

##### x

`number`

##### y

`number`

##### kind?

[`PointerKind`](../type-aliases/PointerKind.md)

#### Returns

`void`

***

### pointerMove()

> **pointerMove**(`x`, `y`): `void`

Defined in: [dev/src/index.ts:120](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L120)

#### Parameters

##### x

`number`

##### y

`number`

#### Returns

`void`

***

### pointerUp()

> **pointerUp**(): `void`

Defined in: [dev/src/index.ts:121](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L121)

#### Returns

`void`

***

### press()

> **press**(`code`): `void`

Defined in: [dev/src/index.ts:110](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L110)

Hold a key (`KeyboardEvent.code`), or the right or middle mouse button as `"PointerRight"` / `"PointerMiddle"`.

#### Parameters

##### code

`string`

#### Returns

`void`

***

### profile()

> **profile**(): `Report` & `object`

Defined in: [dev/src/index.ts:138](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L138)

myaku's report: frame-time percentiles, hitches per minute, and the worst hitches explained (cause,
confidence, the script to look at, a hint), with debuff's update and render as spans.

#### Returns

`Report` & `object`

***

### reducedMotion()

> **reducedMotion**(`value`): [`DevState`](DevState.md)

Defined in: [dev/src/index.ts:108](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L108)

Force `game.reducedMotion` on or off; `null` restores what it was. Returns the new state.

#### Parameters

##### value

`boolean` \| `null`

#### Returns

[`DevState`](DevState.md)

***

### release()

> **release**(`code`): `void`

Defined in: [dev/src/index.ts:111](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L111)

#### Parameters

##### code

`string`

#### Returns

`void`

***

### replay()

> **replay**(`toTick?`): [`Replay`](Replay.md)

Defined in: [dev/src/index.ts:143](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L143)

Everything played since page load (keys, pointer, param changes) up to `toTick` (default: now), as a
scenario that replays it exactly. Pass a note's `tick` to get the session leading up to that note.

#### Parameters

##### toTick?

`number`

#### Returns

[`Replay`](Replay.md)

***

### resume()

> **resume**(): [`DevState`](DevState.md)

Defined in: [dev/src/index.ts:104](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L104)

#### Returns

[`DevState`](DevState.md)

***

### rewind()

> **rewind**(`tick`): `void`

Defined in: [dev/src/index.ts:150](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L150)

Reload and replay this session's inputs to `tick`, then pause there: the exact state at that moment.
Within the known session you can go forward again, until new play branches off.

#### Parameters

##### tick

`number`

#### Returns

`void`

***

### saveClip()

> **saveClip**(`name?`): `Promise`\<[`SavedCapture`](SavedCapture.md)\>

Defined in: [dev/src/index.ts:184](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L184)

Save the last few seconds as a video in `.debuff/captures/` (through `debuff dev`; downloaded otherwise).
MP4 where the browser can record it, else WebM. Needs `clips(true)` first.

#### Parameters

##### name?

`string`

#### Returns

`Promise`\<[`SavedCapture`](SavedCapture.md)\>

***

### setParam()

> **setParam**(`group`, `key`, `value`): `void`

Defined in: [dev/src/index.ts:131](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L131)

#### Parameters

##### group

`string`

##### key

`string`

##### value

[`ParamValue`](../../core/type-aliases/ParamValue.md)

#### Returns

`void`

***

### speed()

> **speed**(`scale`): `void`

Defined in: [dev/src/index.ts:106](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L106)

Simulation speed multiplier (1 = normal).

#### Parameters

##### scale

`number`

#### Returns

`void`

***

### state()

> **state**(): [`DevState`](DevState.md)

Defined in: [dev/src/index.ts:102](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L102)

#### Returns

[`DevState`](DevState.md)

***

### step()

> **step**(`steps?`): [`DevState`](DevState.md)

Defined in: [dev/src/index.ts:101](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L101)

Advance `steps` fixed simulation steps (pausing first) and return the new state.

#### Parameters

##### steps?

`number`

#### Returns

[`DevState`](DevState.md)

***

### tap()

> **tap**(`x`, `y`, `kind?`): `void`

Defined in: [dev/src/index.ts:113](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L113)

Press and release the primary pointer at logical coordinates across one step, as a mouse unless `kind` says otherwise.

#### Parameters

##### x

`number`

##### y

`number`

##### kind?

[`PointerKind`](../type-aliases/PointerKind.md)

#### Returns

`void`

***

### touchDown()

> **touchDown**(`id`, `x`, `y`, `kind?`): `void`

Defined in: [dev/src/index.ts:125](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L125)

Start a touch contact `id` at logical coordinates (a finger, or `"pen"`). The first contact also presses the primary pointer.

#### Parameters

##### id

`number`

##### x

`number`

##### y

`number`

##### kind?

`"pen"` \| `"touch"`

#### Returns

`void`

***

### touchMove()

> **touchMove**(`id`, `x`, `y`): `void`

Defined in: [dev/src/index.ts:126](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L126)

#### Parameters

##### id

`number`

##### x

`number`

##### y

`number`

#### Returns

`void`

***

### touchUp()

> **touchUp**(`id`): `void`

Defined in: [dev/src/index.ts:127](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L127)

#### Parameters

##### id

`number`

#### Returns

`void`

***

### typeErrors()

> **typeErrors**(): [`TypeDiagnostic`](TypeDiagnostic.md)[]

Defined in: [dev/src/index.ts:169](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L169)

Type errors from the dev server's last type-check (`typecheck: true` in debuff.config), replaced on
every check after a save. Empty when type-checking is off or the code type-checks.

#### Returns

[`TypeDiagnostic`](TypeDiagnostic.md)[]

***

### wheel()

> **wheel**(`dy`, `dx?`): `void`

Defined in: [dev/src/index.ts:123](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/dev/src/index.ts#L123)

Scroll the wheel by `dy` (and `dx`) CSS pixels this step: positive scrolls down / right.

#### Parameters

##### dy

`number`

##### dx?

`number`

#### Returns

`void`
