@mmstack/primitives 21.6.0 → 21.7.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/package.json
CHANGED
|
@@ -2276,7 +2276,7 @@ type PointerDragState = {
|
|
|
2276
2276
|
/**
|
|
2277
2277
|
* The element the gesture started on: the `handleSelector` match when one is
|
|
2278
2278
|
* set (so a single delegated listener can tell which child started the drag),
|
|
2279
|
-
* otherwise the
|
|
2279
|
+
* otherwise the pressed element itself (`event.target`). `null` when idle.
|
|
2280
2280
|
*/
|
|
2281
2281
|
origin: HTMLElement | null;
|
|
2282
2282
|
/**
|
|
@@ -3306,7 +3306,7 @@ declare function createHlcClock(now?: () => number): HlcClock;
|
|
|
3306
3306
|
declare const OP_PROTO_VERSION = 1;
|
|
3307
3307
|
type Key = string | number;
|
|
3308
3308
|
/**
|
|
3309
|
-
* The wire/journal
|
|
3309
|
+
* The wire/journal recor. `writer` is an opaque principal pseudonym —
|
|
3310
3310
|
* natural identity never enters the envelope; `origin` identifies the emitting log instance.
|
|
3311
3311
|
*/
|
|
3312
3312
|
type OpEnvelope = {
|
|
@@ -3347,7 +3347,7 @@ declare const lww: MergeFn;
|
|
|
3347
3347
|
declare const mergeThree: MergeFn;
|
|
3348
3348
|
declare const preserve: MergeFn;
|
|
3349
3349
|
/**
|
|
3350
|
-
* Identity-aware array merge
|
|
3350
|
+
* Identity-aware array merge: reconciles two concurrent versions of
|
|
3351
3351
|
* an array item-wise by a user-provided identity, instead of last-writer-wins on the whole
|
|
3352
3352
|
* array. Items are matched by key; per-item fields merge via `merge3` against the ancestor
|
|
3353
3353
|
* item; items added on either side survive; an item removed on either side and unedited on
|
|
@@ -3372,7 +3372,7 @@ type ConvergingApply = {
|
|
|
3372
3372
|
reset(): void;
|
|
3373
3373
|
};
|
|
3374
3374
|
/**
|
|
3375
|
-
* The unsequenced-topology convergence core
|
|
3375
|
+
* The unsequenced-topology convergence core: a per-path last-writer-wins
|
|
3376
3376
|
* register map over the total order (hlc, writer), with subtree dominance. Order-independent:
|
|
3377
3377
|
* any arrival order of the same envelope set yields the same state.
|
|
3378
3378
|
*/
|
|
@@ -3385,7 +3385,7 @@ type RebaseResult<T = unknown> = {
|
|
|
3385
3385
|
pending: StoreOp[][];
|
|
3386
3386
|
};
|
|
3387
3387
|
/**
|
|
3388
|
-
* The shared rebase routine
|
|
3388
|
+
* The shared rebase routine: invert pending, apply remote, re-apply
|
|
3389
3389
|
* pending through the merge policies. Pure — branching's `rebase()` and the sequenced relay
|
|
3390
3390
|
* client both call this.
|
|
3391
3391
|
*/
|
|
@@ -3399,7 +3399,7 @@ declare function rebaseOps<T>(root: T, pending: readonly (readonly StoreOp[])[],
|
|
|
3399
3399
|
*/
|
|
3400
3400
|
declare function policyStrategy<T>(policies: readonly MergePolicyEntry[]): (ancestor: T, mine: T, theirs: T) => T;
|
|
3401
3401
|
type OpSyncOptions = {
|
|
3402
|
-
/** Opaque principal pseudonym — provided by the app, never minted here
|
|
3402
|
+
/** Opaque principal pseudonym — provided by the app, never minted here. */
|
|
3403
3403
|
readonly writer: string;
|
|
3404
3404
|
readonly origin?: string;
|
|
3405
3405
|
readonly policyVersion?: number;
|
|
@@ -3436,6 +3436,16 @@ type OpSync<T = unknown> = {
|
|
|
3436
3436
|
* top, so writes made before hydration are never silently lost.
|
|
3437
3437
|
*/
|
|
3438
3438
|
hydrate(root: T, wm?: Record<string, number>): void;
|
|
3439
|
+
/**
|
|
3440
|
+
* Re-inject this origin's persisted local envelopes on boot (a durable outbox), WITHOUT minting
|
|
3441
|
+
* new versions: each is applied to the store (echo-free), registered as a local winner, and handed
|
|
3442
|
+
* to subscribers so a transport can resend the unacknowledged tail. `highWater` is the highest
|
|
3443
|
+
* version this origin ever emitted (>= every `env.version`); the next mint continues past it, so a
|
|
3444
|
+
* version acked before the reboot but dropped from a debounced outbox never collides. Call on a
|
|
3445
|
+
* FRESH instance, before any `receive`/`hydrate` — restoring onto already-ingested remote winners
|
|
3446
|
+
* would wrongly let a stale local op override them.
|
|
3447
|
+
*/
|
|
3448
|
+
restore(envs: readonly OpEnvelope[], highWater?: number): void;
|
|
3439
3449
|
destroy(): void;
|
|
3440
3450
|
};
|
|
3441
3451
|
declare function opSync<T extends object>(source: WritableSignal<T>, opt: OpSyncOptions): OpSync<T>;
|
|
@@ -3491,6 +3501,23 @@ type MaybePromise<T> = T | Promise<T>;
|
|
|
3491
3501
|
* del: (k) => table.delete(k),
|
|
3492
3502
|
* };
|
|
3493
3503
|
* ```
|
|
3504
|
+
*
|
|
3505
|
+
* The backend is also the seam for cross-cutting storage concerns like encryption: wrap any
|
|
3506
|
+
* backend in a decorator (get/set may be async, so WebCrypto fits here — `serialize` is sync
|
|
3507
|
+
* by design and is for shape, not for the storage medium). Versioning and migration still work
|
|
3508
|
+
* because the version envelope is inspected on what the backend RETURNS, i.e. after decryption:
|
|
3509
|
+
*
|
|
3510
|
+
* ```ts
|
|
3511
|
+
* const encrypted = (inner: AsyncStore, cipher: MyCipher): AsyncStore => ({
|
|
3512
|
+
* get: async (k) => {
|
|
3513
|
+
* const raw = await inner.get(k);
|
|
3514
|
+
* return raw === undefined ? undefined : cipher.decrypt(raw);
|
|
3515
|
+
* },
|
|
3516
|
+
* set: async (k, v) => inner.set(k, await cipher.encrypt(v)),
|
|
3517
|
+
* del: (k) => inner.del(k),
|
|
3518
|
+
* });
|
|
3519
|
+
* providePersistedStoreOptions({ store: encrypted(idbKeyval, cipher) });
|
|
3520
|
+
* ```
|
|
3494
3521
|
*/
|
|
3495
3522
|
type AsyncStore = {
|
|
3496
3523
|
get(key: string): MaybePromise<unknown>;
|
|
@@ -3783,6 +3810,18 @@ type StoredSignal<T> = WritableSignal<T> & {
|
|
|
3783
3810
|
*/
|
|
3784
3811
|
declare function stored<T>(fallback: T, { key, store: providedStore, serialize, deserialize, syncTabs, equal, onKeyChange, cleanupOldKey, validate, pause, injector: providedInjector, ...rest }: CreateStoredOptions<T>): StoredSignal<T>;
|
|
3785
3812
|
|
|
3813
|
+
/**
|
|
3814
|
+
* The cross-tab transport `tabSync` rides. The default is {@link MessageBus} (a `BroadcastChannel`);
|
|
3815
|
+
* pass a custom one through `tabSync`'s `bus` option to route over a different channel, or to drive
|
|
3816
|
+
* tabs deterministically in a test. `subscribe` returns an unsubscribe handle plus a `post` that
|
|
3817
|
+
* fans the value to every OTHER tab on the same `id`.
|
|
3818
|
+
*/
|
|
3819
|
+
type TabSyncBus = {
|
|
3820
|
+
subscribe<T>(id: string, listener: (data: T) => void): {
|
|
3821
|
+
unsub: () => void;
|
|
3822
|
+
post: (value: T) => void;
|
|
3823
|
+
};
|
|
3824
|
+
};
|
|
3786
3825
|
type LegacySyncSignalOptions = {
|
|
3787
3826
|
id?: string;
|
|
3788
3827
|
};
|
|
@@ -3796,11 +3835,13 @@ type SyncSignalOptions = {
|
|
|
3796
3835
|
* it — a cross-tab consistency gap not worth the negligible saving. The channel stays live.
|
|
3797
3836
|
*/
|
|
3798
3837
|
injector?: Injector;
|
|
3838
|
+
/** Cross-tab transport. Defaults to the injected {@link MessageBus} (a `BroadcastChannel`). */
|
|
3839
|
+
bus?: TabSyncBus;
|
|
3799
3840
|
};
|
|
3800
3841
|
/**
|
|
3801
3842
|
* Store mode (`tabSync(store, …)`): syncs structural OPS instead of whole values — concurrent
|
|
3802
3843
|
* edits to different leaves merge instead of clobbering, and a joining tab hydrates from a
|
|
3803
|
-
* peer via the hello exchange
|
|
3844
|
+
* peer via the hello exchange.
|
|
3804
3845
|
*/
|
|
3805
3846
|
type StoreTabSyncOptions = SyncSignalOptions & {
|
|
3806
3847
|
/** Principal pseudonym on emitted envelopes. Tabs share one user, so a default is fine. */
|
|
@@ -4106,4 +4147,4 @@ type CreateHistoryOptions<T> = Omit<CreateSignalOptions<T[]>, 'equal'> & {
|
|
|
4106
4147
|
declare function withHistory<T>(sourceOrValue: WritableSignal<T> | T, opt?: CreateHistoryOptions<T>): SignalWithHistory<T>;
|
|
4107
4148
|
|
|
4108
4149
|
export { CONCURRENCY_INSTRUMENTATION, MmActivity, MmTransition, MmViewTransitionName, OP_PROTO_VERSION, PAUSABLE_OPTIONS, PERSISTED_STORE_OPTIONS, SuspenseBoundary, SuspenseBoundaryBase, UnscopedSuspenseBoundary, activeTransaction, applyOps, batteryStatus, bridgeScopeToPendingTasks, chunked, clipboard, combineWith, compareHlc, compareTotal, createAttributedPending, createConvergingApply, createForwardingScope, createHlcClock, createStoreContext, createTransaction, createTransitionScope, debounce, debounced, deferredValue, derived, diffOps, distinct, elementSize, elementVisibility, extendStore, filter, filterWith, focusWithin, forkStore, geolocation, getTransitionScope, holdUntilReady, idle, indexArray, injectPaused, injectRegisterResource, injectStartTransaction, injectStartTransition, injectTransitionScope, invertBatch, isConflicted, isDerivation, isLeaf, isMutable, isOpaque, isStore, keepPrevious, keyArray, keyedArray, latest, lww, map, mapArray, mapObject, mediaQuery, merge3, mergeThree, mousePosition, mutable, mutableStore, nestedEffect, networkStatus, opLog, opSync, opaque, orientation, pageVisibility, pairwise, pausableComputed, pausableEffect, pausableSignal, perfCustomTracks, persist, persistedStore, pipeable, piped, pointerDrag, policyStrategy, pooled, pooledArray, pooledMap, pooledSet, prefersDarkMode, prefersReducedMotion, preserve, projection, provideConcurrencyInstrumentation, provideForwardingTransitionScope, providePausableOptions, providePaused, providePersistedStoreOptions, provideTransitionScope, rebaseOps, reconcile, registerResource, resolvePause, scan, scrollPosition, select, sensor, sensors, signalFromEvent, startWith, store, storeHistory, stored, tabSync, tap, throttle, throttled, toFakeDerivation, toFakeSignalDerivation, toStore, toWritable, until, use, windowSize, withHistory };
|
|
4109
|
-
export type { AsyncStore, BatteryStatus, ClipboardSignal, Computation, ConcurrencyInstrumentation, Conflicted, ConvergingApply, CreateChunkedOptions, CreateDebouncedOptions, CreateHistoryOptions, CreateLatestOptions, CreateOpLogOptions, CreatePooledOptions, CreateProvidedPooledOptions, CreateStoredOptions, CreateThrottledOptions, CreateTransitionScopeOptions, DebouncedSignal, DeferStrategy, DeferredSignal, DeferredValueOptions, DerivedSignal, ElementSize, ElementSizeOptions, ElementSizeSignal, ElementVisibilityOptions, ElementVisibilitySignal, ExtendStoreOptions, 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, OpSyncOptions, Opaque, PausableOptions, PauseOption, PersistHandle, PersistOptions, PersistedStore, PersistedStoreDefaults, PersistedStoreOptions, PipeableSignal, PointerDragOptions, PointerDragSignal, PointerDragState, PointerModifiers, PointerPoint, ProjectionOptions, RebaseResult, ReconcileFn, ReconcileKey, RegisterOptions, ResourceLike, ScreenOrientation, ScreenOrientationState, ScrollPosition, ScrollPositionOptions, ScrollPositionSignal, SensorRunOptions, SignalFromEventOptions, SignalStore, SignalWithHistory, StoreHistory, StoreHistoryOptions, StoreOp, StoreOptions, StoreTabSyncOptions, StoredSignal, SuspendType, SyncSignalOptions, ThrottledSignal, Transaction, TransactionRef, TransitionRef, TransitionScope, UntilOptions, UseSource, Vivify, WindowSize, WindowSizeOptions, WindowSizeSignal, WithVivify, WritableSignalStore, toStoreOptions };
|
|
4150
|
+
export type { AsyncStore, BatteryStatus, ClipboardSignal, Computation, ConcurrencyInstrumentation, Conflicted, ConvergingApply, CreateChunkedOptions, CreateDebouncedOptions, CreateHistoryOptions, CreateLatestOptions, CreateOpLogOptions, CreatePooledOptions, CreateProvidedPooledOptions, CreateStoredOptions, CreateThrottledOptions, CreateTransitionScopeOptions, DebouncedSignal, DeferStrategy, DeferredSignal, DeferredValueOptions, DerivedSignal, ElementSize, ElementSizeOptions, ElementSizeSignal, ElementVisibilityOptions, ElementVisibilitySignal, ExtendStoreOptions, 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, OpSyncOptions, Opaque, PausableOptions, PauseOption, PersistHandle, PersistOptions, PersistedStore, PersistedStoreDefaults, PersistedStoreOptions, PipeableSignal, PointerDragOptions, PointerDragSignal, PointerDragState, PointerModifiers, PointerPoint, ProjectionOptions, RebaseResult, ReconcileFn, ReconcileKey, RegisterOptions, ResourceLike, ScreenOrientation, ScreenOrientationState, ScrollPosition, ScrollPositionOptions, ScrollPositionSignal, SensorRunOptions, SignalFromEventOptions, SignalStore, SignalWithHistory, StoreHistory, StoreHistoryOptions, StoreOp, StoreOptions, StoreTabSyncOptions, StoredSignal, SuspendType, SyncSignalOptions, TabSyncBus, ThrottledSignal, Transaction, TransactionRef, TransitionRef, TransitionScope, UntilOptions, UseSource, Vivify, WindowSize, WindowSizeOptions, WindowSizeSignal, WithVivify, WritableSignalStore, toStoreOptions };
|