@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,19 @@
|
|
|
1
|
+
import { Accessor } from './kernel.cjs';
|
|
2
|
+
/**
|
|
3
|
+
* Vanilla subscription: invoke `onChange(value)` once per coalesced change to
|
|
4
|
+
* whatever `accessor` reads. Does NOT fire on subscribe (the consumer reads the
|
|
5
|
+
* initial value itself); returns a disposer. This is the universal adapter base.
|
|
6
|
+
*/
|
|
7
|
+
export declare function subscribe<T>(accessor: Accessor<T>, onChange: (value: T) => void): () => void;
|
|
8
|
+
/**
|
|
9
|
+
* The framework-agnostic external-store contract (React's useSyncExternalStore
|
|
10
|
+
* shape, but useful everywhere). `subscribe` takes a zero-arg "something changed"
|
|
11
|
+
* callback; `getSnapshot` reads the current, referentially-stable value.
|
|
12
|
+
*/
|
|
13
|
+
export interface ExternalStore<T> {
|
|
14
|
+
subscribe(onStoreChange: () => void): () => void;
|
|
15
|
+
getSnapshot(): T;
|
|
16
|
+
}
|
|
17
|
+
/** Wrap an accessor as an ExternalStore. Snapshot stability comes from the kernel. */
|
|
18
|
+
export declare function toExternalStore<T>(accessor: Accessor<T>): ExternalStore<T>;
|
|
19
|
+
//# sourceMappingURL=interop.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Accessor } from './kernel.js';
|
|
2
|
+
/**
|
|
3
|
+
* Vanilla subscription: invoke `onChange(value)` once per coalesced change to
|
|
4
|
+
* whatever `accessor` reads. Does NOT fire on subscribe (the consumer reads the
|
|
5
|
+
* initial value itself); returns a disposer. This is the universal adapter base.
|
|
6
|
+
*/
|
|
7
|
+
export declare function subscribe<T>(accessor: Accessor<T>, onChange: (value: T) => void): () => void;
|
|
8
|
+
/**
|
|
9
|
+
* The framework-agnostic external-store contract (React's useSyncExternalStore
|
|
10
|
+
* shape, but useful everywhere). `subscribe` takes a zero-arg "something changed"
|
|
11
|
+
* callback; `getSnapshot` reads the current, referentially-stable value.
|
|
12
|
+
*/
|
|
13
|
+
export interface ExternalStore<T> {
|
|
14
|
+
subscribe(onStoreChange: () => void): () => void;
|
|
15
|
+
getSnapshot(): T;
|
|
16
|
+
}
|
|
17
|
+
/** Wrap an accessor as an ExternalStore. Snapshot stability comes from the kernel. */
|
|
18
|
+
export declare function toExternalStore<T>(accessor: Accessor<T>): ExternalStore<T>;
|
|
19
|
+
//# sourceMappingURL=interop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interop.d.ts","sourceRoot":"","sources":["../../src/reactive/interop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,EAAmB,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AAE1D;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAW5F;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC;IAC/B,SAAS,CAAC,aAAa,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;IACjD,WAAW,IAAI,CAAC,CAAC;CACjB;AAED,sFAAsF;AACtF,wBAAgB,eAAe,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAK1E"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-house fine-grained reactive kernel — signal / computed / effect / batch,
|
|
3
|
+
* plus ownership scopes (`root` / `onCleanup`). Zero dependencies (ADR-0021).
|
|
4
|
+
*
|
|
5
|
+
* This is the engine UI seam's propagation core. It is the same class of machine
|
|
6
|
+
* as the ECS observer system (ADR-0013) — fine-grained, glitch-free, cascades to
|
|
7
|
+
* a fixed point — at a different granularity, which is exactly why #646 chose to
|
|
8
|
+
* own it rather than adopt solid-js / @preact/signals-core / alien-signals.
|
|
9
|
+
*
|
|
10
|
+
* The dependency graph is an intrusive doubly-linked structure. One pooled `Link`
|
|
11
|
+
* per edge is threaded into BOTH the source's subscriber list and the target's
|
|
12
|
+
* dependency list at once, so link/unlink is O(1) pointer surgery with no hashing,
|
|
13
|
+
* and a stable-dependency re-run reuses its edges via a tail cursor (zero graph
|
|
14
|
+
* mutation). That is the entire performance story: it ties the throughput leaders
|
|
15
|
+
* on the hot paths and avoids the Set-based prototype's fan-in collapse.
|
|
16
|
+
*
|
|
17
|
+
* Computed is lazy and glitch-free via a version-cutoff pull (the model
|
|
18
|
+
* alien-signals / preact use):
|
|
19
|
+
*
|
|
20
|
+
* - Every source carries a `version` that bumps only when its value actually
|
|
21
|
+
* changes. Each edge (`Link`) remembers the source version it last saw.
|
|
22
|
+
* - A write does NOT eagerly recompute anything. It propagates a "maybe-dirty"
|
|
23
|
+
* mark (`OUTDATED`) down through computeds to effects, and queues the effects.
|
|
24
|
+
* Computeds stay lazy.
|
|
25
|
+
* - Work happens on the pull: when an effect flushes (or a computed is read),
|
|
26
|
+
* `needsRecompute` walks its deps, refreshes each, and recomputes only if a
|
|
27
|
+
* dep's version actually advanced. A recompute that produces an equal value
|
|
28
|
+
* does NOT bump the node's own version, so its subscribers are skipped.
|
|
29
|
+
*
|
|
30
|
+
* That gives glitch-freedom (a diamond resolves with one consistent recompute of
|
|
31
|
+
* the join) and minimal work (unchanged values cut propagation) at once.
|
|
32
|
+
*
|
|
33
|
+
* Known, deliberate scope (refinements, not correctness gaps): computeds ALWAYS
|
|
34
|
+
* track their sources (no auto-unsubscribe of unobserved computeds — the TRACKING
|
|
35
|
+
* optimization) and there is no global-version fast path. The two help only a
|
|
36
|
+
* workload heavy in *unobserved* computeds and are low-value without each other;
|
|
37
|
+
* see ADR-0021. Cycle reads return the stale value rather than throwing.
|
|
38
|
+
*/
|
|
39
|
+
export type Eq<T> = (a: T, b: T) => boolean;
|
|
40
|
+
/** A read accessor; calling it inside an effect/computed subscribes to the source. */
|
|
41
|
+
export type Accessor<T> = () => T;
|
|
42
|
+
/** A write setter; a same-value write (per `eq`) is a no-op and wakes nobody. */
|
|
43
|
+
export type Setter<T> = (v: T) => void;
|
|
44
|
+
/** Create a writable signal. Returns `[read, write]`; `eq` defaults to `Object.is`.
|
|
45
|
+
* The zero-arg form (Solid parity) starts at `undefined` for late-initialized
|
|
46
|
+
* values: `const [user, setUser] = signal<User>();` reads `User | undefined`. */
|
|
47
|
+
export declare function signal<T>(): readonly [Accessor<T | undefined>, Setter<T | undefined>];
|
|
48
|
+
export declare function signal<T>(initial: T, eq?: Eq<T>): readonly [Accessor<T>, Setter<T>];
|
|
49
|
+
/** Create a lazy, glitch-free derived value. Recomputes on pull only when a dep changed. */
|
|
50
|
+
export declare function computed<T>(fn: () => T, eq?: Eq<T>): Accessor<T>;
|
|
51
|
+
/** Run `fn` now and re-run it whenever a tracked dep changes. Returns a disposer. */
|
|
52
|
+
export declare function effect(fn: () => void): () => void;
|
|
53
|
+
/** Coalesce all writes inside `fn` into a single flush at the outermost boundary. */
|
|
54
|
+
export declare function batch(fn: () => void): void;
|
|
55
|
+
/**
|
|
56
|
+
* Read inside `fn` without subscribing the enclosing effect/computed to anything it
|
|
57
|
+
* touches (Solid's `untrack`). Use it when a callback that runs during a tracked run
|
|
58
|
+
* must NOT become a dependency — e.g. an interop subscriber whose `onChange` reads
|
|
59
|
+
* other accessors. Returns `fn`'s result.
|
|
60
|
+
*/
|
|
61
|
+
export declare function untrack<T>(fn: () => T): T;
|
|
62
|
+
/**
|
|
63
|
+
* Create an ownership scope. `fn` receives a disposer that tears down every
|
|
64
|
+
* effect/computed (and their onCleanups) created under the scope. Detached from
|
|
65
|
+
* any enclosing owner — you hold the disposer (Solid's `createRoot` contract).
|
|
66
|
+
*/
|
|
67
|
+
export declare function root<T>(fn: (dispose: () => void) => T): T;
|
|
68
|
+
/**
|
|
69
|
+
* Register a cleanup with the owner in scope. Inside an effect/computed it runs
|
|
70
|
+
* before each re-run and on dispose; inside a `root` it runs on root disposal.
|
|
71
|
+
*/
|
|
72
|
+
export declare function onCleanup(fn: () => void): void;
|
|
73
|
+
//# sourceMappingURL=kernel.d.ts.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-house fine-grained reactive kernel — signal / computed / effect / batch,
|
|
3
|
+
* plus ownership scopes (`root` / `onCleanup`). Zero dependencies (ADR-0021).
|
|
4
|
+
*
|
|
5
|
+
* This is the engine UI seam's propagation core. It is the same class of machine
|
|
6
|
+
* as the ECS observer system (ADR-0013) — fine-grained, glitch-free, cascades to
|
|
7
|
+
* a fixed point — at a different granularity, which is exactly why #646 chose to
|
|
8
|
+
* own it rather than adopt solid-js / @preact/signals-core / alien-signals.
|
|
9
|
+
*
|
|
10
|
+
* The dependency graph is an intrusive doubly-linked structure. One pooled `Link`
|
|
11
|
+
* per edge is threaded into BOTH the source's subscriber list and the target's
|
|
12
|
+
* dependency list at once, so link/unlink is O(1) pointer surgery with no hashing,
|
|
13
|
+
* and a stable-dependency re-run reuses its edges via a tail cursor (zero graph
|
|
14
|
+
* mutation). That is the entire performance story: it ties the throughput leaders
|
|
15
|
+
* on the hot paths and avoids the Set-based prototype's fan-in collapse.
|
|
16
|
+
*
|
|
17
|
+
* Computed is lazy and glitch-free via a version-cutoff pull (the model
|
|
18
|
+
* alien-signals / preact use):
|
|
19
|
+
*
|
|
20
|
+
* - Every source carries a `version` that bumps only when its value actually
|
|
21
|
+
* changes. Each edge (`Link`) remembers the source version it last saw.
|
|
22
|
+
* - A write does NOT eagerly recompute anything. It propagates a "maybe-dirty"
|
|
23
|
+
* mark (`OUTDATED`) down through computeds to effects, and queues the effects.
|
|
24
|
+
* Computeds stay lazy.
|
|
25
|
+
* - Work happens on the pull: when an effect flushes (or a computed is read),
|
|
26
|
+
* `needsRecompute` walks its deps, refreshes each, and recomputes only if a
|
|
27
|
+
* dep's version actually advanced. A recompute that produces an equal value
|
|
28
|
+
* does NOT bump the node's own version, so its subscribers are skipped.
|
|
29
|
+
*
|
|
30
|
+
* That gives glitch-freedom (a diamond resolves with one consistent recompute of
|
|
31
|
+
* the join) and minimal work (unchanged values cut propagation) at once.
|
|
32
|
+
*
|
|
33
|
+
* Known, deliberate scope (refinements, not correctness gaps): computeds ALWAYS
|
|
34
|
+
* track their sources (no auto-unsubscribe of unobserved computeds — the TRACKING
|
|
35
|
+
* optimization) and there is no global-version fast path. The two help only a
|
|
36
|
+
* workload heavy in *unobserved* computeds and are low-value without each other;
|
|
37
|
+
* see ADR-0021. Cycle reads return the stale value rather than throwing.
|
|
38
|
+
*/
|
|
39
|
+
export type Eq<T> = (a: T, b: T) => boolean;
|
|
40
|
+
/** A read accessor; calling it inside an effect/computed subscribes to the source. */
|
|
41
|
+
export type Accessor<T> = () => T;
|
|
42
|
+
/** A write setter; a same-value write (per `eq`) is a no-op and wakes nobody. */
|
|
43
|
+
export type Setter<T> = (v: T) => void;
|
|
44
|
+
/** Create a writable signal. Returns `[read, write]`; `eq` defaults to `Object.is`.
|
|
45
|
+
* The zero-arg form (Solid parity) starts at `undefined` for late-initialized
|
|
46
|
+
* values: `const [user, setUser] = signal<User>();` reads `User | undefined`. */
|
|
47
|
+
export declare function signal<T>(): readonly [Accessor<T | undefined>, Setter<T | undefined>];
|
|
48
|
+
export declare function signal<T>(initial: T, eq?: Eq<T>): readonly [Accessor<T>, Setter<T>];
|
|
49
|
+
/** Create a lazy, glitch-free derived value. Recomputes on pull only when a dep changed. */
|
|
50
|
+
export declare function computed<T>(fn: () => T, eq?: Eq<T>): Accessor<T>;
|
|
51
|
+
/** Run `fn` now and re-run it whenever a tracked dep changes. Returns a disposer. */
|
|
52
|
+
export declare function effect(fn: () => void): () => void;
|
|
53
|
+
/** Coalesce all writes inside `fn` into a single flush at the outermost boundary. */
|
|
54
|
+
export declare function batch(fn: () => void): void;
|
|
55
|
+
/**
|
|
56
|
+
* Read inside `fn` without subscribing the enclosing effect/computed to anything it
|
|
57
|
+
* touches (Solid's `untrack`). Use it when a callback that runs during a tracked run
|
|
58
|
+
* must NOT become a dependency — e.g. an interop subscriber whose `onChange` reads
|
|
59
|
+
* other accessors. Returns `fn`'s result.
|
|
60
|
+
*/
|
|
61
|
+
export declare function untrack<T>(fn: () => T): T;
|
|
62
|
+
/**
|
|
63
|
+
* Create an ownership scope. `fn` receives a disposer that tears down every
|
|
64
|
+
* effect/computed (and their onCleanups) created under the scope. Detached from
|
|
65
|
+
* any enclosing owner — you hold the disposer (Solid's `createRoot` contract).
|
|
66
|
+
*/
|
|
67
|
+
export declare function root<T>(fn: (dispose: () => void) => T): T;
|
|
68
|
+
/**
|
|
69
|
+
* Register a cleanup with the owner in scope. Inside an effect/computed it runs
|
|
70
|
+
* before each re-run and on dispose; inside a `root` it runs on root disposal.
|
|
71
|
+
*/
|
|
72
|
+
export declare function onCleanup(fn: () => void): void;
|
|
73
|
+
//# sourceMappingURL=kernel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kernel.d.ts","sourceRoot":"","sources":["../../src/reactive/kernel.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,MAAM,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC;AA0W5C,sFAAsF;AACtF,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC;AAClC,iFAAiF;AACjF,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC;AAEvC;;iFAEiF;AACjF,wBAAgB,MAAM,CAAC,CAAC,KAAK,SAAS,CAAC,QAAQ,CAAC,CAAC,GAAG,SAAS,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;AACvF,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AASrF,4FAA4F;AAC5F,wBAAgB,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,GAAE,EAAE,CAAC,CAAC,CAAa,GAAG,QAAQ,CAAC,CAAC,CAAC,CAS3E;AAED,qFAAqF;AACrF,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAKjD;AAED,qFAAqF;AACrF,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAO1C;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAQzC;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CASzD;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAW9C"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface ReactiveMap<K, V> {
|
|
2
|
+
/** Read a key's value, subscribing the caller to that key (or to structure if absent). */
|
|
3
|
+
get(key: K): V | undefined;
|
|
4
|
+
/** Insert or update a key. Updating an existing key wakes only that key's readers. */
|
|
5
|
+
set(key: K, value: V): void;
|
|
6
|
+
/** Remove a key. Wakes that key's readers (now absent) and structure readers. */
|
|
7
|
+
delete(key: K): boolean;
|
|
8
|
+
/** Membership test, tracking the key set. */
|
|
9
|
+
has(key: K): boolean;
|
|
10
|
+
/** Entry count, tracking the key set. */
|
|
11
|
+
size(): number;
|
|
12
|
+
/** Snapshot of keys, tracking the key set. */
|
|
13
|
+
keys(): K[];
|
|
14
|
+
}
|
|
15
|
+
export declare function reactiveMap<K, V>(eq?: (a: V, b: V) => boolean): ReactiveMap<K, V>;
|
|
16
|
+
//# sourceMappingURL=map.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface ReactiveMap<K, V> {
|
|
2
|
+
/** Read a key's value, subscribing the caller to that key (or to structure if absent). */
|
|
3
|
+
get(key: K): V | undefined;
|
|
4
|
+
/** Insert or update a key. Updating an existing key wakes only that key's readers. */
|
|
5
|
+
set(key: K, value: V): void;
|
|
6
|
+
/** Remove a key. Wakes that key's readers (now absent) and structure readers. */
|
|
7
|
+
delete(key: K): boolean;
|
|
8
|
+
/** Membership test, tracking the key set. */
|
|
9
|
+
has(key: K): boolean;
|
|
10
|
+
/** Entry count, tracking the key set. */
|
|
11
|
+
size(): number;
|
|
12
|
+
/** Snapshot of keys, tracking the key set. */
|
|
13
|
+
keys(): K[];
|
|
14
|
+
}
|
|
15
|
+
export declare function reactiveMap<K, V>(eq?: (a: V, b: V) => boolean): ReactiveMap<K, V>;
|
|
16
|
+
//# sourceMappingURL=map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/reactive/map.ts"],"names":[],"mappings":"AA2BA,MAAM,WAAW,WAAW,CAAC,CAAC,EAAE,CAAC;IAChC,0FAA0F;IAC1F,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IAC3B,sFAAsF;IACtF,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IAC5B,iFAAiF;IACjF,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC;IACxB,6CAA6C;IAC7C,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC;IACrB,yCAAyC;IACzC,IAAI,IAAI,MAAM,CAAC;IACf,8CAA8C;IAC9C,IAAI,IAAI,CAAC,EAAE,CAAC;CACZ;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,GAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAmB,GAAG,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAiE5F"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shallow (one-level) value equality — the recommended `eq` for object-valued
|
|
3
|
+
* projections. Mirrors zustand `useShallow` / MobX `comparer.shallow`: two objects
|
|
4
|
+
* are equal iff they have the same own keys with `Object.is`-equal values. Restores
|
|
5
|
+
* "equal write wakes nobody" for projections that build a fresh object each tick.
|
|
6
|
+
*
|
|
7
|
+
* Lives in the kernel entry (`/reactive`) — it has zero ECS dependency
|
|
8
|
+
* (POLISH_AUDIT M12); `/reactive-sync` re-exports it for compatibility.
|
|
9
|
+
*/
|
|
10
|
+
export declare function shallow(a: object, b: object): boolean;
|
|
11
|
+
//# sourceMappingURL=shallow.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shallow (one-level) value equality — the recommended `eq` for object-valued
|
|
3
|
+
* projections. Mirrors zustand `useShallow` / MobX `comparer.shallow`: two objects
|
|
4
|
+
* are equal iff they have the same own keys with `Object.is`-equal values. Restores
|
|
5
|
+
* "equal write wakes nobody" for projections that build a fresh object each tick.
|
|
6
|
+
*
|
|
7
|
+
* Lives in the kernel entry (`/reactive`) — it has zero ECS dependency
|
|
8
|
+
* (POLISH_AUDIT M12); `/reactive-sync` re-exports it for compatibility.
|
|
9
|
+
*/
|
|
10
|
+
export declare function shallow(a: object, b: object): boolean;
|
|
11
|
+
//# sourceMappingURL=shallow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shallow.d.ts","sourceRoot":"","sources":["../../src/reactive/shallow.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAWrD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Per-field setters: `set.field(value)`. */
|
|
2
|
+
export type StructSetters<T> = {
|
|
3
|
+
readonly [K in keyof T]: (v: T[K]) => void;
|
|
4
|
+
};
|
|
5
|
+
/** Optional per-field equality overrides. */
|
|
6
|
+
export type StructEq<T> = {
|
|
7
|
+
readonly [K in keyof T]?: (a: T[K], b: T[K]) => boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare function reactiveStruct<T extends object>(initial: T, eq?: StructEq<T>): readonly [proxy: Readonly<T>, set: StructSetters<T>];
|
|
10
|
+
//# sourceMappingURL=struct.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Per-field setters: `set.field(value)`. */
|
|
2
|
+
export type StructSetters<T> = {
|
|
3
|
+
readonly [K in keyof T]: (v: T[K]) => void;
|
|
4
|
+
};
|
|
5
|
+
/** Optional per-field equality overrides. */
|
|
6
|
+
export type StructEq<T> = {
|
|
7
|
+
readonly [K in keyof T]?: (a: T[K], b: T[K]) => boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare function reactiveStruct<T extends object>(initial: T, eq?: StructEq<T>): readonly [proxy: Readonly<T>, set: StructSetters<T>];
|
|
10
|
+
//# sourceMappingURL=struct.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"struct.d.ts","sourceRoot":"","sources":["../../src/reactive/struct.ts"],"names":[],"mappings":"AA6BA,6CAA6C;AAC7C,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI;IAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI;CAAE,CAAC;AAC9E,6CAA6C;AAC7C,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;IAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO;CAAE,CAAC;AAEtF,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAC9C,OAAO,EAAE,CAAC,EACV,EAAE,GAAE,QAAQ,CAAC,CAAC,CAAM,GAClB,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAyDtD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const p=require("./kernel-yWV3XnAb.cjs");function O(g=Object.is){const l=new Map,[t,h]=p.signal(0);let i=0;const a=(s,r)=>s!==void 0&&r!==void 0?g(s,r):s===r;return{get(s){const r=l.get(s);if(r!==void 0)return r[0]();t()},set(s,r){const o=l.get(s);o!==void 0?o[1](r):(l.set(s,p.signal(r,a)),h(++i))},delete(s){const r=l.get(s);return r===void 0?!1:(l.delete(s),p.batch(()=>{r[1](void 0),h(++i)}),!0)},has(s){return t(),l.has(s)},size(){return t(),l.size},keys(){return t(),[...l.keys()]}}}function k(g,l={}){const t={},h={},i=Object.keys(g),a=new Set(i);for(const r of i){const[o,b]=p.signal(g[r],l[r]);t[r]=o,h[r]=b}return[new Proxy({},{get:(r,o)=>a.has(o)?t[o]():Reflect.get(r,o),has:(r,o)=>a.has(o),ownKeys:()=>i,getOwnPropertyDescriptor:(r,o)=>a.has(o)?{get:()=>t[o](),enumerable:!0,configurable:!0}:void 0,set:(r,o)=>!1}),h]}const y=Symbol("reactiveArray.absent");function j(g=[],l=Object.is){const t=[],[h,i]=p.signal(0);let a=0;const s=(e,n)=>e!==y&&n!==y?l(e,n):e===n,r=e=>p.signal(e,s),o=e=>p.untrack(t[e][0]);for(const e of g)t.push(r(e));function b(e){p.batch(()=>{const n=t.length,f=e.length,v=f<n?f:n;for(let c=0;c<v;c++)t[c][1](e[c]);if(f>n){for(let c=n;c<f;c++)t.push(r(e[c]));i(++a)}else if(f<n){const c=t.splice(f);for(let d=0;d<c.length;d++)c[d][1](y);i(++a)}})}return{get(e){if(e>=0&&e<t.length){const n=t[e][0]();if(n!==y)return n}h()},length(){return h(),t.length},snapshot(){h();const e=new Array(t.length);for(let n=0;n<t.length;n++)e[n]=t[n][0]();return e},set(e,n){e>=0&&e<t.length&&t[e][1](n)},push(e){t.push(r(e)),i(++a)},pop(){const e=t.length;if(e===0)return;const n=o(e-1),[f]=t.splice(e-1);return p.batch(()=>{f[1](y),i(++a)}),n},splice(e,n,...f){const v=t.length,c=e<0?Math.max(v+e,0):Math.min(e,v),d=n===void 0?v-c:Math.max(0,Math.min(n,v-c)),w=[];for(let u=0;u<d;u++)w.push(o(c+u));const m=[];for(let u=0;u<c;u++)m.push(o(u));for(let u=0;u<f.length;u++)m.push(f[u]);for(let u=c+d;u<v;u++)m.push(o(u));return b(m),w},reconcile(e){b(e)}}}function S(g,l){if(Object.is(g,l))return!0;const t=g,h=l,i=Object.keys(t);if(i.length!==Object.keys(h).length)return!1;for(let a=0;a<i.length;a++){const s=i[a];if(!Object.prototype.hasOwnProperty.call(h,s)||!Object.is(t[s],h[s]))return!1}return!0}exports.reactiveArray=j;exports.reactiveMap=O;exports.reactiveStruct=k;exports.shallow=S;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { s as y, b as O, u as j } from "./kernel-DgyrLFjW.js";
|
|
2
|
+
function S(p = Object.is) {
|
|
3
|
+
const l = /* @__PURE__ */ new Map(), [e, f] = y(0);
|
|
4
|
+
let i = 0;
|
|
5
|
+
const a = (s, r) => s !== void 0 && r !== void 0 ? p(s, r) : s === r;
|
|
6
|
+
return {
|
|
7
|
+
get(s) {
|
|
8
|
+
const r = l.get(s);
|
|
9
|
+
if (r !== void 0) return r[0]();
|
|
10
|
+
e();
|
|
11
|
+
},
|
|
12
|
+
set(s, r) {
|
|
13
|
+
const o = l.get(s);
|
|
14
|
+
o !== void 0 ? o[1](r) : (l.set(s, y(r, a)), f(++i));
|
|
15
|
+
},
|
|
16
|
+
delete(s) {
|
|
17
|
+
const r = l.get(s);
|
|
18
|
+
return r === void 0 ? !1 : (l.delete(s), O(() => {
|
|
19
|
+
r[1](void 0), f(++i);
|
|
20
|
+
}), !0);
|
|
21
|
+
},
|
|
22
|
+
has(s) {
|
|
23
|
+
return e(), l.has(s);
|
|
24
|
+
},
|
|
25
|
+
size() {
|
|
26
|
+
return e(), l.size;
|
|
27
|
+
},
|
|
28
|
+
keys() {
|
|
29
|
+
return e(), [...l.keys()];
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function M(p, l = {}) {
|
|
34
|
+
const e = {}, f = {}, i = Object.keys(p), a = new Set(i);
|
|
35
|
+
for (const r of i) {
|
|
36
|
+
const [o, m] = y(
|
|
37
|
+
p[r],
|
|
38
|
+
l[r]
|
|
39
|
+
);
|
|
40
|
+
e[r] = o, f[r] = m;
|
|
41
|
+
}
|
|
42
|
+
return [new Proxy({}, {
|
|
43
|
+
// A field read subscribes; a NON-field key must not throw. `JSON.stringify`
|
|
44
|
+
// (`toJSON`), `await proxy` (`then`), `String(proxy)` (`Symbol.toPrimitive`)
|
|
45
|
+
// and `for..of` (`Symbol.iterator`) all probe keys that aren't fields — fall
|
|
46
|
+
// through to the (empty) target so they see the ordinary undefined/inherited
|
|
47
|
+
// value instead of calling `undefined()`. `fieldSet` (not `k in reads`) so
|
|
48
|
+
// inherited `toString`/`constructor` aren't mistaken for fields.
|
|
49
|
+
get: (r, o) => a.has(o) ? e[o]() : Reflect.get(r, o),
|
|
50
|
+
has: (r, o) => a.has(o),
|
|
51
|
+
// Enumerable without subscribing: enumeration calls `ownKeys` +
|
|
52
|
+
// `getOwnPropertyDescriptor`, never `get`, so `Object.keys(proxy)` returns
|
|
53
|
+
// the field set and tracks nothing. The descriptor is an ACCESSOR whose `get`
|
|
54
|
+
// reads the live signal, so `{...proxy}` / `Object.values(proxy)` /
|
|
55
|
+
// `Object.getOwnPropertyDescriptor(proxy, f).value` see the current value
|
|
56
|
+
// (a value-less descriptor would normalize to `value: undefined`). Non-field
|
|
57
|
+
// keys report no own descriptor. The target is the empty (extensible) object,
|
|
58
|
+
// so these configurable own keys satisfy the Proxy invariants.
|
|
59
|
+
ownKeys: () => i,
|
|
60
|
+
getOwnPropertyDescriptor: (r, o) => a.has(o) ? { get: () => e[o](), enumerable: !0, configurable: !0 } : void 0,
|
|
61
|
+
// Writes go through `set.field(v)` — the proxy is a READ surface, and its
|
|
62
|
+
// public type says so (`Readonly<T>`, POLISH_AUDIT #8). The trap backs the
|
|
63
|
+
// type for JS callers / policed casts: without it, a field assignment threw
|
|
64
|
+
// an opaque "Cannot redefine property" (the accessor descriptor above has no
|
|
65
|
+
// setter) and a TYPO'D field silently stuck on the hidden target as a
|
|
66
|
+
// non-reactive value.
|
|
67
|
+
set: (r, o) => !1
|
|
68
|
+
}), f];
|
|
69
|
+
}
|
|
70
|
+
const v = Symbol("reactiveArray.absent");
|
|
71
|
+
function x(p = [], l = Object.is) {
|
|
72
|
+
const e = [], [f, i] = y(0);
|
|
73
|
+
let a = 0;
|
|
74
|
+
const s = (t, n) => t !== v && n !== v ? l(t, n) : t === n, r = (t) => y(t, s), o = (t) => j(e[t][0]);
|
|
75
|
+
for (const t of p) e.push(r(t));
|
|
76
|
+
function m(t) {
|
|
77
|
+
O(() => {
|
|
78
|
+
const n = e.length, h = t.length, g = h < n ? h : n;
|
|
79
|
+
for (let c = 0; c < g; c++) e[c][1](t[c]);
|
|
80
|
+
if (h > n) {
|
|
81
|
+
for (let c = n; c < h; c++) e.push(r(t[c]));
|
|
82
|
+
i(++a);
|
|
83
|
+
} else if (h < n) {
|
|
84
|
+
const c = e.splice(h);
|
|
85
|
+
for (let d = 0; d < c.length; d++) c[d][1](v);
|
|
86
|
+
i(++a);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
get(t) {
|
|
92
|
+
if (t >= 0 && t < e.length) {
|
|
93
|
+
const n = e[t][0]();
|
|
94
|
+
if (n !== v) return n;
|
|
95
|
+
}
|
|
96
|
+
f();
|
|
97
|
+
},
|
|
98
|
+
length() {
|
|
99
|
+
return f(), e.length;
|
|
100
|
+
},
|
|
101
|
+
snapshot() {
|
|
102
|
+
f();
|
|
103
|
+
const t = new Array(e.length);
|
|
104
|
+
for (let n = 0; n < e.length; n++) t[n] = e[n][0]();
|
|
105
|
+
return t;
|
|
106
|
+
},
|
|
107
|
+
set(t, n) {
|
|
108
|
+
t >= 0 && t < e.length && e[t][1](n);
|
|
109
|
+
},
|
|
110
|
+
push(t) {
|
|
111
|
+
e.push(r(t)), i(++a);
|
|
112
|
+
},
|
|
113
|
+
pop() {
|
|
114
|
+
const t = e.length;
|
|
115
|
+
if (t === 0) return;
|
|
116
|
+
const n = o(t - 1), [h] = e.splice(t - 1);
|
|
117
|
+
return O(() => {
|
|
118
|
+
h[1](v), i(++a);
|
|
119
|
+
}), n;
|
|
120
|
+
},
|
|
121
|
+
splice(t, n, ...h) {
|
|
122
|
+
const g = e.length, c = t < 0 ? Math.max(g + t, 0) : Math.min(t, g), d = n === void 0 ? g - c : Math.max(0, Math.min(n, g - c)), w = [];
|
|
123
|
+
for (let u = 0; u < d; u++) w.push(o(c + u));
|
|
124
|
+
const b = [];
|
|
125
|
+
for (let u = 0; u < c; u++) b.push(o(u));
|
|
126
|
+
for (let u = 0; u < h.length; u++) b.push(h[u]);
|
|
127
|
+
for (let u = c + d; u < g; u++) b.push(o(u));
|
|
128
|
+
return m(b), w;
|
|
129
|
+
},
|
|
130
|
+
reconcile(t) {
|
|
131
|
+
m(t);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function A(p, l) {
|
|
136
|
+
if (Object.is(p, l)) return !0;
|
|
137
|
+
const e = p, f = l, i = Object.keys(e);
|
|
138
|
+
if (i.length !== Object.keys(f).length) return !1;
|
|
139
|
+
for (let a = 0; a < i.length; a++) {
|
|
140
|
+
const s = i[a];
|
|
141
|
+
if (!Object.prototype.hasOwnProperty.call(f, s) || !Object.is(e[s], f[s])) return !1;
|
|
142
|
+
}
|
|
143
|
+
return !0;
|
|
144
|
+
}
|
|
145
|
+
export {
|
|
146
|
+
M as a,
|
|
147
|
+
x as b,
|
|
148
|
+
S as r,
|
|
149
|
+
A as s
|
|
150
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
class u extends Error {
|
|
2
|
+
constructor(t, e, r, n) {
|
|
3
|
+
super(t, n), this.requestedBytes = e, this.capBytes = r, this.name = "StoreCapExceededError";
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
class c extends Error {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(
|
|
9
|
+
"SharedArrayBuffer is not available in this runtime. The chosen world backing is SAB-based and cannot start without it. In browsers this requires cross-origin isolation: serve the page with `Cross-Origin-Opener-Policy: same-origin` and `Cross-Origin-Embedder-Policy: require-corp` (or `credentialless`). Alternatively choose the pure-TS heap profile (`memory: { heap: {} }`), which is backed by a plain ArrayBuffer and needs no SAB / no COOP+COEP. In Bun/Node SAB is available unconditionally — if you see this there, the runtime is older than expected or the global was shadowed."
|
|
10
|
+
), this.name = "SabUnavailableError";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const d = (a) => {
|
|
14
|
+
if (typeof SharedArrayBuffer > "u") throw new c();
|
|
15
|
+
return new SharedArrayBuffer(a);
|
|
16
|
+
}, h = 64 * 1024;
|
|
17
|
+
function f(a, t, e) {
|
|
18
|
+
if (e <= 0 || !Number.isInteger(e))
|
|
19
|
+
throw new Error(`${a}: maxBytes must be a positive integer (got ${e})`);
|
|
20
|
+
let r = null;
|
|
21
|
+
const n = (o) => {
|
|
22
|
+
if (o > e)
|
|
23
|
+
throw new u(
|
|
24
|
+
`${a}: requested ${o} bytes exceeds the by-design maxBytes cap of ${e}. This is a hard ceiling with no grow-beyond-cap fallback (#380); a real workload stays ~16 MiB. Reaching it signals runaway entity/column growth upstream — diagnose that rather than raising the cap blindly.`,
|
|
25
|
+
o,
|
|
26
|
+
e
|
|
27
|
+
);
|
|
28
|
+
return r === null ? (r = t.create(o, e), r) : (o > r.byteLength && t.growTo(r, o), r);
|
|
29
|
+
};
|
|
30
|
+
return Object.defineProperty(n, "isInPlace", { value: !0, enumerable: !0 }), n;
|
|
31
|
+
}
|
|
32
|
+
function w(a = 256 * 1024 * 1024) {
|
|
33
|
+
if (typeof SharedArrayBuffer > "u") throw new c();
|
|
34
|
+
return f(
|
|
35
|
+
"growable_sab_allocator",
|
|
36
|
+
{
|
|
37
|
+
create: (t, e) => {
|
|
38
|
+
const r = SharedArrayBuffer;
|
|
39
|
+
return new r(t, { maxByteLength: e });
|
|
40
|
+
},
|
|
41
|
+
// boundary: SharedArrayBuffer.grow is in the spec but not in all
|
|
42
|
+
// lib types; widen here so the rest of the layer doesn't need to.
|
|
43
|
+
growTo: (t, e) => t.grow(e)
|
|
44
|
+
},
|
|
45
|
+
a
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
function b(a = 256 * 1024 * 1024) {
|
|
49
|
+
return f(
|
|
50
|
+
"heap_arraybuffer_allocator",
|
|
51
|
+
{
|
|
52
|
+
create: (t, e) => {
|
|
53
|
+
const r = ArrayBuffer;
|
|
54
|
+
return new r(t, { maxByteLength: e });
|
|
55
|
+
},
|
|
56
|
+
// boundary: `ArrayBuffer.prototype.resize` is ES2024, not in the ES2022
|
|
57
|
+
// lib types; widen here. Resize keeps the same buffer object and
|
|
58
|
+
// preserves existing views (the in-place contract).
|
|
59
|
+
growTo: (t, e) => t.resize(e)
|
|
60
|
+
},
|
|
61
|
+
a
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
function g(a) {
|
|
65
|
+
if (!(a.buffer instanceof SharedArrayBuffer))
|
|
66
|
+
throw new Error(
|
|
67
|
+
"wasm_memory_allocator: WebAssembly.Memory must be constructed with `shared: true` so its buffer is a SharedArrayBuffer"
|
|
68
|
+
);
|
|
69
|
+
const t = () => a.buffer, e = (r) => {
|
|
70
|
+
const n = a.buffer.byteLength;
|
|
71
|
+
if (r <= n)
|
|
72
|
+
return t();
|
|
73
|
+
const o = Math.ceil((r - n) / h), s = (i) => (
|
|
74
|
+
// The JS API doesn't expose the Memory's `maximum`, so the cap is
|
|
75
|
+
// reported as unknowable (`null`) — the caller declared it at
|
|
76
|
+
// `new WebAssembly.Memory({ maximum })` time.
|
|
77
|
+
new u(
|
|
78
|
+
`wasm_memory_allocator: memory.grow(${o}) failed (current=${n} bytes, requested=${r} bytes, maximum may be reached)`,
|
|
79
|
+
r,
|
|
80
|
+
null,
|
|
81
|
+
{ cause: i }
|
|
82
|
+
)
|
|
83
|
+
);
|
|
84
|
+
let l;
|
|
85
|
+
try {
|
|
86
|
+
l = a.grow(o);
|
|
87
|
+
} catch (i) {
|
|
88
|
+
throw s(i);
|
|
89
|
+
}
|
|
90
|
+
if (l === -1)
|
|
91
|
+
throw s();
|
|
92
|
+
return t();
|
|
93
|
+
};
|
|
94
|
+
return Object.defineProperty(e, "isInPlace", { value: !0, enumerable: !0 }), e;
|
|
95
|
+
}
|
|
96
|
+
export {
|
|
97
|
+
d as D,
|
|
98
|
+
u as S,
|
|
99
|
+
c as a,
|
|
100
|
+
w as g,
|
|
101
|
+
b as h,
|
|
102
|
+
g as w
|
|
103
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";class s extends Error{constructor(o,r,e,n){super(o,n),this.requestedBytes=r,this.capBytes=e,this.name="StoreCapExceededError"}}class l extends Error{constructor(){super("SharedArrayBuffer is not available in this runtime. The chosen world backing is SAB-based and cannot start without it. In browsers this requires cross-origin isolation: serve the page with `Cross-Origin-Opener-Policy: same-origin` and `Cross-Origin-Embedder-Policy: require-corp` (or `credentialless`). Alternatively choose the pure-TS heap profile (`memory: { heap: {} }`), which is backed by a plain ArrayBuffer and needs no SAB / no COOP+COEP. In Bun/Node SAB is available unconditionally — if you see this there, the runtime is older than expected or the global was shadowed."),this.name="SabUnavailableError"}}const h=a=>{if(typeof SharedArrayBuffer>"u")throw new l;return new SharedArrayBuffer(a)},d=64*1024;function f(a,o,r){if(r<=0||!Number.isInteger(r))throw new Error(`${a}: maxBytes must be a positive integer (got ${r})`);let e=null;const n=t=>{if(t>r)throw new s(`${a}: requested ${t} bytes exceeds the by-design maxBytes cap of ${r}. This is a hard ceiling with no grow-beyond-cap fallback (#380); a real workload stays ~16 MiB. Reaching it signals runaway entity/column growth upstream — diagnose that rather than raising the cap blindly.`,t,r);return e===null?(e=o.create(t,r),e):(t>e.byteLength&&o.growTo(e,t),e)};return Object.defineProperty(n,"isInPlace",{value:!0,enumerable:!0}),n}function b(a=256*1024*1024){if(typeof SharedArrayBuffer>"u")throw new l;return f("growable_sab_allocator",{create:(o,r)=>{const e=SharedArrayBuffer;return new e(o,{maxByteLength:r})},growTo:(o,r)=>o.grow(r)},a)}function w(a=256*1024*1024){return f("heap_arraybuffer_allocator",{create:(o,r)=>{const e=ArrayBuffer;return new e(o,{maxByteLength:r})},growTo:(o,r)=>o.resize(r)},a)}function A(a){if(!(a.buffer instanceof SharedArrayBuffer))throw new Error("wasm_memory_allocator: WebAssembly.Memory must be constructed with `shared: true` so its buffer is a SharedArrayBuffer");const o=()=>a.buffer,r=e=>{const n=a.buffer.byteLength;if(e<=n)return o();const t=Math.ceil((e-n)/d),c=i=>new s(`wasm_memory_allocator: memory.grow(${t}) failed (current=${n} bytes, requested=${e} bytes, maximum may be reached)`,e,null,{cause:i});let u;try{u=a.grow(t)}catch(i){throw c(i)}if(u===-1)throw c();return o()};return Object.defineProperty(r,"isInPlace",{value:!0,enumerable:!0}),r}exports.DEFAULT_SAB_ALLOCATOR=h;exports.SabUnavailableError=l;exports.StoreCapExceededError=s;exports.growableSabAllocator=b;exports.heapArraybufferAllocator=w;exports.wasmMemoryAllocator=A;
|
package/dist/shared.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./shared-BymrGTyR.cjs");exports.DEFAULT_SAB_ALLOCATOR=a.DEFAULT_SAB_ALLOCATOR;exports.SabUnavailableError=a.SabUnavailableError;exports.growableSabAllocator=a.growableSabAllocator;exports.wasmMemoryAllocator=a.wasmMemoryAllocator;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@oasys/oecs/shared` — the opt-in SharedArrayBuffer / WASM profile.
|
|
3
|
+
*
|
|
4
|
+
* The default `@oasys/oecs` profile runs the column store over a plain
|
|
5
|
+
* resizable `ArrayBuffer` (no cross-origin isolation). This entry surfaces the
|
|
6
|
+
* `SharedArrayBuffer`-backed allocators for worlds that opt into worker offload
|
|
7
|
+
* or a WASM compute backend — construct with `new ECS({ memory: { shared: {} } })`,
|
|
8
|
+
* or pass one of these allocators through `memory: { allocator }`.
|
|
9
|
+
*
|
|
10
|
+
* **Requires cross-origin isolation (COOP/COEP) in browsers** — that's the
|
|
11
|
+
* whole reason it's a separate, opt-in profile.
|
|
12
|
+
*
|
|
13
|
+
* The WASM compute backend itself is NOT bundled here: oecs ships the
|
|
14
|
+
* `ComputeBackend` *seam* (`@oasys/oecs` → `attachBackend`) plus the
|
|
15
|
+
* cross-thread ring transport (`HostCommandDispatcher`). The worker entrypoint
|
|
16
|
+
* and the compiled WASM module are the consumer's to provide.
|
|
17
|
+
*
|
|
18
|
+
* @module
|
|
19
|
+
*/
|
|
20
|
+
export { growableSabAllocator, wasmMemoryAllocator, DEFAULT_SAB_ALLOCATOR, SabUnavailableError } from './core/store/index.cjs';
|
|
21
|
+
export type { SharedMemoryArm } from './core/ecs/ecs_memory.cjs';
|
|
22
|
+
//# sourceMappingURL=shared.d.ts.map
|
package/dist/shared.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@oasys/oecs/shared` — the opt-in SharedArrayBuffer / WASM profile.
|
|
3
|
+
*
|
|
4
|
+
* The default `@oasys/oecs` profile runs the column store over a plain
|
|
5
|
+
* resizable `ArrayBuffer` (no cross-origin isolation). This entry surfaces the
|
|
6
|
+
* `SharedArrayBuffer`-backed allocators for worlds that opt into worker offload
|
|
7
|
+
* or a WASM compute backend — construct with `new ECS({ memory: { shared: {} } })`,
|
|
8
|
+
* or pass one of these allocators through `memory: { allocator }`.
|
|
9
|
+
*
|
|
10
|
+
* **Requires cross-origin isolation (COOP/COEP) in browsers** — that's the
|
|
11
|
+
* whole reason it's a separate, opt-in profile.
|
|
12
|
+
*
|
|
13
|
+
* The WASM compute backend itself is NOT bundled here: oecs ships the
|
|
14
|
+
* `ComputeBackend` *seam* (`@oasys/oecs` → `attachBackend`) plus the
|
|
15
|
+
* cross-thread ring transport (`HostCommandDispatcher`). The worker entrypoint
|
|
16
|
+
* and the compiled WASM module are the consumer's to provide.
|
|
17
|
+
*
|
|
18
|
+
* @module
|
|
19
|
+
*/
|
|
20
|
+
export { growableSabAllocator, wasmMemoryAllocator, DEFAULT_SAB_ALLOCATOR, SabUnavailableError } from './core/store/index.js';
|
|
21
|
+
export type { SharedMemoryArm } from './core/ecs/ecs_memory.js';
|
|
22
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EACN,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/shared.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";class d{_denseKeys=[];_denseVals=[];_sparse=[];get size(){return this._denseKeys.length}get keys(){return this._denseKeys}has(s){return this._denseKeys[this._sparse[s]]===s}get(s){return this.has(s)?this._denseVals[this._sparse[s]]:void 0}set(s,t){if(this.has(s)){this._denseVals[this._sparse[s]]=t;return}this._sparse[s]=this._denseKeys.length,this._denseKeys.push(s),this._denseVals.push(t)}delete(s){if(!this.has(s))return!1;const t=this._sparse[s],i=this._denseKeys[this._denseKeys.length-1];return this._denseKeys[t]=i,this._denseVals[t]=this._denseVals[this._denseVals.length-1],this._sparse[i]=t,this._denseKeys.pop(),this._denseVals.pop(),!0}clear(){this._denseKeys.length=0,this._denseVals.length=0,this._sparse.length=0}forEach(s){for(let t=0;t<this._denseKeys.length;t++)s(this._denseKeys[t],this._denseVals[t])}[Symbol.iterator](){let s=0;const t=this._denseKeys,i=this._denseVals;return{next(){return s<t.length?{value:[t[s],i[s++]],done:!1}:{value:void 0,done:!0}}}}}class g{_compare;_data=[];constructor(s){this._compare=s}get size(){return this._data.length}peek(){return this._data[0]}push(s){this._data.push(s),this._siftUp(this._data.length-1)}pop(){const s=this._data;if(s.length===0)return;const i=s[0],h=s.pop();return s.length>0&&(s[0]=h,this._siftDown(0)),i}clear(){this._data.length=0}_siftUp(s){const t=this._data,i=this._compare,h=t[s];for(;s>0;){const n=s-1>>1;if(i(h,t[n])>=0)break;t[s]=t[n],s=n}t[s]=h}_siftDown(s){const t=this._data,i=this._compare,h=t.length,n=h>>1,c=t[s];for(;s<n;){let a=(s<<1)+1;const e=a+1;if(e<h&&i(t[e],t[a])<0&&(a=e),i(t[a],c)>=0)break;t[s]=t[a],s=a}t[s]=c}}function u(l,s,t,i){const h=i??(e=>String(e)),n=new Map;for(let e=0;e<l.length;e++)n.set(l[e],0);for(const[,e]of s)for(let r=0;r<e.length;r++){const o=e[r];n.has(o)&&n.set(o,n.get(o)+1)}const c=new g(t);for(let e=0;e<l.length;e++)n.get(l[e])===0&&c.push(l[e]);const a=[];for(;c.size>0;){const e=c.pop();a.push(e);const r=s.get(e);if(r!==void 0)for(let o=0;o<r.length;o++){const _=r[o];if(!n.has(_))continue;const p=n.get(_)-1;n.set(_,p),p===0&&c.push(_)}}if(a.length!==l.length){const e=[];for(const[r,o]of n)o>0&&e.push(h(r));throw new TypeError(`Cycle detected in topological sort. Nodes still pending: ${e.join(", ")}`)}return a}exports.BinaryHeap=g;exports.SparseMap=d;exports.topologicalSort=u;
|