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
@@ -0,0 +1,1908 @@
1
+ import { S as Scheduler } from './scheduler-NbHT3-D2.js';
2
+ import { S as System, W as World, E as Entity } from './types-B8LmNkzG.js';
3
+ import { b as EventBus, M as MouseEvent, U as UIEventMap } from './mouseParser-CCqSEUVN.js';
4
+ import { K as KeyEvent } from './keyParser-DReXe2j-.js';
5
+ import { Writable } from 'node:stream';
6
+ import { a as CellChange, S as ScreenBufferData, C as Cell } from './cell-5Ty_3yMs.js';
7
+ import { D as DoubleBufferData } from './doubleBuffer-CWASihKh.js';
8
+ import { a as DirtyTracker } from './dirtyTracking-kCS9-NVF.js';
9
+
10
+ /**
11
+ * Animation system for updating sprite animations.
12
+ * Processes all entities with Animation component.
13
+ * @module systems/animationSystem
14
+ */
15
+
16
+ /**
17
+ * Query all entities with the Animation component.
18
+ *
19
+ * PERF: Returns iterable query result to avoid per-frame allocation.
20
+ *
21
+ * @param world - The ECS world
22
+ * @returns Iterable of entity IDs with Animation component
23
+ */
24
+ declare function queryAnimation(world: World): Iterable<number>;
25
+ /**
26
+ * Checks if an entity has the Animation component (via system store).
27
+ *
28
+ * @param world - The ECS world
29
+ * @param eid - Entity to check
30
+ * @returns true if entity has Animation component
31
+ */
32
+ declare function hasAnimationSystem(world: World, eid: number): boolean;
33
+ /**
34
+ * Animation system that updates all entities with Animation component.
35
+ *
36
+ * This system should be registered in the UPDATE phase of the game loop.
37
+ * It reads delta time from getDeltaTime() which is set by the scheduler.
38
+ *
39
+ * For each playing animation, the system:
40
+ * 1. Adds elapsed time (scaled by speed)
41
+ * 2. Checks if current frame duration exceeded
42
+ * 3. Advances to next frame (respecting direction)
43
+ * 4. Handles loop/stop when animation completes
44
+ * 5. Updates the entity's Sprite component frame
45
+ *
46
+ * @param world - The ECS world to process
47
+ * @returns The world (unchanged reference)
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * import { createScheduler, LoopPhase, animationSystem } from 'blecsd';
52
+ *
53
+ * const scheduler = createScheduler();
54
+ * scheduler.registerSystem(LoopPhase.UPDATE, animationSystem);
55
+ *
56
+ * // In game loop
57
+ * scheduler.run(world, deltaTime);
58
+ * ```
59
+ */
60
+ declare const animationSystem: System;
61
+ /**
62
+ * Creates a new animation system.
63
+ *
64
+ * Factory function that returns the animationSystem.
65
+ * Useful for cases where you need a fresh reference.
66
+ *
67
+ * @returns The animation system function
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * import { createAnimationSystem, createScheduler, LoopPhase } from 'blecsd';
72
+ *
73
+ * const scheduler = createScheduler();
74
+ * const system = createAnimationSystem();
75
+ * scheduler.registerSystem(LoopPhase.UPDATE, system);
76
+ * ```
77
+ */
78
+ declare function createAnimationSystem(): System;
79
+ /**
80
+ * Registers the animation system with a scheduler.
81
+ *
82
+ * Convenience function that registers animationSystem in the UPDATE phase.
83
+ *
84
+ * @param scheduler - The scheduler to register with
85
+ * @param priority - Optional priority within the UPDATE phase (default: 0)
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * import { createScheduler, registerAnimationSystem } from 'blecsd';
90
+ *
91
+ * const scheduler = createScheduler();
92
+ * registerAnimationSystem(scheduler);
93
+ *
94
+ * // Animation updates will now happen in UPDATE phase
95
+ * scheduler.run(world, deltaTime);
96
+ * ```
97
+ */
98
+ declare function registerAnimationSystem(scheduler: Scheduler, priority?: number): void;
99
+ /**
100
+ * Manually update animations for specific entities.
101
+ *
102
+ * Useful when you need to update animations outside of the system,
103
+ * such as in tests or custom update loops.
104
+ *
105
+ * @param world - The ECS world
106
+ * @param entities - Array of entity IDs to update
107
+ * @param deltaTime - Time elapsed in seconds
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * import { updateAnimations, queryAnimation } from 'blecsd';
112
+ *
113
+ * // Manual update (typically use the system instead)
114
+ * const entities = queryAnimation(world);
115
+ * updateAnimations(world, entities, 0.016); // ~60fps frame
116
+ * ```
117
+ */
118
+ declare function updateAnimations(world: World, entities: readonly number[], deltaTime: number): void;
119
+
120
+ /**
121
+ * Focus Management System
122
+ *
123
+ * Handles keyboard focus navigation and focus state management.
124
+ * Tracks which entity is focused and provides tab/arrow navigation.
125
+ *
126
+ * @module systems/focusSystem
127
+ *
128
+ * @example
129
+ * ```typescript
130
+ * import {
131
+ * focusSystem,
132
+ * focusNext,
133
+ * focusPrev,
134
+ * focusEntity,
135
+ * getFocused,
136
+ * blurAll,
137
+ * } from 'blecsd';
138
+ *
139
+ * // Register with scheduler
140
+ * const scheduler = createScheduler();
141
+ * scheduler.registerSystem(LoopPhase.INPUT, focusSystem);
142
+ *
143
+ * // Navigate focus
144
+ * focusNext(world); // Focus next element
145
+ * focusPrev(world); // Focus previous element
146
+ *
147
+ * // Direct focus
148
+ * focusEntity(world, buttonEntity);
149
+ *
150
+ * // Check current focus
151
+ * const focused = getFocused(world);
152
+ * ```
153
+ */
154
+
155
+ /**
156
+ * Focus event types.
157
+ */
158
+ type FocusEventType = 'focus' | 'blur';
159
+ /**
160
+ * Focus event data.
161
+ */
162
+ interface FocusEventData {
163
+ /** The entity gaining/losing focus */
164
+ readonly entity: Entity;
165
+ /** The previously focused entity (for focus events) */
166
+ readonly previousEntity: Entity | null;
167
+ /** The next focused entity (for blur events) */
168
+ readonly nextEntity: Entity | null;
169
+ }
170
+ /**
171
+ * Focus event map for type-safe event handling.
172
+ */
173
+ interface FocusEventMap {
174
+ focus: FocusEventData;
175
+ blur: FocusEventData;
176
+ }
177
+ /**
178
+ * Gets the focus event bus, creating if needed.
179
+ *
180
+ * @returns The focus event bus
181
+ *
182
+ * @example
183
+ * ```typescript
184
+ * const bus = getFocusEventBus();
185
+ * bus.on('focus', (data) => {
186
+ * console.log(`Entity ${data.entity} focused`);
187
+ * });
188
+ * ```
189
+ */
190
+ declare function getFocusEventBus(): EventBus<FocusEventMap>;
191
+ /**
192
+ * Resets the focus event bus. Used for testing.
193
+ * @internal
194
+ */
195
+ declare function resetFocusEventBus(): void;
196
+ /**
197
+ * Gets all focusable entities sorted by tab order.
198
+ *
199
+ * @param world - The ECS world
200
+ * @returns Sorted array of focusable entity IDs
201
+ */
202
+ declare function getFocusableEntities(world: World): Entity[];
203
+ /**
204
+ * Gets the currently focused entity.
205
+ *
206
+ * @param world - The ECS world
207
+ * @returns The focused entity or null if none focused
208
+ *
209
+ * @example
210
+ * ```typescript
211
+ * const focused = getFocused(world);
212
+ * if (focused) {
213
+ * console.log(`Entity ${focused} is focused`);
214
+ * }
215
+ * ```
216
+ */
217
+ declare function getFocused(world: World): Entity | null;
218
+ /**
219
+ * Focuses a specific entity.
220
+ *
221
+ * @param world - The ECS world
222
+ * @param eid - The entity to focus
223
+ * @returns true if focus was set successfully
224
+ *
225
+ * @example
226
+ * ```typescript
227
+ * focusEntity(world, buttonEntity);
228
+ * ```
229
+ */
230
+ declare function focusEntity(world: World, eid: Entity): boolean;
231
+ /**
232
+ * Removes focus from all entities.
233
+ *
234
+ * @param world - The ECS world
235
+ *
236
+ * @example
237
+ * ```typescript
238
+ * blurAll(world);
239
+ * ```
240
+ */
241
+ declare function blurAll(world: World): void;
242
+ /**
243
+ * Focuses the next focusable entity in tab order.
244
+ *
245
+ * @param world - The ECS world
246
+ * @returns The newly focused entity, or null if none available
247
+ *
248
+ * @example
249
+ * ```typescript
250
+ * // Handle Tab key
251
+ * if (key === 'Tab') {
252
+ * focusNext(world);
253
+ * }
254
+ * ```
255
+ */
256
+ declare function focusNext(world: World): Entity | null;
257
+ /**
258
+ * Focuses the previous focusable entity in tab order.
259
+ *
260
+ * @param world - The ECS world
261
+ * @returns The newly focused entity, or null if none available
262
+ *
263
+ * @example
264
+ * ```typescript
265
+ * // Handle Shift+Tab key
266
+ * if (key === 'Tab' && shiftKey) {
267
+ * focusPrev(world);
268
+ * }
269
+ * ```
270
+ */
271
+ declare function focusPrev(world: World): Entity | null;
272
+ /**
273
+ * Focuses the first focusable entity.
274
+ *
275
+ * @param world - The ECS world
276
+ * @returns The focused entity, or null if none available
277
+ */
278
+ declare function focusFirst(world: World): Entity | null;
279
+ /**
280
+ * Focuses the last focusable entity.
281
+ *
282
+ * @param world - The ECS world
283
+ * @returns The focused entity, or null if none available
284
+ */
285
+ declare function focusLast(world: World): Entity | null;
286
+ /**
287
+ * Pushes current focus onto the stack and focuses a new entity.
288
+ *
289
+ * Use this when opening modals or popups to preserve the previous focus
290
+ * state for restoration later.
291
+ *
292
+ * @param world - The ECS world
293
+ * @param eid - The entity to focus (e.g., modal or popup)
294
+ * @returns true if push was successful
295
+ *
296
+ * @example
297
+ * ```typescript
298
+ * import { focusPush, focusPop } from 'blecsd';
299
+ *
300
+ * // Open modal - save current focus and focus modal
301
+ * function openModal(world: World, modalEntity: Entity): void {
302
+ * focusPush(world, modalEntity);
303
+ * }
304
+ *
305
+ * // Close modal - restore previous focus
306
+ * function closeModal(world: World): void {
307
+ * focusPop(world);
308
+ * }
309
+ * ```
310
+ */
311
+ declare function focusPush(world: World, eid: Entity): boolean;
312
+ /**
313
+ * Pops the focus stack and restores the previous focus.
314
+ *
315
+ * Use this when closing modals or popups to restore focus to the
316
+ * element that was focused before.
317
+ *
318
+ * @param world - The ECS world
319
+ * @returns The restored entity, or null if stack was empty
320
+ *
321
+ * @example
322
+ * ```typescript
323
+ * import { focusPop } from 'blecsd';
324
+ *
325
+ * // Close modal and restore focus
326
+ * const previousFocus = focusPop(world);
327
+ * if (previousFocus) {
328
+ * console.log(`Focus restored to entity ${previousFocus}`);
329
+ * }
330
+ * ```
331
+ */
332
+ declare function focusPop(world: World): Entity | null;
333
+ /**
334
+ * Saves the current focus without affecting the stack.
335
+ *
336
+ * Use this for temporary focus changes that need to be restored
337
+ * without the full stack mechanism.
338
+ *
339
+ * @param world - The ECS world
340
+ *
341
+ * @example
342
+ * ```typescript
343
+ * import { saveFocus, restoreFocus } from 'blecsd';
344
+ *
345
+ * // Save current focus before temporary change
346
+ * saveFocus(world);
347
+ *
348
+ * // ... do something that changes focus ...
349
+ *
350
+ * // Restore the saved focus
351
+ * restoreFocus(world);
352
+ * ```
353
+ */
354
+ declare function saveFocus(world: World): void;
355
+ /**
356
+ * Restores the previously saved focus.
357
+ *
358
+ * @param world - The ECS world
359
+ * @returns The restored entity, or null if no saved focus or entity invalid
360
+ *
361
+ * @example
362
+ * ```typescript
363
+ * import { restoreFocus } from 'blecsd';
364
+ *
365
+ * const restored = restoreFocus(world);
366
+ * ```
367
+ */
368
+ declare function restoreFocus(world: World): Entity | null;
369
+ /**
370
+ * Rewinds focus to the last valid entity in the stack.
371
+ *
372
+ * This is useful when the currently focused entity is destroyed or
373
+ * becomes unfocusable. It searches backwards through the focus stack
374
+ * to find an entity that still exists and is focusable.
375
+ *
376
+ * @param world - The ECS world
377
+ * @returns The entity that received focus, or null if none found
378
+ *
379
+ * @example
380
+ * ```typescript
381
+ * import { rewindFocus } from 'blecsd';
382
+ *
383
+ * // After destroying a focused entity
384
+ * rewindFocus(world);
385
+ * ```
386
+ */
387
+ declare function rewindFocus(world: World): Entity | null;
388
+ /**
389
+ * Moves focus by a specified offset in the tab order.
390
+ *
391
+ * Positive offset moves forward (like Tab), negative moves backward
392
+ * (like Shift+Tab). The offset wraps around at the ends.
393
+ *
394
+ * @param world - The ECS world
395
+ * @param offset - Number of positions to move (positive=forward, negative=backward)
396
+ * @returns The newly focused entity, or null if none available
397
+ *
398
+ * @example
399
+ * ```typescript
400
+ * import { focusOffset } from 'blecsd';
401
+ *
402
+ * // Move focus forward by 2
403
+ * focusOffset(world, 2);
404
+ *
405
+ * // Move focus backward by 1
406
+ * focusOffset(world, -1);
407
+ * ```
408
+ */
409
+ declare function focusOffset(world: World, offset: number): Entity | null;
410
+ /**
411
+ * Gets the current focus stack depth.
412
+ *
413
+ * @param world - The ECS world
414
+ * @returns Number of entries in the focus stack
415
+ */
416
+ declare function getFocusStackDepth(world: World): number;
417
+ /**
418
+ * Clears the focus stack.
419
+ *
420
+ * Use with caution - this removes all saved focus states.
421
+ *
422
+ * @param world - The ECS world
423
+ */
424
+ declare function clearFocusStack(world: World): void;
425
+ /**
426
+ * Peeks at the top of the focus stack without popping.
427
+ *
428
+ * @param world - The ECS world
429
+ * @returns The entity at the top of the stack, or null if empty
430
+ */
431
+ declare function peekFocusStack(world: World): Entity | null;
432
+ /**
433
+ * Focus system that processes focus-related input.
434
+ *
435
+ * Currently this system validates focus state (ensuring focused entity
436
+ * is still focusable and visible). Tab key handling should be done
437
+ * in the input system or user code.
438
+ *
439
+ * @param world - The ECS world
440
+ * @returns The world
441
+ *
442
+ * @example
443
+ * ```typescript
444
+ * import { focusSystem, createScheduler, LoopPhase } from 'blecsd';
445
+ *
446
+ * const scheduler = createScheduler();
447
+ * scheduler.registerSystem(LoopPhase.INPUT, focusSystem);
448
+ * ```
449
+ */
450
+ declare const focusSystem: System;
451
+ /**
452
+ * Creates a focus system.
453
+ *
454
+ * @returns A new focus system function
455
+ */
456
+ declare function createFocusSystem(): System;
457
+
458
+ /**
459
+ * Input system for processing keyboard and mouse events.
460
+ * Handles hit testing, focus management, and event dispatch.
461
+ * @module systems/inputSystem
462
+ */
463
+
464
+ /**
465
+ * Input event types that can be queued.
466
+ */
467
+ type InputEventType = 'key' | 'mouse';
468
+ /**
469
+ * Queued key event.
470
+ */
471
+ interface QueuedKeyEvent {
472
+ type: 'key';
473
+ event: KeyEvent;
474
+ timestamp: number;
475
+ }
476
+ /**
477
+ * Queued mouse event.
478
+ */
479
+ interface QueuedMouseEvent {
480
+ type: 'mouse';
481
+ event: MouseEvent;
482
+ timestamp: number;
483
+ }
484
+ /**
485
+ * Union of all queued input events.
486
+ */
487
+ type QueuedInputEvent = QueuedKeyEvent | QueuedMouseEvent;
488
+ /**
489
+ * Result of hit testing a point.
490
+ */
491
+ interface HitTestResult {
492
+ /** Entity that was hit */
493
+ entity: Entity;
494
+ /** Local X coordinate within the entity */
495
+ localX: number;
496
+ /** Local Y coordinate within the entity */
497
+ localY: number;
498
+ /** Z-index of the entity */
499
+ zIndex: number;
500
+ }
501
+ /**
502
+ * Input system state and configuration.
503
+ */
504
+ interface InputSystemState {
505
+ /** Queue of pending input events */
506
+ eventQueue: QueuedInputEvent[];
507
+ /** Entity that currently has mouse capture (for drag operations) */
508
+ capturedEntity: Entity | null;
509
+ /** Last known mouse position */
510
+ lastMouseX: number;
511
+ lastMouseY: number;
512
+ /** Entity under the mouse last frame */
513
+ lastHoveredEntity: Entity | null;
514
+ /** Global event bus for dispatching UI events */
515
+ eventBus: EventBus<UIEventMap>;
516
+ }
517
+ /**
518
+ * Global input system state.
519
+ * Can be accessed and modified for testing or custom input handling.
520
+ */
521
+ declare const inputState: InputSystemState;
522
+ /**
523
+ * Resets input system state.
524
+ * Useful for testing or when reinitializing the input system.
525
+ *
526
+ * @example
527
+ * ```typescript
528
+ * import { resetInputState } from 'blecsd';
529
+ *
530
+ * // Clear all pending events and state
531
+ * resetInputState();
532
+ * ```
533
+ */
534
+ declare function resetInputState(): void;
535
+ /**
536
+ * Queues a keyboard event for processing.
537
+ *
538
+ * @param event - The parsed key event from the input stream
539
+ *
540
+ * @example
541
+ * ```typescript
542
+ * import { queueKeyEvent } from 'blecsd';
543
+ *
544
+ * // Queue a key event for next frame
545
+ * queueKeyEvent({ name: 'a', ctrl: false, meta: false, shift: false, raw: 'a' });
546
+ * ```
547
+ */
548
+ declare function queueKeyEvent(event: KeyEvent): void;
549
+ /**
550
+ * Queues a mouse event for processing.
551
+ *
552
+ * @param event - The parsed mouse event from the input stream
553
+ *
554
+ * @example
555
+ * ```typescript
556
+ * import { queueMouseEvent } from 'blecsd';
557
+ *
558
+ * // Queue a mouse event for next frame
559
+ * queueMouseEvent({ x: 10, y: 5, button: 'left', action: 'press', raw: '' });
560
+ * ```
561
+ */
562
+ declare function queueMouseEvent(event: MouseEvent): void;
563
+ /**
564
+ * Gets the current event queue.
565
+ * Mainly useful for debugging and testing.
566
+ */
567
+ declare function getEventQueue(): readonly QueuedInputEvent[];
568
+ /**
569
+ * Clears all queued events.
570
+ */
571
+ declare function clearEventQueue(): void;
572
+ /**
573
+ * Gets the global input event bus.
574
+ * Use this to subscribe to UI events from anywhere.
575
+ *
576
+ * @returns The global UI event bus
577
+ *
578
+ * @example
579
+ * ```typescript
580
+ * import { getInputEventBus } from 'blecsd';
581
+ *
582
+ * const eventBus = getInputEventBus();
583
+ * eventBus.on('click', (event) => {
584
+ * console.log(`Clicked at ${event.x}, ${event.y}`);
585
+ * });
586
+ * ```
587
+ */
588
+ declare function getInputEventBus(): EventBus<UIEventMap>;
589
+ /**
590
+ * Captures mouse events to a specific entity.
591
+ * While captured, all mouse events are sent to this entity
592
+ * regardless of hit testing. Used for drag operations.
593
+ *
594
+ * @param entity - Entity to capture events to, or null to release
595
+ *
596
+ * @example
597
+ * ```typescript
598
+ * import { captureMouseTo, releaseMouse } from 'blecsd';
599
+ *
600
+ * // Start drag
601
+ * captureMouseTo(entityId);
602
+ *
603
+ * // End drag
604
+ * releaseMouse();
605
+ * ```
606
+ */
607
+ declare function captureMouseTo(entity: Entity | null): void;
608
+ /**
609
+ * Releases mouse capture.
610
+ */
611
+ declare function releaseMouse(): void;
612
+ /**
613
+ * Checks if an entity is currently capturing mouse events.
614
+ */
615
+ declare function isMouseCaptured(): boolean;
616
+ /**
617
+ * Gets the entity currently capturing mouse events.
618
+ */
619
+ declare function getMouseCaptureEntity(): Entity | null;
620
+ /**
621
+ * Tests if a point is inside an entity's bounding box.
622
+ * Uses Position and Dimensions components.
623
+ *
624
+ * @param world - The ECS world
625
+ * @param eid - Entity to test
626
+ * @param x - X coordinate to test
627
+ * @param y - Y coordinate to test
628
+ * @returns true if point is inside entity bounds
629
+ *
630
+ * @example
631
+ * ```typescript
632
+ * import { pointInEntity } from 'blecsd';
633
+ *
634
+ * if (pointInEntity(world, entity, mouseX, mouseY)) {
635
+ * console.log('Mouse is over entity');
636
+ * }
637
+ * ```
638
+ */
639
+ declare function pointInEntity(world: World, eid: Entity, x: number, y: number): boolean;
640
+ /**
641
+ * Performs hit testing at a point to find all entities under it.
642
+ * Returns entities sorted by z-index (highest first).
643
+ *
644
+ * PERF: Uses iterator directly to avoid intermediate array allocation.
645
+ *
646
+ * @param world - The ECS world
647
+ * @param x - X coordinate to test
648
+ * @param y - Y coordinate to test
649
+ * @returns Array of hit test results, sorted by z-index (highest first)
650
+ *
651
+ * @example
652
+ * ```typescript
653
+ * import { hitTest } from 'blecsd';
654
+ *
655
+ * const hits = hitTest(world, mouseX, mouseY);
656
+ * if (hits.length > 0) {
657
+ * const topEntity = hits[0].entity;
658
+ * console.log(`Top entity at click: ${topEntity}`);
659
+ * }
660
+ * ```
661
+ */
662
+ declare function hitTest(world: World, x: number, y: number): HitTestResult[];
663
+ /**
664
+ * Gets the topmost interactive entity at a point.
665
+ * Only returns entities that can receive input.
666
+ *
667
+ * @param world - The ECS world
668
+ * @param x - X coordinate to test
669
+ * @param y - Y coordinate to test
670
+ * @returns The topmost interactive entity or null
671
+ */
672
+ declare function getInteractiveEntityAt(world: World, x: number, y: number): Entity | null;
673
+ /**
674
+ * The input system processes all queued input events.
675
+ * This system should be registered in the INPUT phase (automatically protected).
676
+ *
677
+ * The system:
678
+ * 1. Processes all queued key and mouse events
679
+ * 2. Updates KeyboardInput and MouseInput components
680
+ * 3. Performs hit testing for mouse events
681
+ * 4. Updates Interactive component state (hovered, pressed)
682
+ * 5. Manages focus changes (click to focus, Tab navigation)
683
+ * 6. Dispatches UI events to the event bus
684
+ *
685
+ * @param world - The ECS world to process
686
+ * @returns The world (unchanged reference)
687
+ *
688
+ * @example
689
+ * ```typescript
690
+ * import { createScheduler, inputSystem, registerInputSystem } from 'blecsd';
691
+ *
692
+ * const scheduler = createScheduler();
693
+ * registerInputSystem(scheduler);
694
+ *
695
+ * // In game loop
696
+ * scheduler.run(world, deltaTime);
697
+ * ```
698
+ */
699
+ declare const inputSystem: System;
700
+ /**
701
+ * Creates a new input system.
702
+ *
703
+ * Factory function that returns the inputSystem.
704
+ * Useful for cases where you need a fresh reference.
705
+ *
706
+ * @returns The input system function
707
+ *
708
+ * @example
709
+ * ```typescript
710
+ * import { createInputSystem, createScheduler } from 'blecsd';
711
+ *
712
+ * const scheduler = createScheduler();
713
+ * const system = createInputSystem();
714
+ * // Note: Use registerInputSystem instead for proper INPUT phase registration
715
+ * ```
716
+ */
717
+ declare function createInputSystem(): System;
718
+ /**
719
+ * Registers the input system with a scheduler.
720
+ *
721
+ * Registers inputSystem in the protected INPUT phase.
722
+ * This ensures input is always processed first.
723
+ *
724
+ * @param scheduler - The scheduler to register with
725
+ * @param priority - Optional priority within the INPUT phase (default: 0)
726
+ *
727
+ * @example
728
+ * ```typescript
729
+ * import { createScheduler, registerInputSystem } from 'blecsd';
730
+ *
731
+ * const scheduler = createScheduler();
732
+ * registerInputSystem(scheduler);
733
+ *
734
+ * // Input events will now be processed in INPUT phase
735
+ * scheduler.run(world, deltaTime);
736
+ * ```
737
+ */
738
+ declare function registerInputSystem(scheduler: Scheduler, priority?: number): void;
739
+ /**
740
+ * Clears input state for an entity.
741
+ * Resets KeyboardInput and MouseInput components to default state.
742
+ *
743
+ * @param world - The ECS world
744
+ * @param eid - Entity to clear input state for
745
+ *
746
+ * @example
747
+ * ```typescript
748
+ * import { clearEntityInput } from 'blecsd';
749
+ *
750
+ * // Clear all input state when entity loses focus
751
+ * clearEntityInput(world, entity);
752
+ * ```
753
+ */
754
+ declare function clearEntityInput(world: World, eid: Entity): void;
755
+ /**
756
+ * Query all entities that can receive input.
757
+ * Returns entities with either Interactive or Focusable components.
758
+ *
759
+ * PERF: Reuses module-level scratch array to avoid per-call allocation.
760
+ * The returned array is only valid until the next call to this function.
761
+ *
762
+ * @param world - The ECS world
763
+ * @returns Array of entity IDs that can receive input (reused buffer)
764
+ */
765
+ declare function queryInputReceivers(world: World): number[];
766
+
767
+ /**
768
+ * Layout system for computing entity positions and dimensions.
769
+ * Runs in the LAYOUT phase to pre-compute absolute positions in tree order.
770
+ * @module systems/layoutSystem
771
+ */
772
+
773
+ /**
774
+ * Computed Layout component stores the final computed positions and dimensions.
775
+ * This component is written by the layout system and read by the render system.
776
+ *
777
+ * @example
778
+ * ```typescript
779
+ * import { ComputedLayout, getComputedLayout } from 'blecsd';
780
+ *
781
+ * // After layout system runs, computed values are available
782
+ * const layout = getComputedLayout(world, entity);
783
+ * if (layout) {
784
+ * console.log(`Absolute: (${layout.x}, ${layout.y})`);
785
+ * console.log(`Size: ${layout.width}x${layout.height}`);
786
+ * }
787
+ * ```
788
+ */
789
+ declare const ComputedLayout: {
790
+ /** Computed absolute X position (screen column) */
791
+ x: Float32Array<ArrayBuffer>;
792
+ /** Computed absolute Y position (screen row) */
793
+ y: Float32Array<ArrayBuffer>;
794
+ /** Computed width in cells */
795
+ width: Float32Array<ArrayBuffer>;
796
+ /** Computed height in cells */
797
+ height: Float32Array<ArrayBuffer>;
798
+ /** Whether layout is valid (0 = needs recompute, 1 = valid) */
799
+ valid: Uint8Array<ArrayBuffer>;
800
+ };
801
+ /**
802
+ * Computed layout data returned by getComputedLayout.
803
+ */
804
+ interface ComputedLayoutData {
805
+ readonly x: number;
806
+ readonly y: number;
807
+ readonly width: number;
808
+ readonly height: number;
809
+ }
810
+ /**
811
+ * Gets the computed layout of an entity.
812
+ *
813
+ * @param world - The ECS world
814
+ * @param eid - The entity ID
815
+ * @returns Computed layout data or undefined if not available
816
+ *
817
+ * @example
818
+ * ```typescript
819
+ * const layout = getComputedLayout(world, entity);
820
+ * if (layout) {
821
+ * console.log(`Position: (${layout.x}, ${layout.y})`);
822
+ * }
823
+ * ```
824
+ */
825
+ declare function getComputedLayout(world: World, eid: Entity): ComputedLayoutData | undefined;
826
+ /**
827
+ * Checks if an entity has a valid computed layout.
828
+ *
829
+ * @param world - The ECS world
830
+ * @param eid - The entity ID
831
+ * @returns true if the entity has a valid computed layout
832
+ */
833
+ declare function hasComputedLayout(world: World, eid: Entity): boolean;
834
+ /**
835
+ * Invalidates the computed layout of an entity.
836
+ * Call this when position or dimensions change to trigger recalculation.
837
+ *
838
+ * @param world - The ECS world
839
+ * @param eid - The entity ID
840
+ */
841
+ declare function invalidateLayout(world: World, eid: Entity): void;
842
+ /**
843
+ * Layout system that computes absolute positions for all entities.
844
+ * Runs in tree order (parents before children) to support relative positioning.
845
+ *
846
+ * The system:
847
+ * 1. Finds all root entities (no parent)
848
+ * 2. Computes layout for each root and its descendants
849
+ * 3. Handles percentage dimensions relative to parent
850
+ * 4. Respects min/max constraints
851
+ * 5. Stores results in ComputedLayout component
852
+ *
853
+ * @param world - The ECS world
854
+ * @returns The world (unchanged)
855
+ *
856
+ * @example
857
+ * ```typescript
858
+ * import { layoutSystem, createScheduler, LoopPhase } from 'blecsd';
859
+ *
860
+ * const scheduler = createScheduler();
861
+ * scheduler.registerSystem(LoopPhase.LAYOUT, layoutSystem);
862
+ * ```
863
+ */
864
+ declare const layoutSystem: System;
865
+ /**
866
+ * Creates the layout system function.
867
+ * This is an alternative to using the layoutSystem directly for custom configuration.
868
+ *
869
+ * @returns A new layout system function
870
+ *
871
+ * @example
872
+ * ```typescript
873
+ * import { createLayoutSystem, createScheduler, LoopPhase } from 'blecsd';
874
+ *
875
+ * const scheduler = createScheduler();
876
+ * scheduler.registerSystem(LoopPhase.LAYOUT, createLayoutSystem());
877
+ * ```
878
+ */
879
+ declare function createLayoutSystem(): System;
880
+ /**
881
+ * Forces a full layout recalculation for all entities.
882
+ * Call this after major changes like screen resize.
883
+ *
884
+ * @param world - The ECS world
885
+ *
886
+ * @example
887
+ * ```typescript
888
+ * import { invalidateAllLayouts } from 'blecsd';
889
+ *
890
+ * // After terminal resize
891
+ * invalidateAllLayouts(world);
892
+ * ```
893
+ */
894
+ declare function invalidateAllLayouts(world: World): void;
895
+ /**
896
+ * Computes layout for a single entity immediately.
897
+ * Useful for getting layout outside the normal system loop.
898
+ *
899
+ * @param world - The ECS world
900
+ * @param eid - The entity ID
901
+ * @returns Computed layout data or undefined if entity lacks Position
902
+ *
903
+ * @example
904
+ * ```typescript
905
+ * import { computeLayoutNow } from 'blecsd';
906
+ *
907
+ * const layout = computeLayoutNow(world, entity);
908
+ * if (layout) {
909
+ * console.log(`Position: (${layout.x}, ${layout.y})`);
910
+ * }
911
+ * ```
912
+ */
913
+ declare function computeLayoutNow(world: World, eid: Entity): ComputedLayoutData | undefined;
914
+ /**
915
+ * Gets the computed content bounds for an entity (position + dimensions).
916
+ * Returns the bounding rectangle in screen coordinates.
917
+ *
918
+ * @param world - The ECS world
919
+ * @param eid - The entity ID
920
+ * @returns Bounding rectangle or undefined
921
+ *
922
+ * @example
923
+ * ```typescript
924
+ * import { getComputedBounds } from 'blecsd';
925
+ *
926
+ * const bounds = getComputedBounds(world, entity);
927
+ * if (bounds) {
928
+ * console.log(`Bounds: (${bounds.left}, ${bounds.top}) to (${bounds.right}, ${bounds.bottom})`);
929
+ * }
930
+ * ```
931
+ */
932
+ declare function getComputedBounds(world: World, eid: Entity): {
933
+ left: number;
934
+ top: number;
935
+ right: number;
936
+ bottom: number;
937
+ } | undefined;
938
+
939
+ /**
940
+ * Output system for writing rendered buffer to terminal.
941
+ * Runs in the POST_RENDER phase after all rendering is complete.
942
+ * @module systems/outputSystem
943
+ */
944
+
945
+ /**
946
+ * Output state maintained across frames.
947
+ */
948
+ interface OutputState {
949
+ /** Last cursor X position (0-indexed) */
950
+ lastX: number;
951
+ /** Last cursor Y position (0-indexed) */
952
+ lastY: number;
953
+ /** Last foreground color */
954
+ lastFg: number;
955
+ /** Last background color */
956
+ lastBg: number;
957
+ /** Last attributes */
958
+ lastAttrs: number;
959
+ /** Whether we're in alternate screen mode */
960
+ alternateScreen: boolean;
961
+ /** Whether mouse tracking is enabled */
962
+ mouseTracking: boolean;
963
+ /** Mouse tracking mode */
964
+ mouseMode: string | null;
965
+ /** Whether synchronized output is active */
966
+ syncOutput: boolean;
967
+ /** Whether bracketed paste mode is enabled */
968
+ bracketedPaste: boolean;
969
+ /** Whether focus reporting is enabled */
970
+ focusReporting: boolean;
971
+ }
972
+ /**
973
+ * Creates initial output state.
974
+ */
975
+ declare function createOutputState(): OutputState;
976
+ declare function generateOutput(world: World, state: OutputState, changes: readonly CellChange[], skipSort?: boolean): string;
977
+ /**
978
+ * Sets the output stream for the output system.
979
+ *
980
+ * @param stream - Writable stream (typically process.stdout)
981
+ *
982
+ * @example
983
+ * ```typescript
984
+ * import { setOutputStream } from 'blecsd';
985
+ *
986
+ * setOutputStream(process.stdout);
987
+ * ```
988
+ */
989
+ declare function setOutputStream(stream: Writable): void;
990
+ /**
991
+ * Gets the current output stream.
992
+ *
993
+ * @returns The current output stream or null
994
+ */
995
+ declare function getOutputStream(): Writable | null;
996
+ /**
997
+ * Clears the output stream reference.
998
+ */
999
+ declare function clearOutputStream(): void;
1000
+ /**
1001
+ * Sets the double buffer for the output system.
1002
+ *
1003
+ * @param db - The double buffer
1004
+ *
1005
+ * @example
1006
+ * ```typescript
1007
+ * import { setOutputBuffer, createDoubleBuffer } from 'blecsd';
1008
+ *
1009
+ * const db = createDoubleBuffer(80, 24);
1010
+ * setOutputBuffer(db);
1011
+ * ```
1012
+ */
1013
+ declare function setOutputBuffer(db: DoubleBufferData): void;
1014
+ /**
1015
+ * Gets the current output buffer.
1016
+ *
1017
+ * @returns The current double buffer or null
1018
+ */
1019
+ declare function getOutputBuffer(): DoubleBufferData | null;
1020
+ /**
1021
+ * Clears the output buffer reference.
1022
+ */
1023
+ declare function clearOutputBuffer(): void;
1024
+ /**
1025
+ * Gets or creates the output state.
1026
+ *
1027
+ * @returns The output state
1028
+ */
1029
+ declare function getOutputState(): OutputState;
1030
+ /**
1031
+ * Resets the output state.
1032
+ */
1033
+ declare function resetOutputState(): void;
1034
+ /**
1035
+ * Output system that writes rendered content to the terminal.
1036
+ *
1037
+ * The system:
1038
+ * 1. Gets minimal updates from the double buffer
1039
+ * 2. Generates optimized ANSI sequences
1040
+ * 3. Writes to the output stream
1041
+ * 4. Swaps buffers and clears dirty regions
1042
+ *
1043
+ * @param world - The ECS world
1044
+ * @returns The world (unchanged)
1045
+ *
1046
+ * @example
1047
+ * ```typescript
1048
+ * import {
1049
+ * outputSystem,
1050
+ * setOutputStream,
1051
+ * setOutputBuffer,
1052
+ * createScheduler,
1053
+ * LoopPhase,
1054
+ * } from 'blecsd';
1055
+ *
1056
+ * // Setup
1057
+ * setOutputStream(process.stdout);
1058
+ * setOutputBuffer(doubleBuffer);
1059
+ *
1060
+ * // Register in POST_RENDER phase
1061
+ * const scheduler = createScheduler();
1062
+ * scheduler.registerSystem(LoopPhase.POST_RENDER, outputSystem);
1063
+ * ```
1064
+ */
1065
+ declare const outputSystem: System;
1066
+ /**
1067
+ * Creates the output system function.
1068
+ *
1069
+ * @returns A new output system function
1070
+ *
1071
+ * @example
1072
+ * ```typescript
1073
+ * import { createOutputSystem, createScheduler, LoopPhase } from 'blecsd';
1074
+ *
1075
+ * const scheduler = createScheduler();
1076
+ * scheduler.registerSystem(LoopPhase.POST_RENDER, createOutputSystem());
1077
+ * ```
1078
+ */
1079
+ declare function createOutputSystem(): System;
1080
+ /**
1081
+ * Writes raw output to the stream.
1082
+ * Bypasses the double buffer for immediate output.
1083
+ *
1084
+ * @param data - String data to write
1085
+ *
1086
+ * @example
1087
+ * ```typescript
1088
+ * import { writeRaw } from 'blecsd';
1089
+ *
1090
+ * // Write raw ANSI sequence
1091
+ * writeRaw('\x1b[2J'); // Clear screen
1092
+ * ```
1093
+ */
1094
+ declare function writeRaw(data: string): void;
1095
+ /**
1096
+ * Hides the terminal cursor.
1097
+ *
1098
+ * @example
1099
+ * ```typescript
1100
+ * import { hideCursor } from 'blecsd';
1101
+ *
1102
+ * hideCursor();
1103
+ * ```
1104
+ */
1105
+ declare function hideCursor(): void;
1106
+ /**
1107
+ * Shows the terminal cursor.
1108
+ *
1109
+ * @example
1110
+ * ```typescript
1111
+ * import { showCursor } from 'blecsd';
1112
+ *
1113
+ * showCursor();
1114
+ * ```
1115
+ */
1116
+ declare function showCursor(): void;
1117
+ /**
1118
+ * Enters alternate screen buffer mode.
1119
+ *
1120
+ * @example
1121
+ * ```typescript
1122
+ * import { enterAlternateScreen } from 'blecsd';
1123
+ *
1124
+ * enterAlternateScreen();
1125
+ * // ... render application ...
1126
+ * leaveAlternateScreen();
1127
+ * ```
1128
+ */
1129
+ declare function enterAlternateScreen(): void;
1130
+ /**
1131
+ * Leaves alternate screen buffer mode.
1132
+ *
1133
+ * @example
1134
+ * ```typescript
1135
+ * import { leaveAlternateScreen } from 'blecsd';
1136
+ *
1137
+ * leaveAlternateScreen();
1138
+ * ```
1139
+ */
1140
+ declare function leaveAlternateScreen(): void;
1141
+ /**
1142
+ * Clears the entire screen.
1143
+ *
1144
+ * @example
1145
+ * ```typescript
1146
+ * import { clearScreen } from 'blecsd';
1147
+ *
1148
+ * clearScreen();
1149
+ * ```
1150
+ */
1151
+ declare function clearScreen(): void;
1152
+ /**
1153
+ * Moves cursor to home position (0, 0).
1154
+ *
1155
+ * @example
1156
+ * ```typescript
1157
+ * import { cursorHome } from 'blecsd';
1158
+ *
1159
+ * cursorHome();
1160
+ * ```
1161
+ */
1162
+ declare function cursorHome(): void;
1163
+ /**
1164
+ * Resets all terminal attributes.
1165
+ *
1166
+ * @example
1167
+ * ```typescript
1168
+ * import { resetAttributes } from 'blecsd';
1169
+ *
1170
+ * resetAttributes();
1171
+ * ```
1172
+ */
1173
+ declare function resetAttributes(): void;
1174
+ /**
1175
+ * Rings the terminal bell.
1176
+ *
1177
+ * @example
1178
+ * ```typescript
1179
+ * import { bell } from 'blecsd';
1180
+ *
1181
+ * bell(); // Produce audible or visual bell
1182
+ * ```
1183
+ */
1184
+ declare function bell(): void;
1185
+ /**
1186
+ * Moves cursor to a specific position.
1187
+ *
1188
+ * @param x - Column position (0-indexed)
1189
+ * @param y - Row position (0-indexed)
1190
+ *
1191
+ * @example
1192
+ * ```typescript
1193
+ * import { moveTo } from 'blecsd';
1194
+ *
1195
+ * moveTo(10, 5); // Move to column 10, row 5
1196
+ * ```
1197
+ */
1198
+ declare function moveTo(x: number, y: number): void;
1199
+ /**
1200
+ * Enables mouse tracking in the terminal.
1201
+ *
1202
+ * @param mode - Mouse tracking mode: 'normal' (clicks only), 'button' (clicks + drag), or 'any' (all motion). Default is 'any'.
1203
+ *
1204
+ * @example
1205
+ * ```typescript
1206
+ * import { enableMouseTracking } from 'blecsd';
1207
+ *
1208
+ * enableMouseTracking('any'); // Track all mouse motion
1209
+ * enableMouseTracking('button'); // Track only when button pressed
1210
+ * enableMouseTracking('normal'); // Track clicks only
1211
+ * ```
1212
+ */
1213
+ declare function enableMouseTracking(mode?: 'normal' | 'button' | 'any'): void;
1214
+ /**
1215
+ * Disables mouse tracking in the terminal.
1216
+ *
1217
+ * @example
1218
+ * ```typescript
1219
+ * import { disableMouseTracking } from 'blecsd';
1220
+ *
1221
+ * disableMouseTracking();
1222
+ * ```
1223
+ */
1224
+ declare function disableMouseTracking(): void;
1225
+ /**
1226
+ * Sets the terminal cursor shape.
1227
+ *
1228
+ * @param shape - Cursor shape: 'block', 'underline', or 'bar'
1229
+ *
1230
+ * @example
1231
+ * ```typescript
1232
+ * import { setTerminalCursorShape } from 'blecsd';
1233
+ *
1234
+ * setTerminalCursorShape('block'); // Block cursor
1235
+ * setTerminalCursorShape('underline'); // Underline cursor
1236
+ * setTerminalCursorShape('bar'); // Bar/vertical line cursor
1237
+ * ```
1238
+ */
1239
+ declare function setTerminalCursorShape(shape: 'block' | 'underline' | 'bar'): void;
1240
+ /**
1241
+ * Sets the terminal window title.
1242
+ *
1243
+ * @param title - Window title string
1244
+ *
1245
+ * @example
1246
+ * ```typescript
1247
+ * import { setWindowTitle } from 'blecsd';
1248
+ *
1249
+ * setWindowTitle('My Terminal App');
1250
+ * ```
1251
+ */
1252
+ declare function setWindowTitle(title: string): void;
1253
+ /**
1254
+ * Begins synchronized output mode.
1255
+ * Prevents partial screen updates from being displayed.
1256
+ *
1257
+ * @example
1258
+ * ```typescript
1259
+ * import { beginSyncOutput, endSyncOutput } from 'blecsd';
1260
+ *
1261
+ * beginSyncOutput();
1262
+ * // ... render multiple updates ...
1263
+ * endSyncOutput(); // All updates appear atomically
1264
+ * ```
1265
+ */
1266
+ declare function beginSyncOutput(): void;
1267
+ /**
1268
+ * Ends synchronized output mode.
1269
+ *
1270
+ * @example
1271
+ * ```typescript
1272
+ * import { endSyncOutput } from 'blecsd';
1273
+ *
1274
+ * endSyncOutput();
1275
+ * ```
1276
+ */
1277
+ declare function endSyncOutput(): void;
1278
+ /**
1279
+ * Saves the current cursor position.
1280
+ *
1281
+ * @example
1282
+ * ```typescript
1283
+ * import { saveCursorPosition, restoreCursorPosition } from 'blecsd';
1284
+ *
1285
+ * saveCursorPosition();
1286
+ * // ... move cursor and draw ...
1287
+ * restoreCursorPosition(); // Return to saved position
1288
+ * ```
1289
+ */
1290
+ declare function saveCursorPosition(): void;
1291
+ /**
1292
+ * Restores the previously saved cursor position.
1293
+ *
1294
+ * @example
1295
+ * ```typescript
1296
+ * import { restoreCursorPosition } from 'blecsd';
1297
+ *
1298
+ * restoreCursorPosition();
1299
+ * ```
1300
+ */
1301
+ declare function restoreCursorPosition(): void;
1302
+ /**
1303
+ * Enables bracketed paste mode in the terminal.
1304
+ * When enabled, pasted text is bracketed with special sequences.
1305
+ *
1306
+ * @example
1307
+ * ```typescript
1308
+ * import { enableBracketedPasteMode } from 'blecsd';
1309
+ *
1310
+ * enableBracketedPasteMode();
1311
+ * ```
1312
+ */
1313
+ declare function enableBracketedPasteMode(): void;
1314
+ /**
1315
+ * Disables bracketed paste mode in the terminal.
1316
+ *
1317
+ * @example
1318
+ * ```typescript
1319
+ * import { disableBracketedPasteMode } from 'blecsd';
1320
+ *
1321
+ * disableBracketedPasteMode();
1322
+ * ```
1323
+ */
1324
+ declare function disableBracketedPasteMode(): void;
1325
+ /**
1326
+ * Enables focus reporting in the terminal.
1327
+ * When enabled, the terminal sends focus in/out events.
1328
+ *
1329
+ * @example
1330
+ * ```typescript
1331
+ * import { enableFocusReporting } from 'blecsd';
1332
+ *
1333
+ * enableFocusReporting();
1334
+ * ```
1335
+ */
1336
+ declare function enableFocusReporting(): void;
1337
+ /**
1338
+ * Disables focus reporting in the terminal.
1339
+ *
1340
+ * @example
1341
+ * ```typescript
1342
+ * import { disableFocusReporting } from 'blecsd';
1343
+ *
1344
+ * disableFocusReporting();
1345
+ * ```
1346
+ */
1347
+ declare function disableFocusReporting(): void;
1348
+ /**
1349
+ * Flushes output and resets terminal state.
1350
+ * Call this before exiting the application.
1351
+ *
1352
+ * @example
1353
+ * ```typescript
1354
+ * import { cleanup } from 'blecsd';
1355
+ *
1356
+ * // Before exiting
1357
+ * cleanup();
1358
+ * ```
1359
+ */
1360
+ declare function cleanup(): void;
1361
+
1362
+ /**
1363
+ * Render system for drawing entities to the screen buffer.
1364
+ * Runs in the RENDER phase after layout computation.
1365
+ * @module systems/renderSystem
1366
+ */
1367
+
1368
+ /**
1369
+ * Render context passed to render functions.
1370
+ */
1371
+ interface RenderContext {
1372
+ /** The ECS world */
1373
+ readonly world: World;
1374
+ /** The screen buffer to render to */
1375
+ readonly buffer: ScreenBufferData;
1376
+ /** The dirty tracker for optimized rendering */
1377
+ readonly dirtyTracker: DirtyTracker;
1378
+ }
1379
+ /**
1380
+ * Computed bounds for an entity.
1381
+ */
1382
+ interface EntityBounds {
1383
+ readonly x: number;
1384
+ readonly y: number;
1385
+ readonly width: number;
1386
+ readonly height: number;
1387
+ }
1388
+ /**
1389
+ * Renders the background fill for an entity.
1390
+ *
1391
+ * @param ctx - Render context
1392
+ * @param eid - Entity ID
1393
+ * @param bounds - Entity bounds
1394
+ *
1395
+ * @example
1396
+ * ```typescript
1397
+ * import { renderBackground } from 'blecsd';
1398
+ *
1399
+ * renderBackground(ctx, entity, bounds);
1400
+ * ```
1401
+ */
1402
+ declare function renderBackground(ctx: RenderContext, eid: Entity, bounds: EntityBounds): void;
1403
+ /**
1404
+ * Renders the border for an entity.
1405
+ *
1406
+ * @param ctx - Render context
1407
+ * @param eid - Entity ID
1408
+ * @param bounds - Entity bounds
1409
+ *
1410
+ * @example
1411
+ * ```typescript
1412
+ * import { renderBorder } from 'blecsd';
1413
+ *
1414
+ * renderBorder(ctx, entity, bounds);
1415
+ * ```
1416
+ */
1417
+ declare function renderBorder(ctx: RenderContext, eid: Entity, bounds: EntityBounds): void;
1418
+ /**
1419
+ * Renders the content area of an entity.
1420
+ * This is a placeholder that can be extended for specific content types.
1421
+ *
1422
+ * @param ctx - Render context
1423
+ * @param eid - Entity ID
1424
+ * @param contentBounds - Content area bounds (inside border)
1425
+ *
1426
+ * @example
1427
+ * ```typescript
1428
+ * import { renderContent } from 'blecsd';
1429
+ *
1430
+ * renderContent(ctx, entity, contentBounds);
1431
+ * ```
1432
+ */
1433
+ declare function renderContent(_ctx: RenderContext, _eid: Entity, _contentBounds: EntityBounds): void;
1434
+ /**
1435
+ * Renders a scrollbar for an entity.
1436
+ * Currently a placeholder for future scrollable content support.
1437
+ *
1438
+ * @param ctx - Render context
1439
+ * @param eid - Entity ID
1440
+ * @param bounds - Entity bounds
1441
+ *
1442
+ * @example
1443
+ * ```typescript
1444
+ * import { renderScrollbar } from 'blecsd';
1445
+ *
1446
+ * renderScrollbar(ctx, entity, bounds);
1447
+ * ```
1448
+ */
1449
+ declare function renderScrollbar(_ctx: RenderContext, _eid: Entity, _bounds: EntityBounds): void;
1450
+ /**
1451
+ * Recursively renders an entity and its children in tree order.
1452
+ * @internal Currently unused, reserved for future tree-based rendering mode.
1453
+ *
1454
+ * @param ctx - Render context
1455
+ * @param eid - Entity ID
1456
+ */
1457
+ /**
1458
+ * Viewport bounds for culling off-screen entities.
1459
+ * Defaults to null (no culling). Set via setViewportBounds().
1460
+ */
1461
+ interface ViewportBounds {
1462
+ readonly x: number;
1463
+ readonly y: number;
1464
+ readonly width: number;
1465
+ readonly height: number;
1466
+ }
1467
+ /**
1468
+ * Sets the viewport bounds for culling.
1469
+ * Entities outside these bounds will be skipped during rendering.
1470
+ *
1471
+ * Pass null to disable viewport culling (default).
1472
+ * Typically set to screen dimensions for scrollable content optimization.
1473
+ *
1474
+ * @param bounds - Viewport bounds or null to disable culling
1475
+ *
1476
+ * @example
1477
+ * ```typescript
1478
+ * import { setViewportBounds } from 'blecsd';
1479
+ *
1480
+ * // Enable viewport culling for 80x24 screen
1481
+ * setViewportBounds({ x: 0, y: 0, width: 80, height: 24 });
1482
+ *
1483
+ * // Disable viewport culling
1484
+ * setViewportBounds(null);
1485
+ * ```
1486
+ */
1487
+ declare function setViewportBounds(bounds: ViewportBounds | null): void;
1488
+ /**
1489
+ * Gets the current viewport bounds.
1490
+ *
1491
+ * @returns Current viewport bounds or null if disabled
1492
+ */
1493
+ declare function getViewportBounds(): ViewportBounds | null;
1494
+ /**
1495
+ * Sets the dirty tracker and screen buffer for the render system.
1496
+ * Must be called before running the render system.
1497
+ *
1498
+ * @param tracker - The dirty tracker for optimized rendering
1499
+ * @param buffer - The screen buffer to render to
1500
+ *
1501
+ * @example
1502
+ * ```typescript
1503
+ * import { setRenderBuffer, createDirtyTracker } from 'blecsd';
1504
+ * import { createScreenBuffer } from 'blecsd';
1505
+ *
1506
+ * const tracker = createDirtyTracker(80, 24);
1507
+ * const buffer = createScreenBuffer(80, 24);
1508
+ * setRenderBuffer(tracker, buffer);
1509
+ * ```
1510
+ */
1511
+ declare function setRenderBuffer(tracker: DirtyTracker, buffer: ScreenBufferData): void;
1512
+ /**
1513
+ * Gets the current dirty tracker.
1514
+ *
1515
+ * @returns The current dirty tracker or null
1516
+ */
1517
+ declare function getRenderBuffer(): DirtyTracker | null;
1518
+ /**
1519
+ * Clears the render buffer references.
1520
+ */
1521
+ declare function clearRenderBuffer(): void;
1522
+ /**
1523
+ * Enables or disables z-order occlusion culling.
1524
+ * When enabled, entities fully hidden behind higher z-index entities are skipped during rendering.
1525
+ *
1526
+ * Disabled by default. Enable for applications with many overlapping widgets (modals, dialogs, overlays)
1527
+ * where the performance benefit outweighs the culling overhead.
1528
+ *
1529
+ * @param enabled - Whether to enable occlusion culling (default: false)
1530
+ *
1531
+ * @example
1532
+ * ```typescript
1533
+ * import { setOcclusionCulling } from 'blecsd';
1534
+ *
1535
+ * // Enable occlusion culling for layered UI
1536
+ * setOcclusionCulling(true);
1537
+ * ```
1538
+ */
1539
+ declare function setOcclusionCulling(enabled: boolean): void;
1540
+ /**
1541
+ * Gets the current occlusion culling state.
1542
+ *
1543
+ * @returns True if occlusion culling is enabled
1544
+ */
1545
+ declare function isOcclusionCullingEnabled(): boolean;
1546
+ /**
1547
+ * Render system that draws visible, dirty entities to the screen buffer.
1548
+ * Entities are rendered in z-index order (lower z first, higher z on top).
1549
+ *
1550
+ * The system:
1551
+ * 1. Queries all entities with Position and Renderable
1552
+ * 2. Filters to visible, dirty entities
1553
+ * 3. Sorts by z-index
1554
+ * 4. Applies viewport bounds culling (skips off-screen entities)
1555
+ * 5. Applies z-order occlusion culling (skips fully hidden entities)
1556
+ * 6. Renders each visible entity (background, border, content)
1557
+ * 7. Marks entities as clean
1558
+ *
1559
+ * Viewport culling: entities completely outside the viewport bounds are skipped
1560
+ * to improve performance in scrollable content with many off-screen entities.
1561
+ * Enable via `setViewportBounds({ x, y, width, height })`.
1562
+ *
1563
+ * Occlusion culling: entities fully covered by higher z-index entities are
1564
+ * skipped to improve performance in layered UIs (modals, dialogs, overlays).
1565
+ * Enable via `setOcclusionCulling(true)`.
1566
+ *
1567
+ * @param world - The ECS world
1568
+ * @returns The world (unchanged)
1569
+ *
1570
+ * @example
1571
+ * ```typescript
1572
+ * import { renderSystem, setRenderBuffer, setViewportBounds, createScheduler, LoopPhase } from 'blecsd';
1573
+ *
1574
+ * const scheduler = createScheduler();
1575
+ * scheduler.registerSystem(LoopPhase.RENDER, renderSystem);
1576
+ *
1577
+ * // Set render buffer and enable viewport culling
1578
+ * setRenderBuffer(dirtyTracker, screenBuffer);
1579
+ * setViewportBounds({ x: 0, y: 0, width: 80, height: 24 });
1580
+ *
1581
+ * scheduler.run(world, deltaTime);
1582
+ * ```
1583
+ */
1584
+ declare const renderSystem: System;
1585
+ /**
1586
+ * Creates the render system function.
1587
+ * This is an alternative to using the renderSystem directly for custom configuration.
1588
+ *
1589
+ * @returns A new render system function
1590
+ *
1591
+ * @example
1592
+ * ```typescript
1593
+ * import { createRenderSystem, createScheduler, LoopPhase } from 'blecsd';
1594
+ *
1595
+ * const scheduler = createScheduler();
1596
+ * scheduler.registerSystem(LoopPhase.RENDER, createRenderSystem());
1597
+ * ```
1598
+ */
1599
+ declare function createRenderSystem(): System;
1600
+ /**
1601
+ * Renders text to a buffer at the specified position.
1602
+ * Utility function for widgets to render text content.
1603
+ *
1604
+ * @param buffer - Screen buffer
1605
+ * @param x - X position
1606
+ * @param y - Y position
1607
+ * @param text - Text to render
1608
+ * @param fg - Foreground color
1609
+ * @param bg - Background color
1610
+ * @param attrs - Text attributes
1611
+ * @returns Number of characters written
1612
+ *
1613
+ * @example
1614
+ * ```typescript
1615
+ * import { renderText, Attr } from 'blecsd';
1616
+ *
1617
+ * renderText(buffer, 10, 5, 'Hello', 0xffffffff, 0x000000ff, Attr.BOLD);
1618
+ * ```
1619
+ */
1620
+ declare function renderText(buffer: ScreenBufferData, x: number, y: number, text: string, fg: number, bg: number, attrs?: number): number;
1621
+ /**
1622
+ * Renders a filled rectangle to a buffer.
1623
+ * Utility function for widgets.
1624
+ *
1625
+ * @param buffer - Screen buffer
1626
+ * @param x - X position
1627
+ * @param y - Y position
1628
+ * @param width - Rectangle width
1629
+ * @param height - Rectangle height
1630
+ * @param cell - Cell to fill with
1631
+ *
1632
+ * @example
1633
+ * ```typescript
1634
+ * import { renderRect, createCell } from 'blecsd';
1635
+ *
1636
+ * renderRect(buffer, 10, 5, 20, 10, createCell(' ', 0xffffffff, 0x0000ffff));
1637
+ * ```
1638
+ */
1639
+ declare function renderRect(buffer: ScreenBufferData, x: number, y: number, width: number, height: number, cell: Cell): void;
1640
+ /**
1641
+ * Marks all entities as dirty, forcing a full re-render.
1642
+ *
1643
+ * @param world - The ECS world
1644
+ *
1645
+ * @example
1646
+ * ```typescript
1647
+ * import { markAllDirty } from 'blecsd';
1648
+ *
1649
+ * // Force re-render of all entities
1650
+ * markAllDirty(world);
1651
+ * ```
1652
+ */
1653
+ declare function markAllDirty(world: World): void;
1654
+
1655
+ /**
1656
+ * Fast panel movement and resizing system.
1657
+ *
1658
+ * Provides instant panel position updates on input with deferred
1659
+ * content re-layout. Uses dirty rect optimization and optional
1660
+ * content simplification during drag for 60fps movement.
1661
+ *
1662
+ * @module systems/panelMovement
1663
+ */
1664
+
1665
+ /**
1666
+ * Resize handle positions.
1667
+ */
1668
+ type ResizeHandle = 'top' | 'bottom' | 'left' | 'right' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight';
1669
+ /**
1670
+ * Panel movement constraints.
1671
+ */
1672
+ interface PanelConstraints {
1673
+ /** Minimum panel width (default: 4) */
1674
+ readonly minWidth: number;
1675
+ /** Minimum panel height (default: 2) */
1676
+ readonly minHeight: number;
1677
+ /** Maximum panel width (0 = no limit) */
1678
+ readonly maxWidth: number;
1679
+ /** Maximum panel height (0 = no limit) */
1680
+ readonly maxHeight: number;
1681
+ /** Constrain movement to screen bounds */
1682
+ readonly constrainToScreen: boolean;
1683
+ /** Screen width for constraining */
1684
+ readonly screenWidth: number;
1685
+ /** Screen height for constraining */
1686
+ readonly screenHeight: number;
1687
+ /** Snap to grid size (0 = no snap) */
1688
+ readonly snapGrid: number;
1689
+ }
1690
+ /**
1691
+ * Panel movement/resize state.
1692
+ */
1693
+ interface PanelMoveState {
1694
+ /** Currently moving entity */
1695
+ readonly entity: Entity | undefined;
1696
+ /** Whether a move is in progress */
1697
+ readonly isMoving: boolean;
1698
+ /** Whether a resize is in progress */
1699
+ readonly isResizing: boolean;
1700
+ /** Active resize handle */
1701
+ readonly resizeHandle: ResizeHandle | undefined;
1702
+ /** Starting mouse/cursor position */
1703
+ readonly startX: number;
1704
+ readonly startY: number;
1705
+ /** Starting panel position */
1706
+ readonly panelStartX: number;
1707
+ readonly panelStartY: number;
1708
+ /** Starting panel dimensions */
1709
+ readonly panelStartWidth: number;
1710
+ readonly panelStartHeight: number;
1711
+ /** Whether content layout is deferred (simplified rendering during move) */
1712
+ readonly layoutDeferred: boolean;
1713
+ }
1714
+ /**
1715
+ * Configuration for panel movement behavior.
1716
+ */
1717
+ interface PanelMoveConfig {
1718
+ /** Defer content layout during move for performance (default: true) */
1719
+ readonly deferLayout: boolean;
1720
+ /** Show resize outline instead of live resize (default: false) */
1721
+ readonly outlineResize: boolean;
1722
+ /** Number of pixels to move with keyboard (default: 1) */
1723
+ readonly keyboardStep: number;
1724
+ /** Number of pixels to resize with keyboard (default: 1) */
1725
+ readonly keyboardResizeStep: number;
1726
+ }
1727
+ /**
1728
+ * Dirty rectangle representing changed area.
1729
+ */
1730
+ interface DirtyRect {
1731
+ readonly x: number;
1732
+ readonly y: number;
1733
+ readonly width: number;
1734
+ readonly height: number;
1735
+ }
1736
+ /**
1737
+ * Result of a panel move or resize operation.
1738
+ */
1739
+ interface MoveResult {
1740
+ /** New position X */
1741
+ readonly x: number;
1742
+ /** New position Y */
1743
+ readonly y: number;
1744
+ /** New width (for resize) */
1745
+ readonly width: number;
1746
+ /** New height (for resize) */
1747
+ readonly height: number;
1748
+ /** Dirty rectangles that need redrawing */
1749
+ readonly dirtyRects: readonly DirtyRect[];
1750
+ /** Whether the operation was clamped by constraints */
1751
+ readonly clamped: boolean;
1752
+ }
1753
+ /**
1754
+ * Creates initial panel move state.
1755
+ *
1756
+ * @returns Fresh move state
1757
+ *
1758
+ * @example
1759
+ * ```typescript
1760
+ * import { createPanelMoveState } from 'blecsd';
1761
+ *
1762
+ * const moveState = createPanelMoveState();
1763
+ * ```
1764
+ */
1765
+ declare function createPanelMoveState(): PanelMoveState;
1766
+ /**
1767
+ * Creates panel move configuration with defaults.
1768
+ *
1769
+ * @param config - Partial overrides
1770
+ * @returns Full configuration
1771
+ */
1772
+ declare function createPanelMoveConfig(config?: Partial<PanelMoveConfig>): PanelMoveConfig;
1773
+ /**
1774
+ * Creates panel constraints with defaults.
1775
+ *
1776
+ * @param constraints - Partial overrides
1777
+ * @returns Full constraints
1778
+ */
1779
+ declare function createPanelConstraints(constraints?: Partial<PanelConstraints>): PanelConstraints;
1780
+ /**
1781
+ * Begins a panel move operation.
1782
+ *
1783
+ * @param state - Current move state
1784
+ * @param entity - Entity to move
1785
+ * @param mouseX - Starting mouse X
1786
+ * @param mouseY - Starting mouse Y
1787
+ * @param panelX - Current panel X position
1788
+ * @param panelY - Current panel Y position
1789
+ * @param panelWidth - Current panel width
1790
+ * @param panelHeight - Current panel height
1791
+ * @param config - Move configuration
1792
+ * @returns Updated state
1793
+ *
1794
+ * @example
1795
+ * ```typescript
1796
+ * import { createPanelMoveState, beginMove } from 'blecsd';
1797
+ *
1798
+ * let state = createPanelMoveState();
1799
+ * state = beginMove(state, eid, mouseX, mouseY, panelX, panelY, 30, 10);
1800
+ * ```
1801
+ */
1802
+ declare function beginMove(state: PanelMoveState, entity: Entity, mouseX: number, mouseY: number, panelX: number, panelY: number, panelWidth: number, panelHeight: number, config?: Partial<PanelMoveConfig>): PanelMoveState;
1803
+ /**
1804
+ * Begins a panel resize operation.
1805
+ *
1806
+ * @param state - Current move state
1807
+ * @param entity - Entity to resize
1808
+ * @param handle - Resize handle being dragged
1809
+ * @param mouseX - Starting mouse X
1810
+ * @param mouseY - Starting mouse Y
1811
+ * @param panelX - Current panel X
1812
+ * @param panelY - Current panel Y
1813
+ * @param panelWidth - Current panel width
1814
+ * @param panelHeight - Current panel height
1815
+ * @param config - Move configuration
1816
+ * @returns Updated state
1817
+ */
1818
+ declare function beginResize(state: PanelMoveState, entity: Entity, handle: ResizeHandle, mouseX: number, mouseY: number, panelX: number, panelY: number, panelWidth: number, panelHeight: number, config?: Partial<PanelMoveConfig>): PanelMoveState;
1819
+ /**
1820
+ * Updates a panel move with new cursor position.
1821
+ * Returns the new panel position with constraints applied.
1822
+ *
1823
+ * @param state - Current move state
1824
+ * @param mouseX - Current mouse X
1825
+ * @param mouseY - Current mouse Y
1826
+ * @param constraints - Panel constraints
1827
+ * @returns Move result with new position and dirty rects
1828
+ *
1829
+ * @example
1830
+ * ```typescript
1831
+ * import { updateMove, createPanelConstraints } from 'blecsd';
1832
+ *
1833
+ * const result = updateMove(state, mouseX, mouseY, createPanelConstraints());
1834
+ * setPosition(world, eid, result.x, result.y);
1835
+ * ```
1836
+ */
1837
+ declare function updateMove(state: PanelMoveState, mouseX: number, mouseY: number, constraints?: Partial<PanelConstraints>): MoveResult;
1838
+ declare function updateResize(state: PanelMoveState, mouseX: number, mouseY: number, constraints?: Partial<PanelConstraints>): MoveResult;
1839
+ /**
1840
+ * Ends the current move or resize operation.
1841
+ *
1842
+ * @param state - Current move state
1843
+ * @returns Reset state
1844
+ */
1845
+ declare function endMoveOrResize(state: PanelMoveState): PanelMoveState;
1846
+ /**
1847
+ * Cancels the current move or resize, returning to original position.
1848
+ *
1849
+ * @param state - Current move state
1850
+ * @returns Object with original position and reset state
1851
+ */
1852
+ declare function cancelMoveOrResize(state: PanelMoveState): {
1853
+ state: PanelMoveState;
1854
+ restoreX: number;
1855
+ restoreY: number;
1856
+ restoreWidth: number;
1857
+ restoreHeight: number;
1858
+ };
1859
+ /**
1860
+ * Moves a panel by keyboard step amount.
1861
+ *
1862
+ * @param x - Current X position
1863
+ * @param y - Current Y position
1864
+ * @param width - Panel width
1865
+ * @param height - Panel height
1866
+ * @param direction - Movement direction
1867
+ * @param step - Step amount
1868
+ * @param constraints - Panel constraints
1869
+ * @returns New position
1870
+ */
1871
+ declare function keyboardMove(x: number, y: number, width: number, height: number, direction: 'up' | 'down' | 'left' | 'right', step: number, constraints?: Partial<PanelConstraints>): {
1872
+ x: number;
1873
+ y: number;
1874
+ };
1875
+ /**
1876
+ * Resizes a panel by keyboard step amount.
1877
+ *
1878
+ * @param width - Current width
1879
+ * @param height - Current height
1880
+ * @param direction - Resize direction
1881
+ * @param step - Step amount
1882
+ * @param constraints - Panel constraints
1883
+ * @returns New dimensions
1884
+ */
1885
+ declare function keyboardResize(width: number, height: number, direction: 'grow-horizontal' | 'shrink-horizontal' | 'grow-vertical' | 'shrink-vertical', step: number, constraints?: Partial<PanelConstraints>): {
1886
+ width: number;
1887
+ height: number;
1888
+ };
1889
+ /**
1890
+ * Detects which resize handle a click position corresponds to.
1891
+ *
1892
+ * @param clickX - Click X relative to panel
1893
+ * @param clickY - Click Y relative to panel
1894
+ * @param panelWidth - Panel width
1895
+ * @param panelHeight - Panel height
1896
+ * @param borderSize - Size of the resize border area (default: 1)
1897
+ * @returns The resize handle, or undefined if not on a border
1898
+ */
1899
+ declare function detectResizeHandle(clickX: number, clickY: number, panelWidth: number, panelHeight: number, borderSize?: number): ResizeHandle | undefined;
1900
+ /**
1901
+ * Merges overlapping dirty rectangles for efficient redraw.
1902
+ *
1903
+ * @param rects - Array of dirty rectangles
1904
+ * @returns Merged bounding rectangle
1905
+ */
1906
+ declare function mergeDirtyRects(rects: readonly DirtyRect[]): DirtyRect | undefined;
1907
+
1908
+ export { computeLayoutNow as $, focusPop as A, peekFocusStack as B, getFocusStackDepth as C, type DirtyRect as D, clearFocusStack as E, saveFocus as F, restoreFocus as G, rewindFocus as H, createInputSystem as I, registerInputSystem as J, type InputSystemState as K, queryInputReceivers as L, hitTest as M, pointInEntity as N, getInteractiveEntityAt as O, queueKeyEvent as P, queueMouseEvent as Q, getEventQueue as R, clearEventQueue as S, clearEntityInput as T, getInputEventBus as U, resetInputState as V, captureMouseTo as W, releaseMouse as X, isMouseCaptured as Y, getMouseCaptureEntity as Z, createLayoutSystem as _, animationSystem as a, isOcclusionCullingEnabled as a$, getComputedLayout as a0, getComputedBounds as a1, hasComputedLayout as a2, invalidateLayout as a3, invalidateAllLayouts as a4, createOutputSystem as a5, createOutputState as a6, clearOutputBuffer as a7, clearOutputStream as a8, generateOutput as a9, endSyncOutput as aA, createPanelMoveState as aB, createPanelMoveConfig as aC, createPanelConstraints as aD, beginMove as aE, beginResize as aF, updateMove as aG, updateResize as aH, endMoveOrResize as aI, cancelMoveOrResize as aJ, detectResizeHandle as aK, mergeDirtyRects as aL, keyboardMove as aM, keyboardResize as aN, createRenderSystem as aO, getRenderBuffer as aP, setRenderBuffer as aQ, clearRenderBuffer as aR, markAllDirty as aS, renderContent as aT, renderBackground as aU, renderBorder as aV, renderScrollbar as aW, renderText as aX, renderRect as aY, getViewportBounds as aZ, setViewportBounds as a_, getOutputBuffer as aa, setOutputBuffer as ab, getOutputStream as ac, setOutputStream as ad, getOutputState as ae, resetOutputState as af, writeRaw as ag, hideCursor as ah, showCursor as ai, cursorHome as aj, moveTo as ak, saveCursorPosition as al, restoreCursorPosition as am, setTerminalCursorShape as an, enterAlternateScreen as ao, leaveAlternateScreen as ap, setWindowTitle as aq, resetAttributes as ar, bell as as, enableMouseTracking as at, disableMouseTracking as au, enableBracketedPasteMode as av, disableBracketedPasteMode as aw, enableFocusReporting as ax, disableFocusReporting as ay, beginSyncOutput as az, clearScreen as b, setOcclusionCulling as b0, ComputedLayout as b1, type ComputedLayoutData as b2, type FocusEventData as b3, type FocusEventMap as b4, type FocusEventType as b5, type HitTestResult as b6, type InputEventType as b7, type MoveResult as b8, type OutputState as b9, type PanelConstraints as ba, type PanelMoveConfig as bb, type PanelMoveState as bc, type QueuedInputEvent as bd, type QueuedKeyEvent as be, type QueuedMouseEvent as bf, type RenderContext as bg, type ResizeHandle as bh, inputState as bi, cleanup as c, createAnimationSystem as d, registerAnimationSystem as e, focusSystem as f, createFocusSystem as g, hasAnimationSystem as h, inputSystem as i, focusEntity as j, focusNext as k, layoutSystem as l, focusPrev as m, focusFirst as n, outputSystem as o, focusLast as p, queryAnimation as q, renderSystem as r, focusOffset as s, blurAll as t, updateAnimations as u, getFocused as v, getFocusableEntities as w, getFocusEventBus as x, resetFocusEventBus as y, focusPush as z };