@flare-engine/debug 0.4.6 → 0.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { Clock } from "@flare-engine/core";
2
- //#region src/boot-trace.d.ts
3
2
  type BootEntry = {
4
3
  readonly name: string;
5
4
  readonly t: number;
@@ -10,9 +9,7 @@ type BootTraceHandle = {
10
9
  reset(): void;
11
10
  getEntries(): readonly BootEntry[];
12
11
  };
13
- declare function createBootTrace(label?: string): BootTraceHandle;
14
- //#endregion
15
- //#region src/stats.d.ts
12
+ export declare function createBootTrace(label?: string): BootTraceHandle;
16
13
  /** Snapshot of engine stats for a single frame. */
17
14
  interface DebugStats {
18
15
  /** Frames per second (smoothed). */
@@ -32,7 +29,7 @@ interface DebugStats {
32
29
  * StatsTracker — collects and exposes per-frame debug statistics.
33
30
  * Wrap in `__DEV__` checks at the call site for tree-shaking.
34
31
  */
35
- declare class StatsTracker {
32
+ export declare class StatsTracker {
36
33
  /** Current frame stats (read-only snapshot). */
37
34
  readonly stats: DebugStats;
38
35
  /** Update timing stats from the clock. */
@@ -44,8 +41,6 @@ declare class StatsTracker {
44
41
  /** Reset all counters to zero. */
45
42
  reset(): void;
46
43
  }
47
- //#endregion
48
- //#region src/fps-widget.d.ts
49
44
  /**
50
45
  * Formatter for a compact FPS / stats overlay.
51
46
  *
@@ -74,9 +69,7 @@ interface FpsWidgetOptions {
74
69
  msPrecision?: number;
75
70
  }
76
71
  /** Create a new FPS widget formatter. */
77
- declare function createFpsWidget(options?: FpsWidgetOptions): FpsWidget;
78
- //#endregion
79
- //#region src/frame-budget.d.ts
72
+ export declare function createFpsWidget(options?: FpsWidgetOptions): FpsWidget;
80
73
  type FrameBudgetLimits = Record<string, number>;
81
74
  type FrameBudgetSnapshot = Record<string, number>;
82
75
  type FrameBudgetHandle = {
@@ -93,9 +86,7 @@ type FrameBudgetOpts = {
93
86
  onWatchdog?: () => void;
94
87
  debug?: boolean;
95
88
  };
96
- declare function createFrameBudget(opts: FrameBudgetOpts): FrameBudgetHandle;
97
- //#endregion
98
- //#region src/overlay.d.ts
89
+ export declare function createFrameBudget(opts: FrameBudgetOpts): FrameBudgetHandle;
99
90
  /**
100
91
  * DebugOverlay — configuration for debug visualization overlays.
101
92
  * The actual rendering is done by the host (e.g., @flare-engine/react) reading
@@ -143,7 +134,7 @@ type DebugDrawCommand = DebugRect | DebugCircle | DebugLine;
143
134
  * Commands are generated based on active overlay flags, then consumed
144
135
  * by the renderer.
145
136
  */
146
- declare class DebugOverlay {
137
+ export declare class DebugOverlay {
147
138
  /** Active overlay flags. */
148
139
  readonly flags: OverlayFlags;
149
140
  /** Queued debug draw commands for the current frame. */
@@ -167,8 +158,6 @@ declare class DebugOverlay {
167
158
  /** Disable all overlays. */
168
159
  disableAll(): void;
169
160
  }
170
- //#endregion
171
- //#region src/perf-recorder.d.ts
172
161
  type PerfSectionStats = {
173
162
  readonly name: string;
174
163
  readonly count: number;
@@ -205,18 +194,14 @@ type PerfRecorderOpts = {
205
194
  label?: string;
206
195
  ringSize?: number;
207
196
  };
208
- declare function createPerfRecorder(opts?: PerfRecorderOpts): PerfRecorderHandle;
209
- //#endregion
210
- //#region src/perf-output.d.ts
211
- declare const PERF_BENCH_TAG = "[perf-bench]";
212
- declare function emitPerfReport(report: PerfReport): void;
213
- //#endregion
214
- //#region src/time-control.d.ts
197
+ export declare function createPerfRecorder(opts?: PerfRecorderOpts): PerfRecorderHandle;
198
+ export declare const PERF_BENCH_TAG = "[perf-bench]";
199
+ export declare function emitPerfReport(report: PerfReport): void;
215
200
  /**
216
201
  * TimeControl — pause, step-frame, and slow-motion via Clock.timescale.
217
202
  * Wrap in `__DEV__` checks at the call site for tree-shaking.
218
203
  */
219
- declare class TimeControl {
204
+ export declare class TimeControl {
220
205
  private _clock;
221
206
  private _savedTimescale;
222
207
  private _paused;
@@ -246,6 +231,5 @@ declare class TimeControl {
246
231
  /** Set slow-motion multiplier (e.g., 0.5 for half-speed). */
247
232
  setTimescale(scale: number): void;
248
233
  }
249
- //#endregion
250
- export { type BootEntry, type BootTraceHandle, type DebugCircle, type DebugDrawCommand, type DebugLine, DebugOverlay, type DebugRect, type DebugStats, type FpsWidget, type FpsWidgetOptions, type FrameBudgetHandle, type FrameBudgetLimits, type FrameBudgetSnapshot, type OverlayFlags, PERF_BENCH_TAG, type PerfCounterStats, type PerfRecorderHandle, type PerfReport, type PerfSectionStats, StatsTracker, TimeControl, createBootTrace, createFpsWidget, createFrameBudget, createPerfRecorder, emitPerfReport };
234
+ export type { BootEntry, BootTraceHandle, DebugCircle, DebugDrawCommand, DebugLine, DebugRect, DebugStats, FpsWidget, FpsWidgetOptions, FrameBudgetHandle, FrameBudgetLimits, FrameBudgetSnapshot, OverlayFlags, PerfCounterStats, PerfRecorderHandle, PerfReport, PerfSectionStats };
251
235
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/boot-trace.ts","../src/stats.ts","../src/fps-widget.ts","../src/frame-budget.ts","../src/overlay.ts","../src/perf-recorder.ts","../src/perf-output.ts","../src/time-control.ts"],"mappings":";;KAAY;WACD;WACA;;KAGC;EACV,KAAK;EACL;EACA;EACA,uBAAuB;;iBAUT,gBAAgB,iBAAuB;;;;UClBtC;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;cAOW;;WAEF,OAAO;;EAUhB,gBAAgB,aAAa,eAAe,YAAY;;EAQxD,eAAe;;EAKf,aAAa;;EAKb;;;;;;;;;;;;;;UCtCe;;EAEf,OAAO,OAAO;;EAEd;;WAES;;;UAIM;;EAEf;;EAEA;;EAEA;;;iBAIc,gBAAgB,UAAS,mBAAwB;;;KChCrD,oBAAoB;KACpB,sBAAsB;KAEtB;EACV,YAAY;EACZ,eAAe,UAAU;EACzB,eAAe,SAAS;EACxB;EACA;;KAGG;EACH,QAAQ;EACR;EACA;EACA;EACA;;iBAGc,kBAAkB,MAAM,kBAAkB;;;;;;;;;UCbzC;;EAEf;;EAEA;;EAEA;;EAEA;;;UAIe;WACN;EACT;EACA;EACA;EACA;EACA;;UAGe;WACN;EACT;EACA;EACA;EACA;;UAGe;WACN;EACT;EACA;EACA;EACA;EACA;;;KAIU,mBAAmB,YAAY,cAAc;;;;;;cAO5C;;WAEF,OAAO;;UAQR;;MAGJ;;MAKA,qBAAqB;;EAKzB,SAAS,WAAW,WAAW,eAAe,gBAAgB;;EAK9D,WAAW,WAAW,WAAW,gBAAgB;;EAKjD,SAAS,YAAY,YAAY,YAAY,YAAY;;EAKzD;;EAKA,WAAW,YAAY;;EAKvB;;EAQA;;;;KC5GU;WACD;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;KAGC;WACD;WACA;WACA;WACA;WACA;WACA;;KAGC;WACD;WACA;WACA;WACA,mBAAmB;WACnB,mBAAmB;;KAGlB;EACV,aAAa;EACb,WAAW;EACX,YAAY,WAAW;EACvB,SAAS;EACT;;KAoBG;EACH;EACA;;iBAqBc,mBAAmB,OAAM,mBAAwB;;;cC1EpD;iBAEG,eAAe,QAAQ;;;;;;;cCE1B;UACH;UACA;UACA;UACA;cAEI,OAAO;;MAKf;;MAKA;;EAKJ;;EAQA;;EAQA;;;;;EAYA;;;;;;EAUA;;EAOA,aAAa"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/boot-trace.ts","../src/stats.ts","../src/fps-widget.ts","../src/frame-budget.ts","../src/overlay.ts","../src/perf-recorder.ts","../src/perf-output.ts","../src/time-control.ts"],"mappings":";KAAY;WACD;WACA;;KAGC;EACV,KAAK;EACL;EACA;EACA,uBAAuB;;wBAUT,gBAAgB,iBAAuB;;UClBtC;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;qBAOW;;WAEF,OAAO;;EAUhB,gBAAgB,aAAa,eAAe,YAAY;;EAQxD,eAAe;;EAKf,aAAa;;EAKb;;;;;;;;;;;;UCtCe;;EAEf,OAAO,OAAO;;EAEd;;WAES;;;UAIM;;EAEf;;EAEA;;EAEA;;;wBAIc,gBAAgB,UAAS,mBAAwB;KChCrD,oBAAoB;KACpB,sBAAsB;KAEtB;EACV,YAAY;EACZ,eAAe,UAAU;EACzB,eAAe,SAAS;EACxB;EACA;;KAGG;EACH,QAAQ;EACR;EACA;EACA;EACA;;wBAGc,kBAAkB,MAAM,kBAAkB;;;;;;;UCbzC;;EAEf;;EAEA;;EAEA;;EAEA;;;UAIe;WACN;EACT;EACA;EACA;EACA;EACA;;UAGe;WACN;EACT;EACA;EACA;EACA;;UAGe;WACN;EACT;EACA;EACA;EACA;EACA;;;KAIU,mBAAmB,YAAY,cAAc;;;;;;qBAO5C;;WAEF,OAAO;;UAQR;;MAGJ;;MAKA,qBAAqB;;EAKzB,SAAS,WAAW,WAAW,eAAe,gBAAgB;;EAK9D,WAAW,WAAW,WAAW,gBAAgB;;EAKjD,SAAS,YAAY,YAAY,YAAY,YAAY;;EAKzD;;EAKA,WAAW,YAAY;;EAKvB;;EAQA;;KC5GU;WACD;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;KAGC;WACD;WACA;WACA;WACA;WACA;WACA;;KAGC;WACD;WACA;WACA;WACA,mBAAmB;WACnB,mBAAmB;;KAGlB;EACV,aAAa;EACb,WAAW;EACX,YAAY,WAAW;EACvB,SAAS;EACT;;KAoBG;EACH;EACA;;wBAqBc,mBAAmB,OAAM,mBAAwB;qBC1EpD;wBAEG,eAAe,QAAQ;;;;;qBCE1B;UACH;UACA;UACA;UACA;EAEI,YAAA,OAAO;;MAKf;;MAKA;;EAKJ;;EAQA;;EAQA;;;;;EAYA;;;;;;EAUA;;EAOA,aAAa"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { Clock } from "@flare-engine/core";
2
- //#region src/boot-trace.d.ts
3
2
  type BootEntry = {
4
3
  readonly name: string;
5
4
  readonly t: number;
@@ -10,9 +9,7 @@ type BootTraceHandle = {
10
9
  reset(): void;
11
10
  getEntries(): readonly BootEntry[];
12
11
  };
13
- declare function createBootTrace(label?: string): BootTraceHandle;
14
- //#endregion
15
- //#region src/stats.d.ts
12
+ export declare function createBootTrace(label?: string): BootTraceHandle;
16
13
  /** Snapshot of engine stats for a single frame. */
17
14
  interface DebugStats {
18
15
  /** Frames per second (smoothed). */
@@ -32,7 +29,7 @@ interface DebugStats {
32
29
  * StatsTracker — collects and exposes per-frame debug statistics.
33
30
  * Wrap in `__DEV__` checks at the call site for tree-shaking.
34
31
  */
35
- declare class StatsTracker {
32
+ export declare class StatsTracker {
36
33
  /** Current frame stats (read-only snapshot). */
37
34
  readonly stats: DebugStats;
38
35
  /** Update timing stats from the clock. */
@@ -44,8 +41,6 @@ declare class StatsTracker {
44
41
  /** Reset all counters to zero. */
45
42
  reset(): void;
46
43
  }
47
- //#endregion
48
- //#region src/fps-widget.d.ts
49
44
  /**
50
45
  * Formatter for a compact FPS / stats overlay.
51
46
  *
@@ -74,9 +69,7 @@ interface FpsWidgetOptions {
74
69
  msPrecision?: number;
75
70
  }
76
71
  /** Create a new FPS widget formatter. */
77
- declare function createFpsWidget(options?: FpsWidgetOptions): FpsWidget;
78
- //#endregion
79
- //#region src/frame-budget.d.ts
72
+ export declare function createFpsWidget(options?: FpsWidgetOptions): FpsWidget;
80
73
  type FrameBudgetLimits = Record<string, number>;
81
74
  type FrameBudgetSnapshot = Record<string, number>;
82
75
  type FrameBudgetHandle = {
@@ -93,9 +86,7 @@ type FrameBudgetOpts = {
93
86
  onWatchdog?: () => void;
94
87
  debug?: boolean;
95
88
  };
96
- declare function createFrameBudget(opts: FrameBudgetOpts): FrameBudgetHandle;
97
- //#endregion
98
- //#region src/overlay.d.ts
89
+ export declare function createFrameBudget(opts: FrameBudgetOpts): FrameBudgetHandle;
99
90
  /**
100
91
  * DebugOverlay — configuration for debug visualization overlays.
101
92
  * The actual rendering is done by the host (e.g., @flare-engine/react) reading
@@ -143,7 +134,7 @@ type DebugDrawCommand = DebugRect | DebugCircle | DebugLine;
143
134
  * Commands are generated based on active overlay flags, then consumed
144
135
  * by the renderer.
145
136
  */
146
- declare class DebugOverlay {
137
+ export declare class DebugOverlay {
147
138
  /** Active overlay flags. */
148
139
  readonly flags: OverlayFlags;
149
140
  /** Queued debug draw commands for the current frame. */
@@ -167,8 +158,6 @@ declare class DebugOverlay {
167
158
  /** Disable all overlays. */
168
159
  disableAll(): void;
169
160
  }
170
- //#endregion
171
- //#region src/perf-recorder.d.ts
172
161
  type PerfSectionStats = {
173
162
  readonly name: string;
174
163
  readonly count: number;
@@ -205,18 +194,14 @@ type PerfRecorderOpts = {
205
194
  label?: string;
206
195
  ringSize?: number;
207
196
  };
208
- declare function createPerfRecorder(opts?: PerfRecorderOpts): PerfRecorderHandle;
209
- //#endregion
210
- //#region src/perf-output.d.ts
211
- declare const PERF_BENCH_TAG = "[perf-bench]";
212
- declare function emitPerfReport(report: PerfReport): void;
213
- //#endregion
214
- //#region src/time-control.d.ts
197
+ export declare function createPerfRecorder(opts?: PerfRecorderOpts): PerfRecorderHandle;
198
+ export declare const PERF_BENCH_TAG = "[perf-bench]";
199
+ export declare function emitPerfReport(report: PerfReport): void;
215
200
  /**
216
201
  * TimeControl — pause, step-frame, and slow-motion via Clock.timescale.
217
202
  * Wrap in `__DEV__` checks at the call site for tree-shaking.
218
203
  */
219
- declare class TimeControl {
204
+ export declare class TimeControl {
220
205
  private _clock;
221
206
  private _savedTimescale;
222
207
  private _paused;
@@ -246,6 +231,5 @@ declare class TimeControl {
246
231
  /** Set slow-motion multiplier (e.g., 0.5 for half-speed). */
247
232
  setTimescale(scale: number): void;
248
233
  }
249
- //#endregion
250
- export { type BootEntry, type BootTraceHandle, type DebugCircle, type DebugDrawCommand, type DebugLine, DebugOverlay, type DebugRect, type DebugStats, type FpsWidget, type FpsWidgetOptions, type FrameBudgetHandle, type FrameBudgetLimits, type FrameBudgetSnapshot, type OverlayFlags, PERF_BENCH_TAG, type PerfCounterStats, type PerfRecorderHandle, type PerfReport, type PerfSectionStats, StatsTracker, TimeControl, createBootTrace, createFpsWidget, createFrameBudget, createPerfRecorder, emitPerfReport };
234
+ export type { BootEntry, BootTraceHandle, DebugCircle, DebugDrawCommand, DebugLine, DebugRect, DebugStats, FpsWidget, FpsWidgetOptions, FrameBudgetHandle, FrameBudgetLimits, FrameBudgetSnapshot, OverlayFlags, PerfCounterStats, PerfRecorderHandle, PerfReport, PerfSectionStats };
251
235
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/boot-trace.ts","../src/stats.ts","../src/fps-widget.ts","../src/frame-budget.ts","../src/overlay.ts","../src/perf-recorder.ts","../src/perf-output.ts","../src/time-control.ts"],"mappings":";;KAAY;WACD;WACA;;KAGC;EACV,KAAK;EACL;EACA;EACA,uBAAuB;;iBAUT,gBAAgB,iBAAuB;;;;UClBtC;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;cAOW;;WAEF,OAAO;;EAUhB,gBAAgB,aAAa,eAAe,YAAY;;EAQxD,eAAe;;EAKf,aAAa;;EAKb;;;;;;;;;;;;;;UCtCe;;EAEf,OAAO,OAAO;;EAEd;;WAES;;;UAIM;;EAEf;;EAEA;;EAEA;;;iBAIc,gBAAgB,UAAS,mBAAwB;;;KChCrD,oBAAoB;KACpB,sBAAsB;KAEtB;EACV,YAAY;EACZ,eAAe,UAAU;EACzB,eAAe,SAAS;EACxB;EACA;;KAGG;EACH,QAAQ;EACR;EACA;EACA;EACA;;iBAGc,kBAAkB,MAAM,kBAAkB;;;;;;;;;UCbzC;;EAEf;;EAEA;;EAEA;;EAEA;;;UAIe;WACN;EACT;EACA;EACA;EACA;EACA;;UAGe;WACN;EACT;EACA;EACA;EACA;;UAGe;WACN;EACT;EACA;EACA;EACA;EACA;;;KAIU,mBAAmB,YAAY,cAAc;;;;;;cAO5C;;WAEF,OAAO;;UAQR;;MAGJ;;MAKA,qBAAqB;;EAKzB,SAAS,WAAW,WAAW,eAAe,gBAAgB;;EAK9D,WAAW,WAAW,WAAW,gBAAgB;;EAKjD,SAAS,YAAY,YAAY,YAAY,YAAY;;EAKzD;;EAKA,WAAW,YAAY;;EAKvB;;EAQA;;;;KC5GU;WACD;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;KAGC;WACD;WACA;WACA;WACA;WACA;WACA;;KAGC;WACD;WACA;WACA;WACA,mBAAmB;WACnB,mBAAmB;;KAGlB;EACV,aAAa;EACb,WAAW;EACX,YAAY,WAAW;EACvB,SAAS;EACT;;KAoBG;EACH;EACA;;iBAqBc,mBAAmB,OAAM,mBAAwB;;;cC1EpD;iBAEG,eAAe,QAAQ;;;;;;;cCE1B;UACH;UACA;UACA;UACA;cAEI,OAAO;;MAKf;;MAKA;;EAKJ;;EAQA;;EAQA;;;;;EAYA;;;;;;EAUA;;EAOA,aAAa"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/boot-trace.ts","../src/stats.ts","../src/fps-widget.ts","../src/frame-budget.ts","../src/overlay.ts","../src/perf-recorder.ts","../src/perf-output.ts","../src/time-control.ts"],"mappings":";KAAY;WACD;WACA;;KAGC;EACV,KAAK;EACL;EACA;EACA,uBAAuB;;wBAUT,gBAAgB,iBAAuB;;UClBtC;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;qBAOW;;WAEF,OAAO;;EAUhB,gBAAgB,aAAa,eAAe,YAAY;;EAQxD,eAAe;;EAKf,aAAa;;EAKb;;;;;;;;;;;;UCtCe;;EAEf,OAAO,OAAO;;EAEd;;WAES;;;UAIM;;EAEf;;EAEA;;EAEA;;;wBAIc,gBAAgB,UAAS,mBAAwB;KChCrD,oBAAoB;KACpB,sBAAsB;KAEtB;EACV,YAAY;EACZ,eAAe,UAAU;EACzB,eAAe,SAAS;EACxB;EACA;;KAGG;EACH,QAAQ;EACR;EACA;EACA;EACA;;wBAGc,kBAAkB,MAAM,kBAAkB;;;;;;;UCbzC;;EAEf;;EAEA;;EAEA;;EAEA;;;UAIe;WACN;EACT;EACA;EACA;EACA;EACA;;UAGe;WACN;EACT;EACA;EACA;EACA;;UAGe;WACN;EACT;EACA;EACA;EACA;EACA;;;KAIU,mBAAmB,YAAY,cAAc;;;;;;qBAO5C;;WAEF,OAAO;;UAQR;;MAGJ;;MAKA,qBAAqB;;EAKzB,SAAS,WAAW,WAAW,eAAe,gBAAgB;;EAK9D,WAAW,WAAW,WAAW,gBAAgB;;EAKjD,SAAS,YAAY,YAAY,YAAY,YAAY;;EAKzD;;EAKA,WAAW,YAAY;;EAKvB;;EAQA;;KC5GU;WACD;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;KAGC;WACD;WACA;WACA;WACA;WACA;WACA;;KAGC;WACD;WACA;WACA;WACA,mBAAmB;WACnB,mBAAmB;;KAGlB;EACV,aAAa;EACb,WAAW;EACX,YAAY,WAAW;EACvB,SAAS;EACT;;KAoBG;EACH;EACA;;wBAqBc,mBAAmB,OAAM,mBAAwB;qBC1EpD;wBAEG,eAAe,QAAQ;;;;;qBCE1B;UACH;UACA;UACA;UACA;EAEI,YAAA,OAAO;;MAKf;;MAKA;;EAKJ;;EAQA;;EAQA;;;;;EAYA;;;;;;EAUA;;EAOA,aAAa"}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region src/boot-trace.ts
2
+ // src/boot-trace.ts
3
3
  function nowMs$1() {
4
4
  if (typeof performance !== "undefined" && typeof performance.now === "function") return performance.now();
5
5
  return Date.now();
@@ -45,8 +45,7 @@ function createBootTrace(label = "boot-trace") {
45
45
  getEntries
46
46
  };
47
47
  }
48
- //#endregion
49
- //#region src/fps-widget.ts
48
+ // src/fps-widget.ts
50
49
  /** Create a new FPS widget formatter. */
51
50
  function createFpsWidget(options = {}) {
52
51
  const showEntities = options.showEntities ?? true;
@@ -73,8 +72,7 @@ function createFpsWidget(options = {}) {
73
72
  };
74
73
  return widget;
75
74
  }
76
- //#endregion
77
- //#region src/frame-budget.ts
75
+ // src/frame-budget.ts
78
76
  function createFrameBudget(opts) {
79
77
  const { limits, onWatchdog, debug = false } = opts;
80
78
  const fpsThreshold = opts.fpsThreshold ?? 55;
@@ -129,8 +127,7 @@ function createFrameBudget(opts) {
129
127
  resetFpsRing
130
128
  };
131
129
  }
132
- //#endregion
133
- //#region src/overlay.ts
130
+ // src/overlay.ts
134
131
  /**
135
132
  * DebugOverlay — collects debug draw commands for the current frame.
136
133
  * Commands are generated based on active overlay flags, then consumed
@@ -209,14 +206,12 @@ var DebugOverlay = class {
209
206
  this.flags.showStats = false;
210
207
  }
211
208
  };
212
- //#endregion
213
- //#region src/perf-output.ts
209
+ // src/perf-output.ts
214
210
  const PERF_BENCH_TAG = "[perf-bench]";
215
211
  function emitPerfReport(report) {
216
212
  console.log(`${PERF_BENCH_TAG} ${JSON.stringify(report)}`);
217
213
  }
218
- //#endregion
219
- //#region src/perf-recorder.ts
214
+ // src/perf-recorder.ts
220
215
  function nowMs() {
221
216
  if (typeof performance !== "undefined" && typeof performance.now === "function") return performance.now();
222
217
  return Date.now();
@@ -377,8 +372,7 @@ function createPerfRecorder(opts = {}) {
377
372
  reset
378
373
  };
379
374
  }
380
- //#endregion
381
- //#region src/stats.ts
375
+ // src/stats.ts
382
376
  /**
383
377
  * StatsTracker — collects and exposes per-frame debug statistics.
384
378
  * Wrap in `__DEV__` checks at the call site for tree-shaking.
@@ -418,8 +412,7 @@ var StatsTracker = class {
418
412
  this.stats.drawCalls = 0;
419
413
  }
420
414
  };
421
- //#endregion
422
- //#region src/time-control.ts
415
+ // src/time-control.ts
423
416
  /**
424
417
  * TimeControl — pause, step-frame, and slow-motion via Clock.timescale.
425
418
  * Wrap in `__DEV__` checks at the call site for tree-shaking.
@@ -483,7 +476,6 @@ var TimeControl = class {
483
476
  else this._clock.timescale = scale;
484
477
  }
485
478
  };
486
- //#endregion
487
479
  exports.DebugOverlay = DebugOverlay;
488
480
  exports.PERF_BENCH_TAG = PERF_BENCH_TAG;
489
481
  exports.StatsTracker = StatsTracker;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["nowMs"],"sources":["../src/boot-trace.ts","../src/fps-widget.ts","../src/frame-budget.ts","../src/overlay.ts","../src/perf-output.ts","../src/perf-recorder.ts","../src/stats.ts","../src/time-control.ts"],"sourcesContent":["export type BootEntry = {\n readonly name: string;\n readonly t: number;\n};\n\nexport type BootTraceHandle = {\n mark(name: string): void;\n dump(): string | null;\n reset(): void;\n getEntries(): readonly BootEntry[];\n};\n\nfunction nowMs(): number {\n if (typeof performance !== 'undefined' && typeof performance.now === 'function') {\n return performance.now();\n }\n return Date.now();\n}\n\nexport function createBootTrace(label = 'boot-trace'): BootTraceHandle {\n const entries: BootEntry[] = [];\n let startT: number | null = null;\n\n function mark(name: string): void {\n if (startT === null) {\n startT = nowMs();\n entries.push({ name, t: 0 });\n } else {\n entries.push({ name, t: nowMs() - startT });\n }\n }\n\n function dump(): string | null {\n if (entries.length === 0) return null;\n const parts: string[] = [];\n for (let i = 1; i < entries.length; i++) {\n const prev = entries[i - 1];\n const cur = entries[i];\n if (!prev || !cur) continue;\n parts.push(`${prev.name}->${cur.name}=${(cur.t - prev.t).toFixed(1)}ms`);\n }\n const last = entries[entries.length - 1];\n const totalMs = last ? last.t.toFixed(1) : '0.0';\n const stepStr = parts.length > 0 ? ` ${parts.join(' ')}` : '';\n return `[${label}] total=${totalMs}ms${stepStr}`;\n }\n\n function reset(): void {\n entries.length = 0;\n startT = null;\n }\n\n function getEntries(): readonly BootEntry[] {\n return entries.slice();\n }\n\n return { mark, dump, reset, getEntries };\n}\n","import type { DebugStats } from './stats.js';\n\n/**\n * Formatter for a compact FPS / stats overlay.\n *\n * Consumes a `DebugStats` snapshot and exposes formatted strings ready\n * for the host to draw (Skia `canvas.drawText`, an RN `<Text>` overlay,\n * whatever). The widget itself has no rendering dependency so it stays\n * drop-in across renderers.\n *\n * Wrap in `__DEV__` at the call site for tree-shaking.\n */\nexport interface FpsWidget {\n /** Rebuild `line` / `lines` from the latest stats. */\n update(stats: DebugStats): void;\n /** Compact one-line summary, e.g. \"60 FPS | 16.7ms | e:42 d:8\". */\n line: string;\n /** Multi-line breakdown — one string per stat row. */\n readonly lines: string[];\n}\n\n/** Options for the FPS widget formatter. */\nexport interface FpsWidgetOptions {\n /** Show entity count in the one-line summary. Default true. */\n showEntities?: boolean;\n /** Show draw call count in the one-line summary. Default true. */\n showDrawCalls?: boolean;\n /** Number of decimals for milliseconds. Default 1. */\n msPrecision?: number;\n}\n\n/** Create a new FPS widget formatter. */\nexport function createFpsWidget(options: FpsWidgetOptions = {}): FpsWidget {\n const showEntities = options.showEntities ?? true;\n const showDrawCalls = options.showDrawCalls ?? true;\n const msPrecision = options.msPrecision ?? 1;\n const lines: string[] = [];\n\n const widget: FpsWidget = {\n line: '',\n lines,\n update(stats: DebugStats): void {\n const fps = Math.round(stats.fps);\n const ms = (stats.rawDt * 1000).toFixed(msPrecision);\n\n let summary = `${fps} FPS | ${ms}ms`;\n if (showEntities) summary += ` | e:${stats.entityCount}`;\n if (showDrawCalls) summary += ` d:${stats.drawCalls}`;\n widget.line = summary;\n\n lines.length = 0;\n lines.push(`FPS: ${fps}`);\n lines.push(`dt: ${ms}ms`);\n lines.push(`frame: ${stats.frame}`);\n lines.push(`entities: ${stats.entityCount}`);\n lines.push(`draws: ${stats.drawCalls}`);\n },\n };\n return widget;\n}\n","export type FrameBudgetLimits = Record<string, number>;\nexport type FrameBudgetSnapshot = Record<string, number>;\n\nexport type FrameBudgetHandle = {\n recordFrame(dtSec: number): void;\n recordCounters(snapshot: FrameBudgetSnapshot): void;\n getSnapshot(): Readonly<FrameBudgetSnapshot>;\n getAvgFps(): number;\n resetFpsRing(): void;\n};\n\ntype FrameBudgetOpts = {\n limits: FrameBudgetLimits;\n fpsThreshold?: number;\n ringSize?: number;\n onWatchdog?: () => void;\n debug?: boolean;\n};\n\nexport function createFrameBudget(opts: FrameBudgetOpts): FrameBudgetHandle {\n const { limits, onWatchdog, debug = false } = opts;\n const fpsThreshold = opts.fpsThreshold ?? 55;\n const ringSize = opts.ringSize ?? 180;\n\n const ring = new Float32Array(ringSize);\n const limitKeys = Object.keys(limits);\n const _lastSnapshot: Record<string, number> = {};\n for (const k of limitKeys) {\n _lastSnapshot[k] = 0;\n }\n\n let head = 0;\n let filled = 0;\n let watchdogFired = false;\n\n function recordFrame(dtSec: number): void {\n ring[head] = dtSec;\n head = (head + 1) % ringSize;\n if (filled < ringSize) filled += 1;\n\n if (filled === ringSize && !watchdogFired) {\n if (getAvgFps() < fpsThreshold) {\n watchdogFired = true;\n onWatchdog?.();\n }\n }\n }\n\n function recordCounters(snapshot: FrameBudgetSnapshot): void {\n for (let i = 0; i < limitKeys.length; i++) {\n const k = limitKeys[i] as string;\n const v = snapshot[k] ?? 0;\n _lastSnapshot[k] = v;\n if (debug && v > (limits[k] as number)) {\n console.warn(`[frame-budget] ${k} over limit: ${v} > ${limits[k]}`);\n }\n }\n }\n\n function getSnapshot(): Readonly<FrameBudgetSnapshot> {\n return _lastSnapshot;\n }\n\n function getAvgFps(): number {\n if (filled < ringSize) return 0;\n let sum = 0;\n for (let i = 0; i < ringSize; i++) {\n sum += ring[i] as number;\n }\n const avgDt = sum / ringSize;\n return avgDt > 0 ? 1 / avgDt : 0;\n }\n\n function resetFpsRing(): void {\n ring.fill(0);\n head = 0;\n filled = 0;\n watchdogFired = false;\n }\n\n return { recordFrame, recordCounters, getSnapshot, getAvgFps, resetFpsRing };\n}\n","/**\n * DebugOverlay — configuration for debug visualization overlays.\n * The actual rendering is done by the host (e.g., @flare-engine/react) reading\n * these flags and drawing appropriate debug shapes.\n * Wrap in `__DEV__` checks at the call site for tree-shaking.\n */\nexport interface OverlayFlags {\n /** Show collision bounding boxes. */\n showCollisionBounds: boolean;\n /** Show entity origin points. */\n showEntityOrigins: boolean;\n /** Show velocity vectors. */\n showVelocityVectors: boolean;\n /** Show FPS/stats overlay. */\n showStats: boolean;\n}\n\n/** Debug draw command types. */\nexport interface DebugRect {\n readonly type: 'rect';\n x: number;\n y: number;\n width: number;\n height: number;\n color: string;\n}\n\nexport interface DebugCircle {\n readonly type: 'circle';\n x: number;\n y: number;\n radius: number;\n color: string;\n}\n\nexport interface DebugLine {\n readonly type: 'line';\n x1: number;\n y1: number;\n x2: number;\n y2: number;\n color: string;\n}\n\n/** Union of debug draw primitive commands. */\nexport type DebugDrawCommand = DebugRect | DebugCircle | DebugLine;\n\n/**\n * DebugOverlay — collects debug draw commands for the current frame.\n * Commands are generated based on active overlay flags, then consumed\n * by the renderer.\n */\nexport class DebugOverlay {\n /** Active overlay flags. */\n readonly flags: OverlayFlags = {\n showCollisionBounds: false,\n showEntityOrigins: false,\n showVelocityVectors: false,\n showStats: false,\n };\n\n /** Queued debug draw commands for the current frame. */\n private _commands: DebugDrawCommand[] = [];\n\n /** Number of queued commands. */\n get commandCount(): number {\n return this._commands.length;\n }\n\n /** Get all commands (read-only view). */\n get commands(): readonly DebugDrawCommand[] {\n return this._commands;\n }\n\n /** Add a debug rectangle. */\n drawRect(x: number, y: number, width: number, height: number, color = '#00ff00'): void {\n this._commands.push({ type: 'rect', x, y, width, height, color });\n }\n\n /** Add a debug circle. */\n drawCircle(x: number, y: number, radius: number, color = '#00ff00'): void {\n this._commands.push({ type: 'circle', x, y, radius, color });\n }\n\n /** Add a debug line. */\n drawLine(x1: number, y1: number, x2: number, y2: number, color = '#ffff00'): void {\n this._commands.push({ type: 'line', x1, y1, x2, y2, color });\n }\n\n /** Clear all commands. Call at the start of each frame. */\n clear(): void {\n this._commands.length = 0;\n }\n\n /** Toggle a specific overlay flag. */\n toggleFlag(flag: keyof OverlayFlags): void {\n this.flags[flag] = !this.flags[flag];\n }\n\n /** Enable all overlays. */\n enableAll(): void {\n this.flags.showCollisionBounds = true;\n this.flags.showEntityOrigins = true;\n this.flags.showVelocityVectors = true;\n this.flags.showStats = true;\n }\n\n /** Disable all overlays. */\n disableAll(): void {\n this.flags.showCollisionBounds = false;\n this.flags.showEntityOrigins = false;\n this.flags.showVelocityVectors = false;\n this.flags.showStats = false;\n }\n}\n","import type { PerfReport } from './perf-recorder.js';\n\nexport const PERF_BENCH_TAG = '[perf-bench]';\n\nexport function emitPerfReport(report: PerfReport): void {\n console.log(`${PERF_BENCH_TAG} ${JSON.stringify(report)}`);\n}\n","export type PerfSectionStats = {\n readonly name: string;\n readonly count: number;\n readonly min: number;\n readonly max: number;\n readonly mean: number;\n readonly p50: number;\n readonly p95: number;\n readonly p99: number;\n};\n\nexport type PerfCounterStats = {\n readonly name: string;\n readonly count: number;\n readonly min: number;\n readonly max: number;\n readonly sum: number;\n readonly mean: number;\n};\n\nexport type PerfReport = {\n readonly label: string;\n readonly durationMs: number;\n readonly frameCount: number;\n readonly sections: readonly PerfSectionStats[];\n readonly counters: readonly PerfCounterStats[];\n};\n\nexport type PerfRecorderHandle = {\n beginSection(name: string): void;\n endSection(name: string): void;\n recordFrame(counters?: Record<string, number>): void;\n flush(): PerfReport;\n reset(): void;\n};\n\ntype SectionState = {\n name: string;\n ring: Float32Array;\n ringSize: number;\n head: number;\n filled: number;\n startT: number;\n};\n\ntype CounterState = {\n name: string;\n count: number;\n min: number;\n max: number;\n sum: number;\n};\n\ntype PerfRecorderOpts = {\n label?: string;\n ringSize?: number;\n};\n\nfunction nowMs(): number {\n if (typeof performance !== 'undefined' && typeof performance.now === 'function') {\n return performance.now();\n }\n return Date.now();\n}\n\nfunction percentile(sorted: Float32Array, n: number, p: number): number {\n if (n === 0) return 0;\n if (n === 1) return sorted[0] as number;\n const idx = (p / 100) * (n - 1);\n const lo = Math.floor(idx);\n const hi = Math.ceil(idx);\n const a = sorted[lo] as number;\n const b = sorted[hi] as number;\n return a + (b - a) * (idx - lo);\n}\n\nexport function createPerfRecorder(opts: PerfRecorderOpts = {}): PerfRecorderHandle {\n const label = opts.label ?? 'perf';\n const ringSize = opts.ringSize ?? 1800;\n\n const sections = new Map<string, SectionState>();\n const counters = new Map<string, CounterState>();\n let frameCount = 0;\n let startT: number | null = null;\n\n // Reusable sort buffer — allocated once on first flush, grown as needed\n let sortBuf = new Float32Array(ringSize);\n\n function getOrCreateSection(name: string): SectionState {\n let s = sections.get(name);\n if (s === undefined) {\n s = {\n name,\n ring: new Float32Array(ringSize),\n ringSize,\n head: 0,\n filled: 0,\n startT: 0,\n };\n sections.set(name, s);\n }\n return s;\n }\n\n function getOrCreateCounter(name: string): CounterState {\n let c = counters.get(name);\n if (c === undefined) {\n c = { name, count: 0, min: Number.POSITIVE_INFINITY, max: Number.NEGATIVE_INFINITY, sum: 0 };\n counters.set(name, c);\n }\n return c;\n }\n\n function beginSection(name: string): void {\n const s = getOrCreateSection(name);\n s.startT = nowMs();\n }\n\n function endSection(name: string): void {\n const s = sections.get(name);\n if (s === undefined) return;\n const elapsed = nowMs() - s.startT;\n s.ring[s.head] = elapsed;\n s.head = (s.head + 1) % s.ringSize;\n if (s.filled < s.ringSize) s.filled += 1;\n }\n\n function recordFrame(frameCounters?: Record<string, number>): void {\n if (startT === null) startT = nowMs();\n frameCount += 1;\n if (frameCounters === undefined) return;\n for (const name in frameCounters) {\n const v = frameCounters[name] as number;\n const c = getOrCreateCounter(name);\n c.count += 1;\n if (v < c.min) c.min = v;\n if (v > c.max) c.max = v;\n c.sum += v;\n }\n }\n\n function flush(): PerfReport {\n const now = nowMs();\n const durationMs = startT !== null ? now - startT : 0;\n\n const sectionStats: PerfSectionStats[] = [];\n for (const s of sections.values()) {\n const n = s.filled;\n if (n === 0) {\n sectionStats.push({\n name: s.name,\n count: 0,\n min: 0,\n max: 0,\n mean: 0,\n p50: 0,\n p95: 0,\n p99: 0,\n });\n continue;\n }\n // Grow sort buffer if needed\n if (sortBuf.length < n) sortBuf = new Float32Array(n);\n let sum = 0;\n let minV = Number.POSITIVE_INFINITY;\n let maxV = Number.NEGATIVE_INFINITY;\n // Copy ring in chronological order\n const start = s.filled < s.ringSize ? 0 : s.head;\n for (let i = 0; i < n; i++) {\n const v = s.ring[(start + i) % s.ringSize] as number;\n sortBuf[i] = v;\n sum += v;\n if (v < minV) minV = v;\n if (v > maxV) maxV = v;\n }\n // Sort only the filled slice\n const slice = sortBuf.subarray(0, n);\n slice.sort();\n sectionStats.push({\n name: s.name,\n count: n,\n min: minV,\n max: maxV,\n mean: sum / n,\n p50: percentile(slice, n, 50),\n p95: percentile(slice, n, 95),\n p99: percentile(slice, n, 99),\n });\n }\n\n const counterStats: PerfCounterStats[] = [];\n for (const c of counters.values()) {\n counterStats.push({\n name: c.name,\n count: c.count,\n min: c.count > 0 ? c.min : 0,\n max: c.count > 0 ? c.max : 0,\n sum: c.sum,\n mean: c.count > 0 ? c.sum / c.count : 0,\n });\n }\n\n return { label, durationMs, frameCount, sections: sectionStats, counters: counterStats };\n }\n\n function reset(): void {\n for (const s of sections.values()) {\n s.ring.fill(0);\n s.head = 0;\n s.filled = 0;\n s.startT = 0;\n }\n for (const c of counters.values()) {\n c.count = 0;\n c.min = Number.POSITIVE_INFINITY;\n c.max = Number.NEGATIVE_INFINITY;\n c.sum = 0;\n }\n frameCount = 0;\n startT = null;\n }\n\n return { beginSection, endSection, recordFrame, flush, reset };\n}\n","/** Snapshot of engine stats for a single frame. */\nexport interface DebugStats {\n /** Frames per second (smoothed). */\n fps: number;\n /** Raw delta time in seconds. */\n rawDt: number;\n /** Scaled delta time in seconds. */\n dt: number;\n /** Current frame number. */\n frame: number;\n /** Total active entities (set by user). */\n entityCount: number;\n /** Draw calls this frame (set by user). */\n drawCalls: number;\n}\n\n/**\n * StatsTracker — collects and exposes per-frame debug statistics.\n * Wrap in `__DEV__` checks at the call site for tree-shaking.\n */\nexport class StatsTracker {\n /** Current frame stats (read-only snapshot). */\n readonly stats: DebugStats = {\n fps: 0,\n rawDt: 0,\n dt: 0,\n frame: 0,\n entityCount: 0,\n drawCalls: 0,\n };\n\n /** Update timing stats from the clock. */\n updateFromClock(fps: number, rawDt: number, dt: number, frame: number): void {\n this.stats.fps = fps;\n this.stats.rawDt = rawDt;\n this.stats.dt = dt;\n this.stats.frame = frame;\n }\n\n /** Set entity count for this frame. */\n setEntityCount(count: number): void {\n this.stats.entityCount = count;\n }\n\n /** Set draw call count for this frame. */\n setDrawCalls(count: number): void {\n this.stats.drawCalls = count;\n }\n\n /** Reset all counters to zero. */\n reset(): void {\n this.stats.fps = 0;\n this.stats.rawDt = 0;\n this.stats.dt = 0;\n this.stats.frame = 0;\n this.stats.entityCount = 0;\n this.stats.drawCalls = 0;\n }\n}\n","import type { Clock } from '@flare-engine/core';\n\n/**\n * TimeControl — pause, step-frame, and slow-motion via Clock.timescale.\n * Wrap in `__DEV__` checks at the call site for tree-shaking.\n */\nexport class TimeControl {\n private _clock: Clock;\n private _savedTimescale = 1;\n private _paused = false;\n private _stepRequested = false;\n\n constructor(clock: Clock) {\n this._clock = clock;\n }\n\n /** Whether the game is currently paused. */\n get paused(): boolean {\n return this._paused;\n }\n\n /** Current time scale. */\n get timescale(): number {\n return this._clock.timescale;\n }\n\n /** Pause the game (sets timescale to 0). */\n pause(): void {\n if (this._paused) return;\n this._savedTimescale = this._clock.timescale;\n this._clock.timescale = 0;\n this._paused = true;\n }\n\n /** Resume the game (restores previous timescale). */\n resume(): void {\n if (!this._paused) return;\n this._clock.timescale = this._savedTimescale;\n this._paused = false;\n this._stepRequested = false;\n }\n\n /** Toggle pause/resume. */\n toggle(): void {\n if (this._paused) {\n this.resume();\n } else {\n this.pause();\n }\n }\n\n /**\n * Request a single-frame step while paused.\n * Call this, then on the next update check `consumeStep()`.\n */\n step(): void {\n if (!this._paused) return;\n this._stepRequested = true;\n }\n\n /**\n * Consume a pending step request. Returns true if a step was requested.\n * When true, the caller should run one frame with the saved timescale,\n * then re-pause.\n */\n consumeStep(): boolean {\n if (!this._stepRequested) return false;\n this._stepRequested = false;\n return true;\n }\n\n /** Set slow-motion multiplier (e.g., 0.5 for half-speed). */\n setTimescale(scale: number): void {\n if (this._paused)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B;;CAGA,SAAe;EACb,IAAI,KAAK,SACP,KAAK,OAAO;OAEZ,KAAK,MAAM;CAEf;;;;;CAMA,OAAa;EACX,IAAI,CAAC,KAAK,SAAS;EACnB,KAAK,iBAAiB;CACxB;;;;;;CAOA,cAAuB;EACrB,IAAI,CAAC,KAAK,gBAAgB,OAAO;EACjC,KAAK,iBAAiB;EACtB,OAAO;CACT;;CAGA,aAAa,OAAqB;EAChC,IAAI,KAAK,SACP,KAAK,kBAAkB;OAEvB,KAAK,OAAO,YAAY;CAE5B;AACF"}
1
+ {"version":3,"file":"index.js","names":["nowMs"],"sources":["../src/boot-trace.ts","../src/fps-widget.ts","../src/frame-budget.ts","../src/overlay.ts","../src/perf-output.ts","../src/perf-recorder.ts","../src/stats.ts","../src/time-control.ts"],"sourcesContent":["export type BootEntry = {\n readonly name: string;\n readonly t: number;\n};\n\nexport type BootTraceHandle = {\n mark(name: string): void;\n dump(): string | null;\n reset(): void;\n getEntries(): readonly BootEntry[];\n};\n\nfunction nowMs(): number {\n if (typeof performance !== 'undefined' && typeof performance.now === 'function') {\n return performance.now();\n }\n return Date.now();\n}\n\nexport function createBootTrace(label = 'boot-trace'): BootTraceHandle {\n const entries: BootEntry[] = [];\n let startT: number | null = null;\n\n function mark(name: string): void {\n if (startT === null) {\n startT = nowMs();\n entries.push({ name, t: 0 });\n } else {\n entries.push({ name, t: nowMs() - startT });\n }\n }\n\n function dump(): string | null {\n if (entries.length === 0) return null;\n const parts: string[] = [];\n for (let i = 1; i < entries.length; i++) {\n const prev = entries[i - 1];\n const cur = entries[i];\n if (!prev || !cur) continue;\n parts.push(`${prev.name}->${cur.name}=${(cur.t - prev.t).toFixed(1)}ms`);\n }\n const last = entries[entries.length - 1];\n const totalMs = last ? last.t.toFixed(1) : '0.0';\n const stepStr = parts.length > 0 ? ` ${parts.join(' ')}` : '';\n return `[${label}] total=${totalMs}ms${stepStr}`;\n }\n\n function reset(): void {\n entries.length = 0;\n startT = null;\n }\n\n function getEntries(): readonly BootEntry[] {\n return entries.slice();\n }\n\n return { mark, dump, reset, getEntries };\n}\n","import type { DebugStats } from './stats.js';\n\n/**\n * Formatter for a compact FPS / stats overlay.\n *\n * Consumes a `DebugStats` snapshot and exposes formatted strings ready\n * for the host to draw (Skia `canvas.drawText`, an RN `<Text>` overlay,\n * whatever). The widget itself has no rendering dependency so it stays\n * drop-in across renderers.\n *\n * Wrap in `__DEV__` at the call site for tree-shaking.\n */\nexport interface FpsWidget {\n /** Rebuild `line` / `lines` from the latest stats. */\n update(stats: DebugStats): void;\n /** Compact one-line summary, e.g. \"60 FPS | 16.7ms | e:42 d:8\". */\n line: string;\n /** Multi-line breakdown — one string per stat row. */\n readonly lines: string[];\n}\n\n/** Options for the FPS widget formatter. */\nexport interface FpsWidgetOptions {\n /** Show entity count in the one-line summary. Default true. */\n showEntities?: boolean;\n /** Show draw call count in the one-line summary. Default true. */\n showDrawCalls?: boolean;\n /** Number of decimals for milliseconds. Default 1. */\n msPrecision?: number;\n}\n\n/** Create a new FPS widget formatter. */\nexport function createFpsWidget(options: FpsWidgetOptions = {}): FpsWidget {\n const showEntities = options.showEntities ?? true;\n const showDrawCalls = options.showDrawCalls ?? true;\n const msPrecision = options.msPrecision ?? 1;\n const lines: string[] = [];\n\n const widget: FpsWidget = {\n line: '',\n lines,\n update(stats: DebugStats): void {\n const fps = Math.round(stats.fps);\n const ms = (stats.rawDt * 1000).toFixed(msPrecision);\n\n let summary = `${fps} FPS | ${ms}ms`;\n if (showEntities) summary += ` | e:${stats.entityCount}`;\n if (showDrawCalls) summary += ` d:${stats.drawCalls}`;\n widget.line = summary;\n\n lines.length = 0;\n lines.push(`FPS: ${fps}`);\n lines.push(`dt: ${ms}ms`);\n lines.push(`frame: ${stats.frame}`);\n lines.push(`entities: ${stats.entityCount}`);\n lines.push(`draws: ${stats.drawCalls}`);\n },\n };\n return widget;\n}\n","export type FrameBudgetLimits = Record<string, number>;\nexport type FrameBudgetSnapshot = Record<string, number>;\n\nexport type FrameBudgetHandle = {\n recordFrame(dtSec: number): void;\n recordCounters(snapshot: FrameBudgetSnapshot): void;\n getSnapshot(): Readonly<FrameBudgetSnapshot>;\n getAvgFps(): number;\n resetFpsRing(): void;\n};\n\ntype FrameBudgetOpts = {\n limits: FrameBudgetLimits;\n fpsThreshold?: number;\n ringSize?: number;\n onWatchdog?: () => void;\n debug?: boolean;\n};\n\nexport function createFrameBudget(opts: FrameBudgetOpts): FrameBudgetHandle {\n const { limits, onWatchdog, debug = false } = opts;\n const fpsThreshold = opts.fpsThreshold ?? 55;\n const ringSize = opts.ringSize ?? 180;\n\n const ring = new Float32Array(ringSize);\n const limitKeys = Object.keys(limits);\n const _lastSnapshot: Record<string, number> = {};\n for (const k of limitKeys) {\n _lastSnapshot[k] = 0;\n }\n\n let head = 0;\n let filled = 0;\n let watchdogFired = false;\n\n function recordFrame(dtSec: number): void {\n ring[head] = dtSec;\n head = (head + 1) % ringSize;\n if (filled < ringSize) filled += 1;\n\n if (filled === ringSize && !watchdogFired) {\n if (getAvgFps() < fpsThreshold) {\n watchdogFired = true;\n onWatchdog?.();\n }\n }\n }\n\n function recordCounters(snapshot: FrameBudgetSnapshot): void {\n for (let i = 0; i < limitKeys.length; i++) {\n const k = limitKeys[i] as string;\n const v = snapshot[k] ?? 0;\n _lastSnapshot[k] = v;\n if (debug && v > (limits[k] as number)) {\n console.warn(`[frame-budget] ${k} over limit: ${v} > ${limits[k]}`);\n }\n }\n }\n\n function getSnapshot(): Readonly<FrameBudgetSnapshot> {\n return _lastSnapshot;\n }\n\n function getAvgFps(): number {\n if (filled < ringSize) return 0;\n let sum = 0;\n for (let i = 0; i < ringSize; i++) {\n sum += ring[i] as number;\n }\n const avgDt = sum / ringSize;\n return avgDt > 0 ? 1 / avgDt : 0;\n }\n\n function resetFpsRing(): void {\n ring.fill(0);\n head = 0;\n filled = 0;\n watchdogFired = false;\n }\n\n return { recordFrame, recordCounters, getSnapshot, getAvgFps, resetFpsRing };\n}\n","/**\n * DebugOverlay — configuration for debug visualization overlays.\n * The actual rendering is done by the host (e.g., @flare-engine/react) reading\n * these flags and drawing appropriate debug shapes.\n * Wrap in `__DEV__` checks at the call site for tree-shaking.\n */\nexport interface OverlayFlags {\n /** Show collision bounding boxes. */\n showCollisionBounds: boolean;\n /** Show entity origin points. */\n showEntityOrigins: boolean;\n /** Show velocity vectors. */\n showVelocityVectors: boolean;\n /** Show FPS/stats overlay. */\n showStats: boolean;\n}\n\n/** Debug draw command types. */\nexport interface DebugRect {\n readonly type: 'rect';\n x: number;\n y: number;\n width: number;\n height: number;\n color: string;\n}\n\nexport interface DebugCircle {\n readonly type: 'circle';\n x: number;\n y: number;\n radius: number;\n color: string;\n}\n\nexport interface DebugLine {\n readonly type: 'line';\n x1: number;\n y1: number;\n x2: number;\n y2: number;\n color: string;\n}\n\n/** Union of debug draw primitive commands. */\nexport type DebugDrawCommand = DebugRect | DebugCircle | DebugLine;\n\n/**\n * DebugOverlay — collects debug draw commands for the current frame.\n * Commands are generated based on active overlay flags, then consumed\n * by the renderer.\n */\nexport class DebugOverlay {\n /** Active overlay flags. */\n readonly flags: OverlayFlags = {\n showCollisionBounds: false,\n showEntityOrigins: false,\n showVelocityVectors: false,\n showStats: false,\n };\n\n /** Queued debug draw commands for the current frame. */\n private _commands: DebugDrawCommand[] = [];\n\n /** Number of queued commands. */\n get commandCount(): number {\n return this._commands.length;\n }\n\n /** Get all commands (read-only view). */\n get commands(): readonly DebugDrawCommand[] {\n return this._commands;\n }\n\n /** Add a debug rectangle. */\n drawRect(x: number, y: number, width: number, height: number, color = '#00ff00'): void {\n this._commands.push({ type: 'rect', x, y, width, height, color });\n }\n\n /** Add a debug circle. */\n drawCircle(x: number, y: number, radius: number, color = '#00ff00'): void {\n this._commands.push({ type: 'circle', x, y, radius, color });\n }\n\n /** Add a debug line. */\n drawLine(x1: number, y1: number, x2: number, y2: number, color = '#ffff00'): void {\n this._commands.push({ type: 'line', x1, y1, x2, y2, color });\n }\n\n /** Clear all commands. Call at the start of each frame. */\n clear(): void {\n this._commands.length = 0;\n }\n\n /** Toggle a specific overlay flag. */\n toggleFlag(flag: keyof OverlayFlags): void {\n this.flags[flag] = !this.flags[flag];\n }\n\n /** Enable all overlays. */\n enableAll(): void {\n this.flags.showCollisionBounds = true;\n this.flags.showEntityOrigins = true;\n this.flags.showVelocityVectors = true;\n this.flags.showStats = true;\n }\n\n /** Disable all overlays. */\n disableAll(): void {\n this.flags.showCollisionBounds = false;\n this.flags.showEntityOrigins = false;\n this.flags.showVelocityVectors = false;\n this.flags.showStats = false;\n }\n}\n","import type { PerfReport } from './perf-recorder.js';\n\nexport const PERF_BENCH_TAG = '[perf-bench]';\n\nexport function emitPerfReport(report: PerfReport): void {\n console.log(`${PERF_BENCH_TAG} ${JSON.stringify(report)}`);\n}\n","export type PerfSectionStats = {\n readonly name: string;\n readonly count: number;\n readonly min: number;\n readonly max: number;\n readonly mean: number;\n readonly p50: number;\n readonly p95: number;\n readonly p99: number;\n};\n\nexport type PerfCounterStats = {\n readonly name: string;\n readonly count: number;\n readonly min: number;\n readonly max: number;\n readonly sum: number;\n readonly mean: number;\n};\n\nexport type PerfReport = {\n readonly label: string;\n readonly durationMs: number;\n readonly frameCount: number;\n readonly sections: readonly PerfSectionStats[];\n readonly counters: readonly PerfCounterStats[];\n};\n\nexport type PerfRecorderHandle = {\n beginSection(name: string): void;\n endSection(name: string): void;\n recordFrame(counters?: Record<string, number>): void;\n flush(): PerfReport;\n reset(): void;\n};\n\ntype SectionState = {\n name: string;\n ring: Float32Array;\n ringSize: number;\n head: number;\n filled: number;\n startT: number;\n};\n\ntype CounterState = {\n name: string;\n count: number;\n min: number;\n max: number;\n sum: number;\n};\n\ntype PerfRecorderOpts = {\n label?: string;\n ringSize?: number;\n};\n\nfunction nowMs(): number {\n if (typeof performance !== 'undefined' && typeof performance.now === 'function') {\n return performance.now();\n }\n return Date.now();\n}\n\nfunction percentile(sorted: Float32Array, n: number, p: number): number {\n if (n === 0) return 0;\n if (n === 1) return sorted[0] as number;\n const idx = (p / 100) * (n - 1);\n const lo = Math.floor(idx);\n const hi = Math.ceil(idx);\n const a = sorted[lo] as number;\n const b = sorted[hi] as number;\n return a + (b - a) * (idx - lo);\n}\n\nexport function createPerfRecorder(opts: PerfRecorderOpts = {}): PerfRecorderHandle {\n const label = opts.label ?? 'perf';\n const ringSize = opts.ringSize ?? 1800;\n\n const sections = new Map<string, SectionState>();\n const counters = new Map<string, CounterState>();\n let frameCount = 0;\n let startT: number | null = null;\n\n // Reusable sort buffer — allocated once on first flush, grown as needed\n let sortBuf = new Float32Array(ringSize);\n\n function getOrCreateSection(name: string): SectionState {\n let s = sections.get(name);\n if (s === undefined) {\n s = {\n name,\n ring: new Float32Array(ringSize),\n ringSize,\n head: 0,\n filled: 0,\n startT: 0,\n };\n sections.set(name, s);\n }\n return s;\n }\n\n function getOrCreateCounter(name: string): CounterState {\n let c = counters.get(name);\n if (c === undefined) {\n c = { name, count: 0, min: Number.POSITIVE_INFINITY, max: Number.NEGATIVE_INFINITY, sum: 0 };\n counters.set(name, c);\n }\n return c;\n }\n\n function beginSection(name: string): void {\n const s = getOrCreateSection(name);\n s.startT = nowMs();\n }\n\n function endSection(name: string): void {\n const s = sections.get(name);\n if (s === undefined) return;\n const elapsed = nowMs() - s.startT;\n s.ring[s.head] = elapsed;\n s.head = (s.head + 1) % s.ringSize;\n if (s.filled < s.ringSize) s.filled += 1;\n }\n\n function recordFrame(frameCounters?: Record<string, number>): void {\n if (startT === null) startT = nowMs();\n frameCount += 1;\n if (frameCounters === undefined) return;\n for (const name in frameCounters) {\n const v = frameCounters[name] as number;\n const c = getOrCreateCounter(name);\n c.count += 1;\n if (v < c.min) c.min = v;\n if (v > c.max) c.max = v;\n c.sum += v;\n }\n }\n\n function flush(): PerfReport {\n const now = nowMs();\n const durationMs = startT !== null ? now - startT : 0;\n\n const sectionStats: PerfSectionStats[] = [];\n for (const s of sections.values()) {\n const n = s.filled;\n if (n === 0) {\n sectionStats.push({\n name: s.name,\n count: 0,\n min: 0,\n max: 0,\n mean: 0,\n p50: 0,\n p95: 0,\n p99: 0,\n });\n continue;\n }\n // Grow sort buffer if needed\n if (sortBuf.length < n) sortBuf = new Float32Array(n);\n let sum = 0;\n let minV = Number.POSITIVE_INFINITY;\n let maxV = Number.NEGATIVE_INFINITY;\n // Copy ring in chronological order\n const start = s.filled < s.ringSize ? 0 : s.head;\n for (let i = 0; i < n; i++) {\n const v = s.ring[(start + i) % s.ringSize] as number;\n sortBuf[i] = v;\n sum += v;\n if (v < minV) minV = v;\n if (v > maxV) maxV = v;\n }\n // Sort only the filled slice\n const slice = sortBuf.subarray(0, n);\n slice.sort();\n sectionStats.push({\n name: s.name,\n count: n,\n min: minV,\n max: maxV,\n mean: sum / n,\n p50: percentile(slice, n, 50),\n p95: percentile(slice, n, 95),\n p99: percentile(slice, n, 99),\n });\n }\n\n const counterStats: PerfCounterStats[] = [];\n for (const c of counters.values()) {\n counterStats.push({\n name: c.name,\n count: c.count,\n min: c.count > 0 ? c.min : 0,\n max: c.count > 0 ? c.max : 0,\n sum: c.sum,\n mean: c.count > 0 ? c.sum / c.count : 0,\n });\n }\n\n return { label, durationMs, frameCount, sections: sectionStats, counters: counterStats };\n }\n\n function reset(): void {\n for (const s of sections.values()) {\n s.ring.fill(0);\n s.head = 0;\n s.filled = 0;\n s.startT = 0;\n }\n for (const c of counters.values()) {\n c.count = 0;\n c.min = Number.POSITIVE_INFINITY;\n c.max = Number.NEGATIVE_INFINITY;\n c.sum = 0;\n }\n frameCount = 0;\n startT = null;\n }\n\n return { beginSection, endSection, recordFrame, flush, reset };\n}\n","/** Snapshot of engine stats for a single frame. */\nexport interface DebugStats {\n /** Frames per second (smoothed). */\n fps: number;\n /** Raw delta time in seconds. */\n rawDt: number;\n /** Scaled delta time in seconds. */\n dt: number;\n /** Current frame number. */\n frame: number;\n /** Total active entities (set by user). */\n entityCount: number;\n /** Draw calls this frame (set by user). */\n drawCalls: number;\n}\n\n/**\n * StatsTracker — collects and exposes per-frame debug statistics.\n * Wrap in `__DEV__` checks at the call site for tree-shaking.\n */\nexport class StatsTracker {\n /** Current frame stats (read-only snapshot). */\n readonly stats: DebugStats = {\n fps: 0,\n rawDt: 0,\n dt: 0,\n frame: 0,\n entityCount: 0,\n drawCalls: 0,\n };\n\n /** Update timing stats from the clock. */\n updateFromClock(fps: number, rawDt: number, dt: number, frame: number): void {\n this.stats.fps = fps;\n this.stats.rawDt = rawDt;\n this.stats.dt = dt;\n this.stats.frame = frame;\n }\n\n /** Set entity count for this frame. */\n setEntityCount(count: number): void {\n this.stats.entityCount = count;\n }\n\n /** Set draw call count for this frame. */\n setDrawCalls(count: number): void {\n this.stats.drawCalls = count;\n }\n\n /** Reset all counters to zero. */\n reset(): void {\n this.stats.fps = 0;\n this.stats.rawDt = 0;\n this.stats.dt = 0;\n this.stats.frame = 0;\n this.stats.entityCount = 0;\n this.stats.drawCalls = 0;\n }\n}\n","import type { Clock } from '@flare-engine/core';\n\n/**\n * TimeControl — pause, step-frame, and slow-motion via Clock.timescale.\n * Wrap in `__DEV__` checks at the call site for tree-shaking.\n */\nexport class TimeControl {\n private _clock: Clock;\n private _savedTimescale = 1;\n private _paused = false;\n private _stepRequested = false;\n\n constructor(clock: Clock) {\n this._clock = clock;\n }\n\n /** Whether the game is currently paused. */\n get paused(): boolean {\n return this._paused;\n }\n\n /** Current time scale. */\n get timescale(): number {\n return this._clock.timescale;\n }\n\n /** Pause the game (sets timescale to 0). */\n pause(): void {\n if (this._paused) return;\n this._savedTimescale = this._clock.timescale;\n this._clock.timescale = 0;\n this._paused = true;\n }\n\n /** Resume the game (restores previous timescale). */\n resume(): void {\n if (!this._paused) return;\n this._clock.timescale = this._savedTimescale;\n this._paused = false;\n this._stepRequested = false;\n }\n\n /** Toggle pause/resume. */\n toggle(): void {\n if (this._paused) {\n this.resume();\n } else {\n this.pause();\n }\n }\n\n /**\n * Request a single-frame step while paused.\n * Call this, then on the next update check `consumeStep()`.\n */\n step(): void {\n if (!this._paused) return;\n this._stepRequested = true;\n }\n\n /**\n * Consume a pending step request. Returns true if a step was requested.\n * When true, the caller should run one frame with the saved timescale,\n * then re-pause.\n */\n consumeStep(): boolean {\n if (!this._stepRequested) return false;\n this._stepRequested = false;\n return true;\n }\n\n /** Set slow-motion multiplier (e.g., 0.5 for half-speed). */\n setTimescale(scale: number): void {\n if (this._paused) {\n this._savedTimescale = scale;\n } else {\n this._clock.timescale = scale;\n }\n }\n}\n"],"mappings":";;AAYA,SAASA,UAAgB;CACvB,IAAI,OAAO,gBAAgB,eAAe,OAAO,YAAY,QAAQ,YACnE,OAAO,YAAY,IAAI;CAEzB,OAAO,KAAK,IAAI;AAClB;AAEA,SAAgB,gBAAgB,QAAQ,cAA+B;CACrE,MAAM,UAAuB,CAAC;CAC9B,IAAI,SAAwB;CAE5B,SAAS,KAAK,MAAoB;EAChC,IAAI,WAAW,MAAM;GACnB,SAASA,QAAM;GACf,QAAQ,KAAK;IAAE;IAAM,GAAG;GAAE,CAAC;EAC7B,OACE,QAAQ,KAAK;GAAE;GAAM,GAAGA,QAAM,IAAI;EAAO,CAAC;CAE9C;CAEA,SAAS,OAAsB;EAC7B,IAAI,QAAQ,WAAW,GAAG,OAAO;EACjC,MAAM,QAAkB,CAAC;EACzB,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;GACvC,MAAM,OAAO,QAAQ,IAAI;GACzB,MAAM,MAAM,QAAQ;GACpB,IAAI,CAAC,QAAQ,CAAC,KAAK;GACnB,MAAM,KAAK,GAAG,KAAK,KAAK,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,EAAA,CAAG,QAAQ,CAAC,EAAE,GAAG;EACzE;EACA,MAAM,OAAO,QAAQ,QAAQ,SAAS;EAGtC,OAAO,IAAI,MAAM,UAFD,OAAO,KAAK,EAAE,QAAQ,CAAC,IAAI,MAER,IADnB,MAAM,SAAS,IAAI,IAAI,MAAM,KAAK,GAAG,MAAM;CAE7D;CAEA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;CAGA,QAAc;EACZ,IAAI,KAAK,SAAS;EAClB,KAAK,kBAAkB,KAAK,OAAO;EACnC,KAAK,OAAO,YAAY;EACxB,KAAK,UAAU;CACjB;;CAGA,SAAe;EACb,IAAI,CAAC,KAAK,SAAS;EACnB,KAAK,OAAO,YAAY,KAAK;EAC7B,KAAK,UAAU;EACf,KAAK,iBAAiB;CACxB;;CAGA,SAAe;EACb,IAAI,KAAK,SACP,KAAK,OAAO;OAEZ,KAAK,MAAM;CAEf;;;;;CAMA,OAAa;EACX,IAAI,CAAC,KAAK,SAAS;EACnB,KAAK,iBAAiB;CACxB;;;;;;CAOA,cAAuB;EACrB,IAAI,CAAC,KAAK,gBAAgB,OAAO;EACjC,KAAK,iBAAiB;EACtB,OAAO;CACT;;CAGA,aAAa,OAAqB;EAChC,IAAI,KAAK,SACP,KAAK,kBAAkB;OAEvB,KAAK,OAAO,YAAY;CAE5B;AACF"}
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/boot-trace.ts
1
+ // src/boot-trace.ts
2
2
  function nowMs$1() {
3
3
  if (typeof performance !== "undefined" && typeof performance.now === "function") return performance.now();
4
4
  return Date.now();
@@ -44,8 +44,7 @@ function createBootTrace(label = "boot-trace") {
44
44
  getEntries
45
45
  };
46
46
  }
47
- //#endregion
48
- //#region src/fps-widget.ts
47
+ // src/fps-widget.ts
49
48
  /** Create a new FPS widget formatter. */
50
49
  function createFpsWidget(options = {}) {
51
50
  const showEntities = options.showEntities ?? true;
@@ -72,8 +71,7 @@ function createFpsWidget(options = {}) {
72
71
  };
73
72
  return widget;
74
73
  }
75
- //#endregion
76
- //#region src/frame-budget.ts
74
+ // src/frame-budget.ts
77
75
  function createFrameBudget(opts) {
78
76
  const { limits, onWatchdog, debug = false } = opts;
79
77
  const fpsThreshold = opts.fpsThreshold ?? 55;
@@ -128,8 +126,7 @@ function createFrameBudget(opts) {
128
126
  resetFpsRing
129
127
  };
130
128
  }
131
- //#endregion
132
- //#region src/overlay.ts
129
+ // src/overlay.ts
133
130
  /**
134
131
  * DebugOverlay — collects debug draw commands for the current frame.
135
132
  * Commands are generated based on active overlay flags, then consumed
@@ -208,14 +205,12 @@ var DebugOverlay = class {
208
205
  this.flags.showStats = false;
209
206
  }
210
207
  };
211
- //#endregion
212
- //#region src/perf-output.ts
208
+ // src/perf-output.ts
213
209
  const PERF_BENCH_TAG = "[perf-bench]";
214
210
  function emitPerfReport(report) {
215
211
  console.log(`${PERF_BENCH_TAG} ${JSON.stringify(report)}`);
216
212
  }
217
- //#endregion
218
- //#region src/perf-recorder.ts
213
+ // src/perf-recorder.ts
219
214
  function nowMs() {
220
215
  if (typeof performance !== "undefined" && typeof performance.now === "function") return performance.now();
221
216
  return Date.now();
@@ -376,8 +371,7 @@ function createPerfRecorder(opts = {}) {
376
371
  reset
377
372
  };
378
373
  }
379
- //#endregion
380
- //#region src/stats.ts
374
+ // src/stats.ts
381
375
  /**
382
376
  * StatsTracker — collects and exposes per-frame debug statistics.
383
377
  * Wrap in `__DEV__` checks at the call site for tree-shaking.
@@ -417,8 +411,7 @@ var StatsTracker = class {
417
411
  this.stats.drawCalls = 0;
418
412
  }
419
413
  };
420
- //#endregion
421
- //#region src/time-control.ts
414
+ // src/time-control.ts
422
415
  /**
423
416
  * TimeControl — pause, step-frame, and slow-motion via Clock.timescale.
424
417
  * Wrap in `__DEV__` checks at the call site for tree-shaking.
@@ -482,7 +475,6 @@ var TimeControl = class {
482
475
  else this._clock.timescale = scale;
483
476
  }
484
477
  };
485
- //#endregion
486
478
  export { DebugOverlay, PERF_BENCH_TAG, StatsTracker, TimeControl, createBootTrace, createFpsWidget, createFrameBudget, createPerfRecorder, emitPerfReport };
487
479
 
488
480
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["nowMs"],"sources":["../src/boot-trace.ts","../src/fps-widget.ts","../src/frame-budget.ts","../src/overlay.ts","../src/perf-output.ts","../src/perf-recorder.ts","../src/stats.ts","../src/time-control.ts"],"sourcesContent":["export type BootEntry = {\n readonly name: string;\n readonly t: number;\n};\n\nexport type BootTraceHandle = {\n mark(name: string): void;\n dump(): string | null;\n reset(): void;\n getEntries(): readonly BootEntry[];\n};\n\nfunction nowMs(): number {\n if (typeof performance !== 'undefined' && typeof performance.now === 'function') {\n return performance.now();\n }\n return Date.now();\n}\n\nexport function createBootTrace(label = 'boot-trace'): BootTraceHandle {\n const entries: BootEntry[] = [];\n let startT: number | null = null;\n\n function mark(name: string): void {\n if (startT === null) {\n startT = nowMs();\n entries.push({ name, t: 0 });\n } else {\n entries.push({ name, t: nowMs() - startT });\n }\n }\n\n function dump(): string | null {\n if (entries.length === 0) return null;\n const parts: string[] = [];\n for (let i = 1; i < entries.length; i++) {\n const prev = entries[i - 1];\n const cur = entries[i];\n if (!prev || !cur) continue;\n parts.push(`${prev.name}->${cur.name}=${(cur.t - prev.t).toFixed(1)}ms`);\n }\n const last = entries[entries.length - 1];\n const totalMs = last ? last.t.toFixed(1) : '0.0';\n const stepStr = parts.length > 0 ? ` ${parts.join(' ')}` : '';\n return `[${label}] total=${totalMs}ms${stepStr}`;\n }\n\n function reset(): void {\n entries.length = 0;\n startT = null;\n }\n\n function getEntries(): readonly BootEntry[] {\n return entries.slice();\n }\n\n return { mark, dump, reset, getEntries };\n}\n","import type { DebugStats } from './stats.js';\n\n/**\n * Formatter for a compact FPS / stats overlay.\n *\n * Consumes a `DebugStats` snapshot and exposes formatted strings ready\n * for the host to draw (Skia `canvas.drawText`, an RN `<Text>` overlay,\n * whatever). The widget itself has no rendering dependency so it stays\n * drop-in across renderers.\n *\n * Wrap in `__DEV__` at the call site for tree-shaking.\n */\nexport interface FpsWidget {\n /** Rebuild `line` / `lines` from the latest stats. */\n update(stats: DebugStats): void;\n /** Compact one-line summary, e.g. \"60 FPS | 16.7ms | e:42 d:8\". */\n line: string;\n /** Multi-line breakdown — one string per stat row. */\n readonly lines: string[];\n}\n\n/** Options for the FPS widget formatter. */\nexport interface FpsWidgetOptions {\n /** Show entity count in the one-line summary. Default true. */\n showEntities?: boolean;\n /** Show draw call count in the one-line summary. Default true. */\n showDrawCalls?: boolean;\n /** Number of decimals for milliseconds. Default 1. */\n msPrecision?: number;\n}\n\n/** Create a new FPS widget formatter. */\nexport function createFpsWidget(options: FpsWidgetOptions = {}): FpsWidget {\n const showEntities = options.showEntities ?? true;\n const showDrawCalls = options.showDrawCalls ?? true;\n const msPrecision = options.msPrecision ?? 1;\n const lines: string[] = [];\n\n const widget: FpsWidget = {\n line: '',\n lines,\n update(stats: DebugStats): void {\n const fps = Math.round(stats.fps);\n const ms = (stats.rawDt * 1000).toFixed(msPrecision);\n\n let summary = `${fps} FPS | ${ms}ms`;\n if (showEntities) summary += ` | e:${stats.entityCount}`;\n if (showDrawCalls) summary += ` d:${stats.drawCalls}`;\n widget.line = summary;\n\n lines.length = 0;\n lines.push(`FPS: ${fps}`);\n lines.push(`dt: ${ms}ms`);\n lines.push(`frame: ${stats.frame}`);\n lines.push(`entities: ${stats.entityCount}`);\n lines.push(`draws: ${stats.drawCalls}`);\n },\n };\n return widget;\n}\n","export type FrameBudgetLimits = Record<string, number>;\nexport type FrameBudgetSnapshot = Record<string, number>;\n\nexport type FrameBudgetHandle = {\n recordFrame(dtSec: number): void;\n recordCounters(snapshot: FrameBudgetSnapshot): void;\n getSnapshot(): Readonly<FrameBudgetSnapshot>;\n getAvgFps(): number;\n resetFpsRing(): void;\n};\n\ntype FrameBudgetOpts = {\n limits: FrameBudgetLimits;\n fpsThreshold?: number;\n ringSize?: number;\n onWatchdog?: () => void;\n debug?: boolean;\n};\n\nexport function createFrameBudget(opts: FrameBudgetOpts): FrameBudgetHandle {\n const { limits, onWatchdog, debug = false } = opts;\n const fpsThreshold = opts.fpsThreshold ?? 55;\n const ringSize = opts.ringSize ?? 180;\n\n const ring = new Float32Array(ringSize);\n const limitKeys = Object.keys(limits);\n const _lastSnapshot: Record<string, number> = {};\n for (const k of limitKeys) {\n _lastSnapshot[k] = 0;\n }\n\n let head = 0;\n let filled = 0;\n let watchdogFired = false;\n\n function recordFrame(dtSec: number): void {\n ring[head] = dtSec;\n head = (head + 1) % ringSize;\n if (filled < ringSize) filled += 1;\n\n if (filled === ringSize && !watchdogFired) {\n if (getAvgFps() < fpsThreshold) {\n watchdogFired = true;\n onWatchdog?.();\n }\n }\n }\n\n function recordCounters(snapshot: FrameBudgetSnapshot): void {\n for (let i = 0; i < limitKeys.length; i++) {\n const k = limitKeys[i] as string;\n const v = snapshot[k] ?? 0;\n _lastSnapshot[k] = v;\n if (debug && v > (limits[k] as number)) {\n console.warn(`[frame-budget] ${k} over limit: ${v} > ${limits[k]}`);\n }\n }\n }\n\n function getSnapshot(): Readonly<FrameBudgetSnapshot> {\n return _lastSnapshot;\n }\n\n function getAvgFps(): number {\n if (filled < ringSize) return 0;\n let sum = 0;\n for (let i = 0; i < ringSize; i++) {\n sum += ring[i] as number;\n }\n const avgDt = sum / ringSize;\n return avgDt > 0 ? 1 / avgDt : 0;\n }\n\n function resetFpsRing(): void {\n ring.fill(0);\n head = 0;\n filled = 0;\n watchdogFired = false;\n }\n\n return { recordFrame, recordCounters, getSnapshot, getAvgFps, resetFpsRing };\n}\n","/**\n * DebugOverlay — configuration for debug visualization overlays.\n * The actual rendering is done by the host (e.g., @flare-engine/react) reading\n * these flags and drawing appropriate debug shapes.\n * Wrap in `__DEV__` checks at the call site for tree-shaking.\n */\nexport interface OverlayFlags {\n /** Show collision bounding boxes. */\n showCollisionBounds: boolean;\n /** Show entity origin points. */\n showEntityOrigins: boolean;\n /** Show velocity vectors. */\n showVelocityVectors: boolean;\n /** Show FPS/stats overlay. */\n showStats: boolean;\n}\n\n/** Debug draw command types. */\nexport interface DebugRect {\n readonly type: 'rect';\n x: number;\n y: number;\n width: number;\n height: number;\n color: string;\n}\n\nexport interface DebugCircle {\n readonly type: 'circle';\n x: number;\n y: number;\n radius: number;\n color: string;\n}\n\nexport interface DebugLine {\n readonly type: 'line';\n x1: number;\n y1: number;\n x2: number;\n y2: number;\n color: string;\n}\n\n/** Union of debug draw primitive commands. */\nexport type DebugDrawCommand = DebugRect | DebugCircle | DebugLine;\n\n/**\n * DebugOverlay — collects debug draw commands for the current frame.\n * Commands are generated based on active overlay flags, then consumed\n * by the renderer.\n */\nexport class DebugOverlay {\n /** Active overlay flags. */\n readonly flags: OverlayFlags = {\n showCollisionBounds: false,\n showEntityOrigins: false,\n showVelocityVectors: false,\n showStats: false,\n };\n\n /** Queued debug draw commands for the current frame. */\n private _commands: DebugDrawCommand[] = [];\n\n /** Number of queued commands. */\n get commandCount(): number {\n return this._commands.length;\n }\n\n /** Get all commands (read-only view). */\n get commands(): readonly DebugDrawCommand[] {\n return this._commands;\n }\n\n /** Add a debug rectangle. */\n drawRect(x: number, y: number, width: number, height: number, color = '#00ff00'): void {\n this._commands.push({ type: 'rect', x, y, width, height, color });\n }\n\n /** Add a debug circle. */\n drawCircle(x: number, y: number, radius: number, color = '#00ff00'): void {\n this._commands.push({ type: 'circle', x, y, radius, color });\n }\n\n /** Add a debug line. */\n drawLine(x1: number, y1: number, x2: number, y2: number, color = '#ffff00'): void {\n this._commands.push({ type: 'line', x1, y1, x2, y2, color });\n }\n\n /** Clear all commands. Call at the start of each frame. */\n clear(): void {\n this._commands.length = 0;\n }\n\n /** Toggle a specific overlay flag. */\n toggleFlag(flag: keyof OverlayFlags): void {\n this.flags[flag] = !this.flags[flag];\n }\n\n /** Enable all overlays. */\n enableAll(): void {\n this.flags.showCollisionBounds = true;\n this.flags.showEntityOrigins = true;\n this.flags.showVelocityVectors = true;\n this.flags.showStats = true;\n }\n\n /** Disable all overlays. */\n disableAll(): void {\n this.flags.showCollisionBounds = false;\n this.flags.showEntityOrigins = false;\n this.flags.showVelocityVectors = false;\n this.flags.showStats = false;\n }\n}\n","import type { PerfReport } from './perf-recorder.js';\n\nexport const PERF_BENCH_TAG = '[perf-bench]';\n\nexport function emitPerfReport(report: PerfReport): void {\n console.log(`${PERF_BENCH_TAG} ${JSON.stringify(report)}`);\n}\n","export type PerfSectionStats = {\n readonly name: string;\n readonly count: number;\n readonly min: number;\n readonly max: number;\n readonly mean: number;\n readonly p50: number;\n readonly p95: number;\n readonly p99: number;\n};\n\nexport type PerfCounterStats = {\n readonly name: string;\n readonly count: number;\n readonly min: number;\n readonly max: number;\n readonly sum: number;\n readonly mean: number;\n};\n\nexport type PerfReport = {\n readonly label: string;\n readonly durationMs: number;\n readonly frameCount: number;\n readonly sections: readonly PerfSectionStats[];\n readonly counters: readonly PerfCounterStats[];\n};\n\nexport type PerfRecorderHandle = {\n beginSection(name: string): void;\n endSection(name: string): void;\n recordFrame(counters?: Record<string, number>): void;\n flush(): PerfReport;\n reset(): void;\n};\n\ntype SectionState = {\n name: string;\n ring: Float32Array;\n ringSize: number;\n head: number;\n filled: number;\n startT: number;\n};\n\ntype CounterState = {\n name: string;\n count: number;\n min: number;\n max: number;\n sum: number;\n};\n\ntype PerfRecorderOpts = {\n label?: string;\n ringSize?: number;\n};\n\nfunction nowMs(): number {\n if (typeof performance !== 'undefined' && typeof performance.now === 'function') {\n return performance.now();\n }\n return Date.now();\n}\n\nfunction percentile(sorted: Float32Array, n: number, p: number): number {\n if (n === 0) return 0;\n if (n === 1) return sorted[0] as number;\n const idx = (p / 100) * (n - 1);\n const lo = Math.floor(idx);\n const hi = Math.ceil(idx);\n const a = sorted[lo] as number;\n const b = sorted[hi] as number;\n return a + (b - a) * (idx - lo);\n}\n\nexport function createPerfRecorder(opts: PerfRecorderOpts = {}): PerfRecorderHandle {\n const label = opts.label ?? 'perf';\n const ringSize = opts.ringSize ?? 1800;\n\n const sections = new Map<string, SectionState>();\n const counters = new Map<string, CounterState>();\n let frameCount = 0;\n let startT: number | null = null;\n\n // Reusable sort buffer — allocated once on first flush, grown as needed\n let sortBuf = new Float32Array(ringSize);\n\n function getOrCreateSection(name: string): SectionState {\n let s = sections.get(name);\n if (s === undefined) {\n s = {\n name,\n ring: new Float32Array(ringSize),\n ringSize,\n head: 0,\n filled: 0,\n startT: 0,\n };\n sections.set(name, s);\n }\n return s;\n }\n\n function getOrCreateCounter(name: string): CounterState {\n let c = counters.get(name);\n if (c === undefined) {\n c = { name, count: 0, min: Number.POSITIVE_INFINITY, max: Number.NEGATIVE_INFINITY, sum: 0 };\n counters.set(name, c);\n }\n return c;\n }\n\n function beginSection(name: string): void {\n const s = getOrCreateSection(name);\n s.startT = nowMs();\n }\n\n function endSection(name: string): void {\n const s = sections.get(name);\n if (s === undefined) return;\n const elapsed = nowMs() - s.startT;\n s.ring[s.head] = elapsed;\n s.head = (s.head + 1) % s.ringSize;\n if (s.filled < s.ringSize) s.filled += 1;\n }\n\n function recordFrame(frameCounters?: Record<string, number>): void {\n if (startT === null) startT = nowMs();\n frameCount += 1;\n if (frameCounters === undefined) return;\n for (const name in frameCounters) {\n const v = frameCounters[name] as number;\n const c = getOrCreateCounter(name);\n c.count += 1;\n if (v < c.min) c.min = v;\n if (v > c.max) c.max = v;\n c.sum += v;\n }\n }\n\n function flush(): PerfReport {\n const now = nowMs();\n const durationMs = startT !== null ? now - startT : 0;\n\n const sectionStats: PerfSectionStats[] = [];\n for (const s of sections.values()) {\n const n = s.filled;\n if (n === 0) {\n sectionStats.push({\n name: s.name,\n count: 0,\n min: 0,\n max: 0,\n mean: 0,\n p50: 0,\n p95: 0,\n p99: 0,\n });\n continue;\n }\n // Grow sort buffer if needed\n if (sortBuf.length < n) sortBuf = new Float32Array(n);\n let sum = 0;\n let minV = Number.POSITIVE_INFINITY;\n let maxV = Number.NEGATIVE_INFINITY;\n // Copy ring in chronological order\n const start = s.filled < s.ringSize ? 0 : s.head;\n for (let i = 0; i < n; i++) {\n const v = s.ring[(start + i) % s.ringSize] as number;\n sortBuf[i] = v;\n sum += v;\n if (v < minV) minV = v;\n if (v > maxV) maxV = v;\n }\n // Sort only the filled slice\n const slice = sortBuf.subarray(0, n);\n slice.sort();\n sectionStats.push({\n name: s.name,\n count: n,\n min: minV,\n max: maxV,\n mean: sum / n,\n p50: percentile(slice, n, 50),\n p95: percentile(slice, n, 95),\n p99: percentile(slice, n, 99),\n });\n }\n\n const counterStats: PerfCounterStats[] = [];\n for (const c of counters.values()) {\n counterStats.push({\n name: c.name,\n count: c.count,\n min: c.count > 0 ? c.min : 0,\n max: c.count > 0 ? c.max : 0,\n sum: c.sum,\n mean: c.count > 0 ? c.sum / c.count : 0,\n });\n }\n\n return { label, durationMs, frameCount, sections: sectionStats, counters: counterStats };\n }\n\n function reset(): void {\n for (const s of sections.values()) {\n s.ring.fill(0);\n s.head = 0;\n s.filled = 0;\n s.startT = 0;\n }\n for (const c of counters.values()) {\n c.count = 0;\n c.min = Number.POSITIVE_INFINITY;\n c.max = Number.NEGATIVE_INFINITY;\n c.sum = 0;\n }\n frameCount = 0;\n startT = null;\n }\n\n return { beginSection, endSection, recordFrame, flush, reset };\n}\n","/** Snapshot of engine stats for a single frame. */\nexport interface DebugStats {\n /** Frames per second (smoothed). */\n fps: number;\n /** Raw delta time in seconds. */\n rawDt: number;\n /** Scaled delta time in seconds. */\n dt: number;\n /** Current frame number. */\n frame: number;\n /** Total active entities (set by user). */\n entityCount: number;\n /** Draw calls this frame (set by user). */\n drawCalls: number;\n}\n\n/**\n * StatsTracker — collects and exposes per-frame debug statistics.\n * Wrap in `__DEV__` checks at the call site for tree-shaking.\n */\nexport class StatsTracker {\n /** Current frame stats (read-only snapshot). */\n readonly stats: DebugStats = {\n fps: 0,\n rawDt: 0,\n dt: 0,\n frame: 0,\n entityCount: 0,\n drawCalls: 0,\n };\n\n /** Update timing stats from the clock. */\n updateFromClock(fps: number, rawDt: number, dt: number, frame: number): void {\n this.stats.fps = fps;\n this.stats.rawDt = rawDt;\n this.stats.dt = dt;\n this.stats.frame = frame;\n }\n\n /** Set entity count for this frame. */\n setEntityCount(count: number): void {\n this.stats.entityCount = count;\n }\n\n /** Set draw call count for this frame. */\n setDrawCalls(count: number): void {\n this.stats.drawCalls = count;\n }\n\n /** Reset all counters to zero. */\n reset(): void {\n this.stats.fps = 0;\n this.stats.rawDt = 0;\n this.stats.dt = 0;\n this.stats.frame = 0;\n this.stats.entityCount = 0;\n this.stats.drawCalls = 0;\n }\n}\n","import type { Clock } from '@flare-engine/core';\n\n/**\n * TimeControl — pause, step-frame, and slow-motion via Clock.timescale.\n * Wrap in `__DEV__` checks at the call site for tree-shaking.\n */\nexport class TimeControl {\n private _clock: Clock;\n private _savedTimescale = 1;\n private _paused = false;\n private _stepRequested = false;\n\n constructor(clock: Clock) {\n this._clock = clock;\n }\n\n /** Whether the game is currently paused. */\n get paused(): boolean {\n return this._paused;\n }\n\n /** Current time scale. */\n get timescale(): number {\n return this._clock.timescale;\n }\n\n /** Pause the game (sets timescale to 0). */\n pause(): void {\n if (this._paused) return;\n this._savedTimescale = this._clock.timescale;\n this._clock.timescale = 0;\n this._paused = true;\n }\n\n /** Resume the game (restores previous timescale). */\n resume(): void {\n if (!this._paused) return;\n this._clock.timescale = this._savedTimescale;\n this._paused = false;\n this._stepRequested = false;\n }\n\n /** Toggle pause/resume. */\n toggle(): void {\n if (this._paused) {\n this.resume();\n } else {\n this.pause();\n }\n }\n\n /**\n * Request a single-frame step while paused.\n * Call this, then on the next update check `consumeStep()`.\n */\n step(): void {\n if (!this._paused) return;\n this._stepRequested = true;\n }\n\n /**\n * Consume a pending step request. Returns true if a step was requested.\n * When true, the caller should run one frame with the saved timescale,\n * then re-pause.\n */\n consumeStep(): boolean {\n if (!this._stepRequested) return false;\n this._stepRequested = false;\n return true;\n }\n\n /** Set slow-motion multiplier (e.g., 0.5 for half-speed). */\n setTimescale(scale: number): void {\n if (this._paused) {\n this._savedTimescale = scale;\n } else {\n this._clock.timescale = scale;\n }\n }\n}\n"],"mappings":";AAYA,SAASA,UAAgB;CACvB,IAAI,OAAO,gBAAgB,eAAe,OAAO,YAAY,QAAQ,YACnE,OAAO,YAAY,IAAI;CAEzB,OAAO,KAAK,IAAI;AAClB;AAEA,SAAgB,gBAAgB,QAAQ,cAA+B;CACrE,MAAM,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T;;CAGA,aAAa,OAAqB;EAChC,IAAI,KAAK,SACP,KAAK,kBAAkB;OAEvB,KAAK,OAAO,YAAY;CAE5B;AACF"}
1
+ {"version":3,"file":"index.mjs","names":["nowMs"],"sources":["../src/boot-trace.ts","../src/fps-widget.ts","../src/frame-budget.ts","../src/overlay.ts","../src/perf-output.ts","../src/perf-recorder.ts","../src/stats.ts","../src/time-control.ts"],"sourcesContent":["export type BootEntry = {\n readonly name: string;\n readonly t: number;\n};\n\nexport type BootTraceHandle = {\n mark(name: string): void;\n dump(): string | null;\n reset(): void;\n getEntries(): readonly BootEntry[];\n};\n\nfunction nowMs(): number {\n if (typeof performance !== 'undefined' && typeof performance.now === 'function') {\n return performance.now();\n }\n return Date.now();\n}\n\nexport function createBootTrace(label = 'boot-trace'): BootTraceHandle {\n const entries: BootEntry[] = [];\n let startT: number | null = null;\n\n function mark(name: string): void {\n if (startT === null) {\n startT = nowMs();\n entries.push({ name, t: 0 });\n } else {\n entries.push({ name, t: nowMs() - startT });\n }\n }\n\n function dump(): string | null {\n if (entries.length === 0) return null;\n const parts: string[] = [];\n for (let i = 1; i < entries.length; i++) {\n const prev = entries[i - 1];\n const cur = entries[i];\n if (!prev || !cur) continue;\n parts.push(`${prev.name}->${cur.name}=${(cur.t - prev.t).toFixed(1)}ms`);\n }\n const last = entries[entries.length - 1];\n const totalMs = last ? last.t.toFixed(1) : '0.0';\n const stepStr = parts.length > 0 ? ` ${parts.join(' ')}` : '';\n return `[${label}] total=${totalMs}ms${stepStr}`;\n }\n\n function reset(): void {\n entries.length = 0;\n startT = null;\n }\n\n function getEntries(): readonly BootEntry[] {\n return entries.slice();\n }\n\n return { mark, dump, reset, getEntries };\n}\n","import type { DebugStats } from './stats.js';\n\n/**\n * Formatter for a compact FPS / stats overlay.\n *\n * Consumes a `DebugStats` snapshot and exposes formatted strings ready\n * for the host to draw (Skia `canvas.drawText`, an RN `<Text>` overlay,\n * whatever). The widget itself has no rendering dependency so it stays\n * drop-in across renderers.\n *\n * Wrap in `__DEV__` at the call site for tree-shaking.\n */\nexport interface FpsWidget {\n /** Rebuild `line` / `lines` from the latest stats. */\n update(stats: DebugStats): void;\n /** Compact one-line summary, e.g. \"60 FPS | 16.7ms | e:42 d:8\". */\n line: string;\n /** Multi-line breakdown — one string per stat row. */\n readonly lines: string[];\n}\n\n/** Options for the FPS widget formatter. */\nexport interface FpsWidgetOptions {\n /** Show entity count in the one-line summary. Default true. */\n showEntities?: boolean;\n /** Show draw call count in the one-line summary. Default true. */\n showDrawCalls?: boolean;\n /** Number of decimals for milliseconds. Default 1. */\n msPrecision?: number;\n}\n\n/** Create a new FPS widget formatter. */\nexport function createFpsWidget(options: FpsWidgetOptions = {}): FpsWidget {\n const showEntities = options.showEntities ?? true;\n const showDrawCalls = options.showDrawCalls ?? true;\n const msPrecision = options.msPrecision ?? 1;\n const lines: string[] = [];\n\n const widget: FpsWidget = {\n line: '',\n lines,\n update(stats: DebugStats): void {\n const fps = Math.round(stats.fps);\n const ms = (stats.rawDt * 1000).toFixed(msPrecision);\n\n let summary = `${fps} FPS | ${ms}ms`;\n if (showEntities) summary += ` | e:${stats.entityCount}`;\n if (showDrawCalls) summary += ` d:${stats.drawCalls}`;\n widget.line = summary;\n\n lines.length = 0;\n lines.push(`FPS: ${fps}`);\n lines.push(`dt: ${ms}ms`);\n lines.push(`frame: ${stats.frame}`);\n lines.push(`entities: ${stats.entityCount}`);\n lines.push(`draws: ${stats.drawCalls}`);\n },\n };\n return widget;\n}\n","export type FrameBudgetLimits = Record<string, number>;\nexport type FrameBudgetSnapshot = Record<string, number>;\n\nexport type FrameBudgetHandle = {\n recordFrame(dtSec: number): void;\n recordCounters(snapshot: FrameBudgetSnapshot): void;\n getSnapshot(): Readonly<FrameBudgetSnapshot>;\n getAvgFps(): number;\n resetFpsRing(): void;\n};\n\ntype FrameBudgetOpts = {\n limits: FrameBudgetLimits;\n fpsThreshold?: number;\n ringSize?: number;\n onWatchdog?: () => void;\n debug?: boolean;\n};\n\nexport function createFrameBudget(opts: FrameBudgetOpts): FrameBudgetHandle {\n const { limits, onWatchdog, debug = false } = opts;\n const fpsThreshold = opts.fpsThreshold ?? 55;\n const ringSize = opts.ringSize ?? 180;\n\n const ring = new Float32Array(ringSize);\n const limitKeys = Object.keys(limits);\n const _lastSnapshot: Record<string, number> = {};\n for (const k of limitKeys) {\n _lastSnapshot[k] = 0;\n }\n\n let head = 0;\n let filled = 0;\n let watchdogFired = false;\n\n function recordFrame(dtSec: number): void {\n ring[head] = dtSec;\n head = (head + 1) % ringSize;\n if (filled < ringSize) filled += 1;\n\n if (filled === ringSize && !watchdogFired) {\n if (getAvgFps() < fpsThreshold) {\n watchdogFired = true;\n onWatchdog?.();\n }\n }\n }\n\n function recordCounters(snapshot: FrameBudgetSnapshot): void {\n for (let i = 0; i < limitKeys.length; i++) {\n const k = limitKeys[i] as string;\n const v = snapshot[k] ?? 0;\n _lastSnapshot[k] = v;\n if (debug && v > (limits[k] as number)) {\n console.warn(`[frame-budget] ${k} over limit: ${v} > ${limits[k]}`);\n }\n }\n }\n\n function getSnapshot(): Readonly<FrameBudgetSnapshot> {\n return _lastSnapshot;\n }\n\n function getAvgFps(): number {\n if (filled < ringSize) return 0;\n let sum = 0;\n for (let i = 0; i < ringSize; i++) {\n sum += ring[i] as number;\n }\n const avgDt = sum / ringSize;\n return avgDt > 0 ? 1 / avgDt : 0;\n }\n\n function resetFpsRing(): void {\n ring.fill(0);\n head = 0;\n filled = 0;\n watchdogFired = false;\n }\n\n return { recordFrame, recordCounters, getSnapshot, getAvgFps, resetFpsRing };\n}\n","/**\n * DebugOverlay — configuration for debug visualization overlays.\n * The actual rendering is done by the host (e.g., @flare-engine/react) reading\n * these flags and drawing appropriate debug shapes.\n * Wrap in `__DEV__` checks at the call site for tree-shaking.\n */\nexport interface OverlayFlags {\n /** Show collision bounding boxes. */\n showCollisionBounds: boolean;\n /** Show entity origin points. */\n showEntityOrigins: boolean;\n /** Show velocity vectors. */\n showVelocityVectors: boolean;\n /** Show FPS/stats overlay. */\n showStats: boolean;\n}\n\n/** Debug draw command types. */\nexport interface DebugRect {\n readonly type: 'rect';\n x: number;\n y: number;\n width: number;\n height: number;\n color: string;\n}\n\nexport interface DebugCircle {\n readonly type: 'circle';\n x: number;\n y: number;\n radius: number;\n color: string;\n}\n\nexport interface DebugLine {\n readonly type: 'line';\n x1: number;\n y1: number;\n x2: number;\n y2: number;\n color: string;\n}\n\n/** Union of debug draw primitive commands. */\nexport type DebugDrawCommand = DebugRect | DebugCircle | DebugLine;\n\n/**\n * DebugOverlay — collects debug draw commands for the current frame.\n * Commands are generated based on active overlay flags, then consumed\n * by the renderer.\n */\nexport class DebugOverlay {\n /** Active overlay flags. */\n readonly flags: OverlayFlags = {\n showCollisionBounds: false,\n showEntityOrigins: false,\n showVelocityVectors: false,\n showStats: false,\n };\n\n /** Queued debug draw commands for the current frame. */\n private _commands: DebugDrawCommand[] = [];\n\n /** Number of queued commands. */\n get commandCount(): number {\n return this._commands.length;\n }\n\n /** Get all commands (read-only view). */\n get commands(): readonly DebugDrawCommand[] {\n return this._commands;\n }\n\n /** Add a debug rectangle. */\n drawRect(x: number, y: number, width: number, height: number, color = '#00ff00'): void {\n this._commands.push({ type: 'rect', x, y, width, height, color });\n }\n\n /** Add a debug circle. */\n drawCircle(x: number, y: number, radius: number, color = '#00ff00'): void {\n this._commands.push({ type: 'circle', x, y, radius, color });\n }\n\n /** Add a debug line. */\n drawLine(x1: number, y1: number, x2: number, y2: number, color = '#ffff00'): void {\n this._commands.push({ type: 'line', x1, y1, x2, y2, color });\n }\n\n /** Clear all commands. Call at the start of each frame. */\n clear(): void {\n this._commands.length = 0;\n }\n\n /** Toggle a specific overlay flag. */\n toggleFlag(flag: keyof OverlayFlags): void {\n this.flags[flag] = !this.flags[flag];\n }\n\n /** Enable all overlays. */\n enableAll(): void {\n this.flags.showCollisionBounds = true;\n this.flags.showEntityOrigins = true;\n this.flags.showVelocityVectors = true;\n this.flags.showStats = true;\n }\n\n /** Disable all overlays. */\n disableAll(): void {\n this.flags.showCollisionBounds = false;\n this.flags.showEntityOrigins = false;\n this.flags.showVelocityVectors = false;\n this.flags.showStats = false;\n }\n}\n","import type { PerfReport } from './perf-recorder.js';\n\nexport const PERF_BENCH_TAG = '[perf-bench]';\n\nexport function emitPerfReport(report: PerfReport): void {\n console.log(`${PERF_BENCH_TAG} ${JSON.stringify(report)}`);\n}\n","export type PerfSectionStats = {\n readonly name: string;\n readonly count: number;\n readonly min: number;\n readonly max: number;\n readonly mean: number;\n readonly p50: number;\n readonly p95: number;\n readonly p99: number;\n};\n\nexport type PerfCounterStats = {\n readonly name: string;\n readonly count: number;\n readonly min: number;\n readonly max: number;\n readonly sum: number;\n readonly mean: number;\n};\n\nexport type PerfReport = {\n readonly label: string;\n readonly durationMs: number;\n readonly frameCount: number;\n readonly sections: readonly PerfSectionStats[];\n readonly counters: readonly PerfCounterStats[];\n};\n\nexport type PerfRecorderHandle = {\n beginSection(name: string): void;\n endSection(name: string): void;\n recordFrame(counters?: Record<string, number>): void;\n flush(): PerfReport;\n reset(): void;\n};\n\ntype SectionState = {\n name: string;\n ring: Float32Array;\n ringSize: number;\n head: number;\n filled: number;\n startT: number;\n};\n\ntype CounterState = {\n name: string;\n count: number;\n min: number;\n max: number;\n sum: number;\n};\n\ntype PerfRecorderOpts = {\n label?: string;\n ringSize?: number;\n};\n\nfunction nowMs(): number {\n if (typeof performance !== 'undefined' && typeof performance.now === 'function') {\n return performance.now();\n }\n return Date.now();\n}\n\nfunction percentile(sorted: Float32Array, n: number, p: number): number {\n if (n === 0) return 0;\n if (n === 1) return sorted[0] as number;\n const idx = (p / 100) * (n - 1);\n const lo = Math.floor(idx);\n const hi = Math.ceil(idx);\n const a = sorted[lo] as number;\n const b = sorted[hi] as number;\n return a + (b - a) * (idx - lo);\n}\n\nexport function createPerfRecorder(opts: PerfRecorderOpts = {}): PerfRecorderHandle {\n const label = opts.label ?? 'perf';\n const ringSize = opts.ringSize ?? 1800;\n\n const sections = new Map<string, SectionState>();\n const counters = new Map<string, CounterState>();\n let frameCount = 0;\n let startT: number | null = null;\n\n // Reusable sort buffer — allocated once on first flush, grown as needed\n let sortBuf = new Float32Array(ringSize);\n\n function getOrCreateSection(name: string): SectionState {\n let s = sections.get(name);\n if (s === undefined) {\n s = {\n name,\n ring: new Float32Array(ringSize),\n ringSize,\n head: 0,\n filled: 0,\n startT: 0,\n };\n sections.set(name, s);\n }\n return s;\n }\n\n function getOrCreateCounter(name: string): CounterState {\n let c = counters.get(name);\n if (c === undefined) {\n c = { name, count: 0, min: Number.POSITIVE_INFINITY, max: Number.NEGATIVE_INFINITY, sum: 0 };\n counters.set(name, c);\n }\n return c;\n }\n\n function beginSection(name: string): void {\n const s = getOrCreateSection(name);\n s.startT = nowMs();\n }\n\n function endSection(name: string): void {\n const s = sections.get(name);\n if (s === undefined) return;\n const elapsed = nowMs() - s.startT;\n s.ring[s.head] = elapsed;\n s.head = (s.head + 1) % s.ringSize;\n if (s.filled < s.ringSize) s.filled += 1;\n }\n\n function recordFrame(frameCounters?: Record<string, number>): void {\n if (startT === null) startT = nowMs();\n frameCount += 1;\n if (frameCounters === undefined) return;\n for (const name in frameCounters) {\n const v = frameCounters[name] as number;\n const c = getOrCreateCounter(name);\n c.count += 1;\n if (v < c.min) c.min = v;\n if (v > c.max) c.max = v;\n c.sum += v;\n }\n }\n\n function flush(): PerfReport {\n const now = nowMs();\n const durationMs = startT !== null ? now - startT : 0;\n\n const sectionStats: PerfSectionStats[] = [];\n for (const s of sections.values()) {\n const n = s.filled;\n if (n === 0) {\n sectionStats.push({\n name: s.name,\n count: 0,\n min: 0,\n max: 0,\n mean: 0,\n p50: 0,\n p95: 0,\n p99: 0,\n });\n continue;\n }\n // Grow sort buffer if needed\n if (sortBuf.length < n) sortBuf = new Float32Array(n);\n let sum = 0;\n let minV = Number.POSITIVE_INFINITY;\n let maxV = Number.NEGATIVE_INFINITY;\n // Copy ring in chronological order\n const start = s.filled < s.ringSize ? 0 : s.head;\n for (let i = 0; i < n; i++) {\n const v = s.ring[(start + i) % s.ringSize] as number;\n sortBuf[i] = v;\n sum += v;\n if (v < minV) minV = v;\n if (v > maxV) maxV = v;\n }\n // Sort only the filled slice\n const slice = sortBuf.subarray(0, n);\n slice.sort();\n sectionStats.push({\n name: s.name,\n count: n,\n min: minV,\n max: maxV,\n mean: sum / n,\n p50: percentile(slice, n, 50),\n p95: percentile(slice, n, 95),\n p99: percentile(slice, n, 99),\n });\n }\n\n const counterStats: PerfCounterStats[] = [];\n for (const c of counters.values()) {\n counterStats.push({\n name: c.name,\n count: c.count,\n min: c.count > 0 ? c.min : 0,\n max: c.count > 0 ? c.max : 0,\n sum: c.sum,\n mean: c.count > 0 ? c.sum / c.count : 0,\n });\n }\n\n return { label, durationMs, frameCount, sections: sectionStats, counters: counterStats };\n }\n\n function reset(): void {\n for (const s of sections.values()) {\n s.ring.fill(0);\n s.head = 0;\n s.filled = 0;\n s.startT = 0;\n }\n for (const c of counters.values()) {\n c.count = 0;\n c.min = Number.POSITIVE_INFINITY;\n c.max = Number.NEGATIVE_INFINITY;\n c.sum = 0;\n }\n frameCount = 0;\n startT = null;\n }\n\n return { beginSection, endSection, recordFrame, flush, reset };\n}\n","/** Snapshot of engine stats for a single frame. */\nexport interface DebugStats {\n /** Frames per second (smoothed). */\n fps: number;\n /** Raw delta time in seconds. */\n rawDt: number;\n /** Scaled delta time in seconds. */\n dt: number;\n /** Current frame number. */\n frame: number;\n /** Total active entities (set by user). */\n entityCount: number;\n /** Draw calls this frame (set by user). */\n drawCalls: number;\n}\n\n/**\n * StatsTracker — collects and exposes per-frame debug statistics.\n * Wrap in `__DEV__` checks at the call site for tree-shaking.\n */\nexport class StatsTracker {\n /** Current frame stats (read-only snapshot). */\n readonly stats: DebugStats = {\n fps: 0,\n rawDt: 0,\n dt: 0,\n frame: 0,\n entityCount: 0,\n drawCalls: 0,\n };\n\n /** Update timing stats from the clock. */\n updateFromClock(fps: number, rawDt: number, dt: number, frame: number): void {\n this.stats.fps = fps;\n this.stats.rawDt = rawDt;\n this.stats.dt = dt;\n this.stats.frame = frame;\n }\n\n /** Set entity count for this frame. */\n setEntityCount(count: number): void {\n this.stats.entityCount = count;\n }\n\n /** Set draw call count for this frame. */\n setDrawCalls(count: number): void {\n this.stats.drawCalls = count;\n }\n\n /** Reset all counters to zero. */\n reset(): void {\n this.stats.fps = 0;\n this.stats.rawDt = 0;\n this.stats.dt = 0;\n this.stats.frame = 0;\n this.stats.entityCount = 0;\n this.stats.drawCalls = 0;\n }\n}\n","import type { Clock } from '@flare-engine/core';\n\n/**\n * TimeControl — pause, step-frame, and slow-motion via Clock.timescale.\n * Wrap in `__DEV__` checks at the call site for tree-shaking.\n */\nexport class TimeControl {\n private _clock: Clock;\n private _savedTimescale = 1;\n private _paused = false;\n private _stepRequested = false;\n\n constructor(clock: Clock) {\n this._clock = clock;\n }\n\n /** Whether the game is currently paused. */\n get paused(): boolean {\n return this._paused;\n }\n\n /** Current time scale. */\n get timescale(): number {\n return this._clock.timescale;\n }\n\n /** Pause the game (sets timescale to 0). */\n pause(): void {\n if (this._paused) return;\n this._savedTimescale = this._clock.timescale;\n this._clock.timescale = 0;\n this._paused = true;\n }\n\n /** Resume the game (restores previous timescale). */\n resume(): void {\n if (!this._paused) return;\n this._clock.timescale = this._savedTimescale;\n this._paused = false;\n this._stepRequested = false;\n }\n\n /** Toggle pause/resume. */\n toggle(): void {\n if (this._paused) {\n this.resume();\n } else {\n this.pause();\n }\n }\n\n /**\n * Request a single-frame step while paused.\n * Call this, then on the next update check `consumeStep()`.\n */\n step(): void {\n if (!this._paused) return;\n this._stepRequested = true;\n }\n\n /**\n * Consume a pending step request. Returns true if a step was requested.\n * When true, the caller should run one frame with the saved timescale,\n * then re-pause.\n */\n consumeStep(): boolean {\n if (!this._stepRequested) return false;\n this._stepRequested = false;\n return true;\n }\n\n /** Set slow-motion multiplier (e.g., 0.5 for half-speed). */\n setTimescale(scale: number): void {\n if (this._paused) {\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GA,SAAe;EACb,IAAI,KAAK,SACP,KAAK,OAAO;OAEZ,KAAK,MAAM;CAEf;;;;;CAMA,OAAa;EACX,IAAI,CAAC,KAAK,SAAS;EACnB,KAAK,iBAAiB;CACxB;;;;;;CAOA,cAAuB;EACrB,IAAI,CAAC,KAAK,gBAAgB,OAAO;EACjC,KAAK,iBAAiB;EACtB,OAAO;CACT;;CAGA,aAAa,OAAqB;EAChC,IAAI,KAAK,SACP,KAAK,kBAAkB;OAEvB,KAAK,OAAO,YAAY;CAE5B;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flare-engine/debug",
3
- "version": "0.4.6",
3
+ "version": "0.4.8",
4
4
  "description": "Dev overlay, stats, entity inspector, time controls",
5
5
  "keywords": ["flare-engine", "debug", "overlay", "stats"],
6
6
  "license": "Apache-2.0",
@@ -37,7 +37,7 @@
37
37
  "typecheck": "tsc --noEmit"
38
38
  },
39
39
  "dependencies": {
40
- "@flare-engine/core": "^0.4.6"
40
+ "@flare-engine/core": "^0.4.8"
41
41
  },
42
42
  "engines": {
43
43
  "node": ">=20"