@oasys/oecs 0.4.0 → 0.5.1
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 +636 -0
- package/README.md +47 -32
- 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 +25 -13
- 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 +201 -0
- package/dist/core/ecs/component.d.ts +100 -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 +580 -0
- package/dist/core/ecs/ecs.d.ts +340 -293
- 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 +8 -2
- 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 +284 -0
- package/dist/core/ecs/host_commands.d.ts +77 -45
- 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 +44 -13
- package/dist/core/ecs/observer.d.ts.map +1 -1
- package/dist/core/ecs/query.d.cts +734 -0
- package/dist/core/ecs/query.d.ts +267 -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/ref.d.ts.map +1 -1
- 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 +16 -10
- 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 +937 -0
- package/dist/core/ecs/store.d.ts +144 -356
- 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 +2 -0
- package/dist/dev_flag.d.ts +2 -0
- package/dist/dev_flag.d.ts.map +1 -0
- package/dist/extensions/editor/editor.d.cts +172 -0
- package/dist/extensions/editor/editor.d.ts +65 -42
- 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 +10 -5
- 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 +130 -100
- 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-BI8pEmjH.js +2326 -0
- package/dist/host_commands-CxhpzMx9.cjs +1 -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 +4489 -5898
- 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
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import { ReactiveArray, ReactiveMap, StructSetters } from '../../
|
|
2
|
-
import { ComponentDef, ComponentSchema, ECS, EntityID, SystemAccessDeclaration } from '../../core/ecs';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* projections. Mirrors zustand `useShallow` / MobX `comparer.shallow`: two objects
|
|
6
|
-
* are equal iff they have the same own keys with `Object.is`-equal values. Restores
|
|
7
|
-
* "equal write wakes nobody" for projections that build a fresh object each tick.
|
|
8
|
-
*/
|
|
9
|
-
export declare function shallow(a: object, b: object): boolean;
|
|
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 };
|
|
10
5
|
/**
|
|
11
6
|
* A read cursor over one entity's single-component state, handed to a single-
|
|
12
7
|
* component `Projection`. `field` is column-backed under "column" grain
|
|
@@ -32,16 +27,19 @@ export interface RowReader<S extends ComponentSchema> {
|
|
|
32
27
|
* Lifetime: like `RowReader`, a reused mutable singleton valid ONLY during the
|
|
33
28
|
* synchronous `project` call — never capture it; the next dispatch mutates it.
|
|
34
29
|
*/
|
|
35
|
-
export interface JoinReader {
|
|
30
|
+
export interface JoinReader<Schemas extends readonly ComponentSchema[] = readonly ComponentSchema[]> {
|
|
36
31
|
/** The current entity (it has all joined components). */
|
|
37
32
|
readonly eid: EntityID;
|
|
38
|
-
/** Read a field of one joined component for the current entity.
|
|
39
|
-
|
|
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;
|
|
40
38
|
}
|
|
41
39
|
/** Map one single-component row to the value a UI cell reads. */
|
|
42
40
|
export type Projection<S extends ComponentSchema, V> = (row: RowReader<S>) => V;
|
|
43
41
|
/** Map one joined entity to the value a UI cell reads. */
|
|
44
|
-
export type JoinProjection<V> = (row: JoinReader) => V;
|
|
42
|
+
export type JoinProjection<V, Schemas extends readonly ComponentSchema[] = readonly ComponentSchema[]> = (row: JoinReader<Schemas>) => V;
|
|
45
43
|
/** Per-component dirty grain. See the module header for the measured crossover. */
|
|
46
44
|
export type SyncGrain = "entity" | "column";
|
|
47
45
|
export interface EcsMapSyncOptions<V> {
|
|
@@ -55,7 +53,7 @@ export interface EcsMapSyncOptions<V> {
|
|
|
55
53
|
eq?: (a: V, b: V) => boolean;
|
|
56
54
|
/**
|
|
57
55
|
* Access surface the projection touches, merged over the synced components'
|
|
58
|
-
* `reads`. `
|
|
56
|
+
* `reads`. `DEV` access-checks the observer callbacks exactly like a system.
|
|
59
57
|
*/
|
|
60
58
|
access?: Partial<SystemAccessDeclaration>;
|
|
61
59
|
/**
|
|
@@ -79,7 +77,7 @@ export interface EcsMapSync<V> {
|
|
|
79
77
|
* To read more than one component per row, use `syncJoinToMap` — reading a second
|
|
80
78
|
* component here goes stale (its changes aren't subscribed).
|
|
81
79
|
*/
|
|
82
|
-
export declare function syncComponentToMap<S extends ComponentSchema, V>(
|
|
80
|
+
export declare function syncComponentToMap<S extends ComponentSchema, V>(ecs: ECS, def: ComponentDef<S>, project: Projection<S, V>, opts?: EcsMapSyncOptions<V>): EcsMapSync<V>;
|
|
83
81
|
/**
|
|
84
82
|
* Sugar over `syncComponentToMap`: project a fixed FIELD LIST into a `{ field:
|
|
85
83
|
* value }` snapshot, with an automatic `shallow` eq so an unchanged row wakes
|
|
@@ -93,7 +91,7 @@ export declare function syncComponentToMap<S extends ComponentSchema, V>(world:
|
|
|
93
91
|
* or hand-written-`eq` projection, so the hot path doesn't allocate exactly where
|
|
94
92
|
* the column grain is meant to keep it cheap.
|
|
95
93
|
*/
|
|
96
|
-
export declare function syncFieldsToMap<S extends ComponentSchema, const F extends readonly (string & keyof S)[]>(
|
|
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<{
|
|
97
95
|
[K in F[number]]: number;
|
|
98
96
|
}>, "eq">): EcsMapSync<{
|
|
99
97
|
[K in F[number]]: number;
|
|
@@ -109,7 +107,9 @@ export declare function syncFieldsToMap<S extends ComponentSchema, const F exten
|
|
|
109
107
|
* Entity grain only: a join spans archetypes, so there is no single column to
|
|
110
108
|
* sweep. Drive with `batchedUpdate(world, dt)`.
|
|
111
109
|
*/
|
|
112
|
-
export declare function syncJoinToMap<V>(
|
|
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
113
|
export interface SingletonStructSync<V extends object> {
|
|
114
114
|
/** The live per-field channel: reading `struct.field` in a tracked scope
|
|
115
115
|
* subscribes to that field alone (pair with `fromKernelStruct` to render). */
|
|
@@ -120,7 +120,7 @@ export interface SingletonStructSync<V extends object> {
|
|
|
120
120
|
export interface SingletonSyncOptions<V extends object = Record<string, number>> {
|
|
121
121
|
/**
|
|
122
122
|
* Access surface the publish touches, merged over the synced def's read.
|
|
123
|
-
* `
|
|
123
|
+
* `DEV` access-checks the observer callbacks exactly like a system.
|
|
124
124
|
*/
|
|
125
125
|
access?: Partial<SystemAccessDeclaration>;
|
|
126
126
|
/** Replay current state on registration (default `true`). flecs `yieldExisting`. */
|
|
@@ -134,6 +134,10 @@ export interface SingletonSyncOptions<V extends object = Record<string, number>>
|
|
|
134
134
|
* the eager initials with the entity's current values on registration.
|
|
135
135
|
*/
|
|
136
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>;
|
|
137
141
|
}
|
|
138
142
|
/**
|
|
139
143
|
* Sync ONE singleton entity's single-component state into a `reactiveStruct`,
|
|
@@ -165,7 +169,7 @@ export interface SingletonSyncOptions<V extends object = Record<string, number>>
|
|
|
165
169
|
* or the zeros of a freshly-created one — captured (untracked) at registration, NOT a
|
|
166
170
|
* blind 0. A singleton is rarely despawned; this keeps the channel well-defined if it is.
|
|
167
171
|
*/
|
|
168
|
-
export declare function syncSingletonToStruct<S extends ComponentSchema, const F extends readonly (string & keyof S)[]>(
|
|
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<{
|
|
169
173
|
[K in F[number]]: number;
|
|
170
174
|
}>): SingletonStructSync<{
|
|
171
175
|
[K in F[number]]: number;
|
|
@@ -197,14 +201,14 @@ export interface SingletonArraySyncOptions<T> {
|
|
|
197
201
|
* `fields` is explicit (a `ComponentDef` is a branded number at runtime). Pair with
|
|
198
202
|
* `@oasys/oecs/solid`'s `fromKernelArray` + a Solid `<Index>`.
|
|
199
203
|
*/
|
|
200
|
-
export declare function syncSingletonToArray<S extends ComponentSchema>(
|
|
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>;
|
|
201
205
|
/**
|
|
202
206
|
* Advance the world one tick with every bridge publish coalesced into a single UI
|
|
203
207
|
* flush. onAdd/onRemove fire mid-tick at flush boundaries and onSet fires at the
|
|
204
208
|
* tick tail; wrapping the whole update in `batch` defers the effect flush until the
|
|
205
209
|
* tick completes, so a frame that touched K entities (across any number of syncs on
|
|
206
210
|
* this world) wakes its readers once, not once per observer dispatch point.
|
|
207
|
-
* Equivalent to `batch(() =>
|
|
211
|
+
* Equivalent to `batch(() => ecs.update(dt))`.
|
|
208
212
|
*/
|
|
209
|
-
export declare function batchedUpdate(
|
|
213
|
+
export declare function batchedUpdate(ecs: ECS, dt: number): void;
|
|
210
214
|
//# sourceMappingURL=ecs_sync.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecs_sync.d.ts","sourceRoot":"","sources":["../../../src/extensions/reactive/ecs_sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EG;AACH,OAAO,EAMN,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,MAAM,
|
|
1
|
+
{"version":3,"file":"ecs_sync.d.ts","sourceRoot":"","sources":["../../../src/extensions/reactive/ecs_sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EG;AACH,OAAO,EAMN,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAEX,YAAY,EACZ,eAAe,EACf,GAAG,EACH,QAAQ,EAGR,uBAAuB,EAEvB,MAAM,gBAAgB,CAAC;AAKxB,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,CAAC;AAEnB;;;;;;;;;GASG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC,SAAS,eAAe;IACnD,oDAAoD;IACpD,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC;IACvB,gEAAg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AED,MAAM,WAAW,yBAAyB,CAAC,CAAC;IAC3C,MAAM,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC1C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,6FAA6F;IAC7F,IAAI,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IACxB,0EAA0E;IAC1E,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC;CAC7B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,eAAe,EAC7D,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC,EACpB,GAAG,EAAE,QAAQ,EACb,MAAM,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,EAAE,EACrC,IAAI,GAAE,yBAAyB,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../kernel-yWV3XnAb.cjs"),
|
|
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
|
|
@@ -19,5 +19,5 @@
|
|
|
19
19
|
* with `@oasys/oecs/solid`'s `fromKernelMap`, the singleton struct with
|
|
20
20
|
* `fromKernelStruct`, and the singleton array with `fromKernelArray`, to render.
|
|
21
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';
|
|
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
23
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
import { b as f, u as _ } from "../../kernel-DgyrLFjW.js";
|
|
2
|
-
import { r as
|
|
3
|
-
function w(a, n) {
|
|
4
|
-
if (Object.is(a, n)) return !0;
|
|
5
|
-
const s = a, r = n, o = Object.keys(s);
|
|
6
|
-
if (o.length !== Object.keys(r).length) return !1;
|
|
7
|
-
for (let l = 0; l < o.length; l++) {
|
|
8
|
-
const u = o[l];
|
|
9
|
-
if (!Object.prototype.hasOwnProperty.call(r, u) || !Object.is(s[u], r[u])) return !1;
|
|
10
|
-
}
|
|
11
|
-
return !0;
|
|
12
|
-
}
|
|
2
|
+
import { r as m, s as E, a as p, b as w } from "../../shallow-DfnAm9vG.js";
|
|
13
3
|
class v {
|
|
14
4
|
constructor(n) {
|
|
15
5
|
this.def = n;
|
|
@@ -53,173 +43,173 @@ class x {
|
|
|
53
43
|
return this._ctx.getField(this._eid, n, s);
|
|
54
44
|
}
|
|
55
45
|
}
|
|
56
|
-
function A(
|
|
57
|
-
const
|
|
46
|
+
function A(l, n, s, r = {}) {
|
|
47
|
+
const c = m(r.eq), a = {
|
|
58
48
|
...r.access,
|
|
59
49
|
reads: [n, ...r.access?.reads ?? []]
|
|
60
|
-
},
|
|
61
|
-
|
|
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)));
|
|
62
52
|
};
|
|
63
53
|
let g;
|
|
64
54
|
return f(() => {
|
|
65
|
-
if (
|
|
66
|
-
const
|
|
67
|
-
g =
|
|
55
|
+
if (h === "column") {
|
|
56
|
+
const o = new R(n);
|
|
57
|
+
g = l.observe(n, {
|
|
68
58
|
granularity: "archetype",
|
|
69
|
-
onSet: (
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
for (let e = 0; e <
|
|
73
|
-
|
|
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));
|
|
74
64
|
},
|
|
75
|
-
onAdd: (
|
|
76
|
-
onRemove: (
|
|
65
|
+
onAdd: (i, t) => y(i, t),
|
|
66
|
+
onRemove: (i) => c.delete(i),
|
|
77
67
|
// Disable = soft remove from the channel; enable = re-add (#677). The
|
|
78
68
|
// column sweep is bounded by enabled rows, so a disabled row would never
|
|
79
69
|
// refresh — drop it on disable, republish on enable.
|
|
80
|
-
onDisable: (
|
|
81
|
-
onEnable: (
|
|
82
|
-
access:
|
|
83
|
-
yieldExisting:
|
|
70
|
+
onDisable: (i) => c.delete(i),
|
|
71
|
+
onEnable: (i, t) => y(i, t),
|
|
72
|
+
access: a,
|
|
73
|
+
yieldExisting: u
|
|
84
74
|
});
|
|
85
75
|
} else
|
|
86
|
-
g =
|
|
76
|
+
g = l.observe(n, {
|
|
87
77
|
granularity: "entity",
|
|
88
|
-
onSet: (
|
|
89
|
-
onAdd: (
|
|
90
|
-
onRemove: (
|
|
91
|
-
onDisable: (
|
|
92
|
-
onEnable: (
|
|
93
|
-
access:
|
|
94
|
-
yieldExisting:
|
|
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
|
|
95
85
|
});
|
|
96
|
-
}), { map:
|
|
86
|
+
}), { map: c, dispose: () => g.dispose() };
|
|
97
87
|
}
|
|
98
|
-
function
|
|
99
|
-
return A(
|
|
100
|
-
const
|
|
101
|
-
for (let
|
|
102
|
-
return
|
|
103
|
-
}, { ...r, eq:
|
|
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 });
|
|
104
94
|
}
|
|
105
|
-
function M(
|
|
106
|
-
const
|
|
95
|
+
function M(l, n, s, r = {}) {
|
|
96
|
+
const c = n, a = m(r.eq), h = {
|
|
107
97
|
...r.access,
|
|
108
|
-
reads: [...
|
|
109
|
-
}, u = r.seedExisting ?? !0,
|
|
110
|
-
for (let
|
|
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;
|
|
111
101
|
return !0;
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
},
|
|
115
|
-
|
|
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);
|
|
116
106
|
};
|
|
117
107
|
let i;
|
|
118
108
|
return f(() => {
|
|
119
|
-
i =
|
|
120
|
-
(t) =>
|
|
109
|
+
i = c.map(
|
|
110
|
+
(t) => l.observe(t, {
|
|
121
111
|
granularity: "entity",
|
|
122
|
-
onSet:
|
|
123
|
-
onAdd:
|
|
124
|
-
onRemove:
|
|
112
|
+
onSet: g,
|
|
113
|
+
onAdd: g,
|
|
114
|
+
onRemove: o,
|
|
125
115
|
// Disabling any joined component soft-removes the entity from the
|
|
126
116
|
// channel; enabling re-evaluates membership and republishes (#677). A
|
|
127
117
|
// disable fires once per carried joined component — `dropRow` is
|
|
128
118
|
// idempotent, and `publishIfMember` re-checks the full join.
|
|
129
|
-
onDisable:
|
|
130
|
-
onEnable:
|
|
131
|
-
access:
|
|
119
|
+
onDisable: o,
|
|
120
|
+
onEnable: g,
|
|
121
|
+
access: h,
|
|
132
122
|
yieldExisting: u
|
|
133
123
|
})
|
|
134
124
|
);
|
|
135
125
|
}), {
|
|
136
|
-
map:
|
|
126
|
+
map: a,
|
|
137
127
|
dispose: () => {
|
|
138
128
|
for (let t = 0; t < i.length; t++) i[t].dispose();
|
|
139
129
|
}
|
|
140
130
|
};
|
|
141
131
|
}
|
|
142
|
-
function
|
|
143
|
-
const
|
|
144
|
-
for (let e = 0; e < r.length; e++)
|
|
145
|
-
const [
|
|
146
|
-
...
|
|
147
|
-
reads: [n, ...
|
|
148
|
-
}, g =
|
|
149
|
-
for (let
|
|
150
|
-
},
|
|
151
|
-
for (let e = 0; e < r.length; e++)
|
|
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]);
|
|
152
142
|
};
|
|
153
|
-
let
|
|
143
|
+
let t;
|
|
154
144
|
return f(() => {
|
|
155
|
-
|
|
145
|
+
t = l.observe(n, {
|
|
156
146
|
granularity: "entity",
|
|
157
|
-
onSet: (e,
|
|
158
|
-
e === s &&
|
|
147
|
+
onSet: (e, d) => {
|
|
148
|
+
e === s && o(d);
|
|
159
149
|
},
|
|
160
|
-
onAdd: (e,
|
|
161
|
-
e === s && !
|
|
150
|
+
onAdd: (e, d) => {
|
|
151
|
+
e === s && !d.isDisabled(s) && o(d);
|
|
162
152
|
},
|
|
163
153
|
onRemove: (e) => {
|
|
164
|
-
e === s &&
|
|
154
|
+
e === s && i();
|
|
165
155
|
},
|
|
166
156
|
onDisable: (e) => {
|
|
167
|
-
e === s &&
|
|
157
|
+
e === s && i();
|
|
168
158
|
},
|
|
169
|
-
onEnable: (e,
|
|
170
|
-
e === s &&
|
|
159
|
+
onEnable: (e, d) => {
|
|
160
|
+
e === s && o(d);
|
|
171
161
|
},
|
|
172
|
-
access:
|
|
162
|
+
access: y,
|
|
173
163
|
yieldExisting: g
|
|
174
164
|
});
|
|
175
|
-
}), { struct:
|
|
165
|
+
}), { struct: h, dispose: () => t.dispose() };
|
|
176
166
|
}
|
|
177
|
-
function
|
|
178
|
-
const
|
|
179
|
-
if (
|
|
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)
|
|
180
170
|
throw new Error(
|
|
181
|
-
`syncSingletonToArray: into.length (${
|
|
171
|
+
`syncSingletonToArray: into.length (${h.length}) must equal fields.length (${r.length})`
|
|
182
172
|
);
|
|
183
|
-
const
|
|
184
|
-
...
|
|
185
|
-
reads: [n, ...
|
|
186
|
-
}, b =
|
|
187
|
-
for (let e = 0; e < r.length; e++)
|
|
188
|
-
|
|
189
|
-
},
|
|
190
|
-
let
|
|
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;
|
|
191
181
|
return f(() => {
|
|
192
|
-
|
|
182
|
+
i = l.observe(n, {
|
|
193
183
|
granularity: "entity",
|
|
194
|
-
onSet: (
|
|
195
|
-
|
|
184
|
+
onSet: (t, e) => {
|
|
185
|
+
t === s && g(e);
|
|
196
186
|
},
|
|
197
|
-
onAdd: (
|
|
198
|
-
|
|
187
|
+
onAdd: (t, e) => {
|
|
188
|
+
t === s && !e.isDisabled(s) && g(e);
|
|
199
189
|
},
|
|
200
|
-
onRemove: (
|
|
201
|
-
|
|
190
|
+
onRemove: (t) => {
|
|
191
|
+
t === s && o();
|
|
202
192
|
},
|
|
203
|
-
onDisable: (
|
|
204
|
-
|
|
193
|
+
onDisable: (t) => {
|
|
194
|
+
t === s && o();
|
|
205
195
|
},
|
|
206
|
-
onEnable: (
|
|
207
|
-
|
|
196
|
+
onEnable: (t, e) => {
|
|
197
|
+
t === s && g(e);
|
|
208
198
|
},
|
|
209
|
-
access:
|
|
199
|
+
access: u,
|
|
210
200
|
yieldExisting: b
|
|
211
201
|
});
|
|
212
|
-
}), { array:
|
|
202
|
+
}), { array: a, dispose: () => i.dispose() };
|
|
213
203
|
}
|
|
214
|
-
function
|
|
215
|
-
f(() =>
|
|
204
|
+
function F(l, n) {
|
|
205
|
+
f(() => l.update(n));
|
|
216
206
|
}
|
|
217
207
|
export {
|
|
218
|
-
|
|
219
|
-
|
|
208
|
+
F as batchedUpdate,
|
|
209
|
+
E as shallow,
|
|
220
210
|
A as syncComponentToMap,
|
|
221
|
-
|
|
211
|
+
q as syncFieldsToMap,
|
|
222
212
|
M as syncJoinToMap,
|
|
223
|
-
|
|
224
|
-
|
|
213
|
+
C as syncSingletonToArray,
|
|
214
|
+
T as syncSingletonToStruct
|
|
225
215
|
};
|
|
@@ -1 +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})}function a(e){return l(()=>e.snapshot())}exports.fromKernel=l;exports.fromKernelArray=a;exports.fromKernelMap=f;exports.fromKernelStruct=i;
|
|
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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `@oasys/oecs/solid` — the SolidJS adapter plugin for oecs's reactive
|
|
3
|
-
* kernel (`@oasys/oecs/reactive` / `../../
|
|
3
|
+
* kernel (`@oasys/oecs/reactive` / `../../reactive`, #646 / ADR-0021).
|
|
4
4
|
*/
|
|
5
|
-
export { fromKernel, fromKernelMap, fromKernelStruct, fromKernelArray, type KernelMapView } from './kernel_solid';
|
|
5
|
+
export { fromKernel, fromKernelMap, fromKernelStruct, fromKernelArray, type KernelMapView } from './kernel_solid.js';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { createSignal as
|
|
1
|
+
import { createSignal as u, onCleanup as c } from "solid-js";
|
|
2
2
|
import { s as a } from "../../interop-CcY6ASQc.js";
|
|
3
3
|
function f(e) {
|
|
4
|
-
const [t, o] =
|
|
5
|
-
return
|
|
4
|
+
const [t, o] = u(e());
|
|
5
|
+
return c(a(e, (s) => o(() => s))), t;
|
|
6
6
|
}
|
|
7
7
|
function g(e) {
|
|
8
8
|
return {
|
|
@@ -18,7 +18,11 @@ function m(e) {
|
|
|
18
18
|
get: (n, r) => s.has(r) ? t[r]() : Reflect.get(n, r),
|
|
19
19
|
has: (n, r) => s.has(r),
|
|
20
20
|
ownKeys: () => o,
|
|
21
|
-
getOwnPropertyDescriptor: (n, r) => s.has(r) ? { get: () => t[r](), enumerable: !0, configurable: !0 } : void 0
|
|
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
|
|
22
26
|
});
|
|
23
27
|
}
|
|
24
28
|
function y(e) {
|
|
@@ -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
|