@mmstack/primitives 22.8.1 → 22.8.3
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
|
@@ -1322,6 +1322,28 @@ declare function indexArray<T, U>(source: Signal<T[]> | (() => T[]), map: (value
|
|
|
1322
1322
|
*/
|
|
1323
1323
|
declare const mapArray: typeof indexArray;
|
|
1324
1324
|
|
|
1325
|
+
/**
|
|
1326
|
+
* Opt-in policy describing how `keyArray` should treat duplicate keys.
|
|
1327
|
+
*
|
|
1328
|
+
* With the `'ordinal'` policy, keys are coerced to strings and disambiguated by
|
|
1329
|
+
* their occurrence order: the first item with a given base key keeps `base`, the
|
|
1330
|
+
* second becomes `base#1`, the third `base#2`, and so on. Each duplicate therefore
|
|
1331
|
+
* gets a stable, distinct entry instead of collapsing.
|
|
1332
|
+
*
|
|
1333
|
+
* Identity follows position-among-duplicates: removing an earlier occurrence
|
|
1334
|
+
* promotes the next one to the base key, which changes its effective key and thus
|
|
1335
|
+
* re-creates its mapped entry.
|
|
1336
|
+
*/
|
|
1337
|
+
type DuplicateKeyPolicy = {
|
|
1338
|
+
/** Disambiguation strategy. Currently only ordinal (`base`, `base#1`, `base#2`, ...). */
|
|
1339
|
+
policy: 'ordinal';
|
|
1340
|
+
/**
|
|
1341
|
+
* Optional diagnostics side-channel. When a recompute observes duplicate keys,
|
|
1342
|
+
* this is invoked once with the duplicate base keys in first-occurrence order.
|
|
1343
|
+
* It is called untracked and must not be relied upon to create reactive dependencies.
|
|
1344
|
+
*/
|
|
1345
|
+
report?: (bases: readonly string[]) => void;
|
|
1346
|
+
};
|
|
1325
1347
|
/**
|
|
1326
1348
|
* Reactively maps items from a source array to a new array by value (identity).
|
|
1327
1349
|
*
|
|
@@ -1340,6 +1362,8 @@ declare const mapArray: typeof indexArray;
|
|
|
1340
1362
|
* - `onDestroy`: A callback invoked when a mapped item is removed from the array.
|
|
1341
1363
|
* - `key`: A custom key extractor for identity matching (e.g. `(item) => item.id`)
|
|
1342
1364
|
* when item references change but conceptual identity is preserved.
|
|
1365
|
+
* - `duplicateKeys`: Opt-in policy for handling duplicate keys. When omitted,
|
|
1366
|
+
* behavior is unchanged (duplicates collapse). See {@link DuplicateKeyPolicy}.
|
|
1343
1367
|
* @returns A `Signal<U[]>` containing the mapped array.
|
|
1344
1368
|
*
|
|
1345
1369
|
* @example
|
|
@@ -1371,6 +1395,12 @@ declare function keyArray<T, U, K>(source: Signal<T[]> | (() => T[]), mapFn: (v:
|
|
|
1371
1395
|
* even if the item reference changes.
|
|
1372
1396
|
*/
|
|
1373
1397
|
key?: (item: T) => K;
|
|
1398
|
+
/**
|
|
1399
|
+
* Opt-in policy for disambiguating duplicate keys. When present, keys are
|
|
1400
|
+
* coerced to strings and duplicates get distinct ordinal effective keys
|
|
1401
|
+
* (`base`, `base#1`, `base#2`, ...). When absent, behavior is unchanged.
|
|
1402
|
+
*/
|
|
1403
|
+
duplicateKeys?: DuplicateKeyPolicy;
|
|
1374
1404
|
}): Signal<U[]>;
|
|
1375
1405
|
|
|
1376
1406
|
type MappedObject<T extends object, U> = {
|
|
@@ -3101,10 +3131,14 @@ declare const STORE_SHARED_GLOBALS: unique symbol;
|
|
|
3101
3131
|
type ProxyCache = WeakMap<object, Map<PropertyKey, WeakRef<Signal<any>>>>;
|
|
3102
3132
|
/**
|
|
3103
3133
|
* @internal
|
|
3104
|
-
* Prunes a cache entry once its proxy is reclaimed by the GC.
|
|
3134
|
+
* Prunes a cache entry once its proxy is reclaimed by the GC. The held value must reference
|
|
3135
|
+
* `target` only weakly: held values are retained by the registry until its cleanup callbacks
|
|
3136
|
+
* run (host tasks — they never run inside a synchronous burst), so a strong `target` here
|
|
3137
|
+
* keeps every dropped subtree's backing-signal ancestry alive across GCs. If `target` is
|
|
3138
|
+
* already dead its whole cache entry died with it (WeakMap), and there is nothing to prune.
|
|
3105
3139
|
*/
|
|
3106
3140
|
type ProxyCleanupRegistry = FinalizationRegistry<{
|
|
3107
|
-
|
|
3141
|
+
targetRef: WeakRef<object>;
|
|
3108
3142
|
prop: PropertyKey;
|
|
3109
3143
|
}>;
|
|
3110
3144
|
/**
|
|
@@ -4489,4 +4523,4 @@ type CreateHistoryOptions<T> = Omit<CreateSignalOptions<T[]>, 'equal'> & {
|
|
|
4489
4523
|
declare function withHistory<T>(sourceOrValue: WritableSignal<T> | T, opt?: CreateHistoryOptions<T>): SignalWithHistory<T>;
|
|
4490
4524
|
|
|
4491
4525
|
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, 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, until, use, validateEnvelope, windowSize, withHistory };
|
|
4492
|
-
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, 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, Transaction, TransactionRef, TransitionRef, TransitionScope, UntilOptions, UseSource, Vivify, WindowSize, WindowSizeOptions, WindowSizeSignal, WithVivify, WritableSignalStore, toStoreOptions };
|
|
4526
|
+
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, Transaction, TransactionRef, TransitionRef, TransitionScope, UntilOptions, UseSource, Vivify, WindowSize, WindowSizeOptions, WindowSizeSignal, WithVivify, WritableSignalStore, toStoreOptions };
|