@mmstack/primitives 22.8.0 → 22.8.2
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
|
@@ -3101,10 +3101,14 @@ declare const STORE_SHARED_GLOBALS: unique symbol;
|
|
|
3101
3101
|
type ProxyCache = WeakMap<object, Map<PropertyKey, WeakRef<Signal<any>>>>;
|
|
3102
3102
|
/**
|
|
3103
3103
|
* @internal
|
|
3104
|
-
* Prunes a cache entry once its proxy is reclaimed by the GC.
|
|
3104
|
+
* Prunes a cache entry once its proxy is reclaimed by the GC. The held value must reference
|
|
3105
|
+
* `target` only weakly: held values are retained by the registry until its cleanup callbacks
|
|
3106
|
+
* run (host tasks — they never run inside a synchronous burst), so a strong `target` here
|
|
3107
|
+
* keeps every dropped subtree's backing-signal ancestry alive across GCs. If `target` is
|
|
3108
|
+
* already dead its whole cache entry died with it (WeakMap), and there is nothing to prune.
|
|
3105
3109
|
*/
|
|
3106
3110
|
type ProxyCleanupRegistry = FinalizationRegistry<{
|
|
3107
|
-
|
|
3111
|
+
targetRef: WeakRef<object>;
|
|
3108
3112
|
prop: PropertyKey;
|
|
3109
3113
|
}>;
|
|
3110
3114
|
/**
|
|
@@ -3774,6 +3778,12 @@ type StoreHistory = {
|
|
|
3774
3778
|
undo(): void;
|
|
3775
3779
|
/** Re-apply the most recently undone change. */
|
|
3776
3780
|
redo(): void;
|
|
3781
|
+
/**
|
|
3782
|
+
* Close the current coalescing run: the next tracked change starts a NEW undo entry even if
|
|
3783
|
+
* it lands inside the `coalesce` window. Call it on the boundaries your UX considers an
|
|
3784
|
+
* action — a field blur, a selection change, a drag drop. A no-op without `coalesce`.
|
|
3785
|
+
*/
|
|
3786
|
+
checkpoint(): void;
|
|
3777
3787
|
/** Forget all tracked history (e.g. after a save boundary). */
|
|
3778
3788
|
clear(): void;
|
|
3779
3789
|
destroy(): void;
|
|
@@ -3785,11 +3795,29 @@ type StoreHistoryOptions = CreateOpLogOptions & {
|
|
|
3785
3795
|
* The change stream to track. Defaults to self-diffing `source` (every change to the store
|
|
3786
3796
|
* becomes undoable). For collaborative-safe undo, pass a sync client's LOCAL envelope stream
|
|
3787
3797
|
* (e.g. an `opSync`'s `subscribe`, which fires only for this peer's own writes) — remote
|
|
3788
|
-
* peers' changes then never land on your undo stack.
|
|
3798
|
+
* peers' changes then never land on your undo stack. When the stream exposes `flush` (an
|
|
3799
|
+
* `opSync` does), undo/redo drain it synchronously so their own emissions never echo back
|
|
3800
|
+
* onto the stack as fresh entries.
|
|
3789
3801
|
*/
|
|
3790
3802
|
readonly track?: {
|
|
3791
3803
|
subscribe(cb: (batch: OpBatch) => void): () => void;
|
|
3804
|
+
flush?(): void;
|
|
3805
|
+
};
|
|
3806
|
+
/**
|
|
3807
|
+
* Merge rapid consecutive edits into ONE undo entry, so a typing run undoes as a unit
|
|
3808
|
+
* instead of per keystroke. A tracked change arriving within `ms` of the previous one AND
|
|
3809
|
+
* touching the same paths with the same op kinds extends the previous entry (set
|
|
3810
|
+
* `samePath: false` to merge on time alone); anything else — a different field, a kind
|
|
3811
|
+
* change, a pause longer than `ms`, a `checkpoint()`, an undo/redo — starts a new entry.
|
|
3812
|
+
* The window is measured between consecutive changes, so an unbroken run keeps merging.
|
|
3813
|
+
* Undoing a merged entry is exactly equivalent to undoing its changes one by one.
|
|
3814
|
+
*/
|
|
3815
|
+
readonly coalesce?: {
|
|
3816
|
+
readonly ms: number;
|
|
3817
|
+
readonly samePath?: boolean;
|
|
3792
3818
|
};
|
|
3819
|
+
/** Clock for the coalescing window (injectable for tests; default `Date.now`). */
|
|
3820
|
+
readonly now?: () => number;
|
|
3793
3821
|
};
|
|
3794
3822
|
/**
|
|
3795
3823
|
* Undo/redo for a copy-on-write store, built on the op-log: each tracked change is stored as
|
|
@@ -3799,7 +3827,8 @@ type StoreHistoryOptions = CreateOpLogOptions & {
|
|
|
3799
3827
|
*
|
|
3800
3828
|
* Composes with sync for collaborative undo: pass `track: syncClient` so only YOUR writes are
|
|
3801
3829
|
* undoable, while `undo()` emits a normal op that propagates to peers (it writes through the
|
|
3802
|
-
* store, which the sync client picks up).
|
|
3830
|
+
* store, which the sync client picks up). Coalescing groups only this stack's entries — what
|
|
3831
|
+
* goes over the wire is untouched.
|
|
3803
3832
|
*/
|
|
3804
3833
|
declare function storeHistory<T extends object>(source: WritableSignal<T>, opt?: StoreHistoryOptions): StoreHistory;
|
|
3805
3834
|
|