@mmstack/primitives 22.10.2 → 22.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1405,6 +1405,7 @@ declare function keyArray<T, U, K>(source: Signal<T[]> | (() => T[]), mapFn: (v:
|
|
|
1405
1405
|
duplicateKeys?: DuplicateKeyPolicy;
|
|
1406
1406
|
}): Signal<U[]>;
|
|
1407
1407
|
|
|
1408
|
+
declare function pooledKeys<T extends Record<string, any>>(src: Signal<T>): Signal<Set<keyof T>>;
|
|
1408
1409
|
type MappedObject<T extends object, U> = {
|
|
1409
1410
|
[K in keyof T]: U;
|
|
1410
1411
|
};
|
|
@@ -3815,6 +3816,75 @@ declare function removeElement<T>(container: ContainerNode<T>, key: string): voi
|
|
|
3815
3816
|
* reclaim precision after many same-gap inserts. Existing reading order is preserved.
|
|
3816
3817
|
*/
|
|
3817
3818
|
declare function rebalanceContainer<T extends object>(sync: Pick<OpSync, 'override'>, container: ContainerNode<T>): void;
|
|
3819
|
+
/**
|
|
3820
|
+
* An element of a container in the WRAPPED representation: position beside the payload rather than
|
|
3821
|
+
* inside it, so the payload stays a closed record a schema can validate without knowing about
|
|
3822
|
+
* `~pos`. A move writes `[container, key, '~pos']` and a field edit writes
|
|
3823
|
+
* `[container, key, 'value', field]` — still disjoint one-field paths.
|
|
3824
|
+
*/
|
|
3825
|
+
type ContainerEntry<T> = {
|
|
3826
|
+
readonly [POS_SEGMENT]: string;
|
|
3827
|
+
readonly value: T;
|
|
3828
|
+
};
|
|
3829
|
+
/** `key` derives an element's key from the value, for payloads carrying their own identity field. */
|
|
3830
|
+
type KeyedContainerConfig<T> = {
|
|
3831
|
+
readonly key?: (value: T) => string;
|
|
3832
|
+
};
|
|
3833
|
+
/** The helpers of one container flavour, with keys supplied by the caller. */
|
|
3834
|
+
type KeyedContainer<T extends object, E extends object = T> = {
|
|
3835
|
+
entries(container: Record<string, E>): OrderedEntry<T>[];
|
|
3836
|
+
insert(container: ContainerNode<E>, key: string, value: T, index?: number): string;
|
|
3837
|
+
move(container: ContainerNode<E>, key: string, index: number): string | undefined;
|
|
3838
|
+
remove(container: ContainerNode<E>, key: string): void;
|
|
3839
|
+
rebalance(sync: Pick<OpSync, 'override'>, container: ContainerNode<E>): void;
|
|
3840
|
+
};
|
|
3841
|
+
/** The same helpers where a configured `key` extractor supplies the key, so `insert` takes none. */
|
|
3842
|
+
type SelfKeyedContainer<T extends object, E extends object = T> = Omit<KeyedContainer<T, E>, 'insert'> & {
|
|
3843
|
+
insert(container: ContainerNode<E>, value: T, index?: number): string;
|
|
3844
|
+
};
|
|
3845
|
+
/**
|
|
3846
|
+
* Binds one container flavour to the whole set of helpers, so every read and write of a container
|
|
3847
|
+
* agrees on how its elements are shaped. Pass the container node itself per call: one flavour
|
|
3848
|
+
* serves every container of a type. Positions live INSIDE the element; for a payload that must
|
|
3849
|
+
* stay a closed record, use {@link wrappedContainer} instead.
|
|
3850
|
+
*
|
|
3851
|
+
* ```typescript
|
|
3852
|
+
* const slots = keyedContainer({ key: (n: Node) => n.id });
|
|
3853
|
+
* slots.insert(node, child, 2); // one set at [container, id]
|
|
3854
|
+
* slots.move(node, 'child-1', 0); // one set at [container, 'child-1', '~pos']
|
|
3855
|
+
* slots.entries(node()); // reading order
|
|
3856
|
+
* ```
|
|
3857
|
+
*
|
|
3858
|
+
* With no extractor, `insert` takes the key: `keyedContainer<Node>()`. A duplicate key OVERWRITES,
|
|
3859
|
+
* taking a fresh position at the requested index. An element's identity field is immutable while it
|
|
3860
|
+
* is resident — re-keying is a remove plus an insert, never an edit.
|
|
3861
|
+
*/
|
|
3862
|
+
declare function keyedContainer<T extends object>(config: {
|
|
3863
|
+
key: (value: T) => string;
|
|
3864
|
+
}): SelfKeyedContainer<T>;
|
|
3865
|
+
declare function keyedContainer<T extends object>(config?: {
|
|
3866
|
+
key?: never;
|
|
3867
|
+
}): KeyedContainer<T>;
|
|
3868
|
+
/**
|
|
3869
|
+
* {@link keyedContainer} storing every element as a {@link ContainerEntry}: the position sits
|
|
3870
|
+
* beside the payload rather than inside it, so a schema that closes the payload record still
|
|
3871
|
+
* validates. `entries` reads back payloads, never wrappers.
|
|
3872
|
+
*
|
|
3873
|
+
* ```typescript
|
|
3874
|
+
* const slots = wrappedContainer({ key: (n: Node) => n.id });
|
|
3875
|
+
* slots.insert(node, child, 2); // one set at [container, id] carrying { '~pos', value }
|
|
3876
|
+
* ```
|
|
3877
|
+
*
|
|
3878
|
+
* A container's representation is fixed when it is created and is never carried on the wire, so
|
|
3879
|
+
* every peer of a synced container must agree on it — converting one after the fact is a data
|
|
3880
|
+
* migration, not a flag.
|
|
3881
|
+
*/
|
|
3882
|
+
declare function wrappedContainer<T extends object>(config: {
|
|
3883
|
+
key: (value: T) => string;
|
|
3884
|
+
}): SelfKeyedContainer<T, ContainerEntry<T>>;
|
|
3885
|
+
declare function wrappedContainer<T extends object>(config?: {
|
|
3886
|
+
key?: never;
|
|
3887
|
+
}): KeyedContainer<T, ContainerEntry<T>>;
|
|
3818
3888
|
|
|
3819
3889
|
type StoreHistory = {
|
|
3820
3890
|
readonly canUndo: Signal<boolean>;
|
|
@@ -4617,5 +4687,5 @@ type CreateHistoryOptions<T> = Omit<CreateSignalOptions<T[]>, 'equal'> & {
|
|
|
4617
4687
|
*/
|
|
4618
4688
|
declare function withHistory<T>(sourceOrValue: WritableSignal<T> | T, opt?: CreateHistoryOptions<T>): SignalWithHistory<T>;
|
|
4619
4689
|
|
|
4620
|
-
export { CONCURRENCY_INSTRUMENTATION, MmActivity, MmTransition, MmViewTransitionName, OP_PROTO_VERSION, PAUSABLE_OPTIONS, PERSISTED_STORE_OPTIONS, POS_SEGMENT, SuspenseBoundary, SuspenseBoundaryBase, UnscopedSuspenseBoundary, activeTransaction, applyOps, batteryStatus, bridgeScopeToPendingTasks, chunked, clipboard, combineWith, compareHlc, compareSiblings, compareTotal, createAttributedPending, createConvergingApply, createForwardingScope, createHlcClock, createStoreContext, createTransaction, createTransitionScope, debounce, debounced, defaultFold, deferredValue, derived, diffOps, distinct, elementSize, elementVisibility, extendStore, filter, filterWith, focusWithin, forkStore, geolocation, getTransitionScope, holdUntilReady, idle, indexArray, injectPaused, injectRegisterResource, injectStartTransaction, injectStartTransition, injectTransitionScope, insertElement, invertBatch, isConflicted, isDerivation, isLeaf, isMutable, isOpaque, isStore, isStored, keepPrevious, keyArray, keyedArray, latest, lww, map, mapArray, mapObject, mediaQuery, merge3, mergeThree, mousePosition, moveElement, mutable, mutableStore, nestedEffect, networkStatus, opLog, opSync, opaque, orderedEntries, orientation, pageVisibility, pairwise, pausableComputed, pausableEffect, pausableSignal, perfCustomTracks, persist, persistedStore, pipeable, piped, pointerDrag, policyStrategy, pooled, pooledArray, pooledMap, pooledSet, posBetween, prefersDarkMode, prefersReducedMotion, preserve, projection, provideConcurrencyInstrumentation, provideForwardingTransitionScope, providePausableOptions, providePaused, providePersistedStoreOptions, provideTransitionScope, rebalanceContainer, rebaseOps, reconcile, registerResource, removeElement, resolvePause, scan, scrollPosition, select, sensor, sensors, signalFromEvent, startWith, store, storeHistory, stored, syncedFork, tabSync, tap, throttle, throttled, toFakeDerivation, toFakeSignalDerivation, toStore, toWritable, traced, until, use, validateEnvelope, windowSize, withHistory };
|
|
4621
|
-
export type { AsyncStore, BatteryStatus, ClipboardSignal, Computation, ConcurrencyInstrumentation, Conflicted, ContainerNode, ConvergingApply, CreateChunkedOptions, CreateDebouncedOptions, CreateHistoryOptions, CreateLatestOptions, CreateOpLogOptions, CreatePooledOptions, CreateProvidedPooledOptions, CreateStoredOptions, CreateThrottledOptions, CreateTransitionScopeOptions, DebouncedSignal, DeferStrategy, DeferredSignal, DeferredValueOptions, DerivedSignal, Dot, DotFrontier, DuplicateKeyPolicy, ElementSize, ElementSizeOptions, ElementSizeSignal, ElementVisibilityOptions, ElementVisibilitySignal, ExtendStoreOptions, FoldFn, FoldPolicyEntry, FoldResult, Fork, ForkStoreOptions, ForkStrategy, ForwardingTransitionScope, Frame, GeolocationOptions, GeolocationSignal, Hlc, HlcClock, IdleOptions, IdleSignal, LatestSignal, MergeContext, MergeFn, MergePolicyEntry, MmTransitionContext, MousePositionOptions, MousePositionSignal, MutableSignal, MutableSignalStore, NetworkStatusSignal, OpBatch, OpEnvelope, OpLog, OpLogDriver, OpSync, OpSyncCheckpoint, OpSyncOptions, Opaque, OrderedEntry, PausableOptions, PauseOption, PersistHandle, PersistOptions, PersistedStore, PersistedStoreDefaults, PersistedStoreOptions, PipeableSignal, PointerDragOptions, PointerDragSignal, PointerDragState, PointerModifiers, PointerPoint, ProjectionOptions, RebaseResult, ReconcileFn, ReconcileKey, RegisterCheckpoint, RegisterOptions, ResourceLike, ScreenOrientation, ScreenOrientationState, ScrollPosition, ScrollPositionOptions, ScrollPositionSignal, SensorRunOptions, SignalFromEventOptions, SignalStore, SignalWithHistory, StoreHistory, StoreHistoryOptions, StoreOp, StoreOptions, StoreTabSyncOptions, StoredSignal, SuspendType, SyncOp, SyncSibling, SyncSignalOptions, SyncedFork, TabSyncBus, ThrottledSignal, Traced, Transaction, TransactionRef, TransitionRef, TransitionScope, UntilOptions, UseSource, Vivify, WindowSize, WindowSizeOptions, WindowSizeSignal, WithVivify, WritableSignalStore, toStoreOptions };
|
|
4690
|
+
export { CONCURRENCY_INSTRUMENTATION, MmActivity, MmTransition, MmViewTransitionName, OP_PROTO_VERSION, PAUSABLE_OPTIONS, PERSISTED_STORE_OPTIONS, POS_SEGMENT, SuspenseBoundary, SuspenseBoundaryBase, UnscopedSuspenseBoundary, activeTransaction, applyOps, batteryStatus, bridgeScopeToPendingTasks, chunked, clipboard, combineWith, compareHlc, compareSiblings, compareTotal, createAttributedPending, createConvergingApply, createForwardingScope, createHlcClock, createStoreContext, createTransaction, createTransitionScope, debounce, debounced, defaultFold, deferredValue, derived, diffOps, distinct, elementSize, elementVisibility, extendStore, filter, filterWith, focusWithin, forkStore, geolocation, getTransitionScope, holdUntilReady, idle, indexArray, injectPaused, injectRegisterResource, injectStartTransaction, injectStartTransition, injectTransitionScope, insertElement, invertBatch, isConflicted, isDerivation, isLeaf, isMutable, isOpaque, isStore, isStored, keepPrevious, keyArray, keyedArray, keyedContainer, latest, lww, map, mapArray, mapObject, mediaQuery, merge3, mergeThree, mousePosition, moveElement, mutable, mutableStore, nestedEffect, networkStatus, opLog, opSync, opaque, orderedEntries, orientation, pageVisibility, pairwise, pausableComputed, pausableEffect, pausableSignal, perfCustomTracks, persist, persistedStore, pipeable, piped, pointerDrag, policyStrategy, pooled, pooledArray, pooledKeys, pooledMap, pooledSet, posBetween, prefersDarkMode, prefersReducedMotion, preserve, projection, provideConcurrencyInstrumentation, provideForwardingTransitionScope, providePausableOptions, providePaused, providePersistedStoreOptions, provideTransitionScope, rebalanceContainer, rebaseOps, reconcile, registerResource, removeElement, resolvePause, scan, scrollPosition, select, sensor, sensors, signalFromEvent, startWith, store, storeHistory, stored, syncedFork, tabSync, tap, throttle, throttled, toFakeDerivation, toFakeSignalDerivation, toStore, toWritable, traced, until, use, validateEnvelope, windowSize, withHistory, wrappedContainer };
|
|
4691
|
+
export type { AsyncStore, BatteryStatus, ClipboardSignal, Computation, ConcurrencyInstrumentation, Conflicted, ContainerEntry, ContainerNode, ConvergingApply, CreateChunkedOptions, CreateDebouncedOptions, CreateHistoryOptions, CreateLatestOptions, CreateOpLogOptions, CreatePooledOptions, CreateProvidedPooledOptions, CreateStoredOptions, CreateThrottledOptions, CreateTransitionScopeOptions, DebouncedSignal, DeferStrategy, DeferredSignal, DeferredValueOptions, DerivedSignal, Dot, DotFrontier, DuplicateKeyPolicy, ElementSize, ElementSizeOptions, ElementSizeSignal, ElementVisibilityOptions, ElementVisibilitySignal, ExtendStoreOptions, FoldFn, FoldPolicyEntry, FoldResult, Fork, ForkStoreOptions, ForkStrategy, ForwardingTransitionScope, Frame, GeolocationOptions, GeolocationSignal, Hlc, HlcClock, IdleOptions, IdleSignal, KeyedContainer, KeyedContainerConfig, LatestSignal, MergeContext, MergeFn, MergePolicyEntry, MmTransitionContext, MousePositionOptions, MousePositionSignal, MutableSignal, MutableSignalStore, NetworkStatusSignal, OpBatch, OpEnvelope, OpLog, OpLogDriver, OpSync, OpSyncCheckpoint, OpSyncOptions, Opaque, OrderedEntry, PausableOptions, PauseOption, PersistHandle, PersistOptions, PersistedStore, PersistedStoreDefaults, PersistedStoreOptions, PipeableSignal, PointerDragOptions, PointerDragSignal, PointerDragState, PointerModifiers, PointerPoint, ProjectionOptions, RebaseResult, ReconcileFn, ReconcileKey, RegisterCheckpoint, RegisterOptions, ResourceLike, ScreenOrientation, ScreenOrientationState, ScrollPosition, ScrollPositionOptions, ScrollPositionSignal, SelfKeyedContainer, SensorRunOptions, SignalFromEventOptions, SignalStore, SignalWithHistory, StoreHistory, StoreHistoryOptions, StoreOp, StoreOptions, StoreTabSyncOptions, StoredSignal, SuspendType, SyncOp, SyncSibling, SyncSignalOptions, SyncedFork, TabSyncBus, ThrottledSignal, Traced, Transaction, TransactionRef, TransitionRef, TransitionScope, UntilOptions, UseSource, Vivify, WindowSize, WindowSizeOptions, WindowSizeSignal, WithVivify, WritableSignalStore, toStoreOptions };
|