blecsd 0.3.0 → 0.6.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 (147) hide show
  1. package/README.md +146 -147
  2. package/dist/{border-Jb7TrMob.d.ts → border-Br-Jc027.d.ts} +2 -2
  3. package/dist/{cell-DwIu2ryP.d.ts → cell-5Ty_3yMs.d.ts} +1 -1
  4. package/dist/cellRenderer-D0-DJXWl.d.ts +374 -0
  5. package/dist/chunk-4N7IFBRQ.js +4 -0
  6. package/dist/{chunk-DNRXW56C.js → chunk-4XCFTNGN.js} +1 -1
  7. package/dist/chunk-5YWRP2KG.js +3 -0
  8. package/dist/chunk-6PX5R326.js +1 -0
  9. package/dist/chunk-73Y45MLV.js +12 -0
  10. package/dist/chunk-7ZFQO3OQ.js +1 -0
  11. package/dist/chunk-A3GSH6MV.js +1 -0
  12. package/dist/chunk-A5B2BGUM.js +1 -0
  13. package/dist/chunk-AM6IDSXI.js +1 -0
  14. package/dist/chunk-EHYOVHRL.js +2 -0
  15. package/dist/chunk-EMZA6G2M.js +4 -0
  16. package/dist/chunk-EOFT3PNU.js +1 -0
  17. package/dist/chunk-ETFDYZVJ.js +1 -0
  18. package/dist/chunk-FUW7OD3H.js +1 -0
  19. package/dist/chunk-GRMSEMU7.js +1 -0
  20. package/dist/chunk-I7AUKTXE.js +1 -0
  21. package/dist/chunk-IANAVH2A.js +1 -0
  22. package/dist/chunk-JN2OGNK3.js +1 -0
  23. package/dist/chunk-JVMNMAHX.js +1 -0
  24. package/dist/chunk-K2QWNDXV.js +1 -0
  25. package/dist/chunk-KYNS3GBJ.js +2 -0
  26. package/dist/chunk-LI3ZYXUT.js +1 -0
  27. package/dist/chunk-LNEISTXM.js +1 -0
  28. package/dist/chunk-QABNK7IA.js +1 -0
  29. package/dist/chunk-QS5QXZNJ.js +1 -0
  30. package/dist/chunk-QTDRFJG2.js +1 -0
  31. package/dist/chunk-RJULLVTH.js +1 -0
  32. package/dist/chunk-SVHITP3F.js +2 -0
  33. package/dist/chunk-UKVY43V3.js +1 -0
  34. package/dist/chunk-VIT4KE6Q.js +1 -0
  35. package/dist/chunk-XG5PVDOP.js +1 -0
  36. package/dist/chunk-XH5GTWCV.js +1 -0
  37. package/dist/chunk-XYMPBCYW.js +1 -0
  38. package/dist/chunk-YRSSCEAS.js +1 -0
  39. package/dist/chunk-ZL46COQF.js +1 -0
  40. package/dist/cli/init.js +1 -1
  41. package/dist/{componentStorage-CJTh-TPO.d.ts → componentStorage-CXJvx4Lt.d.ts} +2 -2
  42. package/dist/components/index.d.ts +7209 -6691
  43. package/dist/components/index.js +5 -1
  44. package/dist/core/index.d.ts +2501 -1262
  45. package/dist/core/index.js +1 -1
  46. package/dist/debug/index.d.ts +310 -84
  47. package/dist/debug/index.js +8 -1
  48. package/dist/{dirtyTracking-C4v8MmM9.d.ts → dirtyTracking-kCS9-NVF.d.ts} +2 -2
  49. package/dist/{doubleBuffer-CKQFmlPN.d.ts → doubleBuffer-CWASihKh.d.ts} +1 -1
  50. package/dist/errors/index.js +1 -1
  51. package/dist/{inputActions-CRsUtTHM.d.ts → factories-vW7bn_He.d.ts} +21 -786
  52. package/dist/{gameLoop-C-Ez_i54.d.ts → gameLoop-C1AyRWyP.d.ts} +3 -3
  53. package/dist/index.d.ts +25 -500
  54. package/dist/index.js +1 -3
  55. package/dist/input/index.d.ts +1 -1
  56. package/dist/input/index.js +1 -1
  57. package/dist/inputStream-COARA4CP.d.ts +1182 -0
  58. package/dist/interactiveSystem-h92W9W4n.d.ts +1977 -0
  59. package/dist/{keyParser-BnHbg2iD.d.ts → keyParser-DReXe2j-.d.ts} +41 -41
  60. package/dist/{events-9ForpTfM.d.ts → mouseParser-CCqSEUVN.d.ts} +177 -2
  61. package/dist/{packedStore-BgvnEdE7.d.ts → packedStore-480t2X74.d.ts} +1 -1
  62. package/dist/panelMovement-DGzIQ8Ll.d.ts +1908 -0
  63. package/dist/{parser-iMHmQuUh.d.ts → parser-Q1YLXYpF.d.ts} +1 -1
  64. package/dist/positioning-DiUivJXa.d.ts +917 -0
  65. package/dist/{renderable-CwqGwrEV.d.ts → renderable-IbSJao5y.d.ts} +2 -2
  66. package/dist/{scheduler-CMcYew9Z.d.ts → scheduler-NbHT3-D2.d.ts} +3 -1
  67. package/dist/schemas/index.d.ts +6 -6
  68. package/dist/schemas/index.js +1 -1
  69. package/dist/systems/index.d.ts +1057 -1807
  70. package/dist/systems/index.js +1 -1
  71. package/dist/terminal/index.d.ts +7207 -2709
  72. package/dist/terminal/index.js +1 -1
  73. package/dist/terminalBuffer-BbUz27qM.d.ts +691 -0
  74. package/dist/{terminus-14-bold-HWSPRLJD.js → terminus-14-bold-ZS4IH465.js} +1 -1
  75. package/dist/{terminus-14-normal-T3SWMH4D.js → terminus-14-normal-HD5N7F5W.js} +1 -1
  76. package/dist/text/index.d.ts +263 -0
  77. package/dist/text/index.js +3 -0
  78. package/dist/textWrap-Ct2J8gO6.d.ts +761 -0
  79. package/dist/{tilemap-BirMJdbu.d.ts → tilemap-ByvTsepD.d.ts} +5 -5
  80. package/dist/{types-CPB4CpbH.d.ts → types-B8LmNkzG.d.ts} +1 -1
  81. package/dist/utils/index.d.ts +827 -780
  82. package/dist/utils/index.js +32 -1
  83. package/dist/{virtualScrollback-D9uLFe8l.d.ts → virtualScrollback-CiooIebp.d.ts} +4 -4
  84. package/dist/virtualViewport-fIlbIGPt.d.ts +657 -0
  85. package/dist/{virtualizedLineStore-DwPEvPkk.d.ts → virtualizedLineStore-DfyhojPZ.d.ts} +1 -1
  86. package/dist/widgets/bigText.d.ts +13 -13
  87. package/dist/widgets/bigText.js +1 -1
  88. package/dist/widgets/fonts/index.d.ts +1 -1
  89. package/dist/widgets/fonts/index.js +1 -1
  90. package/dist/widgets/index.d.ts +2933 -1102
  91. package/dist/widgets/index.js +24 -1
  92. package/package.json +9 -22
  93. package/dist/3d/index.d.ts +0 -5
  94. package/dist/3d/index.js +0 -1
  95. package/dist/audio/index.d.ts +0 -177
  96. package/dist/audio/index.js +0 -1
  97. package/dist/chunk-2IEMMRUO.js +0 -1
  98. package/dist/chunk-35LCBY6P.js +0 -1
  99. package/dist/chunk-3AV52GY5.js +0 -1
  100. package/dist/chunk-3LHLSY3Y.js +0 -1
  101. package/dist/chunk-3O4TQHGK.js +0 -4
  102. package/dist/chunk-3UJWZ5ZN.js +0 -1
  103. package/dist/chunk-5PELJRUQ.js +0 -1
  104. package/dist/chunk-6M2J5QUA.js +0 -1
  105. package/dist/chunk-7IQEUVGF.js +0 -1
  106. package/dist/chunk-A6M6TFBL.js +0 -1
  107. package/dist/chunk-CIK4AMUA.js +0 -1
  108. package/dist/chunk-CUEUJAHK.js +0 -3
  109. package/dist/chunk-D42Q2KKR.js +0 -1
  110. package/dist/chunk-DYEXOFUU.js +0 -2
  111. package/dist/chunk-DYU72XLL.js +0 -1
  112. package/dist/chunk-E4CJRSND.js +0 -1
  113. package/dist/chunk-EAY7B5GL.js +0 -1
  114. package/dist/chunk-FCMTWFSE.js +0 -1
  115. package/dist/chunk-FGHEFXLK.js +0 -1
  116. package/dist/chunk-FL56THSI.js +0 -25
  117. package/dist/chunk-G437VE43.js +0 -1
  118. package/dist/chunk-G7GIWWLE.js +0 -1
  119. package/dist/chunk-GGXNWT36.js +0 -8
  120. package/dist/chunk-HLFORKXS.js +0 -1
  121. package/dist/chunk-J7MBKEBY.js +0 -1
  122. package/dist/chunk-K3SX2LY5.js +0 -1
  123. package/dist/chunk-LDAFEXN5.js +0 -1
  124. package/dist/chunk-LYSK5S63.js +0 -1
  125. package/dist/chunk-MKMFUXLB.js +0 -33
  126. package/dist/chunk-MQWPHPUM.js +0 -1
  127. package/dist/chunk-MTI376CU.js +0 -5
  128. package/dist/chunk-MTV2RJZD.js +0 -1
  129. package/dist/chunk-NZ55KBM6.js +0 -1
  130. package/dist/chunk-OB66FB4F.js +0 -1
  131. package/dist/chunk-OMMJ7B5P.js +0 -1
  132. package/dist/chunk-OR3BZY7C.js +0 -1
  133. package/dist/chunk-PXXGH3BV.js +0 -1
  134. package/dist/chunk-R7AICVRN.js +0 -2
  135. package/dist/chunk-RZ7FGVI6.js +0 -1
  136. package/dist/chunk-SHUC6JWA.js +0 -1
  137. package/dist/chunk-TWSWTBYL.js +0 -1
  138. package/dist/chunk-UMGTXSQB.js +0 -11
  139. package/dist/chunk-X3Q3T2SS.js +0 -4
  140. package/dist/chunk-XZJRWFOS.js +0 -1
  141. package/dist/chunk-ZAHG7Y3X.js +0 -1
  142. package/dist/game/index.d.ts +0 -486
  143. package/dist/game/index.js +0 -1
  144. package/dist/index-DBS5Uefn.d.ts +0 -3156
  145. package/dist/mouseParser-Cfrbn3AX.d.ts +0 -177
  146. package/dist/viewport3d-xI33-_wq.d.ts +0 -182
  147. package/dist/virtualViewport-Bpv6jlKt.d.ts +0 -1856
@@ -1,7 +1,6 @@
1
+ import { W as World, E as Entity } from './types-B8LmNkzG.js';
1
2
  import { z } from 'zod';
2
- import { h as BorderCharset } from './border-Jb7TrMob.js';
3
- import { M as MouseEvent, c as MouseButton } from './mouseParser-Cfrbn3AX.js';
4
- import { b as KeyEvent, K as KeyName } from './keyParser-BnHbg2iD.js';
3
+ import { o as BorderCharset } from './border-Br-Jc027.js';
5
4
 
6
5
  /**
7
6
  * Zod validation schemas and TypeScript types for entity configurations.
@@ -1138,789 +1137,25 @@ declare const RadioButtonConfigSchema: z.ZodObject<{
1138
1137
  type RadioButtonConfig = z.infer<typeof RadioButtonConfigSchema>;
1139
1138
 
1140
1139
  /**
1141
- * Input event buffer for frame-independent input handling.
1142
- *
1143
- * Buffers keyboard and mouse events between frames so no input is lost.
1144
- * Events are collected asynchronously from stdin and drained synchronously
1145
- * each frame by the game loop.
1146
- *
1147
- * HARD REQUIREMENT: No input events should ever be lost or delayed.
1148
- *
1149
- * @module core/inputEventBuffer
1150
- */
1151
-
1152
- /**
1153
- * A timestamped keyboard event.
1154
- */
1155
- interface TimestampedKeyEvent {
1156
- readonly type: 'key';
1157
- readonly event: KeyEvent;
1158
- readonly timestamp: number;
1159
- }
1160
- /**
1161
- * A timestamped mouse event.
1162
- */
1163
- interface TimestampedMouseEvent {
1164
- readonly type: 'mouse';
1165
- readonly event: MouseEvent;
1166
- readonly timestamp: number;
1167
- }
1168
- /**
1169
- * Union of all timestamped input events.
1170
- */
1171
- type TimestampedInputEvent = TimestampedKeyEvent | TimestampedMouseEvent;
1172
- /**
1173
- * Statistics about the input buffer.
1174
- */
1175
- interface InputBufferStats {
1176
- /** Total key events pushed since creation/reset */
1177
- readonly totalKeyEvents: number;
1178
- /** Total mouse events pushed since creation/reset */
1179
- readonly totalMouseEvents: number;
1180
- /** Current key events in buffer */
1181
- readonly pendingKeyEvents: number;
1182
- /** Current mouse events in buffer */
1183
- readonly pendingMouseEvents: number;
1184
- /** Number of events dropped due to overflow */
1185
- readonly droppedEvents: number;
1186
- /** Maximum buffer size */
1187
- readonly maxBufferSize: number;
1188
- }
1189
- /**
1190
- * Latency statistics for input processing.
1191
- * All values in milliseconds.
1192
- */
1193
- interface InputLatencyStats {
1194
- /** Minimum latency observed */
1195
- readonly min: number;
1196
- /** Maximum latency observed */
1197
- readonly max: number;
1198
- /** Average latency */
1199
- readonly avg: number;
1200
- /** 95th percentile latency */
1201
- readonly p95: number;
1202
- /** 99th percentile latency */
1203
- readonly p99: number;
1204
- /** Number of samples in the window */
1205
- readonly sampleCount: number;
1206
- /** Last frame processing time in ms */
1207
- readonly lastFrameProcessingTime: number;
1208
- /** Average frame processing time */
1209
- readonly avgFrameProcessingTime: number;
1210
- }
1211
- /**
1212
- * Configuration options for the input event buffer.
1213
- */
1214
- interface InputEventBufferOptions {
1215
- /**
1216
- * Maximum number of events to buffer before dropping oldest.
1217
- * Set to 0 for unlimited (not recommended).
1218
- * @default 1000
1219
- */
1220
- readonly maxBufferSize?: number;
1221
- /**
1222
- * Whether to emit a warning when buffer overflows.
1223
- * @default true
1224
- */
1225
- readonly warnOnOverflow?: boolean;
1226
- /**
1227
- * Custom warning handler for overflow events.
1228
- * @default console.warn
1229
- */
1230
- readonly onOverflow?: (droppedCount: number) => void;
1231
- /**
1232
- * Maximum number of latency samples to keep for statistics.
1233
- * @default 1000
1234
- */
1235
- readonly maxLatencySamples?: number;
1236
- /**
1237
- * Maximum number of frame processing time samples to keep.
1238
- * @default 100
1239
- */
1240
- readonly maxFrameSamples?: number;
1241
- }
1242
- /**
1243
- * Input event buffer data structure.
1244
- * All state is stored in plain arrays for functional manipulation.
1245
- */
1246
- interface InputEventBufferData {
1247
- /** Pending key events */
1248
- keyEvents: TimestampedKeyEvent[];
1249
- /** Pending mouse events */
1250
- mouseEvents: TimestampedMouseEvent[];
1251
- /** Latency samples for statistics */
1252
- latencySamples: number[];
1253
- /** Frame processing time samples */
1254
- frameProcessingTimes: number[];
1255
- /** Frame start timestamp */
1256
- frameStartTime: number;
1257
- /** Total key events pushed since creation/reset */
1258
- totalKeyEvents: number;
1259
- /** Total mouse events pushed since creation/reset */
1260
- totalMouseEvents: number;
1261
- /** Number of events dropped due to overflow */
1262
- droppedEvents: number;
1263
- /** Configuration */
1264
- readonly config: {
1265
- readonly maxBufferSize: number;
1266
- readonly maxLatencySamples: number;
1267
- readonly maxFrameSamples: number;
1268
- readonly warnOnOverflow: boolean;
1269
- readonly onOverflow: (droppedCount: number) => void;
1270
- };
1271
- }
1272
- /**
1273
- * Creates a new input event buffer.
1274
- *
1275
- * @param options - Buffer configuration options
1276
- * @returns A new InputEventBufferData
1277
- *
1278
- * @example
1279
- * ```typescript
1280
- * import { createInputEventBuffer, pushKeyEvent, drainKeys } from 'blecsd';
1281
- *
1282
- * const buffer = createInputEventBuffer({ maxBufferSize: 500 });
1283
- *
1284
- * // Push events from stdin
1285
- * pushKeyEvent(buffer, keyEvent);
1286
- *
1287
- * // Drain in game loop
1288
- * const keys = drainKeys(buffer);
1289
- * ```
1290
- */
1291
- declare function createInputEventBuffer(options?: InputEventBufferOptions): InputEventBufferData;
1292
- /**
1293
- * Pushes a keyboard event to the buffer.
1294
- *
1295
- * @param buffer - The input event buffer
1296
- * @param event - The keyboard event to buffer
1297
- * @param timestamp - Optional timestamp (default: now)
1298
- *
1299
- * @example
1300
- * ```typescript
1301
- * pushKeyEvent(buffer, { name: 'a', ctrl: false, meta: false, shift: false, sequence: 'a' });
1302
- * ```
1303
- */
1304
- declare function pushKeyEvent(buffer: InputEventBufferData, event: KeyEvent, timestamp?: number): void;
1305
- /**
1306
- * Pushes a mouse event to the buffer.
1307
- *
1308
- * @param buffer - The input event buffer
1309
- * @param event - The mouse event to buffer
1310
- * @param timestamp - Optional timestamp (default: now)
1311
- *
1312
- * @example
1313
- * ```typescript
1314
- * pushMouseEvent(buffer, { x: 10, y: 20, button: 'left', action: 'mousedown', ctrl: false, meta: false, shift: false });
1315
- * ```
1316
- */
1317
- declare function pushMouseEvent(buffer: InputEventBufferData, event: MouseEvent, timestamp?: number): void;
1318
- /**
1319
- * Drains all keyboard events from the buffer.
1320
- * Returns events in order (oldest first) and clears the buffer.
1321
- *
1322
- * @param buffer - The input event buffer
1323
- * @returns Array of timestamped key events
1324
- *
1325
- * @example
1326
- * ```typescript
1327
- * const keys = drainKeys(buffer);
1328
- * for (const { event, timestamp } of keys) {
1329
- * console.log(`Key: ${event.name} at ${timestamp}`);
1330
- * }
1331
- * ```
1332
- */
1333
- declare function drainKeys(buffer: InputEventBufferData): TimestampedKeyEvent[];
1334
- /**
1335
- * Drains all mouse events from the buffer.
1336
- * Returns events in order (oldest first) and clears the buffer.
1337
- *
1338
- * @param buffer - The input event buffer
1339
- * @returns Array of timestamped mouse events
1340
- *
1341
- * @example
1342
- * ```typescript
1343
- * const mouse = drainMouse(buffer);
1344
- * for (const { event, timestamp } of mouse) {
1345
- * console.log(`Mouse: ${event.action} at ${event.x},${event.y}`);
1346
- * }
1347
- * ```
1348
- */
1349
- declare function drainMouse(buffer: InputEventBufferData): TimestampedMouseEvent[];
1350
- /**
1351
- * Drains all events (keys and mouse) from the buffer.
1352
- * Returns events in chronological order by timestamp.
1353
- *
1354
- * @param buffer - The input event buffer
1355
- * @returns Array of all timestamped events sorted by timestamp
1356
- *
1357
- * @example
1358
- * ```typescript
1359
- * const events = drainAllEvents(buffer);
1360
- * for (const event of events) {
1361
- * if (event.type === 'key') {
1362
- * handleKey(event.event);
1363
- * } else {
1364
- * handleMouse(event.event);
1365
- * }
1366
- * }
1367
- * ```
1368
- */
1369
- declare function drainAllEvents(buffer: InputEventBufferData): TimestampedInputEvent[];
1370
- /**
1371
- * Peeks at all pending events without removing them.
1372
- *
1373
- * @param buffer - The input event buffer
1374
- * @returns Array of all pending events sorted by timestamp
1375
- */
1376
- declare function peekEvents(buffer: InputEventBufferData): TimestampedInputEvent[];
1377
- /**
1378
- * Peeks at pending key events without removing them.
1379
- *
1380
- * @param buffer - The input event buffer
1381
- * @returns Array of pending key events
1382
- */
1383
- declare function peekKeys(buffer: InputEventBufferData): readonly TimestampedKeyEvent[];
1384
- /**
1385
- * Peeks at pending mouse events without removing them.
1386
- *
1387
- * @param buffer - The input event buffer
1388
- * @returns Array of pending mouse events
1389
- */
1390
- declare function peekMouse(buffer: InputEventBufferData): readonly TimestampedMouseEvent[];
1391
- /**
1392
- * Clears all pending events from the buffer.
1393
- *
1394
- * @param buffer - The input event buffer
1395
- */
1396
- declare function clearBuffer(buffer: InputEventBufferData): void;
1397
- /**
1398
- * Gets the number of pending key events.
1399
- *
1400
- * @param buffer - The input event buffer
1401
- */
1402
- declare function getPendingKeyCount(buffer: InputEventBufferData): number;
1403
- /**
1404
- * Gets the number of pending mouse events.
1405
- *
1406
- * @param buffer - The input event buffer
1407
- */
1408
- declare function getPendingMouseCount(buffer: InputEventBufferData): number;
1409
- /**
1410
- * Gets the total number of pending events.
1411
- *
1412
- * @param buffer - The input event buffer
1413
- */
1414
- declare function getPendingCount(buffer: InputEventBufferData): number;
1415
- /**
1416
- * Checks if there are any pending events.
1417
- *
1418
- * @param buffer - The input event buffer
1419
- */
1420
- declare function hasPendingEvents(buffer: InputEventBufferData): boolean;
1421
- /**
1422
- * Gets buffer statistics for debugging.
1423
- *
1424
- * @param buffer - The input event buffer
1425
- * @returns Statistics about the buffer
1426
- *
1427
- * @example
1428
- * ```typescript
1429
- * const stats = getStats(buffer);
1430
- * console.log(`Total events: ${stats.totalKeyEvents + stats.totalMouseEvents}`);
1431
- * console.log(`Dropped: ${stats.droppedEvents}`);
1432
- * ```
1433
- */
1434
- declare function getStats(buffer: InputEventBufferData): InputBufferStats;
1435
- /**
1436
- * Resets buffer statistics.
1437
- *
1438
- * @param buffer - The input event buffer
1439
- */
1440
- declare function resetStats(buffer: InputEventBufferData): void;
1441
- /**
1442
- * Marks the start of frame processing.
1443
- * Call this at the beginning of your input processing phase.
1444
- *
1445
- * @param buffer - The input event buffer
1446
- *
1447
- * @example
1448
- * ```typescript
1449
- * beginFrame(buffer);
1450
- * const keys = drainKeys(buffer);
1451
- * // process keys...
1452
- * endFrame(buffer);
1453
- * ```
1454
- */
1455
- declare function beginFrame(buffer: InputEventBufferData): void;
1456
- /**
1457
- * Marks the end of frame processing and records the processing time.
1458
- * Call this after all input events have been processed.
1459
- *
1460
- * @param buffer - The input event buffer
1461
- * @returns The frame processing time in milliseconds
1462
- */
1463
- declare function endFrame(buffer: InputEventBufferData): number;
1464
- /**
1465
- * Records latency for a processed event.
1466
- * Call this when an event has been fully processed to track input latency.
1467
- *
1468
- * @param buffer - The input event buffer
1469
- * @param latencyMs - The latency in milliseconds
1470
- *
1471
- * @example
1472
- * ```typescript
1473
- * for (const { event, timestamp } of drainKeys(buffer)) {
1474
- * handleKey(event);
1475
- * const latency = performance.now() - timestamp;
1476
- * recordLatency(buffer, latency);
1477
- * }
1478
- * ```
1479
- */
1480
- declare function recordLatency(buffer: InputEventBufferData, latencyMs: number): void;
1481
- /**
1482
- * Records latency for multiple events at once.
1483
- * More efficient than calling recordLatency for each event.
1484
- *
1485
- * @param buffer - The input event buffer
1486
- * @param avgLatencyMs - Average latency for all events
1487
- * @param eventCount - Number of events processed
1488
- */
1489
- declare function recordLatencyBatch(buffer: InputEventBufferData, avgLatencyMs: number, eventCount: number): void;
1490
- /**
1491
- * Gets latency statistics for input processing.
1492
- * Returns min, max, average, and percentile latencies.
1493
- *
1494
- * @param buffer - The input event buffer
1495
- * @returns Latency statistics in milliseconds
1496
- *
1497
- * @example
1498
- * ```typescript
1499
- * const stats = getLatencyStats(buffer);
1500
- * console.log(`Avg latency: ${stats.avg.toFixed(2)}ms`);
1501
- * console.log(`P95 latency: ${stats.p95.toFixed(2)}ms`);
1502
- * if (stats.max > 16) {
1503
- * console.warn('Input latency exceeds frame budget!');
1504
- * }
1505
- * ```
1506
- */
1507
- declare function getLatencyStats(buffer: InputEventBufferData): InputLatencyStats;
1508
- /**
1509
- * Resets latency statistics.
1510
- *
1511
- * @param buffer - The input event buffer
1512
- */
1513
- declare function resetLatencyStats(buffer: InputEventBufferData): void;
1514
- /**
1515
- * Checks if the current latency is within acceptable bounds.
1516
- * By default, checks if p95 latency is under 16ms (one frame at 60fps).
1517
- *
1518
- * @param buffer - The input event buffer
1519
- * @param maxLatencyMs - Maximum acceptable p95 latency in milliseconds
1520
- * @returns True if latency is acceptable
1521
- */
1522
- declare function isLatencyAcceptable(buffer: InputEventBufferData, maxLatencyMs?: number): boolean;
1523
- /**
1524
- * Checks if frame processing time is within budget.
1525
- * By default, checks if average processing time is under 1ms.
1526
- *
1527
- * @param buffer - The input event buffer
1528
- * @param maxProcessingTimeMs - Maximum acceptable processing time in milliseconds
1529
- * @returns True if processing time is acceptable
1530
- */
1531
- declare function isProcessingTimeAcceptable(buffer: InputEventBufferData, maxProcessingTimeMs?: number): boolean;
1532
- /**
1533
- * Global shared input buffer for simple use cases.
1534
- *
1535
- * For more complex scenarios (multiple input sources, custom overflow handling),
1536
- * create your own buffer with createInputEventBuffer().
1537
- *
1538
- * @example
1539
- * ```typescript
1540
- * import { globalInputBuffer, pushKeyEvent, drainAllEvents } from 'blecsd';
1541
- *
1542
- * // Push from stdin handler
1543
- * pushKeyEvent(globalInputBuffer, event);
1544
- *
1545
- * // Drain in game loop
1546
- * const events = drainAllEvents(globalInputBuffer);
1547
- * ```
1140
+ * Entity factory functions for creating common entity types.
1141
+ * These factories combine components and helpers to create fully-configured entities.
1142
+ * @module core/entities/factories
1548
1143
  */
1549
- declare const globalInputBuffer: InputEventBufferData;
1550
1144
 
1551
- /**
1552
- * Input state tracking for keyboard and mouse.
1553
- *
1554
- * Provides frame-aware input queries like isKeyPressed (just this frame),
1555
- * isKeyReleased, key hold time, and repeat handling.
1556
- *
1557
- * @module core/inputState
1558
- */
1559
-
1560
- /**
1561
- * State of a single key.
1562
- */
1563
- interface KeyState {
1564
- /** Key is currently pressed down */
1565
- readonly pressed: boolean;
1566
- /** Key was pressed this frame (transitioned from up to down) */
1567
- readonly justPressed: boolean;
1568
- /** Key was released this frame (transitioned from down to up) */
1569
- readonly justReleased: boolean;
1570
- /** Time the key has been held in milliseconds */
1571
- readonly heldTime: number;
1572
- /** Number of auto-repeat events received while held */
1573
- readonly repeatCount: number;
1574
- /** Last event timestamp */
1575
- readonly lastEventTime: number;
1576
- }
1577
- /**
1578
- * State of a mouse button.
1579
- */
1580
- interface MouseButtonState {
1581
- /** Button is currently pressed */
1582
- readonly pressed: boolean;
1583
- /** Button was pressed this frame */
1584
- readonly justPressed: boolean;
1585
- /** Button was released this frame */
1586
- readonly justReleased: boolean;
1587
- /** Time the button has been held in milliseconds */
1588
- readonly heldTime: number;
1589
- /** Last event timestamp */
1590
- readonly lastEventTime: number;
1591
- }
1592
- /**
1593
- * Current mouse position and state.
1594
- */
1595
- interface MouseState {
1596
- /** Current X position */
1597
- readonly x: number;
1598
- /** Current Y position */
1599
- readonly y: number;
1600
- /** X movement since last frame */
1601
- readonly deltaX: number;
1602
- /** Y movement since last frame */
1603
- readonly deltaY: number;
1604
- /** Scroll wheel delta since last frame (positive = up) */
1605
- readonly wheelDelta: number;
1606
- /** State of each button */
1607
- readonly buttons: Readonly<Record<MouseButton, MouseButtonState>>;
1608
- }
1609
- /**
1610
- * Input state statistics.
1611
- */
1612
- interface InputStateStats {
1613
- /** Number of keys currently held down */
1614
- readonly keysDown: number;
1615
- /** Number of keys pressed this frame */
1616
- readonly keysPressed: number;
1617
- /** Number of keys released this frame */
1618
- readonly keysReleased: number;
1619
- /** Total key events processed this frame */
1620
- readonly keyEventsThisFrame: number;
1621
- /** Total mouse events processed this frame */
1622
- readonly mouseEventsThisFrame: number;
1623
- /** Current frame number */
1624
- readonly frameCount: number;
1625
- }
1626
- /**
1627
- * Configuration for input state tracking.
1628
- */
1629
- interface InputStateConfig {
1630
- /**
1631
- * Whether to track OS key repeats separately.
1632
- * When true, repeatCount increments for each repeat event.
1633
- * When false, repeats are ignored after initial press.
1634
- * @default true
1635
- */
1636
- readonly trackRepeats?: boolean;
1637
- /**
1638
- * Minimum time (ms) between key events to consider them separate presses.
1639
- * Helps filter out very fast unintentional double-presses.
1640
- * @default 0 (no debouncing)
1641
- */
1642
- readonly debounceTime?: number;
1643
- /**
1644
- * Custom repeat rate in ms. When set, overrides OS key repeat.
1645
- * InputState will generate synthetic repeat events at this rate.
1646
- * @default undefined (use OS repeat)
1647
- */
1648
- readonly customRepeatRate?: number;
1649
- /**
1650
- * Initial delay before custom repeat starts (ms).
1651
- * @default 500
1652
- */
1653
- readonly customRepeatDelay?: number;
1654
- }
1655
- /**
1656
- * InputState interface for type-safe access.
1657
- *
1658
- * Tracks input state across frames.
1659
- * Call `update()` at the start of each frame with input events from the buffer.
1660
- * Then use query methods like `isKeyDown()`, `isKeyPressed()`, etc.
1661
- */
1662
- interface InputState {
1663
- update(keyEvents: readonly TimestampedKeyEvent[], mouseEvents: readonly TimestampedMouseEvent[], deltaTime: number): void;
1664
- isKeyDown(key: KeyName | string): boolean;
1665
- isKeyPressed(key: KeyName | string): boolean;
1666
- isKeyReleased(key: KeyName | string): boolean;
1667
- getKeyHeldTime(key: KeyName | string): number;
1668
- getKeyState(key: KeyName | string): KeyState;
1669
- getKeyRepeatCount(key: KeyName | string): number;
1670
- getPressedKeys(): string[];
1671
- getJustPressedKeys(): string[];
1672
- getJustReleasedKeys(): string[];
1673
- isCtrlDown(): boolean;
1674
- isAltDown(): boolean;
1675
- isShiftDown(): boolean;
1676
- hasModifier(): boolean;
1677
- isMouseButtonDown(button: MouseButton): boolean;
1678
- isMouseButtonPressed(button: MouseButton): boolean;
1679
- isMouseButtonReleased(button: MouseButton): boolean;
1680
- getMouseX(): number;
1681
- getMouseY(): number;
1682
- getMousePosition(): {
1683
- x: number;
1684
- y: number;
1685
- };
1686
- getMouseDelta(): {
1687
- deltaX: number;
1688
- deltaY: number;
1689
- };
1690
- getWheelDelta(): number;
1691
- getMouseState(): MouseState;
1692
- releaseKey(key: KeyName | string): void;
1693
- releaseAllKeys(): void;
1694
- releaseAllMouseButtons(): void;
1695
- releaseAll(): void;
1696
- getStats(): InputStateStats;
1697
- getFrameCount(): number;
1698
- reset(): void;
1699
- }
1700
- /**
1701
- * Creates a new InputState tracker.
1702
- *
1703
- * @param config - Configuration options
1704
- * @returns A new InputState instance
1705
- *
1706
- * @example
1707
- * ```typescript
1708
- * import { createInputState } from 'blecsd';
1709
- *
1710
- * const inputState = createInputState({
1711
- * trackRepeats: true,
1712
- * debounceTime: 50, // Ignore inputs within 50ms
1713
- * });
1714
- * ```
1715
- */
1716
- declare function createInputState(config?: InputStateConfig): InputState;
1717
- /**
1718
- * Checks if any of the specified keys are pressed.
1719
- *
1720
- * @param inputState - The input state to check
1721
- * @param keys - Keys to check
1722
- * @returns true if any key is currently pressed
1723
- *
1724
- * @example
1725
- * ```typescript
1726
- * if (isAnyKeyDown(inputState, ['w', 'up'])) {
1727
- * moveForward();
1728
- * }
1729
- * ```
1730
- */
1731
- declare function isAnyKeyDown(inputState: InputState, keys: readonly (KeyName | string)[]): boolean;
1732
- /**
1733
- * Checks if all specified keys are pressed.
1734
- *
1735
- * @param inputState - The input state to check
1736
- * @param keys - Keys to check
1737
- * @returns true if all keys are currently pressed
1738
- *
1739
- * @example
1740
- * ```typescript
1741
- * if (isAllKeysDown(inputState, ['ctrl', 's'])) {
1742
- * save();
1743
- * }
1744
- * ```
1745
- */
1746
- declare function isAllKeysDown(inputState: InputState, keys: readonly (KeyName | string)[]): boolean;
1747
- /**
1748
- * Checks if any of the specified keys were just pressed this frame.
1749
- *
1750
- * @param inputState - The input state to check
1751
- * @param keys - Keys to check
1752
- * @returns true if any key was just pressed
1753
- */
1754
- declare function isAnyKeyPressed(inputState: InputState, keys: readonly (KeyName | string)[]): boolean;
1755
- /**
1756
- * Gets the direction vector from WASD or arrow keys.
1757
- *
1758
- * @param inputState - The input state to check
1759
- * @returns Object with x (-1, 0, or 1) and y (-1, 0, or 1)
1760
- *
1761
- * @example
1762
- * ```typescript
1763
- * const dir = getMovementDirection(inputState);
1764
- * player.x += dir.x * speed;
1765
- * player.y += dir.y * speed;
1766
- * ```
1767
- */
1768
- declare function getMovementDirection(inputState: InputState): {
1769
- x: number;
1770
- y: number;
1771
- };
1772
-
1773
- /**
1774
- * Input action mapping system for game controls.
1775
- *
1776
- * Maps physical inputs (keys, mouse buttons) to logical game actions.
1777
- * Supports multiple bindings per action, runtime rebinding, and save/load.
1778
- *
1779
- * @module core/inputActions
1780
- */
1781
-
1782
- /**
1783
- * Configuration for a single action binding.
1784
- */
1785
- interface ActionBinding {
1786
- /** Unique action identifier (e.g., 'jump', 'attack', 'move_left') */
1787
- readonly action: string;
1788
- /** Keys that activate this action */
1789
- readonly keys: readonly string[];
1790
- /** Mouse buttons that activate this action */
1791
- readonly mouseButtons?: readonly MouseButton[] | undefined;
1792
- /** Whether action fires continuously while held (default: false) */
1793
- readonly continuous?: boolean | undefined;
1794
- /** Deadzone for analog inputs (0-1, default: 0.1) */
1795
- readonly deadzone?: number | undefined;
1796
- }
1797
- /**
1798
- * Runtime state of an action.
1799
- */
1800
- interface ActionState {
1801
- /** Action is currently active (input is held) */
1802
- readonly active: boolean;
1803
- /** Action was just activated this frame */
1804
- readonly justActivated: boolean;
1805
- /** Action was just deactivated this frame */
1806
- readonly justDeactivated: boolean;
1807
- /** How long the action has been active (ms) */
1808
- readonly activeTime: number;
1809
- /** Analog value (0-1), 1 when digital input is pressed */
1810
- readonly value: number;
1811
- }
1812
- /**
1813
- * Serialized action bindings for save/load.
1814
- */
1815
- interface SerializedBindings {
1816
- readonly version: number;
1817
- readonly bindings: readonly {
1818
- readonly action: string;
1819
- readonly keys: readonly string[];
1820
- readonly mouseButtons?: readonly string[] | undefined;
1821
- readonly continuous?: boolean | undefined;
1822
- }[];
1823
- }
1824
- /**
1825
- * Callback for action state changes.
1826
- */
1827
- type ActionCallback = (action: string, state: ActionState, inputState: InputState) => void;
1828
- /**
1829
- * Zod schema for action binding validation.
1830
- */
1831
- declare const ActionBindingSchema: z.ZodObject<{
1832
- action: z.ZodString;
1833
- keys: z.ZodDefault<z.ZodArray<z.ZodString>>;
1834
- mouseButtons: z.ZodOptional<z.ZodArray<z.ZodEnum<{
1835
- unknown: "unknown";
1836
- left: "left";
1837
- right: "right";
1838
- middle: "middle";
1839
- wheelUp: "wheelUp";
1840
- wheelDown: "wheelDown";
1841
- }>>>;
1842
- continuous: z.ZodDefault<z.ZodBoolean>;
1843
- deadzone: z.ZodDefault<z.ZodNumber>;
1844
- }, z.core.$strip>;
1845
- /**
1846
- * Zod schema for serialized bindings.
1847
- */
1848
- declare const SerializedBindingsSchema: z.ZodObject<{
1849
- version: z.ZodNumber;
1850
- bindings: z.ZodArray<z.ZodObject<{
1851
- action: z.ZodString;
1852
- keys: z.ZodArray<z.ZodString>;
1853
- mouseButtons: z.ZodOptional<z.ZodArray<z.ZodString>>;
1854
- continuous: z.ZodOptional<z.ZodBoolean>;
1855
- }, z.core.$strip>>;
1856
- }, z.core.$strip>;
1857
- /**
1858
- * InputActionManager interface for type-safe access.
1859
- */
1860
- interface InputActionManager {
1861
- register(binding: ActionBinding): InputActionManager;
1862
- registerAll(bindings: readonly ActionBinding[]): InputActionManager;
1863
- unregister(action: string): boolean;
1864
- hasAction(action: string): boolean;
1865
- getActions(): string[];
1866
- getBinding(action: string): ActionBinding | undefined;
1867
- update(inputState: InputState, deltaTime: number): void;
1868
- isActive(action: string): boolean;
1869
- isJustActivated(action: string): boolean;
1870
- isJustDeactivated(action: string): boolean;
1871
- getValue(action: string): number;
1872
- getActiveTime(action: string): number;
1873
- getState(action: string): ActionState;
1874
- getActiveActions(): string[];
1875
- rebindKeys(action: string, keys: readonly string[]): boolean;
1876
- rebindMouseButtons(action: string, buttons: readonly MouseButton[]): boolean;
1877
- addKey(action: string, key: string): boolean;
1878
- removeKey(action: string, key: string): boolean;
1879
- getKeysForAction(action: string): string[];
1880
- getMouseButtonsForAction(action: string): MouseButton[];
1881
- getActionsForKey(key: string): string[];
1882
- onAction(action: string, callback: ActionCallback): () => void;
1883
- onAnyAction(callback: ActionCallback): () => void;
1884
- saveBindings(): SerializedBindings;
1885
- loadBindings(data: unknown): void;
1886
- toJSON(pretty?: boolean): string;
1887
- fromJSON(json: string): void;
1888
- resetStates(): void;
1889
- clear(): void;
1890
- }
1891
- /**
1892
- * Creates a new InputActionManager.
1893
- *
1894
- * @param initialBindings - Optional initial bindings to register
1895
- * @returns A new InputActionManager instance
1896
- *
1897
- * @example
1898
- * ```typescript
1899
- * import { createInputActionManager } from 'blecsd';
1900
- *
1901
- * const actions = createInputActionManager([
1902
- * { action: 'jump', keys: ['space'] },
1903
- * { action: 'attack', keys: ['j'], mouseButtons: ['left'] },
1904
- * ]);
1905
- * ```
1906
- */
1907
- declare function createInputActionManager(initialBindings?: readonly ActionBinding[]): InputActionManager;
1908
- /**
1909
- * Common action presets for quick setup.
1910
- */
1911
- declare const ActionPresets: {
1912
- /**
1913
- * Standard platformer controls.
1914
- */
1915
- readonly platformer: readonly ActionBinding[];
1916
- /**
1917
- * Standard top-down controls.
1918
- */
1919
- readonly topDown: readonly ActionBinding[];
1920
- /**
1921
- * Menu navigation controls.
1922
- */
1923
- readonly menu: readonly ActionBinding[];
1924
- };
1145
+ declare function createBoxEntity(world: World, config?: BoxConfig): Entity;
1146
+ declare function createTextEntity(world: World, config?: TextConfig): Entity;
1147
+ declare function createButtonEntity(world: World, config?: ButtonConfig): Entity;
1148
+ declare function createScreenEntity(world: World, config: ScreenConfig): Entity;
1149
+ declare function createInputEntity(world: World, config?: InputConfig): Entity;
1150
+ declare function createListEntity(world: World, config?: ListConfig): Entity;
1151
+ declare function createCheckboxEntity(world: World, config?: CheckboxConfig): Entity;
1152
+ declare function createTextboxEntity(world: World, config?: TextboxConfig): Entity;
1153
+ declare function createTextareaEntity(world: World, config?: TextareaConfig): Entity;
1154
+ declare function createSelectEntity(world: World, config?: SelectConfig): Entity;
1155
+ declare function createSliderEntity(world: World, config?: SliderConfig): Entity;
1156
+ declare function createFormEntity(world: World, config?: FormConfig): Entity;
1157
+ declare function createProgressBarEntity(world: World, config?: ProgressBarConfig): Entity;
1158
+ declare function createRadioSetEntity(world: World, config?: RadioSetConfig): Entity;
1159
+ declare function createRadioButtonEntity(world: World, config?: RadioButtonConfig): Entity;
1925
1160
 
1926
- export { createInputEventBuffer as $, type ActionBinding as A, type BoxConfig as B, type CheckboxConfig as C, RadioSetConfigSchema as D, type ScreenConfig as E, type FormConfig as F, ScreenConfigSchema as G, SelectConfigSchema as H, type InputEventBufferData as I, type SerializedBindings as J, type KeyState as K, type ListConfig as L, type MouseButtonState as M, SerializedBindingsSchema as N, SliderConfigSchema as O, type ProgressBarConfig as P, TextConfigSchema as Q, type RadioButtonConfig as R, type SelectConfig as S, type TextConfig as T, TextareaConfigSchema as U, TextboxConfigSchema as V, type TimestampedInputEvent as W, type TimestampedKeyEvent as X, type TimestampedMouseEvent as Y, beginFrame as Z, createInputActionManager as _, type InputState as a, createInputState as a0, drainAllEvents as a1, drainKeys as a2, drainMouse as a3, endFrame as a4, getLatencyStats as a5, getMovementDirection as a6, getPendingCount as a7, getPendingKeyCount as a8, getPendingMouseCount as a9, globalInputBuffer as aa, hasPendingEvents as ab, isAllKeysDown as ac, isAnyKeyDown as ad, isAnyKeyPressed as ae, isLatencyAcceptable as af, isProcessingTimeAcceptable as ag, peekEvents as ah, peekKeys as ai, peekMouse as aj, pushKeyEvent as ak, pushMouseEvent as al, recordLatency as am, recordLatencyBatch as an, resetLatencyStats as ao, resetStats as ap, clearBuffer as aq, getStats as ar, type ButtonConfig as b, type InputConfig as c, type TextareaConfig as d, type TextboxConfig as e, type RadioSetConfig as f, type SliderConfig as g, ActionBindingSchema as h, type ActionCallback as i, ActionPresets as j, type ActionState as k, BoxConfigSchema as l, ButtonConfigSchema as m, CheckboxConfigSchema as n, FormConfigSchema as o, type InputActionManager as p, type InputBufferStats as q, InputConfigSchema as r, type InputEventBufferOptions as s, type InputLatencyStats as t, type InputStateConfig as u, type InputStateStats as v, ListConfigSchema as w, type MouseState as x, ProgressBarConfigSchema as y, RadioButtonConfigSchema as z };
1161
+ export { TextareaConfigSchema as A, type BoxConfig as B, type CheckboxConfig as C, type TextboxConfig as D, TextboxConfigSchema as E, type FormConfig as F, createFormEntity as G, createProgressBarEntity as H, type InputConfig as I, createRadioButtonEntity as J, createRadioSetEntity as K, type ListConfig as L, createSliderEntity as M, createTextareaEntity as N, createTextboxEntity as O, type ProgressBarConfig as P, type RadioButtonConfig as R, type ScreenConfig as S, type TextConfig as T, BoxConfigSchema as a, TextConfigSchema as b, createBoxEntity as c, createButtonEntity as d, createCheckboxEntity as e, createInputEntity as f, createListEntity as g, createScreenEntity as h, createSelectEntity as i, createTextEntity as j, type ButtonConfig as k, ButtonConfigSchema as l, CheckboxConfigSchema as m, FormConfigSchema as n, InputConfigSchema as o, ListConfigSchema as p, ProgressBarConfigSchema as q, RadioButtonConfigSchema as r, type RadioSetConfig as s, RadioSetConfigSchema as t, ScreenConfigSchema as u, type SelectConfig as v, SelectConfigSchema as w, type SliderConfig as x, SliderConfigSchema as y, type TextareaConfig as z };