@oasys/oecs 0.3.0 → 0.4.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/README.md +196 -267
- package/dist/array-CxbPyiHO.cjs +1 -0
- package/dist/array-uFR7Q8fU.js +132 -0
- package/dist/core/ecs/access_check.d.ts +77 -0
- package/dist/core/ecs/access_check.d.ts.map +1 -0
- package/dist/core/ecs/archetype.d.ts +474 -0
- package/dist/core/ecs/archetype.d.ts.map +1 -0
- package/dist/core/ecs/builtin_relations.d.ts +43 -0
- package/dist/core/ecs/builtin_relations.d.ts.map +1 -0
- package/dist/core/ecs/command_log.d.ts +113 -0
- package/dist/core/ecs/command_log.d.ts.map +1 -0
- package/dist/core/ecs/component.d.ts +106 -0
- package/dist/core/ecs/component.d.ts.map +1 -0
- package/dist/core/ecs/compute_backend.d.ts +37 -0
- package/dist/core/ecs/compute_backend.d.ts.map +1 -0
- package/dist/core/ecs/dispatch_trace.d.ts +93 -0
- package/dist/core/ecs/dispatch_trace.d.ts.map +1 -0
- package/dist/core/ecs/ecs.d.ts +533 -0
- package/dist/core/ecs/ecs.d.ts.map +1 -0
- package/dist/core/ecs/ecs_memory.d.ts +179 -0
- package/dist/core/ecs/ecs_memory.d.ts.map +1 -0
- package/dist/core/ecs/entity.d.ts +28 -0
- package/dist/core/ecs/entity.d.ts.map +1 -0
- package/dist/core/ecs/event.d.ts +54 -0
- package/dist/core/ecs/event.d.ts.map +1 -0
- package/dist/core/ecs/frame_trace.d.ts +133 -0
- package/dist/core/ecs/frame_trace.d.ts.map +1 -0
- package/dist/core/ecs/host_commands.d.ts +252 -0
- package/dist/core/ecs/host_commands.d.ts.map +1 -0
- package/dist/core/ecs/index.d.ts +41 -0
- package/dist/core/ecs/index.d.ts.map +1 -0
- package/dist/core/ecs/observer.d.ts +142 -0
- package/dist/core/ecs/observer.d.ts.map +1 -0
- package/dist/core/ecs/query.d.ts +557 -0
- package/dist/core/ecs/query.d.ts.map +1 -0
- package/dist/core/ecs/ref.d.ts +31 -0
- package/dist/core/ecs/ref.d.ts.map +1 -0
- package/dist/core/ecs/relation.d.ts +231 -0
- package/dist/core/ecs/relation.d.ts.map +1 -0
- package/dist/core/ecs/resource.d.ts +33 -0
- package/dist/core/ecs/resource.d.ts.map +1 -0
- package/dist/core/ecs/resume.d.ts +85 -0
- package/dist/core/ecs/resume.d.ts.map +1 -0
- package/dist/core/ecs/run_condition.d.ts +75 -0
- package/dist/core/ecs/run_condition.d.ts.map +1 -0
- package/dist/core/ecs/schedule.d.ts +133 -0
- package/dist/core/ecs/schedule.d.ts.map +1 -0
- package/dist/core/ecs/sparse_store.d.ts +107 -0
- package/dist/core/ecs/sparse_store.d.ts.map +1 -0
- package/dist/core/ecs/store.d.ts +1149 -0
- package/dist/core/ecs/store.d.ts.map +1 -0
- package/dist/core/ecs/store_layout_listener.d.ts +23 -0
- package/dist/core/ecs/store_layout_listener.d.ts.map +1 -0
- package/dist/core/ecs/system.d.ts +134 -0
- package/dist/core/ecs/system.d.ts.map +1 -0
- package/dist/core/ecs/utils/arrays.d.ts +7 -0
- package/dist/core/ecs/utils/arrays.d.ts.map +1 -0
- package/dist/core/ecs/utils/constants.d.ts +12 -0
- package/dist/core/ecs/utils/constants.d.ts.map +1 -0
- package/dist/core/ecs/utils/error.d.ts +51 -0
- package/dist/core/ecs/utils/error.d.ts.map +1 -0
- package/dist/core/reactive/array.d.ts +24 -0
- package/dist/core/reactive/array.d.ts.map +1 -0
- package/dist/core/reactive/index.cjs +1 -0
- package/dist/core/reactive/index.d.ts +10 -0
- package/dist/core/reactive/index.d.ts.map +1 -0
- package/dist/core/reactive/index.js +17 -0
- package/dist/core/reactive/interop.d.ts +19 -0
- package/dist/core/reactive/interop.d.ts.map +1 -0
- package/dist/core/reactive/kernel.d.ts +71 -0
- package/dist/core/reactive/kernel.d.ts.map +1 -0
- package/dist/core/reactive/map.d.ts +16 -0
- package/dist/core/reactive/map.d.ts.map +1 -0
- package/dist/core/reactive/struct.d.ts +10 -0
- package/dist/core/reactive/struct.d.ts.map +1 -0
- package/dist/core/store/__generated__/abi.d.ts +43 -0
- package/dist/core/store/__generated__/abi.d.ts.map +1 -0
- package/dist/core/store/action_ring.d.ts +136 -0
- package/dist/core/store/action_ring.d.ts.map +1 -0
- package/dist/core/store/allocator.d.ts +238 -0
- package/dist/core/store/allocator.d.ts.map +1 -0
- package/dist/core/store/buffer_backed_column.d.ts +69 -0
- package/dist/core/store/buffer_backed_column.d.ts.map +1 -0
- package/dist/core/store/column_store.d.ts +265 -0
- package/dist/core/store/column_store.d.ts.map +1 -0
- package/dist/core/store/command_dispatch.d.ts +52 -0
- package/dist/core/store/command_dispatch.d.ts.map +1 -0
- package/dist/core/store/command_ring.d.ts +107 -0
- package/dist/core/store/command_ring.d.ts.map +1 -0
- package/dist/core/store/descriptor.d.ts +80 -0
- package/dist/core/store/descriptor.d.ts.map +1 -0
- package/dist/core/store/entity_index.d.ts +108 -0
- package/dist/core/store/entity_index.d.ts.map +1 -0
- package/dist/core/store/event_ring.d.ts +95 -0
- package/dist/core/store/event_ring.d.ts.map +1 -0
- package/dist/core/store/extend.d.ts +109 -0
- package/dist/core/store/extend.d.ts.map +1 -0
- package/dist/core/store/grow.d.ts +39 -0
- package/dist/core/store/grow.d.ts.map +1 -0
- package/dist/core/store/header.d.ts +64 -0
- package/dist/core/store/header.d.ts.map +1 -0
- package/dist/core/store/index.d.ts +16 -0
- package/dist/core/store/index.d.ts.map +1 -0
- package/dist/core/store/region_table.d.ts +74 -0
- package/dist/core/store/region_table.d.ts.map +1 -0
- package/dist/core/store/snapshot.d.ts +43 -0
- package/dist/core/store/snapshot.d.ts.map +1 -0
- package/dist/core/store/state_hash.d.ts +38 -0
- package/dist/core/store/state_hash.d.ts.map +1 -0
- package/dist/core/store/store_regions.d.ts +38 -0
- package/dist/core/store/store_regions.d.ts.map +1 -0
- package/dist/extensions/editor/editor.d.ts +149 -0
- package/dist/extensions/editor/editor.d.ts.map +1 -0
- package/dist/extensions/editor/field_handle.d.ts +35 -0
- package/dist/extensions/editor/field_handle.d.ts.map +1 -0
- package/dist/extensions/editor/index.cjs +1 -0
- package/dist/extensions/editor/index.d.ts +21 -0
- package/dist/extensions/editor/index.d.ts.map +1 -0
- package/dist/extensions/editor/index.js +209 -0
- package/dist/extensions/reactive/ecs_sync.d.ts +210 -0
- package/dist/extensions/reactive/ecs_sync.d.ts.map +1 -0
- package/dist/extensions/reactive/index.cjs +1 -0
- package/dist/extensions/reactive/index.d.ts +23 -0
- package/dist/extensions/reactive/index.d.ts.map +1 -0
- package/dist/extensions/reactive/index.js +225 -0
- package/dist/extensions/solid/index.cjs +1 -0
- package/dist/extensions/solid/index.d.ts +6 -0
- package/dist/extensions/solid/index.d.ts.map +1 -0
- package/dist/extensions/solid/index.js +32 -0
- package/dist/extensions/solid/kernel_solid.d.ts +42 -0
- package/dist/extensions/solid/kernel_solid.d.ts.map +1 -0
- package/dist/index.cjs +2 -1
- package/dist/index.d.ts +16 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8563 -1233
- package/dist/interop-CT-REx0W.cjs +1 -0
- package/dist/interop-CcY6ASQc.js +18 -0
- package/dist/kernel-DgyrLFjW.js +227 -0
- package/dist/kernel-yWV3XnAb.cjs +1 -0
- package/dist/log/console_sink.d.ts +4 -0
- package/dist/log/console_sink.d.ts.map +1 -0
- package/dist/log/index.d.ts +3 -0
- package/dist/log/index.d.ts.map +1 -0
- package/dist/log/logger.d.ts +27 -0
- package/dist/log/logger.d.ts.map +1 -0
- package/dist/primitives.cjs +1 -0
- package/dist/primitives.d.ts +18 -0
- package/dist/primitives.d.ts.map +1 -0
- package/dist/primitives.js +44 -0
- package/dist/shared-BXSZnxx4.cjs +1 -0
- package/dist/shared-C678TAPY.js +99 -0
- package/dist/shared.cjs +1 -0
- package/dist/shared.d.ts +22 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +7 -0
- package/dist/topological_sort-DlRpSrxu.js +391 -0
- package/dist/topological_sort-WAT-VHb-.cjs +1 -0
- package/dist/type_primitives/assertions.d.ts +12 -8
- package/dist/type_primitives/assertions.d.ts.map +1 -1
- package/dist/type_primitives/binary_heap/binary_heap.d.ts +6 -2
- package/dist/type_primitives/binary_heap/binary_heap.d.ts.map +1 -1
- package/dist/type_primitives/bitset/bitset.d.ts +16 -4
- package/dist/type_primitives/bitset/bitset.d.ts.map +1 -1
- package/dist/type_primitives/brand.d.ts +6 -1
- package/dist/type_primitives/brand.d.ts.map +1 -1
- package/dist/type_primitives/error.d.ts +4 -0
- package/dist/type_primitives/error.d.ts.map +1 -1
- package/dist/type_primitives/index.d.ts +3 -0
- package/dist/type_primitives/index.d.ts.map +1 -1
- package/dist/type_primitives/sparse_map/sparse_map.d.ts +7 -3
- package/dist/type_primitives/sparse_map/sparse_map.d.ts.map +1 -1
- package/dist/type_primitives/sparse_set/sparse_set.d.ts +4 -0
- package/dist/type_primitives/sparse_set/sparse_set.d.ts.map +1 -1
- package/dist/type_primitives/topological_sort/topological_sort.d.ts +7 -3
- package/dist/type_primitives/topological_sort/topological_sort.d.ts.map +1 -1
- package/dist/type_primitives/typed_arrays/typed_arrays.d.ts +53 -16
- package/dist/type_primitives/typed_arrays/typed_arrays.d.ts.map +1 -1
- package/dist/utils/arrays.d.ts +1 -1
- package/dist/utils/arrays.d.ts.map +1 -1
- package/dist/utils/error.d.ts +2 -20
- package/dist/utils/error.d.ts.map +1 -1
- package/package.json +36 -9
- package/dist/archetype.d.ts +0 -101
- package/dist/archetype.d.ts.map +0 -1
- package/dist/component.d.ts +0 -45
- package/dist/component.d.ts.map +0 -1
- package/dist/ecs.d.ts +0 -104
- package/dist/ecs.d.ts.map +0 -1
- package/dist/entity.d.ts +0 -11
- package/dist/entity.d.ts.map +0 -1
- package/dist/event.d.ts +0 -30
- package/dist/event.d.ts.map +0 -1
- package/dist/query.d.ts +0 -90
- package/dist/query.d.ts.map +0 -1
- package/dist/ref.d.ts +0 -23
- package/dist/ref.d.ts.map +0 -1
- package/dist/resource.d.ts +0 -23
- package/dist/resource.d.ts.map +0 -1
- package/dist/schedule.d.ts +0 -45
- package/dist/schedule.d.ts.map +0 -1
- package/dist/store.d.ts +0 -118
- package/dist/store.d.ts.map +0 -1
- package/dist/system.d.ts +0 -16
- package/dist/system.d.ts.map +0 -1
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event ring — SPSC ring buffer for ECS signal/event payloads shared
|
|
3
|
+
* between TS and the Zig sim. (#247 / Phase 4 PR 4C)
|
|
4
|
+
*
|
|
5
|
+
* Same byte layout as the command ring (`command_ring.ts`); the two
|
|
6
|
+
* could share a primitive but keeping them separate makes the
|
|
7
|
+
* direction of flow explicit: command ring is WASM→TS (structural
|
|
8
|
+
* intents to drain post-tick); event ring is bidirectional during
|
|
9
|
+
* `tick()` — Zig systems push events, TS readers (or other Zig
|
|
10
|
+
* systems) drain.
|
|
11
|
+
*
|
|
12
|
+
* Layout (identical to command ring):
|
|
13
|
+
*
|
|
14
|
+
* [ write_head: u32 ] slot 0..N-1, monotonic (NOT slot-modulo)
|
|
15
|
+
* [ read_head: u32 ] slot 0..N-1, monotonic
|
|
16
|
+
* [ capacity: u32 ] slot count, power-of-two
|
|
17
|
+
* [ overflow_flag: u32 ] 0 = OK; 1 = sticky overflow witness
|
|
18
|
+
* [ slot 0: 16 B ] opCode: u8, payload: [15]u8
|
|
19
|
+
* [ slot 1: 16 B ] ...
|
|
20
|
+
*
|
|
21
|
+
* Op codes: event-def IDs (assigned by `ECS.registerEvent()` at
|
|
22
|
+
* registration time; #247 plan §required-FFI). The 0 op-code is
|
|
23
|
+
* reserved as the empty-slot marker so a zero-initialised SAB does not
|
|
24
|
+
* appear to hold a valid event. Event-def registration starts numbering
|
|
25
|
+
* from 1 to honour this; the engine integration in 4D+ enforces it.
|
|
26
|
+
*
|
|
27
|
+
* SPSC contract (Phase 4 scope, single host thread):
|
|
28
|
+
* - Producer: Zig sim `tick()` (post-4D) OR TS host (test producers /
|
|
29
|
+
* existing JS-side emitters bridged into the ring).
|
|
30
|
+
* - Consumer: TS host drain (post-4D) OR Zig system that reads
|
|
31
|
+
* queued events from a sibling system.
|
|
32
|
+
* - The two never run concurrently in Phase 4 (single host thread
|
|
33
|
+
* orchestrates both). Phase 5's worker offload promotes the head
|
|
34
|
+
* bumps to `Atomics.store`; that's an additive change without
|
|
35
|
+
* altering the layout.
|
|
36
|
+
*
|
|
37
|
+
* Payload size: fixed 15 bytes per slot. Today's events all fit
|
|
38
|
+
* (e.g. a 12-byte 3-field event, a 4-byte 1-field event, a 0-field
|
|
39
|
+
* signal). Larger payloads require a separate variable-size ring
|
|
40
|
+
* design — out of scope here.
|
|
41
|
+
*
|
|
42
|
+
* Region placement: between the entity-index region and the descriptor
|
|
43
|
+
* region so its offset is stable across descriptor / column growth.
|
|
44
|
+
* `header.event_ring_off` (the field promoted out of `_reserved0` in
|
|
45
|
+
* #245's reservation) carries the offset; 0 means absent.
|
|
46
|
+
*/
|
|
47
|
+
/** Total bytes for the ring header. Matches command ring exactly. */
|
|
48
|
+
export declare const EVENT_RING_HEADER_BYTES = 16;
|
|
49
|
+
/** Fixed slot size — 1-byte opCode + 15-byte payload. Matches
|
|
50
|
+
* command ring exactly. */
|
|
51
|
+
export declare const EVENT_RING_SLOT_BYTES = 16;
|
|
52
|
+
/** Default ring capacity in slots. 256 × 16 B = 4 KiB of slot data
|
|
53
|
+
* plus 16 B header. Mirrors `COMMAND_RING_DEFAULT_CAPACITY_SLOTS`. */
|
|
54
|
+
export declare const EVENT_RING_DEFAULT_CAPACITY_SLOTS = 256;
|
|
55
|
+
/** Byte offsets within the ring header. Mirrored on the Zig side in
|
|
56
|
+
* `packages/sim/src/event_ring.zig` — keep in sync. */
|
|
57
|
+
export declare const EVENT_RING_HEADER_OFFSETS: {
|
|
58
|
+
readonly write_head: 0;
|
|
59
|
+
readonly read_head: 4;
|
|
60
|
+
readonly capacity_slots: 8;
|
|
61
|
+
readonly overflow_flag: 12;
|
|
62
|
+
};
|
|
63
|
+
/** Op-code = `0` is reserved across the SAB layer as "empty slot"
|
|
64
|
+
* (see file header). Event-def IDs start at 1; `ECS.registerEvent`
|
|
65
|
+
* shifts to honour this when wiring SAB-backed channels in 4D+. */
|
|
66
|
+
export declare const EVENT_OP_EMPTY = 0;
|
|
67
|
+
/** Total bytes the ring occupies for `capacity_slots` slots. */
|
|
68
|
+
export declare function eventRingBytes(capacitySlots: number): number;
|
|
69
|
+
export declare class EventRingError extends Error {
|
|
70
|
+
constructor(message: string);
|
|
71
|
+
}
|
|
72
|
+
/** Initialise the ring header at `ringOff` in the SAB. Zeroes
|
|
73
|
+
* `write_head`, `read_head`, and `overflow_flag`; sets `capacity_slots`.
|
|
74
|
+
* Slot bytes are left as-is (callers normally allocate the ring on a
|
|
75
|
+
* fresh, zero-initialised SAB). */
|
|
76
|
+
export declare function initEventRing(view: DataView, ringOff: number, capacitySlots: number): void;
|
|
77
|
+
export declare function ringWriteHead(view: DataView, ringOff: number): number;
|
|
78
|
+
export declare function ringReadHead(view: DataView, ringOff: number): number;
|
|
79
|
+
export declare function ringCapacitySlots(view: DataView, ringOff: number): number;
|
|
80
|
+
export declare function ringOverflow(view: DataView, ringOff: number): boolean;
|
|
81
|
+
/** Pending event count = `(write_head - read_head) mod 2^32`. */
|
|
82
|
+
export declare function pendingEventCount(view: DataView, ringOff: number): number;
|
|
83
|
+
/** Push an event into the ring. Returns `false` on overflow and sets
|
|
84
|
+
* the (sticky) overflow flag. `opCode` must be > 0 — 0 is reserved as
|
|
85
|
+
* the empty-slot marker. Payload must be exactly 15 bytes. */
|
|
86
|
+
export declare function pushEvent(view: DataView, ringOff: number, opCode: number, payload: Uint8Array): boolean;
|
|
87
|
+
/** Read one event from the ring. Returns opCode (0 = empty/no event)
|
|
88
|
+
* and fills `outPayload` with 15 bytes. When 0 is returned,
|
|
89
|
+
* `outPayload` is untouched. */
|
|
90
|
+
export declare function popEvent(view: DataView, ringOff: number, outPayload: Uint8Array): number;
|
|
91
|
+
/** Drain every pending event, calling `handler` for each. Yields a
|
|
92
|
+
* freshly-copied 15-byte Uint8Array per event so handlers can hold the
|
|
93
|
+
* payload past the next iteration. Returns the count drained. */
|
|
94
|
+
export declare function drainEventRing(view: DataView, ringOff: number, handler: (opCode: number, payload: Uint8Array) => void): number;
|
|
95
|
+
//# sourceMappingURL=event_ring.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event_ring.d.ts","sourceRoot":"","sources":["../../../src/core/store/event_ring.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,qEAAqE;AACrE,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C;2BAC2B;AAC3B,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC;sEACsE;AACtE,eAAO,MAAM,iCAAiC,MAAM,CAAC;AAErD;uDACuD;AACvD,eAAO,MAAM,yBAAyB;;;;;CAK5B,CAAC;AAEX;;mEAEmE;AACnE,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC,gEAAgE;AAChE,wBAAgB,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAE5D;AAMD,qBAAa,cAAe,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI3B;AAED;;;mCAGmC;AACnC,wBAAgB,aAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI,CAU1F;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAErE;AACD,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEpE;AACD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEzE;AACD,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAErE;AAED,iEAAiE;AACjE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEzE;AAED;;8DAE8D;AAC9D,wBAAgB,SAAS,CACxB,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,UAAU,GACjB,OAAO,CA4BT;AAED;;gCAEgC;AAChC,wBAAgB,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,MAAM,CAiBxF;AAED;;iEAEiE;AACjE,wBAAgB,cAAc,CAC7B,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,KAAK,IAAI,GACpD,MAAM,CASR"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { ArchetypeGrowSpec } from './grow';
|
|
2
|
+
import { ArchetypeSpec, CreateColumnStoreOptions, ColumnStore } from './column_store';
|
|
3
|
+
import { BufferAllocator } from './allocator';
|
|
4
|
+
import { StoreRegionOffsetField } from './store_regions';
|
|
5
|
+
/**
|
|
6
|
+
* Derive `CreateColumnStoreOptions` from an old ColumnStore so a slow-path realloc
|
|
7
|
+
* preserves the same set of optional regions at the same byte offsets in the
|
|
8
|
+
* new SAB. Without this, an extend / grow would silently drop a region — the
|
|
9
|
+
* command ring's pending commands, every entity placement in the index, etc.
|
|
10
|
+
* would be lost.
|
|
11
|
+
*
|
|
12
|
+
* Walks `STORE_PREFIX_REGIONS`: each present region's `readOptions` replays the
|
|
13
|
+
* exact capacity the engine configured (regions may carry non-default sizes),
|
|
14
|
+
* not just the default. Live state (write_head, length, …) is preserved
|
|
15
|
+
* separately via `snapshotPrefixRegions`.
|
|
16
|
+
*
|
|
17
|
+
* Also re-applies the descriptor-region headroom policy
|
|
18
|
+
* (`reservedDescriptorBytes`, #541). Unlike the prefix regions this is NOT
|
|
19
|
+
* read from the SAB bytes — it's a JS-side policy carried on
|
|
20
|
+
* `ColumnStoreInternal._reservedDescriptorBytes` — but it belongs here for the
|
|
21
|
+
* same reason: without it the realloc'd store drops to zero descriptor
|
|
22
|
+
* headroom and every later `extendColumnStore` takes the slow path forever.
|
|
23
|
+
* Re-reserving the same margin (additive, see `planLayout`) keeps the #237
|
|
24
|
+
* in-place fast path alive across reallocs.
|
|
25
|
+
*/
|
|
26
|
+
export declare function optionsFromOld(old: ColumnStore): CreateColumnStoreOptions;
|
|
27
|
+
/** A prefix-region snapshot: the live bytes of every present region from the
|
|
28
|
+
* old SAB. `mechanism` is keyed by the `StoreHeader` field holding a mechanism
|
|
29
|
+
* region's offset; `consumer` is keyed by `region_id` (consumer regions have no
|
|
30
|
+
* named header field). Pairs `snapshotPrefixRegions` with
|
|
31
|
+
* `restorePrefixRegions`. */
|
|
32
|
+
export interface PrefixRegionSnapshot {
|
|
33
|
+
readonly mechanism: Map<StoreRegionOffsetField, Uint8Array>;
|
|
34
|
+
readonly consumer: Map<number, Uint8Array>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Snapshot the live bytes of every present region — both engine MECHANISM
|
|
38
|
+
* regions (STORE_PREFIX_REGIONS) and CONSUMER regions (the region-table
|
|
39
|
+
* directory) — from the old SAB BEFORE any allocator call that may detach
|
|
40
|
+
* views. Each entry is a heap `Uint8Array` copy (via `slice()`) so it survives
|
|
41
|
+
* an allocator-induced detach; `restorePrefixRegions` places it back at the
|
|
42
|
+
* matching offset in the new SAB.
|
|
43
|
+
*
|
|
44
|
+
* Header bytes themselves are NOT snapshotted — `createColumnStore` writes the
|
|
45
|
+
* header (and the region-table directory) from scratch with the correct
|
|
46
|
+
* view_stamp (bumped after this call) and offsets.
|
|
47
|
+
*/
|
|
48
|
+
export declare function snapshotPrefixRegions(old: ColumnStore): PrefixRegionSnapshot;
|
|
49
|
+
/** Restore prefix-region byte snapshots into `newStore` at the matching
|
|
50
|
+
* region offsets. Pairs with `snapshotPrefixRegions`. The new SAB's regions
|
|
51
|
+
* were sized identically by `optionsFromOld`, so each snapshot lands at the
|
|
52
|
+
* same length its source had — mechanism regions at their named header offset,
|
|
53
|
+
* consumer regions at the offset the rebuilt region-table resolves their id to. */
|
|
54
|
+
export declare function restorePrefixRegions(newStore: ColumnStore, snap: PrefixRegionSnapshot): void;
|
|
55
|
+
/**
|
|
56
|
+
* Snapshot per-archetype live column bytes from `old` BEFORE any
|
|
57
|
+
* subsequent allocator call may detach the underlying typed-array views.
|
|
58
|
+
* Returned shape: `{ archetype_id → Uint8Array[] }`, one entry per
|
|
59
|
+
* column in `columnsInOrder`. Each `Uint8Array` is a fresh copy
|
|
60
|
+
* (not a view) so it survives a `WebAssembly.Memory.grow`. Archetypes
|
|
61
|
+
* with `row_count === 0` are omitted — nothing to copy.
|
|
62
|
+
*
|
|
63
|
+
* Shared with `growColumnStore`; both functions need the same
|
|
64
|
+
* snapshot-before-allocate pattern under the wasm-memory allocator.
|
|
65
|
+
*/
|
|
66
|
+
export declare function snapshotLiveColumns(old: ColumnStore, rowCountsById: Map<number, number>): Map<number, Uint8Array[]>;
|
|
67
|
+
/**
|
|
68
|
+
* Write per-archetype column snapshots produced by `snapshotLiveColumns`
|
|
69
|
+
* into `newStore`'s column views. The snapshot's column ORDER must match
|
|
70
|
+
* the new archetype's `columnsInOrder` (extend / grow guarantee this
|
|
71
|
+
* because they carry the column spec forward unchanged).
|
|
72
|
+
*/
|
|
73
|
+
export declare function restoreColumnSnapshots(newStore: ColumnStore, snapshots: Map<number, Uint8Array[]>): void;
|
|
74
|
+
export interface ExtendPlan {
|
|
75
|
+
/** Archetypes to append. Each `archetype_id` MUST be absent from
|
|
76
|
+
* `old.archetypes`; collisions throw `StoreExtendError`. */
|
|
77
|
+
readonly newArchetypes: readonly ArchetypeSpec[];
|
|
78
|
+
/** Per-existing-archetype live row counts. Same shape as
|
|
79
|
+
* `GrowPlan.archetypes` so callers can reuse plan-building helpers.
|
|
80
|
+
* Omitted or `0` ⇒ no rows to copy (the archetype is empty). */
|
|
81
|
+
readonly existing?: readonly ArchetypeGrowSpec[];
|
|
82
|
+
}
|
|
83
|
+
export interface ExtendResult {
|
|
84
|
+
readonly store: ColumnStore;
|
|
85
|
+
readonly oldViewStamp: number;
|
|
86
|
+
readonly newViewStamp: number;
|
|
87
|
+
/** True when the in-place fast path (#237 Option A) was taken: the SAB
|
|
88
|
+
* instance is reused, existing column TypedArray views are unchanged,
|
|
89
|
+
* and callers may skip `refreshViews` on every pre-existing
|
|
90
|
+
* Archetype. False when the slow path ran (fresh SAB or wasm-memory
|
|
91
|
+
* grow with detached views); callers MUST refresh every Archetype's
|
|
92
|
+
* SAB-backed columns from the returned `store` before reading them. */
|
|
93
|
+
readonly viewsPreserved: boolean;
|
|
94
|
+
}
|
|
95
|
+
export declare class StoreExtendError extends Error {
|
|
96
|
+
constructor(message: string);
|
|
97
|
+
}
|
|
98
|
+
/** Allocate a new SAB sized for `old` + `plan.newArchetypes`, copy
|
|
99
|
+
* existing rows, bump `view_stamp`.
|
|
100
|
+
*
|
|
101
|
+
* `allocator` (PR 3D / #234): pluggable buffer source forwarded into
|
|
102
|
+
* `createColumnStore`. When the allocator is `wasmMemoryAllocator`,
|
|
103
|
+
* `memory.grow` may detach `old`'s typed-array views before the copy
|
|
104
|
+
* runs — so live rows are snapshotted into heap `Uint8Array`s BEFORE the
|
|
105
|
+
* allocator call and restored into the new views afterwards. The cost
|
|
106
|
+
* is one extra heap allocation per live archetype-column; negligible
|
|
107
|
+
* compared to the SAB walk itself. */
|
|
108
|
+
export declare function extendColumnStore(old: ColumnStore, plan: ExtendPlan, allocator?: BufferAllocator): ExtendResult;
|
|
109
|
+
//# sourceMappingURL=extend.d.ts.map
|
|
@@ -0,0 +1 @@
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AAM,WAAW,UAAU;IAC1B;gEAC4D;IAC5D,QAAQ,CAAC,aAAa,EAAE,SAAS,aAAa,EAAE,CAAC;IACjD;;oEAEgE;IAChE,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;CACjD;AAED,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B;;;;;2EAKuE;IACvE,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;CACjC;AAED,qBAAa,gBAAiB,SAAQ,KAAK;gBAC9B,OAAO,EAAE,MAAM;CAI3B;AAED;;;;;;;;;sCASsC;AACtC,wBAAgB,iBAAiB,CAChC,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,UAAU,EAChB,SAAS,CAAC,EAAE,eAAe,GACzB,YAAY,CAoLd"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ColumnStore } from './column_store';
|
|
2
|
+
import { BufferAllocator } from './allocator';
|
|
3
|
+
/** Per-archetype growth input. The caller picks the new `row_capacity` and
|
|
4
|
+
* declares the current live `row_count` so we know how many rows to copy. */
|
|
5
|
+
export interface ArchetypeGrowSpec {
|
|
6
|
+
readonly archetypeId: number;
|
|
7
|
+
readonly newRowCapacity: number;
|
|
8
|
+
readonly rowCount: number;
|
|
9
|
+
}
|
|
10
|
+
export interface GrowPlan {
|
|
11
|
+
readonly archetypes: readonly ArchetypeGrowSpec[];
|
|
12
|
+
}
|
|
13
|
+
/** Returned alongside the new `ColumnStore` so callers can sanity-check the
|
|
14
|
+
* grow (and so tests can assert it without re-reading the SAB). */
|
|
15
|
+
export interface GrowResult {
|
|
16
|
+
readonly store: ColumnStore;
|
|
17
|
+
readonly oldViewStamp: number;
|
|
18
|
+
readonly newViewStamp: number;
|
|
19
|
+
/** True when the in-place fast path ran: every archetype EXCEPT those in
|
|
20
|
+
* `grownArchetypeIds` kept its column views, so the caller only needs to
|
|
21
|
+
* `refreshViews` the grown ones. False on the realloc path, where the
|
|
22
|
+
* whole store moved and every view must be refreshed. */
|
|
23
|
+
readonly viewsPreserved: boolean;
|
|
24
|
+
/** Archetype ids whose columns were relocated (in-place path). Empty on
|
|
25
|
+
* the realloc path. */
|
|
26
|
+
readonly grownArchetypeIds: readonly number[];
|
|
27
|
+
}
|
|
28
|
+
export declare class StoreGrowError extends Error {
|
|
29
|
+
constructor(message: string);
|
|
30
|
+
}
|
|
31
|
+
/** Allocate a new SAB sized for `plan`, copy live rows from `old`, bump
|
|
32
|
+
* `view_stamp`. With the default allocator the old SAB is untouched and
|
|
33
|
+
* callers may continue reading from it until they finish swapping in
|
|
34
|
+
* the new views. With a `wasmMemoryAllocator`, `old`'s typed-array
|
|
35
|
+
* views may be detached as soon as `createColumnStore` returns — live
|
|
36
|
+
* data is snapshotted before the allocator call to make both code paths
|
|
37
|
+
* behave identically from the caller's perspective. (PR 3D / #234) */
|
|
38
|
+
export declare function growColumnStore(old: ColumnStore, plan: GrowPlan, allocator?: BufferAllocator): GrowResult;
|
|
39
|
+
//# sourceMappingURL=grow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grow.d.ts","sourceRoot":"","sources":["../../../src/core/store/grow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAUH,OAAO,EAQN,KAAK,WAAW,EAEhB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AASnD;6EAC6E;AAC7E,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,QAAQ;IACxB,QAAQ,CAAC,UAAU,EAAE,SAAS,iBAAiB,EAAE,CAAC;CAClD;AAED;mEACmE;AACnE,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B;;;6DAGyD;IACzD,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC;2BACuB;IACvB,QAAQ,CAAC,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9C;AA4KD,qBAAa,cAAe,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI3B;AAED;;;;;;sEAMsE;AACtE,wBAAgB,eAAe,CAC9B,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,QAAQ,EACd,SAAS,CAAC,EAAE,eAAe,GACzB,UAAU,CAgIZ"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { STORE_MAGIC, SIM_ABI_VERSION, STORE_HEADER_BYTES, STORE_HEADER_OFFSETS, REGION_TABLE_ENTRY_BYTES, REGION_TABLE_ENTRY_OFFSETS } from './__generated__/abi';
|
|
2
|
+
export { STORE_MAGIC, SIM_ABI_VERSION, STORE_HEADER_BYTES, STORE_HEADER_OFFSETS, REGION_TABLE_ENTRY_BYTES, REGION_TABLE_ENTRY_OFFSETS };
|
|
3
|
+
export interface StoreHeader {
|
|
4
|
+
/** Magic value `STORE_MAGIC`; used to detect a stale or foreign buffer
|
|
5
|
+
* before any other field is trusted. */
|
|
6
|
+
readonly magic: number;
|
|
7
|
+
/** ABI version; mismatch means the WASM and TS disagree on layout and
|
|
8
|
+
* the SAB must not be used. */
|
|
9
|
+
readonly simAbiVersion: number;
|
|
10
|
+
/** Monotonic; incremented every time the host reallocates the SAB.
|
|
11
|
+
* Cached TypedArray views become stale on bump. (#171 §8.1) */
|
|
12
|
+
readonly viewStamp: number;
|
|
13
|
+
/** Total SAB size in bytes. */
|
|
14
|
+
readonly capacity: number;
|
|
15
|
+
/** Number of archetype regions described by the layout descriptor. */
|
|
16
|
+
readonly archetypeCount: number;
|
|
17
|
+
/** Byte offset into the SAB where the layout descriptor region starts. */
|
|
18
|
+
readonly layoutDescriptorOff: number;
|
|
19
|
+
/** Byte offset of the WASM→TS command ring header. (#171 §7.5) */
|
|
20
|
+
readonly commandRingOff: number;
|
|
21
|
+
/** Byte offset of the TS→WASM action ring header. (#171 §7.5, Phase 5) */
|
|
22
|
+
readonly actionRingOff: number;
|
|
23
|
+
/** Byte offset of the entity-index region (entityId → archetype_id,
|
|
24
|
+
* row, generation lookup). 0 means absent — fixtures and bare-SAB
|
|
25
|
+
* tests that don't need the index see the v1 layout (the engine's
|
|
26
|
+
* `Store` always allocates one). (#245 / Phase 4 PR 4B) */
|
|
27
|
+
readonly entityIndexOff: number;
|
|
28
|
+
/** Byte offset of the event ring region (ECS signal payloads shared
|
|
29
|
+
* with the Zig sim). 0 means absent. (#247 / Phase 4 PR 4C) */
|
|
30
|
+
readonly eventRingOff: number;
|
|
31
|
+
/** Byte offset of the region-table directory — a `RegionTableEntry[]`
|
|
32
|
+
* (`(region_id, byte_offset, byte_length)` triples) holding one entry
|
|
33
|
+
* per consumer-declared region. 0 means no consumer regions were
|
|
34
|
+
* declared. The engine treats `region_id` as opaque; a consumer resolves
|
|
35
|
+
* its region with `findRegionOffset(view, header, id)` (TS) /
|
|
36
|
+
* `abi.find_region(header_addr, id)` (Zig). Replaces the five game-named
|
|
37
|
+
* offset fields (`terrain_off`/`spatial_grid_off`/… ) the SAB header
|
|
38
|
+
* used to hard-code. (#623 — de-game the SAB substrate; ADR-0018.) */
|
|
39
|
+
readonly regionTableOff: number;
|
|
40
|
+
/** Number of `RegionTableEntry` records at `region_table_off`. (#623) */
|
|
41
|
+
readonly regionTableCount: number;
|
|
42
|
+
/** Byte offset of the sim-bindings region — an opaque block of `u16`
|
|
43
|
+
* `(component_id, field_id)` IDs (layout owned by the game, in
|
|
44
|
+
* `@internal/sim`'s `sim_bindings.ts` / `bindings.zig`). The host writes it
|
|
45
|
+
* once per layout via `write_sim_bindings`; the Zig per-system exports
|
|
46
|
+
* (`tick_cooldown_ready` / `tick_movement_tick` / `tick_faith_production`
|
|
47
|
+
* and the batched `tick_all`) read their IDs from here instead of taking
|
|
48
|
+
* them as call args. Present only when the consumer opts into a WASM backend
|
|
49
|
+
* by passing `bindingsRegionBytes` to `createColumnStore`; 0 = absent (a
|
|
50
|
+
* pure-TS game pays nothing for this region). The size is a runtime input,
|
|
51
|
+
* not an engine ABI constant, since #625. (v5 / "SAB-is-the-interface".) */
|
|
52
|
+
readonly bindingsOff: number;
|
|
53
|
+
}
|
|
54
|
+
export declare function writeStoreHeader(view: DataView, h: StoreHeader): void;
|
|
55
|
+
export declare function readStoreHeader(view: DataView): StoreHeader;
|
|
56
|
+
/** Increment `view_stamp` in place after a host-side SAB reallocation. The
|
|
57
|
+
* monotonic counter is the trigger for cached-view invalidation on the TS
|
|
58
|
+
* side and for re-pointing in WASM. (#171 §8.1) */
|
|
59
|
+
export declare function bumpViewStamp(view: DataView): number;
|
|
60
|
+
/** True iff the buffer's first four bytes are `STORE_MAGIC` AND the ABI
|
|
61
|
+
* version matches the current build. Used by both TS and WASM as a
|
|
62
|
+
* pre-flight before treating any other field as meaningful. */
|
|
63
|
+
export declare function isValidSab(view: DataView): boolean;
|
|
64
|
+
//# sourceMappingURL=header.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../../src/core/store/header.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkFG;AAoBH,OAAO,EACN,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,wBAAwB,EACxB,0BAA0B,EAC1B,MAAM,qB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Q,GAAG,OAAO,CAKlD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { STORE_MAGIC, SIM_ABI_VERSION, STORE_HEADER_BYTES, STORE_HEADER_OFFSETS, REGION_TABLE_ENTRY_BYTES, REGION_TABLE_ENTRY_OFFSETS, type StoreHeader, writeStoreHeader, readStoreHeader, bumpViewStamp, isValidSab } from './header';
|
|
2
|
+
export { type StoreRegionSpec, type RegionTableEntry, type ColumnStoreRegionHandle, RegionRegistryError, regionTableBytes, validateRegionSpecs, writeRegionTableEntry, readRegionTableEntry, writeRegionTable, readRegionTable, readHeaderRegionTable, findRegionOffset, findRegionEntry } from './region_table';
|
|
3
|
+
export { TYPE_TAG, type TypeTagValue, TYPE_TAG_STRIDE, TYPED_ARRAY_TAG_TO_TYPE_TAG, COLUMN_DESCRIPTOR_BYTES, COLUMN_DESCRIPTOR_OFFSETS, type ColumnDescriptor, writeColumnDescriptor, readColumnDescriptor, ARCHETYPE_DESCRIPTOR_HEADER_BYTES, ARCHETYPE_DESCRIPTOR_OFFSETS, COMPONENT_MASK_WORDS, STORE_DESCRIPTOR_COMPONENT_LIMIT, type ArchetypeDescriptor, archetypeDescriptorBytes, writeArchetypeDescriptor, readArchetypeDescriptor, writeLayoutDescriptorRegion, readLayoutDescriptorRegion, layoutDescriptorRegionBytes } from './descriptor';
|
|
4
|
+
export { type ColumnSpec, type ArchetypeSpec, type ColumnView, type ArchetypeViews, type ColumnStore, type AnyTypedArray, type CreateColumnStoreOptions, alignUp, buildArchetypeViews, columnKey, createColumnStore, StoreLayoutOverflowError, STORE_MAX_BYTE_OFFSET, COMMAND_RING_DEFAULT_CAPACITY_SLOTS, ENTITY_INDEX_DEFAULT_CAPACITY, EVENT_RING_DEFAULT_CAPACITY_SLOTS } from './column_store';
|
|
5
|
+
export { EVENT_OP_EMPTY, EVENT_RING_HEADER_BYTES, EVENT_RING_SLOT_BYTES, EVENT_RING_HEADER_OFFSETS, EventRingError, drainEventRing, eventRingBytes, initEventRing, pendingEventCount, popEvent, pushEvent, ringCapacitySlots as eventRingCapacitySlots, ringOverflow as eventRingOverflow, ringReadHead as eventRingReadHead, ringWriteHead as eventRingWriteHead } from './event_ring';
|
|
6
|
+
export { ENTITY_INDEX_HEADER_BYTES, ENTITY_INDEX_BYTES_PER_SLOT, ENTITY_INDEX_HEADER_OFFSETS, EntityIndexError, buildEntityIndexViews, entityIndexCapacity, entityIndexLength, entityIndexRegionBytes, initEntityIndexRegion, setEntityIndexLength } from './entity_index';
|
|
7
|
+
export { COMMAND_OP_EMPTY, COMMAND_RING_HEADER_BYTES, COMMAND_RING_SLOT_BYTES, COMMAND_RING_HEADER_OFFSETS, CommandRingError, commandRingBytes, drainCommandRing, initCommandRing, pendingCommandCount, popCommand, pushCommand, ringCapacitySlots, ringOverflow, ringReadHead, ringWriteHead } from './command_ring';
|
|
8
|
+
export { type PayloadCodec, CommandDispatcher } from './command_dispatch';
|
|
9
|
+
export { BufferBackedColumn, StoreColumnOverflowError } from './buffer_backed_column';
|
|
10
|
+
export { type ArchetypeGrowSpec, type GrowPlan, type GrowResult, StoreGrowError, growColumnStore } from './grow';
|
|
11
|
+
export { type ExtendPlan, type ExtendResult, StoreExtendError, extendColumnStore, snapshotLiveColumns, restoreColumnSnapshots } from './extend';
|
|
12
|
+
export { type BufferAllocator, type InPlaceBufferAllocator, StoreCapExceededError, SabUnavailableError, DEFAULT_SAB_ALLOCATOR, wasmMemoryAllocator, growableSabAllocator, heapArraybufferAllocator } from './allocator';
|
|
13
|
+
export { StoreRestoreError, snapshotColumnStore, restoreColumnStore } from './snapshot';
|
|
14
|
+
export { FNV1A_OFFSET_BASIS, FNV1A_PRIME, fnv1a32, fnv1aStep, fnv1aStepWord, columnStoreStateHash } from './state_hash';
|
|
15
|
+
export { ACTION_RING_DEFAULT_CAPACITY_SLOTS, ACTION_RING_HEADER_BYTES, ACTION_RING_HEADER_OFFSETS, ACTION_RING_MAX_PAYLOAD_BYTES, ACTION_RING_SLOT_BYTES, ActionRingError, actionRingBytes, actionRingCapacitySlots, actionRingOverflow, actionRingReadHead, actionRingWriteHead, clearActionRingOverflow, drainActionRing, initActionRing, pendingActionCount, popAction, pushAction } from './action_ring';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/store/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,wBAAwB,EACxB,0BAA0B,EAC1B,KAAK,WAAW,EAChB,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,UAAU,EACV,MAAM,UAAU,CAAC;AAKlB,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACN,QAAQ,EACR,KAAK,YAAY,EACjB,eAAe,EACf,2BAA2B,EAC3B,uBAAuB,EACvB,yBAAyB,EACzB,KAAK,gBAAgB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,iCAAiC,EACjC,4BAA4B,EAC5B,oBAAoB,EACpB,gCAAgC,EAChC,KAAK,mBAAmB,EACxB,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,2BAA2B,EAC3B,0BAA0B,EAC1B,2BAA2B,EAC3B,MAAM,cAAc,CAAC;AAEtB,OAAO,EACN,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAC7B,OAAO,EACP,mBAAmB,EACnB,SAAS,EACT,iBAAiB,EACjB,wBAAwB,EACxB,q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,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAExF,OAAO,EACN,kBAAkB,EAClB,WAAW,EACX,OAAO,EACP,SAAS,EACT,aAAa,EACb,oBAAoB,EACpB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACN,kCAAkC,EAClC,wBAAwB,EACxB,0BAA0B,EAC1B,6BAA6B,EAC7B,sBAAsB,EACtB,eAAe,EACf,eAAe,EACf,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { REGION_TABLE_ENTRY_BYTES, REGION_TABLE_ENTRY_OFFSETS } from './__generated__/abi';
|
|
2
|
+
export { REGION_TABLE_ENTRY_BYTES, REGION_TABLE_ENTRY_OFFSETS };
|
|
3
|
+
/** A consumer-declared SAB region. The consumer owns `id` (a nonzero integer,
|
|
4
|
+
* distinct within its region set, that it also resolves on the read side),
|
|
5
|
+
* computes `bytes`, and seeds the region header + contents in `init`.
|
|
6
|
+
*
|
|
7
|
+
* `init` runs ONCE at first allocation. Across a SAB grow/extend the region's
|
|
8
|
+
* live bytes are snapshotted and restored verbatim (the table is
|
|
9
|
+
* self-describing), so `init` is not re-run — a consumer must not rely on it
|
|
10
|
+
* firing per realloc. */
|
|
11
|
+
export interface StoreRegionSpec {
|
|
12
|
+
/** Consumer-owned region id (nonzero, distinct). Written to the directory;
|
|
13
|
+
* resolved by the consumer via `findRegionOffset` / `abi.find_region`. */
|
|
14
|
+
readonly id: number;
|
|
15
|
+
/** Human label for diagnostics / the self-documenting directory dump. */
|
|
16
|
+
readonly name: string;
|
|
17
|
+
/** Byte size to allocate for this region (consumer computes from its knobs).
|
|
18
|
+
* Must be > 0. */
|
|
19
|
+
readonly bytes: number;
|
|
20
|
+
/** Initialise the region header + seed bytes at absolute byte offset `off`. */
|
|
21
|
+
readonly init: (view: DataView, off: number) => void;
|
|
22
|
+
}
|
|
23
|
+
/** One decoded directory record. */
|
|
24
|
+
export interface RegionTableEntry {
|
|
25
|
+
readonly regionId: number;
|
|
26
|
+
readonly byteOffset: number;
|
|
27
|
+
readonly byteLength: number;
|
|
28
|
+
}
|
|
29
|
+
/** A resolved handle to a consumer region, returned by `ECS.regionHandle` /
|
|
30
|
+
* `Store.regionHandle`. Carries the live `buffer`/`view` plus the region's byte
|
|
31
|
+
* `offset` and full `bytes`, so a consumer's region module can build a
|
|
32
|
+
* TypedArray view over exactly the region's span without re-reading the
|
|
33
|
+
* directory. Re-fetch after a SAB grow (the offset/view may have moved). */
|
|
34
|
+
export interface ColumnStoreRegionHandle {
|
|
35
|
+
/** `ArrayBufferLike` — see `ColumnStore.buffer`. Consumer regions are a SAB-profile
|
|
36
|
+
* feature (WASM/worker), so in practice this is a `SharedArrayBuffer` wherever
|
|
37
|
+
* regions are declared; the type is widened only because it flows from the
|
|
38
|
+
* backing-agnostic store. */
|
|
39
|
+
readonly buffer: ArrayBufferLike;
|
|
40
|
+
readonly view: DataView;
|
|
41
|
+
readonly offset: number;
|
|
42
|
+
readonly bytes: number;
|
|
43
|
+
}
|
|
44
|
+
export declare class RegionRegistryError extends Error {
|
|
45
|
+
constructor(message: string);
|
|
46
|
+
}
|
|
47
|
+
/** Bytes a region-table directory of `count` entries occupies. */
|
|
48
|
+
export declare function regionTableBytes(count: number): number;
|
|
49
|
+
/** Validate a consumer region set before layout: ids must be nonzero (0 is the
|
|
50
|
+
* "absent" sentinel `findRegionOffset` returns) and distinct, and each region
|
|
51
|
+
* must request a positive byte size. Throws `RegionRegistryError` otherwise —
|
|
52
|
+
* the same loud-failure stance the mechanism registry's paired-knob guards take. */
|
|
53
|
+
export declare function validateRegionSpecs(regions: readonly StoreRegionSpec[]): void;
|
|
54
|
+
/** Write one directory record at absolute byte offset `off`. */
|
|
55
|
+
export declare function writeRegionTableEntry(view: DataView, off: number, e: RegionTableEntry): void;
|
|
56
|
+
/** Read one directory record at absolute byte offset `off`. */
|
|
57
|
+
export declare function readRegionTableEntry(view: DataView, off: number): RegionTableEntry;
|
|
58
|
+
/** Write the whole directory of `entries` at `tableOff`. */
|
|
59
|
+
export declare function writeRegionTable(view: DataView, tableOff: number, entries: readonly RegionTableEntry[]): void;
|
|
60
|
+
/** Read all `count` directory records starting at `tableOff`, in order. */
|
|
61
|
+
export declare function readRegionTable(view: DataView, tableOff: number, count: number): RegionTableEntry[];
|
|
62
|
+
/** Read the directory described by the SAB header (`region_table_off` /
|
|
63
|
+
* `region_table_count`). Empty when no consumer regions were declared. */
|
|
64
|
+
export declare function readHeaderRegionTable(view: DataView): RegionTableEntry[];
|
|
65
|
+
/** Resolve a consumer region's byte offset by `region_id`, or 0 when absent
|
|
66
|
+
* (no directory, or no matching entry). The TS twin of Zig
|
|
67
|
+
* `abi.find_region(header_addr, region_id)`; 0 is an unambiguous "absent"
|
|
68
|
+
* sentinel because a real region never starts at SAB byte 0 (the header does). */
|
|
69
|
+
export declare function findRegionOffset(view: DataView, regionId: number): number;
|
|
70
|
+
/** Resolve a consumer region's `(byte_offset, byte_length)` by `region_id`, or
|
|
71
|
+
* `null` when absent. Use when a reader needs the region's size (e.g. to
|
|
72
|
+
* materialise a TypedArray view) and not just its start. */
|
|
73
|
+
export declare function findRegionEntry(view: DataView, regionId: number): RegionTableEntry | null;
|
|
74
|
+
//# sourceMappingURL=region_table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"region_table.d.ts","sourceRoot":"","sources":["../../../src/core/store/region_table.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EACN,wBAAwB,EACxB,0BAA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AA+D;AAC/D,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAMlF;AAED,4DAA4D;AAC5D,wBAAgB,gBAAgB,CAC/B,IAAI,EAAE,QAAQ,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,SAAS,gBAAgB,EAAE,GAClC,IAAI,CAIN;AAED,2EAA2E;AAC3E,wBAAgB,eAAe,CAC9B,IAAI,EAAE,QAAQ,EACd,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GACX,gBAAgB,EAAE,CAMpB;AAED;0EAC0E;AAC1E,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,QAAQ,GAAG,gBAAgB,EAAE,CAKxE;AAED;;;kFAGkF;AAClF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAWzE;AAED;;4DAE4D;AAC5D,wBAAgB,eAAe,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CASzF"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ColumnStore } from './column_store';
|
|
2
|
+
import { BufferAllocator } from './allocator';
|
|
3
|
+
export declare class StoreRestoreError extends Error {
|
|
4
|
+
constructor(message: string);
|
|
5
|
+
}
|
|
6
|
+
/** Zero-copy `Uint8Array` view over the SAB's used byte range. Length is
|
|
7
|
+
* `header.capacity` — the canonical size, NOT `buffer.byteLength`. The two
|
|
8
|
+
* coincide for `DEFAULT_SAB_ALLOCATOR` (it allocates exactly `totalBytes`),
|
|
9
|
+
* but `wasmMemoryAllocator` / `growableSabAllocator` round the buffer up
|
|
10
|
+
* to 64 KiB page boundaries, so `buffer.byteLength` can exceed `capacity` by up
|
|
11
|
+
* to a page of trailing slack (see the allocator contract in `allocator.ts`).
|
|
12
|
+
* Hashing or round-tripping that slack would make two logically-identical
|
|
13
|
+
* stores with different grow trajectories (or different allocators) diverge,
|
|
14
|
+
* so we size to `capacity` here.
|
|
15
|
+
*
|
|
16
|
+
* Capacity is read live from `store.view` rather than the cached
|
|
17
|
+
* `store.header` — the in-place grow path bumps the header fields in the
|
|
18
|
+
* view but leaves `store.header` a stale snapshot (see `grow.ts`).
|
|
19
|
+
*
|
|
20
|
+
* The view shares storage with the SAB; subsequent writes to columns are
|
|
21
|
+
* visible through it. Callers that need a stable snapshot should slice
|
|
22
|
+
* (`new Uint8Array(view)`) before mutating the store further. */
|
|
23
|
+
export declare function snapshotColumnStore(store: ColumnStore): Uint8Array;
|
|
24
|
+
/** Allocate a fresh backing buffer of `bytes.byteLength`, copy the snapshot
|
|
25
|
+
* bytes in, validate the header, and reconstruct the `ColumnStore` (header cache +
|
|
26
|
+
* DataView + per-archetype `ArchetypeViews`).
|
|
27
|
+
*
|
|
28
|
+
* `allocator` selects the backing: the default `DEFAULT_SAB_ALLOCATOR`
|
|
29
|
+
* (`SharedArrayBuffer`) keeps existing callers' behaviour; pass
|
|
30
|
+
* `heapArraybufferAllocator()` to round-trip a snapshot into a pure-TS heap
|
|
31
|
+
* world (no SAB required). Either way only one allocation happens — restore
|
|
32
|
+
* never grows — so a non-in-place allocator is fine here.
|
|
33
|
+
*
|
|
34
|
+
* The input can be any `Uint8Array` — a view from `snapshotColumnStore`,
|
|
35
|
+
* a sliced copy, or bytes read off disk / postMessage. The function
|
|
36
|
+
* honours `bytes.byteOffset` and `bytes.byteLength`, so passing a
|
|
37
|
+
* subarray that doesn't start at offset 0 of its backing buffer is
|
|
38
|
+
* supported.
|
|
39
|
+
*
|
|
40
|
+
* Throws `StoreRestoreError` if the bytes are too short for the header,
|
|
41
|
+
* have the wrong magic, or carry an incompatible `sim_abi_version`. */
|
|
42
|
+
export declare function restoreColumnStore(bytes: Uint8Array, allocator?: BufferAllocator): ColumnStore;
|
|
43
|
+
//# sourceMappingURL=snapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../../src/core/store/snapshot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAUH,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAE1E,qBAAa,iBAAkB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI3B;AAED;;;;;;;;;;;;;;;;iEAgBiE;AACjE,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,WAAW,GAAG,UAAU,CAGlE;AAED;;;;;;;;;;;;;;;;;uEAiBuE;AACvE,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,UAAU,EACjB,SAAS,GAAE,eAAuC,GAChD,WAAW,CAiEb"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ColumnStore } from './column_store';
|
|
2
|
+
/** FNV-1a 32-bit offset basis (Fowler/Noll/Vo). */
|
|
3
|
+
export declare const FNV1A_OFFSET_BASIS = 2166136261;
|
|
4
|
+
/** FNV-1a 32-bit prime. */
|
|
5
|
+
export declare const FNV1A_PRIME = 16777619;
|
|
6
|
+
/** One FNV-1a round folding a single **byte** (the low 8 bits of `b`) into the
|
|
7
|
+
* running `hash`: `hash = imul((hash ^ (b & 0xff)) >>> 0, PRIME) >>> 0`. The
|
|
8
|
+
* single canonical definition of the byte step (#498) — reused by `fnv1a32`
|
|
9
|
+
* here, by the sparse-store `schemaFingerprint`, and by the server determinism
|
|
10
|
+
* byte/u32 folds, so the constants and the round live in exactly one place.
|
|
11
|
+
*
|
|
12
|
+
* Trivially inlinable (monomorphic, no allocation); the intermediate `>>> 0`s
|
|
13
|
+
* never change a later round (xor/imul see the same 32-bit pattern signed or
|
|
14
|
+
* unsigned), they just keep the value unsigned for readers. */
|
|
15
|
+
export declare function fnv1aStep(hash: number, b: number): number;
|
|
16
|
+
/** One FNV-1a round folding a full 32-bit **word** into `hash` — the whole word
|
|
17
|
+
* xored at once, not four byte rounds. A coarser fold than per-byte FNV-1a, but
|
|
18
|
+
* equally deterministic and ~4× cheaper, which is why `Store.stateHash` folds
|
|
19
|
+
* its columns this way (#326). This is the canonical word-step definition its
|
|
20
|
+
* cold sparse/relation folds call; its hot dense-column inner loop inlines this
|
|
21
|
+
* exact step for speed and must stay in sync. Same `>>> 0` reasoning as
|
|
22
|
+
* `fnv1aStep`. */
|
|
23
|
+
export declare function fnv1aStepWord(hash: number, word: number): number;
|
|
24
|
+
/** FNV-1a 32-bit hash of a byte buffer. Returned as an unsigned 32-bit
|
|
25
|
+
* `number` (i.e. always in `[0, 2^32)`).
|
|
26
|
+
*
|
|
27
|
+
* Standalone export so callers that already have a `Uint8Array` (a sliced
|
|
28
|
+
* snapshot, bytes off disk, a hot subrange) can hash without round-tripping
|
|
29
|
+
* through `ColumnStore`. */
|
|
30
|
+
export declare function fnv1a32(bytes: Uint8Array): number;
|
|
31
|
+
/** FNV-1a 32-bit hash of the entire SAB region — header + descriptors +
|
|
32
|
+
* column bytes. The canonical state identifier for cross-replay determinism
|
|
33
|
+
* checks (#171 plan exit criterion §6.1.7).
|
|
34
|
+
*
|
|
35
|
+
* The snapshot view is zero-copy (`snapshotColumnStore` is a view, not a
|
|
36
|
+
* copy), so this is one scan over the live SAB with no allocation. */
|
|
37
|
+
export declare function columnStoreStateHash(store: ColumnStore): number;
|
|
38
|
+
//# sourceMappingURL=state_hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state_hash.d.ts","sourceRoot":"","sources":["../../../src/core/store/state_hash.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,mDAAmD;AACnD,eAAO,MAAM,kBAAkB,aAAa,CAAC;AAC7C,2BAA2B;AAC3B,eAAO,MAAM,WAAW,WAAa,CAAC;AAEtC;;;;;;;;+DAQ+D;AAC/D,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAGzD;AAED;;;;;;kBAMkB;AAClB,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAGhE;AAED;;;;;4BAK4B;AAC5B,wBAAgB,OAAO,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAIjD;AAED;;;;;sEAKsE;AACtE,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAE/D"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { CreateColumnStoreOptions } from './column_store';
|
|
2
|
+
/** The `StoreHeader` fields that hold a MECHANISM region's byte offset (0 ⇒
|
|
3
|
+
* region absent). Exactly the four fields a `MechanismRegionSpec` can own; the
|
|
4
|
+
* always-present `bindings_off` / `layout_descriptor_off` and the generic
|
|
5
|
+
* `region_table_off` / `region_table_count` pair are not mechanism regions in
|
|
6
|
+
* this sense and are computed directly outside the loop. */
|
|
7
|
+
export type StoreRegionOffsetField = "command_ring_off" | "entity_index_off" | "event_ring_off" | "action_ring_off";
|
|
8
|
+
/** Mutable accumulator for building `CreateColumnStoreOptions` field by field as
|
|
9
|
+
* each region reads itself back out of an existing SAB (`readOptions`). */
|
|
10
|
+
export type MutableColumnStoreOptions = {
|
|
11
|
+
-readonly [K in keyof CreateColumnStoreOptions]: CreateColumnStoreOptions[K];
|
|
12
|
+
};
|
|
13
|
+
/** One engine MECHANISM region. The four closures are the per-region half of
|
|
14
|
+
* each generic pass; see the module doc for which consumer drives which.
|
|
15
|
+
*
|
|
16
|
+
* (Consumer/game regions use the separate self-contained `StoreRegionSpec` in
|
|
17
|
+
* `region_table.ts` — they carry a precomputed `bytes` + `init` and are
|
|
18
|
+
* addressed by an opaque `region_id`, not a named header field.) */
|
|
19
|
+
export interface MechanismRegionSpec {
|
|
20
|
+
/** Stable name — reads in diagnostics and keeps the array self-documenting. */
|
|
21
|
+
readonly name: string;
|
|
22
|
+
/** `StoreHeader` field this region's byte offset is written to. */
|
|
23
|
+
readonly headerOff: StoreRegionOffsetField;
|
|
24
|
+
/** Byte size implied by `options` (0 ⇒ region absent, so no offset/init). */
|
|
25
|
+
readonly sizeFromOptions: (options: CreateColumnStoreOptions) => number;
|
|
26
|
+
/** Initialise the region's header at `off`. Called by `createColumnStore`
|
|
27
|
+
* only when the region is present (`off !== 0`). */
|
|
28
|
+
readonly init: (view: DataView, off: number, options: CreateColumnStoreOptions) => void;
|
|
29
|
+
/** Byte length of an already-allocated region, read from its own header.
|
|
30
|
+
* Used to snapshot exactly the live bytes before a realloc. */
|
|
31
|
+
readonly regionBytes: (view: DataView, off: number) => number;
|
|
32
|
+
/** Re-derive the `CreateColumnStoreOptions` knobs that recreate this region
|
|
33
|
+
* from an existing SAB, so a realloc lays it out identically. */
|
|
34
|
+
readonly readOptions: (view: DataView, off: number, out: MutableColumnStoreOptions) => void;
|
|
35
|
+
}
|
|
36
|
+
/** The engine mechanism prefix regions, in SAB byte order (see module doc). */
|
|
37
|
+
export declare const STORE_PREFIX_REGIONS: readonly MechanismRegionSpec[];
|
|
38
|
+
//# sourceMappingURL=store_regions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store_regions.d.ts","sourceRoot":"","sources":["../../../src/core/store/store_regions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAUH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAE/D;;;;4DAI4D;AAC5D,MAAM,MAAM,sBAAsB,GAC/B,kBAAkB,GAClB,kBAAkB,GAClB,gBAAgB,GAChB,iBAAiB,CAAC;AAErB;2EAC2E;AAC3E,MAAM,MAAM,yBAAyB,GAAG;IACvC,CAAC,UAAU,CAAC,IAAI,MA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