@oasys/oecs 0.3.1 → 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 +207 -267
- package/dist/core/ecs/access_check.d.cts +77 -0
- package/dist/core/ecs/access_check.d.ts +77 -0
- package/dist/core/ecs/access_check.d.ts.map +1 -0
- package/dist/core/ecs/archetype.d.cts +486 -0
- package/dist/core/ecs/archetype.d.ts +486 -0
- package/dist/core/ecs/archetype.d.ts.map +1 -0
- 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 +43 -0
- package/dist/core/ecs/builtin_relations.d.ts.map +1 -0
- package/dist/core/ecs/command_log.d.cts +116 -0
- package/dist/core/ecs/command_log.d.ts +116 -0
- package/dist/core/ecs/command_log.d.ts.map +1 -0
- package/dist/core/ecs/component.d.cts +176 -0
- package/dist/core/ecs/component.d.ts +176 -0
- package/dist/core/ecs/component.d.ts.map +1 -0
- package/dist/core/ecs/compute_backend.d.cts +37 -0
- package/dist/core/ecs/compute_backend.d.ts +37 -0
- package/dist/core/ecs/compute_backend.d.ts.map +1 -0
- package/dist/core/ecs/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 +93 -0
- package/dist/core/ecs/dispatch_trace.d.ts.map +1 -0
- package/dist/core/ecs/ecs.d.cts +562 -0
- package/dist/core/ecs/ecs.d.ts +562 -0
- package/dist/core/ecs/ecs.d.ts.map +1 -0
- package/dist/core/ecs/ecs_memory.d.cts +179 -0
- package/dist/core/ecs/ecs_memory.d.ts +179 -0
- package/dist/core/ecs/ecs_memory.d.ts.map +1 -0
- package/dist/core/ecs/entity.d.cts +34 -0
- package/dist/core/ecs/entity.d.ts +34 -0
- package/dist/core/ecs/entity.d.ts.map +1 -0
- 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 +79 -0
- package/dist/core/ecs/event.d.ts.map +1 -0
- 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 +133 -0
- package/dist/core/ecs/frame_trace.d.ts.map +1 -0
- package/dist/core/ecs/host_commands.d.cts +274 -0
- package/dist/core/ecs/host_commands.d.ts +274 -0
- package/dist/core/ecs/host_commands.d.ts.map +1 -0
- package/dist/core/ecs/index.d.cts +46 -0
- package/dist/core/ecs/index.d.ts +46 -0
- package/dist/core/ecs/index.d.ts.map +1 -0
- package/dist/core/ecs/observer.d.cts +173 -0
- package/dist/core/ecs/observer.d.ts +173 -0
- package/dist/core/ecs/observer.d.ts.map +1 -0
- package/dist/core/ecs/query.d.cts +718 -0
- package/dist/core/ecs/query.d.ts +718 -0
- package/dist/core/ecs/query.d.ts.map +1 -0
- package/dist/core/ecs/ref.d.cts +31 -0
- package/dist/core/ecs/ref.d.ts +31 -0
- package/dist/core/ecs/ref.d.ts.map +1 -0
- package/dist/core/ecs/relation.d.cts +243 -0
- package/dist/core/ecs/relation.d.ts +243 -0
- package/dist/core/ecs/relation.d.ts.map +1 -0
- 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 +53 -0
- package/dist/core/ecs/resource.d.ts.map +1 -0
- 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 +85 -0
- package/dist/core/ecs/resume.d.ts.map +1 -0
- package/dist/core/ecs/run_condition.d.cts +81 -0
- package/dist/core/ecs/run_condition.d.ts +81 -0
- package/dist/core/ecs/run_condition.d.ts.map +1 -0
- package/dist/core/ecs/schedule.d.cts +142 -0
- package/dist/core/ecs/schedule.d.ts +142 -0
- package/dist/core/ecs/schedule.d.ts.map +1 -0
- 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 +110 -0
- package/dist/core/ecs/sparse_store.d.ts.map +1 -0
- package/dist/core/ecs/store.d.cts +950 -0
- package/dist/core/ecs/store.d.ts +950 -0
- package/dist/core/ecs/store.d.ts.map +1 -0
- package/dist/core/ecs/store_layout_listener.d.cts +23 -0
- package/dist/core/ecs/store_layout_listener.d.ts +23 -0
- package/dist/core/ecs/store_layout_listener.d.ts.map +1 -0
- package/dist/core/ecs/system.d.cts +250 -0
- package/dist/core/ecs/system.d.ts +250 -0
- package/dist/core/ecs/system.d.ts.map +1 -0
- package/dist/core/ecs/utils/arrays.d.cts +7 -0
- package/dist/{utils → core/ecs/utils}/arrays.d.ts +2 -1
- package/dist/core/ecs/utils/arrays.d.ts.map +1 -0
- package/dist/core/ecs/utils/constants.d.ts +12 -0
- package/dist/core/ecs/utils/constants.d.ts.map +1 -0
- package/dist/core/ecs/utils/error.d.cts +61 -0
- package/dist/core/ecs/utils/error.d.ts +61 -0
- package/dist/core/ecs/utils/error.d.ts.map +1 -0
- package/dist/core/store/action_ring.d.cts +136 -0
- package/dist/core/store/action_ring.d.ts +136 -0
- package/dist/core/store/action_ring.d.ts.map +1 -0
- package/dist/core/store/allocator.d.cts +238 -0
- package/dist/core/store/allocator.d.ts +238 -0
- package/dist/core/store/allocator.d.ts.map +1 -0
- package/dist/core/store/buffer_backed_column.d.cts +69 -0
- package/dist/core/store/buffer_backed_column.d.ts +69 -0
- package/dist/core/store/buffer_backed_column.d.ts.map +1 -0
- package/dist/core/store/column_store.d.cts +273 -0
- package/dist/core/store/column_store.d.ts +273 -0
- package/dist/core/store/column_store.d.ts.map +1 -0
- package/dist/core/store/command_dispatch.d.cts +52 -0
- package/dist/core/store/command_dispatch.d.ts +52 -0
- package/dist/core/store/command_dispatch.d.ts.map +1 -0
- package/dist/core/store/command_ring.d.cts +107 -0
- package/dist/core/store/command_ring.d.ts +107 -0
- package/dist/core/store/command_ring.d.ts.map +1 -0
- package/dist/core/store/descriptor.d.cts +80 -0
- package/dist/core/store/descriptor.d.ts +80 -0
- package/dist/core/store/descriptor.d.ts.map +1 -0
- package/dist/core/store/entity_index.d.cts +108 -0
- package/dist/core/store/entity_index.d.ts +108 -0
- package/dist/core/store/entity_index.d.ts.map +1 -0
- package/dist/core/store/event_ring.d.cts +95 -0
- package/dist/core/store/event_ring.d.ts +95 -0
- package/dist/core/store/event_ring.d.ts.map +1 -0
- package/dist/core/store/extend.d.cts +39 -0
- package/dist/core/store/extend.d.ts +39 -0
- package/dist/core/store/extend.d.ts.map +1 -0
- package/dist/core/store/grow.d.cts +34 -0
- package/dist/core/store/grow.d.ts +34 -0
- package/dist/core/store/grow.d.ts.map +1 -0
- package/dist/core/store/header.d.cts +64 -0
- package/dist/core/store/header.d.ts +64 -0
- package/dist/core/store/header.d.ts.map +1 -0
- package/dist/core/store/index.d.cts +17 -0
- package/dist/core/store/index.d.ts +17 -0
- package/dist/core/store/index.d.ts.map +1 -0
- 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 +74 -0
- package/dist/core/store/region_table.d.ts.map +1 -0
- package/dist/core/store/snapshot.d.cts +43 -0
- package/dist/core/store/snapshot.d.ts +43 -0
- package/dist/core/store/snapshot.d.ts.map +1 -0
- package/dist/core/store/state_hash.d.cts +38 -0
- package/dist/core/store/state_hash.d.ts +38 -0
- package/dist/core/store/state_hash.d.ts.map +1 -0
- package/dist/core/store/store_regions.d.cts +38 -0
- package/dist/core/store/store_regions.d.ts +38 -0
- package/dist/core/store/store_regions.d.ts.map +1 -0
- package/dist/core/store/vendored_abi/abi.d.cts +43 -0
- package/dist/core/store/vendored_abi/abi.d.ts +43 -0
- package/dist/core/store/vendored_abi/abi.d.ts.map +1 -0
- 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 +170 -0
- package/dist/extensions/editor/editor.d.ts.map +1 -0
- package/dist/extensions/editor/field_handle.d.cts +40 -0
- package/dist/extensions/editor/field_handle.d.ts +40 -0
- package/dist/extensions/editor/field_handle.d.ts.map +1 -0
- package/dist/extensions/editor/index.cjs +1 -0
- package/dist/extensions/editor/index.d.cts +21 -0
- package/dist/extensions/editor/index.d.ts +21 -0
- package/dist/extensions/editor/index.d.ts.map +1 -0
- package/dist/extensions/editor/index.js +237 -0
- package/dist/extensions/reactive/ecs_sync.d.cts +214 -0
- package/dist/extensions/reactive/ecs_sync.d.ts +214 -0
- package/dist/extensions/reactive/ecs_sync.d.ts.map +1 -0
- package/dist/extensions/reactive/index.cjs +1 -0
- package/dist/extensions/reactive/index.d.cts +23 -0
- package/dist/extensions/reactive/index.d.ts +23 -0
- package/dist/extensions/reactive/index.d.ts.map +1 -0
- package/dist/extensions/reactive/index.js +215 -0
- package/dist/extensions/solid/index.cjs +1 -0
- package/dist/extensions/solid/index.d.cts +6 -0
- package/dist/extensions/solid/index.d.ts +6 -0
- package/dist/extensions/solid/index.d.ts.map +1 -0
- package/dist/extensions/solid/index.js +36 -0
- package/dist/extensions/solid/kernel_solid.d.cts +45 -0
- package/dist/extensions/solid/kernel_solid.d.ts +45 -0
- package/dist/extensions/solid/kernel_solid.d.ts.map +1 -0
- package/dist/host_commands-BF8QMi3c.cjs +1 -0
- package/dist/host_commands-i4cAeyL5.js +2318 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +66 -0
- package/dist/index.d.ts +65 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7080 -1289
- 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/interop-CT-REx0W.cjs +1 -0
- package/dist/interop-CcY6ASQc.js +18 -0
- package/dist/kernel-DgyrLFjW.js +227 -0
- package/dist/kernel-yWV3XnAb.cjs +1 -0
- package/dist/primitives.cjs +1 -0
- package/dist/primitives.d.cts +18 -0
- package/dist/primitives.d.ts +18 -0
- package/dist/primitives.d.ts.map +1 -0
- package/dist/primitives.js +45 -0
- package/dist/reactive/array.d.cts +24 -0
- 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/reactive/interop.d.ts +19 -0
- package/dist/reactive/interop.d.ts.map +1 -0
- package/dist/reactive/kernel.d.cts +73 -0
- package/dist/reactive/kernel.d.ts +73 -0
- package/dist/reactive/kernel.d.ts.map +1 -0
- package/dist/reactive/map.d.cts +16 -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/reactive/struct.d.ts +10 -0
- 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 -0
- package/dist/shared.d.cts +22 -0
- package/dist/shared.d.ts +22 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +7 -0
- package/dist/topological_sort-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 +25 -9
- 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/binary_heap/binary_heap.d.ts +6 -2
- package/dist/type_primitives/binary_heap/binary_heap.d.ts.map +1 -1
- package/dist/type_primitives/bitset/bitset.d.cts +54 -0
- package/dist/type_primitives/bitset/bitset.d.ts +16 -4
- package/dist/type_primitives/bitset/bitset.d.ts.map +1 -1
- package/dist/type_primitives/brand.d.cts +23 -0
- package/dist/type_primitives/brand.d.ts +6 -1
- package/dist/type_primitives/brand.d.ts.map +1 -1
- package/dist/type_primitives/error.d.cts +16 -0
- package/dist/type_primitives/error.d.ts +8 -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 +12 -9
- package/dist/type_primitives/index.d.ts.map +1 -1
- package/dist/type_primitives/sparse_map/sparse_map.d.cts +30 -0
- package/dist/type_primitives/sparse_map/sparse_map.d.ts +7 -3
- package/dist/type_primitives/sparse_map/sparse_map.d.ts.map +1 -1
- package/dist/type_primitives/sparse_set/sparse_set.d.cts +28 -0
- package/dist/type_primitives/sparse_set/sparse_set.d.ts +4 -0
- package/dist/type_primitives/sparse_set/sparse_set.d.ts.map +1 -1
- package/dist/type_primitives/topological_sort/topological_sort.d.cts +29 -0
- package/dist/type_primitives/topological_sort/topological_sort.d.ts +7 -3
- package/dist/type_primitives/topological_sort/topological_sort.d.ts.map +1 -1
- package/dist/type_primitives/typed_arrays/typed_arrays.d.cts +127 -0
- package/dist/type_primitives/typed_arrays/typed_arrays.d.ts +53 -16
- package/dist/type_primitives/typed_arrays/typed_arrays.d.ts.map +1 -1
- package/dist/typed_arrays-BcXcnzB4.js +258 -0
- package/dist/typed_arrays-D3NmwtCG.cjs +1 -0
- package/dist/utils/error.d.cts +6 -0
- package/dist/utils/error.d.ts +2 -20
- package/dist/utils/error.d.ts.map +1 -1
- 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 +115 -5
- package/dist/archetype.d.ts +0 -108
- package/dist/archetype.d.ts.map +0 -1
- package/dist/component.d.ts +0 -45
- package/dist/component.d.ts.map +0 -1
- package/dist/ecs.d.ts +0 -104
- package/dist/ecs.d.ts.map +0 -1
- package/dist/entity.d.ts +0 -11
- package/dist/entity.d.ts.map +0 -1
- package/dist/event.d.ts +0 -30
- package/dist/event.d.ts.map +0 -1
- package/dist/query.d.ts +0 -94
- package/dist/query.d.ts.map +0 -1
- package/dist/ref.d.ts +0 -23
- package/dist/ref.d.ts.map +0 -1
- package/dist/resource.d.ts +0 -23
- package/dist/resource.d.ts.map +0 -1
- package/dist/schedule.d.ts +0 -45
- package/dist/schedule.d.ts.map +0 -1
- package/dist/store.d.ts +0 -118
- package/dist/store.d.ts.map +0 -1
- package/dist/system.d.ts +0 -16
- package/dist/system.d.ts.map +0 -1
- 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
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { ReactiveArray, ReactiveMap, StructSetters, StructEq } from '../../reactive/index.js';
|
|
2
|
+
import { ComponentDef, ComponentSchema, ECS, EntityID, SystemAccessDeclaration } from '../../core/ecs/index.js';
|
|
3
|
+
import { shallow } from '../../reactive/shallow.js';
|
|
4
|
+
export { shallow };
|
|
5
|
+
/**
|
|
6
|
+
* A read cursor over one entity's single-component state, handed to a single-
|
|
7
|
+
* component `Projection`. `field` is column-backed under "column" grain
|
|
8
|
+
* (sequential), random-access (`getField`) under "entity" grain.
|
|
9
|
+
*
|
|
10
|
+
* Lifetime: the cursor is a reused, mutable singleton valid ONLY during the
|
|
11
|
+
* synchronous `project` call for the current row. Read what you need and return —
|
|
12
|
+
* never capture `row` (or stash its `field` reads keyed off a later closure): the
|
|
13
|
+
* next row/tick mutates it in place, so a captured cursor reads stale data.
|
|
14
|
+
*/
|
|
15
|
+
export interface RowReader<S extends ComponentSchema> {
|
|
16
|
+
/** The current entity (the row being projected). */
|
|
17
|
+
readonly eid: EntityID;
|
|
18
|
+
/** Read a field of the synced component for the current row. */
|
|
19
|
+
field<K extends string & keyof S>(name: K): number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A read cursor over a JOINED entity (it carries every component in the join), for
|
|
23
|
+
* a `JoinProjection`. `field(def, name)` reads any field of any joined component
|
|
24
|
+
* for the current entity (random-access; the join subscribes to all of them so the
|
|
25
|
+
* read can never go stale).
|
|
26
|
+
*
|
|
27
|
+
* Lifetime: like `RowReader`, a reused mutable singleton valid ONLY during the
|
|
28
|
+
* synchronous `project` call — never capture it; the next dispatch mutates it.
|
|
29
|
+
*/
|
|
30
|
+
export interface JoinReader<Schemas extends readonly ComponentSchema[] = readonly ComponentSchema[]> {
|
|
31
|
+
/** The current entity (it has all joined components). */
|
|
32
|
+
readonly eid: EntityID;
|
|
33
|
+
/** Read a field of one joined component for the current entity. `def` is
|
|
34
|
+
* constrained to the join's own component set — reading a def outside the
|
|
35
|
+
* join is the stale-read footgun the module header warns about (its changes
|
|
36
|
+
* aren't subscribed), so it's a compile error. */
|
|
37
|
+
field<S extends Schemas[number], K extends string & keyof S>(def: ComponentDef<S>, name: K): number;
|
|
38
|
+
}
|
|
39
|
+
/** Map one single-component row to the value a UI cell reads. */
|
|
40
|
+
export type Projection<S extends ComponentSchema, V> = (row: RowReader<S>) => V;
|
|
41
|
+
/** Map one joined entity to the value a UI cell reads. */
|
|
42
|
+
export type JoinProjection<V, Schemas extends readonly ComponentSchema[] = readonly ComponentSchema[]> = (row: JoinReader<Schemas>) => V;
|
|
43
|
+
/** Per-component dirty grain. See the module header for the measured crossover. */
|
|
44
|
+
export type SyncGrain = "entity" | "column";
|
|
45
|
+
export interface EcsMapSyncOptions<V> {
|
|
46
|
+
/** Dirty grain (default `"entity"`). Use `"column"` for high-churn components. */
|
|
47
|
+
grain?: SyncGrain;
|
|
48
|
+
/**
|
|
49
|
+
* Value equality for the map's per-key no-op skip (default `Object.is`). Pass
|
|
50
|
+
* `shallow` for object projections, or a content comparator. A fresh object
|
|
51
|
+
* every tick under the default reference eq wakes the row every frame.
|
|
52
|
+
*/
|
|
53
|
+
eq?: (a: V, b: V) => boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Access surface the projection touches, merged over the synced components'
|
|
56
|
+
* `reads`. `DEV` access-checks the observer callbacks exactly like a system.
|
|
57
|
+
*/
|
|
58
|
+
access?: Partial<SystemAccessDeclaration>;
|
|
59
|
+
/**
|
|
60
|
+
* Replay current matches on registration (default `true`), so a bridge attached
|
|
61
|
+
* to an already-populated world seeds the map with present state instead of
|
|
62
|
+
* waking only on the next change. flecs `yieldExisting`.
|
|
63
|
+
*/
|
|
64
|
+
seedExisting?: boolean;
|
|
65
|
+
}
|
|
66
|
+
export interface EcsMapSync<V> {
|
|
67
|
+
/** The live channel: a reader of key `eid` subscribes to that entity alone. */
|
|
68
|
+
readonly map: ReactiveMap<EntityID, V>;
|
|
69
|
+
/** Unregister the observer(s) and stop publishing. Safe to call more than once. */
|
|
70
|
+
dispose(): void;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Sync ONE component's change detection into a `reactiveMap`, keyed by `EntityID`.
|
|
74
|
+
* A value change publishes the changed rows; a spawn inserts a row and a despawn
|
|
75
|
+
* deletes it. Returns the map + a disposer. Drive with `batchedUpdate(world, dt)`.
|
|
76
|
+
*
|
|
77
|
+
* To read more than one component per row, use `syncJoinToMap` — reading a second
|
|
78
|
+
* component here goes stale (its changes aren't subscribed).
|
|
79
|
+
*/
|
|
80
|
+
export declare function syncComponentToMap<S extends ComponentSchema, V>(ecs: ECS, def: ComponentDef<S>, project: Projection<S, V>, opts?: EcsMapSyncOptions<V>): EcsMapSync<V>;
|
|
81
|
+
/**
|
|
82
|
+
* Sugar over `syncComponentToMap`: project a fixed FIELD LIST into a `{ field:
|
|
83
|
+
* value }` snapshot, with an automatic `shallow` eq so an unchanged row wakes
|
|
84
|
+
* nobody. The declarative-field-list model from WatermelonDB `observeWithColumns` /
|
|
85
|
+
* TanStack `select` — the common "mirror these fields" case without hand-writing
|
|
86
|
+
* the projection + comparator.
|
|
87
|
+
*
|
|
88
|
+
* Allocation note: this builds a fresh object per dirty row and `shallow` does two
|
|
89
|
+
* `Object.keys` per compare — fine for low-churn. For a HIGH-churn component (the
|
|
90
|
+
* case you'd pick `grain:"column"` for), prefer `syncComponentToMap` with a scalar
|
|
91
|
+
* or hand-written-`eq` projection, so the hot path doesn't allocate exactly where
|
|
92
|
+
* the column grain is meant to keep it cheap.
|
|
93
|
+
*/
|
|
94
|
+
export declare function syncFieldsToMap<S extends ComponentSchema, const F extends readonly (string & keyof S)[]>(ecs: ECS, def: ComponentDef<S>, fields: F, opts?: Omit<EcsMapSyncOptions<{
|
|
95
|
+
[K in F[number]]: number;
|
|
96
|
+
}>, "eq">): EcsMapSync<{
|
|
97
|
+
[K in F[number]]: number;
|
|
98
|
+
}>;
|
|
99
|
+
/**
|
|
100
|
+
* Sync a multi-component JOIN into a `reactiveMap`. An entity is a member iff it
|
|
101
|
+
* has EVERY component in `defs`; the projection reads any of them via
|
|
102
|
+
* `row.field(def, name)`. Change detection subscribes to ALL joined components, so
|
|
103
|
+
* a write to ANY of them republishes the row — the join can never go stale (the
|
|
104
|
+
* bug a single-component sync + manual secondary read would have). Spawns/removes
|
|
105
|
+
* of any joined component re-evaluate membership.
|
|
106
|
+
*
|
|
107
|
+
* Entity grain only: a join spans archetypes, so there is no single column to
|
|
108
|
+
* sweep. Drive with `batchedUpdate(world, dt)`.
|
|
109
|
+
*/
|
|
110
|
+
export declare function syncJoinToMap<Schemas extends readonly ComponentSchema[], V>(ecs: ECS, defs: readonly [...{
|
|
111
|
+
[I in keyof Schemas]: ComponentDef<Schemas[I]>;
|
|
112
|
+
}], project: JoinProjection<V, Schemas>, opts?: Omit<EcsMapSyncOptions<V>, "grain">): EcsMapSync<V>;
|
|
113
|
+
export interface SingletonStructSync<V extends object> {
|
|
114
|
+
/** The live per-field channel: reading `struct.field` in a tracked scope
|
|
115
|
+
* subscribes to that field alone (pair with `fromKernelStruct` to render). */
|
|
116
|
+
readonly struct: V;
|
|
117
|
+
/** Unregister the observer and stop publishing. Safe to call more than once. */
|
|
118
|
+
dispose(): void;
|
|
119
|
+
}
|
|
120
|
+
export interface SingletonSyncOptions<V extends object = Record<string, number>> {
|
|
121
|
+
/**
|
|
122
|
+
* Access surface the publish touches, merged over the synced def's read.
|
|
123
|
+
* `DEV` access-checks the observer callbacks exactly like a system.
|
|
124
|
+
*/
|
|
125
|
+
access?: Partial<SystemAccessDeclaration>;
|
|
126
|
+
/** Replay current state on registration (default `true`). flecs `yieldExisting`. */
|
|
127
|
+
seedExisting?: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Drive a PRE-CREATED `reactiveStruct` (its `[proxy, set]` pair) instead of
|
|
130
|
+
* creating a fresh one. Lets the consumer keep the struct at module scope as a
|
|
131
|
+
* stable "channel" with initial values present before the sync attaches (the
|
|
132
|
+
* client UI seam: panels import the eager proxy; the sync, set up at world build,
|
|
133
|
+
* republishes into it via the observer). The seed (`yieldExisting`) overwrites
|
|
134
|
+
* the eager initials with the entity's current values on registration.
|
|
135
|
+
*/
|
|
136
|
+
into?: readonly [V, StructSetters<V>];
|
|
137
|
+
/** Per-field equality overrides for the created struct (parity with
|
|
138
|
+
* `SingletonArraySyncOptions.eq`). Ignored when `into` supplies a
|
|
139
|
+
* pre-created struct — that struct already carries its own `eq`. */
|
|
140
|
+
eq?: StructEq<V>;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Sync ONE singleton entity's single-component state into a `reactiveStruct`,
|
|
144
|
+
* keyless — the singleton/resource shape (ADR-0024). This is how heterogeneous
|
|
145
|
+
* ephemeral UI state (net status + latency, FPS/mem, wave timer, hovered hex) joins
|
|
146
|
+
* the same reactive view as per-entity components: model it as components on a
|
|
147
|
+
* reserved singleton entity (the flecs / Unity-DOTS "singleton-as-entity" model)
|
|
148
|
+
* and read it through per-field channels — NOT a separate reactive-resource
|
|
149
|
+
* subsystem. Resources stay non-reactive internal singletons.
|
|
150
|
+
*
|
|
151
|
+
* It reuses the entity-grain ADR-0013 component observer verbatim, filtered to the
|
|
152
|
+
* one target eid: an `onSet` (or seed `onAdd`) republishes the entity's field values
|
|
153
|
+
* into the struct via per-field setters. The per-field `Object.is` eq means an
|
|
154
|
+
* unchanged field writes nothing — "equal write → 0 renders" — and per-field signals
|
|
155
|
+
* give "1-of-N FIELD → 1 re-render"; drive with `batchedUpdate` for "one tick → one
|
|
156
|
+
* commit". Because the component change-detection fires on `ctx.setField`, the
|
|
157
|
+
* in-place write pattern that defeats a `setResource`-keyed resource observer is
|
|
158
|
+
* handled for free.
|
|
159
|
+
*
|
|
160
|
+
* `fields` is explicit: a `ComponentDef` is a branded number at runtime (its schema
|
|
161
|
+
* is a phantom type), so the field names must be passed — same contract as
|
|
162
|
+
* `syncFieldsToMap`. Project a subset to channel only what the UI reads.
|
|
163
|
+
*
|
|
164
|
+
* A `reactiveStruct` has a fixed field set and no `delete`, so the map adapter's
|
|
165
|
+
* delete-on-disable (#677 / ADR-0023) has no struct analog: `onRemove`/`onDisable`
|
|
166
|
+
* **reset the fields to the channel's declared initial values** (`onSet` skips
|
|
167
|
+
* disabled entities), `onEnable` republishes. The defaults are the channel's own
|
|
168
|
+
* initials — the eager `into` struct's declared values (e.g. `NetStats.latency = -1`),
|
|
169
|
+
* or the zeros of a freshly-created one — captured (untracked) at registration, NOT a
|
|
170
|
+
* blind 0. A singleton is rarely despawned; this keeps the channel well-defined if it is.
|
|
171
|
+
*/
|
|
172
|
+
export declare function syncSingletonToStruct<S extends ComponentSchema, const F extends readonly (string & keyof S)[]>(ecs: ECS, def: ComponentDef<S>, eid: EntityID, fields: F, opts?: SingletonSyncOptions<{
|
|
173
|
+
[K in F[number]]: number;
|
|
174
|
+
}>): SingletonStructSync<{
|
|
175
|
+
[K in F[number]]: number;
|
|
176
|
+
}>;
|
|
177
|
+
export interface SingletonArraySync<T> {
|
|
178
|
+
/** The live ordered channel: a reader of slot `i` subscribes to that slot alone. */
|
|
179
|
+
readonly array: ReactiveArray<T>;
|
|
180
|
+
/** Unregister the observer and stop publishing. Safe to call more than once. */
|
|
181
|
+
dispose(): void;
|
|
182
|
+
}
|
|
183
|
+
export interface SingletonArraySyncOptions<T> {
|
|
184
|
+
access?: Partial<SystemAccessDeclaration>;
|
|
185
|
+
seedExisting?: boolean;
|
|
186
|
+
/** Drive a PRE-CREATED `reactiveArray` (the module-scope channel) instead of a fresh one. */
|
|
187
|
+
into?: ReactiveArray<T>;
|
|
188
|
+
/** Per-slot equality for the array's no-op skip (default `Object.is`). */
|
|
189
|
+
eq?: (a: T, b: T) => boolean;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Sync ONE singleton entity's component into a `reactiveArray`, one slot per field
|
|
193
|
+
* in `fields` order (#685 / ADR-0024) — the ORDERED sibling of `syncSingletonToStruct`,
|
|
194
|
+
* for positional UI state (the army slots). On every change to the component it
|
|
195
|
+
* `reconcile`s the array from the field values: a slot whose value is unchanged keeps
|
|
196
|
+
* its reference (structural sharing), only changed slots wake. `onRemove`/`onDisable`
|
|
197
|
+
* reset the slots to the channel's DECLARED initial slots (a reactiveArray has no row
|
|
198
|
+
* delete) — captured (untracked) at registration, so the army channel resets to its
|
|
199
|
+
* empty sentinel (`EMPTY_SLOT`), NOT a blind 0 that would read as unit type 0.
|
|
200
|
+
*
|
|
201
|
+
* `fields` is explicit (a `ComponentDef` is a branded number at runtime). Pair with
|
|
202
|
+
* `@oasys/oecs/solid`'s `fromKernelArray` + a Solid `<Index>`.
|
|
203
|
+
*/
|
|
204
|
+
export declare function syncSingletonToArray<S extends ComponentSchema>(ecs: ECS, def: ComponentDef<S>, eid: EntityID, fields: readonly (string & keyof S)[], opts?: SingletonArraySyncOptions<number>): SingletonArraySync<number>;
|
|
205
|
+
/**
|
|
206
|
+
* Advance the world one tick with every bridge publish coalesced into a single UI
|
|
207
|
+
* flush. onAdd/onRemove fire mid-tick at flush boundaries and onSet fires at the
|
|
208
|
+
* tick tail; wrapping the whole update in `batch` defers the effect flush until the
|
|
209
|
+
* tick completes, so a frame that touched K entities (across any number of syncs on
|
|
210
|
+
* this world) wakes its readers once, not once per observer dispatch point.
|
|
211
|
+
* Equivalent to `batch(() => ecs.update(dt))`.
|
|
212
|
+
*/
|
|
213
|
+
export declare function batchedUpdate(ecs: ECS, dt: number): void;
|
|
214
|
+
//# sourceMappingURL=ecs_sync.d.ts.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B,CAAC,MAAM,CAAM,GAC1C,kBAAkB,CAAC,MAAM,CAAC,CA2D5B;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAExD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../kernel-yWV3XnAb.cjs"),_=require("../../shallow-DQ8aG51_.cjs");class w{constructor(n){this.def=n}_ctx;_eid=0;get eid(){return this._eid}field(n){return this._ctx.getField(this._eid,this.def,n)}}class m{constructor(n){this.def=n}_eid=0;_row=0;cols=new Map;arch;bind(n){this.arch=n,this.cols.clear()}get eid(){return this._eid}field(n){let s=this.cols.get(n);return s===void 0&&(s=this.arch.getColumnRead(this.def,n),this.cols.set(n,s)),s[this._row]}}class v{_ctx;_eid=0;get eid(){return this._eid}field(n,s){return this._ctx.getField(this._eid,n,s)}}function p(l,n,s,r={}){const c=_.reactiveMap(r.eq),a={...r.access,reads:[n,...r.access?.reads??[]]},h=r.grain??"entity",u=r.seedExisting??!0,b=new w(n),y=(i,o)=>{o.isDisabled(i)||(b._ctx=o,b._eid=i,c.set(i,s(b)))};let g;return f.batch(()=>{if(h==="column"){const i=new m(n);g=l.observe(n,{granularity:"archetype",onSet:o=>{i.bind(o);const t=o.entityIds;for(let e=0;e<o.entityCount;e++)i._row=e,i._eid=t[e],c.set(i._eid,s(i))},onAdd:(o,t)=>y(o,t),onRemove:o=>c.delete(o),onDisable:o=>c.delete(o),onEnable:(o,t)=>y(o,t),access:a,yieldExisting:u})}else g=l.observe(n,{granularity:"entity",onSet:(i,o)=>y(i,o),onAdd:(i,o)=>y(i,o),onRemove:i=>c.delete(i),onDisable:i=>c.delete(i),onEnable:(i,o)=>y(i,o),access:a,yieldExisting:u})}),{map:c,dispose:()=>g.dispose()}}function E(l,n,s,r={}){return p(l,n,a=>{const h={};for(let u=0;u<s.length;u++)h[s[u]]=a.field(s[u]);return h},{...r,eq:_.shallow})}function S(l,n,s,r={}){const c=n,a=_.reactiveMap(r.eq),h={...r.access,reads:[...c,...r.access?.reads??[]]},u=r.seedExisting??!0,b=new v,y=(t,e)=>{for(let d=0;d<c.length;d++)if(!t.hasComponent(e,c[d]))return!1;return!0},g=(t,e)=>{e.isDisabled(t)||y(e,t)&&(b._ctx=e,b._eid=t,a.set(t,s(b)))},i=t=>{a.delete(t)};let o;return f.batch(()=>{o=c.map(t=>l.observe(t,{granularity:"entity",onSet:g,onAdd:g,onRemove:i,onDisable:i,onEnable:g,access:h,yieldExisting:u}))}),{map:a,dispose:()=>{for(let t=0;t<o.length;t++)o[t].dispose()}}}function R(l,n,s,r,c={}){const a={};for(let e=0;e<r.length;e++)a[r[e]]=0;const[h,u]=c.into??_.reactiveStruct(a,c.eq),b=f.untrack(()=>r.map(e=>h[e])),y={...c.access,reads:[n,...c.access?.reads??[]]},g=c.seedExisting??!0,i=e=>{for(let d=0;d<r.length;d++)u[r[d]](e.getField(s,n,r[d]))},o=()=>{for(let e=0;e<r.length;e++)u[r[e]](b[e])};let t;return f.batch(()=>{t=l.observe(n,{granularity:"entity",onSet:(e,d)=>{e===s&&i(d)},onAdd:(e,d)=>{e===s&&!d.isDisabled(s)&&i(d)},onRemove:e=>{e===s&&o()},onDisable:e=>{e===s&&o()},onEnable:(e,d)=>{e===s&&i(d)},access:y,yieldExisting:g})}),{struct:h,dispose:()=>t.dispose()}}function T(l,n,s,r,c={}){const a=c.into??_.reactiveArray(new Array(r.length).fill(0),c.eq),h=f.untrack(()=>a.snapshot());if(c.into!==void 0&&h.length!==r.length)throw new Error(`syncSingletonToArray: into.length (${h.length}) must equal fields.length (${r.length})`);const u={...c.access,reads:[n,...c.access?.reads??[]]},b=c.seedExisting??!0,y=new Array(r.length),g=t=>{for(let e=0;e<r.length;e++)y[e]=t.getField(s,n,r[e]);a.reconcile(y)},i=()=>a.reconcile(h);let o;return f.batch(()=>{o=l.observe(n,{granularity:"entity",onSet:(t,e)=>{t===s&&g(e)},onAdd:(t,e)=>{t===s&&!e.isDisabled(s)&&g(e)},onRemove:t=>{t===s&&i()},onDisable:t=>{t===s&&i()},onEnable:(t,e)=>{t===s&&g(e)},access:u,yieldExisting:b})}),{array:a,dispose:()=>o.dispose()}}function x(l,n){f.batch(()=>l.update(n))}exports.shallow=_.shallow;exports.batchedUpdate=x;exports.syncComponentToMap=p;exports.syncFieldsToMap=E;exports.syncJoinToMap=S;exports.syncSingletonToArray=T;exports.syncSingletonToStruct=R;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The production ECS→UI reactive bridge (#672 / ADR-0021).
|
|
3
|
+
*
|
|
4
|
+
* Drains the engine's own change detection (ADR-0013 component observers, riding
|
|
5
|
+
* the ADR-0012 per-row dirty list) into a `reactiveMap` — publishing O(changed),
|
|
6
|
+
* not O(all), each tick. Declarative selection + closure projection (the Bevy
|
|
7
|
+
* `ExtractComponent` / WatermelonDB `observeWithColumns` shape):
|
|
8
|
+
* - `syncComponentToMap(def, project)` — one component, grain `"entity"`/`"column"`.
|
|
9
|
+
* - `syncFieldsToMap(def, [fields])` — field-list sugar with auto `shallow` eq.
|
|
10
|
+
* - `syncJoinToMap([defs], project)` — multi-component join (subscribes all defs).
|
|
11
|
+
*
|
|
12
|
+
* For singleton/ephemeral UI state (net status+latency, FPS/mem, wave timer), model
|
|
13
|
+
* it as a component on a reserved singleton entity and read it keyless via per-field
|
|
14
|
+
* channels (#687 / ADR-0024) — NOT a separate reactive-resource subsystem:
|
|
15
|
+
* - `syncSingletonToStruct(def, eid, [fields])` — one singleton entity → `reactiveStruct`.
|
|
16
|
+
* - `syncSingletonToArray(def, eid, [fields])` — one singleton entity → `reactiveArray` (ordered slots).
|
|
17
|
+
*
|
|
18
|
+
* The framework-agnostic counterpart to the Solid leaf: pair the map entry points
|
|
19
|
+
* with `@oasys/oecs/solid`'s `fromKernelMap`, the singleton struct with
|
|
20
|
+
* `fromKernelStruct`, and the singleton array with `fromKernelArray`, to render.
|
|
21
|
+
*/
|
|
22
|
+
export { syncComponentToMap, syncFieldsToMap, syncJoinToMap, syncSingletonToStruct, syncSingletonToArray, batchedUpdate, shallow, type Projection, type JoinProjection, type RowReader, type JoinReader, type SyncGrain, type EcsMapSync, type EcsMapSyncOptions, type SingletonStructSync, type SingletonSyncOptions, type SingletonArraySync, type SingletonArraySyncOptions } from './ecs_sync.cjs';
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The production ECS→UI reactive bridge (#672 / ADR-0021).
|
|
3
|
+
*
|
|
4
|
+
* Drains the engine's own change detection (ADR-0013 component observers, riding
|
|
5
|
+
* the ADR-0012 per-row dirty list) into a `reactiveMap` — publishing O(changed),
|
|
6
|
+
* not O(all), each tick. Declarative selection + closure projection (the Bevy
|
|
7
|
+
* `ExtractComponent` / WatermelonDB `observeWithColumns` shape):
|
|
8
|
+
* - `syncComponentToMap(def, project)` — one component, grain `"entity"`/`"column"`.
|
|
9
|
+
* - `syncFieldsToMap(def, [fields])` — field-list sugar with auto `shallow` eq.
|
|
10
|
+
* - `syncJoinToMap([defs], project)` — multi-component join (subscribes all defs).
|
|
11
|
+
*
|
|
12
|
+
* For singleton/ephemeral UI state (net status+latency, FPS/mem, wave timer), model
|
|
13
|
+
* it as a component on a reserved singleton entity and read it keyless via per-field
|
|
14
|
+
* channels (#687 / ADR-0024) — NOT a separate reactive-resource subsystem:
|
|
15
|
+
* - `syncSingletonToStruct(def, eid, [fields])` — one singleton entity → `reactiveStruct`.
|
|
16
|
+
* - `syncSingletonToArray(def, eid, [fields])` — one singleton entity → `reactiveArray` (ordered slots).
|
|
17
|
+
*
|
|
18
|
+
* The framework-agnostic counterpart to the Solid leaf: pair the map entry points
|
|
19
|
+
* with `@oasys/oecs/solid`'s `fromKernelMap`, the singleton struct with
|
|
20
|
+
* `fromKernelStruct`, and the singleton array with `fromKernelArray`, to render.
|
|
21
|
+
*/
|
|
22
|
+
export { syncComponentToMap, syncFieldsToMap, syncJoinToMap, syncSingletonToStruct, syncSingletonToArray, batchedUpdate, shallow, type Projection, type JoinProjection, type RowReader, type JoinReader, type SyncGrain, type EcsMapSync, type EcsMapSyncOptions, type SingletonStructSync, type SingletonSyncOptions, type SingletonArraySync, type SingletonArraySyncOptions } from './ecs_sync.js';
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extensions/reactive/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EACN,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,EACb,OAAO,EACP,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAC9B,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { b as f, u as _ } from "../../kernel-DgyrLFjW.js";
|
|
2
|
+
import { r as m, s as E, a as p, b as w } from "../../shallow-DfnAm9vG.js";
|
|
3
|
+
class v {
|
|
4
|
+
constructor(n) {
|
|
5
|
+
this.def = n;
|
|
6
|
+
}
|
|
7
|
+
_ctx;
|
|
8
|
+
_eid = 0;
|
|
9
|
+
get eid() {
|
|
10
|
+
return this._eid;
|
|
11
|
+
}
|
|
12
|
+
field(n) {
|
|
13
|
+
return this._ctx.getField(this._eid, this.def, n);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
class R {
|
|
17
|
+
constructor(n) {
|
|
18
|
+
this.def = n;
|
|
19
|
+
}
|
|
20
|
+
_eid = 0;
|
|
21
|
+
_row = 0;
|
|
22
|
+
cols = /* @__PURE__ */ new Map();
|
|
23
|
+
arch;
|
|
24
|
+
/** Bind to an archetype for one dispatch (drops the previous column cache). */
|
|
25
|
+
bind(n) {
|
|
26
|
+
this.arch = n, this.cols.clear();
|
|
27
|
+
}
|
|
28
|
+
get eid() {
|
|
29
|
+
return this._eid;
|
|
30
|
+
}
|
|
31
|
+
field(n) {
|
|
32
|
+
let s = this.cols.get(n);
|
|
33
|
+
return s === void 0 && (s = this.arch.getColumnRead(this.def, n), this.cols.set(n, s)), s[this._row];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
class x {
|
|
37
|
+
_ctx;
|
|
38
|
+
_eid = 0;
|
|
39
|
+
get eid() {
|
|
40
|
+
return this._eid;
|
|
41
|
+
}
|
|
42
|
+
field(n, s) {
|
|
43
|
+
return this._ctx.getField(this._eid, n, s);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function A(l, n, s, r = {}) {
|
|
47
|
+
const c = m(r.eq), a = {
|
|
48
|
+
...r.access,
|
|
49
|
+
reads: [n, ...r.access?.reads ?? []]
|
|
50
|
+
}, h = r.grain ?? "entity", u = r.seedExisting ?? !0, b = new v(n), y = (o, i) => {
|
|
51
|
+
i.isDisabled(o) || (b._ctx = i, b._eid = o, c.set(o, s(b)));
|
|
52
|
+
};
|
|
53
|
+
let g;
|
|
54
|
+
return f(() => {
|
|
55
|
+
if (h === "column") {
|
|
56
|
+
const o = new R(n);
|
|
57
|
+
g = l.observe(n, {
|
|
58
|
+
granularity: "archetype",
|
|
59
|
+
onSet: (i) => {
|
|
60
|
+
o.bind(i);
|
|
61
|
+
const t = i.entityIds;
|
|
62
|
+
for (let e = 0; e < i.entityCount; e++)
|
|
63
|
+
o._row = e, o._eid = t[e], c.set(o._eid, s(o));
|
|
64
|
+
},
|
|
65
|
+
onAdd: (i, t) => y(i, t),
|
|
66
|
+
onRemove: (i) => c.delete(i),
|
|
67
|
+
// Disable = soft remove from the channel; enable = re-add (#677). The
|
|
68
|
+
// column sweep is bounded by enabled rows, so a disabled row would never
|
|
69
|
+
// refresh — drop it on disable, republish on enable.
|
|
70
|
+
onDisable: (i) => c.delete(i),
|
|
71
|
+
onEnable: (i, t) => y(i, t),
|
|
72
|
+
access: a,
|
|
73
|
+
yieldExisting: u
|
|
74
|
+
});
|
|
75
|
+
} else
|
|
76
|
+
g = l.observe(n, {
|
|
77
|
+
granularity: "entity",
|
|
78
|
+
onSet: (o, i) => y(o, i),
|
|
79
|
+
onAdd: (o, i) => y(o, i),
|
|
80
|
+
onRemove: (o) => c.delete(o),
|
|
81
|
+
onDisable: (o) => c.delete(o),
|
|
82
|
+
onEnable: (o, i) => y(o, i),
|
|
83
|
+
access: a,
|
|
84
|
+
yieldExisting: u
|
|
85
|
+
});
|
|
86
|
+
}), { map: c, dispose: () => g.dispose() };
|
|
87
|
+
}
|
|
88
|
+
function q(l, n, s, r = {}) {
|
|
89
|
+
return A(l, n, (a) => {
|
|
90
|
+
const h = {};
|
|
91
|
+
for (let u = 0; u < s.length; u++) h[s[u]] = a.field(s[u]);
|
|
92
|
+
return h;
|
|
93
|
+
}, { ...r, eq: E });
|
|
94
|
+
}
|
|
95
|
+
function M(l, n, s, r = {}) {
|
|
96
|
+
const c = n, a = m(r.eq), h = {
|
|
97
|
+
...r.access,
|
|
98
|
+
reads: [...c, ...r.access?.reads ?? []]
|
|
99
|
+
}, u = r.seedExisting ?? !0, b = new x(), y = (t, e) => {
|
|
100
|
+
for (let d = 0; d < c.length; d++) if (!t.hasComponent(e, c[d])) return !1;
|
|
101
|
+
return !0;
|
|
102
|
+
}, g = (t, e) => {
|
|
103
|
+
e.isDisabled(t) || y(e, t) && (b._ctx = e, b._eid = t, a.set(t, s(b)));
|
|
104
|
+
}, o = (t) => {
|
|
105
|
+
a.delete(t);
|
|
106
|
+
};
|
|
107
|
+
let i;
|
|
108
|
+
return f(() => {
|
|
109
|
+
i = c.map(
|
|
110
|
+
(t) => l.observe(t, {
|
|
111
|
+
granularity: "entity",
|
|
112
|
+
onSet: g,
|
|
113
|
+
onAdd: g,
|
|
114
|
+
onRemove: o,
|
|
115
|
+
// Disabling any joined component soft-removes the entity from the
|
|
116
|
+
// channel; enabling re-evaluates membership and republishes (#677). A
|
|
117
|
+
// disable fires once per carried joined component — `dropRow` is
|
|
118
|
+
// idempotent, and `publishIfMember` re-checks the full join.
|
|
119
|
+
onDisable: o,
|
|
120
|
+
onEnable: g,
|
|
121
|
+
access: h,
|
|
122
|
+
yieldExisting: u
|
|
123
|
+
})
|
|
124
|
+
);
|
|
125
|
+
}), {
|
|
126
|
+
map: a,
|
|
127
|
+
dispose: () => {
|
|
128
|
+
for (let t = 0; t < i.length; t++) i[t].dispose();
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function T(l, n, s, r, c = {}) {
|
|
133
|
+
const a = {};
|
|
134
|
+
for (let e = 0; e < r.length; e++) a[r[e]] = 0;
|
|
135
|
+
const [h, u] = c.into ?? p(a, c.eq), b = _(() => r.map((e) => h[e])), y = {
|
|
136
|
+
...c.access,
|
|
137
|
+
reads: [n, ...c.access?.reads ?? []]
|
|
138
|
+
}, g = c.seedExisting ?? !0, o = (e) => {
|
|
139
|
+
for (let d = 0; d < r.length; d++) u[r[d]](e.getField(s, n, r[d]));
|
|
140
|
+
}, i = () => {
|
|
141
|
+
for (let e = 0; e < r.length; e++) u[r[e]](b[e]);
|
|
142
|
+
};
|
|
143
|
+
let t;
|
|
144
|
+
return f(() => {
|
|
145
|
+
t = l.observe(n, {
|
|
146
|
+
granularity: "entity",
|
|
147
|
+
onSet: (e, d) => {
|
|
148
|
+
e === s && o(d);
|
|
149
|
+
},
|
|
150
|
+
onAdd: (e, d) => {
|
|
151
|
+
e === s && !d.isDisabled(s) && o(d);
|
|
152
|
+
},
|
|
153
|
+
onRemove: (e) => {
|
|
154
|
+
e === s && i();
|
|
155
|
+
},
|
|
156
|
+
onDisable: (e) => {
|
|
157
|
+
e === s && i();
|
|
158
|
+
},
|
|
159
|
+
onEnable: (e, d) => {
|
|
160
|
+
e === s && o(d);
|
|
161
|
+
},
|
|
162
|
+
access: y,
|
|
163
|
+
yieldExisting: g
|
|
164
|
+
});
|
|
165
|
+
}), { struct: h, dispose: () => t.dispose() };
|
|
166
|
+
}
|
|
167
|
+
function C(l, n, s, r, c = {}) {
|
|
168
|
+
const a = c.into ?? w(new Array(r.length).fill(0), c.eq), h = _(() => a.snapshot());
|
|
169
|
+
if (c.into !== void 0 && h.length !== r.length)
|
|
170
|
+
throw new Error(
|
|
171
|
+
`syncSingletonToArray: into.length (${h.length}) must equal fields.length (${r.length})`
|
|
172
|
+
);
|
|
173
|
+
const u = {
|
|
174
|
+
...c.access,
|
|
175
|
+
reads: [n, ...c.access?.reads ?? []]
|
|
176
|
+
}, b = c.seedExisting ?? !0, y = new Array(r.length), g = (t) => {
|
|
177
|
+
for (let e = 0; e < r.length; e++) y[e] = t.getField(s, n, r[e]);
|
|
178
|
+
a.reconcile(y);
|
|
179
|
+
}, o = () => a.reconcile(h);
|
|
180
|
+
let i;
|
|
181
|
+
return f(() => {
|
|
182
|
+
i = l.observe(n, {
|
|
183
|
+
granularity: "entity",
|
|
184
|
+
onSet: (t, e) => {
|
|
185
|
+
t === s && g(e);
|
|
186
|
+
},
|
|
187
|
+
onAdd: (t, e) => {
|
|
188
|
+
t === s && !e.isDisabled(s) && g(e);
|
|
189
|
+
},
|
|
190
|
+
onRemove: (t) => {
|
|
191
|
+
t === s && o();
|
|
192
|
+
},
|
|
193
|
+
onDisable: (t) => {
|
|
194
|
+
t === s && o();
|
|
195
|
+
},
|
|
196
|
+
onEnable: (t, e) => {
|
|
197
|
+
t === s && g(e);
|
|
198
|
+
},
|
|
199
|
+
access: u,
|
|
200
|
+
yieldExisting: b
|
|
201
|
+
});
|
|
202
|
+
}), { array: a, dispose: () => i.dispose() };
|
|
203
|
+
}
|
|
204
|
+
function F(l, n) {
|
|
205
|
+
f(() => l.update(n));
|
|
206
|
+
}
|
|
207
|
+
export {
|
|
208
|
+
F as batchedUpdate,
|
|
209
|
+
E as shallow,
|
|
210
|
+
A as syncComponentToMap,
|
|
211
|
+
q as syncFieldsToMap,
|
|
212
|
+
M as syncJoinToMap,
|
|
213
|
+
C as syncSingletonToArray,
|
|
214
|
+
T as syncSingletonToStruct
|
|
215
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("solid-js"),c=require("../../interop-CT-REx0W.cjs");function l(e){const[t,o]=u.createSignal(e());return u.onCleanup(c.subscribe(e,s=>o(()=>s))),t}function f(e){return{keys:l(()=>e.keys()),cell:t=>l(()=>e.get(t))}}function i(e){const t={},o=Object.keys(e),s=new Set(o);for(const n of o)t[n]=l(()=>e[n]);return new Proxy({},{get:(n,r)=>s.has(r)?t[r]():Reflect.get(n,r),has:(n,r)=>s.has(r),ownKeys:()=>o,getOwnPropertyDescriptor:(n,r)=>s.has(r)?{get:()=>t[r](),enumerable:!0,configurable:!0}:void 0,set:(n,r)=>!1})}function a(e){return l(()=>e.snapshot())}exports.fromKernel=l;exports.fromKernelArray=a;exports.fromKernelMap=f;exports.fromKernelStruct=i;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@oasys/oecs/solid` — the SolidJS adapter plugin for oecs's reactive
|
|
3
|
+
* kernel (`@oasys/oecs/reactive` / `../../reactive`, #646 / ADR-0021).
|
|
4
|
+
*/
|
|
5
|
+
export { fromKernel, fromKernelMap, fromKernelStruct, fromKernelArray, type KernelMapView } from './kernel_solid.cjs';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@oasys/oecs/solid` — the SolidJS adapter plugin for oecs's reactive
|
|
3
|
+
* kernel (`@oasys/oecs/reactive` / `../../reactive`, #646 / ADR-0021).
|
|
4
|
+
*/
|
|
5
|
+
export { fromKernel, fromKernelMap, fromKernelStruct, fromKernelArray, type KernelMapView } from './kernel_solid.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extensions/solid/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACN,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,KAAK,aAAa,EAClB,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createSignal as u, onCleanup as c } from "solid-js";
|
|
2
|
+
import { s as a } from "../../interop-CcY6ASQc.js";
|
|
3
|
+
function f(e) {
|
|
4
|
+
const [t, o] = u(e());
|
|
5
|
+
return c(a(e, (s) => o(() => s))), t;
|
|
6
|
+
}
|
|
7
|
+
function g(e) {
|
|
8
|
+
return {
|
|
9
|
+
keys: f(() => e.keys()),
|
|
10
|
+
cell: (t) => f(() => e.get(t))
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function m(e) {
|
|
14
|
+
const t = {}, o = Object.keys(e), s = new Set(o);
|
|
15
|
+
for (const n of o)
|
|
16
|
+
t[n] = f(() => e[n]);
|
|
17
|
+
return new Proxy({}, {
|
|
18
|
+
get: (n, r) => s.has(r) ? t[r]() : Reflect.get(n, r),
|
|
19
|
+
has: (n, r) => s.has(r),
|
|
20
|
+
ownKeys: () => o,
|
|
21
|
+
getOwnPropertyDescriptor: (n, r) => s.has(r) ? { get: () => t[r](), enumerable: !0, configurable: !0 } : void 0,
|
|
22
|
+
// Read surface only (`Readonly<T>`, POLISH_AUDIT #8) — mirrors the kernel
|
|
23
|
+
// struct proxy's trap so a JS-side assignment fails loudly instead of
|
|
24
|
+
// sticking a non-reactive value on the hidden target.
|
|
25
|
+
set: (n, r) => !1
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function y(e) {
|
|
29
|
+
return f(() => e.snapshot());
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
f as fromKernel,
|
|
33
|
+
y as fromKernelArray,
|
|
34
|
+
g as fromKernelMap,
|
|
35
|
+
m as fromKernelStruct
|
|
36
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Accessor } from 'solid-js';
|
|
2
|
+
import { ReactiveArray, ReactiveMap } from '../../reactive/index.cjs';
|
|
3
|
+
/**
|
|
4
|
+
* Mirror a kernel accessor into a Solid accessor. The returned accessor tracks in
|
|
5
|
+
* Solid; it updates once per coalesced kernel change and never on an equal write.
|
|
6
|
+
*/
|
|
7
|
+
export declare function fromKernel<T>(accessor: () => T): Accessor<T>;
|
|
8
|
+
/** A kernel `reactiveMap` projected for a keyed Solid `<For>`. */
|
|
9
|
+
export interface KernelMapView<K, V> {
|
|
10
|
+
/** The live key set — pass to a keyed Solid `<For each>`. Keyed on the id. */
|
|
11
|
+
readonly keys: Accessor<readonly K[]>;
|
|
12
|
+
/** A bridged value accessor for one key — read inside the `<For>` row.
|
|
13
|
+
* Each call mints a FRESH bridge (subscription): call it once per row (bind
|
|
14
|
+
* the accessor in the row's scope), never inline it in a hot JSX expression
|
|
15
|
+
* that re-evaluates per render. */
|
|
16
|
+
cell(key: K): Accessor<V | undefined>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Bridge a kernel `reactiveMap` for keyed Solid rendering. `keys` drives a `<For>`
|
|
20
|
+
* (one row per entity, keyed on the stable id); `cell(id)` is that row's bridged
|
|
21
|
+
* value. Changing one entity wakes only its row; spawn/despawn add/remove one row.
|
|
22
|
+
*/
|
|
23
|
+
export declare function fromKernelMap<K, V>(map: ReactiveMap<K, V>): KernelMapView<K, V>;
|
|
24
|
+
/**
|
|
25
|
+
* Bridge a kernel `reactiveStruct` proxy into a Solid-reactive proxy: reading
|
|
26
|
+
* `view.field` in a Solid scope tracks that field alone (one `fromKernel` per
|
|
27
|
+
* field), so a change to one field re-renders only its readers. Completes the
|
|
28
|
+
* `fromKernel` / `fromKernelMap` / `fromKernelStruct` trio — the read side for the
|
|
29
|
+
* singleton/ephemeral UI state `syncSingletonToStruct` publishes (ADR-0024). The
|
|
30
|
+
* field set is read once from the (enumerable) struct proxy; call inside a component
|
|
31
|
+
* or `root` so each field's `onCleanup` has an owner. The kernel struct's per-field
|
|
32
|
+
* `eq` and batching carry through `fromKernel` unchanged.
|
|
33
|
+
*/
|
|
34
|
+
export declare function fromKernelStruct<T extends object>(struct: Readonly<T>): Readonly<T>;
|
|
35
|
+
/**
|
|
36
|
+
* Bridge a kernel `reactiveArray` into a Solid accessor of its snapshot, for a
|
|
37
|
+
* positional Solid `<Index each={view()}>`. `<Index>` (NOT `<For>`) is the match for
|
|
38
|
+
* an ordered slot list: it keys by position and hands each slot an accessor, so
|
|
39
|
+
* duplicate primitive values (e.g. empty army slots) don't alias and a slot change
|
|
40
|
+
* updates only that row. The snapshot is the array's coarse read (any slot change
|
|
41
|
+
* wakes it), but `<Index>` then diffs by position and touches only the changed
|
|
42
|
+
* index's DOM. Use `fromKernelMap` instead for an *entity* collection (keyed, `<For>`).
|
|
43
|
+
*/
|
|
44
|
+
export declare function fromKernelArray<T>(arr: ReactiveArray<T>): Accessor<readonly T[]>;
|
|
45
|
+
//# sourceMappingURL=kernel_solid.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Accessor } from 'solid-js';
|
|
2
|
+
import { ReactiveArray, ReactiveMap } from '../../reactive/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Mirror a kernel accessor into a Solid accessor. The returned accessor tracks in
|
|
5
|
+
* Solid; it updates once per coalesced kernel change and never on an equal write.
|
|
6
|
+
*/
|
|
7
|
+
export declare function fromKernel<T>(accessor: () => T): Accessor<T>;
|
|
8
|
+
/** A kernel `reactiveMap` projected for a keyed Solid `<For>`. */
|
|
9
|
+
export interface KernelMapView<K, V> {
|
|
10
|
+
/** The live key set — pass to a keyed Solid `<For each>`. Keyed on the id. */
|
|
11
|
+
readonly keys: Accessor<readonly K[]>;
|
|
12
|
+
/** A bridged value accessor for one key — read inside the `<For>` row.
|
|
13
|
+
* Each call mints a FRESH bridge (subscription): call it once per row (bind
|
|
14
|
+
* the accessor in the row's scope), never inline it in a hot JSX expression
|
|
15
|
+
* that re-evaluates per render. */
|
|
16
|
+
cell(key: K): Accessor<V | undefined>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Bridge a kernel `reactiveMap` for keyed Solid rendering. `keys` drives a `<For>`
|
|
20
|
+
* (one row per entity, keyed on the stable id); `cell(id)` is that row's bridged
|
|
21
|
+
* value. Changing one entity wakes only its row; spawn/despawn add/remove one row.
|
|
22
|
+
*/
|
|
23
|
+
export declare function fromKernelMap<K, V>(map: ReactiveMap<K, V>): KernelMapView<K, V>;
|
|
24
|
+
/**
|
|
25
|
+
* Bridge a kernel `reactiveStruct` proxy into a Solid-reactive proxy: reading
|
|
26
|
+
* `view.field` in a Solid scope tracks that field alone (one `fromKernel` per
|
|
27
|
+
* field), so a change to one field re-renders only its readers. Completes the
|
|
28
|
+
* `fromKernel` / `fromKernelMap` / `fromKernelStruct` trio — the read side for the
|
|
29
|
+
* singleton/ephemeral UI state `syncSingletonToStruct` publishes (ADR-0024). The
|
|
30
|
+
* field set is read once from the (enumerable) struct proxy; call inside a component
|
|
31
|
+
* or `root` so each field's `onCleanup` has an owner. The kernel struct's per-field
|
|
32
|
+
* `eq` and batching carry through `fromKernel` unchanged.
|
|
33
|
+
*/
|
|
34
|
+
export declare function fromKernelStruct<T extends object>(struct: Readonly<T>): Readonly<T>;
|
|
35
|
+
/**
|
|
36
|
+
* Bridge a kernel `reactiveArray` into a Solid accessor of its snapshot, for a
|
|
37
|
+
* positional Solid `<Index each={view()}>`. `<Index>` (NOT `<For>`) is the match for
|
|
38
|
+
* an ordered slot list: it keys by position and hands each slot an accessor, so
|
|
39
|
+
* duplicate primitive values (e.g. empty army slots) don't alias and a slot change
|
|
40
|
+
* updates only that row. The snapshot is the array's coarse read (any slot change
|
|
41
|
+
* wakes it), but `<Index>` then diffs by position and touches only the changed
|
|
42
|
+
* index's DOM. Use `fromKernelMap` instead for an *entity* collection (keyed, `<For>`).
|
|
43
|
+
*/
|
|
44
|
+
export declare function fromKernelArray<T>(arr: ReactiveArray<T>): Accessor<readonly T[]>;
|
|
45
|
+
//# sourceMappingURL=kernel_solid.d.ts.map
|