@mmstack/primitives 21.10.3 → 21.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
|
@@ -3809,6 +3809,75 @@ declare function removeElement<T>(container: ContainerNode<T>, key: string): voi
|
|
|
3809
3809
|
* reclaim precision after many same-gap inserts. Existing reading order is preserved.
|
|
3810
3810
|
*/
|
|
3811
3811
|
declare function rebalanceContainer<T extends object>(sync: Pick<OpSync, 'override'>, container: ContainerNode<T>): void;
|
|
3812
|
+
/**
|
|
3813
|
+
* An element of a container in the WRAPPED representation: position beside the payload rather than
|
|
3814
|
+
* inside it, so the payload stays a closed record a schema can validate without knowing about
|
|
3815
|
+
* `~pos`. A move writes `[container, key, '~pos']` and a field edit writes
|
|
3816
|
+
* `[container, key, 'value', field]` — still disjoint one-field paths.
|
|
3817
|
+
*/
|
|
3818
|
+
type ContainerEntry<T> = {
|
|
3819
|
+
readonly [POS_SEGMENT]: string;
|
|
3820
|
+
readonly value: T;
|
|
3821
|
+
};
|
|
3822
|
+
/** `key` derives an element's key from the value, for payloads carrying their own identity field. */
|
|
3823
|
+
type KeyedContainerConfig<T> = {
|
|
3824
|
+
readonly key?: (value: T) => string;
|
|
3825
|
+
};
|
|
3826
|
+
/** The helpers of one container flavour, with keys supplied by the caller. */
|
|
3827
|
+
type KeyedContainer<T extends object, E extends object = T> = {
|
|
3828
|
+
entries(container: Record<string, E>): OrderedEntry<T>[];
|
|
3829
|
+
insert(container: ContainerNode<E>, key: string, value: T, index?: number): string;
|
|
3830
|
+
move(container: ContainerNode<E>, key: string, index: number): string | undefined;
|
|
3831
|
+
remove(container: ContainerNode<E>, key: string): void;
|
|
3832
|
+
rebalance(sync: Pick<OpSync, 'override'>, container: ContainerNode<E>): void;
|
|
3833
|
+
};
|
|
3834
|
+
/** The same helpers where a configured `key` extractor supplies the key, so `insert` takes none. */
|
|
3835
|
+
type SelfKeyedContainer<T extends object, E extends object = T> = Omit<KeyedContainer<T, E>, 'insert'> & {
|
|
3836
|
+
insert(container: ContainerNode<E>, value: T, index?: number): string;
|
|
3837
|
+
};
|
|
3838
|
+
/**
|
|
3839
|
+
* Binds one container flavour to the whole set of helpers, so every read and write of a container
|
|
3840
|
+
* agrees on how its elements are shaped. Pass the container node itself per call: one flavour
|
|
3841
|
+
* serves every container of a type. Positions live INSIDE the element; for a payload that must
|
|
3842
|
+
* stay a closed record, use {@link wrappedContainer} instead.
|
|
3843
|
+
*
|
|
3844
|
+
* ```typescript
|
|
3845
|
+
* const slots = keyedContainer({ key: (n: Node) => n.id });
|
|
3846
|
+
* slots.insert(node, child, 2); // one set at [container, id]
|
|
3847
|
+
* slots.move(node, 'child-1', 0); // one set at [container, 'child-1', '~pos']
|
|
3848
|
+
* slots.entries(node()); // reading order
|
|
3849
|
+
* ```
|
|
3850
|
+
*
|
|
3851
|
+
* With no extractor, `insert` takes the key: `keyedContainer<Node>()`. A duplicate key OVERWRITES,
|
|
3852
|
+
* taking a fresh position at the requested index. An element's identity field is immutable while it
|
|
3853
|
+
* is resident — re-keying is a remove plus an insert, never an edit.
|
|
3854
|
+
*/
|
|
3855
|
+
declare function keyedContainer<T extends object>(config: {
|
|
3856
|
+
key: (value: T) => string;
|
|
3857
|
+
}): SelfKeyedContainer<T>;
|
|
3858
|
+
declare function keyedContainer<T extends object>(config?: {
|
|
3859
|
+
key?: never;
|
|
3860
|
+
}): KeyedContainer<T>;
|
|
3861
|
+
/**
|
|
3862
|
+
* {@link keyedContainer} storing every element as a {@link ContainerEntry}: the position sits
|
|
3863
|
+
* beside the payload rather than inside it, so a schema that closes the payload record still
|
|
3864
|
+
* validates. `entries` reads back payloads, never wrappers.
|
|
3865
|
+
*
|
|
3866
|
+
* ```typescript
|
|
3867
|
+
* const slots = wrappedContainer({ key: (n: Node) => n.id });
|
|
3868
|
+
* slots.insert(node, child, 2); // one set at [container, id] carrying { '~pos', value }
|
|
3869
|
+
* ```
|
|
3870
|
+
*
|
|
3871
|
+
* A container's representation is fixed when it is created and is never carried on the wire, so
|
|
3872
|
+
* every peer of a synced container must agree on it — converting one after the fact is a data
|
|
3873
|
+
* migration, not a flag.
|
|
3874
|
+
*/
|
|
3875
|
+
declare function wrappedContainer<T extends object>(config: {
|
|
3876
|
+
key: (value: T) => string;
|
|
3877
|
+
}): SelfKeyedContainer<T, ContainerEntry<T>>;
|
|
3878
|
+
declare function wrappedContainer<T extends object>(config?: {
|
|
3879
|
+
key?: never;
|
|
3880
|
+
}): KeyedContainer<T, ContainerEntry<T>>;
|
|
3812
3881
|
|
|
3813
3882
|
type StoreHistory = {
|
|
3814
3883
|
readonly canUndo: Signal<boolean>;
|
|
@@ -4611,5 +4680,5 @@ type CreateHistoryOptions<T> = Omit<CreateSignalOptions<T[]>, 'equal'> & {
|
|
|
4611
4680
|
*/
|
|
4612
4681
|
declare function withHistory<T>(sourceOrValue: WritableSignal<T> | T, opt?: CreateHistoryOptions<T>): SignalWithHistory<T>;
|
|
4613
4682
|
|
|
4614
|
-
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, 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 };
|
|
4615
|
-
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 };
|
|
4683
|
+
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 };
|
|
4684
|
+
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 };
|