@mmstack/primitives 20.11.0 → 20.12.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/index.d.ts CHANGED
@@ -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 record (op-protocol RFC §3). `writer` is an opaque principal pseudonym —
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 (op-protocol RFC §12 v0): reconciles two concurrent versions of
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 (op-protocol RFC §4): a per-path last-writer-wins
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 (op-protocol RFC §5): invert pending, apply remote, re-apply
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 (RFC §3). */
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>;
@@ -3783,6 +3793,18 @@ type StoredSignal<T> = WritableSignal<T> & {
3783
3793
  */
3784
3794
  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
3795
 
3796
+ /**
3797
+ * The cross-tab transport `tabSync` rides. The default is {@link MessageBus} (a `BroadcastChannel`);
3798
+ * pass a custom one through `tabSync`'s `bus` option to route over a different channel, or to drive
3799
+ * tabs deterministically in a test. `subscribe` returns an unsubscribe handle plus a `post` that
3800
+ * fans the value to every OTHER tab on the same `id`.
3801
+ */
3802
+ type TabSyncBus = {
3803
+ subscribe<T>(id: string, listener: (data: T) => void): {
3804
+ unsub: () => void;
3805
+ post: (value: T) => void;
3806
+ };
3807
+ };
3786
3808
  type LegacySyncSignalOptions = {
3787
3809
  id?: string;
3788
3810
  };
@@ -3796,11 +3818,13 @@ type SyncSignalOptions = {
3796
3818
  * it — a cross-tab consistency gap not worth the negligible saving. The channel stays live.
3797
3819
  */
3798
3820
  injector?: Injector;
3821
+ /** Cross-tab transport. Defaults to the injected {@link MessageBus} (a `BroadcastChannel`). */
3822
+ bus?: TabSyncBus;
3799
3823
  };
3800
3824
  /**
3801
3825
  * Store mode (`tabSync(store, …)`): syncs structural OPS instead of whole values — concurrent
3802
3826
  * edits to different leaves merge instead of clobbering, and a joining tab hydrates from a
3803
- * peer via the hello exchange (up-to-date / snapshot; op-protocol RFC §6).
3827
+ * peer via the hello exchange.
3804
3828
  */
3805
3829
  type StoreTabSyncOptions = SyncSignalOptions & {
3806
3830
  /** Principal pseudonym on emitted envelopes. Tabs share one user, so a default is fine. */
@@ -4106,4 +4130,4 @@ type CreateHistoryOptions<T> = Omit<CreateSignalOptions<T[]>, 'equal'> & {
4106
4130
  declare function withHistory<T>(sourceOrValue: WritableSignal<T> | T, opt?: CreateHistoryOptions<T>): SignalWithHistory<T>;
4107
4131
 
4108
4132
  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 };
4133
+ 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmstack/primitives",
3
- "version": "20.11.0",
3
+ "version": "20.12.0",
4
4
  "keywords": [
5
5
  "angular",
6
6
  "signals",