@mmstack/primitives 21.6.1 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmstack/primitives",
3
- "version": "21.6.1",
3
+ "version": "21.7.0",
4
4
  "keywords": [
5
5
  "angular",
6
6
  "signals",
@@ -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>;
@@ -3800,6 +3810,18 @@ type StoredSignal<T> = WritableSignal<T> & {
3800
3810
  */
3801
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>;
3802
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
+ };
3803
3825
  type LegacySyncSignalOptions = {
3804
3826
  id?: string;
3805
3827
  };
@@ -3813,11 +3835,13 @@ type SyncSignalOptions = {
3813
3835
  * it — a cross-tab consistency gap not worth the negligible saving. The channel stays live.
3814
3836
  */
3815
3837
  injector?: Injector;
3838
+ /** Cross-tab transport. Defaults to the injected {@link MessageBus} (a `BroadcastChannel`). */
3839
+ bus?: TabSyncBus;
3816
3840
  };
3817
3841
  /**
3818
3842
  * Store mode (`tabSync(store, …)`): syncs structural OPS instead of whole values — concurrent
3819
3843
  * edits to different leaves merge instead of clobbering, and a joining tab hydrates from a
3820
- * peer via the hello exchange (up-to-date / snapshot; op-protocol RFC §6).
3844
+ * peer via the hello exchange.
3821
3845
  */
3822
3846
  type StoreTabSyncOptions = SyncSignalOptions & {
3823
3847
  /** Principal pseudonym on emitted envelopes. Tabs share one user, so a default is fine. */
@@ -4123,4 +4147,4 @@ type CreateHistoryOptions<T> = Omit<CreateSignalOptions<T[]>, 'equal'> & {
4123
4147
  declare function withHistory<T>(sourceOrValue: WritableSignal<T> | T, opt?: CreateHistoryOptions<T>): SignalWithHistory<T>;
4124
4148
 
4125
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 };
4126
- 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 };