json-patch-to-crdt 0.3.0 → 0.5.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/README.md +84 -1
- package/dist/{compact-BToZE6Q6.js → compact-CDvajUfn.js} +1602 -621
- package/dist/{compact-BS7F604m.mjs → compact-Dj0BYeY5.mjs} +1715 -764
- package/dist/{depth-BTHjgY18.d.mts → depth-CM1kCxhm.d.mts} +101 -19
- package/dist/{depth-DSl2ghKu.d.ts → depth-NbZ6Giq9.d.ts} +101 -19
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -2
- package/dist/index.mjs +2 -2
- package/dist/internals.d.mts +11 -4
- package/dist/internals.d.ts +11 -4
- package/dist/internals.js +6 -1
- package/dist/internals.mjs +2 -2
- package/package.json +1 -1
|
@@ -17,8 +17,9 @@ type JsonValue = JsonPrimitive | JsonValue[] | {
|
|
|
17
17
|
/**
|
|
18
18
|
* Runtime handling mode for non-JSON inputs received through `any` / untyped callers.
|
|
19
19
|
* - `"none"`: keep current behavior (no extra runtime guardrails).
|
|
20
|
-
* - `"strict"`: reject invalid values (e.g. `NaN`, `Infinity`, `undefined`).
|
|
21
|
-
* - `"normalize"`: coerce invalid values into JSON-safe output.
|
|
20
|
+
* - `"strict"`: reject invalid values (e.g. `NaN`, `Infinity`, `undefined`, or non-plain objects like `Date`).
|
|
21
|
+
* - `"normalize"`: coerce invalid values into JSON-safe output. Non-plain objects become `null`
|
|
22
|
+
* at the root or in arrays, and are omitted from object properties.
|
|
22
23
|
*/
|
|
23
24
|
type JsonValidationMode = "none" | "strict" | "normalize";
|
|
24
25
|
/** Mutable clock that tracks an actor's identity and monotonic counter. */
|
|
@@ -87,20 +88,35 @@ type SerializedNode = {
|
|
|
87
88
|
kind: "seq";
|
|
88
89
|
elems: Record<string, SerializedRgaElem>;
|
|
89
90
|
};
|
|
90
|
-
/** JSON-serializable form of a CRDT document. */
|
|
91
|
-
|
|
91
|
+
/** Versioned JSON-serializable form of a CRDT document. */
|
|
92
|
+
interface SerializedDocV1 {
|
|
93
|
+
version: 1;
|
|
92
94
|
root: SerializedNode;
|
|
93
|
-
}
|
|
95
|
+
}
|
|
96
|
+
/** Legacy unversioned JSON-serializable form of a CRDT document. */
|
|
97
|
+
interface LegacySerializedDoc {
|
|
98
|
+
root: SerializedNode;
|
|
99
|
+
}
|
|
100
|
+
/** JSON-serializable form of a CRDT document. */
|
|
101
|
+
type SerializedDoc = SerializedDocV1 | LegacySerializedDoc;
|
|
94
102
|
/** JSON-serializable form of a clock. */
|
|
95
|
-
|
|
103
|
+
interface SerializedClock {
|
|
96
104
|
actor: ActorId;
|
|
97
105
|
ctr: number;
|
|
98
|
-
}
|
|
99
|
-
/** JSON-serializable form of a full CRDT state (document + clock). */
|
|
100
|
-
|
|
106
|
+
}
|
|
107
|
+
/** Versioned JSON-serializable form of a full CRDT state (document + clock). */
|
|
108
|
+
interface SerializedStateV1 {
|
|
109
|
+
version: 1;
|
|
101
110
|
doc: SerializedDoc;
|
|
102
111
|
clock: SerializedClock;
|
|
103
|
-
}
|
|
112
|
+
}
|
|
113
|
+
/** Legacy unversioned JSON-serializable form of a full CRDT state (document + clock). */
|
|
114
|
+
interface LegacySerializedState {
|
|
115
|
+
doc: SerializedDoc;
|
|
116
|
+
clock: SerializedClock;
|
|
117
|
+
}
|
|
118
|
+
/** JSON-serializable form of a full CRDT state (document + clock). */
|
|
119
|
+
type SerializedState = SerializedStateV1 | LegacySerializedState;
|
|
104
120
|
/** Typed reasons for rejecting malformed serialized CRDT payloads. */
|
|
105
121
|
type DeserializeErrorReason = "INVALID_SERIALIZED_SHAPE" | "INVALID_SERIALIZED_INVARIANT";
|
|
106
122
|
/** Structured failure payload used by non-throwing deserialize helpers. */
|
|
@@ -308,6 +324,16 @@ type ValidatePatchResult = {
|
|
|
308
324
|
ok: false;
|
|
309
325
|
error: ApplyError;
|
|
310
326
|
};
|
|
327
|
+
/**
|
|
328
|
+
* Merge strategy applied when two non-empty array sequences share no element lineage.
|
|
329
|
+
*
|
|
330
|
+
* - `"reject"` – abort the merge and return a `LINEAGE_MISMATCH` error (default).
|
|
331
|
+
* - `"atomic-replace"` – replace the losing array entirely with the one that has
|
|
332
|
+
* the higher representative dot (causal last-write-wins at the array level).
|
|
333
|
+
* - `"unsafe-union"` – union all elements from both sequences without any lineage
|
|
334
|
+
* check. Element ordering may be non-deterministic across peers.
|
|
335
|
+
*/
|
|
336
|
+
type UnrelatedArraysStrategy = "reject" | "atomic-replace" | "unsafe-union";
|
|
311
337
|
/** Options for `mergeState`. */
|
|
312
338
|
type MergeStateOptions = {
|
|
313
339
|
/**
|
|
@@ -316,16 +342,30 @@ type MergeStateOptions = {
|
|
|
316
342
|
*/
|
|
317
343
|
actor?: ActorId;
|
|
318
344
|
/**
|
|
319
|
-
*
|
|
320
|
-
* Defaults to `
|
|
345
|
+
* Strategy for merging unrelated (non-overlapping) non-empty array sequences.
|
|
346
|
+
* Defaults to `"reject"`.
|
|
347
|
+
*/
|
|
348
|
+
unrelatedArrays?: UnrelatedArraysStrategy;
|
|
349
|
+
/**
|
|
350
|
+
* @deprecated Use `unrelatedArrays` instead.
|
|
351
|
+
* When `true`, behaves like `unrelatedArrays: "reject"`.
|
|
352
|
+
* When `false`, behaves like `unrelatedArrays: "unsafe-union"`.
|
|
353
|
+
* Ignored when `unrelatedArrays` is also provided.
|
|
321
354
|
*/
|
|
322
355
|
requireSharedOrigin?: boolean;
|
|
323
356
|
};
|
|
324
357
|
/** Options for `mergeDoc`. */
|
|
325
358
|
type MergeDocOptions = {
|
|
326
359
|
/**
|
|
327
|
-
*
|
|
328
|
-
* Defaults to `
|
|
360
|
+
* Strategy for merging unrelated (non-overlapping) non-empty array sequences.
|
|
361
|
+
* Defaults to `"reject"`.
|
|
362
|
+
*/
|
|
363
|
+
unrelatedArrays?: UnrelatedArraysStrategy;
|
|
364
|
+
/**
|
|
365
|
+
* @deprecated Use `unrelatedArrays` instead.
|
|
366
|
+
* When `true`, behaves like `unrelatedArrays: "reject"`.
|
|
367
|
+
* When `false`, behaves like `unrelatedArrays: "unsafe-union"`.
|
|
368
|
+
* Ignored when `unrelatedArrays` is also provided.
|
|
329
369
|
*/
|
|
330
370
|
requireSharedOrigin?: boolean;
|
|
331
371
|
};
|
|
@@ -403,6 +443,19 @@ type DiffOptions = {
|
|
|
403
443
|
* Set to `Number.POSITIVE_INFINITY` to always allow LCS.
|
|
404
444
|
*/
|
|
405
445
|
lcsMaxCells?: number;
|
|
446
|
+
/**
|
|
447
|
+
* Optional guardrail for `arrayStrategy: "lcs-linear"`.
|
|
448
|
+
* Uses the trimmed unmatched window size
|
|
449
|
+
* (`(unmatchedBase.length + 1) * (unmatchedNext.length + 1)`) as a proxy for
|
|
450
|
+
* worst-case work. When the cap is exceeded, the diff falls back to an atomic
|
|
451
|
+
* array replacement instead of running the linear-space traversal.
|
|
452
|
+
*
|
|
453
|
+
* Unlike `lcsMaxCells`, this is opt-in and defaults to no fallback so
|
|
454
|
+
* existing `lcs-linear` callers keep their current behavior.
|
|
455
|
+
*
|
|
456
|
+
* Set to `Number.POSITIVE_INFINITY` to always allow `lcs-linear`.
|
|
457
|
+
*/
|
|
458
|
+
lcsLinearMaxCells?: number;
|
|
406
459
|
/**
|
|
407
460
|
* Emit RFC 6902 `move` operations when a deterministic remove/add rewrite is available.
|
|
408
461
|
* Defaults to `false` for backward compatibility.
|
|
@@ -556,8 +609,8 @@ declare function compileJsonPatchToIntent(baseJson: JsonValue, patch: JsonPatchO
|
|
|
556
609
|
* By default arrays use a deterministic LCS strategy.
|
|
557
610
|
* Pass `{ arrayStrategy: "atomic" }` for single-op array replacement.
|
|
558
611
|
* Pass `{ arrayStrategy: "lcs-linear" }` for a lower-memory LCS variant.
|
|
559
|
-
*
|
|
560
|
-
*
|
|
612
|
+
* Use `lcsLinearMaxCells` to optionally cap worst-case `lcs-linear` work and
|
|
613
|
+
* fall back to an atomic array replacement for very large unmatched windows.
|
|
561
614
|
* Pass `{ emitMoves: true }` or `{ emitCopies: true }` to opt into RFC 6902
|
|
562
615
|
* move/copy emission when a deterministic rewrite is available.
|
|
563
616
|
* @param base - The original JSON value.
|
|
@@ -566,6 +619,8 @@ declare function compileJsonPatchToIntent(baseJson: JsonValue, patch: JsonPatchO
|
|
|
566
619
|
* @returns An array of JSON Patch operations that transform `base` into `next`.
|
|
567
620
|
*/
|
|
568
621
|
declare function diffJsonPatch(base: JsonValue, next: JsonValue, options?: DiffOptions): JsonPatchOp[];
|
|
622
|
+
/** @internal Stable structural fingerprint used for deterministic diff rewrites. */
|
|
623
|
+
declare function stableJsonValueKey(value: JsonValue, structuralKeyCache?: WeakMap<object, string>): string;
|
|
569
624
|
/** Deep equality check for JSON values (null-safe, handles arrays and objects). */
|
|
570
625
|
declare function jsonEquals(a: JsonValue, b: JsonValue): boolean;
|
|
571
626
|
//#endregion
|
|
@@ -584,7 +639,12 @@ declare function deserializeDoc(data: SerializedDoc): Doc;
|
|
|
584
639
|
declare function tryDeserializeDoc(data: SerializedDoc): TryDeserializeDocResult;
|
|
585
640
|
/** Serialize a full CRDT state (document + clock) to a JSON-safe representation. */
|
|
586
641
|
declare function serializeState(state: CrdtState): SerializedState;
|
|
587
|
-
/**
|
|
642
|
+
/**
|
|
643
|
+
* Reconstruct a full CRDT state from its serialized form, restoring the clock.
|
|
644
|
+
*
|
|
645
|
+
* May throw `TraversalDepthError` when the payload exceeds the maximum
|
|
646
|
+
* supported nesting depth.
|
|
647
|
+
*/
|
|
588
648
|
declare function deserializeState(data: SerializedState): CrdtState;
|
|
589
649
|
/** Non-throwing `deserializeState` variant with typed validation details. */
|
|
590
650
|
declare function tryDeserializeState(data: SerializedState): TryDeserializeStateResult;
|
|
@@ -619,7 +679,7 @@ declare function tryMergeDoc(a: Doc, b: Doc, options?: MergeDocOptions): TryMerg
|
|
|
619
679
|
* The merged clock keeps a stable actor identity:
|
|
620
680
|
* - defaults to the actor from the first argument (`a`)
|
|
621
681
|
* - can be overridden via `options.actor`
|
|
622
|
-
* - optional `options.
|
|
682
|
+
* - optional `options.unrelatedArrays` controls the merge strategy for non-overlapping sequences
|
|
623
683
|
*
|
|
624
684
|
* The merged counter is lifted to the highest counter already observed for
|
|
625
685
|
* that actor across both input clocks and the merged document dots.
|
|
@@ -628,6 +688,28 @@ declare function mergeState(a: CrdtState, b: CrdtState, options?: MergeStateOpti
|
|
|
628
688
|
/** Non-throwing `mergeState` variant with structured conflict details. */
|
|
629
689
|
declare function tryMergeState(a: CrdtState, b: CrdtState, options?: MergeStateOptions): TryMergeStateResult;
|
|
630
690
|
//#endregion
|
|
691
|
+
//#region src/version-vector.d.ts
|
|
692
|
+
/**
|
|
693
|
+
* Inspect a document or state and return the highest observed counter per actor.
|
|
694
|
+
*
|
|
695
|
+
* When a `CrdtState` is provided, the returned vector is also seeded from the
|
|
696
|
+
* state's local clock so callers do not lose counters that have advanced ahead
|
|
697
|
+
* of the currently materialized document tree.
|
|
698
|
+
*/
|
|
699
|
+
declare function observedVersionVector(target: Doc | CrdtState): VersionVector;
|
|
700
|
+
/** Combine version vectors using per-actor maxima. */
|
|
701
|
+
declare function mergeVersionVectors(...vectors: readonly VersionVector[]): VersionVector;
|
|
702
|
+
/**
|
|
703
|
+
* Derive a causally-stable checkpoint by taking the per-actor minimum.
|
|
704
|
+
*
|
|
705
|
+
* When called with a single vector the result equals that vector. In practice,
|
|
706
|
+
* a meaningful shared-stability checkpoint usually needs acknowledgements from
|
|
707
|
+
* at least two peers or from an explicit quorum.
|
|
708
|
+
*/
|
|
709
|
+
declare function intersectVersionVectors(...vectors: readonly VersionVector[]): VersionVector;
|
|
710
|
+
/** Check whether one version vector has observed every counter in another. */
|
|
711
|
+
declare function versionVectorCovers(observed: VersionVector, required: VersionVector): boolean;
|
|
712
|
+
//#endregion
|
|
631
713
|
//#region src/compact.d.ts
|
|
632
714
|
/**
|
|
633
715
|
* Compact causally-stable tombstones in a document.
|
|
@@ -660,4 +742,4 @@ declare class TraversalDepthError extends Error {
|
|
|
660
742
|
constructor(depth: number, maxDepth?: number);
|
|
661
743
|
}
|
|
662
744
|
//#endregion
|
|
663
|
-
export {
|
|
745
|
+
export { Clock as $, cloneClock as A, SerializedClock as At, forkState as B, TryDeserializeDocResult as Bt, diffJsonPatch as C, ObjEntry as Ct, stableJsonValueKey as D, ROOT_KEY as Dt, parseJsonPointer as E, PatchSemantics as Et, PatchError as F, TombstoneCompactionOptions as Ft, validateJsonPatch as G, ValidatePatchResult as Gt, tryApplyPatch as H, TryMergeDocResult as Ht, applyPatch as I, TombstoneCompactionStats as It, ApplyPatchAsActorOptions as J, ActorId as K, VersionVector as Kt, applyPatchAsActor as L, TryApplyPatchAsActorResult as Lt, nextDotForActor as M, SerializedNode as Mt, observeDot as N, SerializedRgaElem as Nt, stringifyJsonPointer as O, RgaElem as Ot, JsonValueValidationError as P, SerializedState as Pt, ApplyResult as Q, applyPatchInPlace as R, TryApplyPatchInPlaceResult as Rt, compileJsonPatchToIntent as S, Node as St, jsonEquals as T, PatchErrorReason as Tt, tryApplyPatchAsActor as U, TryMergeStateResult as Ut, toJson as V, TryDeserializeStateResult as Vt, tryApplyPatchInPlace as W, UnrelatedArraysStrategy as Wt, ApplyPatchInPlaceOptions as X, ApplyPatchAsActorResult as Y, ApplyPatchOptions as Z, serializeDoc as _, JsonValidationMode as _t, intersectVersionVectors as a, DeserializeErrorReason as at, tryDeserializeState as b, MergeDocOptions as bt, versionVectorCovers as c, Doc as ct, mergeState as d, ForkStateOptions as dt, CompactDocTombstonesResult as et, tryMergeDoc as f, IntentOp as ft, deserializeState as g, JsonPrimitive as gt, deserializeDoc as h, JsonPatchToCrdtOptions as ht, compactStateTombstones as i, CreateStateOptions as it, createClock as j, SerializedDoc as jt, ClockValidationError as k, RgaSeq as kt, MergeError as l, Dot as lt, DeserializeError as m, JsonPatchOp as mt, TraversalDepthError as n, CompilePatchOptions as nt, mergeVersionVectors as o, DeserializeFailure as ot, tryMergeState as p, JsonPatch as pt, ApplyError as q, compactDocTombstones as r, CrdtState as rt, observedVersionVector as s, DiffOptions as st, MAX_TRAVERSAL_DEPTH as t, CompactStateTombstonesResult as tt, mergeDoc as u, ElemId as ut, serializeState as v, JsonValue as vt, getAtJson as w, ObjNode as wt, PatchCompileError as x, MergeStateOptions as xt, tryDeserializeDoc as y, LwwReg as yt, createState as z, TryApplyPatchResult as zt };
|
|
@@ -17,8 +17,9 @@ type JsonValue = JsonPrimitive | JsonValue[] | {
|
|
|
17
17
|
/**
|
|
18
18
|
* Runtime handling mode for non-JSON inputs received through `any` / untyped callers.
|
|
19
19
|
* - `"none"`: keep current behavior (no extra runtime guardrails).
|
|
20
|
-
* - `"strict"`: reject invalid values (e.g. `NaN`, `Infinity`, `undefined`).
|
|
21
|
-
* - `"normalize"`: coerce invalid values into JSON-safe output.
|
|
20
|
+
* - `"strict"`: reject invalid values (e.g. `NaN`, `Infinity`, `undefined`, or non-plain objects like `Date`).
|
|
21
|
+
* - `"normalize"`: coerce invalid values into JSON-safe output. Non-plain objects become `null`
|
|
22
|
+
* at the root or in arrays, and are omitted from object properties.
|
|
22
23
|
*/
|
|
23
24
|
type JsonValidationMode = "none" | "strict" | "normalize";
|
|
24
25
|
/** Mutable clock that tracks an actor's identity and monotonic counter. */
|
|
@@ -87,20 +88,35 @@ type SerializedNode = {
|
|
|
87
88
|
kind: "seq";
|
|
88
89
|
elems: Record<string, SerializedRgaElem>;
|
|
89
90
|
};
|
|
90
|
-
/** JSON-serializable form of a CRDT document. */
|
|
91
|
-
|
|
91
|
+
/** Versioned JSON-serializable form of a CRDT document. */
|
|
92
|
+
interface SerializedDocV1 {
|
|
93
|
+
version: 1;
|
|
92
94
|
root: SerializedNode;
|
|
93
|
-
}
|
|
95
|
+
}
|
|
96
|
+
/** Legacy unversioned JSON-serializable form of a CRDT document. */
|
|
97
|
+
interface LegacySerializedDoc {
|
|
98
|
+
root: SerializedNode;
|
|
99
|
+
}
|
|
100
|
+
/** JSON-serializable form of a CRDT document. */
|
|
101
|
+
type SerializedDoc = SerializedDocV1 | LegacySerializedDoc;
|
|
94
102
|
/** JSON-serializable form of a clock. */
|
|
95
|
-
|
|
103
|
+
interface SerializedClock {
|
|
96
104
|
actor: ActorId;
|
|
97
105
|
ctr: number;
|
|
98
|
-
}
|
|
99
|
-
/** JSON-serializable form of a full CRDT state (document + clock). */
|
|
100
|
-
|
|
106
|
+
}
|
|
107
|
+
/** Versioned JSON-serializable form of a full CRDT state (document + clock). */
|
|
108
|
+
interface SerializedStateV1 {
|
|
109
|
+
version: 1;
|
|
101
110
|
doc: SerializedDoc;
|
|
102
111
|
clock: SerializedClock;
|
|
103
|
-
}
|
|
112
|
+
}
|
|
113
|
+
/** Legacy unversioned JSON-serializable form of a full CRDT state (document + clock). */
|
|
114
|
+
interface LegacySerializedState {
|
|
115
|
+
doc: SerializedDoc;
|
|
116
|
+
clock: SerializedClock;
|
|
117
|
+
}
|
|
118
|
+
/** JSON-serializable form of a full CRDT state (document + clock). */
|
|
119
|
+
type SerializedState = SerializedStateV1 | LegacySerializedState;
|
|
104
120
|
/** Typed reasons for rejecting malformed serialized CRDT payloads. */
|
|
105
121
|
type DeserializeErrorReason = "INVALID_SERIALIZED_SHAPE" | "INVALID_SERIALIZED_INVARIANT";
|
|
106
122
|
/** Structured failure payload used by non-throwing deserialize helpers. */
|
|
@@ -308,6 +324,16 @@ type ValidatePatchResult = {
|
|
|
308
324
|
ok: false;
|
|
309
325
|
error: ApplyError;
|
|
310
326
|
};
|
|
327
|
+
/**
|
|
328
|
+
* Merge strategy applied when two non-empty array sequences share no element lineage.
|
|
329
|
+
*
|
|
330
|
+
* - `"reject"` – abort the merge and return a `LINEAGE_MISMATCH` error (default).
|
|
331
|
+
* - `"atomic-replace"` – replace the losing array entirely with the one that has
|
|
332
|
+
* the higher representative dot (causal last-write-wins at the array level).
|
|
333
|
+
* - `"unsafe-union"` – union all elements from both sequences without any lineage
|
|
334
|
+
* check. Element ordering may be non-deterministic across peers.
|
|
335
|
+
*/
|
|
336
|
+
type UnrelatedArraysStrategy = "reject" | "atomic-replace" | "unsafe-union";
|
|
311
337
|
/** Options for `mergeState`. */
|
|
312
338
|
type MergeStateOptions = {
|
|
313
339
|
/**
|
|
@@ -316,16 +342,30 @@ type MergeStateOptions = {
|
|
|
316
342
|
*/
|
|
317
343
|
actor?: ActorId;
|
|
318
344
|
/**
|
|
319
|
-
*
|
|
320
|
-
* Defaults to `
|
|
345
|
+
* Strategy for merging unrelated (non-overlapping) non-empty array sequences.
|
|
346
|
+
* Defaults to `"reject"`.
|
|
347
|
+
*/
|
|
348
|
+
unrelatedArrays?: UnrelatedArraysStrategy;
|
|
349
|
+
/**
|
|
350
|
+
* @deprecated Use `unrelatedArrays` instead.
|
|
351
|
+
* When `true`, behaves like `unrelatedArrays: "reject"`.
|
|
352
|
+
* When `false`, behaves like `unrelatedArrays: "unsafe-union"`.
|
|
353
|
+
* Ignored when `unrelatedArrays` is also provided.
|
|
321
354
|
*/
|
|
322
355
|
requireSharedOrigin?: boolean;
|
|
323
356
|
};
|
|
324
357
|
/** Options for `mergeDoc`. */
|
|
325
358
|
type MergeDocOptions = {
|
|
326
359
|
/**
|
|
327
|
-
*
|
|
328
|
-
* Defaults to `
|
|
360
|
+
* Strategy for merging unrelated (non-overlapping) non-empty array sequences.
|
|
361
|
+
* Defaults to `"reject"`.
|
|
362
|
+
*/
|
|
363
|
+
unrelatedArrays?: UnrelatedArraysStrategy;
|
|
364
|
+
/**
|
|
365
|
+
* @deprecated Use `unrelatedArrays` instead.
|
|
366
|
+
* When `true`, behaves like `unrelatedArrays: "reject"`.
|
|
367
|
+
* When `false`, behaves like `unrelatedArrays: "unsafe-union"`.
|
|
368
|
+
* Ignored when `unrelatedArrays` is also provided.
|
|
329
369
|
*/
|
|
330
370
|
requireSharedOrigin?: boolean;
|
|
331
371
|
};
|
|
@@ -403,6 +443,19 @@ type DiffOptions = {
|
|
|
403
443
|
* Set to `Number.POSITIVE_INFINITY` to always allow LCS.
|
|
404
444
|
*/
|
|
405
445
|
lcsMaxCells?: number;
|
|
446
|
+
/**
|
|
447
|
+
* Optional guardrail for `arrayStrategy: "lcs-linear"`.
|
|
448
|
+
* Uses the trimmed unmatched window size
|
|
449
|
+
* (`(unmatchedBase.length + 1) * (unmatchedNext.length + 1)`) as a proxy for
|
|
450
|
+
* worst-case work. When the cap is exceeded, the diff falls back to an atomic
|
|
451
|
+
* array replacement instead of running the linear-space traversal.
|
|
452
|
+
*
|
|
453
|
+
* Unlike `lcsMaxCells`, this is opt-in and defaults to no fallback so
|
|
454
|
+
* existing `lcs-linear` callers keep their current behavior.
|
|
455
|
+
*
|
|
456
|
+
* Set to `Number.POSITIVE_INFINITY` to always allow `lcs-linear`.
|
|
457
|
+
*/
|
|
458
|
+
lcsLinearMaxCells?: number;
|
|
406
459
|
/**
|
|
407
460
|
* Emit RFC 6902 `move` operations when a deterministic remove/add rewrite is available.
|
|
408
461
|
* Defaults to `false` for backward compatibility.
|
|
@@ -556,8 +609,8 @@ declare function compileJsonPatchToIntent(baseJson: JsonValue, patch: JsonPatchO
|
|
|
556
609
|
* By default arrays use a deterministic LCS strategy.
|
|
557
610
|
* Pass `{ arrayStrategy: "atomic" }` for single-op array replacement.
|
|
558
611
|
* Pass `{ arrayStrategy: "lcs-linear" }` for a lower-memory LCS variant.
|
|
559
|
-
*
|
|
560
|
-
*
|
|
612
|
+
* Use `lcsLinearMaxCells` to optionally cap worst-case `lcs-linear` work and
|
|
613
|
+
* fall back to an atomic array replacement for very large unmatched windows.
|
|
561
614
|
* Pass `{ emitMoves: true }` or `{ emitCopies: true }` to opt into RFC 6902
|
|
562
615
|
* move/copy emission when a deterministic rewrite is available.
|
|
563
616
|
* @param base - The original JSON value.
|
|
@@ -566,6 +619,8 @@ declare function compileJsonPatchToIntent(baseJson: JsonValue, patch: JsonPatchO
|
|
|
566
619
|
* @returns An array of JSON Patch operations that transform `base` into `next`.
|
|
567
620
|
*/
|
|
568
621
|
declare function diffJsonPatch(base: JsonValue, next: JsonValue, options?: DiffOptions): JsonPatchOp[];
|
|
622
|
+
/** @internal Stable structural fingerprint used for deterministic diff rewrites. */
|
|
623
|
+
declare function stableJsonValueKey(value: JsonValue, structuralKeyCache?: WeakMap<object, string>): string;
|
|
569
624
|
/** Deep equality check for JSON values (null-safe, handles arrays and objects). */
|
|
570
625
|
declare function jsonEquals(a: JsonValue, b: JsonValue): boolean;
|
|
571
626
|
//#endregion
|
|
@@ -584,7 +639,12 @@ declare function deserializeDoc(data: SerializedDoc): Doc;
|
|
|
584
639
|
declare function tryDeserializeDoc(data: SerializedDoc): TryDeserializeDocResult;
|
|
585
640
|
/** Serialize a full CRDT state (document + clock) to a JSON-safe representation. */
|
|
586
641
|
declare function serializeState(state: CrdtState): SerializedState;
|
|
587
|
-
/**
|
|
642
|
+
/**
|
|
643
|
+
* Reconstruct a full CRDT state from its serialized form, restoring the clock.
|
|
644
|
+
*
|
|
645
|
+
* May throw `TraversalDepthError` when the payload exceeds the maximum
|
|
646
|
+
* supported nesting depth.
|
|
647
|
+
*/
|
|
588
648
|
declare function deserializeState(data: SerializedState): CrdtState;
|
|
589
649
|
/** Non-throwing `deserializeState` variant with typed validation details. */
|
|
590
650
|
declare function tryDeserializeState(data: SerializedState): TryDeserializeStateResult;
|
|
@@ -619,7 +679,7 @@ declare function tryMergeDoc(a: Doc, b: Doc, options?: MergeDocOptions): TryMerg
|
|
|
619
679
|
* The merged clock keeps a stable actor identity:
|
|
620
680
|
* - defaults to the actor from the first argument (`a`)
|
|
621
681
|
* - can be overridden via `options.actor`
|
|
622
|
-
* - optional `options.
|
|
682
|
+
* - optional `options.unrelatedArrays` controls the merge strategy for non-overlapping sequences
|
|
623
683
|
*
|
|
624
684
|
* The merged counter is lifted to the highest counter already observed for
|
|
625
685
|
* that actor across both input clocks and the merged document dots.
|
|
@@ -628,6 +688,28 @@ declare function mergeState(a: CrdtState, b: CrdtState, options?: MergeStateOpti
|
|
|
628
688
|
/** Non-throwing `mergeState` variant with structured conflict details. */
|
|
629
689
|
declare function tryMergeState(a: CrdtState, b: CrdtState, options?: MergeStateOptions): TryMergeStateResult;
|
|
630
690
|
//#endregion
|
|
691
|
+
//#region src/version-vector.d.ts
|
|
692
|
+
/**
|
|
693
|
+
* Inspect a document or state and return the highest observed counter per actor.
|
|
694
|
+
*
|
|
695
|
+
* When a `CrdtState` is provided, the returned vector is also seeded from the
|
|
696
|
+
* state's local clock so callers do not lose counters that have advanced ahead
|
|
697
|
+
* of the currently materialized document tree.
|
|
698
|
+
*/
|
|
699
|
+
declare function observedVersionVector(target: Doc | CrdtState): VersionVector;
|
|
700
|
+
/** Combine version vectors using per-actor maxima. */
|
|
701
|
+
declare function mergeVersionVectors(...vectors: readonly VersionVector[]): VersionVector;
|
|
702
|
+
/**
|
|
703
|
+
* Derive a causally-stable checkpoint by taking the per-actor minimum.
|
|
704
|
+
*
|
|
705
|
+
* When called with a single vector the result equals that vector. In practice,
|
|
706
|
+
* a meaningful shared-stability checkpoint usually needs acknowledgements from
|
|
707
|
+
* at least two peers or from an explicit quorum.
|
|
708
|
+
*/
|
|
709
|
+
declare function intersectVersionVectors(...vectors: readonly VersionVector[]): VersionVector;
|
|
710
|
+
/** Check whether one version vector has observed every counter in another. */
|
|
711
|
+
declare function versionVectorCovers(observed: VersionVector, required: VersionVector): boolean;
|
|
712
|
+
//#endregion
|
|
631
713
|
//#region src/compact.d.ts
|
|
632
714
|
/**
|
|
633
715
|
* Compact causally-stable tombstones in a document.
|
|
@@ -660,4 +742,4 @@ declare class TraversalDepthError extends Error {
|
|
|
660
742
|
constructor(depth: number, maxDepth?: number);
|
|
661
743
|
}
|
|
662
744
|
//#endregion
|
|
663
|
-
export {
|
|
745
|
+
export { Clock as $, cloneClock as A, SerializedClock as At, forkState as B, TryDeserializeDocResult as Bt, diffJsonPatch as C, ObjEntry as Ct, stableJsonValueKey as D, ROOT_KEY as Dt, parseJsonPointer as E, PatchSemantics as Et, PatchError as F, TombstoneCompactionOptions as Ft, validateJsonPatch as G, ValidatePatchResult as Gt, tryApplyPatch as H, TryMergeDocResult as Ht, applyPatch as I, TombstoneCompactionStats as It, ApplyPatchAsActorOptions as J, ActorId as K, VersionVector as Kt, applyPatchAsActor as L, TryApplyPatchAsActorResult as Lt, nextDotForActor as M, SerializedNode as Mt, observeDot as N, SerializedRgaElem as Nt, stringifyJsonPointer as O, RgaElem as Ot, JsonValueValidationError as P, SerializedState as Pt, ApplyResult as Q, applyPatchInPlace as R, TryApplyPatchInPlaceResult as Rt, compileJsonPatchToIntent as S, Node as St, jsonEquals as T, PatchErrorReason as Tt, tryApplyPatchAsActor as U, TryMergeStateResult as Ut, toJson as V, TryDeserializeStateResult as Vt, tryApplyPatchInPlace as W, UnrelatedArraysStrategy as Wt, ApplyPatchInPlaceOptions as X, ApplyPatchAsActorResult as Y, ApplyPatchOptions as Z, serializeDoc as _, JsonValidationMode as _t, intersectVersionVectors as a, DeserializeErrorReason as at, tryDeserializeState as b, MergeDocOptions as bt, versionVectorCovers as c, Doc as ct, mergeState as d, ForkStateOptions as dt, CompactDocTombstonesResult as et, tryMergeDoc as f, IntentOp as ft, deserializeState as g, JsonPrimitive as gt, deserializeDoc as h, JsonPatchToCrdtOptions as ht, compactStateTombstones as i, CreateStateOptions as it, createClock as j, SerializedDoc as jt, ClockValidationError as k, RgaSeq as kt, MergeError as l, Dot as lt, DeserializeError as m, JsonPatchOp as mt, TraversalDepthError as n, CompilePatchOptions as nt, mergeVersionVectors as o, DeserializeFailure as ot, tryMergeState as p, JsonPatch as pt, ApplyError as q, compactDocTombstones as r, CrdtState as rt, observedVersionVector as s, DiffOptions as st, MAX_TRAVERSAL_DEPTH as t, CompactStateTombstonesResult as tt, mergeDoc as u, ElemId as ut, serializeState as v, JsonValue as vt, getAtJson as w, ObjNode as wt, PatchCompileError as x, MergeStateOptions as xt, tryDeserializeDoc as y, LwwReg as yt, createState as z, TryApplyPatchResult as zt };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { type ActorId, type ApplyError, type ApplyPatchInPlaceOptions, type ApplyPatchOptions, ClockValidationError, type CompactStateTombstonesResult, type CrdtState, type CreateStateOptions, DeserializeError, type DeserializeErrorReason, type DeserializeFailure, type DiffOptions, type ForkStateOptions, type JsonPatch, type JsonPatchOp, type JsonPrimitive, type JsonValidationMode, type JsonValue, JsonValueValidationError, MAX_TRAVERSAL_DEPTH, MergeError, type MergeStateOptions, PatchError, type PatchErrorReason, type PatchSemantics, type SerializedState, type TombstoneCompactionOptions, type TombstoneCompactionStats, TraversalDepthError, type TryApplyPatchInPlaceResult, type TryApplyPatchResult, type TryDeserializeStateResult, type TryMergeStateResult, type ValidatePatchResult, applyPatch, applyPatchInPlace, compactStateTombstones, createState, deserializeState, diffJsonPatch, forkState, mergeState, serializeState, toJson, tryApplyPatch, tryApplyPatchInPlace, tryDeserializeState, tryMergeState, validateJsonPatch };
|
|
1
|
+
import { B as forkState, C as diffJsonPatch, Et as PatchSemantics, F as PatchError, Ft as TombstoneCompactionOptions, G as validateJsonPatch, Gt as ValidatePatchResult, H as tryApplyPatch, I as applyPatch, It as TombstoneCompactionStats, K as ActorId, P as JsonValueValidationError, Pt as SerializedState, R as applyPatchInPlace, Rt as TryApplyPatchInPlaceResult, Tt as PatchErrorReason, Ut as TryMergeStateResult, V as toJson, Vt as TryDeserializeStateResult, W as tryApplyPatchInPlace, Wt as UnrelatedArraysStrategy, X as ApplyPatchInPlaceOptions, Z as ApplyPatchOptions, _t as JsonValidationMode, a as intersectVersionVectors, at as DeserializeErrorReason, b as tryDeserializeState, c as versionVectorCovers, d as mergeState, dt as ForkStateOptions, g as deserializeState, gt as JsonPrimitive, i as compactStateTombstones, it as CreateStateOptions, k as ClockValidationError, l as MergeError, m as DeserializeError, mt as JsonPatchOp, n as TraversalDepthError, o as mergeVersionVectors, ot as DeserializeFailure, p as tryMergeState, pt as JsonPatch, q as ApplyError, rt as CrdtState, s as observedVersionVector, st as DiffOptions, t as MAX_TRAVERSAL_DEPTH, tt as CompactStateTombstonesResult, v as serializeState, vt as JsonValue, xt as MergeStateOptions, z as createState, zt as TryApplyPatchResult } from "./depth-CM1kCxhm.mjs";
|
|
2
|
+
export { type ActorId, type ApplyError, type ApplyPatchInPlaceOptions, type ApplyPatchOptions, ClockValidationError, type CompactStateTombstonesResult, type CrdtState, type CreateStateOptions, DeserializeError, type DeserializeErrorReason, type DeserializeFailure, type DiffOptions, type ForkStateOptions, type JsonPatch, type JsonPatchOp, type JsonPrimitive, type JsonValidationMode, type JsonValue, JsonValueValidationError, MAX_TRAVERSAL_DEPTH, MergeError, type MergeStateOptions, PatchError, type PatchErrorReason, type PatchSemantics, type SerializedState, type TombstoneCompactionOptions, type TombstoneCompactionStats, TraversalDepthError, type TryApplyPatchInPlaceResult, type TryApplyPatchResult, type TryDeserializeStateResult, type TryMergeStateResult, type UnrelatedArraysStrategy, type ValidatePatchResult, applyPatch, applyPatchInPlace, compactStateTombstones, createState, deserializeState, diffJsonPatch, forkState, intersectVersionVectors, mergeState, mergeVersionVectors, observedVersionVector, serializeState, toJson, tryApplyPatch, tryApplyPatchInPlace, tryDeserializeState, tryMergeState, validateJsonPatch, versionVectorCovers };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { type ActorId, type ApplyError, type ApplyPatchInPlaceOptions, type ApplyPatchOptions, ClockValidationError, type CompactStateTombstonesResult, type CrdtState, type CreateStateOptions, DeserializeError, type DeserializeErrorReason, type DeserializeFailure, type DiffOptions, type ForkStateOptions, type JsonPatch, type JsonPatchOp, type JsonPrimitive, type JsonValidationMode, type JsonValue, JsonValueValidationError, MAX_TRAVERSAL_DEPTH, MergeError, type MergeStateOptions, PatchError, type PatchErrorReason, type PatchSemantics, type SerializedState, type TombstoneCompactionOptions, type TombstoneCompactionStats, TraversalDepthError, type TryApplyPatchInPlaceResult, type TryApplyPatchResult, type TryDeserializeStateResult, type TryMergeStateResult, type ValidatePatchResult, applyPatch, applyPatchInPlace, compactStateTombstones, createState, deserializeState, diffJsonPatch, forkState, mergeState, serializeState, toJson, tryApplyPatch, tryApplyPatchInPlace, tryDeserializeState, tryMergeState, validateJsonPatch };
|
|
1
|
+
import { B as forkState, C as diffJsonPatch, Et as PatchSemantics, F as PatchError, Ft as TombstoneCompactionOptions, G as validateJsonPatch, Gt as ValidatePatchResult, H as tryApplyPatch, I as applyPatch, It as TombstoneCompactionStats, K as ActorId, P as JsonValueValidationError, Pt as SerializedState, R as applyPatchInPlace, Rt as TryApplyPatchInPlaceResult, Tt as PatchErrorReason, Ut as TryMergeStateResult, V as toJson, Vt as TryDeserializeStateResult, W as tryApplyPatchInPlace, Wt as UnrelatedArraysStrategy, X as ApplyPatchInPlaceOptions, Z as ApplyPatchOptions, _t as JsonValidationMode, a as intersectVersionVectors, at as DeserializeErrorReason, b as tryDeserializeState, c as versionVectorCovers, d as mergeState, dt as ForkStateOptions, g as deserializeState, gt as JsonPrimitive, i as compactStateTombstones, it as CreateStateOptions, k as ClockValidationError, l as MergeError, m as DeserializeError, mt as JsonPatchOp, n as TraversalDepthError, o as mergeVersionVectors, ot as DeserializeFailure, p as tryMergeState, pt as JsonPatch, q as ApplyError, rt as CrdtState, s as observedVersionVector, st as DiffOptions, t as MAX_TRAVERSAL_DEPTH, tt as CompactStateTombstonesResult, v as serializeState, vt as JsonValue, xt as MergeStateOptions, z as createState, zt as TryApplyPatchResult } from "./depth-NbZ6Giq9.js";
|
|
2
|
+
export { type ActorId, type ApplyError, type ApplyPatchInPlaceOptions, type ApplyPatchOptions, ClockValidationError, type CompactStateTombstonesResult, type CrdtState, type CreateStateOptions, DeserializeError, type DeserializeErrorReason, type DeserializeFailure, type DiffOptions, type ForkStateOptions, type JsonPatch, type JsonPatchOp, type JsonPrimitive, type JsonValidationMode, type JsonValue, JsonValueValidationError, MAX_TRAVERSAL_DEPTH, MergeError, type MergeStateOptions, PatchError, type PatchErrorReason, type PatchSemantics, type SerializedState, type TombstoneCompactionOptions, type TombstoneCompactionStats, TraversalDepthError, type TryApplyPatchInPlaceResult, type TryApplyPatchResult, type TryDeserializeStateResult, type TryMergeStateResult, type UnrelatedArraysStrategy, type ValidatePatchResult, applyPatch, applyPatchInPlace, compactStateTombstones, createState, deserializeState, diffJsonPatch, forkState, intersectVersionVectors, mergeState, mergeVersionVectors, observedVersionVector, serializeState, toJson, tryApplyPatch, tryApplyPatchInPlace, tryDeserializeState, tryMergeState, validateJsonPatch, versionVectorCovers };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_compact = require('./compact-
|
|
2
|
+
const require_compact = require('./compact-CDvajUfn.js');
|
|
3
3
|
|
|
4
4
|
exports.ClockValidationError = require_compact.ClockValidationError;
|
|
5
5
|
exports.DeserializeError = require_compact.DeserializeError;
|
|
@@ -15,11 +15,15 @@ exports.createState = require_compact.createState;
|
|
|
15
15
|
exports.deserializeState = require_compact.deserializeState;
|
|
16
16
|
exports.diffJsonPatch = require_compact.diffJsonPatch;
|
|
17
17
|
exports.forkState = require_compact.forkState;
|
|
18
|
+
exports.intersectVersionVectors = require_compact.intersectVersionVectors;
|
|
18
19
|
exports.mergeState = require_compact.mergeState;
|
|
20
|
+
exports.mergeVersionVectors = require_compact.mergeVersionVectors;
|
|
21
|
+
exports.observedVersionVector = require_compact.observedVersionVector;
|
|
19
22
|
exports.serializeState = require_compact.serializeState;
|
|
20
23
|
exports.toJson = require_compact.toJson;
|
|
21
24
|
exports.tryApplyPatch = require_compact.tryApplyPatch;
|
|
22
25
|
exports.tryApplyPatchInPlace = require_compact.tryApplyPatchInPlace;
|
|
23
26
|
exports.tryDeserializeState = require_compact.tryDeserializeState;
|
|
24
27
|
exports.tryMergeState = require_compact.tryMergeState;
|
|
25
|
-
exports.validateJsonPatch = require_compact.validateJsonPatch;
|
|
28
|
+
exports.validateJsonPatch = require_compact.validateJsonPatch;
|
|
29
|
+
exports.versionVectorCovers = require_compact.versionVectorCovers;
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { R as diffJsonPatch, S as tryApplyPatch,
|
|
1
|
+
import { Ct as TraversalDepthError, G as JsonValueValidationError, R as diffJsonPatch, S as tryApplyPatch, St as MAX_TRAVERSAL_DEPTH, T as validateJsonPatch, a as mergeState, b as forkState, bt as observedVersionVector, c as DeserializeError, f as serializeState, g as applyPatch, h as PatchError, m as tryDeserializeState, n as compactStateTombstones, pt as ClockValidationError, r as MergeError, s as tryMergeState, u as deserializeState, v as applyPatchInPlace, vt as intersectVersionVectors, w as tryApplyPatchInPlace, x as toJson, xt as versionVectorCovers, y as createState, yt as mergeVersionVectors } from "./compact-Dj0BYeY5.mjs";
|
|
2
2
|
|
|
3
|
-
export { ClockValidationError, DeserializeError, JsonValueValidationError, MAX_TRAVERSAL_DEPTH, MergeError, PatchError, TraversalDepthError, applyPatch, applyPatchInPlace, compactStateTombstones, createState, deserializeState, diffJsonPatch, forkState, mergeState, serializeState, toJson, tryApplyPatch, tryApplyPatchInPlace, tryDeserializeState, tryMergeState, validateJsonPatch };
|
|
3
|
+
export { ClockValidationError, DeserializeError, JsonValueValidationError, MAX_TRAVERSAL_DEPTH, MergeError, PatchError, TraversalDepthError, applyPatch, applyPatchInPlace, compactStateTombstones, createState, deserializeState, diffJsonPatch, forkState, intersectVersionVectors, mergeState, mergeVersionVectors, observedVersionVector, serializeState, toJson, tryApplyPatch, tryApplyPatchInPlace, tryDeserializeState, tryMergeState, validateJsonPatch, versionVectorCovers };
|
package/dist/internals.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as Clock, A as cloneClock, At as SerializedClock, B as forkState, Bt as TryDeserializeDocResult, C as diffJsonPatch, Ct as ObjEntry, D as stableJsonValueKey, Dt as ROOT_KEY, E as parseJsonPointer, Et as PatchSemantics, F as PatchError, Ft as TombstoneCompactionOptions, G as validateJsonPatch, Gt as ValidatePatchResult, H as tryApplyPatch, Ht as TryMergeDocResult, I as applyPatch, It as TombstoneCompactionStats, J as ApplyPatchAsActorOptions, K as ActorId, Kt as VersionVector, L as applyPatchAsActor, Lt as TryApplyPatchAsActorResult, M as nextDotForActor, Mt as SerializedNode, N as observeDot, Nt as SerializedRgaElem, O as stringifyJsonPointer, Ot as RgaElem, P as JsonValueValidationError, Pt as SerializedState, Q as ApplyResult, R as applyPatchInPlace, Rt as TryApplyPatchInPlaceResult, S as compileJsonPatchToIntent, St as Node, T as jsonEquals, Tt as PatchErrorReason, U as tryApplyPatchAsActor, Ut as TryMergeStateResult, V as toJson, Vt as TryDeserializeStateResult, W as tryApplyPatchInPlace, Wt as UnrelatedArraysStrategy, X as ApplyPatchInPlaceOptions, Y as ApplyPatchAsActorResult, Z as ApplyPatchOptions, _ as serializeDoc, _t as JsonValidationMode, a as intersectVersionVectors, at as DeserializeErrorReason, b as tryDeserializeState, bt as MergeDocOptions, c as versionVectorCovers, ct as Doc, d as mergeState, dt as ForkStateOptions, et as CompactDocTombstonesResult, f as tryMergeDoc, ft as IntentOp, g as deserializeState, gt as JsonPrimitive, h as deserializeDoc, ht as JsonPatchToCrdtOptions, i as compactStateTombstones, it as CreateStateOptions, j as createClock, jt as SerializedDoc, k as ClockValidationError, kt as RgaSeq, l as MergeError, lt as Dot, m as DeserializeError, mt as JsonPatchOp, n as TraversalDepthError, nt as CompilePatchOptions, o as mergeVersionVectors, ot as DeserializeFailure, p as tryMergeState, pt as JsonPatch, q as ApplyError, r as compactDocTombstones, rt as CrdtState, s as observedVersionVector, st as DiffOptions, t as MAX_TRAVERSAL_DEPTH, tt as CompactStateTombstonesResult, u as mergeDoc, ut as ElemId, v as serializeState, vt as JsonValue, w as getAtJson, wt as ObjNode, x as PatchCompileError, xt as MergeStateOptions, y as tryDeserializeDoc, yt as LwwReg, z as createState, zt as TryApplyPatchResult } from "./depth-CM1kCxhm.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/doc.d.ts
|
|
4
4
|
/**
|
|
@@ -9,8 +9,15 @@ import { $ as CreateStateOptions, A as PatchError, At as TombstoneCompactionOpti
|
|
|
9
9
|
*/
|
|
10
10
|
declare function docFromJson(value: JsonValue, nextDot: () => Dot): Doc;
|
|
11
11
|
/**
|
|
12
|
-
* Legacy
|
|
13
|
-
*
|
|
12
|
+
* Legacy helper for tests and fixtures that seeds an entire document from one dot.
|
|
13
|
+
*
|
|
14
|
+
* It reuses that dot for object entries and synthesizes array child counters from the
|
|
15
|
+
* same seed, which can produce low-quality causal metadata and unrealistic sequence
|
|
16
|
+
* identities in production CRDT state.
|
|
17
|
+
*
|
|
18
|
+
* Prefer `docFromJson(value, nextDot)` so every node receives a fresh unique dot.
|
|
19
|
+
*
|
|
20
|
+
* @deprecated Use `docFromJson(value, nextDot)` for production documents.
|
|
14
21
|
*/
|
|
15
22
|
declare function docFromJsonWithDot(value: JsonValue, dot: Dot): Doc;
|
|
16
23
|
/** Deep-clone a CRDT document. The clone is fully independent of the original. */
|
|
@@ -128,4 +135,4 @@ declare function rgaCompactTombstones(seq: RgaSeq, isStable: (dot: Dot) => boole
|
|
|
128
135
|
declare function rgaIdAtIndex(seq: RgaSeq, index: number): ElemId | undefined;
|
|
129
136
|
declare function rgaPrevForInsertAtIndex(seq: RgaSeq, index: number): ElemId;
|
|
130
137
|
//#endregion
|
|
131
|
-
export { ActorId, ApplyError, type ApplyPatchAsActorOptions, type ApplyPatchAsActorResult, ApplyPatchInPlaceOptions, ApplyPatchOptions, type ApplyResult, type Clock, ClockValidationError, type CompactDocTombstonesResult, type CompactStateTombstonesResult, type CompilePatchOptions, CrdtState, CreateStateOptions, DeserializeError, DeserializeErrorReason, type DeserializeFailure, DiffOptions, type Doc, type Dot, type ElemId, ForkStateOptions, HEAD, type IntentOp, JsonPatch, JsonPatchOp, type JsonPatchToCrdtOptions, JsonPrimitive, JsonValidationMode, JsonValue, JsonValueValidationError, type LwwReg, MAX_TRAVERSAL_DEPTH, type MergeDocOptions, MergeError, MergeStateOptions, type Node, type ObjEntry, type ObjNode, PatchCompileError, PatchError, PatchErrorReason, PatchSemantics, ROOT_KEY, type RgaElem, type RgaSeq, type RgaValidationIssue, type RgaValidationResult, type SerializedClock, type SerializedDoc, type SerializedNode, type SerializedRgaElem, SerializedState, type TombstoneCompactionOptions, type TombstoneCompactionStats, TraversalDepthError, type TryApplyPatchAsActorResult, TryApplyPatchInPlaceResult, TryApplyPatchResult, type TryDeserializeDocResult, TryDeserializeStateResult, type TryMergeDocResult, TryMergeStateResult, ValidatePatchResult, type VersionVector, applyIntentsToCrdt, applyPatch, applyPatchAsActor, applyPatchInPlace, cloneClock, cloneDoc, compactDocTombstones, compactStateTombstones, compareDot, compileJsonPatchToIntent, crdtNodesToJsonPatch, crdtToFullReplace, crdtToJsonPatch, createClock, createState, deserializeDoc, deserializeState, diffJsonPatch, docFromJson, docFromJsonWithDot, dotToElemId, forkState, getAtJson, jsonEquals, jsonPatchToCrdt, jsonPatchToCrdtSafe, lwwSet, materialize, mergeDoc, mergeState, newObj, newReg, newSeq, nextDotForActor, objCompactTombstones, objRemove, objSet, observeDot, parseJsonPointer, rgaCompactTombstones, rgaDelete, rgaIdAtIndex, rgaInsertAfter, rgaInsertAfterChecked, rgaLinearizeIds, rgaPrevForInsertAtIndex, serializeDoc, serializeState, stringifyJsonPointer, toJson, tryApplyPatch, tryApplyPatchAsActor, tryApplyPatchInPlace, tryDeserializeDoc, tryDeserializeState, tryJsonPatchToCrdt, tryMergeDoc, tryMergeState, validateJsonPatch, validateRgaSeq, vvHasDot, vvMerge };
|
|
138
|
+
export { ActorId, ApplyError, type ApplyPatchAsActorOptions, type ApplyPatchAsActorResult, ApplyPatchInPlaceOptions, ApplyPatchOptions, type ApplyResult, type Clock, ClockValidationError, type CompactDocTombstonesResult, type CompactStateTombstonesResult, type CompilePatchOptions, CrdtState, CreateStateOptions, DeserializeError, DeserializeErrorReason, type DeserializeFailure, DiffOptions, type Doc, type Dot, type ElemId, ForkStateOptions, HEAD, type IntentOp, JsonPatch, JsonPatchOp, type JsonPatchToCrdtOptions, JsonPrimitive, JsonValidationMode, JsonValue, JsonValueValidationError, type LwwReg, MAX_TRAVERSAL_DEPTH, type MergeDocOptions, MergeError, MergeStateOptions, type Node, type ObjEntry, type ObjNode, PatchCompileError, PatchError, PatchErrorReason, PatchSemantics, ROOT_KEY, type RgaElem, type RgaSeq, type RgaValidationIssue, type RgaValidationResult, type SerializedClock, type SerializedDoc, type SerializedNode, type SerializedRgaElem, SerializedState, type TombstoneCompactionOptions, type TombstoneCompactionStats, TraversalDepthError, type TryApplyPatchAsActorResult, TryApplyPatchInPlaceResult, TryApplyPatchResult, type TryDeserializeDocResult, TryDeserializeStateResult, type TryMergeDocResult, TryMergeStateResult, type UnrelatedArraysStrategy, ValidatePatchResult, type VersionVector, applyIntentsToCrdt, applyPatch, applyPatchAsActor, applyPatchInPlace, cloneClock, cloneDoc, compactDocTombstones, compactStateTombstones, compareDot, compileJsonPatchToIntent, crdtNodesToJsonPatch, crdtToFullReplace, crdtToJsonPatch, createClock, createState, deserializeDoc, deserializeState, diffJsonPatch, docFromJson, docFromJsonWithDot, dotToElemId, forkState, getAtJson, intersectVersionVectors, jsonEquals, jsonPatchToCrdt, jsonPatchToCrdtSafe, lwwSet, materialize, mergeDoc, mergeState, mergeVersionVectors, newObj, newReg, newSeq, nextDotForActor, objCompactTombstones, objRemove, objSet, observeDot, observedVersionVector, parseJsonPointer, rgaCompactTombstones, rgaDelete, rgaIdAtIndex, rgaInsertAfter, rgaInsertAfterChecked, rgaLinearizeIds, rgaPrevForInsertAtIndex, serializeDoc, serializeState, stableJsonValueKey, stringifyJsonPointer, toJson, tryApplyPatch, tryApplyPatchAsActor, tryApplyPatchInPlace, tryDeserializeDoc, tryDeserializeState, tryJsonPatchToCrdt, tryMergeDoc, tryMergeState, validateJsonPatch, validateRgaSeq, versionVectorCovers, vvHasDot, vvMerge };
|
package/dist/internals.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as Clock, A as cloneClock, At as SerializedClock, B as forkState, Bt as TryDeserializeDocResult, C as diffJsonPatch, Ct as ObjEntry, D as stableJsonValueKey, Dt as ROOT_KEY, E as parseJsonPointer, Et as PatchSemantics, F as PatchError, Ft as TombstoneCompactionOptions, G as validateJsonPatch, Gt as ValidatePatchResult, H as tryApplyPatch, Ht as TryMergeDocResult, I as applyPatch, It as TombstoneCompactionStats, J as ApplyPatchAsActorOptions, K as ActorId, Kt as VersionVector, L as applyPatchAsActor, Lt as TryApplyPatchAsActorResult, M as nextDotForActor, Mt as SerializedNode, N as observeDot, Nt as SerializedRgaElem, O as stringifyJsonPointer, Ot as RgaElem, P as JsonValueValidationError, Pt as SerializedState, Q as ApplyResult, R as applyPatchInPlace, Rt as TryApplyPatchInPlaceResult, S as compileJsonPatchToIntent, St as Node, T as jsonEquals, Tt as PatchErrorReason, U as tryApplyPatchAsActor, Ut as TryMergeStateResult, V as toJson, Vt as TryDeserializeStateResult, W as tryApplyPatchInPlace, Wt as UnrelatedArraysStrategy, X as ApplyPatchInPlaceOptions, Y as ApplyPatchAsActorResult, Z as ApplyPatchOptions, _ as serializeDoc, _t as JsonValidationMode, a as intersectVersionVectors, at as DeserializeErrorReason, b as tryDeserializeState, bt as MergeDocOptions, c as versionVectorCovers, ct as Doc, d as mergeState, dt as ForkStateOptions, et as CompactDocTombstonesResult, f as tryMergeDoc, ft as IntentOp, g as deserializeState, gt as JsonPrimitive, h as deserializeDoc, ht as JsonPatchToCrdtOptions, i as compactStateTombstones, it as CreateStateOptions, j as createClock, jt as SerializedDoc, k as ClockValidationError, kt as RgaSeq, l as MergeError, lt as Dot, m as DeserializeError, mt as JsonPatchOp, n as TraversalDepthError, nt as CompilePatchOptions, o as mergeVersionVectors, ot as DeserializeFailure, p as tryMergeState, pt as JsonPatch, q as ApplyError, r as compactDocTombstones, rt as CrdtState, s as observedVersionVector, st as DiffOptions, t as MAX_TRAVERSAL_DEPTH, tt as CompactStateTombstonesResult, u as mergeDoc, ut as ElemId, v as serializeState, vt as JsonValue, w as getAtJson, wt as ObjNode, x as PatchCompileError, xt as MergeStateOptions, y as tryDeserializeDoc, yt as LwwReg, z as createState, zt as TryApplyPatchResult } from "./depth-NbZ6Giq9.js";
|
|
2
2
|
|
|
3
3
|
//#region src/doc.d.ts
|
|
4
4
|
/**
|
|
@@ -9,8 +9,15 @@ import { $ as CreateStateOptions, A as PatchError, At as TombstoneCompactionOpti
|
|
|
9
9
|
*/
|
|
10
10
|
declare function docFromJson(value: JsonValue, nextDot: () => Dot): Doc;
|
|
11
11
|
/**
|
|
12
|
-
* Legacy
|
|
13
|
-
*
|
|
12
|
+
* Legacy helper for tests and fixtures that seeds an entire document from one dot.
|
|
13
|
+
*
|
|
14
|
+
* It reuses that dot for object entries and synthesizes array child counters from the
|
|
15
|
+
* same seed, which can produce low-quality causal metadata and unrealistic sequence
|
|
16
|
+
* identities in production CRDT state.
|
|
17
|
+
*
|
|
18
|
+
* Prefer `docFromJson(value, nextDot)` so every node receives a fresh unique dot.
|
|
19
|
+
*
|
|
20
|
+
* @deprecated Use `docFromJson(value, nextDot)` for production documents.
|
|
14
21
|
*/
|
|
15
22
|
declare function docFromJsonWithDot(value: JsonValue, dot: Dot): Doc;
|
|
16
23
|
/** Deep-clone a CRDT document. The clone is fully independent of the original. */
|
|
@@ -128,4 +135,4 @@ declare function rgaCompactTombstones(seq: RgaSeq, isStable: (dot: Dot) => boole
|
|
|
128
135
|
declare function rgaIdAtIndex(seq: RgaSeq, index: number): ElemId | undefined;
|
|
129
136
|
declare function rgaPrevForInsertAtIndex(seq: RgaSeq, index: number): ElemId;
|
|
130
137
|
//#endregion
|
|
131
|
-
export { ActorId, ApplyError, type ApplyPatchAsActorOptions, type ApplyPatchAsActorResult, ApplyPatchInPlaceOptions, ApplyPatchOptions, type ApplyResult, type Clock, ClockValidationError, type CompactDocTombstonesResult, type CompactStateTombstonesResult, type CompilePatchOptions, CrdtState, CreateStateOptions, DeserializeError, DeserializeErrorReason, type DeserializeFailure, DiffOptions, type Doc, type Dot, type ElemId, ForkStateOptions, HEAD, type IntentOp, JsonPatch, JsonPatchOp, type JsonPatchToCrdtOptions, JsonPrimitive, JsonValidationMode, JsonValue, JsonValueValidationError, type LwwReg, MAX_TRAVERSAL_DEPTH, type MergeDocOptions, MergeError, MergeStateOptions, type Node, type ObjEntry, type ObjNode, PatchCompileError, PatchError, PatchErrorReason, PatchSemantics, ROOT_KEY, type RgaElem, type RgaSeq, type RgaValidationIssue, type RgaValidationResult, type SerializedClock, type SerializedDoc, type SerializedNode, type SerializedRgaElem, SerializedState, type TombstoneCompactionOptions, type TombstoneCompactionStats, TraversalDepthError, type TryApplyPatchAsActorResult, TryApplyPatchInPlaceResult, TryApplyPatchResult, type TryDeserializeDocResult, TryDeserializeStateResult, type TryMergeDocResult, TryMergeStateResult, ValidatePatchResult, type VersionVector, applyIntentsToCrdt, applyPatch, applyPatchAsActor, applyPatchInPlace, cloneClock, cloneDoc, compactDocTombstones, compactStateTombstones, compareDot, compileJsonPatchToIntent, crdtNodesToJsonPatch, crdtToFullReplace, crdtToJsonPatch, createClock, createState, deserializeDoc, deserializeState, diffJsonPatch, docFromJson, docFromJsonWithDot, dotToElemId, forkState, getAtJson, jsonEquals, jsonPatchToCrdt, jsonPatchToCrdtSafe, lwwSet, materialize, mergeDoc, mergeState, newObj, newReg, newSeq, nextDotForActor, objCompactTombstones, objRemove, objSet, observeDot, parseJsonPointer, rgaCompactTombstones, rgaDelete, rgaIdAtIndex, rgaInsertAfter, rgaInsertAfterChecked, rgaLinearizeIds, rgaPrevForInsertAtIndex, serializeDoc, serializeState, stringifyJsonPointer, toJson, tryApplyPatch, tryApplyPatchAsActor, tryApplyPatchInPlace, tryDeserializeDoc, tryDeserializeState, tryJsonPatchToCrdt, tryMergeDoc, tryMergeState, validateJsonPatch, validateRgaSeq, vvHasDot, vvMerge };
|
|
138
|
+
export { ActorId, ApplyError, type ApplyPatchAsActorOptions, type ApplyPatchAsActorResult, ApplyPatchInPlaceOptions, ApplyPatchOptions, type ApplyResult, type Clock, ClockValidationError, type CompactDocTombstonesResult, type CompactStateTombstonesResult, type CompilePatchOptions, CrdtState, CreateStateOptions, DeserializeError, DeserializeErrorReason, type DeserializeFailure, DiffOptions, type Doc, type Dot, type ElemId, ForkStateOptions, HEAD, type IntentOp, JsonPatch, JsonPatchOp, type JsonPatchToCrdtOptions, JsonPrimitive, JsonValidationMode, JsonValue, JsonValueValidationError, type LwwReg, MAX_TRAVERSAL_DEPTH, type MergeDocOptions, MergeError, MergeStateOptions, type Node, type ObjEntry, type ObjNode, PatchCompileError, PatchError, PatchErrorReason, PatchSemantics, ROOT_KEY, type RgaElem, type RgaSeq, type RgaValidationIssue, type RgaValidationResult, type SerializedClock, type SerializedDoc, type SerializedNode, type SerializedRgaElem, SerializedState, type TombstoneCompactionOptions, type TombstoneCompactionStats, TraversalDepthError, type TryApplyPatchAsActorResult, TryApplyPatchInPlaceResult, TryApplyPatchResult, type TryDeserializeDocResult, TryDeserializeStateResult, type TryMergeDocResult, TryMergeStateResult, type UnrelatedArraysStrategy, ValidatePatchResult, type VersionVector, applyIntentsToCrdt, applyPatch, applyPatchAsActor, applyPatchInPlace, cloneClock, cloneDoc, compactDocTombstones, compactStateTombstones, compareDot, compileJsonPatchToIntent, crdtNodesToJsonPatch, crdtToFullReplace, crdtToJsonPatch, createClock, createState, deserializeDoc, deserializeState, diffJsonPatch, docFromJson, docFromJsonWithDot, dotToElemId, forkState, getAtJson, intersectVersionVectors, jsonEquals, jsonPatchToCrdt, jsonPatchToCrdtSafe, lwwSet, materialize, mergeDoc, mergeState, mergeVersionVectors, newObj, newReg, newSeq, nextDotForActor, objCompactTombstones, objRemove, objSet, observeDot, observedVersionVector, parseJsonPointer, rgaCompactTombstones, rgaDelete, rgaIdAtIndex, rgaInsertAfter, rgaInsertAfterChecked, rgaLinearizeIds, rgaPrevForInsertAtIndex, serializeDoc, serializeState, stableJsonValueKey, stringifyJsonPointer, toJson, tryApplyPatch, tryApplyPatchAsActor, tryApplyPatchInPlace, tryDeserializeDoc, tryDeserializeState, tryJsonPatchToCrdt, tryMergeDoc, tryMergeState, validateJsonPatch, validateRgaSeq, versionVectorCovers, vvHasDot, vvMerge };
|