Appearance
Devtools API
Signatures and behavior for @idlekitjs/devtools.
Private package
@idlekitjs/devtools is private and not published to npm; it is only available inside the monorepo.
Imports
ts
import { devtools, DevMetrics } from "@idlekitjs/devtools";
import type { DevtoolsExtension, DevtoolsOptions } from "@idlekitjs/devtools";devtools
ts
function devtools<T extends object>(
options?: DevtoolsOptions<T>,
): DevtoolsExtension<T>;Returns an Extension<T> installable with engine.use(...).
ts
interface DevtoolsOptions<T extends object> {
save?: SaveManager<T>;
dispose?: () => void;
stats?: (state: T) => Record<string, unknown>;
hotkey?: string;
open?: boolean;
refreshMs?: number;
}| Option | Behavior |
|---|---|
save | Enables overlay save and wipe actions. |
dispose | Called before wiping data. Useful for stopping loops and lifecycle saves. |
stats | Extra rows, recomputed on each refresh. |
hotkey | KeyboardEvent.key that toggles the overlay. Default: backtick. |
open | Start expanded. Default: true. |
refreshMs | Text refresh interval in milliseconds. Default: 200. |
The extension mounts a browser overlay when document exists and removes it on teardown. Outside the browser, setup does not mount UI.
DevtoolsExtension
ts
interface DevtoolsExtension<T extends object> extends Extension<T> {
readonly metrics: DevMetrics;
}The extension records one tick in update and one frame in render.
DevMetrics
ts
class DevMetrics {
recordTick(): void;
recordFrame(nowMs: number): void;
readonly fps: number;
readonly tickRate: number;
readonly totalTicks: number;
}fps is the smoothed render frame rate. tickRate is the measured simulation tick rate. totalTicks is the total simulation ticks recorded since start.