@oasys/oecs 0.4.0 → 0.5.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/CHANGELOG.md +553 -0
- package/README.md +42 -31
- package/dist/core/ecs/access_check.d.cts +77 -0
- package/dist/core/ecs/access_check.d.ts +8 -8
- package/dist/core/ecs/access_check.d.ts.map +1 -1
- package/dist/core/ecs/archetype.d.cts +486 -0
- package/dist/core/ecs/archetype.d.ts +23 -11
- package/dist/core/ecs/archetype.d.ts.map +1 -1
- package/dist/core/ecs/archetype_graph.d.cts +96 -0
- package/dist/core/ecs/archetype_graph.d.ts +96 -0
- package/dist/core/ecs/archetype_graph.d.ts.map +1 -0
- package/dist/core/ecs/builtin_relations.d.cts +43 -0
- package/dist/core/ecs/builtin_relations.d.ts +8 -8
- package/dist/core/ecs/builtin_relations.d.ts.map +1 -1
- package/dist/core/ecs/command_log.d.cts +116 -0
- package/dist/core/ecs/command_log.d.ts +13 -10
- package/dist/core/ecs/command_log.d.ts.map +1 -1
- package/dist/core/ecs/component.d.cts +176 -0
- package/dist/core/ecs/component.d.ts +75 -5
- package/dist/core/ecs/component.d.ts.map +1 -1
- package/dist/core/ecs/compute_backend.d.cts +37 -0
- package/dist/core/ecs/compute_backend.d.ts +2 -2
- package/dist/core/ecs/debug_names.d.cts +7 -0
- package/dist/core/ecs/debug_names.d.ts +7 -0
- package/dist/core/ecs/debug_names.d.ts.map +1 -0
- package/dist/core/ecs/deferred_commands.d.cts +55 -0
- package/dist/core/ecs/deferred_commands.d.ts +55 -0
- package/dist/core/ecs/deferred_commands.d.ts.map +1 -0
- package/dist/core/ecs/dispatch_trace.d.cts +93 -0
- package/dist/core/ecs/dispatch_trace.d.ts +3 -3
- package/dist/core/ecs/ecs.d.cts +562 -0
- package/dist/core/ecs/ecs.d.ts +314 -285
- package/dist/core/ecs/ecs.d.ts.map +1 -1
- package/dist/core/ecs/ecs_memory.d.cts +179 -0
- package/dist/core/ecs/ecs_memory.d.ts +1 -1
- package/dist/core/ecs/entity.d.cts +34 -0
- package/dist/core/ecs/entity.d.ts +7 -1
- package/dist/core/ecs/entity.d.ts.map +1 -1
- package/dist/core/ecs/entity_allocator.d.cts +59 -0
- package/dist/core/ecs/entity_allocator.d.ts +59 -0
- package/dist/core/ecs/entity_allocator.d.ts.map +1 -0
- package/dist/core/ecs/event.d.cts +79 -0
- package/dist/core/ecs/event.d.ts +36 -11
- package/dist/core/ecs/event.d.ts.map +1 -1
- package/dist/core/ecs/event_registry.d.cts +22 -0
- package/dist/core/ecs/event_registry.d.ts +22 -0
- package/dist/core/ecs/event_registry.d.ts.map +1 -0
- package/dist/core/ecs/facades.d.cts +158 -0
- package/dist/core/ecs/facades.d.ts +158 -0
- package/dist/core/ecs/facades.d.ts.map +1 -0
- package/dist/core/ecs/frame_stepper.d.cts +58 -0
- package/dist/core/ecs/frame_stepper.d.ts +58 -0
- package/dist/core/ecs/frame_stepper.d.ts.map +1 -0
- package/dist/core/ecs/frame_trace.d.cts +133 -0
- package/dist/core/ecs/frame_trace.d.ts +5 -5
- package/dist/core/ecs/frame_trace.d.ts.map +1 -1
- package/dist/core/ecs/host_commands.d.cts +274 -0
- package/dist/core/ecs/host_commands.d.ts +53 -31
- package/dist/core/ecs/host_commands.d.ts.map +1 -1
- package/dist/core/ecs/index.d.cts +46 -0
- package/dist/core/ecs/index.d.ts +45 -40
- package/dist/core/ecs/index.d.ts.map +1 -1
- package/dist/core/ecs/observer.d.cts +173 -0
- package/dist/core/ecs/observer.d.ts +43 -12
- package/dist/core/ecs/observer.d.ts.map +1 -1
- package/dist/core/ecs/query.d.cts +718 -0
- package/dist/core/ecs/query.d.ts +251 -90
- package/dist/core/ecs/query.d.ts.map +1 -1
- package/dist/core/ecs/ref.d.cts +31 -0
- package/dist/core/ecs/ref.d.ts +3 -3
- package/dist/core/ecs/relation.d.cts +243 -0
- package/dist/core/ecs/relation.d.ts +26 -14
- package/dist/core/ecs/relation.d.ts.map +1 -1
- package/dist/core/ecs/relation_service.d.cts +235 -0
- package/dist/core/ecs/relation_service.d.ts +235 -0
- package/dist/core/ecs/relation_service.d.ts.map +1 -0
- package/dist/core/ecs/resource.d.cts +53 -0
- package/dist/core/ecs/resource.d.ts +25 -5
- package/dist/core/ecs/resource.d.ts.map +1 -1
- package/dist/core/ecs/resource_registry.d.cts +20 -0
- package/dist/core/ecs/resource_registry.d.ts +20 -0
- package/dist/core/ecs/resource_registry.d.ts.map +1 -0
- package/dist/core/ecs/resume.d.cts +85 -0
- package/dist/core/ecs/resume.d.ts +6 -6
- package/dist/core/ecs/resume.d.ts.map +1 -1
- package/dist/core/ecs/run_condition.d.cts +81 -0
- package/dist/core/ecs/run_condition.d.ts +15 -9
- package/dist/core/ecs/run_condition.d.ts.map +1 -1
- package/dist/core/ecs/schedule.d.cts +142 -0
- package/dist/core/ecs/schedule.d.ts +15 -6
- package/dist/core/ecs/schedule.d.ts.map +1 -1
- package/dist/core/ecs/snapshot_service.d.cts +94 -0
- package/dist/core/ecs/snapshot_service.d.ts +94 -0
- package/dist/core/ecs/snapshot_service.d.ts.map +1 -0
- package/dist/core/ecs/sparse_store.d.cts +110 -0
- package/dist/core/ecs/sparse_store.d.ts +5 -2
- package/dist/core/ecs/sparse_store.d.ts.map +1 -1
- package/dist/core/ecs/store.d.cts +950 -0
- package/dist/core/ecs/store.d.ts +143 -342
- package/dist/core/ecs/store.d.ts.map +1 -1
- package/dist/core/ecs/store_layout_listener.d.cts +23 -0
- package/dist/core/ecs/system.d.cts +250 -0
- package/dist/core/ecs/system.d.ts +138 -22
- package/dist/core/ecs/system.d.ts.map +1 -1
- package/dist/{utils/arrays.d.ts → core/ecs/utils/arrays.d.cts} +1 -0
- package/dist/core/ecs/utils/error.d.cts +61 -0
- package/dist/core/ecs/utils/error.d.ts +12 -2
- package/dist/core/ecs/utils/error.d.ts.map +1 -1
- package/dist/core/store/action_ring.d.cts +136 -0
- package/dist/core/store/allocator.d.cts +238 -0
- package/dist/core/store/allocator.d.ts.map +1 -1
- package/dist/core/store/buffer_backed_column.d.cts +69 -0
- package/dist/core/store/buffer_backed_column.d.ts +2 -2
- package/dist/core/store/column_store.d.cts +273 -0
- package/dist/core/store/column_store.d.ts +18 -10
- package/dist/core/store/column_store.d.ts.map +1 -1
- package/dist/core/store/command_dispatch.d.cts +52 -0
- package/dist/core/store/command_ring.d.cts +107 -0
- package/dist/core/store/descriptor.d.cts +80 -0
- package/dist/core/store/descriptor.d.ts +1 -1
- package/dist/core/store/descriptor.d.ts.map +1 -1
- package/dist/core/store/entity_index.d.cts +108 -0
- package/dist/core/store/event_ring.d.cts +95 -0
- package/dist/core/store/extend.d.cts +39 -0
- package/dist/core/store/extend.d.ts +3 -73
- package/dist/core/store/extend.d.ts.map +1 -1
- package/dist/core/store/grow.d.cts +34 -0
- package/dist/core/store/grow.d.ts +4 -9
- package/dist/core/store/grow.d.ts.map +1 -1
- package/dist/core/store/header.d.cts +64 -0
- package/dist/core/store/header.d.ts +1 -1
- package/dist/core/store/header.d.ts.map +1 -1
- package/dist/core/store/index.d.cts +17 -0
- package/dist/core/store/index.d.ts +16 -15
- package/dist/core/store/index.d.ts.map +1 -1
- package/dist/core/store/layout_ops.d.cts +152 -0
- package/dist/core/store/layout_ops.d.ts +152 -0
- package/dist/core/store/layout_ops.d.ts.map +1 -0
- package/dist/core/store/region_table.d.cts +74 -0
- package/dist/core/store/region_table.d.ts +1 -1
- package/dist/core/store/region_table.d.ts.map +1 -1
- package/dist/core/store/snapshot.d.cts +43 -0
- package/dist/core/store/snapshot.d.ts +2 -2
- package/dist/core/store/state_hash.d.cts +38 -0
- package/dist/core/store/state_hash.d.ts +1 -1
- package/dist/core/store/store_regions.d.cts +38 -0
- package/dist/core/store/store_regions.d.ts +1 -1
- package/dist/core/store/vendored_abi/abi.d.ts +43 -0
- package/dist/core/store/{__generated__ → vendored_abi}/abi.d.ts.map +1 -1
- package/dist/dev_flag.d.cts +17 -0
- package/dist/dev_flag.d.ts +17 -0
- package/dist/dev_flag.d.ts.map +1 -0
- package/dist/extensions/editor/editor.d.cts +170 -0
- package/dist/extensions/editor/editor.d.ts +43 -22
- package/dist/extensions/editor/editor.d.ts.map +1 -1
- package/dist/extensions/editor/field_handle.d.cts +40 -0
- package/dist/extensions/editor/field_handle.d.ts +8 -3
- package/dist/extensions/editor/field_handle.d.ts.map +1 -1
- package/dist/extensions/editor/index.cjs +1 -1
- package/dist/extensions/editor/index.d.cts +21 -0
- package/dist/extensions/editor/index.d.ts +2 -2
- package/dist/extensions/editor/index.js +116 -88
- package/dist/extensions/reactive/ecs_sync.d.cts +214 -0
- package/dist/extensions/reactive/ecs_sync.d.ts +26 -22
- package/dist/extensions/reactive/ecs_sync.d.ts.map +1 -1
- package/dist/extensions/reactive/index.cjs +1 -1
- package/dist/extensions/reactive/index.d.cts +23 -0
- package/dist/extensions/reactive/index.d.ts +1 -1
- package/dist/extensions/reactive/index.js +106 -116
- package/dist/extensions/solid/index.cjs +1 -1
- package/dist/extensions/solid/index.d.cts +6 -0
- package/dist/extensions/solid/index.d.ts +2 -2
- package/dist/extensions/solid/index.js +8 -4
- package/dist/extensions/solid/kernel_solid.d.cts +45 -0
- package/dist/extensions/solid/kernel_solid.d.ts +6 -3
- package/dist/extensions/solid/kernel_solid.d.ts.map +1 -1
- package/dist/host_commands-BF8QMi3c.cjs +1 -0
- package/dist/host_commands-i4cAeyL5.js +2318 -0
- package/dist/index.cjs +1 -2
- package/dist/index.d.cts +66 -0
- package/dist/index.d.ts +50 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4469 -5933
- package/dist/internal.cjs +2 -0
- package/dist/internal.d.cts +20 -0
- package/dist/internal.d.ts +20 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +141 -0
- package/dist/primitives.cjs +1 -1
- package/dist/primitives.d.cts +18 -0
- package/dist/primitives.d.ts +6 -6
- package/dist/primitives.js +24 -23
- package/dist/reactive/array.d.ts +24 -0
- package/dist/reactive/array.d.ts.map +1 -0
- package/dist/reactive/index.cjs +1 -0
- package/dist/reactive/index.d.cts +11 -0
- package/dist/reactive/index.d.ts +11 -0
- package/dist/reactive/index.d.ts.map +1 -0
- package/dist/reactive/index.js +18 -0
- package/dist/reactive/interop.d.cts +19 -0
- package/dist/{core/reactive → reactive}/interop.d.ts +1 -1
- package/dist/reactive/interop.d.ts.map +1 -0
- package/dist/reactive/kernel.d.cts +73 -0
- package/dist/{core/reactive → reactive}/kernel.d.ts +5 -3
- package/dist/reactive/kernel.d.ts.map +1 -0
- package/dist/reactive/map.d.ts +16 -0
- package/dist/reactive/map.d.ts.map +1 -0
- package/dist/reactive/shallow.d.cts +11 -0
- package/dist/reactive/shallow.d.ts +11 -0
- package/dist/reactive/shallow.d.ts.map +1 -0
- package/dist/reactive/struct.d.cts +10 -0
- package/dist/{core/reactive → reactive}/struct.d.ts +1 -1
- package/dist/reactive/struct.d.ts.map +1 -0
- package/dist/shallow-DQ8aG51_.cjs +1 -0
- package/dist/shallow-DfnAm9vG.js +150 -0
- package/dist/shared-BU1Cd40h.js +103 -0
- package/dist/shared-BymrGTyR.cjs +1 -0
- package/dist/shared.cjs +1 -1
- package/dist/shared.d.cts +22 -0
- package/dist/shared.d.ts +2 -2
- package/dist/shared.js +1 -1
- package/dist/topological_sort-BDvEyb9W.cjs +1 -0
- package/dist/topological_sort-DK6EjpWa.js +135 -0
- package/dist/type_primitives/assertions.d.cts +32 -0
- package/dist/type_primitives/assertions.d.ts +13 -1
- package/dist/type_primitives/assertions.d.ts.map +1 -1
- package/dist/type_primitives/binary_heap/binary_heap.d.cts +37 -0
- package/dist/type_primitives/bitset/bitset.d.cts +54 -0
- package/dist/type_primitives/brand.d.cts +23 -0
- package/dist/type_primitives/error.d.cts +16 -0
- package/dist/type_primitives/error.d.ts +4 -3
- package/dist/type_primitives/error.d.ts.map +1 -1
- package/dist/type_primitives/index.d.cts +13 -0
- package/dist/type_primitives/index.d.ts +9 -9
- package/dist/type_primitives/sparse_map/sparse_map.d.cts +30 -0
- package/dist/type_primitives/sparse_set/sparse_set.d.cts +28 -0
- package/dist/type_primitives/topological_sort/topological_sort.d.cts +29 -0
- package/dist/type_primitives/typed_arrays/typed_arrays.d.cts +127 -0
- package/dist/typed_arrays-BcXcnzB4.js +258 -0
- package/dist/typed_arrays-D3NmwtCG.cjs +1 -0
- package/dist/utils/error.d.cts +6 -0
- package/dist/version.d.cts +10 -0
- package/dist/version.d.ts +10 -0
- package/dist/version.d.ts.map +1 -0
- package/package.json +102 -19
- package/dist/array-CxbPyiHO.cjs +0 -1
- package/dist/array-uFR7Q8fU.js +0 -132
- package/dist/core/reactive/array.d.ts.map +0 -1
- package/dist/core/reactive/index.cjs +0 -1
- package/dist/core/reactive/index.d.ts +0 -10
- package/dist/core/reactive/index.d.ts.map +0 -1
- package/dist/core/reactive/index.js +0 -17
- package/dist/core/reactive/interop.d.ts.map +0 -1
- package/dist/core/reactive/kernel.d.ts.map +0 -1
- package/dist/core/reactive/map.d.ts.map +0 -1
- package/dist/core/reactive/struct.d.ts.map +0 -1
- package/dist/log/console_sink.d.ts +0 -4
- package/dist/log/console_sink.d.ts.map +0 -1
- package/dist/log/index.d.ts +0 -3
- package/dist/log/index.d.ts.map +0 -1
- package/dist/log/logger.d.ts +0 -27
- package/dist/log/logger.d.ts.map +0 -1
- package/dist/shared-BXSZnxx4.cjs +0 -1
- package/dist/shared-C678TAPY.js +0 -99
- package/dist/topological_sort-DlRpSrxu.js +0 -391
- package/dist/topological_sort-WAT-VHb-.cjs +0 -1
- package/dist/utils/arrays.d.ts.map +0 -1
- package/dist/utils/constants.d.ts.map +0 -1
- /package/dist/{utils/constants.d.ts → core/ecs/utils/constants.d.cts} +0 -0
- /package/dist/core/store/{__generated__/abi.d.ts → vendored_abi/abi.d.cts} +0 -0
- /package/dist/{core/reactive/array.d.ts → reactive/array.d.cts} +0 -0
- /package/dist/{core/reactive/map.d.ts → reactive/map.d.cts} +0 -0
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { StoreHeader } from './header.cjs';
|
|
2
|
+
import { ArchetypeDescriptor, TypeTagValue } from './descriptor.cjs';
|
|
3
|
+
import { BufferAllocator } from './allocator.cjs';
|
|
4
|
+
import { COMMAND_RING_DEFAULT_CAPACITY_SLOTS } from './command_ring.cjs';
|
|
5
|
+
import { ENTITY_INDEX_DEFAULT_CAPACITY } from './entity_index.cjs';
|
|
6
|
+
import { EVENT_RING_DEFAULT_CAPACITY_SLOTS } from './event_ring.cjs';
|
|
7
|
+
import { StoreRegionSpec } from './region_table.cjs';
|
|
8
|
+
/** Caller-facing column spec — no `byte_off` yet, the store computes it. */
|
|
9
|
+
export interface ColumnSpec {
|
|
10
|
+
readonly componentId: number;
|
|
11
|
+
readonly fieldId: number;
|
|
12
|
+
readonly typeTag: TypeTagValue;
|
|
13
|
+
}
|
|
14
|
+
/** Caller-facing archetype spec — no `column_count` (derived) and no
|
|
15
|
+
* `byte_off`s in the columns; both are computed during sizing. */
|
|
16
|
+
export interface ArchetypeSpec {
|
|
17
|
+
readonly archetypeId: number;
|
|
18
|
+
/** Component bitmask, `COMPONENT_MASK_WORDS` little-endian u32 words. */
|
|
19
|
+
readonly componentMask: readonly number[];
|
|
20
|
+
readonly rowCapacity: number;
|
|
21
|
+
readonly columns: readonly ColumnSpec[];
|
|
22
|
+
}
|
|
23
|
+
/** A single column's view after allocation. The `byte_off` matches what
|
|
24
|
+
* was recorded in the layout descriptor; `view` is a TypedArray of the
|
|
25
|
+
* right element type, length `row_capacity`, backed by the SAB. */
|
|
26
|
+
export interface ColumnView {
|
|
27
|
+
readonly componentId: number;
|
|
28
|
+
readonly fieldId: number;
|
|
29
|
+
readonly typeTag: TypeTagValue;
|
|
30
|
+
readonly byteOff: number;
|
|
31
|
+
readonly stride: number;
|
|
32
|
+
readonly view: AnyTypedArray;
|
|
33
|
+
}
|
|
34
|
+
/** Views for all columns in a single archetype, indexed by a numeric
|
|
35
|
+
* key encoding `(component_id, field_id)` so a (cid, fid) pair maps to
|
|
36
|
+
* its column in O(1). The encoding (see `columnKey`) is dense over
|
|
37
|
+
* (cid: 0..65535, fid: 0..65535), letting V8 keep this as a
|
|
38
|
+
* Number-keyed `Map` — meaningfully faster than the previous string
|
|
39
|
+
* keys (no per-lookup template-string allocation, no string hashing).
|
|
40
|
+
* The row order matches `ArchetypeSpec.columns`. The
|
|
41
|
+
* `component_mask` words mirror what's in the SAB layout descriptor so
|
|
42
|
+
* `growColumnStore` (and any other carry-forward path) doesn't have to
|
|
43
|
+
* re-parse the descriptor region. */
|
|
44
|
+
export interface ArchetypeViews {
|
|
45
|
+
readonly archetypeId: number;
|
|
46
|
+
/** Component bitmask, `COMPONENT_MASK_WORDS` little-endian u32 words. */
|
|
47
|
+
readonly componentMask: readonly number[];
|
|
48
|
+
readonly rowCapacity: number;
|
|
49
|
+
readonly columns: ReadonlyMap<number, ColumnView>;
|
|
50
|
+
readonly columnsInOrder: readonly ColumnView[];
|
|
51
|
+
}
|
|
52
|
+
export interface ColumnStore {
|
|
53
|
+
/** The backing buffer. `ArrayBufferLike` because the store is backing-agnostic:
|
|
54
|
+
* a `SharedArrayBuffer` for the SAB/WASM/worker profile, or a plain resizable
|
|
55
|
+
* `ArrayBuffer` for the pure-TS heap profile (`heapArraybufferAllocator`).
|
|
56
|
+
* Consumers that genuinely require sharing (worker transfer, WASM memory)
|
|
57
|
+
* narrow back to `SharedArrayBuffer` at their boundary. */
|
|
58
|
+
readonly buffer: ArrayBufferLike;
|
|
59
|
+
readonly view: DataView;
|
|
60
|
+
readonly header: StoreHeader;
|
|
61
|
+
/** Indexed by `archetype_id`. */
|
|
62
|
+
readonly archetypes: ReadonlyMap<number, ArchetypeViews>;
|
|
63
|
+
}
|
|
64
|
+
export type AnyTypedArray = Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array | Float32Array | Float64Array;
|
|
65
|
+
/** Pack `(component_id, field_id)` into a single non-negative integer so
|
|
66
|
+
* `ArchetypeViews.columns` can be a `Map<number, ColumnView>` instead of
|
|
67
|
+
* `Map<string, ColumnView>`. V8's number-keyed `Map` skips the
|
|
68
|
+
* string-hash + string-equality every lookup pays, and template-string
|
|
69
|
+
* keys (`"${cid}:${fid}"`) allocated a fresh string on every call. On
|
|
70
|
+
* the lazy-registration ramp-up the per-extend `refreshViews`
|
|
71
|
+
* walks `N` × `cols` of these lookups for `N` archetypes, so the saving
|
|
72
|
+
* compounds quadratically.
|
|
73
|
+
*
|
|
74
|
+
* Encoding: `(component_id << 16) | field_id`. `component_id` is bounded
|
|
75
|
+
* by `STORE_DESCRIPTOR_COMPONENT_LIMIT` (the registration cap, 128), well
|
|
76
|
+
* below 65536. `field_id` is bounded by the component's schema width,
|
|
77
|
+
* single digits in practice. */
|
|
78
|
+
export declare function columnKey(componentId: number, fieldId: number): number;
|
|
79
|
+
/** First byte offset the SAB layout math cannot represent: 2³¹.
|
|
80
|
+
*
|
|
81
|
+
* `alignUp` rounds with `& ~(align-1)`, and JS bitwise operators coerce
|
|
82
|
+
* their operands to **signed** 32-bit integers (`ToInt32`). Once an offset
|
|
83
|
+
* reaches 2³¹ the result wraps to a negative number (or, for some inputs, a
|
|
84
|
+
* misaligned positive one), which then flows straight into
|
|
85
|
+
* `new Uint8Array(buffer, byte_off, …)` — either a thrown `RangeError` deep in
|
|
86
|
+
* the TypedArray ctor or, worse, a silently wrong view overlapping another
|
|
87
|
+
* column. The 256 MiB default allocator cap (`growableSabAllocator`) keeps
|
|
88
|
+
* real matches three orders of magnitude below this, but the cap is tunable
|
|
89
|
+
* and callers are invited to raise it for bigger worlds — so the layout step
|
|
90
|
+
* guards the hard 2³¹ ceiling explicitly rather than relying on the policy
|
|
91
|
+
* cap to stay in front of it (#382). */
|
|
92
|
+
export declare const STORE_MAX_BYTE_OFFSET: number;
|
|
93
|
+
/** Thrown when a SAB column layout would place an offset at or beyond
|
|
94
|
+
* {@link STORE_MAX_BYTE_OFFSET} (2³¹), past which the signed-32-bit bitwise
|
|
95
|
+
* `alignUp` can no longer produce correct offsets. This is a hard ceiling,
|
|
96
|
+
* not the (tunable, much lower) 256 MiB allocator cap — see #382. */
|
|
97
|
+
export declare class StoreLayoutOverflowError extends Error {
|
|
98
|
+
constructor(byteOff: number);
|
|
99
|
+
}
|
|
100
|
+
/** Round `off` up to the next multiple of `align`. `align` must be a power
|
|
101
|
+
* of two (1/2/4/8 here, all `TYPE_TAG_STRIDE` values).
|
|
102
|
+
*
|
|
103
|
+
* Throws {@link StoreLayoutOverflowError} when the rounded offset would reach
|
|
104
|
+
* {@link STORE_MAX_BYTE_OFFSET}, because the `& ~(align-1)` step coerces to a
|
|
105
|
+
* signed 32-bit int and wraps past 2³¹ (#382). The guard fires before the
|
|
106
|
+
* bitwise op so any returned offset is always a correct, in-range value.
|
|
107
|
+
* Shared by `extend.ts` and `grow.ts`, whose in-place paths compute tail
|
|
108
|
+
* byte_offs without going through `planLayout`. */
|
|
109
|
+
export declare function alignUp(off: number, align: number): number;
|
|
110
|
+
/** Build the layout-descriptor-region descriptors (with `byte_off` and
|
|
111
|
+
* `stride` filled in) and return both them and the byte offset just past
|
|
112
|
+
* the last column — i.e. the total SAB size.
|
|
113
|
+
*
|
|
114
|
+
* `headroomBytes` reserves slack at the end of the descriptor region — ON
|
|
115
|
+
* TOP OF the natural size for `specs` — so future extends can append new
|
|
116
|
+
* descriptor entries without shifting existing column byte_offs. Used by
|
|
117
|
+
* the growable-SAB path (#237 Option A) — column views stay valid across
|
|
118
|
+
* `extendColumnStore` because their byte_offs don't move.
|
|
119
|
+
*
|
|
120
|
+
* Additive, not a floor (#541): `regionSize = natural + headroom`, NOT
|
|
121
|
+
* `max(natural, headroom)`. A floor only yields slack while `natural` is
|
|
122
|
+
* below it; the moment the descriptor region outgrows the floor (the #237
|
|
123
|
+
* headroom exhausts and a realloc re-plans the merged spec set), a floor
|
|
124
|
+
* would size the region to exactly `natural` — zero slack — and every
|
|
125
|
+
* subsequent extend would take the slow realloc path forever after. The
|
|
126
|
+
* additive form re-creates the same `headroom` margin on every realloc.
|
|
127
|
+
* For the engine's empty-seed store (`createColumnStore([], …)`, where
|
|
128
|
+
* `natural === 0`) the two forms coincide, so this is behaviour-identical
|
|
129
|
+
* for the only production caller. */
|
|
130
|
+
declare function planLayout(specs: readonly ArchetypeSpec[], regionOff: number, headroomBytes?: number): {
|
|
131
|
+
descriptors: ArchetypeDescriptor[];
|
|
132
|
+
totalBytes: number;
|
|
133
|
+
regionBytes: number;
|
|
134
|
+
};
|
|
135
|
+
/** Exported for the layout tests' overflow-guard coverage; the in-place
|
|
136
|
+
* resize paths use `layoutColumnsAtTail` (layout_ops.ts), not this. */
|
|
137
|
+
export { planLayout };
|
|
138
|
+
/** Optional configuration for `createColumnStore`. */
|
|
139
|
+
export interface CreateColumnStoreOptions {
|
|
140
|
+
/** Extra slack to reserve at the end of the layout descriptor region,
|
|
141
|
+
* ON TOP OF the natural size for `specs` (#541 — additive, not a floor).
|
|
142
|
+
* The descriptor region is padded with this many unused bytes so future
|
|
143
|
+
* `extendColumnStore` calls can append new archetype descriptors into the
|
|
144
|
+
* slack without shifting existing column byte_offs. Pairs with
|
|
145
|
+
* `growableSabAllocator` to give the #237 Option A fast path: existing
|
|
146
|
+
* TypedArray column views stay valid across extends because their offsets
|
|
147
|
+
* and the underlying buffer both stay put.
|
|
148
|
+
*
|
|
149
|
+
* Carried forward as a policy across the realloc-and-republish path: the
|
|
150
|
+
* value lives on `ColumnStoreInternal._reservedDescriptorBytes` and
|
|
151
|
+
* `optionsFromOld` re-applies it, so a store that exhausts its headroom
|
|
152
|
+
* and reallocs gets a fresh margin rather than dropping to zero slack and
|
|
153
|
+
* going permanently slow (#541). */
|
|
154
|
+
readonly reservedDescriptorBytes?: number;
|
|
155
|
+
/** When provided, allocates a command ring (#171 §7.5, Phase 4) inside
|
|
156
|
+
* the SAB at a stable offset right after the 48-byte header. Slot
|
|
157
|
+
* count MUST be a power of two; `COMMAND_RING_DEFAULT_CAPACITY_SLOTS`
|
|
158
|
+
* (256) is the canonical value. Omitted ⇒ no ring; `command_ring_off`
|
|
159
|
+
* stays at 0 ("absent"); existing test fixtures with hand-rolled SABs
|
|
160
|
+
* see the legacy layout (descriptor region immediately after header).
|
|
161
|
+
*
|
|
162
|
+
* Sizing the ring this way — between header and descriptor region —
|
|
163
|
+
* keeps `command_ring_off` stable across `extendColumnStore` /
|
|
164
|
+
* `growColumnStore` calls, since those grow the descriptor region and
|
|
165
|
+
* the column tail but never the bytes between header and descriptor. */
|
|
166
|
+
readonly commandRingCapacitySlots?: number;
|
|
167
|
+
/** When provided, allocates the entity-index region (#245 / Phase 4
|
|
168
|
+
* PR 4B) inside the SAB at a stable offset between the command ring
|
|
169
|
+
* (or header) and the descriptor region. Holds `(generations,
|
|
170
|
+
* archetypes, rows)` triples indexed by entity slot; the engine's
|
|
171
|
+
* `Store` populates them as entities are created/moved/destroyed,
|
|
172
|
+
* and Zig systems read them to resolve cross-entity targets without
|
|
173
|
+
* a callback. Capacity is in *slots* (entities), not bytes; each
|
|
174
|
+
* slot is 12 bytes. Omitted ⇒ no region; `entity_index_off` stays
|
|
175
|
+
* at 0 ("absent"). The engine's Store always sets it to
|
|
176
|
+
* `ENTITY_INDEX_DEFAULT_CAPACITY`; bare-SAB tests can leave it
|
|
177
|
+
* absent. */
|
|
178
|
+
readonly entityIndexCapacity?: number;
|
|
179
|
+
/** When provided, allocates the event ring (#247 / Phase 4 PR 4C)
|
|
180
|
+
* inside the SAB at a stable offset between the entity-index region
|
|
181
|
+
* and the descriptor region. Same SPSC shape as the command ring;
|
|
182
|
+
* carries ECS signal payloads so Zig systems can emit and consume
|
|
183
|
+
* them during `tick()` without callbacks into TS.
|
|
184
|
+
*
|
|
185
|
+
* Slot count MUST be a power of two; `EVENT_RING_DEFAULT_CAPACITY_SLOTS`
|
|
186
|
+
* (256) is the canonical value. Omitted ⇒ no ring; `event_ring_off`
|
|
187
|
+
* stays at 0 ("absent"); existing test fixtures with hand-rolled
|
|
188
|
+
* SABs see the pre-#247 layout. */
|
|
189
|
+
readonly eventRingCapacitySlots?: number;
|
|
190
|
+
/** When provided, allocates the action ring (#291 / Phase 5 PR 5L)
|
|
191
|
+
* inside the SAB at a stable offset between the entity-index/event-ring
|
|
192
|
+
* and the region-table directory. Main writes encoded actions to it;
|
|
193
|
+
* the sim worker drains them on each apply.
|
|
194
|
+
*
|
|
195
|
+
* Slot count MUST be a power of two; `ACTION_RING_DEFAULT_CAPACITY_SLOTS`
|
|
196
|
+
* (256) is the canonical value. Omitted ⇒ no ring; `action_ring_off`
|
|
197
|
+
* stays at 0 ("absent"); bare-SAB tests skip it. (Engine mechanism — the
|
|
198
|
+
* `Store` allocates one always-on; it is no longer a public ECS option.) */
|
|
199
|
+
readonly actionRingCapacitySlots?: number;
|
|
200
|
+
/** Consumer-declared SAB regions (#623). Each `StoreRegionSpec` carries an
|
|
201
|
+
* opaque `region_id`, a precomputed byte size, and an `init` closure; the
|
|
202
|
+
* engine lays them out after the mechanism regions, writes a generic
|
|
203
|
+
* region-table directory (`region_table.ts`) keyed by `region_id`, and
|
|
204
|
+
* snapshots/restores them across a grow/extend. The engine never
|
|
205
|
+
* interprets `region_id` — a game (e.g. `@internal/sim`'s region specs)
|
|
206
|
+
* owns it. Omitted ⇒ no consumer regions; `region_table_off` stays 0. */
|
|
207
|
+
readonly regions?: readonly StoreRegionSpec[];
|
|
208
|
+
/** Byte size of the always-before-descriptor sim-bindings region (v5 /
|
|
209
|
+
* "SAB-is-the-interface"). A consumer that opts into a WASM backend supplies
|
|
210
|
+
* its own size here — `@internal/sim`'s `SIM_BINDINGS_BYTES`, computed from
|
|
211
|
+
* the game's binding manifest. The engine treats the region as opaque bytes:
|
|
212
|
+
* it reserves the block at `bindings_off` (right before the descriptor
|
|
213
|
+
* region, so the offset is stable across grow/extend) and the host writes the
|
|
214
|
+
* `(component_id, field_id)` IDs into it via `write_sim_bindings`.
|
|
215
|
+
*
|
|
216
|
+
* Omitted / 0 ⇒ NO bindings region (`bindings_off` stays 0, "absent") — the
|
|
217
|
+
* default for a pure-TS game that pays nothing for the WASM seam. This used
|
|
218
|
+
* to be the engine-baked `SIM_BINDINGS_BYTES` ABI constant reflected from the
|
|
219
|
+
* game's Zig struct; #625 de-welded it so a manifest edit no longer dirties
|
|
220
|
+
* the engine ABI golden. Re-derived across realloc by `optionsFromOld`
|
|
221
|
+
* (= `layout_descriptor_off - bindings_off`), so it survives grow/extend
|
|
222
|
+
* without a carried policy field. */
|
|
223
|
+
readonly bindingsRegionBytes?: number;
|
|
224
|
+
}
|
|
225
|
+
/** Internal `ColumnStore` extension carrying the descriptor-region byte
|
|
226
|
+
* size. Used by the in-place extend path to know where the next
|
|
227
|
+
* descriptor entry should be written (= `regionOff + region_bytes_used`,
|
|
228
|
+
* tracked separately) and how much headroom remains. */
|
|
229
|
+
export interface ColumnStoreInternal extends ColumnStore {
|
|
230
|
+
readonly _regionBytes: number;
|
|
231
|
+
readonly _allocator: BufferAllocator;
|
|
232
|
+
/** The `reservedDescriptorBytes` policy this store was created with
|
|
233
|
+
* (the additive descriptor-region headroom margin; 0 when none). Carried
|
|
234
|
+
* with the store — NOT re-derivable from the SAB bytes, since `_regionBytes`
|
|
235
|
+
* holds the absolute region size (natural + this), and once `natural`
|
|
236
|
+
* outgrows the margin the two are indistinguishable. The realloc slow path
|
|
237
|
+
* reads it via `optionsFromOld` and re-reserves the same margin, so a
|
|
238
|
+
* store that exhausts its headroom and reallocs keeps taking the #237
|
|
239
|
+
* in-place fast path instead of going permanently slow (#541). The
|
|
240
|
+
* `*_in_place` paths carry it forward verbatim. */
|
|
241
|
+
readonly _reservedDescriptorBytes: number;
|
|
242
|
+
}
|
|
243
|
+
/** Typed recovery of `ColumnStoreInternal` from a public `ColumnStore` (M8).
|
|
244
|
+
* Not every store is internal: `restoreColumnStore` deliberately returns a
|
|
245
|
+
* plain `{ buffer, view, header, archetypes }` (a snapshot carries no JS-side
|
|
246
|
+
* allocator or headroom policy), and grow/extend must send such a store down
|
|
247
|
+
* the realloc slow path. This guard is the ONE place that discrimination
|
|
248
|
+
* happens — grow/extend previously re-derived the internal type via
|
|
249
|
+
* structural `as`-casts at six sites. */
|
|
250
|
+
export declare function isColumnStoreInternal(store: ColumnStore): store is ColumnStoreInternal;
|
|
251
|
+
/** Allocate a SAB sized for `specs`, write the header + layout descriptor,
|
|
252
|
+
* and construct one TypedArray view per column.
|
|
253
|
+
*
|
|
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 Phase 4 SAB
|
|
256
|
+
* grow flow will bump it. (#171 §6.1.4 / §8.1) */
|
|
257
|
+
export declare function createColumnStore(specs: readonly ArchetypeSpec[], allocator?: BufferAllocator, options?: CreateColumnStoreOptions): ColumnStore;
|
|
258
|
+
/** Default command-ring slot count used by `ECS.Store` when constructing
|
|
259
|
+
* its SAB. Re-exported here so the Store doesn't reach across modules. */
|
|
260
|
+
export { COMMAND_RING_DEFAULT_CAPACITY_SLOTS };
|
|
261
|
+
/** Default entity-index capacity used by `ECS.Store` when constructing
|
|
262
|
+
* its SAB. Re-exported alongside `COMMAND_RING_DEFAULT_CAPACITY_SLOTS`. */
|
|
263
|
+
export { ENTITY_INDEX_DEFAULT_CAPACITY };
|
|
264
|
+
/** Default event-ring slot count used by `ECS.Store` when constructing
|
|
265
|
+
* its SAB. Re-exported alongside the other defaults. */
|
|
266
|
+
export { EVENT_RING_DEFAULT_CAPACITY_SLOTS };
|
|
267
|
+
/** Build the `ArchetypeViews` map from a SAB and its parsed descriptors.
|
|
268
|
+
* Shared by `createColumnStore` (fresh allocation, byte_offs just computed)
|
|
269
|
+
* and `restoreColumnStore` (existing allocation, byte_offs read out of the
|
|
270
|
+
* snapshot). Either way the views land at the byte_offs the descriptors
|
|
271
|
+
* already carry — this helper does not plan layout. */
|
|
272
|
+
export declare function buildArchetypeViews(buffer: ArrayBufferLike, descriptors: readonly ArchetypeDescriptor[]): Map<number, ArchetypeViews>;
|
|
273
|
+
//# sourceMappingURL=column_store.d.ts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { StoreHeader } from './header';
|
|
2
|
-
import { ArchetypeDescriptor, TypeTagValue } from './descriptor';
|
|
3
|
-
import { BufferAllocator } from './allocator';
|
|
4
|
-
import { COMMAND_RING_DEFAULT_CAPACITY_SLOTS } from './command_ring';
|
|
5
|
-
import { ENTITY_INDEX_DEFAULT_CAPACITY } from './entity_index';
|
|
6
|
-
import { EVENT_RING_DEFAULT_CAPACITY_SLOTS } from './event_ring';
|
|
7
|
-
import { StoreRegionSpec } from './region_table';
|
|
1
|
+
import { StoreHeader } from './header.js';
|
|
2
|
+
import { ArchetypeDescriptor, TypeTagValue } from './descriptor.js';
|
|
3
|
+
import { BufferAllocator } from './allocator.js';
|
|
4
|
+
import { COMMAND_RING_DEFAULT_CAPACITY_SLOTS } from './command_ring.js';
|
|
5
|
+
import { ENTITY_INDEX_DEFAULT_CAPACITY } from './entity_index.js';
|
|
6
|
+
import { EVENT_RING_DEFAULT_CAPACITY_SLOTS } from './event_ring.js';
|
|
7
|
+
import { StoreRegionSpec } from './region_table.js';
|
|
8
8
|
/** Caller-facing column spec — no `byte_off` yet, the store computes it. */
|
|
9
9
|
export interface ColumnSpec {
|
|
10
10
|
readonly componentId: number;
|
|
@@ -132,9 +132,9 @@ declare function planLayout(specs: readonly ArchetypeSpec[], regionOff: number,
|
|
|
132
132
|
totalBytes: number;
|
|
133
133
|
regionBytes: number;
|
|
134
134
|
};
|
|
135
|
-
/**
|
|
136
|
-
*
|
|
137
|
-
export { planLayout
|
|
135
|
+
/** Exported for the layout tests' overflow-guard coverage; the in-place
|
|
136
|
+
* resize paths use `layoutColumnsAtTail` (layout_ops.ts), not this. */
|
|
137
|
+
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,
|
|
@@ -240,6 +240,14 @@ export interface ColumnStoreInternal extends ColumnStore {
|
|
|
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` (M8).
|
|
244
|
+
* Not every store is internal: `restoreColumnStore` deliberately returns a
|
|
245
|
+
* plain `{ buffer, view, header, archetypes }` (a snapshot carries no JS-side
|
|
246
|
+
* allocator or headroom policy), and grow/extend must send such a store down
|
|
247
|
+
* the realloc slow path. This guard is the ONE place that discrimination
|
|
248
|
+
* happens — grow/extend previously re-derived the internal type via
|
|
249
|
+
* structural `as`-casts at six sites. */
|
|
250
|
+
export declare function isColumnStoreInternal(store: ColumnStore): store is ColumnStoreInternal;
|
|
243
251
|
/** Allocate a SAB sized for `specs`, write the header + layout descriptor,
|
|
244
252
|
* and construct one TypedArray view per column.
|
|
245
253
|
*
|
|
@@ -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,CAA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3
|
+
* (#624, game-agnostic ECS / epic #616).
|
|
4
|
+
*
|
|
5
|
+
* The command ring (`command_ring.ts`) carries opaque `(opCode, payload)`
|
|
6
|
+
* slots; the engine never interprets a code. This module is the thin,
|
|
7
|
+
* game-free glue that lets a consumer bind a payload codec + typed handler to
|
|
8
|
+
* each opcode and drain the ring in one call. The opcode enum and the codecs
|
|
9
|
+
* themselves stay consumer-owned — for our game they live in
|
|
10
|
+
* `@internal/sim`'s `command_payloads.ts` (`COMMAND_OP`, `SpawnUnitFields`,
|
|
11
|
+
* `encode/decode_spawn_unit_payload`); the engine knows none of those names.
|
|
12
|
+
*
|
|
13
|
+
* Usage:
|
|
14
|
+
*
|
|
15
|
+
* const dispatcher = new CommandDispatcher()
|
|
16
|
+
* .on(COMMAND_OP.spawn_unit, spawn_unit_codec, (fields) => spawn(fields));
|
|
17
|
+
* dispatcher.drain(view, ringOff); // runs after wasm.tick() returns
|
|
18
|
+
*
|
|
19
|
+
* Unregistered opcodes are skipped (the same forward-compatible stance as the
|
|
20
|
+
* raw `drainCommandRing` handler that ignores codes it doesn't know).
|
|
21
|
+
*/
|
|
22
|
+
/** Decode (and, symmetrically, encode) the 15-byte payload region of a
|
|
23
|
+
* command slot into a typed value. A consumer supplies one per opcode it
|
|
24
|
+
* cares about; the engine only ever calls `decode` during a drain, but the
|
|
25
|
+
* `encode` half keeps the codec a single round-trippable unit (and is what
|
|
26
|
+
* test/host producers use to push). */
|
|
27
|
+
export interface PayloadCodec<T> {
|
|
28
|
+
/** Encode `value` into a fresh `COMMAND_RING_SLOT_BYTES - 1` (15) byte
|
|
29
|
+
* payload, ready for `pushCommand(view, off, op, payload)`. */
|
|
30
|
+
encode(value: T): Uint8Array;
|
|
31
|
+
/** Decode a 15-byte payload back into the typed value. */
|
|
32
|
+
decode(payload: Uint8Array): T;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Registry mapping command opcodes to a payload codec + handler. Generic over
|
|
36
|
+
* the consumer's opcodes — the engine ships the mechanism; the game supplies
|
|
37
|
+
* the codes and codecs.
|
|
38
|
+
*/
|
|
39
|
+
export declare class CommandDispatcher {
|
|
40
|
+
private readonly bindings;
|
|
41
|
+
/** Register `handler` for `opCode`, decoding each slot with `codec`.
|
|
42
|
+
* Re-registering an opcode replaces its binding. `opCode` must be a u8 in
|
|
43
|
+
* `[1, 255]` — `0` is the reserved empty-slot marker and can never carry a
|
|
44
|
+
* command. Returns `this` for chaining. */
|
|
45
|
+
on<T>(opCode: number, codec: PayloadCodec<T>, handler: (value: T) => void): this;
|
|
46
|
+
/** Drain every pending command, decoding + dispatching each to its
|
|
47
|
+
* registered handler. Commands with no registered opcode are skipped.
|
|
48
|
+
* Returns the number of slots drained (including skipped ones — the ring is
|
|
49
|
+
* advanced regardless, matching `drainCommandRing`). */
|
|
50
|
+
drain(view: DataView, ringOff: number): number;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=command_dispatch.d.ts.map
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command ring — WASM-side producer / TS-side consumer SPSC ring buffer
|
|
3
|
+
* for structural-change intents emitted during `sim.tick()`. Plan §7.5
|
|
4
|
+
* (`docs/ideas/buffer-wasm-sim-plan-2026-05-14T1600.md`).
|
|
5
|
+
*
|
|
6
|
+
* Layout:
|
|
7
|
+
*
|
|
8
|
+
* [ write_head: u32 ] slot 0..N-1, monotonic (NOT slot-modulo)
|
|
9
|
+
* [ read_head: u32 ] slot 0..N-1, monotonic
|
|
10
|
+
* [ capacity: u32 ] slot count, power-of-two
|
|
11
|
+
* [ overflow: u32 ] 0 = OK; 1 = WASM exhausted the ring this tick
|
|
12
|
+
* [ slot 0: 16 B ] opCode: u8, payload: [15]u8
|
|
13
|
+
* [ slot 1: 16 B ] ...
|
|
14
|
+
* ...
|
|
15
|
+
*
|
|
16
|
+
* SPSC contract (Phase 4 scope):
|
|
17
|
+
* - Producer: WASM `sim.tick()`. Pushes 0..N commands during one tick;
|
|
18
|
+
* bumps `write_head` after each.
|
|
19
|
+
* - Consumer: TS host, immediately after `wasm.tick()` returns. Drains
|
|
20
|
+
* 0..N pending commands; bumps `read_head` after each.
|
|
21
|
+
* - The two never run concurrently in Phase 4 (single host thread
|
|
22
|
+
* orchestrates both). Phase 5's worker offload promotes the head
|
|
23
|
+
* bumps to `Atomics.store`; that's an additive change without
|
|
24
|
+
* altering the layout.
|
|
25
|
+
*
|
|
26
|
+
* Overflow:
|
|
27
|
+
* - If WASM would write a slot when (`write_head - read_head == capacity`),
|
|
28
|
+
* it sets `overflow = 1` and drops the command. TS treats overflow as
|
|
29
|
+
* a hard error in dev builds; production logs and continues (a command
|
|
30
|
+
* might be lost rather than crash the host).
|
|
31
|
+
*
|
|
32
|
+
* Slot format (plan §7.5):
|
|
33
|
+
* byte 0: opCode (u8). 0 is reserved as the empty-slot marker
|
|
34
|
+
* (`COMMAND_OP_EMPTY`); all other codes are consumer-defined.
|
|
35
|
+
* The engine never interprets a code — it drains
|
|
36
|
+
* `(opCode, payload)` and hands them to the attached
|
|
37
|
+
* consumer, which owns the opcode enum + payload codecs (the
|
|
38
|
+
* game's live in `@internal/sim`'s `command_payloads.ts`).
|
|
39
|
+
* bytes 1..15: payload, op-specific. Multi-byte fields may be
|
|
40
|
+
* unaligned within the payload; readers must use byte-
|
|
41
|
+
* oriented helpers (DataView in TS, `mem.readInt` in Zig).
|
|
42
|
+
*
|
|
43
|
+
* The ring lives BEFORE the layout-descriptor region in the SAB (right
|
|
44
|
+
* after the 32-byte header) so its offset is stable across descriptor /
|
|
45
|
+
* column-region growth. The host writes `header.command_ring_off` to
|
|
46
|
+
* point at it during `createColumnStore`; absent ring is signalled by
|
|
47
|
+
* `command_ring_off === 0`.
|
|
48
|
+
*/
|
|
49
|
+
/** Total bytes for the ring header. */
|
|
50
|
+
export declare const COMMAND_RING_HEADER_BYTES = 16;
|
|
51
|
+
/** Fixed slot size — 1-byte opCode + 15-byte payload. */
|
|
52
|
+
export declare const COMMAND_RING_SLOT_BYTES = 16;
|
|
53
|
+
/** Default ring capacity in slots. 256 × 16 B = 4 KiB of ring data plus
|
|
54
|
+
* 16 B header. Sized for the worst-case burst (peak spawn intents per
|
|
55
|
+
* tick) × small safety margin. Tune up if a Phase 4 burst pushes past it
|
|
56
|
+
* in the bench harness. */
|
|
57
|
+
export declare const COMMAND_RING_DEFAULT_CAPACITY_SLOTS = 256;
|
|
58
|
+
/** Byte offsets within the ring header. Mirrored on the Zig side in
|
|
59
|
+
* `packages/sim/src/command_ring.zig` — keep in sync. */
|
|
60
|
+
export declare const COMMAND_RING_HEADER_OFFSETS: {
|
|
61
|
+
readonly write_head: 0;
|
|
62
|
+
readonly read_head: 4;
|
|
63
|
+
readonly capacity_slots: 8;
|
|
64
|
+
readonly overflow_flag: 12;
|
|
65
|
+
};
|
|
66
|
+
/** Op-code `0` is reserved across the SAB layer as the empty-slot marker
|
|
67
|
+
* so a zero-initialised SAB doesn't appear to hold a valid command (mirror
|
|
68
|
+
* of `EVENT_OP_EMPTY`). All non-zero codes are opaque to the engine —
|
|
69
|
+
* the attached consumer owns the opcode enum + payload codecs (the game's
|
|
70
|
+
* `COMMAND_OP` + `SpawnUnitFields` live in `@internal/sim`). */
|
|
71
|
+
export declare const COMMAND_OP_EMPTY = 0;
|
|
72
|
+
/** Total bytes the ring occupies for `capacity_slots` slots. */
|
|
73
|
+
export declare function commandRingBytes(capacitySlots: number): number;
|
|
74
|
+
export declare class CommandRingError extends Error {
|
|
75
|
+
constructor(message: string);
|
|
76
|
+
}
|
|
77
|
+
/** Initialise the ring header at `ringOff` in the SAB. Zeroes
|
|
78
|
+
* `write_head`, `read_head`, and `overflow_flag`; sets `capacity_slots`.
|
|
79
|
+
* Slot bytes are left as-is (callers normally allocate the ring on a
|
|
80
|
+
* fresh, zero-initialised SAB). */
|
|
81
|
+
export declare function initCommandRing(view: DataView, ringOff: number, capacitySlots: number): void;
|
|
82
|
+
/** Read live ring-header field. */
|
|
83
|
+
export declare function ringWriteHead(view: DataView, ringOff: number): number;
|
|
84
|
+
export declare function ringReadHead(view: DataView, ringOff: number): number;
|
|
85
|
+
export declare function ringCapacitySlots(view: DataView, ringOff: number): number;
|
|
86
|
+
export declare function ringOverflow(view: DataView, ringOff: number): boolean;
|
|
87
|
+
/** Pending command count = `(write_head - read_head) mod 2^32`. The
|
|
88
|
+
* `>>> 0` keeps the result a u32 in the wrap-around case (rings live for
|
|
89
|
+
* the host's lifetime; 2^32 commands at 50 Hz ≈ 2 years, but the
|
|
90
|
+
* arithmetic should be correct regardless). */
|
|
91
|
+
export declare function pendingCommandCount(view: DataView, ringOff: number): number;
|
|
92
|
+
/** Push a command into the ring from the TS side. Production producer is
|
|
93
|
+
* WASM (via `command_ring.zig`); this is for host-side tests and for
|
|
94
|
+
* symmetric tests across the two sides. Returns `false` on overflow and
|
|
95
|
+
* sets the overflow flag. Payload must be exactly 15 bytes. */
|
|
96
|
+
export declare function pushCommand(view: DataView, ringOff: number, opCode: number, payload: Uint8Array): boolean;
|
|
97
|
+
/** Read one command from the ring. Returns opCode (0 = empty/no
|
|
98
|
+
* command) and fills `outPayload` (15 bytes) with the slot's payload.
|
|
99
|
+
* When 0 is returned, `outPayload` is untouched. */
|
|
100
|
+
export declare function popCommand(view: DataView, ringOff: number, outPayload: Uint8Array): number;
|
|
101
|
+
/** Visit every pending command and bump `read_head` past them. Yields
|
|
102
|
+
* `{ opCode, payload }` per slot where `payload` is a freshly-copied
|
|
103
|
+
* 15-byte Uint8Array (so the handler can hold it past the next pop
|
|
104
|
+
* without aliasing the ring). Stops when the ring is empty. Used by the
|
|
105
|
+
* TS host drain that runs right after `wasm.tick()` returns. */
|
|
106
|
+
export declare function drainCommandRing(view: DataView, ringOff: number, handler: (opCode: number, payload: Uint8Array) => void): number;
|
|
107
|
+
//# sourceMappingURL=command_ring.d.ts.map
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { COLUMN_DESCRIPTOR_BYTES, COLUMN_DESCRIPTOR_OFFSETS, ARCHETYPE_DESCRIPTOR_HEADER_BYTES, ARCHETYPE_DESCRIPTOR_OFFSETS, COMPONENT_MASK_WORDS } from './vendored_abi/abi.cjs';
|
|
2
|
+
export { COLUMN_DESCRIPTOR_BYTES, COLUMN_DESCRIPTOR_OFFSETS, ARCHETYPE_DESCRIPTOR_HEADER_BYTES, ARCHETYPE_DESCRIPTOR_OFFSETS, COMPONENT_MASK_WORDS };
|
|
3
|
+
/** type_tag values for `ColumnDescriptor.type_tag`. The order matches the
|
|
4
|
+
* TypedArrayTag union in `packages/std/type_primitives` so a tag's element
|
|
5
|
+
* width is `TYPE_TAG_STRIDE[tag]`. */
|
|
6
|
+
export declare const TYPE_TAG: {
|
|
7
|
+
readonly u8: 0;
|
|
8
|
+
readonly i8: 1;
|
|
9
|
+
readonly u16: 2;
|
|
10
|
+
readonly i16: 3;
|
|
11
|
+
readonly u32: 4;
|
|
12
|
+
readonly i32: 5;
|
|
13
|
+
readonly f32: 6;
|
|
14
|
+
readonly f64: 7;
|
|
15
|
+
};
|
|
16
|
+
export type TypeTagValue = (typeof TYPE_TAG)[keyof typeof TYPE_TAG];
|
|
17
|
+
/** Element width in bytes for each `TYPE_TAG`. Indexed by tag value so a
|
|
18
|
+
* `stride = TYPE_TAG_STRIDE[tag]` lookup is O(1) array access. */
|
|
19
|
+
export declare const TYPE_TAG_STRIDE: Readonly<Record<TypeTagValue, number>>;
|
|
20
|
+
/** String-tag → numeric-tag bridge. `TypedArrayTag` ("u8", "f32", …) is the
|
|
21
|
+
* vocabulary the TS-side component registry speaks; `TypeTagValue` is the
|
|
22
|
+
* numeric enum the SAB descriptors carry on the wire. Bridging happens at
|
|
23
|
+
* the ECS↔SAB seam — Archetype layouts come in as strings, ColumnSpecs go
|
|
24
|
+
* out as integers. */
|
|
25
|
+
export declare const TYPED_ARRAY_TAG_TO_TYPE_TAG: {
|
|
26
|
+
readonly u8: 0;
|
|
27
|
+
readonly i8: 1;
|
|
28
|
+
readonly u16: 2;
|
|
29
|
+
readonly i16: 3;
|
|
30
|
+
readonly u32: 4;
|
|
31
|
+
readonly i32: 5;
|
|
32
|
+
readonly f32: 6;
|
|
33
|
+
readonly f64: 7;
|
|
34
|
+
};
|
|
35
|
+
export interface ColumnDescriptor {
|
|
36
|
+
readonly componentId: number;
|
|
37
|
+
readonly fieldId: number;
|
|
38
|
+
readonly typeTag: TypeTagValue;
|
|
39
|
+
/** Byte offset of the column's first row, measured from SAB byte 0. */
|
|
40
|
+
readonly byteOff: number;
|
|
41
|
+
/** Element width in bytes; should always equal `TYPE_TAG_STRIDE[type_tag]`. */
|
|
42
|
+
readonly stride: number;
|
|
43
|
+
}
|
|
44
|
+
export declare function writeColumnDescriptor(view: DataView, off: number, c: ColumnDescriptor): void;
|
|
45
|
+
export declare function readColumnDescriptor(view: DataView, off: number): ColumnDescriptor;
|
|
46
|
+
/** Number of distinct components the cross-language ECS supports:
|
|
47
|
+
* `COMPONENT_MASK_WORDS × 32` bits in the SAB archetype descriptor mask. The
|
|
48
|
+
* Zig side matches archetypes purely on this mask, so a component whose ID is
|
|
49
|
+
* ≥ this limit would be invisible there while the heap-side `BitSet` stayed
|
|
50
|
+
* correct — silently conflating archetypes that differ only in such a
|
|
51
|
+
* component. `Store.registerComponent` enforces this as a hard registration
|
|
52
|
+
* ceiling so the overflow fails loudly instead (#381). The mask is sized to
|
|
53
|
+
* the `BitSet`'s `INITIAL_WORD_COUNT`, so a registry within the limit never
|
|
54
|
+
* grows a component mask past its initial words. */
|
|
55
|
+
export declare const STORE_DESCRIPTOR_COMPONENT_LIMIT: number;
|
|
56
|
+
export interface ArchetypeDescriptor {
|
|
57
|
+
readonly archetypeId: number;
|
|
58
|
+
/** Component bitmask, `COMPONENT_MASK_WORDS` little-endian u32 words. Word
|
|
59
|
+
* `w` holds component IDs in `[w*32, w*32+32)`. */
|
|
60
|
+
readonly componentMask: readonly number[];
|
|
61
|
+
readonly rowCount: number;
|
|
62
|
+
readonly rowCapacity: number;
|
|
63
|
+
/** Enabled-row count `≤ row_count` (#577 / #599). Per-row entity-scan loops in
|
|
64
|
+
* the WASM sim bound on this so disabled entities (swapped to the tail
|
|
65
|
+
* `[enabled_count, row_count)`) are not simulated; row-indexed cross-entity
|
|
66
|
+
* reads still use `row_count`. */
|
|
67
|
+
readonly enabledCount: number;
|
|
68
|
+
readonly columns: readonly ColumnDescriptor[];
|
|
69
|
+
}
|
|
70
|
+
/** Total bytes a descriptor will occupy, given its column count. Useful for
|
|
71
|
+
* planning the layout descriptor region size up front. */
|
|
72
|
+
export declare function archetypeDescriptorBytes(columnCount: number): number;
|
|
73
|
+
export declare function writeArchetypeDescriptor(view: DataView, off: number, d: ArchetypeDescriptor): number;
|
|
74
|
+
export declare function readArchetypeDescriptor(view: DataView, off: number): ArchetypeDescriptor;
|
|
75
|
+
export declare function writeLayoutDescriptorRegion(view: DataView, regionOff: number, descriptors: readonly ArchetypeDescriptor[]): number;
|
|
76
|
+
export declare function readLayoutDescriptorRegion(view: DataView, regionOff: number, archetypeCount: number): readonly ArchetypeDescriptor[];
|
|
77
|
+
/** Total bytes needed for a layout descriptor region holding these archetypes.
|
|
78
|
+
* Use to size the SAB region between header end and the first column. */
|
|
79
|
+
export declare function layoutDescriptorRegionBytes(descriptors: readonly ArchetypeDescriptor[]): number;
|
|
80
|
+
//# sourceMappingURL=descriptor.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { COLUMN_DESCRIPTOR_BYTES, COLUMN_DESCRIPTOR_OFFSETS, ARCHETYPE_DESCRIPTOR_HEADER_BYTES, ARCHETYPE_DESCRIPTOR_OFFSETS, COMPONENT_MASK_WORDS } from './
|
|
1
|
+
import { COLUMN_DESCRIPTOR_BYTES, COLUMN_DESCRIPTOR_OFFSETS, ARCHETYPE_DESCRIPTOR_HEADER_BYTES, ARCHETYPE_DESCRIPTOR_OFFSETS, COMPONENT_MASK_WORDS } from './vendored_abi/abi.js';
|
|
2
2
|
export { COLUMN_DESCRIPTOR_BYTES, COLUMN_DESCRIPTOR_OFFSETS, ARCHETYPE_DESCRIPTOR_HEADER_BYTES, ARCHETYPE_DESCRIPTOR_OFFSETS, COMPONENT_MASK_WORDS };
|
|
3
3
|
/** type_tag values for `ColumnDescriptor.type_tag`. The order matches the
|
|
4
4
|
* TypedArrayTag union in `packages/std/type_primitives` so a tag's element
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"descriptor.d.ts","sourceRoot":"","sources":["../../../src/core/store/descriptor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAeH,OAAO,EACN,uBAAuB,EACvB,yBAAyB,EACzB,iCAAiC,EACjC,4BAA4B,EAC5B,oBAAoB,EACpB,MAAM,
|
|
1
|
+
{"version":3,"file":"descriptor.d.ts","sourceRoot":"","sources":["../../../src/core/store/descriptor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAeH,OAAO,EACN,uBAAuB,EACvB,yBAAyB,EACzB,iCAAiC,EACjC,4BAA4B,EAC5B,oBAAoB,EACpB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACN,uBAAuB,EACvB,yBAAyB,EACzB,iCAAiC,EACjC,4BAA4B,EAC5B,oBAAoB,EACpB,CAAC;AAEF;;sCAEsC;AACtC,eAAO,MAAM,QAAQ;;;;;;;;;CASX,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAC;AAEpE;kEACkE;AAClE,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CASjE,CAAC;AAEH;;;;sBAIsB;AACtB,eAAO,MAAM,2BAA2B;;;;;;;;;CAS9B,CAAC;AAUX,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC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