blecsd 0.1.0

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.
Files changed (109) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +220 -0
  3. package/dist/3d/index.d.ts +5 -0
  4. package/dist/3d/index.js +1 -0
  5. package/dist/audio/index.d.ts +177 -0
  6. package/dist/audio/index.js +1 -0
  7. package/dist/border-D_Jb4ZJV.d.ts +257 -0
  8. package/dist/cell-DwIu2ryP.d.ts +505 -0
  9. package/dist/chunk-2UBBZFE4.js +1 -0
  10. package/dist/chunk-35LCBY6P.js +1 -0
  11. package/dist/chunk-3B7MIVW6.js +1 -0
  12. package/dist/chunk-3EGGGI5J.js +3 -0
  13. package/dist/chunk-4LWWONFK.js +1 -0
  14. package/dist/chunk-4X4N4HNQ.js +2 -0
  15. package/dist/chunk-5PELJRUQ.js +1 -0
  16. package/dist/chunk-AEJIX2MW.js +1 -0
  17. package/dist/chunk-AQ7LW75B.js +1 -0
  18. package/dist/chunk-AXZQAH4X.js +1 -0
  19. package/dist/chunk-B6Z2JFRY.js +1 -0
  20. package/dist/chunk-BCADUCOZ.js +1 -0
  21. package/dist/chunk-C5PCEQ6G.js +1 -0
  22. package/dist/chunk-CIK4AMUA.js +1 -0
  23. package/dist/chunk-DNRXW56C.js +1 -0
  24. package/dist/chunk-FC5FFAAC.js +12 -0
  25. package/dist/chunk-FGHEFXLK.js +1 -0
  26. package/dist/chunk-FYEBZAWN.js +1 -0
  27. package/dist/chunk-G7GIWWLE.js +1 -0
  28. package/dist/chunk-GYHI26UE.js +1 -0
  29. package/dist/chunk-H2YAOJDW.js +1 -0
  30. package/dist/chunk-J4JZ2NU2.js +1 -0
  31. package/dist/chunk-JKVHO4LH.js +1 -0
  32. package/dist/chunk-K2B2OXQ5.js +5 -0
  33. package/dist/chunk-K37L3G4Z.js +4 -0
  34. package/dist/chunk-KD55INV7.js +1 -0
  35. package/dist/chunk-KFAK4A3G.js +1 -0
  36. package/dist/chunk-LCN2ZITE.js +1 -0
  37. package/dist/chunk-LYSK5S63.js +1 -0
  38. package/dist/chunk-NZ55KBM6.js +1 -0
  39. package/dist/chunk-OMMJ7B5P.js +1 -0
  40. package/dist/chunk-OUXUPF3V.js +33 -0
  41. package/dist/chunk-OVT2PPGW.js +19 -0
  42. package/dist/chunk-P6CJO3BC.js +1 -0
  43. package/dist/chunk-PSXXMBVJ.js +1 -0
  44. package/dist/chunk-PXXGH3BV.js +1 -0
  45. package/dist/chunk-QIKIOVP2.js +1 -0
  46. package/dist/chunk-SHUC6JWA.js +1 -0
  47. package/dist/chunk-TDXJDLY6.js +6 -0
  48. package/dist/chunk-TWSWTBYL.js +1 -0
  49. package/dist/chunk-TYMY2TBR.js +3 -0
  50. package/dist/chunk-VNZ6CWJA.js +2 -0
  51. package/dist/chunk-VOCM5T2G.js +5 -0
  52. package/dist/chunk-W5OU7Z6J.js +1 -0
  53. package/dist/chunk-WNG4A3K7.js +4 -0
  54. package/dist/chunk-XQIGERNI.js +1 -0
  55. package/dist/chunk-XZA63ZPO.js +1 -0
  56. package/dist/chunk-YAMOSPWB.js +4 -0
  57. package/dist/chunk-YD6ULIUR.js +1 -0
  58. package/dist/chunk-Z4EZERNE.js +1 -0
  59. package/dist/cli/init.d.ts +86 -0
  60. package/dist/cli/init.js +179 -0
  61. package/dist/color-B78w3zH-.d.ts +79 -0
  62. package/dist/components/index.d.ts +10298 -0
  63. package/dist/components/index.js +1 -0
  64. package/dist/core/index.d.ts +6700 -0
  65. package/dist/core/index.js +1 -0
  66. package/dist/debug/index.d.ts +711 -0
  67. package/dist/debug/index.js +1 -0
  68. package/dist/doubleBuffer-CKQFmlPN.d.ts +95 -0
  69. package/dist/errors/index.d.ts +1110 -0
  70. package/dist/errors/index.js +1 -0
  71. package/dist/events-BbbxkgvX.d.ts +125 -0
  72. package/dist/game/index.d.ts +486 -0
  73. package/dist/game/index.js +1 -0
  74. package/dist/gameLoop-BIPW7-OY.d.ts +219 -0
  75. package/dist/index-zSGJ2eUk.d.ts +3156 -0
  76. package/dist/index.d.ts +246 -0
  77. package/dist/index.js +1 -0
  78. package/dist/input/index.d.ts +158 -0
  79. package/dist/input/index.js +1 -0
  80. package/dist/inputActions-CefRUBuT.d.ts +2637 -0
  81. package/dist/keyParser-Bwm8-l7v.d.ts +229 -0
  82. package/dist/mouseParser-Cfrbn3AX.d.ts +177 -0
  83. package/dist/parser-iMHmQuUh.d.ts +265 -0
  84. package/dist/program-BZaKqDKH.d.ts +141 -0
  85. package/dist/renderable-jTMOA-GK.d.ts +302 -0
  86. package/dist/scheduler-DcfoFuum.d.ts +86 -0
  87. package/dist/schemas/index.d.ts +936 -0
  88. package/dist/schemas/index.js +1 -0
  89. package/dist/systems/index.d.ts +4036 -0
  90. package/dist/systems/index.js +1 -0
  91. package/dist/terminal/index.d.ts +7357 -0
  92. package/dist/terminal/index.js +1 -0
  93. package/dist/terminus-14-bold-HWSPRLJD.js +1 -0
  94. package/dist/terminus-14-normal-T3SWMH4D.js +1 -0
  95. package/dist/tilemap-D1HJvKy3.d.ts +1211 -0
  96. package/dist/types-BcsvoKzf.d.ts +68 -0
  97. package/dist/utils/index.d.ts +6104 -0
  98. package/dist/utils/index.js +1 -0
  99. package/dist/viewport3d-xI33-_wq.d.ts +182 -0
  100. package/dist/virtualScrollback-DvZTRU8a.d.ts +274 -0
  101. package/dist/virtualViewport-Dx2iJliO.d.ts +2334 -0
  102. package/dist/virtualizedLineStore-DwPEvPkk.d.ts +297 -0
  103. package/dist/widgets/bigText.d.ts +230 -0
  104. package/dist/widgets/bigText.js +1 -0
  105. package/dist/widgets/fonts/index.d.ts +211 -0
  106. package/dist/widgets/fonts/index.js +1 -0
  107. package/dist/widgets/index.d.ts +8591 -0
  108. package/dist/widgets/index.js +1 -0
  109. package/package.json +213 -0
@@ -0,0 +1,711 @@
1
+ import { W as World, E as Entity } from '../types-BcsvoKzf.js';
2
+ import { G as GameLoop } from '../gameLoop-BIPW7-OY.js';
3
+ import 'bitecs';
4
+ import '../scheduler-DcfoFuum.js';
5
+
6
+ /**
7
+ * Memory Profiling and Leak Detection
8
+ *
9
+ * Tracks entity and component allocations to catch memory issues during
10
+ * development. Provides allocation counting, periodic snapshots, and
11
+ * leak detection for common patterns.
12
+ *
13
+ * @module debug/memoryProfiler
14
+ */
15
+
16
+ /**
17
+ * Memory snapshot at a point in time.
18
+ */
19
+ interface MemorySnapshot {
20
+ /** Timestamp of the snapshot */
21
+ readonly timestamp: number;
22
+ /** Total entity count */
23
+ readonly entityCount: number;
24
+ /** Component counts by name */
25
+ readonly componentCounts: Record<string, number>;
26
+ /** Node.js heap used in bytes */
27
+ readonly heapUsed: number;
28
+ /** Node.js heap total in bytes */
29
+ readonly heapTotal: number;
30
+ /** Node.js RSS in bytes */
31
+ readonly rss: number;
32
+ /** External memory in bytes */
33
+ readonly external: number;
34
+ }
35
+ /**
36
+ * Memory diff between two snapshots.
37
+ */
38
+ interface MemoryDiff {
39
+ /** Time elapsed between snapshots in ms */
40
+ readonly elapsed: number;
41
+ /** Entity count change */
42
+ readonly entityCountDelta: number;
43
+ /** Component count changes by name */
44
+ readonly componentDeltas: Record<string, number>;
45
+ /** Heap used change in bytes */
46
+ readonly heapUsedDelta: number;
47
+ /** RSS change in bytes */
48
+ readonly rssDelta: number;
49
+ /** Possible leaks detected */
50
+ readonly possibleLeaks: readonly LeakWarning[];
51
+ }
52
+ /**
53
+ * Warning about a potential memory leak.
54
+ */
55
+ interface LeakWarning {
56
+ /** Type of leak */
57
+ readonly type: 'entity' | 'component' | 'heap';
58
+ /** Description of the warning */
59
+ readonly message: string;
60
+ /** Growth rate (units per second) */
61
+ readonly growthRate: number;
62
+ }
63
+ /**
64
+ * Allocation tracker state.
65
+ */
66
+ interface AllocationTracker {
67
+ /** Total entities allocated since tracking started */
68
+ readonly totalAllocated: number;
69
+ /** Total entities deallocated since tracking started */
70
+ readonly totalDeallocated: number;
71
+ /** Current entity count */
72
+ readonly currentCount: number;
73
+ /** Per-component allocation counts */
74
+ readonly componentAllocations: Record<string, number>;
75
+ }
76
+ /**
77
+ * Memory profiler configuration.
78
+ */
79
+ interface MemoryProfilerConfig {
80
+ /** Interval between automatic snapshots in ms (0 = disabled) */
81
+ readonly snapshotInterval: number;
82
+ /** Maximum number of snapshots to keep */
83
+ readonly maxSnapshots: number;
84
+ /** Growth rate threshold for leak detection (entities per second) */
85
+ readonly entityLeakThreshold: number;
86
+ /** Heap growth threshold for leak detection (bytes per second) */
87
+ readonly heapLeakThreshold: number;
88
+ /** Components to track (all if empty) */
89
+ readonly trackedComponents: readonly {
90
+ component: unknown;
91
+ name: string;
92
+ }[];
93
+ }
94
+ /**
95
+ * Memory profiler state.
96
+ */
97
+ interface MemoryProfiler {
98
+ /** Take a snapshot */
99
+ snapshot(world: World): MemorySnapshot;
100
+ /** Compare two snapshots */
101
+ diff(older: MemorySnapshot, newer: MemorySnapshot): MemoryDiff;
102
+ /** Get all snapshots */
103
+ getSnapshots(): readonly MemorySnapshot[];
104
+ /** Get the latest snapshot */
105
+ getLatestSnapshot(): MemorySnapshot | null;
106
+ /** Get a memory report string */
107
+ getReport(world: World): string;
108
+ /** Start automatic snapshotting */
109
+ startAutoSnapshot(world: World): void;
110
+ /** Stop automatic snapshotting */
111
+ stopAutoSnapshot(): void;
112
+ /** Reset all data */
113
+ reset(): void;
114
+ }
115
+ /**
116
+ * Creates a memory profiler for tracking allocations and detecting leaks.
117
+ *
118
+ * @param config - Optional configuration
119
+ * @returns Memory profiler instance
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * import { createMemoryProfiler } from 'blecsd';
124
+ *
125
+ * const profiler = createMemoryProfiler({
126
+ * snapshotInterval: 5000,
127
+ * trackedComponents: [
128
+ * { component: Position, name: 'Position' },
129
+ * { component: Renderable, name: 'Renderable' },
130
+ * ],
131
+ * });
132
+ *
133
+ * // Take manual snapshots
134
+ * const snap1 = profiler.snapshot(world);
135
+ * // ... do work ...
136
+ * const snap2 = profiler.snapshot(world);
137
+ *
138
+ * // Check for leaks
139
+ * const diff = profiler.diff(snap1, snap2);
140
+ * if (diff.possibleLeaks.length > 0) {
141
+ * console.warn('Possible leaks:', diff.possibleLeaks);
142
+ * }
143
+ *
144
+ * // Get a formatted report
145
+ * console.log(profiler.getReport(world));
146
+ * ```
147
+ */
148
+ declare function createMemoryProfiler(config?: Partial<MemoryProfilerConfig>): MemoryProfiler;
149
+
150
+ /**
151
+ * Debug overlay widget for visual debugging.
152
+ *
153
+ * Displays real-time debugging information:
154
+ * - FPS counter
155
+ * - Entity count
156
+ * - System timings
157
+ * - Memory usage
158
+ * - Input events
159
+ *
160
+ * @module debug/overlay
161
+ */
162
+
163
+ /**
164
+ * Debug overlay configuration.
165
+ */
166
+ interface DebugOverlayConfig {
167
+ /** X position (default: 0) */
168
+ readonly x?: number;
169
+ /** Y position (default: 0) */
170
+ readonly y?: number;
171
+ /** Width (default: 35) */
172
+ readonly width?: number;
173
+ /** Toggle key (default: 'F12') */
174
+ readonly toggleKey?: string;
175
+ /** Whether to show FPS (default: true) */
176
+ readonly showFPS?: boolean;
177
+ /** Whether to show entity count (default: true) */
178
+ readonly showEntityCount?: boolean;
179
+ /** Whether to show memory usage (default: true) */
180
+ readonly showMemory?: boolean;
181
+ /** Whether to show system timings (default: true) */
182
+ readonly showSystemTimings?: boolean;
183
+ /** Maximum number of systems to show (default: 5) */
184
+ readonly maxSystemsShown?: number;
185
+ /** Background color (default: dark blue) */
186
+ readonly bgColor?: number;
187
+ /** Foreground color (default: white) */
188
+ readonly fgColor?: number;
189
+ /** Whether visible on start (default: false) */
190
+ readonly visibleOnStart?: boolean;
191
+ }
192
+ /**
193
+ * Debug overlay state.
194
+ */
195
+ interface DebugOverlay {
196
+ /** Whether the overlay is currently visible */
197
+ readonly visible: boolean;
198
+ /** The overlay entity (null if not created) */
199
+ readonly entity: Entity | null;
200
+ /** Configuration */
201
+ readonly config: Required<DebugOverlayConfig>;
202
+ /** Show the overlay */
203
+ show(): void;
204
+ /** Hide the overlay */
205
+ hide(): void;
206
+ /** Toggle visibility */
207
+ toggle(): void;
208
+ /** Update overlay content */
209
+ update(world: World, loop?: GameLoop): void;
210
+ /** Destroy the overlay */
211
+ destroy(): void;
212
+ }
213
+ /**
214
+ * Creates a debug overlay for the given world.
215
+ *
216
+ * The overlay displays real-time debugging information and can be
217
+ * toggled with a configurable key (default: F12).
218
+ *
219
+ * @param world - The ECS world
220
+ * @param config - Optional configuration
221
+ * @returns Debug overlay controller
222
+ *
223
+ * @example
224
+ * ```typescript
225
+ * import { createDebugOverlay } from 'blecsd/debug';
226
+ *
227
+ * const overlay = createDebugOverlay(world, {
228
+ * toggleKey: 'F12',
229
+ * showSystemTimings: true,
230
+ * });
231
+ *
232
+ * // In game loop
233
+ * game.onUpdate(() => {
234
+ * overlay.update(world, loop);
235
+ * });
236
+ *
237
+ * // Toggle with key
238
+ * game.onKey('F12', () => overlay.toggle());
239
+ * ```
240
+ */
241
+ declare function createDebugOverlay(world: World, config?: DebugOverlayConfig): DebugOverlay;
242
+ /**
243
+ * Input event log entry.
244
+ */
245
+ interface InputLogEntry {
246
+ readonly type: 'key' | 'mouse';
247
+ readonly detail: string;
248
+ readonly timestamp: number;
249
+ }
250
+ /**
251
+ * Input event logger state.
252
+ */
253
+ interface InputLogger {
254
+ readonly entries: readonly InputLogEntry[];
255
+ readonly maxEntries: number;
256
+ log(type: 'key' | 'mouse', detail: string): void;
257
+ clear(): void;
258
+ getRecentEntries(count?: number): readonly InputLogEntry[];
259
+ }
260
+ /**
261
+ * Creates an input event logger for debugging.
262
+ *
263
+ * @param maxEntries - Maximum entries to keep (default: 20)
264
+ * @returns Input logger
265
+ *
266
+ * @example
267
+ * ```typescript
268
+ * import { createInputLogger } from 'blecsd/debug';
269
+ *
270
+ * const logger = createInputLogger(10);
271
+ *
272
+ * // In input handler
273
+ * game.onAnyKey((event) => {
274
+ * logger.log('key', `${event.name} ${event.ctrl ? '+Ctrl' : ''}`);
275
+ * });
276
+ *
277
+ * game.onMouse((event) => {
278
+ * logger.log('mouse', `${event.action} @ ${event.x},${event.y}`);
279
+ * });
280
+ *
281
+ * // Get recent entries
282
+ * console.log(logger.getRecentEntries(5));
283
+ * ```
284
+ */
285
+ declare function createInputLogger(maxEntries?: number): InputLogger;
286
+ /**
287
+ * Mini profiler for measuring code sections.
288
+ */
289
+ interface MiniProfiler {
290
+ /** Start timing a section */
291
+ start(name: string): void;
292
+ /** End timing a section */
293
+ end(name: string): number;
294
+ /** Get average time for a section */
295
+ getAverage(name: string): number;
296
+ /** Get all timings */
297
+ getAll(): Record<string, {
298
+ avg: number;
299
+ min: number;
300
+ max: number;
301
+ count: number;
302
+ }>;
303
+ /** Reset all timings */
304
+ reset(): void;
305
+ }
306
+ /**
307
+ * Creates a mini profiler for measuring code sections.
308
+ *
309
+ * @returns Mini profiler instance
310
+ *
311
+ * @example
312
+ * ```typescript
313
+ * import { createMiniProfiler } from 'blecsd/debug';
314
+ *
315
+ * const profiler = createMiniProfiler();
316
+ *
317
+ * profiler.start('render');
318
+ * // ... render code ...
319
+ * const elapsed = profiler.end('render');
320
+ *
321
+ * console.log(`Render avg: ${profiler.getAverage('render').toFixed(2)}ms`);
322
+ * ```
323
+ */
324
+ declare function createMiniProfiler(): MiniProfiler;
325
+ /**
326
+ * Frame rate graph data.
327
+ */
328
+ interface FrameRateGraph {
329
+ /** Add a frame time sample */
330
+ addSample(frameTimeMs: number): void;
331
+ /** Get samples for rendering */
332
+ getSamples(): readonly number[];
333
+ /** Get current FPS */
334
+ getCurrentFPS(): number;
335
+ /** Get average FPS */
336
+ getAverageFPS(): number;
337
+ /** Get min/max FPS */
338
+ getMinMaxFPS(): {
339
+ min: number;
340
+ max: number;
341
+ };
342
+ /** Reset the graph */
343
+ reset(): void;
344
+ }
345
+ /**
346
+ * Creates a frame rate graph for visualizing performance over time.
347
+ *
348
+ * @param sampleCount - Number of samples to keep (default: 60)
349
+ * @returns Frame rate graph
350
+ *
351
+ * @example
352
+ * ```typescript
353
+ * import { createFrameRateGraph } from 'blecsd/debug';
354
+ *
355
+ * const graph = createFrameRateGraph(120); // 2 seconds at 60fps
356
+ *
357
+ * // In game loop
358
+ * game.onUpdate((dt) => {
359
+ * graph.addSample(dt * 1000);
360
+ *
361
+ * // Render graph...
362
+ * const samples = graph.getSamples();
363
+ * // samples are frame times in ms, convert to FPS for display
364
+ * });
365
+ * ```
366
+ */
367
+ declare function createFrameRateGraph(sampleCount?: number): FrameRateGraph;
368
+
369
+ /**
370
+ * Debug utilities for development and debugging.
371
+ *
372
+ * These utilities help with:
373
+ * - Inspecting entity state
374
+ * - Viewing world statistics
375
+ * - Performance monitoring
376
+ * - Visual debugging
377
+ *
378
+ * @module debug
379
+ */
380
+
381
+ /**
382
+ * Component information for inspection.
383
+ */
384
+ interface ComponentInfo {
385
+ readonly name: string;
386
+ readonly data: Record<string, unknown>;
387
+ }
388
+ /**
389
+ * Entity inspection result.
390
+ */
391
+ interface EntityInspection {
392
+ readonly entity: Entity;
393
+ readonly name: string | null;
394
+ readonly components: readonly ComponentInfo[];
395
+ readonly parent: Entity | null;
396
+ readonly children: readonly Entity[];
397
+ }
398
+ /**
399
+ * World inspection result.
400
+ */
401
+ interface WorldInspection {
402
+ readonly entityCount: number;
403
+ readonly componentCounts: Record<string, number>;
404
+ readonly hierarchyRoots: readonly Entity[];
405
+ }
406
+ /**
407
+ * Performance statistics.
408
+ */
409
+ interface PerformanceStats {
410
+ /** Current frames per second */
411
+ readonly fps: number;
412
+ /** Current frame time in milliseconds */
413
+ readonly frameTime: number;
414
+ /** Total frames rendered */
415
+ readonly frameCount: number;
416
+ /** Total running time in seconds */
417
+ readonly runningTime: number;
418
+ /** Entity count */
419
+ readonly entityCount: number;
420
+ /** Memory usage in MB (if available) */
421
+ readonly memoryUsageMB: number | null;
422
+ /** System timing in milliseconds per system */
423
+ readonly systemTimings: Record<string, number>;
424
+ }
425
+ /**
426
+ * Known components for inspection.
427
+ */
428
+ declare const KNOWN_COMPONENTS: readonly {
429
+ component: unknown;
430
+ name: string;
431
+ }[];
432
+ /**
433
+ * Inspects an entity and returns detailed information about its components.
434
+ *
435
+ * @param world - The ECS world
436
+ * @param eid - The entity to inspect
437
+ * @returns Entity inspection data
438
+ *
439
+ * @example
440
+ * ```typescript
441
+ * import { inspectEntity } from 'blecsd/debug';
442
+ *
443
+ * const entity = addEntity(world);
444
+ * setPosition(world, entity, 10, 20);
445
+ *
446
+ * const info = inspectEntity(world, entity);
447
+ * console.log(info.components);
448
+ * // [{ name: 'Position', data: { x: 10, y: 20, z: 0, absolute: 0 } }]
449
+ * ```
450
+ */
451
+ declare function inspectEntity(world: World, eid: Entity): EntityInspection;
452
+ /**
453
+ * Formats an entity inspection as a human-readable string.
454
+ *
455
+ * @param inspection - The entity inspection data
456
+ * @returns Formatted string
457
+ *
458
+ * @example
459
+ * ```typescript
460
+ * import { inspectEntity, formatEntityInspection } from 'blecsd/debug';
461
+ *
462
+ * const info = inspectEntity(world, entity);
463
+ * console.log(formatEntityInspection(info));
464
+ * // Entity 1 (MyBox)
465
+ * // ├─ Position: x=10, y=20, z=0
466
+ * // ├─ Dimensions: width=40, height=10
467
+ * // └─ Renderable: visible=1
468
+ * ```
469
+ */
470
+ declare function formatEntityInspection(inspection: EntityInspection): string;
471
+ /**
472
+ * Inspects the world and returns statistics about entities and components.
473
+ *
474
+ * @param world - The ECS world to inspect
475
+ * @returns World inspection data
476
+ *
477
+ * @example
478
+ * ```typescript
479
+ * import { inspectWorld } from 'blecsd/debug';
480
+ *
481
+ * const info = inspectWorld(world);
482
+ * console.log(`Entities: ${info.entityCount}`);
483
+ * console.log(`Position components: ${info.componentCounts['Position']}`);
484
+ * ```
485
+ */
486
+ declare function inspectWorld(world: World): WorldInspection;
487
+ /**
488
+ * Formats a world inspection as a human-readable string.
489
+ *
490
+ * @param inspection - The world inspection data
491
+ * @returns Formatted string
492
+ *
493
+ * @example
494
+ * ```typescript
495
+ * import { inspectWorld, formatWorldInspection } from 'blecsd/debug';
496
+ *
497
+ * const info = inspectWorld(world);
498
+ * console.log(formatWorldInspection(info));
499
+ * // World Statistics
500
+ * // ────────────────
501
+ * // Entities: 42
502
+ * // Components:
503
+ * // Position: 38
504
+ * // Dimensions: 35
505
+ * // ...
506
+ * ```
507
+ */
508
+ declare function formatWorldInspection(inspection: WorldInspection): string;
509
+ /**
510
+ * Enables or disables system timing tracking.
511
+ *
512
+ * When enabled, system execution times are tracked and can be retrieved
513
+ * via getPerformanceStats().
514
+ *
515
+ * @param enabled - Whether to enable timing
516
+ *
517
+ * @example
518
+ * ```typescript
519
+ * import { enableSystemTiming, getPerformanceStats } from 'blecsd/debug';
520
+ *
521
+ * // Enable timing
522
+ * enableSystemTiming(true);
523
+ *
524
+ * // Run game loop...
525
+ *
526
+ * // Get stats
527
+ * const stats = getPerformanceStats(world, loop);
528
+ * console.log(stats.systemTimings);
529
+ * ```
530
+ */
531
+ declare function enableSystemTiming(enabled: boolean): void;
532
+ /**
533
+ * Checks if system timing is enabled.
534
+ */
535
+ declare function isSystemTimingEnabled(): boolean;
536
+ /**
537
+ * Records system execution time.
538
+ * Called internally by timed system wrappers.
539
+ *
540
+ * @param systemName - Name of the system
541
+ * @param timeMs - Execution time in milliseconds
542
+ * @internal
543
+ */
544
+ declare function recordSystemTime(systemName: string, timeMs: number): void;
545
+ /**
546
+ * Wraps a system function with timing instrumentation.
547
+ *
548
+ * @param name - Name for the system (used in timing reports)
549
+ * @param system - The system function to wrap
550
+ * @returns Wrapped system that records execution time
551
+ *
552
+ * @example
553
+ * ```typescript
554
+ * import { timedSystem } from 'blecsd/debug';
555
+ *
556
+ * const movementSystem = timedSystem('movement', (world) => {
557
+ * // movement logic
558
+ * return world;
559
+ * });
560
+ *
561
+ * // Register the timed system
562
+ * loop.registerSystem(LoopPhase.UPDATE, movementSystem);
563
+ * ```
564
+ */
565
+ declare function timedSystem<T extends (world: World) => World>(name: string, system: T): T;
566
+ /**
567
+ * Gets the current system timing data.
568
+ * Returns average time per call for each system.
569
+ *
570
+ * @returns Map of system name to average time in milliseconds
571
+ */
572
+ declare function getSystemTimings(): Record<string, number>;
573
+ /**
574
+ * Resets all system timing data.
575
+ */
576
+ declare function resetSystemTimings(): void;
577
+ /**
578
+ * Resets the performance stats cache.
579
+ * Useful for testing.
580
+ * @internal
581
+ */
582
+ declare function resetPerformanceStatsCache(): void;
583
+ /**
584
+ * Gets current performance statistics.
585
+ *
586
+ * @param world - The ECS world
587
+ * @param loop - Optional game loop for frame stats
588
+ * @returns Performance statistics
589
+ *
590
+ * @example
591
+ * ```typescript
592
+ * import { getPerformanceStats } from 'blecsd/debug';
593
+ *
594
+ * const stats = getPerformanceStats(world, loop);
595
+ * console.log(`FPS: ${stats.fps}`);
596
+ * console.log(`Entities: ${stats.entityCount}`);
597
+ * console.log(`Memory: ${stats.memoryUsageMB?.toFixed(1)}MB`);
598
+ * ```
599
+ */
600
+ declare function getPerformanceStats(world: World, loop?: {
601
+ getStats(): {
602
+ fps: number;
603
+ frameTime: number;
604
+ frameCount: number;
605
+ runningTime: number;
606
+ };
607
+ }): PerformanceStats;
608
+ /**
609
+ * Debug bounds drawing state.
610
+ */
611
+ interface DebugBoundsState {
612
+ enabled: boolean;
613
+ showHitboxes: boolean;
614
+ showPadding: boolean;
615
+ showMargins: boolean;
616
+ color: number;
617
+ }
618
+ /**
619
+ * Enables or disables debug bounds visualization.
620
+ *
621
+ * When enabled, entity hitboxes and bounds are drawn as colored outlines.
622
+ * This is useful for debugging layout and collision issues.
623
+ *
624
+ * @param enabled - Whether to enable debug bounds
625
+ * @param options - Optional configuration
626
+ *
627
+ * @example
628
+ * ```typescript
629
+ * import { enableDebugBounds } from 'blecsd/debug';
630
+ *
631
+ * // Enable with default settings
632
+ * enableDebugBounds(true);
633
+ *
634
+ * // Enable with custom color
635
+ * enableDebugBounds(true, { color: 0xffff0000 }); // Red
636
+ * ```
637
+ */
638
+ declare function enableDebugBounds(enabled: boolean, options?: {
639
+ showHitboxes?: boolean;
640
+ showPadding?: boolean;
641
+ showMargins?: boolean;
642
+ color?: number;
643
+ }): void;
644
+ /**
645
+ * Checks if debug bounds are enabled.
646
+ */
647
+ declare function isDebugBoundsEnabled(): boolean;
648
+ /**
649
+ * Gets debug bounds configuration.
650
+ */
651
+ declare function getDebugBoundsConfig(): Readonly<DebugBoundsState>;
652
+ /**
653
+ * Gets entities that should have debug bounds drawn.
654
+ * Returns entities with Position and Dimensions components.
655
+ *
656
+ * @param world - The ECS world
657
+ * @returns Array of entities to draw bounds for
658
+ */
659
+ declare function getDebugBoundsEntities(world: World): Entity[];
660
+ /**
661
+ * Gets a debug summary of an entity as a single line.
662
+ *
663
+ * @param world - The ECS world
664
+ * @param eid - The entity to summarize
665
+ * @returns Single-line summary string
666
+ *
667
+ * @example
668
+ * ```typescript
669
+ * import { getEntitySummary } from 'blecsd/debug';
670
+ *
671
+ * console.log(getEntitySummary(world, entity));
672
+ * // "Entity 1 (MyBox) @ 10,20 [40x10] focused hovered"
673
+ * ```
674
+ */
675
+ declare function getEntitySummary(world: World, eid: Entity): string;
676
+ /**
677
+ * Logs an entity to the console with formatting.
678
+ *
679
+ * @param world - The ECS world
680
+ * @param eid - The entity to log
681
+ *
682
+ * @example
683
+ * ```typescript
684
+ * import { logEntity } from 'blecsd/debug';
685
+ *
686
+ * logEntity(world, entity);
687
+ * // [DEBUG] Entity 1 (MyBox)
688
+ * // ├─ Position: x=10, y=20, z=0
689
+ * // └─ Dimensions: width=40, height=10
690
+ * ```
691
+ */
692
+ declare function logEntity(world: World, eid: Entity): void;
693
+ /**
694
+ * Logs world statistics to the console.
695
+ *
696
+ * @param world - The ECS world
697
+ *
698
+ * @example
699
+ * ```typescript
700
+ * import { logWorld } from 'blecsd/debug';
701
+ *
702
+ * logWorld(world);
703
+ * // [DEBUG] World Statistics
704
+ * // ────────────────
705
+ * // Entities: 42
706
+ * // ...
707
+ * ```
708
+ */
709
+ declare function logWorld(world: World): void;
710
+
711
+ export { type AllocationTracker, type ComponentInfo, type DebugOverlay, type DebugOverlayConfig, type EntityInspection, type FrameRateGraph, KNOWN_COMPONENTS, type LeakWarning, type MemoryDiff, type MemoryProfiler, type MemoryProfilerConfig, type MemorySnapshot, type MiniProfiler, type PerformanceStats, type WorldInspection, createDebugOverlay, createFrameRateGraph, createInputLogger, createMemoryProfiler, createMiniProfiler, enableDebugBounds, enableSystemTiming, formatEntityInspection, formatWorldInspection, getDebugBoundsConfig, getDebugBoundsEntities, getEntitySummary, getPerformanceStats, getSystemTimings, inspectEntity, inspectWorld, isDebugBoundsEnabled, isSystemTimingEnabled, logEntity, logWorld, recordSystemTime, resetPerformanceStatsCache, resetSystemTimings, timedSystem };
@@ -0,0 +1 @@
1
+ export{f as KNOWN_COMPONENTS,b as createDebugOverlay,e as createFrameRateGraph,c as createInputLogger,a as createMemoryProfiler,d as createMiniProfiler,s as enableDebugBounds,k as enableSystemTiming,h as formatEntityInspection,j as formatWorldInspection,u as getDebugBoundsConfig,v as getDebugBoundsEntities,w as getEntitySummary,r as getPerformanceStats,o as getSystemTimings,g as inspectEntity,i as inspectWorld,t as isDebugBoundsEnabled,l as isSystemTimingEnabled,x as logEntity,y as logWorld,m as recordSystemTime,q as resetPerformanceStatsCache,p as resetSystemTimings,n as timedSystem}from'../chunk-TDXJDLY6.js';import'../chunk-OMMJ7B5P.js';import'../chunk-CIK4AMUA.js';import'../chunk-JKVHO4LH.js';import'../chunk-KD55INV7.js';import'../chunk-PSXXMBVJ.js';import'../chunk-LCN2ZITE.js';import'../chunk-FYEBZAWN.js';import'../chunk-W5OU7Z6J.js';import'../chunk-Z4EZERNE.js';import'../chunk-WNG4A3K7.js';import'../chunk-SHUC6JWA.js';import'../chunk-G7GIWWLE.js';import'../chunk-PXXGH3BV.js';import'../chunk-5PELJRUQ.js';