blecsd 0.1.1 → 0.3.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.
- package/LICENSE +4 -2
- package/README.md +209 -66
- package/dist/3d/index.d.ts +2 -2
- package/dist/3d/index.js +1 -1
- package/dist/audio/index.d.ts +2 -2
- package/dist/{border-D_Jb4ZJV.d.ts → border-Jb7TrMob.d.ts} +20 -10
- package/dist/chunk-2IEMMRUO.js +1 -0
- package/dist/chunk-3AV52GY5.js +1 -0
- package/dist/chunk-3LHLSY3Y.js +1 -0
- package/dist/chunk-3O4TQHGK.js +4 -0
- package/dist/chunk-3UJWZ5ZN.js +1 -0
- package/dist/chunk-5N3O25O7.js +1 -0
- package/dist/chunk-6M2J5QUA.js +1 -0
- package/dist/chunk-7IQEUVGF.js +1 -0
- package/dist/chunk-A6M6TFBL.js +1 -0
- package/dist/chunk-CUEUJAHK.js +3 -0
- package/dist/chunk-D42Q2KKR.js +1 -0
- package/dist/chunk-DYEXOFUU.js +2 -0
- package/dist/chunk-DYU72XLL.js +1 -0
- package/dist/chunk-E4CJRSND.js +1 -0
- package/dist/chunk-EAY7B5GL.js +1 -0
- package/dist/chunk-FCMTWFSE.js +1 -0
- package/dist/chunk-FL56THSI.js +25 -0
- package/dist/{chunk-2UBBZFE4.js → chunk-G437VE43.js} +1 -1
- package/dist/chunk-GGXNWT36.js +8 -0
- package/dist/chunk-HLFORKXS.js +1 -0
- package/dist/chunk-J7MBKEBY.js +1 -0
- package/dist/{chunk-TYMY2TBR.js → chunk-JHCKPCUH.js} +3 -3
- package/dist/chunk-K3SX2LY5.js +1 -0
- package/dist/chunk-LDAFEXN5.js +1 -0
- package/dist/chunk-MKMFUXLB.js +33 -0
- package/dist/chunk-MQWPHPUM.js +1 -0
- package/dist/chunk-MTI376CU.js +5 -0
- package/dist/chunk-MTV2RJZD.js +1 -0
- package/dist/chunk-NPDPBAW6.js +4 -0
- package/dist/chunk-OB66FB4F.js +1 -0
- package/dist/chunk-OR3BZY7C.js +1 -0
- package/dist/{chunk-VNZ6CWJA.js → chunk-R7AICVRN.js} +2 -2
- package/dist/{chunk-3B7MIVW6.js → chunk-RZ7FGVI6.js} +1 -1
- package/dist/chunk-UMGTXSQB.js +11 -0
- package/dist/chunk-X3Q3T2SS.js +4 -0
- package/dist/{chunk-JKVHO4LH.js → chunk-XZJRWFOS.js} +1 -1
- package/dist/chunk-ZAHG7Y3X.js +1 -0
- package/dist/cli/init.d.ts +1 -1
- package/dist/componentStorage-CJTh-TPO.d.ts +246 -0
- package/dist/components/index.d.ts +1942 -514
- package/dist/components/index.js +1 -1
- package/dist/core/index.d.ts +857 -259
- package/dist/core/index.js +1 -1
- package/dist/debug/index.d.ts +491 -98
- package/dist/debug/index.js +1 -1
- package/dist/dirtyTracking-C4v8MmM9.d.ts +235 -0
- package/dist/errors/index.d.ts +12 -12
- package/dist/errors/index.js +1 -1
- package/dist/{events-BbbxkgvX.d.ts → events-9ForpTfM.d.ts} +75 -2
- package/dist/game/index.d.ts +7 -7
- package/dist/game/index.js +1 -1
- package/dist/{gameLoop-BIPW7-OY.d.ts → gameLoop-C-Ez_i54.d.ts} +2 -2
- package/dist/{index-zSGJ2eUk.d.ts → index-DBS5Uefn.d.ts} +2 -2
- package/dist/index.d.ts +283 -20
- package/dist/index.js +3 -1
- package/dist/input/index.d.ts +1 -1
- package/dist/input/index.js +1 -1
- package/dist/{inputActions-CefRUBuT.d.ts → inputActions-CRsUtTHM.d.ts} +10 -721
- package/dist/packedStore-BgvnEdE7.d.ts +191 -0
- package/dist/{renderable-jTMOA-GK.d.ts → renderable-CwqGwrEV.d.ts} +9 -9
- package/dist/{scheduler-DcfoFuum.d.ts → scheduler-CMcYew9Z.d.ts} +65 -3
- package/dist/systems/index.d.ts +356 -55
- package/dist/systems/index.js +1 -1
- package/dist/terminal/index.d.ts +2233 -2299
- package/dist/terminal/index.js +1 -1
- package/dist/{tilemap-D1HJvKy3.d.ts → tilemap-BirMJdbu.d.ts} +92 -3
- package/dist/{types-BcsvoKzf.d.ts → types-CPB4CpbH.d.ts} +2 -2
- package/dist/utils/index.d.ts +27 -180
- package/dist/utils/index.js +1 -1
- package/dist/{virtualScrollback-DvZTRU8a.d.ts → virtualScrollback-D9uLFe8l.d.ts} +4 -4
- package/dist/{virtualViewport-Dx2iJliO.d.ts → virtualViewport-Bpv6jlKt.d.ts} +283 -761
- package/dist/widgets/bigText.d.ts +1 -1
- package/dist/widgets/bigText.js +1 -1
- package/dist/widgets/index.d.ts +10519 -5463
- package/dist/widgets/index.js +1 -1
- package/package.json +102 -6
- package/dist/chunk-35I22JJO.js +0 -1
- package/dist/chunk-3EGGGI5J.js +0 -3
- package/dist/chunk-4X4N4HNQ.js +0 -2
- package/dist/chunk-AQ7LW75B.js +0 -1
- package/dist/chunk-AXZQAH4X.js +0 -1
- package/dist/chunk-BCADUCOZ.js +0 -1
- package/dist/chunk-EJ5WVDDZ.js +0 -6
- package/dist/chunk-FT7BMYSN.js +0 -1
- package/dist/chunk-FYEBZAWN.js +0 -1
- package/dist/chunk-GYHI26UE.js +0 -1
- package/dist/chunk-H2YAOJDW.js +0 -1
- package/dist/chunk-K2B2OXQ5.js +0 -5
- package/dist/chunk-K37L3G4Z.js +0 -4
- package/dist/chunk-KD55INV7.js +0 -1
- package/dist/chunk-KFAK4A3G.js +0 -1
- package/dist/chunk-LCN2ZITE.js +0 -1
- package/dist/chunk-OUXUPF3V.js +0 -33
- package/dist/chunk-P6CJO3BC.js +0 -1
- package/dist/chunk-PI5UOHOH.js +0 -1
- package/dist/chunk-PSXXMBVJ.js +0 -1
- package/dist/chunk-TRK4422V.js +0 -12
- package/dist/chunk-W5OU7Z6J.js +0 -1
- package/dist/chunk-WNG4A3K7.js +0 -4
- package/dist/chunk-XRJNAHNG.js +0 -19
- package/dist/chunk-XZA63ZPO.js +0 -1
- package/dist/chunk-YAMOSPWB.js +0 -4
- package/dist/chunk-YD6ULIUR.js +0 -1
- package/dist/{keyParser-Bwm8-l7v.d.ts → keyParser-BnHbg2iD.d.ts} +1 -1
package/dist/core/index.d.ts
CHANGED
|
@@ -1,21 +1,166 @@
|
|
|
1
|
-
import { W as World, E as Entity, L as LoopPhase, S as System } from '../types-
|
|
2
|
-
export { U as Unsubscribe } from '../types-
|
|
1
|
+
import { W as World, E as Entity, L as LoopPhase, S as System } from '../types-CPB4CpbH.js';
|
|
2
|
+
export { U as Unsubscribe } from '../types-CPB4CpbH.js';
|
|
3
|
+
import { a as ComponentStore } from '../componentStorage-CJTh-TPO.js';
|
|
4
|
+
export { j as DirtyRect, D as DirtyTracker, c as clearDirtyTracking, a as createDirtyTracker, f as forceFullRedraw, g as getDirtyRegions, b as getDirtyTrackingStats, h as hasDirtyRegions, i as isCellDirty, m as markCellDirty, d as markEntityDirty, e as markRegionDirty, r as removeEntityFromTracking } from '../dirtyTracking-C4v8MmM9.js';
|
|
3
5
|
import * as bitecs from 'bitecs';
|
|
4
6
|
import { ComponentRef, QueryTerm, QueryResult } from 'bitecs';
|
|
5
7
|
export { ComponentRef, QueryResult, QueryTerm } from 'bitecs';
|
|
6
|
-
import { S as StyleData } from '../renderable-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export {
|
|
8
|
+
import { S as StyleData } from '../renderable-CwqGwrEV.js';
|
|
9
|
+
import { B as BoxConfig, b as ButtonConfig, C as CheckboxConfig, F as FormConfig, c as InputConfig, L as ListConfig, P as ProgressBarConfig, R as RadioButtonConfig, f as RadioSetConfig, E as ScreenConfig, S as SelectConfig, g as SliderConfig, T as TextConfig, d as TextareaConfig, e as TextboxConfig } from '../inputActions-CRsUtTHM.js';
|
|
10
|
+
export { A as ActionBinding, h as ActionBindingSchema, i as ActionCallback, j as ActionPresets, k as ActionState, l as BoxConfigSchema, m as ButtonConfigSchema, n as CheckboxConfigSchema, o as FormConfigSchema, p as InputActionManager, q as InputBufferStats, r as InputConfigSchema, I as InputEventBufferData, s as InputEventBufferOptions, t as InputLatencyStats, a as InputState, u as InputStateConfig, v as InputStateStats, K as KeyState, w as ListConfigSchema, M as MouseButtonState, x as MouseState, y as ProgressBarConfigSchema, z as RadioButtonConfigSchema, D as RadioSetConfigSchema, G as ScreenConfigSchema, H as SelectConfigSchema, J as SerializedBindings, N as SerializedBindingsSchema, O as SliderConfigSchema, Q as TextConfigSchema, U as TextareaConfigSchema, V as TextboxConfigSchema, W as TimestampedInputEvent, X as TimestampedKeyEvent, Y as TimestampedMouseEvent, Z as beginFrame, aq as clearBuffer, _ as createInputActionManager, $ as createInputEventBuffer, a0 as createInputState, a1 as drainAllEvents, a2 as drainKeys, a3 as drainMouse, a4 as endFrame, a5 as getLatencyStats, a6 as getMovementDirection, a7 as getPendingCount, a8 as getPendingKeyCount, a9 as getPendingMouseCount, ar as getStats, aa as globalInputBuffer, ab as hasPendingEvents, ac as isAllKeysDown, ad as isAnyKeyDown, ae as isAnyKeyPressed, af as isLatencyAcceptable, ag as isProcessingTimeAcceptable, ah as peekEvents, ai as peekKeys, aj as peekMouse, ak as pushKeyEvent, al as pushMouseEvent, am as recordLatency, an as recordLatencyBatch, ao as resetLatencyStats, ap as resetStats } from '../inputActions-CRsUtTHM.js';
|
|
11
|
+
import { c as EventMap, G as GetEntityEventBus, a as EventBus } from '../events-9ForpTfM.js';
|
|
12
|
+
export { E as EntityEventBusStore, b as EventHandler, S as ScreenEventMap, U as UIEventMap, d as createEntityEventBusStore, e as createEventBus } from '../events-9ForpTfM.js';
|
|
11
13
|
import { z } from 'zod';
|
|
12
|
-
|
|
14
|
+
export { F as FixedTimestepConfig, a as FixedUpdateHook, G as GameLoop, b as GameLoopHooks, c as GameLoopOptions, I as InterpolateHook, d as LoopHook, e as LoopState, L as LoopStats, f as createGameLoop, i as isLoopPaused, g as isLoopRunning } from '../gameLoop-C-Ez_i54.js';
|
|
15
|
+
import { K as KeyName, b as KeyEvent } from '../keyParser-BnHbg2iD.js';
|
|
13
16
|
import { K as KeyEvent$1 } from '../program-BZaKqDKH.js';
|
|
14
|
-
export { S as Scheduler, c as createScheduler, g as getDeltaTime } from '../scheduler-
|
|
15
|
-
|
|
17
|
+
export { A as AdaptiveFrameBudgetConfig, a as AdaptiveFrameBudgetStatus, F as FrameTelemetry, P as PhaseTimingData, S as Scheduler, T as TelemetryConfig, c as createScheduler, g as getDeltaTime } from '../scheduler-CMcYew9Z.js';
|
|
18
|
+
export { a as PackedHandle, P as PackedStore, b as addToStore, c as clearStore, d as createPackedStore, f as forEachInStore, g as getFromStore, e as getStoreCapacity, h as getStoreData, i as getStoreSize, j as isValidHandle, m as mapStore, r as removeFromStore, s as setInStore } from '../packedStore-BgvnEdE7.js';
|
|
19
|
+
import '../border-Jb7TrMob.js';
|
|
16
20
|
import '../mouseParser-Cfrbn3AX.js';
|
|
17
21
|
import 'node:stream';
|
|
18
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Absolute positioning helpers for screen-edge anchoring.
|
|
25
|
+
* Provides blessed-compatible aleft, aright, atop, abottom positioning.
|
|
26
|
+
* @module core/absolutePositioning
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Sets the absolute left position (distance from left edge of screen).
|
|
31
|
+
*
|
|
32
|
+
* This anchors the element to the left edge of the screen, ignoring parent positioning.
|
|
33
|
+
* Equivalent to blessed's `aleft` property.
|
|
34
|
+
*
|
|
35
|
+
* @param world - The ECS world
|
|
36
|
+
* @param eid - The entity ID
|
|
37
|
+
* @param left - Distance from left edge of screen
|
|
38
|
+
* @returns The entity ID for chaining
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* import { setAbsoluteLeft } from 'blecsd';
|
|
43
|
+
*
|
|
44
|
+
* // Position element 10 cells from left edge of screen
|
|
45
|
+
* setAbsoluteLeft(world, entity, 10);
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
declare function setAbsoluteLeft(world: World, eid: Entity, left: number): Entity;
|
|
49
|
+
/**
|
|
50
|
+
* Sets the absolute right position (distance from right edge of screen).
|
|
51
|
+
*
|
|
52
|
+
* This anchors the element to the right edge of the screen, ignoring parent positioning.
|
|
53
|
+
* Equivalent to blessed's `aright` property.
|
|
54
|
+
*
|
|
55
|
+
* @param world - The ECS world
|
|
56
|
+
* @param eid - The entity ID
|
|
57
|
+
* @param right - Distance from right edge of screen
|
|
58
|
+
* @returns The entity ID for chaining
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* import { setAbsoluteRight } from 'blecsd';
|
|
63
|
+
*
|
|
64
|
+
* // Position element 10 cells from right edge of screen
|
|
65
|
+
* setAbsoluteRight(world, entity, 10);
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
declare function setAbsoluteRight(world: World, eid: Entity, right: number): Entity;
|
|
69
|
+
/**
|
|
70
|
+
* Sets the absolute top position (distance from top edge of screen).
|
|
71
|
+
*
|
|
72
|
+
* This anchors the element to the top edge of the screen, ignoring parent positioning.
|
|
73
|
+
* Equivalent to blessed's `atop` property.
|
|
74
|
+
*
|
|
75
|
+
* @param world - The ECS world
|
|
76
|
+
* @param eid - The entity ID
|
|
77
|
+
* @param top - Distance from top edge of screen
|
|
78
|
+
* @returns The entity ID for chaining
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* import { setAbsoluteTop } from 'blecsd';
|
|
83
|
+
*
|
|
84
|
+
* // Position element 5 cells from top edge of screen
|
|
85
|
+
* setAbsoluteTop(world, entity, 5);
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
declare function setAbsoluteTop(world: World, eid: Entity, top: number): Entity;
|
|
89
|
+
/**
|
|
90
|
+
* Sets the absolute bottom position (distance from bottom edge of screen).
|
|
91
|
+
*
|
|
92
|
+
* This anchors the element to the bottom edge of the screen, ignoring parent positioning.
|
|
93
|
+
* Equivalent to blessed's `abottom` property.
|
|
94
|
+
*
|
|
95
|
+
* @param world - The ECS world
|
|
96
|
+
* @param eid - The entity ID
|
|
97
|
+
* @param bottom - Distance from bottom edge of screen
|
|
98
|
+
* @returns The entity ID for chaining
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* import { setAbsoluteBottom } from 'blecsd';
|
|
103
|
+
*
|
|
104
|
+
* // Position element 5 cells from bottom edge of screen
|
|
105
|
+
* setAbsoluteBottom(world, entity, 5);
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
declare function setAbsoluteBottom(world: World, eid: Entity, bottom: number): Entity;
|
|
109
|
+
/**
|
|
110
|
+
* Sets absolute position from all four edges.
|
|
111
|
+
*
|
|
112
|
+
* This is a convenience function that sets the position based on multiple edge distances.
|
|
113
|
+
* Uses left/top if both left/right or top/bottom are specified.
|
|
114
|
+
*
|
|
115
|
+
* @param world - The ECS world
|
|
116
|
+
* @param eid - The entity ID
|
|
117
|
+
* @param options - Edge distances (any combination)
|
|
118
|
+
* @returns The entity ID for chaining
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```typescript
|
|
122
|
+
* import { setAbsoluteEdges } from 'blecsd';
|
|
123
|
+
*
|
|
124
|
+
* // Position element 10 from left, 5 from top
|
|
125
|
+
* setAbsoluteEdges(world, entity, { left: 10, top: 5 });
|
|
126
|
+
*
|
|
127
|
+
* // Position element 10 from right, 5 from bottom
|
|
128
|
+
* setAbsoluteEdges(world, entity, { right: 10, bottom: 5 });
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
declare function setAbsoluteEdges(world: World, eid: Entity, options: {
|
|
132
|
+
left?: number;
|
|
133
|
+
right?: number;
|
|
134
|
+
top?: number;
|
|
135
|
+
bottom?: number;
|
|
136
|
+
}): Entity;
|
|
137
|
+
/**
|
|
138
|
+
* Gets the current absolute edge distances for an entity.
|
|
139
|
+
*
|
|
140
|
+
* Returns distances from each edge of the screen. Useful for reading back
|
|
141
|
+
* the current positioning of an absolutely-positioned element.
|
|
142
|
+
*
|
|
143
|
+
* @param world - The ECS world
|
|
144
|
+
* @param eid - The entity ID
|
|
145
|
+
* @returns Edge distances or undefined if entity has no position
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* import { getAbsoluteEdges } from 'blecsd';
|
|
150
|
+
*
|
|
151
|
+
* const edges = getAbsoluteEdges(world, entity);
|
|
152
|
+
* if (edges) {
|
|
153
|
+
* console.log(`Left: ${edges.left}, Top: ${edges.top}`);
|
|
154
|
+
* }
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
declare function getAbsoluteEdges(world: World, eid: Entity): {
|
|
158
|
+
left: number;
|
|
159
|
+
right: number;
|
|
160
|
+
top: number;
|
|
161
|
+
bottom: number;
|
|
162
|
+
} | undefined;
|
|
163
|
+
|
|
19
164
|
/**
|
|
20
165
|
* Auto-padding system for automatically adding padding inside borders.
|
|
21
166
|
*
|
|
@@ -1171,8 +1316,8 @@ interface DirtyTrackerData {
|
|
|
1171
1316
|
readonly dirtyCells: Uint8Array;
|
|
1172
1317
|
/** Set of dirty entity IDs */
|
|
1173
1318
|
readonly dirtyEntities: Set<Entity>;
|
|
1174
|
-
/** Previous bounds for each entity */
|
|
1175
|
-
readonly entityBounds:
|
|
1319
|
+
/** Previous bounds for each entity, backed by ComponentStore for cache-friendly iteration */
|
|
1320
|
+
readonly entityBounds: ComponentStore<EntityBoundsEntry>;
|
|
1176
1321
|
/** Coalesced dirty regions */
|
|
1177
1322
|
readonly dirtyRegions: DirtyRect[];
|
|
1178
1323
|
/** Whether regions need recalculation */
|
|
@@ -2274,6 +2419,28 @@ declare function clearEffectState(eid: Entity): void;
|
|
|
2274
2419
|
*/
|
|
2275
2420
|
declare function clearAllEffectConfigs(): void;
|
|
2276
2421
|
|
|
2422
|
+
/**
|
|
2423
|
+
* Entity factory functions for creating common entity types.
|
|
2424
|
+
* These factories combine components and helpers to create fully-configured entities.
|
|
2425
|
+
* @module core/entities/factories
|
|
2426
|
+
*/
|
|
2427
|
+
|
|
2428
|
+
declare function createBoxEntity(world: World, config?: BoxConfig): Entity;
|
|
2429
|
+
declare function createTextEntity(world: World, config?: TextConfig): Entity;
|
|
2430
|
+
declare function createButtonEntity(world: World, config?: ButtonConfig): Entity;
|
|
2431
|
+
declare function createScreenEntity(world: World, config: ScreenConfig): Entity;
|
|
2432
|
+
declare function createInputEntity(world: World, config?: InputConfig): Entity;
|
|
2433
|
+
declare function createListEntity(world: World, config?: ListConfig): Entity;
|
|
2434
|
+
declare function createCheckboxEntity(world: World, config?: CheckboxConfig): Entity;
|
|
2435
|
+
declare function createTextboxEntity(world: World, config?: TextboxConfig): Entity;
|
|
2436
|
+
declare function createTextareaEntity(world: World, config?: TextareaConfig): Entity;
|
|
2437
|
+
declare function createSelectEntity(world: World, config?: SelectConfig): Entity;
|
|
2438
|
+
declare function createSliderEntity(world: World, config?: SliderConfig): Entity;
|
|
2439
|
+
declare function createFormEntity(world: World, config?: FormConfig): Entity;
|
|
2440
|
+
declare function createProgressBarEntity(world: World, config?: ProgressBarConfig): Entity;
|
|
2441
|
+
declare function createRadioSetEntity(world: World, config?: RadioSetConfig): Entity;
|
|
2442
|
+
declare function createRadioButtonEntity(world: World, config?: RadioButtonConfig): Entity;
|
|
2443
|
+
|
|
2277
2444
|
/**
|
|
2278
2445
|
* Entity data storage for arbitrary key-value pairs.
|
|
2279
2446
|
*
|
|
@@ -2601,11 +2768,6 @@ interface BubbleableEventOptions<T> {
|
|
|
2601
2768
|
* ```
|
|
2602
2769
|
*/
|
|
2603
2770
|
declare function createBubbleableEvent<T>(options: BubbleableEventOptions<T>): BubbleableEvent<T>;
|
|
2604
|
-
/**
|
|
2605
|
-
* Function type for getting an EventBus for a specific entity.
|
|
2606
|
-
* Returns undefined if the entity has no event bus.
|
|
2607
|
-
*/
|
|
2608
|
-
type GetEntityEventBus<T extends EventMap> = (world: World, eid: Entity) => EventBus<T> | undefined;
|
|
2609
2771
|
/**
|
|
2610
2772
|
* Result of bubbling an event through the hierarchy.
|
|
2611
2773
|
*/
|
|
@@ -2656,51 +2818,102 @@ interface BubbleResult {
|
|
|
2656
2818
|
* ```
|
|
2657
2819
|
*/
|
|
2658
2820
|
declare function bubbleEvent<T, E extends EventMap>(world: World, event: BubbleableEvent<T>, getEventBus: GetEntityEventBus<E>): BubbleResult;
|
|
2821
|
+
|
|
2659
2822
|
/**
|
|
2660
|
-
*
|
|
2661
|
-
*
|
|
2662
|
-
*
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
*
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
*
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
*
|
|
2823
|
+
* Event propagation to descendants (downward through hierarchy).
|
|
2824
|
+
* Emits events to an entity and all its children recursively.
|
|
2825
|
+
* @module core/eventDescendants
|
|
2826
|
+
*/
|
|
2827
|
+
|
|
2828
|
+
/**
|
|
2829
|
+
* Result of emitting an event to descendants.
|
|
2830
|
+
*/
|
|
2831
|
+
interface EmitDescendantsResult {
|
|
2832
|
+
/** Number of entities the event was dispatched to */
|
|
2833
|
+
dispatchCount: number;
|
|
2834
|
+
/** Maximum depth reached during traversal */
|
|
2835
|
+
maxDepth: number;
|
|
2836
|
+
/** Whether a circular reference was detected */
|
|
2837
|
+
circularReferenceDetected: boolean;
|
|
2838
|
+
}
|
|
2839
|
+
/**
|
|
2840
|
+
* Zod schema for EmitDescendantsResult.
|
|
2841
|
+
*/
|
|
2842
|
+
declare const EmitDescendantsResultSchema: z.ZodObject<{
|
|
2843
|
+
dispatchCount: z.ZodNumber;
|
|
2844
|
+
maxDepth: z.ZodNumber;
|
|
2845
|
+
circularReferenceDetected: z.ZodBoolean;
|
|
2846
|
+
}, z.core.$strip>;
|
|
2847
|
+
/**
|
|
2848
|
+
* Options for emitting events to descendants.
|
|
2849
|
+
*/
|
|
2850
|
+
interface EmitDescendantsOptions {
|
|
2851
|
+
/** Maximum depth to traverse (default: Infinity) */
|
|
2852
|
+
maxDepth?: number;
|
|
2853
|
+
/** Whether to include the root entity (default: true) */
|
|
2854
|
+
includeRoot?: boolean;
|
|
2855
|
+
}
|
|
2856
|
+
/**
|
|
2857
|
+
* Zod schema for EmitDescendantsOptions.
|
|
2858
|
+
*/
|
|
2859
|
+
declare const EmitDescendantsOptionsSchema: z.ZodObject<{
|
|
2860
|
+
maxDepth: z.ZodOptional<z.ZodNumber>;
|
|
2861
|
+
includeRoot: z.ZodOptional<z.ZodBoolean>;
|
|
2862
|
+
}, z.core.$strip>;
|
|
2863
|
+
/**
|
|
2864
|
+
* Emits an event to an entity and all its descendants in the hierarchy.
|
|
2865
|
+
* Traverses the entity tree depth-first, visiting each descendant entity.
|
|
2866
|
+
* Safely handles circular references by tracking visited entities.
|
|
2686
2867
|
*
|
|
2687
|
-
*
|
|
2688
|
-
*
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2868
|
+
* @typeParam T - Event map type
|
|
2869
|
+
* @typeParam K - Event name type
|
|
2870
|
+
* @param world - The ECS world
|
|
2871
|
+
* @param eid - The root entity to start emitting from
|
|
2872
|
+
* @param eventName - The name of the event to emit
|
|
2873
|
+
* @param eventData - The event data to pass to handlers
|
|
2874
|
+
* @param getEventBus - Function to get the event bus for an entity
|
|
2875
|
+
* @param options - Optional emission configuration
|
|
2876
|
+
* @returns Result with dispatch count, max depth, and circular reference detection
|
|
2877
|
+
*
|
|
2878
|
+
* @example
|
|
2879
|
+
* ```typescript
|
|
2880
|
+
* import { emitDescendants, createEventBus } from 'blecsd';
|
|
2881
|
+
*
|
|
2882
|
+
* // Set up entity hierarchy
|
|
2883
|
+
* const parent = addEntity(world);
|
|
2884
|
+
* const child1 = addEntity(world);
|
|
2885
|
+
* const child2 = addEntity(world);
|
|
2886
|
+
* appendChild(world, parent, child1);
|
|
2887
|
+
* appendChild(world, parent, child2);
|
|
2888
|
+
*
|
|
2889
|
+
* // Create event buses for entities
|
|
2890
|
+
* const eventBuses = new Map();
|
|
2891
|
+
* eventBuses.set(parent, createEventBus());
|
|
2892
|
+
* eventBuses.set(child1, createEventBus());
|
|
2893
|
+
* eventBuses.set(child2, createEventBus());
|
|
2894
|
+
*
|
|
2895
|
+
* const getEventBus = (world, eid) => eventBuses.get(eid);
|
|
2896
|
+
*
|
|
2897
|
+
* // Listen for events
|
|
2898
|
+
* eventBuses.get(parent).on('action', (data) => console.log('Parent:', data));
|
|
2899
|
+
* eventBuses.get(child1).on('action', (data) => console.log('Child1:', data));
|
|
2900
|
+
* eventBuses.get(child2).on('action', (data) => console.log('Child2:', data));
|
|
2901
|
+
*
|
|
2902
|
+
* // Emit to all descendants
|
|
2903
|
+
* const result = emitDescendants(
|
|
2904
|
+
* world,
|
|
2905
|
+
* parent,
|
|
2906
|
+
* 'action',
|
|
2907
|
+
* { type: 'activate' },
|
|
2908
|
+
* getEventBus
|
|
2909
|
+
* );
|
|
2910
|
+
* // Logs: "Parent: { type: 'activate' }"
|
|
2911
|
+
* // "Child1: { type: 'activate' }"
|
|
2912
|
+
* "Child2: { type: 'activate' }"
|
|
2913
|
+
* // result.dispatchCount === 3
|
|
2914
|
+
* ```
|
|
2915
|
+
*/
|
|
2916
|
+
declare function emitDescendants<T extends EventMap, K extends keyof T>(world: World, eid: Entity, eventName: K, eventData: T[K], getEventBus: GetEntityEventBus<T>, options?: EmitDescendantsOptions): EmitDescendantsResult;
|
|
2704
2917
|
|
|
2705
2918
|
/**
|
|
2706
2919
|
* Hit Test System with Z-Order Aware Clickable Sorting
|
|
@@ -4033,7 +4246,7 @@ interface PhaseManager {
|
|
|
4033
4246
|
*
|
|
4034
4247
|
* // Add custom phases
|
|
4035
4248
|
* const preRender = manager.registerPhase('PRE_RENDER', LoopPhase.LAYOUT);
|
|
4036
|
-
* const postPhysics = manager.registerPhase('POST_PHYSICS', LoopPhase.
|
|
4249
|
+
* const postPhysics = manager.registerPhase('POST_PHYSICS', LoopPhase.ANIMATION);
|
|
4037
4250
|
*
|
|
4038
4251
|
* // Get execution order
|
|
4039
4252
|
* console.log(manager.getPhaseOrder());
|
|
@@ -5065,7 +5278,7 @@ interface SceneTransition {
|
|
|
5065
5278
|
/** Called when the transition starts */
|
|
5066
5279
|
onStart?(world: World): void;
|
|
5067
5280
|
/** Called each frame during the transition with progress (0-1) */
|
|
5068
|
-
onUpdate
|
|
5281
|
+
onUpdate?: ((world: World, progress: number) => void) | undefined;
|
|
5069
5282
|
/** Called when the transition completes */
|
|
5070
5283
|
onComplete?(world: World): void;
|
|
5071
5284
|
}
|
|
@@ -5264,27 +5477,27 @@ interface SerializedWorld {
|
|
|
5264
5477
|
/** Array of serialized entities */
|
|
5265
5478
|
readonly entities: readonly SerializedEntity[];
|
|
5266
5479
|
/** Optional metadata attached by user */
|
|
5267
|
-
readonly metadata?: Record<string, unknown
|
|
5480
|
+
readonly metadata?: Record<string, unknown> | undefined;
|
|
5268
5481
|
}
|
|
5269
5482
|
/**
|
|
5270
5483
|
* Options for serialization.
|
|
5271
5484
|
*/
|
|
5272
5485
|
interface SerializeOptions {
|
|
5273
5486
|
/** Only serialize entities with these IDs (default: all entities) */
|
|
5274
|
-
readonly entityFilter?: readonly Entity[];
|
|
5487
|
+
readonly entityFilter?: readonly Entity[] | undefined;
|
|
5275
5488
|
/** Only serialize these components by name (default: all registered) */
|
|
5276
|
-
readonly componentFilter?: readonly string[];
|
|
5489
|
+
readonly componentFilter?: readonly string[] | undefined;
|
|
5277
5490
|
/** Metadata to include in the snapshot */
|
|
5278
|
-
readonly metadata?: Record<string, unknown
|
|
5491
|
+
readonly metadata?: Record<string, unknown> | undefined;
|
|
5279
5492
|
}
|
|
5280
5493
|
/**
|
|
5281
5494
|
* Options for deserialization.
|
|
5282
5495
|
*/
|
|
5283
5496
|
interface DeserializeOptions {
|
|
5284
5497
|
/** If true, clear the world before loading (default: false) */
|
|
5285
|
-
readonly clearWorld?: boolean;
|
|
5498
|
+
readonly clearWorld?: boolean | undefined;
|
|
5286
5499
|
/** If true, create a new world instead of modifying the given one (default: false) */
|
|
5287
|
-
readonly createNew?: boolean;
|
|
5500
|
+
readonly createNew?: boolean | undefined;
|
|
5288
5501
|
}
|
|
5289
5502
|
/**
|
|
5290
5503
|
* Result of deserialization.
|
|
@@ -5722,196 +5935,6 @@ declare function getEntityPoolCapacity(pool: EntityPool): number;
|
|
|
5722
5935
|
*/
|
|
5723
5936
|
declare function assertEntityAlive(pool: EntityPool, handle: EntityHandle): void;
|
|
5724
5937
|
|
|
5725
|
-
/**
|
|
5726
|
-
* Packed Store: Cache-friendly storage with stable handles
|
|
5727
|
-
*
|
|
5728
|
-
* Implements the three-vector pattern for O(1) add/remove operations
|
|
5729
|
-
* with stable identifiers and cache-friendly iteration:
|
|
5730
|
-
*
|
|
5731
|
-
* - data[]: Dense contiguous storage for actual values
|
|
5732
|
-
* - dataIndex[]: Maps handle index → position in data array
|
|
5733
|
-
* - id[]: Maps position in data → handle index (inverse mapping)
|
|
5734
|
-
* - generations[]: Tracks generation at each slot for stale handle detection
|
|
5735
|
-
*
|
|
5736
|
-
* @module core/storage/packedStore
|
|
5737
|
-
*/
|
|
5738
|
-
/**
|
|
5739
|
-
* Handle to an element in a packed store.
|
|
5740
|
-
* The combination of index and generation ensures handles
|
|
5741
|
-
* become invalid after the element is removed.
|
|
5742
|
-
*/
|
|
5743
|
-
interface PackedHandle {
|
|
5744
|
-
readonly index: number;
|
|
5745
|
-
readonly gen: number;
|
|
5746
|
-
}
|
|
5747
|
-
/**
|
|
5748
|
-
* Packed store state. All arrays are parallel structures
|
|
5749
|
-
* that work together to provide stable handles with O(1) operations.
|
|
5750
|
-
*/
|
|
5751
|
-
interface PackedStore<T> {
|
|
5752
|
-
/** Dense contiguous data array for cache-friendly iteration */
|
|
5753
|
-
readonly data: T[];
|
|
5754
|
-
/** Maps handle index → position in data array */
|
|
5755
|
-
readonly dataIndex: Int32Array;
|
|
5756
|
-
/** Maps data position → handle index (inverse of dataIndex) */
|
|
5757
|
-
readonly id: Int32Array;
|
|
5758
|
-
/** Generation counter for each slot (bumped on removal) */
|
|
5759
|
-
readonly generations: Uint32Array;
|
|
5760
|
-
/** Number of live elements */
|
|
5761
|
-
size: number;
|
|
5762
|
-
/** Total allocated capacity */
|
|
5763
|
-
capacity: number;
|
|
5764
|
-
}
|
|
5765
|
-
/**
|
|
5766
|
-
* Creates a new packed store with optional initial capacity.
|
|
5767
|
-
*
|
|
5768
|
-
* @param initialCapacity - Initial capacity hint (default 64)
|
|
5769
|
-
* @returns Empty packed store
|
|
5770
|
-
*
|
|
5771
|
-
* @example
|
|
5772
|
-
* ```typescript
|
|
5773
|
-
* import { createPackedStore, addToStore } from 'blecsd';
|
|
5774
|
-
*
|
|
5775
|
-
* interface Particle { x: number; y: number; vx: number; vy: number; }
|
|
5776
|
-
* const particles = createPackedStore<Particle>();
|
|
5777
|
-
* const handle = addToStore(particles, { x: 0, y: 0, vx: 1, vy: 0 });
|
|
5778
|
-
* ```
|
|
5779
|
-
*/
|
|
5780
|
-
declare function createPackedStore<T>(initialCapacity?: number): PackedStore<T>;
|
|
5781
|
-
/**
|
|
5782
|
-
* Adds a value to the packed store and returns a stable handle.
|
|
5783
|
-
*
|
|
5784
|
-
* If there are freed slots from prior deletions, one is reused.
|
|
5785
|
-
* Otherwise, capacity is expanded as needed.
|
|
5786
|
-
*
|
|
5787
|
-
* @param store - The packed store
|
|
5788
|
-
* @param value - Value to add
|
|
5789
|
-
* @returns Handle to the stored value
|
|
5790
|
-
*
|
|
5791
|
-
* @example
|
|
5792
|
-
* ```typescript
|
|
5793
|
-
* const handle = addToStore(store, { name: 'entity1' });
|
|
5794
|
-
* // handle.index is stable even after other elements are removed
|
|
5795
|
-
* ```
|
|
5796
|
-
*/
|
|
5797
|
-
declare function addToStore<T>(store: PackedStore<T>, value: T): PackedHandle;
|
|
5798
|
-
/**
|
|
5799
|
-
* Checks if a handle is valid (points to a live element).
|
|
5800
|
-
*
|
|
5801
|
-
* @param store - The packed store
|
|
5802
|
-
* @param handle - Handle to validate
|
|
5803
|
-
* @returns True if the handle points to a live element
|
|
5804
|
-
*
|
|
5805
|
-
* @example
|
|
5806
|
-
* ```typescript
|
|
5807
|
-
* if (isValidHandle(store, handle)) {
|
|
5808
|
-
* const value = getFromStore(store, handle);
|
|
5809
|
-
* }
|
|
5810
|
-
* ```
|
|
5811
|
-
*/
|
|
5812
|
-
declare function isValidHandle<T>(store: PackedStore<T>, handle: PackedHandle): boolean;
|
|
5813
|
-
/**
|
|
5814
|
-
* Gets the value associated with a handle.
|
|
5815
|
-
*
|
|
5816
|
-
* @param store - The packed store
|
|
5817
|
-
* @param handle - Handle to the element
|
|
5818
|
-
* @returns The value, or undefined if handle is invalid
|
|
5819
|
-
*
|
|
5820
|
-
* @example
|
|
5821
|
-
* ```typescript
|
|
5822
|
-
* const particle = getFromStore(particles, handle);
|
|
5823
|
-
* if (particle) {
|
|
5824
|
-
* console.log(particle.x, particle.y);
|
|
5825
|
-
* }
|
|
5826
|
-
* ```
|
|
5827
|
-
*/
|
|
5828
|
-
declare function getFromStore<T>(store: PackedStore<T>, handle: PackedHandle): T | undefined;
|
|
5829
|
-
/**
|
|
5830
|
-
* Sets (replaces) the value at a handle.
|
|
5831
|
-
*
|
|
5832
|
-
* @param store - The packed store
|
|
5833
|
-
* @param handle - Handle to the element
|
|
5834
|
-
* @param value - New value
|
|
5835
|
-
* @returns True if successful, false if handle is invalid
|
|
5836
|
-
*/
|
|
5837
|
-
declare function setInStore<T>(store: PackedStore<T>, handle: PackedHandle, value: T): boolean;
|
|
5838
|
-
/**
|
|
5839
|
-
* Removes an element from the packed store using swap-and-pop.
|
|
5840
|
-
*
|
|
5841
|
-
* The handle becomes invalid after removal. Any other handles
|
|
5842
|
-
* remain valid (this is the key benefit of the three-vector pattern).
|
|
5843
|
-
*
|
|
5844
|
-
* @param store - The packed store
|
|
5845
|
-
* @param handle - Handle to remove
|
|
5846
|
-
* @returns True if removed, false if handle was invalid
|
|
5847
|
-
*
|
|
5848
|
-
* @example
|
|
5849
|
-
* ```typescript
|
|
5850
|
-
* removeFromStore(particles, handle);
|
|
5851
|
-
* // handle is now invalid, but other handles remain valid
|
|
5852
|
-
* ```
|
|
5853
|
-
*/
|
|
5854
|
-
declare function removeFromStore<T>(store: PackedStore<T>, handle: PackedHandle): boolean;
|
|
5855
|
-
/**
|
|
5856
|
-
* Clears all elements from the store but retains capacity.
|
|
5857
|
-
*
|
|
5858
|
-
* @param store - The packed store to clear
|
|
5859
|
-
*/
|
|
5860
|
-
declare function clearStore<T>(store: PackedStore<T>): void;
|
|
5861
|
-
/**
|
|
5862
|
-
* Iterates over all live elements in the store.
|
|
5863
|
-
* Iteration is cache-friendly as it traverses the dense data array.
|
|
5864
|
-
*
|
|
5865
|
-
* @param store - The packed store
|
|
5866
|
-
* @param fn - Callback for each element (receives value and handle)
|
|
5867
|
-
*
|
|
5868
|
-
* @example
|
|
5869
|
-
* ```typescript
|
|
5870
|
-
* forEachInStore(particles, (particle, handle) => {
|
|
5871
|
-
* particle.x += particle.vx;
|
|
5872
|
-
* particle.y += particle.vy;
|
|
5873
|
-
* });
|
|
5874
|
-
* ```
|
|
5875
|
-
*/
|
|
5876
|
-
declare function forEachInStore<T>(store: PackedStore<T>, fn: (value: T, handle: PackedHandle) => void): void;
|
|
5877
|
-
/**
|
|
5878
|
-
* Maps over all live elements, producing a new array.
|
|
5879
|
-
*
|
|
5880
|
-
* @param store - The packed store
|
|
5881
|
-
* @param fn - Transform function
|
|
5882
|
-
* @returns Array of transformed values
|
|
5883
|
-
*/
|
|
5884
|
-
declare function mapStore<T, U>(store: PackedStore<T>, fn: (value: T, handle: PackedHandle) => U): U[];
|
|
5885
|
-
/**
|
|
5886
|
-
* Returns the dense data array for direct iteration.
|
|
5887
|
-
* This is the fastest way to iterate when you don't need handles.
|
|
5888
|
-
*
|
|
5889
|
-
* WARNING: Do not modify the array structure (push/pop/splice).
|
|
5890
|
-
* The returned array is a view into internal storage.
|
|
5891
|
-
*
|
|
5892
|
-
* @param store - The packed store
|
|
5893
|
-
* @returns Readonly view of the dense data array (length = store.size)
|
|
5894
|
-
*
|
|
5895
|
-
* @example
|
|
5896
|
-
* ```typescript
|
|
5897
|
-
* // Fastest iteration when handles aren't needed
|
|
5898
|
-
* const data = getStoreData(particles);
|
|
5899
|
-
* for (let i = 0; i < particles.size; i++) {
|
|
5900
|
-
* const p = data[i];
|
|
5901
|
-
* p.x += p.vx;
|
|
5902
|
-
* }
|
|
5903
|
-
* ```
|
|
5904
|
-
*/
|
|
5905
|
-
declare function getStoreData<T>(store: PackedStore<T>): readonly T[];
|
|
5906
|
-
/**
|
|
5907
|
-
* Gets the current number of live elements.
|
|
5908
|
-
*/
|
|
5909
|
-
declare function getStoreSize<T>(store: PackedStore<T>): number;
|
|
5910
|
-
/**
|
|
5911
|
-
* Gets the current capacity (including freed slots).
|
|
5912
|
-
*/
|
|
5913
|
-
declare function getStoreCapacity<T>(store: PackedStore<T>): number;
|
|
5914
|
-
|
|
5915
5938
|
/**
|
|
5916
5939
|
* Archetype-based Entity Pool: Pre-allocated entity recycling per component archetype
|
|
5917
5940
|
*
|
|
@@ -6335,6 +6358,360 @@ declare function precomputeStyles(world: World, entities: readonly Entity[]): vo
|
|
|
6335
6358
|
*/
|
|
6336
6359
|
declare function getComputedStyles(world: World, entities: readonly Entity[]): Map<Entity, StyleData>;
|
|
6337
6360
|
|
|
6361
|
+
/**
|
|
6362
|
+
* Entity and component validation utilities
|
|
6363
|
+
*
|
|
6364
|
+
* Provides helpful error messages when components are missing or entities are invalid.
|
|
6365
|
+
*
|
|
6366
|
+
* @module core/validation
|
|
6367
|
+
*/
|
|
6368
|
+
|
|
6369
|
+
/**
|
|
6370
|
+
* Error thrown when entity validation fails.
|
|
6371
|
+
*/
|
|
6372
|
+
declare class EntityValidationError extends Error {
|
|
6373
|
+
constructor(message: string);
|
|
6374
|
+
}
|
|
6375
|
+
/**
|
|
6376
|
+
* Registers a component name for better error messages.
|
|
6377
|
+
* This is optional but recommended for clearer validation errors.
|
|
6378
|
+
*
|
|
6379
|
+
* @param component - The component to register
|
|
6380
|
+
* @param name - The human-readable name for the component
|
|
6381
|
+
*
|
|
6382
|
+
* @example
|
|
6383
|
+
* ```typescript
|
|
6384
|
+
* import { registerComponentName, Position, Velocity } from 'blecsd';
|
|
6385
|
+
*
|
|
6386
|
+
* registerComponentName(Position, 'Position');
|
|
6387
|
+
* registerComponentName(Velocity, 'Velocity');
|
|
6388
|
+
* ```
|
|
6389
|
+
*/
|
|
6390
|
+
declare function registerComponentName(component: ComponentRef, name: string): void;
|
|
6391
|
+
/**
|
|
6392
|
+
* Validates that an entity exists and has all required components.
|
|
6393
|
+
* Throws a descriptive error if validation fails.
|
|
6394
|
+
*
|
|
6395
|
+
* @param world - The ECS world
|
|
6396
|
+
* @param eid - The entity ID to validate
|
|
6397
|
+
* @param requiredComponents - Array of components the entity must have
|
|
6398
|
+
* @param context - Context string describing where this validation is happening (e.g., "layoutSystem", "createBox")
|
|
6399
|
+
* @throws {EntityValidationError} If entity doesn't exist or is missing required components
|
|
6400
|
+
*
|
|
6401
|
+
* @example
|
|
6402
|
+
* ```typescript
|
|
6403
|
+
* import { createWorld, addEntity, validateEntity, Position, Velocity } from 'blecsd';
|
|
6404
|
+
*
|
|
6405
|
+
* const world = createWorld();
|
|
6406
|
+
* const entity = addEntity(world);
|
|
6407
|
+
*
|
|
6408
|
+
* // This will throw because entity is missing Position and Velocity
|
|
6409
|
+
* try {
|
|
6410
|
+
* validateEntity(world, entity, [Position, Velocity], 'movementSystem');
|
|
6411
|
+
* } catch (error) {
|
|
6412
|
+
* console.error(error.message);
|
|
6413
|
+
* // "Entity 0 is missing required components for movementSystem: Position, Velocity.
|
|
6414
|
+
* // Did you forget to call addComponent(world, eid, Position)?"
|
|
6415
|
+
* }
|
|
6416
|
+
* ```
|
|
6417
|
+
*
|
|
6418
|
+
* @example
|
|
6419
|
+
* ```typescript
|
|
6420
|
+
* import { createWorld, addEntity, addComponent, validateEntity, Position } from 'blecsd';
|
|
6421
|
+
*
|
|
6422
|
+
* const world = createWorld();
|
|
6423
|
+
* const entity = addEntity(world);
|
|
6424
|
+
* addComponent(world, entity, Position);
|
|
6425
|
+
*
|
|
6426
|
+
* // This passes - no error thrown
|
|
6427
|
+
* validateEntity(world, entity, [Position], 'renderSystem');
|
|
6428
|
+
* ```
|
|
6429
|
+
*/
|
|
6430
|
+
declare function validateEntity(world: World, eid: Entity, requiredComponents: ComponentRef[], context: string): void;
|
|
6431
|
+
/**
|
|
6432
|
+
* Validates that an entity exists and has all required components.
|
|
6433
|
+
* Returns true if valid, false if invalid (does not throw).
|
|
6434
|
+
*
|
|
6435
|
+
* @param world - The ECS world
|
|
6436
|
+
* @param eid - The entity ID to validate
|
|
6437
|
+
* @param requiredComponents - Array of components the entity must have
|
|
6438
|
+
* @returns True if entity exists and has all required components, false otherwise
|
|
6439
|
+
*
|
|
6440
|
+
* @example
|
|
6441
|
+
* ```typescript
|
|
6442
|
+
* import { createWorld, addEntity, addComponent, isEntityValid, Position, Velocity } from 'blecsd';
|
|
6443
|
+
*
|
|
6444
|
+
* const world = createWorld();
|
|
6445
|
+
* const entity = addEntity(world);
|
|
6446
|
+
* addComponent(world, entity, Position);
|
|
6447
|
+
*
|
|
6448
|
+
* console.log(isEntityValid(world, entity, [Position])); // true
|
|
6449
|
+
* console.log(isEntityValid(world, entity, [Position, Velocity])); // false
|
|
6450
|
+
* ```
|
|
6451
|
+
*/
|
|
6452
|
+
declare function isEntityValid(world: World, eid: Entity, requiredComponents: ComponentRef[]): boolean;
|
|
6453
|
+
|
|
6454
|
+
/**
|
|
6455
|
+
* Warning system for non-fatal screen issues.
|
|
6456
|
+
*
|
|
6457
|
+
* Provides typed warnings for terminal/screen issues like small sizes,
|
|
6458
|
+
* unsupported capabilities, deprecated APIs, and performance problems.
|
|
6459
|
+
*
|
|
6460
|
+
* @module core/warnings
|
|
6461
|
+
*
|
|
6462
|
+
* @example
|
|
6463
|
+
* ```typescript
|
|
6464
|
+
* import { createWarningEmitter, WarningType } from 'blecsd';
|
|
6465
|
+
*
|
|
6466
|
+
* const warnings = createWarningEmitter();
|
|
6467
|
+
*
|
|
6468
|
+
* warnings.on('warning', (event) => {
|
|
6469
|
+
* console.warn(`[${event.type}] ${event.message}`);
|
|
6470
|
+
* });
|
|
6471
|
+
*
|
|
6472
|
+
* // Emit a warning
|
|
6473
|
+
* warnings.emit('warning', {
|
|
6474
|
+
* type: WarningType.TERMINAL_TOO_SMALL,
|
|
6475
|
+
* message: 'Terminal size is very small',
|
|
6476
|
+
* metadata: { width: 20, height: 10, minWidth: 80, minHeight: 24 },
|
|
6477
|
+
* timestamp: Date.now(),
|
|
6478
|
+
* });
|
|
6479
|
+
* ```
|
|
6480
|
+
*/
|
|
6481
|
+
|
|
6482
|
+
/**
|
|
6483
|
+
* Warning type enumeration.
|
|
6484
|
+
*/
|
|
6485
|
+
declare const WarningType: {
|
|
6486
|
+
/** Terminal resized to very small dimensions */
|
|
6487
|
+
readonly TERMINAL_TOO_SMALL: "terminal-too-small";
|
|
6488
|
+
/** Requested terminal capability is not supported */
|
|
6489
|
+
readonly UNSUPPORTED_CAPABILITY: "unsupported-capability";
|
|
6490
|
+
/** Using deprecated API */
|
|
6491
|
+
readonly DEPRECATED_API: "deprecated-api";
|
|
6492
|
+
/** Performance issue detected (frame drops) */
|
|
6493
|
+
readonly PERFORMANCE_ISSUE: "performance-issue";
|
|
6494
|
+
};
|
|
6495
|
+
type WarningTypeValue = (typeof WarningType)[keyof typeof WarningType];
|
|
6496
|
+
/**
|
|
6497
|
+
* Metadata for terminal too small warnings.
|
|
6498
|
+
*/
|
|
6499
|
+
interface TerminalTooSmallMetadata {
|
|
6500
|
+
readonly width: number;
|
|
6501
|
+
readonly height: number;
|
|
6502
|
+
readonly minWidth: number;
|
|
6503
|
+
readonly minHeight: number;
|
|
6504
|
+
}
|
|
6505
|
+
/**
|
|
6506
|
+
* Metadata for unsupported capability warnings.
|
|
6507
|
+
*/
|
|
6508
|
+
interface UnsupportedCapabilityMetadata {
|
|
6509
|
+
readonly capability: string;
|
|
6510
|
+
readonly fallback?: string | undefined;
|
|
6511
|
+
}
|
|
6512
|
+
/**
|
|
6513
|
+
* Metadata for deprecated API warnings.
|
|
6514
|
+
*/
|
|
6515
|
+
interface DeprecatedAPIMetadata {
|
|
6516
|
+
readonly api: string;
|
|
6517
|
+
readonly replacement: string;
|
|
6518
|
+
readonly since: string;
|
|
6519
|
+
}
|
|
6520
|
+
/**
|
|
6521
|
+
* Metadata for performance warnings.
|
|
6522
|
+
*/
|
|
6523
|
+
interface PerformanceIssueMetadata {
|
|
6524
|
+
readonly metric: string;
|
|
6525
|
+
readonly value: number;
|
|
6526
|
+
readonly threshold: number;
|
|
6527
|
+
readonly frameTime?: number | undefined;
|
|
6528
|
+
}
|
|
6529
|
+
/**
|
|
6530
|
+
* Union type for warning metadata.
|
|
6531
|
+
*/
|
|
6532
|
+
type WarningMetadata = TerminalTooSmallMetadata | UnsupportedCapabilityMetadata | DeprecatedAPIMetadata | PerformanceIssueMetadata;
|
|
6533
|
+
/**
|
|
6534
|
+
* Warning event payload.
|
|
6535
|
+
*/
|
|
6536
|
+
interface WarningEvent {
|
|
6537
|
+
readonly type: WarningTypeValue;
|
|
6538
|
+
readonly message: string;
|
|
6539
|
+
readonly metadata: WarningMetadata;
|
|
6540
|
+
readonly timestamp: number;
|
|
6541
|
+
}
|
|
6542
|
+
/**
|
|
6543
|
+
* Zod schema for terminal too small metadata.
|
|
6544
|
+
*/
|
|
6545
|
+
declare const TerminalTooSmallMetadataSchema: z.ZodObject<{
|
|
6546
|
+
width: z.ZodNumber;
|
|
6547
|
+
height: z.ZodNumber;
|
|
6548
|
+
minWidth: z.ZodNumber;
|
|
6549
|
+
minHeight: z.ZodNumber;
|
|
6550
|
+
}, z.core.$strip>;
|
|
6551
|
+
/**
|
|
6552
|
+
* Zod schema for unsupported capability metadata.
|
|
6553
|
+
*/
|
|
6554
|
+
declare const UnsupportedCapabilityMetadataSchema: z.ZodObject<{
|
|
6555
|
+
capability: z.ZodString;
|
|
6556
|
+
fallback: z.ZodOptional<z.ZodString>;
|
|
6557
|
+
}, z.core.$strip>;
|
|
6558
|
+
/**
|
|
6559
|
+
* Zod schema for deprecated API metadata.
|
|
6560
|
+
*/
|
|
6561
|
+
declare const DeprecatedAPIMetadataSchema: z.ZodObject<{
|
|
6562
|
+
api: z.ZodString;
|
|
6563
|
+
replacement: z.ZodString;
|
|
6564
|
+
since: z.ZodString;
|
|
6565
|
+
}, z.core.$strip>;
|
|
6566
|
+
/**
|
|
6567
|
+
* Zod schema for performance issue metadata.
|
|
6568
|
+
*/
|
|
6569
|
+
declare const PerformanceIssueMetadataSchema: z.ZodObject<{
|
|
6570
|
+
metric: z.ZodString;
|
|
6571
|
+
value: z.ZodNumber;
|
|
6572
|
+
threshold: z.ZodNumber;
|
|
6573
|
+
frameTime: z.ZodOptional<z.ZodNumber>;
|
|
6574
|
+
}, z.core.$strip>;
|
|
6575
|
+
/**
|
|
6576
|
+
* Zod schema for warning events.
|
|
6577
|
+
*/
|
|
6578
|
+
declare const WarningEventSchema: z.ZodObject<{
|
|
6579
|
+
type: z.ZodEnum<{
|
|
6580
|
+
"terminal-too-small": "terminal-too-small";
|
|
6581
|
+
"unsupported-capability": "unsupported-capability";
|
|
6582
|
+
"deprecated-api": "deprecated-api";
|
|
6583
|
+
"performance-issue": "performance-issue";
|
|
6584
|
+
}>;
|
|
6585
|
+
message: z.ZodString;
|
|
6586
|
+
metadata: z.ZodUnion<readonly [z.ZodObject<{
|
|
6587
|
+
width: z.ZodNumber;
|
|
6588
|
+
height: z.ZodNumber;
|
|
6589
|
+
minWidth: z.ZodNumber;
|
|
6590
|
+
minHeight: z.ZodNumber;
|
|
6591
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
6592
|
+
capability: z.ZodString;
|
|
6593
|
+
fallback: z.ZodOptional<z.ZodString>;
|
|
6594
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
6595
|
+
api: z.ZodString;
|
|
6596
|
+
replacement: z.ZodString;
|
|
6597
|
+
since: z.ZodString;
|
|
6598
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
6599
|
+
metric: z.ZodString;
|
|
6600
|
+
value: z.ZodNumber;
|
|
6601
|
+
threshold: z.ZodNumber;
|
|
6602
|
+
frameTime: z.ZodOptional<z.ZodNumber>;
|
|
6603
|
+
}, z.core.$strip>]>;
|
|
6604
|
+
timestamp: z.ZodNumber;
|
|
6605
|
+
}, z.core.$strip>;
|
|
6606
|
+
/**
|
|
6607
|
+
* Warning event map for typed event bus.
|
|
6608
|
+
*/
|
|
6609
|
+
interface WarningEventMap {
|
|
6610
|
+
warning: WarningEvent;
|
|
6611
|
+
}
|
|
6612
|
+
/**
|
|
6613
|
+
* Warning emitter type.
|
|
6614
|
+
*/
|
|
6615
|
+
type WarningEmitter = EventBus<WarningEventMap>;
|
|
6616
|
+
/**
|
|
6617
|
+
* Creates a new warning event emitter.
|
|
6618
|
+
*
|
|
6619
|
+
* @returns A new warning emitter
|
|
6620
|
+
*
|
|
6621
|
+
* @example
|
|
6622
|
+
* ```typescript
|
|
6623
|
+
* import { createWarningEmitter } from 'blecsd';
|
|
6624
|
+
*
|
|
6625
|
+
* const warnings = createWarningEmitter();
|
|
6626
|
+
*
|
|
6627
|
+
* // Listen for all warnings
|
|
6628
|
+
* warnings.on('warning', (event) => {
|
|
6629
|
+
* console.warn(`Warning: ${event.message}`);
|
|
6630
|
+
* });
|
|
6631
|
+
* ```
|
|
6632
|
+
*/
|
|
6633
|
+
declare function createWarningEmitter(): WarningEmitter;
|
|
6634
|
+
/**
|
|
6635
|
+
* Creates and emits a terminal too small warning.
|
|
6636
|
+
*
|
|
6637
|
+
* @param emitter - The warning emitter
|
|
6638
|
+
* @param width - Current terminal width
|
|
6639
|
+
* @param height - Current terminal height
|
|
6640
|
+
* @param minWidth - Minimum recommended width
|
|
6641
|
+
* @param minHeight - Minimum recommended height
|
|
6642
|
+
*
|
|
6643
|
+
* @example
|
|
6644
|
+
* ```typescript
|
|
6645
|
+
* import { emitTerminalTooSmallWarning } from 'blecsd';
|
|
6646
|
+
*
|
|
6647
|
+
* emitTerminalTooSmallWarning(warnings, 40, 15, 80, 24);
|
|
6648
|
+
* ```
|
|
6649
|
+
*/
|
|
6650
|
+
declare function emitTerminalTooSmallWarning(emitter: WarningEmitter, width: number, height: number, minWidth: number, minHeight: number): void;
|
|
6651
|
+
/**
|
|
6652
|
+
* Creates and emits an unsupported capability warning.
|
|
6653
|
+
*
|
|
6654
|
+
* @param emitter - The warning emitter
|
|
6655
|
+
* @param capability - The unsupported capability name
|
|
6656
|
+
* @param fallback - Optional fallback description
|
|
6657
|
+
*
|
|
6658
|
+
* @example
|
|
6659
|
+
* ```typescript
|
|
6660
|
+
* import { emitUnsupportedCapabilityWarning } from 'blecsd';
|
|
6661
|
+
*
|
|
6662
|
+
* emitUnsupportedCapabilityWarning(
|
|
6663
|
+
* warnings,
|
|
6664
|
+
* 'truecolor',
|
|
6665
|
+
* 'Falling back to 256-color mode'
|
|
6666
|
+
* );
|
|
6667
|
+
* ```
|
|
6668
|
+
*/
|
|
6669
|
+
declare function emitUnsupportedCapabilityWarning(emitter: WarningEmitter, capability: string, fallback?: string): void;
|
|
6670
|
+
/**
|
|
6671
|
+
* Creates and emits a deprecated API warning.
|
|
6672
|
+
*
|
|
6673
|
+
* @param emitter - The warning emitter
|
|
6674
|
+
* @param api - The deprecated API name
|
|
6675
|
+
* @param replacement - The replacement API
|
|
6676
|
+
* @param since - Version since deprecated
|
|
6677
|
+
*
|
|
6678
|
+
* @example
|
|
6679
|
+
* ```typescript
|
|
6680
|
+
* import { emitDeprecatedAPIWarning } from 'blecsd';
|
|
6681
|
+
*
|
|
6682
|
+
* emitDeprecatedAPIWarning(
|
|
6683
|
+
* warnings,
|
|
6684
|
+
* 'oldFunction()',
|
|
6685
|
+
* 'newFunction()',
|
|
6686
|
+
* 'v2.0.0'
|
|
6687
|
+
* );
|
|
6688
|
+
* ```
|
|
6689
|
+
*/
|
|
6690
|
+
declare function emitDeprecatedAPIWarning(emitter: WarningEmitter, api: string, replacement: string, since: string): void;
|
|
6691
|
+
/**
|
|
6692
|
+
* Creates and emits a performance issue warning.
|
|
6693
|
+
*
|
|
6694
|
+
* @param emitter - The warning emitter
|
|
6695
|
+
* @param metric - The performance metric name
|
|
6696
|
+
* @param value - The measured value
|
|
6697
|
+
* @param threshold - The threshold value
|
|
6698
|
+
* @param frameTime - Optional frame time in milliseconds
|
|
6699
|
+
*
|
|
6700
|
+
* @example
|
|
6701
|
+
* ```typescript
|
|
6702
|
+
* import { emitPerformanceWarning } from 'blecsd';
|
|
6703
|
+
*
|
|
6704
|
+
* emitPerformanceWarning(
|
|
6705
|
+
* warnings,
|
|
6706
|
+
* 'frame-time',
|
|
6707
|
+
* 35,
|
|
6708
|
+
* 16.67,
|
|
6709
|
+
* 35
|
|
6710
|
+
* );
|
|
6711
|
+
* ```
|
|
6712
|
+
*/
|
|
6713
|
+
declare function emitPerformanceWarning(emitter: WarningEmitter, metric: string, value: number, threshold: number, frameTime?: number): void;
|
|
6714
|
+
|
|
6338
6715
|
/**
|
|
6339
6716
|
* World adapter API for custom storage and query strategies.
|
|
6340
6717
|
*
|
|
@@ -6360,6 +6737,9 @@ type WorldAdapterType = 'bitecs' | 'custom';
|
|
|
6360
6737
|
/**
|
|
6361
6738
|
* World adapter interface.
|
|
6362
6739
|
*
|
|
6740
|
+
* The base interface provides `queryRenderables` for backwards compatibility.
|
|
6741
|
+
* Adapters may optionally support named queries via `queryByName`.
|
|
6742
|
+
*
|
|
6363
6743
|
* @example
|
|
6364
6744
|
* ```typescript
|
|
6365
6745
|
* import type { WorldAdapter } from 'blecsd';
|
|
@@ -6380,7 +6760,164 @@ interface WorldAdapter {
|
|
|
6380
6760
|
* @returns Array of renderable entities
|
|
6381
6761
|
*/
|
|
6382
6762
|
readonly queryRenderables: (world: World) => readonly Entity[];
|
|
6763
|
+
/**
|
|
6764
|
+
* Returns entities matching a named query, or undefined if
|
|
6765
|
+
* the query name is not registered.
|
|
6766
|
+
*
|
|
6767
|
+
* Only available on adapters that support named queries
|
|
6768
|
+
* (e.g. PackedQueryAdapter).
|
|
6769
|
+
*
|
|
6770
|
+
* @param name - The query name
|
|
6771
|
+
* @param world - The ECS world
|
|
6772
|
+
* @returns Array of entities, or undefined if query not registered
|
|
6773
|
+
*/
|
|
6774
|
+
readonly queryByName?: (name: string, world: World) => readonly Entity[] | undefined;
|
|
6775
|
+
}
|
|
6776
|
+
/**
|
|
6777
|
+
* Registration entry for a named PackedStore-backed query.
|
|
6778
|
+
*
|
|
6779
|
+
* @example
|
|
6780
|
+
* ```typescript
|
|
6781
|
+
* import type { PackedQueryRegistration } from 'blecsd';
|
|
6782
|
+
* import { Position, Renderable } from 'blecsd';
|
|
6783
|
+
*
|
|
6784
|
+
* const reg: PackedQueryRegistration = {
|
|
6785
|
+
* name: 'renderables',
|
|
6786
|
+
* components: [Position, Renderable],
|
|
6787
|
+
* };
|
|
6788
|
+
* ```
|
|
6789
|
+
*/
|
|
6790
|
+
interface PackedQueryRegistration {
|
|
6791
|
+
/** Unique name for the query */
|
|
6792
|
+
readonly name: string;
|
|
6793
|
+
/** Component set that defines the query */
|
|
6794
|
+
readonly components: readonly QueryTerm[];
|
|
6383
6795
|
}
|
|
6796
|
+
/**
|
|
6797
|
+
* Configuration for creating a PackedQueryAdapter.
|
|
6798
|
+
*
|
|
6799
|
+
* @example
|
|
6800
|
+
* ```typescript
|
|
6801
|
+
* import type { PackedQueryAdapterConfig } from 'blecsd';
|
|
6802
|
+
* import { Focusable, Interactive, Position, Renderable } from 'blecsd';
|
|
6803
|
+
*
|
|
6804
|
+
* const config: PackedQueryAdapterConfig = {
|
|
6805
|
+
* queries: [
|
|
6806
|
+
* { name: 'renderables', components: [Position, Renderable] },
|
|
6807
|
+
* { name: 'focusable', components: [Focusable] },
|
|
6808
|
+
* { name: 'interactive', components: [Interactive] },
|
|
6809
|
+
* ],
|
|
6810
|
+
* initialCapacity: 128,
|
|
6811
|
+
* };
|
|
6812
|
+
* ```
|
|
6813
|
+
*/
|
|
6814
|
+
interface PackedQueryAdapterConfig {
|
|
6815
|
+
/** Named queries to register */
|
|
6816
|
+
readonly queries: readonly PackedQueryRegistration[];
|
|
6817
|
+
/** Initial capacity for each PackedStore (default: 64) */
|
|
6818
|
+
readonly initialCapacity?: number;
|
|
6819
|
+
}
|
|
6820
|
+
/**
|
|
6821
|
+
* Extended adapter backed by PackedStores for cache-friendly iteration.
|
|
6822
|
+
*
|
|
6823
|
+
* Maintains a PackedStore<number> per registered query, updated via sync().
|
|
6824
|
+
* Use getQueryData/getQuerySize for zero-allocation hot-path iteration.
|
|
6825
|
+
*
|
|
6826
|
+
* @example
|
|
6827
|
+
* ```typescript
|
|
6828
|
+
* import { createPackedQueryAdapter, Position, Renderable, Focusable } from 'blecsd';
|
|
6829
|
+
*
|
|
6830
|
+
* const adapter = createPackedQueryAdapter({
|
|
6831
|
+
* queries: [
|
|
6832
|
+
* { name: 'renderables', components: [Position, Renderable] },
|
|
6833
|
+
* { name: 'focusable', components: [Focusable] },
|
|
6834
|
+
* ],
|
|
6835
|
+
* });
|
|
6836
|
+
*
|
|
6837
|
+
* // Each frame: sync, then query
|
|
6838
|
+
* adapter.sync(world);
|
|
6839
|
+
* const data = adapter.getQueryData('focusable');
|
|
6840
|
+
* for (let i = 0; i < adapter.getQuerySize('focusable'); i++) {
|
|
6841
|
+
* const eid = data[i];
|
|
6842
|
+
* // Process entity...
|
|
6843
|
+
* }
|
|
6844
|
+
* ```
|
|
6845
|
+
*/
|
|
6846
|
+
interface PackedQueryAdapter extends WorldAdapter {
|
|
6847
|
+
/** Looks up entities by registered query name. Returns undefined for unknown names. */
|
|
6848
|
+
readonly queryByName: (name: string, world: World) => readonly Entity[] | undefined;
|
|
6849
|
+
/**
|
|
6850
|
+
* Synchronizes all PackedStores with current bitecs query results.
|
|
6851
|
+
* Call once per frame before querying.
|
|
6852
|
+
*
|
|
6853
|
+
* @param world - The ECS world
|
|
6854
|
+
*/
|
|
6855
|
+
readonly sync: (world: World) => void;
|
|
6856
|
+
/**
|
|
6857
|
+
* Returns the dense data array for a named query (zero-allocation hot path).
|
|
6858
|
+
* Only elements at indices 0 through getQuerySize(name) - 1 are live.
|
|
6859
|
+
* Returns a frozen empty array for unknown query names.
|
|
6860
|
+
*
|
|
6861
|
+
* @param name - The query name
|
|
6862
|
+
* @returns Dense array of entity IDs
|
|
6863
|
+
*/
|
|
6864
|
+
readonly getQueryData: (name: string) => readonly number[];
|
|
6865
|
+
/**
|
|
6866
|
+
* Returns the number of entities in a named query's PackedStore.
|
|
6867
|
+
* Returns 0 for unknown query names.
|
|
6868
|
+
*
|
|
6869
|
+
* @param name - The query name
|
|
6870
|
+
* @returns Entity count
|
|
6871
|
+
*/
|
|
6872
|
+
readonly getQuerySize: (name: string) => number;
|
|
6873
|
+
/**
|
|
6874
|
+
* Returns all registered query names.
|
|
6875
|
+
*
|
|
6876
|
+
* @returns Frozen array of query names
|
|
6877
|
+
*/
|
|
6878
|
+
readonly getRegisteredQueries: () => readonly string[];
|
|
6879
|
+
}
|
|
6880
|
+
/**
|
|
6881
|
+
* Zod schema for PackedQueryRegistration.
|
|
6882
|
+
*
|
|
6883
|
+
* Validates the structural shape of a query registration.
|
|
6884
|
+
* Component references (QueryTerm) are opaque to Zod and validated
|
|
6885
|
+
* as unknown[].
|
|
6886
|
+
*
|
|
6887
|
+
* @example
|
|
6888
|
+
* ```typescript
|
|
6889
|
+
* import { PackedQueryRegistrationSchema } from 'blecsd';
|
|
6890
|
+
*
|
|
6891
|
+
* const result = PackedQueryRegistrationSchema.safeParse({
|
|
6892
|
+
* name: 'renderables',
|
|
6893
|
+
* components: [Position, Renderable],
|
|
6894
|
+
* });
|
|
6895
|
+
* ```
|
|
6896
|
+
*/
|
|
6897
|
+
declare const PackedQueryRegistrationSchema: z.ZodObject<{
|
|
6898
|
+
name: z.ZodString;
|
|
6899
|
+
components: z.ZodArray<z.ZodUnknown>;
|
|
6900
|
+
}, z.core.$strip>;
|
|
6901
|
+
/**
|
|
6902
|
+
* Zod schema for PackedQueryAdapterConfig.
|
|
6903
|
+
*
|
|
6904
|
+
* @example
|
|
6905
|
+
* ```typescript
|
|
6906
|
+
* import { PackedQueryAdapterConfigSchema } from 'blecsd';
|
|
6907
|
+
*
|
|
6908
|
+
* const result = PackedQueryAdapterConfigSchema.safeParse({
|
|
6909
|
+
* queries: [{ name: 'renderables', components: [Position, Renderable] }],
|
|
6910
|
+
* initialCapacity: 128,
|
|
6911
|
+
* });
|
|
6912
|
+
* ```
|
|
6913
|
+
*/
|
|
6914
|
+
declare const PackedQueryAdapterConfigSchema: z.ZodObject<{
|
|
6915
|
+
queries: z.ZodArray<z.ZodObject<{
|
|
6916
|
+
name: z.ZodString;
|
|
6917
|
+
components: z.ZodArray<z.ZodUnknown>;
|
|
6918
|
+
}, z.core.$strip>>;
|
|
6919
|
+
initialCapacity: z.ZodOptional<z.ZodNumber>;
|
|
6920
|
+
}, z.core.$strip>;
|
|
6384
6921
|
/**
|
|
6385
6922
|
* Default adapter used when no custom adapter is registered.
|
|
6386
6923
|
*
|
|
@@ -6456,6 +6993,67 @@ declare function getWorldAdapter(world: World): WorldAdapter;
|
|
|
6456
6993
|
* ```
|
|
6457
6994
|
*/
|
|
6458
6995
|
declare function clearWorldAdapter(world: World): void;
|
|
6996
|
+
/**
|
|
6997
|
+
* Creates a PackedQueryAdapter backed by PackedStores for cache-friendly iteration.
|
|
6998
|
+
*
|
|
6999
|
+
* Each registered query gets its own PackedStore<number> holding entity IDs.
|
|
7000
|
+
* Call sync(world) once per frame to reconcile stores with bitecs query results,
|
|
7001
|
+
* then use queryByName, getQueryData, or getQuerySize to read results.
|
|
7002
|
+
*
|
|
7003
|
+
* If no 'renderables' query is registered, one is auto-registered with
|
|
7004
|
+
* [Position, Renderable] to maintain backwards compatibility with queryRenderables.
|
|
7005
|
+
*
|
|
7006
|
+
* @param config - Adapter configuration with named queries
|
|
7007
|
+
* @returns A PackedQueryAdapter
|
|
7008
|
+
*
|
|
7009
|
+
* @example
|
|
7010
|
+
* ```typescript
|
|
7011
|
+
* import {
|
|
7012
|
+
* createPackedQueryAdapter,
|
|
7013
|
+
* setWorldAdapter,
|
|
7014
|
+
* Position,
|
|
7015
|
+
* Renderable,
|
|
7016
|
+
* Focusable,
|
|
7017
|
+
* } from 'blecsd';
|
|
7018
|
+
*
|
|
7019
|
+
* const adapter = createPackedQueryAdapter({
|
|
7020
|
+
* queries: [
|
|
7021
|
+
* { name: 'renderables', components: [Position, Renderable] },
|
|
7022
|
+
* { name: 'focusable', components: [Focusable] },
|
|
7023
|
+
* ],
|
|
7024
|
+
* initialCapacity: 256,
|
|
7025
|
+
* });
|
|
7026
|
+
*
|
|
7027
|
+
* setWorldAdapter(world, adapter);
|
|
7028
|
+
*
|
|
7029
|
+
* // Each frame:
|
|
7030
|
+
* adapter.sync(world);
|
|
7031
|
+
* const data = adapter.getQueryData('focusable');
|
|
7032
|
+
* for (let i = 0; i < adapter.getQuerySize('focusable'); i++) {
|
|
7033
|
+
* const eid = data[i];
|
|
7034
|
+
* // Process entity in dense cache-friendly order
|
|
7035
|
+
* }
|
|
7036
|
+
* ```
|
|
7037
|
+
*/
|
|
7038
|
+
declare function createPackedQueryAdapter(config: PackedQueryAdapterConfig): PackedQueryAdapter;
|
|
7039
|
+
/**
|
|
7040
|
+
* Type guard to check if an adapter is a PackedQueryAdapter.
|
|
7041
|
+
*
|
|
7042
|
+
* @param adapter - The adapter to check
|
|
7043
|
+
* @returns True if the adapter is a PackedQueryAdapter
|
|
7044
|
+
*
|
|
7045
|
+
* @example
|
|
7046
|
+
* ```typescript
|
|
7047
|
+
* import { getWorldAdapter, isPackedQueryAdapter } from 'blecsd';
|
|
7048
|
+
*
|
|
7049
|
+
* const adapter = getWorldAdapter(world);
|
|
7050
|
+
* if (isPackedQueryAdapter(adapter)) {
|
|
7051
|
+
* adapter.sync(world);
|
|
7052
|
+
* const data = adapter.getQueryData('renderables');
|
|
7053
|
+
* }
|
|
7054
|
+
* ```
|
|
7055
|
+
*/
|
|
7056
|
+
declare function isPackedQueryAdapter(adapter: WorldAdapter): adapter is PackedQueryAdapter;
|
|
6459
7057
|
|
|
6460
7058
|
/**
|
|
6461
7059
|
* Z-order management for entity layering.
|
|
@@ -6697,4 +7295,4 @@ declare function normalizeZIndices(world: World, parent: Entity): void;
|
|
|
6697
7295
|
*/
|
|
6698
7296
|
declare function resetZOrder(entity: Entity): void;
|
|
6699
7297
|
|
|
6700
|
-
export { type AbsolutePosition, type AdoptEvent, type ArchetypeDefinition, type ArchetypePoolConfig, type ArchetypePoolStats, type AttachEvent, type AutoPaddingData, BUILTIN_PHASE_NAMES, type BindingMatch, type BorderDockingContext, type BorderDockingOptions, type BorderEdge, type BorderStyleType, type BubbleResult, type BubbleableEvent, type BubbleableEventOptions, type CachedPosition, type CleanupCallback, type ClickableCache, type ClipRect, type ClipStack, Clipping, type ClippingData, type ClippingOptions, type ComponentDescriptor, type ComponentResetFn, type ComputedPositionData, type ConditionContext, type ConnectionFlags, DEFAULT_NAV_BINDINGS, DEFAULT_TEXT_BINDINGS, DEFAULT_WORLD_ADAPTER, DEFAULT_Z_INDEX, type DataValue, type DeserializeOptions, type DeserializeResult, type DestroyEvent, type DestroyOptions, type DetachEvent, type
|
|
7298
|
+
export { type AbsolutePosition, type AdoptEvent, type ArchetypeDefinition, type ArchetypePoolConfig, type ArchetypePoolStats, type AttachEvent, type AutoPaddingData, BUILTIN_PHASE_NAMES, type BindingMatch, type BorderDockingContext, type BorderDockingOptions, type BorderEdge, type BorderStyleType, BoxConfig, type BubbleResult, type BubbleableEvent, type BubbleableEventOptions, ButtonConfig, type CachedPosition, CheckboxConfig, type CleanupCallback, type ClickableCache, type ClipRect, type ClipStack, Clipping, type ClippingData, type ClippingOptions, type ComponentDescriptor, type ComponentResetFn, type ComputedPositionData, type ConditionContext, type ConnectionFlags, DEFAULT_NAV_BINDINGS, DEFAULT_TEXT_BINDINGS, DEFAULT_WORLD_ADAPTER, DEFAULT_Z_INDEX, type DataValue, type DeprecatedAPIMetadata, DeprecatedAPIMetadataSchema, type DeserializeOptions, type DeserializeResult, type DestroyEvent, type DestroyOptions, type DetachEvent, type DirtyStats, type DirtyTrackerData, type DockingBuffer, type DockingCell, type DynamicValue, type EffectConfig, type EffectivePaddingData, type EffectsConfig, type EmitDescendantsOptions, EmitDescendantsOptionsSchema, type EmitDescendantsResult, EmitDescendantsResultSchema, Entity, type EntityDataMap, type EntityHandle, type EntityPool, EntityValidationError, EventBus, EventMap, FormConfig, GetEntityEventBus, type HitTestOptions, type HitTestResult, INHERITING_PROPERTIES, InitPriority, type InitPriorityLevel, type InnerDimensions, type InnerPosition, InputConfig, JUNCTION_ASCII, JUNCTION_BOLD, JUNCTION_DOUBLE, JUNCTION_SINGLE, type Junction, type JunctionCharset, type KeyBinding, type KeyBindingRegistry, KeyBindingSchema, KeyBindingsArraySchema, type KeyLockFilter, type KeyLockOptions, type KeyLockState, type LazyInitFn, type LazyValue, type DirtyRect as LegacyDirtyRect, type LifecycleEvent, type LifecycleEventMap, type LifecycleEventName, ListConfig, LoopPhase, MAX_Z_INDEX, MIN_Z_INDEX, NON_INHERITING_PROPERTIES, Overflow, type OverflowValue, type PackedQueryAdapter, type PackedQueryAdapterConfig, PackedQueryAdapterConfigSchema, type PackedQueryRegistration, PackedQueryRegistrationSchema, type ParsedKey, type PerformanceIssueMetadata, PerformanceIssueMetadataSchema, type PhaseId, type PhaseManager, PositionCache, type PositionValue, PositionValueSchema, ProgressBarConfig, RadioButtonConfig, RadioSetConfig, type RecyclingSystemStats, type RelativePosition, type RemoveEvent, type ReparentEvent, type ResolvedEffect, SERIALIZATION_VERSION, type Scene, type SceneManager, type SceneTransition, ScreenConfig, SelectConfig, type SerializeOptions, type SerializedComponentData, type SerializedEntity, type SerializedWorld, type SetPositionCacheOptions, type ShrinkBox, SliderConfig, type StartupReport, type SubsystemEntry, System, type TerminalCapabilities, type TerminalTooSmallMetadata, TerminalTooSmallMetadataSchema, TextConfig, TextareaConfig, TextboxConfig, type TotalPadding, type TransitionState, type UnsupportedCapabilityMetadata, UnsupportedCapabilityMetadataSchema, type WarningEmitter, type WarningEvent, type WarningEventMap, WarningEventSchema, type WarningMetadata, WarningType, type WarningTypeValue, World, type WorldAdapter, type WorldAdapterType, ZOrder, acquireEntity, addComponent, addEntity, addIgnoredKeys, allocateEntity, applyCustomEffect, applyDisabledEffect, applyFocusEffect, applyHoverEffect, applyJunctions, applyKeyLockOptions, applyPressEffect, applyShrink, areAllKeysLocked, assertEntityAlive, bubbleEvent, calculateShrinkSize, centerPosition, clampPosition, clampToClipRect, clearAllArchetypePools, clearAllEffectConfigs, clearAllEntityData, clearAllPositionCaches, clearAllStoredStyles, clearArchetypePool, clearCapabilityCache, clearCleanupCallbacks, clearDestroyQueue, clearDockingContext, clearEffectState, clearEffects, clearEntityData, clearIgnoredKeys, clearLifecycleEventBuses, clearSerializableRegistry, clearStoredStyle, clearStyleCache, clearWorldAdapter, cloneSnapshot, computeInheritedStyle, createBorderDockingContext, createBoxEntity, createBubbleableEvent, createButtonEntity, createCheckboxEntity, createClickableCache, createClipRect, createClipStack, createEntityPool, createFadeTransition, createFormEntity, createInfiniteClipRect, createInputEntity, createKeyBindingRegistry, createKeyLockScope, createKeyLockState, createListEntity, createPackedQueryAdapter, createPhaseManager, createProgressBarEntity, createRadioButtonEntity, createRadioSetEntity, createSceneManager, createSceneSystem, createScreenEntity, createSelectEntity, createSlideTransition, createSliderEntity, createTextEntity, createTextareaEntity, createTextboxEntity, createWarningEmitter, createWorld, createWorldAdapter, deallocateEntity, defaultPhaseManager, deleteEntityData, deserializeWorld, deserializeWorldFromJSON, destroyAllChildren, destroyEntity, destroyWorld, detectAllJunctions, detectBorderStyle, detectCapabilities, detectJunctions, doesPropertyInherit, emitAdopt, emitAttach, emitDeprecatedAPIWarning, emitDescendants, emitDestroy, emitDetach, emitPerformanceWarning, emitRemove, emitReparent, emitTerminalTooSmallWarning, emitUnsupportedCapabilityWarning, entityExists, evaluateCondition, filterClickable, filterDirty, filterFocusable, filterVisible, filterVisibleDirty, findPropertySource, flushDestroyQueue, forceFullRedrawFlag, formatKey, formatKeyEvent, formatStartupReport, getAbsoluteEdges, getAbsolutePosition, getAllClickablesAt, getAllEntities, getAllEntityData, getAllHoverablesAt, getArchetypePoolStats, getAutoPadding, getBindingForAction, getBindingsForKey, getCacheGeneration, getCachedInnerHeight, getCachedInnerWidth, getChildEntities, getChildrenByZIndex, getClickableAt, getClickableCount, getClickableEntities, getClipRect, getClipRectHeight, getClipRectToAncestor, getClipRectWidth, getClipping, getComputedEffectStyle, getComputedPosition, getComputedStyles, getConnectionFlags, getCurrentClip, getDefaultStyle, getDescendantEntities, getDestroyQueueSize, getDirtyEntities, getDirtyRegionsInViewport, getDirtyStats, getEdgeCount, getEdgesAt, getEffectState, getEffectivePadding, getEffects, getEntityCount, getEntityData, getEntityDataCount, getEntityDataKeys, getEntityPoolCapacity, getGrabbedKeys, getHoverableAt, getIgnoredKeys, getInheritedProperty, getInnerDimensions, getInnerPosition, getJunctionChar, getJunctionCharset, getJunctionRenderData, getKeyLockFilter, getKeyLockState, getLifecycleEventBus, getLocalStyle, getLocalZ, getOriginalStyle, getOverflow, getPositionCache, getRecyclingStats, getRegisteredComponents, getRelativePosition, getRootEntities, getSerializable, getShrinkBox, getShrinkHeight, getShrinkWidth, getStartupReport, getStoredStyle, getTotalEffectivePadding, getTotalPadding, getWorldAdapter, getZIndex, grabKeys, hasAnyEffectApplied, hasAnyEntityData, hasAutoPadding, hasClickableAt, hasClipping, hasComponent, hasDirtyEntities, hasDisabledEffectApplied, hasEntityAutoPadding, hasEntityData, hasFocusEffectApplied, hasHoverEffectApplied, hasHoverableAt, hasPressEffectApplied, hasStoredStyle, hasValidPositionCache, hasValidStyleCache, hasZOrder, hitTest, hitTestAll, hitTestDetailed, initSubsystem, initSubsystemsUpTo, intersectClipRects, invalidateAllStyleCaches, invalidateClickableCache, invalidatePositionCache, invalidatePositionCacheTree, invalidateStyleCache, isBorderChar, isBuiltinPhase, isCacheDirty, isClipRectEmpty, isDefaultColor, isEntityAlive, isEntityDirty, isEntityValid, isJunctionChar, isKeyGrabbed, isKeyIgnored, isKeyLocked, isKeywordPosition, isMarkedForDestruction, isPackedQueryAdapter, isPercentagePosition, isPointInCachedBounds, isPointInEntity, isPointInInnerBounds, isPointVisible, isRectVisible, lazy, clearDirtyTracking as legacyClearDirtyTracking, createDirtyTracker as legacyCreateDirtyTracker, getDirtyRegions as legacyGetDirtyRegions, isCellDirty as legacyIsCellDirty, markCellDirty as legacyMarkCellDirty, markEntityDirty as legacyMarkEntityDirty, markRegionDirty as legacyMarkRegionDirty, removeEntityFromTracking as legacyRemoveEntityFromTracking, listBindings, lockAllKeys, markAllEntitiesDirty, matchEvent, matchesKey, mergeStyles, moveDown, moveUp, needsFullRedraw, normalizeZIndices, onAdopt, onAttach, onDestroy, onDetach, onRemove, onReparent, parseKeyString, parsePosition, parsePositionWithNegative, percentOffsetPosition, percentPosition, popClipRect, preallocateEntities, precomputeStyles, pushClipRect, query, queryBorder, queryContent, queryFocusable, queryHierarchy, queryInteractive, queryPadding, queryRenderable, queryScrollable, regionIntersectsDirty, registerArchetype, registerBinding, registerBindings, registerCleanupCallback, registerComponent, registerComponentName, registerEdge, registerRectBorder, registerSerializable, registerSubsystem, releaseAllGrabbedKeys, releaseEntity, releaseKeys, removeAllEffects, removeComponent, removeDisabledEffect, removeEntity, removeFocusEffect, removeHoverEffect, removeIgnoredKeys, removeLifecycleEventBus, removePressEffect, resetDisposalState, resetEntityPool, resetKeyLockState, resetSubsystems, resetWorld, resetZOrder, resizeDirtyTracker, resizeDockingContext, resolveEffectConfig, resolvePosition, resolvePositionClamped, resolveStyle, serializeWorld, serializeWorldToJSON, setAbsoluteBottom, setAbsoluteEdges, setAbsoluteLeft, setAbsolutePosition, setAbsoluteRight, setAbsoluteTop, setBack, setEffects, setEntityData, setEntityDataBulk, setFront, setIgnoredKeys, setKeyLockFilter, setLocalZ, setOverflow, setPositionCache, setRelativePosition, setWorldAdapter, setZIndex, shouldBlockKeyEvent, shouldClipContent, sortByDepth, sortByTabIndex, sortByZIndex, syncEffects, unlockAllKeys, unregisterArchetype, unregisterBinding, unregisterSerializable, updateCachedScrollBase, updateClickableCache, updateEntityBounds, updateEntityData, validateEntity, withStore };
|