@oasys/oecs 0.5.3 → 0.5.4
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/CHANGELOG.md +194 -28
- package/README.md +198 -145
- package/dist/core/ecs/access_check.d.cts +3 -3
- package/dist/core/ecs/access_check.d.ts +3 -3
- package/dist/core/ecs/archetype.d.cts +103 -43
- package/dist/core/ecs/archetype.d.ts +103 -43
- package/dist/core/ecs/archetype.d.ts.map +1 -1
- package/dist/core/ecs/archetype_graph.d.cts +8 -8
- package/dist/core/ecs/archetype_graph.d.ts +8 -8
- package/dist/core/ecs/archetype_graph.d.ts.map +1 -1
- package/dist/core/ecs/builtin_relations.d.cts +1 -1
- package/dist/core/ecs/builtin_relations.d.ts +1 -1
- package/dist/core/ecs/command_log.d.cts +4 -4
- package/dist/core/ecs/command_log.d.ts +4 -4
- package/dist/core/ecs/command_log.d.ts.map +1 -1
- package/dist/core/ecs/component.d.cts +4 -4
- package/dist/core/ecs/component.d.ts +4 -4
- package/dist/core/ecs/deferred_commands.d.cts +1 -1
- package/dist/core/ecs/deferred_commands.d.ts +1 -1
- package/dist/core/ecs/deferred_commands.d.ts.map +1 -1
- package/dist/core/ecs/ecs.d.cts +85 -43
- package/dist/core/ecs/ecs.d.ts +85 -43
- package/dist/core/ecs/ecs.d.ts.map +1 -1
- package/dist/core/ecs/ecs_memory.d.cts +10 -10
- package/dist/core/ecs/ecs_memory.d.ts +10 -10
- package/dist/core/ecs/ecs_memory.d.ts.map +1 -1
- package/dist/core/ecs/entity_allocator.d.cts +6 -6
- package/dist/core/ecs/entity_allocator.d.ts +6 -6
- package/dist/core/ecs/entity_allocator.d.ts.map +1 -1
- package/dist/core/ecs/event.d.cts +2 -2
- package/dist/core/ecs/event.d.ts +2 -2
- package/dist/core/ecs/event_registry.d.cts +1 -1
- package/dist/core/ecs/event_registry.d.ts +1 -1
- package/dist/core/ecs/event_registry.d.ts.map +1 -1
- package/dist/core/ecs/facades.d.cts +15 -15
- package/dist/core/ecs/facades.d.ts +15 -15
- package/dist/core/ecs/facades.d.ts.map +1 -1
- package/dist/core/ecs/frame_trace.d.cts +2 -2
- package/dist/core/ecs/frame_trace.d.ts +2 -2
- package/dist/core/ecs/host_commands.d.cts +12 -12
- package/dist/core/ecs/host_commands.d.ts +12 -12
- package/dist/core/ecs/host_commands.d.ts.map +1 -1
- package/dist/core/ecs/index.d.cts +1 -1
- package/dist/core/ecs/index.d.ts +1 -1
- package/dist/core/ecs/index.d.ts.map +1 -1
- package/dist/core/ecs/observer.d.cts +9 -9
- package/dist/core/ecs/observer.d.ts +9 -9
- package/dist/core/ecs/observer.d.ts.map +1 -1
- package/dist/core/ecs/query.d.cts +91 -70
- package/dist/core/ecs/query.d.ts +91 -70
- package/dist/core/ecs/query.d.ts.map +1 -1
- package/dist/core/ecs/ref.d.cts +53 -1
- package/dist/core/ecs/ref.d.ts +53 -1
- package/dist/core/ecs/ref.d.ts.map +1 -1
- package/dist/core/ecs/relation.d.cts +15 -15
- package/dist/core/ecs/relation.d.ts +15 -15
- package/dist/core/ecs/relation.d.ts.map +1 -1
- package/dist/core/ecs/relation_service.d.cts +14 -14
- package/dist/core/ecs/relation_service.d.ts +14 -14
- package/dist/core/ecs/relation_service.d.ts.map +1 -1
- package/dist/core/ecs/resource.d.cts +1 -1
- package/dist/core/ecs/resource.d.ts +1 -1
- package/dist/core/ecs/resource_registry.d.cts +2 -2
- package/dist/core/ecs/resource_registry.d.ts +2 -2
- package/dist/core/ecs/resume.d.cts +3 -3
- package/dist/core/ecs/resume.d.ts +3 -3
- package/dist/core/ecs/resume.d.ts.map +1 -1
- package/dist/core/ecs/schedule.d.cts +22 -9
- package/dist/core/ecs/schedule.d.ts +22 -9
- package/dist/core/ecs/schedule.d.ts.map +1 -1
- package/dist/core/ecs/snapshot_service.d.cts +3 -3
- package/dist/core/ecs/snapshot_service.d.ts +3 -3
- package/dist/core/ecs/sparse_store.d.cts +6 -6
- package/dist/core/ecs/sparse_store.d.ts +6 -6
- package/dist/core/ecs/sparse_store.d.ts.map +1 -1
- package/dist/core/ecs/store.d.cts +189 -110
- package/dist/core/ecs/store.d.ts +189 -110
- package/dist/core/ecs/store.d.ts.map +1 -1
- package/dist/core/ecs/store_layout_listener.d.cts +2 -2
- package/dist/core/ecs/store_layout_listener.d.ts +2 -2
- package/dist/core/ecs/system.d.cts +8 -8
- package/dist/core/ecs/system.d.ts +8 -8
- package/dist/core/ecs/system.d.ts.map +1 -1
- package/dist/core/ecs/utils/error.d.cts +7 -0
- package/dist/core/ecs/utils/error.d.ts +7 -0
- package/dist/core/ecs/utils/error.d.ts.map +1 -1
- package/dist/core/store/action_ring.d.cts +7 -8
- package/dist/core/store/action_ring.d.ts +7 -8
- package/dist/core/store/action_ring.d.ts.map +1 -1
- package/dist/core/store/allocator.d.cts +26 -28
- package/dist/core/store/allocator.d.ts +26 -28
- package/dist/core/store/allocator.d.ts.map +1 -1
- package/dist/core/store/buffer_backed_column.d.cts +5 -6
- package/dist/core/store/buffer_backed_column.d.ts +5 -6
- package/dist/core/store/buffer_backed_column.d.ts.map +1 -1
- package/dist/core/store/column_store.d.cts +22 -22
- package/dist/core/store/column_store.d.ts +22 -22
- package/dist/core/store/column_store.d.ts.map +1 -1
- package/dist/core/store/command_dispatch.d.cts +1 -1
- package/dist/core/store/command_dispatch.d.ts +1 -1
- package/dist/core/store/command_ring.d.cts +6 -7
- package/dist/core/store/command_ring.d.ts +6 -7
- package/dist/core/store/command_ring.d.ts.map +1 -1
- package/dist/core/store/descriptor.d.cts +2 -2
- package/dist/core/store/descriptor.d.ts +2 -2
- package/dist/core/store/entity_index.d.cts +3 -3
- package/dist/core/store/entity_index.d.ts +3 -3
- package/dist/core/store/event_ring.d.cts +7 -7
- package/dist/core/store/event_ring.d.ts +7 -7
- package/dist/core/store/extend.d.cts +2 -2
- package/dist/core/store/extend.d.ts +2 -2
- package/dist/core/store/grow.d.cts +1 -1
- package/dist/core/store/grow.d.ts +1 -1
- package/dist/core/store/grow.d.ts.map +1 -1
- package/dist/core/store/header.d.cts +9 -9
- package/dist/core/store/header.d.ts +9 -9
- package/dist/core/store/header.d.ts.map +1 -1
- package/dist/core/store/layout_ops.d.cts +7 -7
- package/dist/core/store/layout_ops.d.ts +7 -7
- package/dist/core/store/state_hash.d.cts +3 -3
- package/dist/core/store/state_hash.d.ts +3 -3
- package/dist/extensions/editor/editor.d.cts +4 -4
- package/dist/extensions/editor/editor.d.ts +4 -4
- package/dist/extensions/editor/editor.d.ts.map +1 -1
- package/dist/extensions/editor/field_handle.d.cts +1 -1
- package/dist/extensions/editor/field_handle.d.ts +1 -1
- package/dist/extensions/editor/index.d.cts +2 -2
- package/dist/extensions/editor/index.d.ts +2 -2
- package/dist/extensions/editor/index.development.js +4 -4
- package/dist/extensions/editor/index.js +4 -4
- package/dist/extensions/reactive/ecs_sync.d.cts +4 -4
- package/dist/extensions/reactive/ecs_sync.d.ts +4 -4
- package/dist/extensions/reactive/index.d.cts +4 -4
- package/dist/extensions/reactive/index.d.ts +4 -4
- package/dist/extensions/reactive/index.development.js +3 -3
- package/dist/extensions/reactive/index.js +3 -3
- package/dist/extensions/solid/index.d.cts +1 -1
- package/dist/extensions/solid/index.d.ts +1 -1
- package/dist/extensions/solid/index.development.js +1 -1
- package/dist/extensions/solid/index.js +1 -1
- package/dist/extensions/solid/kernel_solid.d.cts +1 -1
- package/dist/extensions/solid/kernel_solid.d.ts +1 -1
- package/dist/extensions/solid/kernel_solid.d.ts.map +1 -1
- package/dist/{host_commands-3jyFfWNg.js → host_commands-BlR3oZ3x.js} +472 -392
- package/dist/host_commands-C2cpU3yC.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.development.cjs +1 -1
- package/dist/index.development.js +3344 -2965
- package/dist/index.js +1494 -1132
- package/dist/{internal-C9jjL90H.js → internal-BoxWl4dG.js} +409 -329
- package/dist/internal-CGBEwfeB.cjs +2 -0
- package/dist/internal.cjs +1 -1
- package/dist/internal.development.cjs +1 -1
- package/dist/internal.development.js +1 -1
- package/dist/internal.js +1 -1
- package/dist/primitives.development.js +1 -1
- package/dist/primitives.js +1 -1
- package/dist/reactive/index.d.cts +2 -2
- package/dist/reactive/index.d.ts +2 -2
- package/dist/reactive/index.development.js +1 -1
- package/dist/reactive/index.js +1 -1
- package/dist/reactive/kernel.d.cts +5 -5
- package/dist/reactive/kernel.d.ts +5 -5
- package/dist/reactive/shallow.d.cts +1 -1
- package/dist/reactive/shallow.d.ts +1 -1
- package/dist/{shallow-DfnAm9vG.js → shallow-Bs39EPh1.js} +1 -1
- package/dist/{shallow-9S1pY_Iw.js → shallow-CiFC70Dz.js} +1 -1
- package/dist/{shared-DQKK0i-E.js → shared-B4v0L1cw.js} +4 -4
- package/dist/shared-DU78k0pU.cjs +1 -0
- package/dist/shared.cjs +1 -1
- package/dist/shared.development.cjs +1 -1
- package/dist/shared.development.js +1 -1
- package/dist/shared.js +1 -1
- package/dist/type_primitives/typed_arrays/typed_arrays.d.cts +2 -2
- package/dist/type_primitives/typed_arrays/typed_arrays.d.ts +2 -2
- package/dist/{typed_arrays-BcXcnzB4.js → typed_arrays-DIVwVy5_.js} +1 -1
- package/dist/version.d.cts +2 -2
- package/dist/version.d.ts +2 -2
- package/package.json +1 -1
- package/dist/host_commands-DNf0f6ko.cjs +0 -1
- package/dist/internal-RZN14uMw.cjs +0 -2
- package/dist/shared-BMXh9hxm.cjs +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* BufferAllocator — pluggable buffer source for the SAB layer
|
|
2
|
+
* BufferAllocator — pluggable buffer source for the SAB layer.
|
|
3
3
|
*
|
|
4
4
|
* The engine has historically allocated its SAB as a fresh
|
|
5
5
|
* `new SharedArrayBuffer(totalBytes)` inside `createColumnStore`.
|
|
6
|
-
*
|
|
7
|
-
* `WebAssembly.Memory.buffer` so the
|
|
6
|
+
* A WASM backend needs the SAB to optionally be backed by a
|
|
7
|
+
* `WebAssembly.Memory.buffer` instead, so the sim can read and write the live
|
|
8
8
|
* ECS columns through its own memory handle. This module abstracts the
|
|
9
9
|
* "where does the buffer come from" decision behind a single function
|
|
10
10
|
* type.
|
|
@@ -67,7 +67,7 @@ export interface BufferAllocator {
|
|
|
67
67
|
readonly isInPlace?: boolean;
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
|
-
* The only allocator shape a **live `Store`** accepts
|
|
70
|
+
* The only allocator shape a **live `Store`** accepts. The engine makes
|
|
71
71
|
* "a live Store is backed by an in-place allocator" a correctness invariant —
|
|
72
72
|
* the flush loops hoist entity-index views across grows. This brand moves
|
|
73
73
|
* that invariant from runtime convention to the type/construction boundary:
|
|
@@ -86,10 +86,10 @@ export type InPlaceBufferAllocator = BufferAllocator & {
|
|
|
86
86
|
};
|
|
87
87
|
/**
|
|
88
88
|
* Thrown when an allocator cannot satisfy a request because its by-design
|
|
89
|
-
* byte ceiling is reached (
|
|
89
|
+
* byte ceiling is reached (the cap is a runaway-growth signal, not a
|
|
90
90
|
* limit to paper over — there is deliberately no grow-beyond-cap fallback).
|
|
91
91
|
* Typed so `Store`'s grow handler can recognise the cap case and re-throw
|
|
92
|
-
* with the caller's declared sizing intent attached
|
|
92
|
+
* with the caller's declared sizing intent attached without ever
|
|
93
93
|
* catching-to-recover.
|
|
94
94
|
*/
|
|
95
95
|
export declare class StoreCapExceededError extends Error {
|
|
@@ -133,16 +133,16 @@ export declare const DEFAULT_SAB_ALLOCATOR: BufferAllocator;
|
|
|
133
133
|
* in place rather than relocating).
|
|
134
134
|
*
|
|
135
135
|
* Sizing: `maxBytes` is committed *virtual* memory, not resident RAM —
|
|
136
|
-
* physical pages fault in lazily as the SAB actually grows.
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
136
|
+
* physical pages fault in lazily as the SAB actually grows. A larger cap costs
|
|
137
|
+
* more time per allocation than a smaller one, because V8 does per-byte
|
|
138
|
+
* bookkeeping when it constructs the buffer. The cost increases with the cap, so
|
|
139
|
+
* a 1 GiB cap is the slowest of the sizes we measured and a 1 MiB cap the
|
|
140
|
+
* quickest. A caller with a bigger world can pass a larger cap; a caller that
|
|
141
|
+
* stays under the 256 MiB default keeps the quicker Store construction.
|
|
142
142
|
*
|
|
143
143
|
* THE 256 MiB DEFAULT IS A HARD DESIGN CEILING, NOT A SOFT TARGET — and
|
|
144
144
|
* exceeding it is INTENDED to be fatal. There is deliberately no
|
|
145
|
-
* grow-beyond-cap fallback or compaction pass (see
|
|
145
|
+
* grow-beyond-cap fallback or compaction pass (see the loud
|
|
146
146
|
* note at the `bytes > maxBytes` throw below). If you are here because
|
|
147
147
|
* a workload died at the cap and you are tempted to add a fresh-allocator
|
|
148
148
|
* realloc fallback: don't, unless the numbers below have changed. They
|
|
@@ -169,40 +169,38 @@ export declare const DEFAULT_SAB_ALLOCATOR: BufferAllocator;
|
|
|
169
169
|
* therefore signals a real defect upstream (runaway entity creation), not
|
|
170
170
|
* a sizing shortfall to paper over.
|
|
171
171
|
*
|
|
172
|
-
* Cited verification
|
|
172
|
+
* Cited verification: a Bun runtime check
|
|
173
173
|
* confirms `new Int32Array(buffer, off, len)` retains identical byteOffset,
|
|
174
174
|
* length, and stored values after `.grow()`; DataView byteLength
|
|
175
175
|
* auto-tracks the grown buffer.
|
|
176
176
|
*
|
|
177
177
|
* Used by the `extendColumnStore` fast path during lazy archetype
|
|
178
|
-
* registration
|
|
178
|
+
* registration — keeps existing column views valid so
|
|
179
179
|
* `refreshViews` is a no-op for old archetypes.
|
|
180
180
|
*/
|
|
181
181
|
export declare function growableSabAllocator(maxBytes?: number): InPlaceBufferAllocator;
|
|
182
182
|
/**
|
|
183
183
|
* Allocator that backs the store by a single **fixed (non-resizable) plain
|
|
184
184
|
* `ArrayBuffer`** reserved at the full `maxBytes` cap up front. This is the
|
|
185
|
-
* pure-TS **heap profile** — the oecs default
|
|
186
|
-
*
|
|
185
|
+
* pure-TS **heap profile** — the oecs default: no `SharedArrayBuffer`,
|
|
186
|
+
* hence no cross-origin isolation
|
|
187
187
|
* (COOP/COEP) requirement, and no worker/WASM transfer (single-process worlds
|
|
188
188
|
* only).
|
|
189
189
|
*
|
|
190
190
|
* WHY FIXED, NOT RESIZABLE (the 0.5.3 iteration-perf fix): V8 has no fast
|
|
191
|
-
* element-access path for TypedArray views over a **resizable
|
|
192
|
-
* `ArrayBuffer
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
* regressed all iteration-bound systems ~5× (the cross-library `packed_5`
|
|
198
|
-
* scenario: 0.5.2 ~86k op/s → 0.5.3 ~420k). A fixed buffer restores the fast path.
|
|
191
|
+
* element-access path for TypedArray views over a **resizable or growable**
|
|
192
|
+
* `ArrayBuffer`, because each `col[i]` reads the mutable length again. Thus a
|
|
193
|
+
* loop over a column is much slower than the same loop over a fixed buffer.
|
|
194
|
+
* Version 0.3.x gave each column its own fixed buffer. The change in 0.5.0 to
|
|
195
|
+
* one resizable arena made every iteration-bound system slower, and it gave no
|
|
196
|
+
* signal. A fixed buffer restores the fast path.
|
|
199
197
|
*
|
|
200
198
|
* How growth still works in place: the cap is reserved as one fixed buffer at
|
|
201
199
|
* construction. A resizable buffer was originally chosen so `.resize()` could
|
|
202
200
|
* grow in place without moving views; a fixed buffer never moves EITHER — the
|
|
203
201
|
* store's grow/extend relocate columns to the tail *within* this buffer
|
|
204
202
|
* (`copyWithin`), so the buffer object and every existing view stay valid.
|
|
205
|
-
* `isInPlace: true` therefore still holds, and
|
|
203
|
+
* `isInPlace: true` therefore still holds, and the
|
|
206
204
|
* entity-index-hoist-across-grow invariant is preserved. The store keys its
|
|
207
205
|
* tail cursor off the header `capacity` (the logical high-water), NOT
|
|
208
206
|
* `buffer.byteLength` — which is now always `maxBytes` (the same decoupling the
|
|
@@ -213,7 +211,7 @@ export declare function growableSabAllocator(maxBytes?: number): InPlaceBufferAl
|
|
|
213
211
|
* `maxByteLength` reservation — a 256 MiB reservation on a 1000-entity world
|
|
214
212
|
* stays a few MiB resident (measured ~4 MiB RSS, within ~1 MiB of the old
|
|
215
213
|
* resizable buffer).
|
|
216
|
-
* - same 256 MiB default cap with hard-ceiling semantics
|
|
214
|
+
* - same 256 MiB default cap with hard-ceiling semantics: a request
|
|
217
215
|
* past `maxBytes` throws `StoreCapExceededError` — runaway growth signal,
|
|
218
216
|
* not a limit to route around.
|
|
219
217
|
*
|
|
@@ -228,7 +226,7 @@ export declare function heapArraybufferAllocator(maxBytes?: number): InPlaceBuff
|
|
|
228
226
|
* live SAB *be* a WASM module's `WebAssembly.Memory`. Grows the memory in
|
|
229
227
|
* 64 KiB page increments when `bytes` exceeds the current buffer.
|
|
230
228
|
*
|
|
231
|
-
* This is the **opt-in storage backing for the WASM path
|
|
229
|
+
* This is the **opt-in storage backing for the WASM path**. A consumer
|
|
232
230
|
* that attaches a WASM `ComputeBackend` passes
|
|
233
231
|
* `bufferAllocator: wasmMemoryAllocator(memory)` so the Zig systems read/write
|
|
234
232
|
* the same bytes the host's columns live in — zero-copy across the FFI boundary.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"allocator.d.ts","sourceRoot":"","sources":["../../../src/core/store/allocator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,WAAW,eAAe;IAC/B;;;;;;;8BAO0B;IAC1B,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,CAAC;IACjC,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,sBAAsB,GAAG,eAAe,GAAG;IAAE,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAA;CAAE,CAAC;AAEpF;;;;;;;GAOG;AACH,qBA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KvB;AAED;;;;;;oEAMoE;AACpE,qBAAa,mBAAoB,SAAQ,KAAK;;CAe7C;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,EAAE,eAGnC,CAAC;AAgEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,GAAE,MAA0B,GAAG,sBAAsB,CA6BjG;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,wBAAwB,CACvC,QAAQ,GAAE,MAA0B,GAClC,sBAAsB,CAsBxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,GAAG,sBAAsB,CA4DtF"}
|
|
@@ -23,8 +23,8 @@ export declare class BufferBackedColumn<T extends AnyTypedArray> implements Colu
|
|
|
23
23
|
* `newView` already (`growColumnStore` does this). The logical length is
|
|
24
24
|
* preserved across the swap; capacity becomes `newView.length`.
|
|
25
25
|
*
|
|
26
|
-
* Used to honour the `view_stamp` invariant after a host-side SAB realloc
|
|
27
|
-
*
|
|
26
|
+
* Used to honour the `view_stamp` invariant after a host-side SAB realloc:
|
|
27
|
+
* every cached column view must be rebuilt before
|
|
28
28
|
* the next read/write. */
|
|
29
29
|
refreshView(newView: T): void;
|
|
30
30
|
get length(): number;
|
|
@@ -39,15 +39,14 @@ export declare class BufferBackedColumn<T extends AnyTypedArray> implements Colu
|
|
|
39
39
|
clear(): void;
|
|
40
40
|
/** Set the logical length directly, declaring that `[0, len)` of the backing
|
|
41
41
|
* SAB view already holds valid data. The snapshot-mount path
|
|
42
|
-
* (`Archetype.restoreHostRows
|
|
42
|
+
* (`Archetype.restoreHostRows`) uses this to re-sync the column's
|
|
43
43
|
* logical length with the restored `Archetype.length` — the bytes come from
|
|
44
44
|
* the restored SAB, but `_len` is host state. Throws on overrun (cannot grow
|
|
45
45
|
* a fixed SAB view here — the mount already adopted the restored capacity). */
|
|
46
46
|
setLength(len: number): void;
|
|
47
47
|
/** Raw backing view. Stable for the lifetime of the SAB; views over a
|
|
48
48
|
* SAB do not invalidate the way a `GrowableTypedArray`'s `buf` does
|
|
49
|
-
* after a grow. (`view_stamp`
|
|
50
|
-
* once #171 §6.1.4 lands.) */
|
|
49
|
+
* after a grow. (`view_stamp` signals "underlying SAB swapped".) */
|
|
51
50
|
get buf(): T;
|
|
52
51
|
/** Zero-copy subarray of valid data (`0..length-1`). */
|
|
53
52
|
view(): T;
|
|
@@ -55,7 +54,7 @@ export declare class BufferBackedColumn<T extends AnyTypedArray> implements Colu
|
|
|
55
54
|
/** Throw if the backing view cannot hold `capacity` elements. Mirrors
|
|
56
55
|
* `GrowableTypedArray.ensureCapacity` but cannot allocate — a SAB
|
|
57
56
|
* grow requires republishing the underlying buffer and rebuilding views
|
|
58
|
-
* across every archetype, which is the
|
|
57
|
+
* across every archetype, which is the republish invariant. */
|
|
59
58
|
ensureCapacity(capacity: number): void;
|
|
60
59
|
/** Append `count` elements from `src[srcOffset..srcOffset+count]`.
|
|
61
60
|
* Throws on overrun. */
|
|
@@ -23,8 +23,8 @@ export declare class BufferBackedColumn<T extends AnyTypedArray> implements Colu
|
|
|
23
23
|
* `newView` already (`growColumnStore` does this). The logical length is
|
|
24
24
|
* preserved across the swap; capacity becomes `newView.length`.
|
|
25
25
|
*
|
|
26
|
-
* Used to honour the `view_stamp` invariant after a host-side SAB realloc
|
|
27
|
-
*
|
|
26
|
+
* Used to honour the `view_stamp` invariant after a host-side SAB realloc:
|
|
27
|
+
* every cached column view must be rebuilt before
|
|
28
28
|
* the next read/write. */
|
|
29
29
|
refreshView(newView: T): void;
|
|
30
30
|
get length(): number;
|
|
@@ -39,15 +39,14 @@ export declare class BufferBackedColumn<T extends AnyTypedArray> implements Colu
|
|
|
39
39
|
clear(): void;
|
|
40
40
|
/** Set the logical length directly, declaring that `[0, len)` of the backing
|
|
41
41
|
* SAB view already holds valid data. The snapshot-mount path
|
|
42
|
-
* (`Archetype.restoreHostRows
|
|
42
|
+
* (`Archetype.restoreHostRows`) uses this to re-sync the column's
|
|
43
43
|
* logical length with the restored `Archetype.length` — the bytes come from
|
|
44
44
|
* the restored SAB, but `_len` is host state. Throws on overrun (cannot grow
|
|
45
45
|
* a fixed SAB view here — the mount already adopted the restored capacity). */
|
|
46
46
|
setLength(len: number): void;
|
|
47
47
|
/** Raw backing view. Stable for the lifetime of the SAB; views over a
|
|
48
48
|
* SAB do not invalidate the way a `GrowableTypedArray`'s `buf` does
|
|
49
|
-
* after a grow. (`view_stamp`
|
|
50
|
-
* once #171 §6.1.4 lands.) */
|
|
49
|
+
* after a grow. (`view_stamp` signals "underlying SAB swapped".) */
|
|
51
50
|
get buf(): T;
|
|
52
51
|
/** Zero-copy subarray of valid data (`0..length-1`). */
|
|
53
52
|
view(): T;
|
|
@@ -55,7 +54,7 @@ export declare class BufferBackedColumn<T extends AnyTypedArray> implements Colu
|
|
|
55
54
|
/** Throw if the backing view cannot hold `capacity` elements. Mirrors
|
|
56
55
|
* `GrowableTypedArray.ensureCapacity` but cannot allocate — a SAB
|
|
57
56
|
* grow requires republishing the underlying buffer and rebuilding views
|
|
58
|
-
* across every archetype, which is the
|
|
57
|
+
* across every archetype, which is the republish invariant. */
|
|
59
58
|
ensureCapacity(capacity: number): void;
|
|
60
59
|
/** Append `count` elements from `src[srcOffset..srcOffset+count]`.
|
|
61
60
|
* Throws on overrun. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer_backed_column.d.ts","sourceRoot":"","sources":["../../../src/core/store/buffer_backed_column.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD;;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C4D;IACrD,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;CAK1D"}
|
|
@@ -88,12 +88,12 @@ export declare function columnKey(componentId: number, fieldId: number): number;
|
|
|
88
88
|
* real matches three orders of magnitude below this, but the cap is tunable
|
|
89
89
|
* and callers are invited to raise it for bigger worlds — so the layout step
|
|
90
90
|
* guards the hard 2³¹ ceiling explicitly rather than relying on the policy
|
|
91
|
-
* cap to stay in front of it
|
|
91
|
+
* cap to stay in front of it. */
|
|
92
92
|
export declare const STORE_MAX_BYTE_OFFSET: number;
|
|
93
93
|
/** Thrown when a SAB column layout would place an offset at or beyond
|
|
94
94
|
* {@link STORE_MAX_BYTE_OFFSET} (2³¹), past which the signed-32-bit bitwise
|
|
95
95
|
* `alignUp` can no longer produce correct offsets. This is a hard ceiling,
|
|
96
|
-
* not the (tunable, much lower) 256 MiB allocator cap
|
|
96
|
+
* not the (tunable, much lower) 256 MiB allocator cap. */
|
|
97
97
|
export declare class StoreLayoutOverflowError extends Error {
|
|
98
98
|
constructor(byteOff: number);
|
|
99
99
|
}
|
|
@@ -102,7 +102,7 @@ export declare class StoreLayoutOverflowError extends Error {
|
|
|
102
102
|
*
|
|
103
103
|
* Throws {@link StoreLayoutOverflowError} when the rounded offset would reach
|
|
104
104
|
* {@link STORE_MAX_BYTE_OFFSET}, because the `& ~(align-1)` step coerces to a
|
|
105
|
-
* signed 32-bit int and wraps past 2
|
|
105
|
+
* signed 32-bit int and wraps past 2³¹. The guard fires before the
|
|
106
106
|
* bitwise op so any returned offset is always a correct, in-range value.
|
|
107
107
|
* Shared by `extend.ts` and `grow.ts`, whose in-place paths compute tail
|
|
108
108
|
* byte_offs without going through `planLayout`. */
|
|
@@ -114,12 +114,12 @@ export declare function alignUp(off: number, align: number): number;
|
|
|
114
114
|
* `headroomBytes` reserves slack at the end of the descriptor region — ON
|
|
115
115
|
* TOP OF the natural size for `specs` — so future extends can append new
|
|
116
116
|
* descriptor entries without shifting existing column byte_offs. Used by
|
|
117
|
-
* the growable-SAB path
|
|
117
|
+
* the growable-SAB path — column views stay valid across
|
|
118
118
|
* `extendColumnStore` because their byte_offs don't move.
|
|
119
119
|
*
|
|
120
|
-
* Additive, not a floor
|
|
120
|
+
* Additive, not a floor: `regionSize = natural + headroom`, NOT
|
|
121
121
|
* `max(natural, headroom)`. A floor only yields slack while `natural` is
|
|
122
|
-
* below it; the moment the descriptor region outgrows the floor (the
|
|
122
|
+
* below it; the moment the descriptor region outgrows the floor (the
|
|
123
123
|
* headroom exhausts and a realloc re-plans the merged spec set), a floor
|
|
124
124
|
* would size the region to exactly `natural` — zero slack — and every
|
|
125
125
|
* subsequent extend would take the slow realloc path forever after. The
|
|
@@ -138,11 +138,11 @@ export { planLayout };
|
|
|
138
138
|
/** Optional configuration for `createColumnStore`. */
|
|
139
139
|
export interface CreateColumnStoreOptions {
|
|
140
140
|
/** Extra slack to reserve at the end of the layout descriptor region,
|
|
141
|
-
* ON TOP OF the natural size for `specs` (
|
|
141
|
+
* ON TOP OF the natural size for `specs` (additive, not a floor).
|
|
142
142
|
* The descriptor region is padded with this many unused bytes so future
|
|
143
143
|
* `extendColumnStore` calls can append new archetype descriptors into the
|
|
144
144
|
* slack without shifting existing column byte_offs. Pairs with
|
|
145
|
-
* `growableSabAllocator` to give the
|
|
145
|
+
* `growableSabAllocator` to give the in-place fast path: existing
|
|
146
146
|
* TypedArray column views stay valid across extends because their offsets
|
|
147
147
|
* and the underlying buffer both stay put.
|
|
148
148
|
*
|
|
@@ -150,9 +150,9 @@ export interface CreateColumnStoreOptions {
|
|
|
150
150
|
* value lives on `ColumnStoreInternal._reservedDescriptorBytes` and
|
|
151
151
|
* `optionsFromOld` re-applies it, so a store that exhausts its headroom
|
|
152
152
|
* and reallocs gets a fresh margin rather than dropping to zero slack and
|
|
153
|
-
* going permanently slow
|
|
153
|
+
* going permanently slow. */
|
|
154
154
|
readonly reservedDescriptorBytes?: number;
|
|
155
|
-
/** When provided, allocates a command ring
|
|
155
|
+
/** When provided, allocates a command ring inside
|
|
156
156
|
* the SAB at a stable offset right after the 48-byte header. Slot
|
|
157
157
|
* count MUST be a power of two; `COMMAND_RING_DEFAULT_CAPACITY_SLOTS`
|
|
158
158
|
* (256) is the canonical value. Omitted ⇒ no ring; `command_ring_off`
|
|
@@ -164,8 +164,8 @@ export interface CreateColumnStoreOptions {
|
|
|
164
164
|
* `growColumnStore` calls, since those grow the descriptor region and
|
|
165
165
|
* the column tail but never the bytes between header and descriptor. */
|
|
166
166
|
readonly commandRingCapacitySlots?: number;
|
|
167
|
-
/** When provided, allocates the entity-index region
|
|
168
|
-
*
|
|
167
|
+
/** When provided, allocates the entity-index region inside the SAB at a
|
|
168
|
+
* stable offset between the command ring
|
|
169
169
|
* (or header) and the descriptor region. Holds `(generations,
|
|
170
170
|
* archetypes, rows)` triples indexed by entity slot; the engine's
|
|
171
171
|
* `Store` populates them as entities are created/moved/destroyed,
|
|
@@ -176,7 +176,7 @@ export interface CreateColumnStoreOptions {
|
|
|
176
176
|
* `ENTITY_INDEX_DEFAULT_CAPACITY`; bare-SAB tests can leave it
|
|
177
177
|
* absent. */
|
|
178
178
|
readonly entityIndexCapacity?: number;
|
|
179
|
-
/** When provided, allocates the event ring
|
|
179
|
+
/** When provided, allocates the event ring
|
|
180
180
|
* inside the SAB at a stable offset between the entity-index region
|
|
181
181
|
* and the descriptor region. Same SPSC shape as the command ring;
|
|
182
182
|
* carries ECS signal payloads so Zig systems can emit and consume
|
|
@@ -185,9 +185,9 @@ export interface CreateColumnStoreOptions {
|
|
|
185
185
|
* Slot count MUST be a power of two; `EVENT_RING_DEFAULT_CAPACITY_SLOTS`
|
|
186
186
|
* (256) is the canonical value. Omitted ⇒ no ring; `event_ring_off`
|
|
187
187
|
* stays at 0 ("absent"); existing test fixtures with hand-rolled
|
|
188
|
-
* SABs see the
|
|
188
|
+
* SABs see the layout without it. */
|
|
189
189
|
readonly eventRingCapacitySlots?: number;
|
|
190
|
-
/** When provided, allocates the action ring
|
|
190
|
+
/** When provided, allocates the action ring
|
|
191
191
|
* inside the SAB at a stable offset between the entity-index/event-ring
|
|
192
192
|
* and the region-table directory. Main writes encoded actions to it;
|
|
193
193
|
* the sim worker drains them on each apply.
|
|
@@ -197,7 +197,7 @@ export interface CreateColumnStoreOptions {
|
|
|
197
197
|
* stays at 0 ("absent"); bare-SAB tests skip it. (Engine mechanism — the
|
|
198
198
|
* `Store` allocates one always-on; it is no longer a public ECS option.) */
|
|
199
199
|
readonly actionRingCapacitySlots?: number;
|
|
200
|
-
/** Consumer-declared SAB regions
|
|
200
|
+
/** Consumer-declared SAB regions. Each `StoreRegionSpec` carries an
|
|
201
201
|
* opaque `region_id`, a precomputed byte size, and an `init` closure; the
|
|
202
202
|
* engine lays them out after the mechanism regions, writes a generic
|
|
203
203
|
* region-table directory (`region_table.ts`) keyed by `region_id`, and
|
|
@@ -216,7 +216,7 @@ export interface CreateColumnStoreOptions {
|
|
|
216
216
|
* Omitted / 0 ⇒ NO bindings region (`bindings_off` stays 0, "absent") — the
|
|
217
217
|
* default for a pure-TS game that pays nothing for the WASM seam. This used
|
|
218
218
|
* to be the engine-baked `SIM_BINDINGS_BYTES` ABI constant reflected from the
|
|
219
|
-
* game's Zig struct;
|
|
219
|
+
* game's Zig struct; it is now de-welded, so a manifest edit no longer dirties
|
|
220
220
|
* the engine ABI golden. Re-derived across realloc by `optionsFromOld`
|
|
221
221
|
* (= `layout_descriptor_off - bindings_off`), so it survives grow/extend
|
|
222
222
|
* without a carried policy field. */
|
|
@@ -235,12 +235,12 @@ export interface ColumnStoreInternal extends ColumnStore {
|
|
|
235
235
|
* holds the absolute region size (natural + this), and once `natural`
|
|
236
236
|
* outgrows the margin the two are indistinguishable. The realloc slow path
|
|
237
237
|
* reads it via `optionsFromOld` and re-reserves the same margin, so a
|
|
238
|
-
* store that exhausts its headroom and reallocs keeps taking the
|
|
239
|
-
* in-place fast path instead of going permanently slow
|
|
238
|
+
* store that exhausts its headroom and reallocs keeps taking the
|
|
239
|
+
* in-place fast path instead of going permanently slow. The
|
|
240
240
|
* `*_in_place` paths carry it forward verbatim. */
|
|
241
241
|
readonly _reservedDescriptorBytes: number;
|
|
242
242
|
}
|
|
243
|
-
/** Typed recovery of `ColumnStoreInternal` from a public `ColumnStore
|
|
243
|
+
/** Typed recovery of `ColumnStoreInternal` from a public `ColumnStore`.
|
|
244
244
|
* Not every store is internal: `restoreColumnStore` deliberately returns a
|
|
245
245
|
* plain `{ buffer, view, header, archetypes }` (a snapshot carries no JS-side
|
|
246
246
|
* allocator or headroom policy), and grow/extend must send such a store down
|
|
@@ -252,8 +252,8 @@ export declare function isColumnStoreInternal(store: ColumnStore): store is Colu
|
|
|
252
252
|
* and construct one TypedArray view per column.
|
|
253
253
|
*
|
|
254
254
|
* The returned `ColumnStore` is the source of truth for "where every column
|
|
255
|
-
* lives in this SAB". `view_stamp` is initialised to 0 — a
|
|
256
|
-
* grow flow
|
|
255
|
+
* lives in this SAB". `view_stamp` is initialised to 0 — a SAB
|
|
256
|
+
* grow flow bumps it. */
|
|
257
257
|
export declare function createColumnStore(specs: readonly ArchetypeSpec[], allocator?: BufferAllocator, options?: CreateColumnStoreOptions): ColumnStore;
|
|
258
258
|
/** Default command-ring slot count used by `ECS.Store` when constructing
|
|
259
259
|
* its SAB. Re-exported here so the Store doesn't reach across modules. */
|
|
@@ -88,12 +88,12 @@ export declare function columnKey(componentId: number, fieldId: number): number;
|
|
|
88
88
|
* real matches three orders of magnitude below this, but the cap is tunable
|
|
89
89
|
* and callers are invited to raise it for bigger worlds — so the layout step
|
|
90
90
|
* guards the hard 2³¹ ceiling explicitly rather than relying on the policy
|
|
91
|
-
* cap to stay in front of it
|
|
91
|
+
* cap to stay in front of it. */
|
|
92
92
|
export declare const STORE_MAX_BYTE_OFFSET: number;
|
|
93
93
|
/** Thrown when a SAB column layout would place an offset at or beyond
|
|
94
94
|
* {@link STORE_MAX_BYTE_OFFSET} (2³¹), past which the signed-32-bit bitwise
|
|
95
95
|
* `alignUp` can no longer produce correct offsets. This is a hard ceiling,
|
|
96
|
-
* not the (tunable, much lower) 256 MiB allocator cap
|
|
96
|
+
* not the (tunable, much lower) 256 MiB allocator cap. */
|
|
97
97
|
export declare class StoreLayoutOverflowError extends Error {
|
|
98
98
|
constructor(byteOff: number);
|
|
99
99
|
}
|
|
@@ -102,7 +102,7 @@ export declare class StoreLayoutOverflowError extends Error {
|
|
|
102
102
|
*
|
|
103
103
|
* Throws {@link StoreLayoutOverflowError} when the rounded offset would reach
|
|
104
104
|
* {@link STORE_MAX_BYTE_OFFSET}, because the `& ~(align-1)` step coerces to a
|
|
105
|
-
* signed 32-bit int and wraps past 2
|
|
105
|
+
* signed 32-bit int and wraps past 2³¹. The guard fires before the
|
|
106
106
|
* bitwise op so any returned offset is always a correct, in-range value.
|
|
107
107
|
* Shared by `extend.ts` and `grow.ts`, whose in-place paths compute tail
|
|
108
108
|
* byte_offs without going through `planLayout`. */
|
|
@@ -114,12 +114,12 @@ export declare function alignUp(off: number, align: number): number;
|
|
|
114
114
|
* `headroomBytes` reserves slack at the end of the descriptor region — ON
|
|
115
115
|
* TOP OF the natural size for `specs` — so future extends can append new
|
|
116
116
|
* descriptor entries without shifting existing column byte_offs. Used by
|
|
117
|
-
* the growable-SAB path
|
|
117
|
+
* the growable-SAB path — column views stay valid across
|
|
118
118
|
* `extendColumnStore` because their byte_offs don't move.
|
|
119
119
|
*
|
|
120
|
-
* Additive, not a floor
|
|
120
|
+
* Additive, not a floor: `regionSize = natural + headroom`, NOT
|
|
121
121
|
* `max(natural, headroom)`. A floor only yields slack while `natural` is
|
|
122
|
-
* below it; the moment the descriptor region outgrows the floor (the
|
|
122
|
+
* below it; the moment the descriptor region outgrows the floor (the
|
|
123
123
|
* headroom exhausts and a realloc re-plans the merged spec set), a floor
|
|
124
124
|
* would size the region to exactly `natural` — zero slack — and every
|
|
125
125
|
* subsequent extend would take the slow realloc path forever after. The
|
|
@@ -138,11 +138,11 @@ export { planLayout };
|
|
|
138
138
|
/** Optional configuration for `createColumnStore`. */
|
|
139
139
|
export interface CreateColumnStoreOptions {
|
|
140
140
|
/** Extra slack to reserve at the end of the layout descriptor region,
|
|
141
|
-
* ON TOP OF the natural size for `specs` (
|
|
141
|
+
* ON TOP OF the natural size for `specs` (additive, not a floor).
|
|
142
142
|
* The descriptor region is padded with this many unused bytes so future
|
|
143
143
|
* `extendColumnStore` calls can append new archetype descriptors into the
|
|
144
144
|
* slack without shifting existing column byte_offs. Pairs with
|
|
145
|
-
* `growableSabAllocator` to give the
|
|
145
|
+
* `growableSabAllocator` to give the in-place fast path: existing
|
|
146
146
|
* TypedArray column views stay valid across extends because their offsets
|
|
147
147
|
* and the underlying buffer both stay put.
|
|
148
148
|
*
|
|
@@ -150,9 +150,9 @@ export interface CreateColumnStoreOptions {
|
|
|
150
150
|
* value lives on `ColumnStoreInternal._reservedDescriptorBytes` and
|
|
151
151
|
* `optionsFromOld` re-applies it, so a store that exhausts its headroom
|
|
152
152
|
* and reallocs gets a fresh margin rather than dropping to zero slack and
|
|
153
|
-
* going permanently slow
|
|
153
|
+
* going permanently slow. */
|
|
154
154
|
readonly reservedDescriptorBytes?: number;
|
|
155
|
-
/** When provided, allocates a command ring
|
|
155
|
+
/** When provided, allocates a command ring inside
|
|
156
156
|
* the SAB at a stable offset right after the 48-byte header. Slot
|
|
157
157
|
* count MUST be a power of two; `COMMAND_RING_DEFAULT_CAPACITY_SLOTS`
|
|
158
158
|
* (256) is the canonical value. Omitted ⇒ no ring; `command_ring_off`
|
|
@@ -164,8 +164,8 @@ export interface CreateColumnStoreOptions {
|
|
|
164
164
|
* `growColumnStore` calls, since those grow the descriptor region and
|
|
165
165
|
* the column tail but never the bytes between header and descriptor. */
|
|
166
166
|
readonly commandRingCapacitySlots?: number;
|
|
167
|
-
/** When provided, allocates the entity-index region
|
|
168
|
-
*
|
|
167
|
+
/** When provided, allocates the entity-index region inside the SAB at a
|
|
168
|
+
* stable offset between the command ring
|
|
169
169
|
* (or header) and the descriptor region. Holds `(generations,
|
|
170
170
|
* archetypes, rows)` triples indexed by entity slot; the engine's
|
|
171
171
|
* `Store` populates them as entities are created/moved/destroyed,
|
|
@@ -176,7 +176,7 @@ export interface CreateColumnStoreOptions {
|
|
|
176
176
|
* `ENTITY_INDEX_DEFAULT_CAPACITY`; bare-SAB tests can leave it
|
|
177
177
|
* absent. */
|
|
178
178
|
readonly entityIndexCapacity?: number;
|
|
179
|
-
/** When provided, allocates the event ring
|
|
179
|
+
/** When provided, allocates the event ring
|
|
180
180
|
* inside the SAB at a stable offset between the entity-index region
|
|
181
181
|
* and the descriptor region. Same SPSC shape as the command ring;
|
|
182
182
|
* carries ECS signal payloads so Zig systems can emit and consume
|
|
@@ -185,9 +185,9 @@ export interface CreateColumnStoreOptions {
|
|
|
185
185
|
* Slot count MUST be a power of two; `EVENT_RING_DEFAULT_CAPACITY_SLOTS`
|
|
186
186
|
* (256) is the canonical value. Omitted ⇒ no ring; `event_ring_off`
|
|
187
187
|
* stays at 0 ("absent"); existing test fixtures with hand-rolled
|
|
188
|
-
* SABs see the
|
|
188
|
+
* SABs see the layout without it. */
|
|
189
189
|
readonly eventRingCapacitySlots?: number;
|
|
190
|
-
/** When provided, allocates the action ring
|
|
190
|
+
/** When provided, allocates the action ring
|
|
191
191
|
* inside the SAB at a stable offset between the entity-index/event-ring
|
|
192
192
|
* and the region-table directory. Main writes encoded actions to it;
|
|
193
193
|
* the sim worker drains them on each apply.
|
|
@@ -197,7 +197,7 @@ export interface CreateColumnStoreOptions {
|
|
|
197
197
|
* stays at 0 ("absent"); bare-SAB tests skip it. (Engine mechanism — the
|
|
198
198
|
* `Store` allocates one always-on; it is no longer a public ECS option.) */
|
|
199
199
|
readonly actionRingCapacitySlots?: number;
|
|
200
|
-
/** Consumer-declared SAB regions
|
|
200
|
+
/** Consumer-declared SAB regions. Each `StoreRegionSpec` carries an
|
|
201
201
|
* opaque `region_id`, a precomputed byte size, and an `init` closure; the
|
|
202
202
|
* engine lays them out after the mechanism regions, writes a generic
|
|
203
203
|
* region-table directory (`region_table.ts`) keyed by `region_id`, and
|
|
@@ -216,7 +216,7 @@ export interface CreateColumnStoreOptions {
|
|
|
216
216
|
* Omitted / 0 ⇒ NO bindings region (`bindings_off` stays 0, "absent") — the
|
|
217
217
|
* default for a pure-TS game that pays nothing for the WASM seam. This used
|
|
218
218
|
* to be the engine-baked `SIM_BINDINGS_BYTES` ABI constant reflected from the
|
|
219
|
-
* game's Zig struct;
|
|
219
|
+
* game's Zig struct; it is now de-welded, so a manifest edit no longer dirties
|
|
220
220
|
* the engine ABI golden. Re-derived across realloc by `optionsFromOld`
|
|
221
221
|
* (= `layout_descriptor_off - bindings_off`), so it survives grow/extend
|
|
222
222
|
* without a carried policy field. */
|
|
@@ -235,12 +235,12 @@ export interface ColumnStoreInternal extends ColumnStore {
|
|
|
235
235
|
* holds the absolute region size (natural + this), and once `natural`
|
|
236
236
|
* outgrows the margin the two are indistinguishable. The realloc slow path
|
|
237
237
|
* reads it via `optionsFromOld` and re-reserves the same margin, so a
|
|
238
|
-
* store that exhausts its headroom and reallocs keeps taking the
|
|
239
|
-
* in-place fast path instead of going permanently slow
|
|
238
|
+
* store that exhausts its headroom and reallocs keeps taking the
|
|
239
|
+
* in-place fast path instead of going permanently slow. The
|
|
240
240
|
* `*_in_place` paths carry it forward verbatim. */
|
|
241
241
|
readonly _reservedDescriptorBytes: number;
|
|
242
242
|
}
|
|
243
|
-
/** Typed recovery of `ColumnStoreInternal` from a public `ColumnStore
|
|
243
|
+
/** Typed recovery of `ColumnStoreInternal` from a public `ColumnStore`.
|
|
244
244
|
* Not every store is internal: `restoreColumnStore` deliberately returns a
|
|
245
245
|
* plain `{ buffer, view, header, archetypes }` (a snapshot carries no JS-side
|
|
246
246
|
* allocator or headroom policy), and grow/extend must send such a store down
|
|
@@ -252,8 +252,8 @@ export declare function isColumnStoreInternal(store: ColumnStore): store is Colu
|
|
|
252
252
|
* and construct one TypedArray view per column.
|
|
253
253
|
*
|
|
254
254
|
* The returned `ColumnStore` is the source of truth for "where every column
|
|
255
|
-
* lives in this SAB". `view_stamp` is initialised to 0 — a
|
|
256
|
-
* grow flow
|
|
255
|
+
* lives in this SAB". `view_stamp` is initialised to 0 — a SAB
|
|
256
|
+
* grow flow bumps it. */
|
|
257
257
|
export declare function createColumnStore(specs: readonly ArchetypeSpec[], allocator?: BufferAllocator, options?: CreateColumnStoreOptions): ColumnStore;
|
|
258
258
|
/** Default command-ring slot count used by `ECS.Store` when constructing
|
|
259
259
|
* its SAB. Re-exported here so the Store doesn't reach across modules. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column_store.d.ts","sourceRoot":"","sources":["../../../src/core/store/column_store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAKN,KAAK,WAAW,EAChB,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,KAAK,mBAAmB,EAExB,KAAK,YAAY,EAKjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,mCAAmC,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,iCAAiC,EAAE,MAAM,cAAc,CAAC;AAEjE,OAAO,EAKN,KAAK,eAAe,EACpB,MAAM,gBAAgB,CAAC;AAExB,4EAA4E;AAC5E,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;CAC/B;AAED;kEACkE;AAClE,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,yEAAyE;IACzE,QAAQ,CAAC,aAAa,EAAE,S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AKyB;AACzB,wBAAgB,iBAAiB,CAChC,KAAK,EAAE,SAAS,aAAa,EAAE,EAC/B,SAAS,GAAE,eAAuC,EAClD,OAAO,GAAE,wBAA6B,GACpC,WAAW,CA2Hb;AAED;0EAC0E;AAC1E,OAAO,EAAE,mCAAmC,EAAE,CAAC;AAE/C;2EAC2E;AAC3E,OAAO,EAAE,6BAA6B,EAAE,CAAC;AAEzC;wDACwD;AACxD,OAAO,EAAE,iCAAiC,EAAE,CAAC;AAE7C;;;;uDAIuD;AACvD,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,eAAe,EACvB,WAAW,EAAE,SAAS,mBAAmB,EAAE,GACzC,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CA4B7B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Command dispatch — the generic drain surface a consumer registers against
|
|
3
|
-
* (
|
|
3
|
+
* (a game-agnostic ECS).
|
|
4
4
|
*
|
|
5
5
|
* The command ring (`command_ring.ts`) carries opaque `(opCode, payload)`
|
|
6
6
|
* slots; the engine never interprets a code. This module is the thin,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Command dispatch — the generic drain surface a consumer registers against
|
|
3
|
-
* (
|
|
3
|
+
* (a game-agnostic ECS).
|
|
4
4
|
*
|
|
5
5
|
* The command ring (`command_ring.ts`) carries opaque `(opCode, payload)`
|
|
6
6
|
* slots; the engine never interprets a code. This module is the thin,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Command ring — WASM-side producer / TS-side consumer SPSC ring buffer
|
|
3
|
-
* for structural-change intents emitted during `sim.tick()`.
|
|
4
|
-
* (`docs/ideas/buffer-wasm-sim-plan-2026-05-14T1600.md`).
|
|
3
|
+
* for structural-change intents emitted during `sim.tick()`.
|
|
5
4
|
*
|
|
6
5
|
* Layout:
|
|
7
6
|
*
|
|
@@ -13,13 +12,13 @@
|
|
|
13
12
|
* [ slot 1: 16 B ] ...
|
|
14
13
|
* ...
|
|
15
14
|
*
|
|
16
|
-
* SPSC contract (
|
|
15
|
+
* SPSC contract (single host thread):
|
|
17
16
|
* - Producer: WASM `sim.tick()`. Pushes 0..N commands during one tick;
|
|
18
17
|
* bumps `write_head` after each.
|
|
19
18
|
* - Consumer: TS host, immediately after `wasm.tick()` returns. Drains
|
|
20
19
|
* 0..N pending commands; bumps `read_head` after each.
|
|
21
|
-
* - The two never run concurrently
|
|
22
|
-
*
|
|
20
|
+
* - The two never run concurrently (one host thread orchestrates
|
|
21
|
+
* both). A later worker offload promotes the head
|
|
23
22
|
* bumps to `Atomics.store`; that's an additive change without
|
|
24
23
|
* altering the layout.
|
|
25
24
|
*
|
|
@@ -29,7 +28,7 @@
|
|
|
29
28
|
* a hard error in dev builds; production logs and continues (a command
|
|
30
29
|
* might be lost rather than crash the host).
|
|
31
30
|
*
|
|
32
|
-
* Slot format
|
|
31
|
+
* Slot format:
|
|
33
32
|
* byte 0: opCode (u8). 0 is reserved as the empty-slot marker
|
|
34
33
|
* (`COMMAND_OP_EMPTY`); all other codes are consumer-defined.
|
|
35
34
|
* The engine never interprets a code — it drains
|
|
@@ -52,7 +51,7 @@ export declare const COMMAND_RING_HEADER_BYTES = 16;
|
|
|
52
51
|
export declare const COMMAND_RING_SLOT_BYTES = 16;
|
|
53
52
|
/** Default ring capacity in slots. 256 × 16 B = 4 KiB of ring data plus
|
|
54
53
|
* 16 B header. Sized for the worst-case burst (peak spawn intents per
|
|
55
|
-
* tick) × small safety margin. Tune up if a
|
|
54
|
+
* tick) × small safety margin. Tune up if a burst pushes past it
|
|
56
55
|
* in the bench harness. */
|
|
57
56
|
export declare const COMMAND_RING_DEFAULT_CAPACITY_SLOTS = 256;
|
|
58
57
|
/** Byte offsets within the ring header. Mirrored on the Zig side in
|