json-patch-to-crdt 0.1.1 → 0.1.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.
@@ -92,6 +92,8 @@ type SerializedState = {
92
92
  doc: SerializedDoc;
93
93
  clock: SerializedClock;
94
94
  };
95
+ /** Typed reasons for rejecting malformed serialized CRDT payloads. */
96
+ type DeserializeErrorReason = "INVALID_SERIALIZED_SHAPE" | "INVALID_SERIALIZED_INVARIANT";
95
97
  /**
96
98
  * Internal intent operations produced by compiling RFC 6902 JSON Patch ops.
97
99
  * Each variant maps to a specific CRDT mutation.
@@ -181,7 +183,7 @@ type ApplyPatchAsActorOptions = {
181
183
  semantics?: PatchSemantics;
182
184
  };
183
185
  /** Typed failure reason used across patch/merge helpers. */
184
- type PatchErrorReason = "INVALID_PATCH" | "INVALID_POINTER" | "MISSING_PARENT" | "MISSING_TARGET" | "INVALID_TARGET" | "OUT_OF_BOUNDS" | "TEST_FAILED" | "INVALID_MOVE" | "LINEAGE_MISMATCH";
186
+ type PatchErrorReason = "INVALID_PATCH" | "INVALID_POINTER" | "MISSING_PARENT" | "MISSING_TARGET" | "INVALID_TARGET" | "OUT_OF_BOUNDS" | "TEST_FAILED" | "INVALID_MOVE" | "DOT_GENERATION_EXHAUSTED" | "MAX_DEPTH_EXCEEDED" | "LINEAGE_MISMATCH";
185
187
  /** Structured conflict payload used by non-throwing APIs. */
186
188
  type ApplyError = {
187
189
  ok: false; /** HTTP-friendly status code for conflict-style failures. */
@@ -275,6 +277,34 @@ type TryMergeStateResult = {
275
277
  ok: false;
276
278
  error: ApplyError;
277
279
  };
280
+ /** Options for tombstone compaction helpers. */
281
+ type TombstoneCompactionOptions = {
282
+ /**
283
+ * Causally stable checkpoint. Only tombstones at or below this checkpoint
284
+ * are candidates for pruning.
285
+ */
286
+ stable: VersionVector;
287
+ /**
288
+ * Mutate the input value in place.
289
+ * Defaults to `false` (immutable output).
290
+ */
291
+ mutate?: boolean;
292
+ };
293
+ /** Counts emitted by tombstone compaction helpers. */
294
+ type TombstoneCompactionStats = {
295
+ objectTombstonesRemoved: number;
296
+ sequenceTombstonesRemoved: number;
297
+ };
298
+ /** Result for `compactDocTombstones`. */
299
+ type CompactDocTombstonesResult = {
300
+ doc: Doc;
301
+ stats: TombstoneCompactionStats;
302
+ };
303
+ /** Result for `compactStateTombstones`. */
304
+ type CompactStateTombstonesResult = {
305
+ state: CrdtState;
306
+ stats: TombstoneCompactionStats;
307
+ };
278
308
  /** Options-object overload shape for low-level JSON Patch -> CRDT conversion. */
279
309
  type JsonPatchToCrdtOptions = {
280
310
  base: Doc;
@@ -287,7 +317,19 @@ type JsonPatchToCrdtOptions = {
287
317
  };
288
318
  /** Options for `crdtToJsonPatch` and `diffJsonPatch`. */
289
319
  type DiffOptions = {
320
+ /**
321
+ * Array diff mode.
322
+ * - `"lcs"` (default): index-level edits using LCS.
323
+ * - `"atomic"`: one-op root/field replacement for changed arrays.
324
+ */
290
325
  arrayStrategy?: "atomic" | "lcs";
326
+ /**
327
+ * Maximum LCS matrix cells (`(base.length + 1) * (next.length + 1)`) before
328
+ * falling back to atomic replacement. Defaults to `250_000`.
329
+ *
330
+ * Set to `Number.POSITIVE_INFINITY` to always allow LCS.
331
+ */
332
+ lcsMaxCells?: number;
291
333
  };
292
334
  /**
293
335
  * Internal sentinel key used in `IntentOp` to represent root-level operations.
@@ -403,6 +445,12 @@ declare function diffJsonPatch(base: JsonValue, next: JsonValue, options?: DiffO
403
445
  declare function jsonEquals(a: JsonValue, b: JsonValue): boolean;
404
446
  //#endregion
405
447
  //#region src/serialize.d.ts
448
+ declare class DeserializeError extends Error {
449
+ readonly code: 409;
450
+ readonly reason: DeserializeErrorReason;
451
+ readonly path: string;
452
+ constructor(reason: DeserializeErrorReason, path: string, message: string);
453
+ }
406
454
  /** Serialize a CRDT document to a JSON-safe representation (Maps become plain objects). */
407
455
  declare function serializeDoc(doc: Doc): SerializedDoc;
408
456
  /** Reconstruct a CRDT document from its serialized form. */
@@ -416,7 +464,7 @@ declare function deserializeState(data: SerializedState): CrdtState;
416
464
  /** Error thrown by throwing merge helpers (`mergeDoc` / `mergeState`). */
417
465
  declare class MergeError extends Error {
418
466
  readonly code: 409;
419
- readonly reason: "LINEAGE_MISMATCH";
467
+ readonly reason: PatchErrorReason;
420
468
  readonly path?: string;
421
469
  constructor(error: ApplyError);
422
470
  }
@@ -451,4 +499,36 @@ declare function mergeState(a: CrdtState, b: CrdtState, options?: MergeStateOpti
451
499
  /** Non-throwing `mergeState` variant with structured conflict details. */
452
500
  declare function tryMergeState(a: CrdtState, b: CrdtState, options?: MergeStateOptions): TryMergeStateResult;
453
501
  //#endregion
454
- export { ObjNode as $, ApplyPatchAsActorResult as A, ElemId as B, toJson as C, ActorId as D, validateJsonPatch as E, CompilePatchOptions as F, JsonPatchToCrdtOptions as G, IntentOp as H, CrdtState as I, LwwReg as J, JsonPrimitive as K, DiffOptions as L, ApplyPatchOptions as M, ApplyResult as N, ApplyError as O, Clock as P, ObjEntry as Q, Doc as R, forkState as S, tryApplyPatchInPlace as T, JsonPatch as U, ForkStateOptions as V, JsonPatchOp as W, MergeStateOptions as X, MergeDocOptions as Y, Node as Z, PatchError as _, tryMergeState as a, SerializedClock as at, applyPatchInPlace as b, serializeDoc as c, SerializedRgaElem as ct, compileJsonPatchToIntent as d, TryApplyPatchResult as dt, PatchErrorReason as et, diffJsonPatch as f, TryMergeDocResult as ft, stringifyJsonPointer as g, parseJsonPointer as h, VersionVector as ht, tryMergeDoc as i, RgaSeq as it, ApplyPatchInPlaceOptions as j, ApplyPatchAsActorOptions as k, serializeState as l, SerializedState as lt, jsonEquals as m, ValidatePatchResult as mt, mergeDoc as n, ROOT_KEY as nt, deserializeDoc as o, SerializedDoc as ot, getAtJson as p, TryMergeStateResult as pt, JsonValue as q, mergeState as r, RgaElem as rt, deserializeState as s, SerializedNode as st, MergeError as t, PatchSemantics as tt, PatchCompileError as u, TryApplyPatchInPlaceResult as ut, applyPatch as v, tryApplyPatch as w, createState as x, applyPatchAsActor as y, Dot as z };
502
+ //#region src/compact.d.ts
503
+ /**
504
+ * Compact causally-stable tombstones in a document.
505
+ *
506
+ * Safety note:
507
+ * - Only compact at checkpoints that are causally stable across all peers you
508
+ * may still merge with.
509
+ * - Do not merge this compacted document with replicas that might be behind
510
+ * the provided checkpoint.
511
+ */
512
+ declare function compactDocTombstones(doc: Doc, options: TombstoneCompactionOptions): CompactDocTombstonesResult;
513
+ /**
514
+ * Compact causally-stable tombstones in a state document.
515
+ *
516
+ * Safety note:
517
+ * - Only compact at checkpoints that are causally stable across all peers you
518
+ * may still merge with.
519
+ * - Do not merge this compacted state with replicas that might be behind the
520
+ * provided checkpoint.
521
+ */
522
+ declare function compactStateTombstones(state: CrdtState, options: TombstoneCompactionOptions): CompactStateTombstonesResult;
523
+ //#endregion
524
+ //#region src/depth.d.ts
525
+ declare const MAX_TRAVERSAL_DEPTH = 16384;
526
+ declare class TraversalDepthError extends Error {
527
+ readonly code: 409;
528
+ readonly reason: "MAX_DEPTH_EXCEEDED";
529
+ readonly depth: number;
530
+ readonly maxDepth: number;
531
+ constructor(depth: number, maxDepth?: number);
532
+ }
533
+ //#endregion
534
+ export { JsonPatchToCrdtOptions as $, tryApplyPatchInPlace as A, CompactDocTombstonesResult as B, applyPatch as C, TryMergeStateResult as Ct, forkState as D, createState as E, ApplyPatchAsActorResult as F, DiffOptions as G, CompilePatchOptions as H, ApplyPatchInPlaceOptions as I, ElemId as J, Doc as K, ApplyPatchOptions as L, ActorId as M, ApplyError as N, toJson as O, ApplyPatchAsActorOptions as P, JsonPatchOp as Q, ApplyResult as R, PatchError as S, TryMergeDocResult as St, applyPatchInPlace as T, VersionVector as Tt, CrdtState as U, CompactStateTombstonesResult as V, DeserializeErrorReason as W, IntentOp as X, ForkStateOptions as Y, JsonPatch as Z, diffJsonPatch as _, SerializedState as _t, MergeError as a, Node as at, parseJsonPointer as b, TryApplyPatchInPlaceResult as bt, tryMergeDoc as c, PatchErrorReason as ct, deserializeDoc as d, RgaElem as dt, JsonPrimitive as et, deserializeState as f, RgaSeq as ft, compileJsonPatchToIntent as g, SerializedRgaElem as gt, PatchCompileError as h, SerializedNode as ht, compactStateTombstones as i, MergeStateOptions as it, validateJsonPatch as j, tryApplyPatch as k, tryMergeState as l, PatchSemantics as lt, serializeState as m, SerializedDoc as mt, TraversalDepthError as n, LwwReg as nt, mergeDoc as o, ObjEntry as ot, serializeDoc as p, SerializedClock as pt, Dot as q, compactDocTombstones as r, MergeDocOptions as rt, mergeState as s, ObjNode as st, MAX_TRAVERSAL_DEPTH as t, JsonValue as tt, DeserializeError as u, ROOT_KEY as ut, getAtJson as v, TombstoneCompactionOptions as vt, applyPatchAsActor as w, ValidatePatchResult as wt, stringifyJsonPointer as x, TryApplyPatchResult as xt, jsonEquals as y, TombstoneCompactionStats as yt, Clock as z };
@@ -92,6 +92,8 @@ type SerializedState = {
92
92
  doc: SerializedDoc;
93
93
  clock: SerializedClock;
94
94
  };
95
+ /** Typed reasons for rejecting malformed serialized CRDT payloads. */
96
+ type DeserializeErrorReason = "INVALID_SERIALIZED_SHAPE" | "INVALID_SERIALIZED_INVARIANT";
95
97
  /**
96
98
  * Internal intent operations produced by compiling RFC 6902 JSON Patch ops.
97
99
  * Each variant maps to a specific CRDT mutation.
@@ -181,7 +183,7 @@ type ApplyPatchAsActorOptions = {
181
183
  semantics?: PatchSemantics;
182
184
  };
183
185
  /** Typed failure reason used across patch/merge helpers. */
184
- type PatchErrorReason = "INVALID_PATCH" | "INVALID_POINTER" | "MISSING_PARENT" | "MISSING_TARGET" | "INVALID_TARGET" | "OUT_OF_BOUNDS" | "TEST_FAILED" | "INVALID_MOVE" | "LINEAGE_MISMATCH";
186
+ type PatchErrorReason = "INVALID_PATCH" | "INVALID_POINTER" | "MISSING_PARENT" | "MISSING_TARGET" | "INVALID_TARGET" | "OUT_OF_BOUNDS" | "TEST_FAILED" | "INVALID_MOVE" | "DOT_GENERATION_EXHAUSTED" | "MAX_DEPTH_EXCEEDED" | "LINEAGE_MISMATCH";
185
187
  /** Structured conflict payload used by non-throwing APIs. */
186
188
  type ApplyError = {
187
189
  ok: false; /** HTTP-friendly status code for conflict-style failures. */
@@ -275,6 +277,34 @@ type TryMergeStateResult = {
275
277
  ok: false;
276
278
  error: ApplyError;
277
279
  };
280
+ /** Options for tombstone compaction helpers. */
281
+ type TombstoneCompactionOptions = {
282
+ /**
283
+ * Causally stable checkpoint. Only tombstones at or below this checkpoint
284
+ * are candidates for pruning.
285
+ */
286
+ stable: VersionVector;
287
+ /**
288
+ * Mutate the input value in place.
289
+ * Defaults to `false` (immutable output).
290
+ */
291
+ mutate?: boolean;
292
+ };
293
+ /** Counts emitted by tombstone compaction helpers. */
294
+ type TombstoneCompactionStats = {
295
+ objectTombstonesRemoved: number;
296
+ sequenceTombstonesRemoved: number;
297
+ };
298
+ /** Result for `compactDocTombstones`. */
299
+ type CompactDocTombstonesResult = {
300
+ doc: Doc;
301
+ stats: TombstoneCompactionStats;
302
+ };
303
+ /** Result for `compactStateTombstones`. */
304
+ type CompactStateTombstonesResult = {
305
+ state: CrdtState;
306
+ stats: TombstoneCompactionStats;
307
+ };
278
308
  /** Options-object overload shape for low-level JSON Patch -> CRDT conversion. */
279
309
  type JsonPatchToCrdtOptions = {
280
310
  base: Doc;
@@ -287,7 +317,19 @@ type JsonPatchToCrdtOptions = {
287
317
  };
288
318
  /** Options for `crdtToJsonPatch` and `diffJsonPatch`. */
289
319
  type DiffOptions = {
320
+ /**
321
+ * Array diff mode.
322
+ * - `"lcs"` (default): index-level edits using LCS.
323
+ * - `"atomic"`: one-op root/field replacement for changed arrays.
324
+ */
290
325
  arrayStrategy?: "atomic" | "lcs";
326
+ /**
327
+ * Maximum LCS matrix cells (`(base.length + 1) * (next.length + 1)`) before
328
+ * falling back to atomic replacement. Defaults to `250_000`.
329
+ *
330
+ * Set to `Number.POSITIVE_INFINITY` to always allow LCS.
331
+ */
332
+ lcsMaxCells?: number;
291
333
  };
292
334
  /**
293
335
  * Internal sentinel key used in `IntentOp` to represent root-level operations.
@@ -403,6 +445,12 @@ declare function diffJsonPatch(base: JsonValue, next: JsonValue, options?: DiffO
403
445
  declare function jsonEquals(a: JsonValue, b: JsonValue): boolean;
404
446
  //#endregion
405
447
  //#region src/serialize.d.ts
448
+ declare class DeserializeError extends Error {
449
+ readonly code: 409;
450
+ readonly reason: DeserializeErrorReason;
451
+ readonly path: string;
452
+ constructor(reason: DeserializeErrorReason, path: string, message: string);
453
+ }
406
454
  /** Serialize a CRDT document to a JSON-safe representation (Maps become plain objects). */
407
455
  declare function serializeDoc(doc: Doc): SerializedDoc;
408
456
  /** Reconstruct a CRDT document from its serialized form. */
@@ -416,7 +464,7 @@ declare function deserializeState(data: SerializedState): CrdtState;
416
464
  /** Error thrown by throwing merge helpers (`mergeDoc` / `mergeState`). */
417
465
  declare class MergeError extends Error {
418
466
  readonly code: 409;
419
- readonly reason: "LINEAGE_MISMATCH";
467
+ readonly reason: PatchErrorReason;
420
468
  readonly path?: string;
421
469
  constructor(error: ApplyError);
422
470
  }
@@ -451,4 +499,36 @@ declare function mergeState(a: CrdtState, b: CrdtState, options?: MergeStateOpti
451
499
  /** Non-throwing `mergeState` variant with structured conflict details. */
452
500
  declare function tryMergeState(a: CrdtState, b: CrdtState, options?: MergeStateOptions): TryMergeStateResult;
453
501
  //#endregion
454
- export { ObjNode as $, ApplyPatchAsActorResult as A, ElemId as B, toJson as C, ActorId as D, validateJsonPatch as E, CompilePatchOptions as F, JsonPatchToCrdtOptions as G, IntentOp as H, CrdtState as I, LwwReg as J, JsonPrimitive as K, DiffOptions as L, ApplyPatchOptions as M, ApplyResult as N, ApplyError as O, Clock as P, ObjEntry as Q, Doc as R, forkState as S, tryApplyPatchInPlace as T, JsonPatch as U, ForkStateOptions as V, JsonPatchOp as W, MergeStateOptions as X, MergeDocOptions as Y, Node as Z, PatchError as _, tryMergeState as a, SerializedClock as at, applyPatchInPlace as b, serializeDoc as c, SerializedRgaElem as ct, compileJsonPatchToIntent as d, TryApplyPatchResult as dt, PatchErrorReason as et, diffJsonPatch as f, TryMergeDocResult as ft, stringifyJsonPointer as g, parseJsonPointer as h, VersionVector as ht, tryMergeDoc as i, RgaSeq as it, ApplyPatchInPlaceOptions as j, ApplyPatchAsActorOptions as k, serializeState as l, SerializedState as lt, jsonEquals as m, ValidatePatchResult as mt, mergeDoc as n, ROOT_KEY as nt, deserializeDoc as o, SerializedDoc as ot, getAtJson as p, TryMergeStateResult as pt, JsonValue as q, mergeState as r, RgaElem as rt, deserializeState as s, SerializedNode as st, MergeError as t, PatchSemantics as tt, PatchCompileError as u, TryApplyPatchInPlaceResult as ut, applyPatch as v, tryApplyPatch as w, createState as x, applyPatchAsActor as y, Dot as z };
502
+ //#region src/compact.d.ts
503
+ /**
504
+ * Compact causally-stable tombstones in a document.
505
+ *
506
+ * Safety note:
507
+ * - Only compact at checkpoints that are causally stable across all peers you
508
+ * may still merge with.
509
+ * - Do not merge this compacted document with replicas that might be behind
510
+ * the provided checkpoint.
511
+ */
512
+ declare function compactDocTombstones(doc: Doc, options: TombstoneCompactionOptions): CompactDocTombstonesResult;
513
+ /**
514
+ * Compact causally-stable tombstones in a state document.
515
+ *
516
+ * Safety note:
517
+ * - Only compact at checkpoints that are causally stable across all peers you
518
+ * may still merge with.
519
+ * - Do not merge this compacted state with replicas that might be behind the
520
+ * provided checkpoint.
521
+ */
522
+ declare function compactStateTombstones(state: CrdtState, options: TombstoneCompactionOptions): CompactStateTombstonesResult;
523
+ //#endregion
524
+ //#region src/depth.d.ts
525
+ declare const MAX_TRAVERSAL_DEPTH = 16384;
526
+ declare class TraversalDepthError extends Error {
527
+ readonly code: 409;
528
+ readonly reason: "MAX_DEPTH_EXCEEDED";
529
+ readonly depth: number;
530
+ readonly maxDepth: number;
531
+ constructor(depth: number, maxDepth?: number);
532
+ }
533
+ //#endregion
534
+ export { JsonPatchToCrdtOptions as $, tryApplyPatchInPlace as A, CompactDocTombstonesResult as B, applyPatch as C, TryMergeStateResult as Ct, forkState as D, createState as E, ApplyPatchAsActorResult as F, DiffOptions as G, CompilePatchOptions as H, ApplyPatchInPlaceOptions as I, ElemId as J, Doc as K, ApplyPatchOptions as L, ActorId as M, ApplyError as N, toJson as O, ApplyPatchAsActorOptions as P, JsonPatchOp as Q, ApplyResult as R, PatchError as S, TryMergeDocResult as St, applyPatchInPlace as T, VersionVector as Tt, CrdtState as U, CompactStateTombstonesResult as V, DeserializeErrorReason as W, IntentOp as X, ForkStateOptions as Y, JsonPatch as Z, diffJsonPatch as _, SerializedState as _t, MergeError as a, Node as at, parseJsonPointer as b, TryApplyPatchInPlaceResult as bt, tryMergeDoc as c, PatchErrorReason as ct, deserializeDoc as d, RgaElem as dt, JsonPrimitive as et, deserializeState as f, RgaSeq as ft, compileJsonPatchToIntent as g, SerializedRgaElem as gt, PatchCompileError as h, SerializedNode as ht, compactStateTombstones as i, MergeStateOptions as it, validateJsonPatch as j, tryApplyPatch as k, tryMergeState as l, PatchSemantics as lt, serializeState as m, SerializedDoc as mt, TraversalDepthError as n, LwwReg as nt, mergeDoc as o, ObjEntry as ot, serializeDoc as p, SerializedClock as pt, Dot as q, compactDocTombstones as r, MergeDocOptions as rt, mergeState as s, ObjNode as st, MAX_TRAVERSAL_DEPTH as t, JsonValue as tt, DeserializeError as u, ROOT_KEY as ut, getAtJson as v, TombstoneCompactionOptions as vt, applyPatchAsActor as w, ValidatePatchResult as wt, stringifyJsonPointer as x, TryApplyPatchResult as xt, jsonEquals as y, TombstoneCompactionStats as yt, Clock as z };
package/dist/index.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { C as toJson, D as ActorId, E as validateJsonPatch, I as CrdtState, K as JsonPrimitive, L as DiffOptions, M as ApplyPatchOptions, O as ApplyError, S as forkState, T as tryApplyPatchInPlace, U as JsonPatch, V as ForkStateOptions, W as JsonPatchOp, X as MergeStateOptions, _ as PatchError, a as tryMergeState, b as applyPatchInPlace, dt as TryApplyPatchResult, et as PatchErrorReason, f as diffJsonPatch, j as ApplyPatchInPlaceOptions, l as serializeState, lt as SerializedState, mt as ValidatePatchResult, pt as TryMergeStateResult, q as JsonValue, r as mergeState, s as deserializeState, t as MergeError, tt as PatchSemantics, ut as TryApplyPatchInPlaceResult, v as applyPatch, w as tryApplyPatch, x as createState } from "./merge-DQ_KDtnE.mjs";
2
- export { type ActorId, type ApplyError, type ApplyPatchInPlaceOptions, type ApplyPatchOptions, type CrdtState, type DiffOptions, type ForkStateOptions, type JsonPatch, type JsonPatchOp, type JsonPrimitive, type JsonValue, MergeError, type MergeStateOptions, PatchError, type PatchErrorReason, type PatchSemantics, type SerializedState, type TryApplyPatchInPlaceResult, type TryApplyPatchResult, type TryMergeStateResult, type ValidatePatchResult, applyPatch, applyPatchInPlace, createState, deserializeState, diffJsonPatch, forkState, mergeState, serializeState, toJson, tryApplyPatch, tryApplyPatchInPlace, tryMergeState, validateJsonPatch };
1
+ import { A as tryApplyPatchInPlace, C as applyPatch, Ct as TryMergeStateResult, D as forkState, E as createState, G as DiffOptions, I as ApplyPatchInPlaceOptions, L as ApplyPatchOptions, M as ActorId, N as ApplyError, O as toJson, Q as JsonPatchOp, S as PatchError, T as applyPatchInPlace, U as CrdtState, V as CompactStateTombstonesResult, W as DeserializeErrorReason, Y as ForkStateOptions, Z as JsonPatch, _ as diffJsonPatch, _t as SerializedState, a as MergeError, bt as TryApplyPatchInPlaceResult, ct as PatchErrorReason, et as JsonPrimitive, f as deserializeState, i as compactStateTombstones, it as MergeStateOptions, j as validateJsonPatch, k as tryApplyPatch, l as tryMergeState, lt as PatchSemantics, m as serializeState, n as TraversalDepthError, s as mergeState, t as MAX_TRAVERSAL_DEPTH, tt as JsonValue, u as DeserializeError, vt as TombstoneCompactionOptions, wt as ValidatePatchResult, xt as TryApplyPatchResult, yt as TombstoneCompactionStats } from "./depth-wDeQ1hO1.mjs";
2
+ export { type ActorId, type ApplyError, type ApplyPatchInPlaceOptions, type ApplyPatchOptions, type CompactStateTombstonesResult, type CrdtState, DeserializeError, type DeserializeErrorReason, type DiffOptions, type ForkStateOptions, type JsonPatch, type JsonPatchOp, type JsonPrimitive, type JsonValue, MAX_TRAVERSAL_DEPTH, MergeError, type MergeStateOptions, PatchError, type PatchErrorReason, type PatchSemantics, type SerializedState, type TombstoneCompactionOptions, type TombstoneCompactionStats, TraversalDepthError, type TryApplyPatchInPlaceResult, type TryApplyPatchResult, type TryMergeStateResult, type ValidatePatchResult, applyPatch, applyPatchInPlace, compactStateTombstones, createState, deserializeState, diffJsonPatch, forkState, mergeState, serializeState, toJson, tryApplyPatch, tryApplyPatchInPlace, tryMergeState, validateJsonPatch };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { C as toJson, D as ActorId, E as validateJsonPatch, I as CrdtState, K as JsonPrimitive, L as DiffOptions, M as ApplyPatchOptions, O as ApplyError, S as forkState, T as tryApplyPatchInPlace, U as JsonPatch, V as ForkStateOptions, W as JsonPatchOp, X as MergeStateOptions, _ as PatchError, a as tryMergeState, b as applyPatchInPlace, dt as TryApplyPatchResult, et as PatchErrorReason, f as diffJsonPatch, j as ApplyPatchInPlaceOptions, l as serializeState, lt as SerializedState, mt as ValidatePatchResult, pt as TryMergeStateResult, q as JsonValue, r as mergeState, s as deserializeState, t as MergeError, tt as PatchSemantics, ut as TryApplyPatchInPlaceResult, v as applyPatch, w as tryApplyPatch, x as createState } from "./merge-B8nmGV-o.js";
2
- export { type ActorId, type ApplyError, type ApplyPatchInPlaceOptions, type ApplyPatchOptions, type CrdtState, type DiffOptions, type ForkStateOptions, type JsonPatch, type JsonPatchOp, type JsonPrimitive, type JsonValue, MergeError, type MergeStateOptions, PatchError, type PatchErrorReason, type PatchSemantics, type SerializedState, type TryApplyPatchInPlaceResult, type TryApplyPatchResult, type TryMergeStateResult, type ValidatePatchResult, applyPatch, applyPatchInPlace, createState, deserializeState, diffJsonPatch, forkState, mergeState, serializeState, toJson, tryApplyPatch, tryApplyPatchInPlace, tryMergeState, validateJsonPatch };
1
+ import { A as tryApplyPatchInPlace, C as applyPatch, Ct as TryMergeStateResult, D as forkState, E as createState, G as DiffOptions, I as ApplyPatchInPlaceOptions, L as ApplyPatchOptions, M as ActorId, N as ApplyError, O as toJson, Q as JsonPatchOp, S as PatchError, T as applyPatchInPlace, U as CrdtState, V as CompactStateTombstonesResult, W as DeserializeErrorReason, Y as ForkStateOptions, Z as JsonPatch, _ as diffJsonPatch, _t as SerializedState, a as MergeError, bt as TryApplyPatchInPlaceResult, ct as PatchErrorReason, et as JsonPrimitive, f as deserializeState, i as compactStateTombstones, it as MergeStateOptions, j as validateJsonPatch, k as tryApplyPatch, l as tryMergeState, lt as PatchSemantics, m as serializeState, n as TraversalDepthError, s as mergeState, t as MAX_TRAVERSAL_DEPTH, tt as JsonValue, u as DeserializeError, vt as TombstoneCompactionOptions, wt as ValidatePatchResult, xt as TryApplyPatchResult, yt as TombstoneCompactionStats } from "./depth-p6fX9Ak7.js";
2
+ export { type ActorId, type ApplyError, type ApplyPatchInPlaceOptions, type ApplyPatchOptions, type CompactStateTombstonesResult, type CrdtState, DeserializeError, type DeserializeErrorReason, type DiffOptions, type ForkStateOptions, type JsonPatch, type JsonPatchOp, type JsonPrimitive, type JsonValue, MAX_TRAVERSAL_DEPTH, MergeError, type MergeStateOptions, PatchError, type PatchErrorReason, type PatchSemantics, type SerializedState, type TombstoneCompactionOptions, type TombstoneCompactionStats, TraversalDepthError, type TryApplyPatchInPlaceResult, type TryApplyPatchResult, type TryMergeStateResult, type ValidatePatchResult, applyPatch, applyPatchInPlace, compactStateTombstones, createState, deserializeState, diffJsonPatch, forkState, mergeState, serializeState, toJson, tryApplyPatch, tryApplyPatchInPlace, tryMergeState, validateJsonPatch };
package/dist/index.js CHANGED
@@ -1,18 +1,22 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_merge = require('./merge-BAfuC6bf.js');
2
+ const require_compact = require('./compact-CkLd4Yh5.js');
3
3
 
4
- exports.MergeError = require_merge.MergeError;
5
- exports.PatchError = require_merge.PatchError;
6
- exports.applyPatch = require_merge.applyPatch;
7
- exports.applyPatchInPlace = require_merge.applyPatchInPlace;
8
- exports.createState = require_merge.createState;
9
- exports.deserializeState = require_merge.deserializeState;
10
- exports.diffJsonPatch = require_merge.diffJsonPatch;
11
- exports.forkState = require_merge.forkState;
12
- exports.mergeState = require_merge.mergeState;
13
- exports.serializeState = require_merge.serializeState;
14
- exports.toJson = require_merge.toJson;
15
- exports.tryApplyPatch = require_merge.tryApplyPatch;
16
- exports.tryApplyPatchInPlace = require_merge.tryApplyPatchInPlace;
17
- exports.tryMergeState = require_merge.tryMergeState;
18
- exports.validateJsonPatch = require_merge.validateJsonPatch;
4
+ exports.DeserializeError = require_compact.DeserializeError;
5
+ exports.MAX_TRAVERSAL_DEPTH = require_compact.MAX_TRAVERSAL_DEPTH;
6
+ exports.MergeError = require_compact.MergeError;
7
+ exports.PatchError = require_compact.PatchError;
8
+ exports.TraversalDepthError = require_compact.TraversalDepthError;
9
+ exports.applyPatch = require_compact.applyPatch;
10
+ exports.applyPatchInPlace = require_compact.applyPatchInPlace;
11
+ exports.compactStateTombstones = require_compact.compactStateTombstones;
12
+ exports.createState = require_compact.createState;
13
+ exports.deserializeState = require_compact.deserializeState;
14
+ exports.diffJsonPatch = require_compact.diffJsonPatch;
15
+ exports.forkState = require_compact.forkState;
16
+ exports.mergeState = require_compact.mergeState;
17
+ exports.serializeState = require_compact.serializeState;
18
+ exports.toJson = require_compact.toJson;
19
+ exports.tryApplyPatch = require_compact.tryApplyPatch;
20
+ exports.tryApplyPatchInPlace = require_compact.tryApplyPatchInPlace;
21
+ exports.tryMergeState = require_compact.tryMergeState;
22
+ exports.validateJsonPatch = require_compact.validateJsonPatch;
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { _ as tryApplyPatch, a as tryMergeState, d as applyPatch, g as toJson, h as forkState, j as diffJsonPatch, l as serializeState, m as createState, p as applyPatchInPlace, r as mergeState, s as deserializeState, t as MergeError, u as PatchError, v as tryApplyPatchInPlace, y as validateJsonPatch } from "./merge-CKcP1ZPt.mjs";
1
+ import { P as diffJsonPatch, S as validateJsonPatch, _ as createState, a as mergeState, at as MAX_TRAVERSAL_DEPTH, b as tryApplyPatch, c as DeserializeError, f as serializeState, g as applyPatchInPlace, m as applyPatch, n as compactStateTombstones, ot as TraversalDepthError, p as PatchError, r as MergeError, s as tryMergeState, u as deserializeState, v as forkState, x as tryApplyPatchInPlace, y as toJson } from "./compact-BJBGW9tC.mjs";
2
2
 
3
- export { MergeError, PatchError, applyPatch, applyPatchInPlace, createState, deserializeState, diffJsonPatch, forkState, mergeState, serializeState, toJson, tryApplyPatch, tryApplyPatchInPlace, tryMergeState, validateJsonPatch };
3
+ export { DeserializeError, MAX_TRAVERSAL_DEPTH, MergeError, PatchError, TraversalDepthError, applyPatch, applyPatchInPlace, compactStateTombstones, createState, deserializeState, diffJsonPatch, forkState, mergeState, serializeState, toJson, tryApplyPatch, tryApplyPatchInPlace, tryMergeState, validateJsonPatch };
@@ -1,4 +1,4 @@
1
- import { $ as ObjNode, A as ApplyPatchAsActorResult, B as ElemId, C as toJson, D as ActorId, E as validateJsonPatch, F as CompilePatchOptions, G as JsonPatchToCrdtOptions, H as IntentOp, I as CrdtState, J as LwwReg, K as JsonPrimitive, L as DiffOptions, M as ApplyPatchOptions, N as ApplyResult, O as ApplyError, P as Clock, Q as ObjEntry, R as Doc, S as forkState, T as tryApplyPatchInPlace, U as JsonPatch, V as ForkStateOptions, W as JsonPatchOp, X as MergeStateOptions, Y as MergeDocOptions, Z as Node, _ as PatchError, a as tryMergeState, at as SerializedClock, b as applyPatchInPlace, c as serializeDoc, ct as SerializedRgaElem, d as compileJsonPatchToIntent, dt as TryApplyPatchResult, et as PatchErrorReason, f as diffJsonPatch, ft as TryMergeDocResult, g as stringifyJsonPointer, h as parseJsonPointer, ht as VersionVector, i as tryMergeDoc, it as RgaSeq, j as ApplyPatchInPlaceOptions, k as ApplyPatchAsActorOptions, l as serializeState, lt as SerializedState, m as jsonEquals, mt as ValidatePatchResult, n as mergeDoc, nt as ROOT_KEY, o as deserializeDoc, ot as SerializedDoc, p as getAtJson, pt as TryMergeStateResult, q as JsonValue, r as mergeState, rt as RgaElem, s as deserializeState, st as SerializedNode, t as MergeError, tt as PatchSemantics, u as PatchCompileError, ut as TryApplyPatchInPlaceResult, v as applyPatch, w as tryApplyPatch, x as createState, y as applyPatchAsActor, z as Dot } from "./merge-DQ_KDtnE.mjs";
1
+ import { $ as JsonPatchToCrdtOptions, A as tryApplyPatchInPlace, B as CompactDocTombstonesResult, C as applyPatch, Ct as TryMergeStateResult, D as forkState, E as createState, F as ApplyPatchAsActorResult, G as DiffOptions, H as CompilePatchOptions, I as ApplyPatchInPlaceOptions, J as ElemId, K as Doc, L as ApplyPatchOptions, M as ActorId, N as ApplyError, O as toJson, P as ApplyPatchAsActorOptions, Q as JsonPatchOp, R as ApplyResult, S as PatchError, St as TryMergeDocResult, T as applyPatchInPlace, Tt as VersionVector, U as CrdtState, V as CompactStateTombstonesResult, W as DeserializeErrorReason, X as IntentOp, Y as ForkStateOptions, Z as JsonPatch, _ as diffJsonPatch, _t as SerializedState, a as MergeError, at as Node, b as parseJsonPointer, bt as TryApplyPatchInPlaceResult, c as tryMergeDoc, ct as PatchErrorReason, d as deserializeDoc, dt as RgaElem, et as JsonPrimitive, f as deserializeState, ft as RgaSeq, g as compileJsonPatchToIntent, gt as SerializedRgaElem, h as PatchCompileError, ht as SerializedNode, i as compactStateTombstones, it as MergeStateOptions, j as validateJsonPatch, k as tryApplyPatch, l as tryMergeState, lt as PatchSemantics, m as serializeState, mt as SerializedDoc, n as TraversalDepthError, nt as LwwReg, o as mergeDoc, ot as ObjEntry, p as serializeDoc, pt as SerializedClock, q as Dot, r as compactDocTombstones, rt as MergeDocOptions, s as mergeState, st as ObjNode, t as MAX_TRAVERSAL_DEPTH, tt as JsonValue, u as DeserializeError, ut as ROOT_KEY, v as getAtJson, vt as TombstoneCompactionOptions, w as applyPatchAsActor, wt as ValidatePatchResult, x as stringifyJsonPointer, xt as TryApplyPatchResult, y as jsonEquals, yt as TombstoneCompactionStats, z as Clock } from "./depth-wDeQ1hO1.mjs";
2
2
 
3
3
  //#region src/clock.d.ts
4
4
  /**
@@ -75,7 +75,7 @@ declare function crdtToJsonPatch(base: Doc, head: Doc, options?: DiffOptions): J
75
75
  declare function crdtToFullReplace(doc: Doc): JsonPatchOp[];
76
76
  //#endregion
77
77
  //#region src/materialize.d.ts
78
- /** Recursively convert a CRDT node graph into a plain JSON value. */
78
+ /** Convert a CRDT node graph into a plain JSON value using an explicit stack. */
79
79
  declare function materialize(node: Node): JsonValue;
80
80
  //#endregion
81
81
  //#region src/dot.d.ts
@@ -91,13 +91,25 @@ declare function newReg(value: JsonValue, dot: Dot): LwwReg;
91
91
  declare function lwwSet(reg: LwwReg, value: JsonValue, dot: Dot): void;
92
92
  declare function objSet(obj: ObjNode, key: string, node: Node, dot: Dot): void;
93
93
  declare function objRemove(obj: ObjNode, key: string, dot: Dot): void;
94
+ /**
95
+ * Prune object tombstones that satisfy a caller-provided stability predicate.
96
+ * Returns the number of removed tombstone records.
97
+ */
98
+ declare function objCompactTombstones(obj: ObjNode, isStable: (dot: Dot) => boolean): number;
94
99
  //#endregion
95
100
  //#region src/rga.d.ts
96
101
  declare const HEAD: ElemId;
97
102
  declare function rgaLinearizeIds(seq: RgaSeq): ElemId[];
98
103
  declare function rgaInsertAfter(seq: RgaSeq, prev: ElemId, id: ElemId, insDot: Dot, value: Node): void;
99
104
  declare function rgaDelete(seq: RgaSeq, id: ElemId): void;
105
+ /**
106
+ * Prune tombstoned elements that are causally stable and have no live descendants
107
+ * depending on them for sequence traversal.
108
+ *
109
+ * Returns the number of removed elements.
110
+ */
111
+ declare function rgaCompactTombstones(seq: RgaSeq, isStable: (dot: Dot) => boolean): number;
100
112
  declare function rgaIdAtIndex(seq: RgaSeq, index: number): ElemId | undefined;
101
113
  declare function rgaPrevForInsertAtIndex(seq: RgaSeq, index: number): ElemId;
102
114
  //#endregion
103
- export { ActorId, ApplyError, type ApplyPatchAsActorOptions, type ApplyPatchAsActorResult, ApplyPatchInPlaceOptions, ApplyPatchOptions, type ApplyResult, type Clock, type CompilePatchOptions, CrdtState, DiffOptions, type Doc, type Dot, type ElemId, ForkStateOptions, HEAD, type IntentOp, JsonPatch, JsonPatchOp, type JsonPatchToCrdtOptions, JsonPrimitive, JsonValue, type LwwReg, type MergeDocOptions, MergeError, MergeStateOptions, type Node, type ObjEntry, type ObjNode, PatchCompileError, PatchError, PatchErrorReason, PatchSemantics, ROOT_KEY, type RgaElem, type RgaSeq, type SerializedClock, type SerializedDoc, type SerializedNode, type SerializedRgaElem, SerializedState, TryApplyPatchInPlaceResult, TryApplyPatchResult, type TryMergeDocResult, TryMergeStateResult, ValidatePatchResult, type VersionVector, applyIntentsToCrdt, applyPatch, applyPatchAsActor, applyPatchInPlace, cloneClock, cloneDoc, compareDot, compileJsonPatchToIntent, crdtToFullReplace, crdtToJsonPatch, createClock, createState, deserializeDoc, deserializeState, diffJsonPatch, docFromJson, docFromJsonWithDot, dotToElemId, forkState, getAtJson, jsonEquals, jsonPatchToCrdt, jsonPatchToCrdtSafe, lwwSet, materialize, mergeDoc, mergeState, newObj, newReg, newSeq, nextDotForActor, objRemove, objSet, observeDot, parseJsonPointer, rgaDelete, rgaIdAtIndex, rgaInsertAfter, rgaLinearizeIds, rgaPrevForInsertAtIndex, serializeDoc, serializeState, stringifyJsonPointer, toJson, tryApplyPatch, tryApplyPatchInPlace, tryJsonPatchToCrdt, tryMergeDoc, tryMergeState, validateJsonPatch, vvHasDot, vvMerge };
115
+ export { ActorId, ApplyError, type ApplyPatchAsActorOptions, type ApplyPatchAsActorResult, ApplyPatchInPlaceOptions, ApplyPatchOptions, type ApplyResult, type Clock, type CompactDocTombstonesResult, type CompactStateTombstonesResult, type CompilePatchOptions, CrdtState, DeserializeError, DeserializeErrorReason, DiffOptions, type Doc, type Dot, type ElemId, ForkStateOptions, HEAD, type IntentOp, JsonPatch, JsonPatchOp, type JsonPatchToCrdtOptions, JsonPrimitive, JsonValue, 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 SerializedClock, type SerializedDoc, type SerializedNode, type SerializedRgaElem, SerializedState, type TombstoneCompactionOptions, type TombstoneCompactionStats, TraversalDepthError, TryApplyPatchInPlaceResult, TryApplyPatchResult, type TryMergeDocResult, TryMergeStateResult, ValidatePatchResult, type VersionVector, applyIntentsToCrdt, applyPatch, applyPatchAsActor, applyPatchInPlace, cloneClock, cloneDoc, compactDocTombstones, compactStateTombstones, compareDot, compileJsonPatchToIntent, 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, rgaLinearizeIds, rgaPrevForInsertAtIndex, serializeDoc, serializeState, stringifyJsonPointer, toJson, tryApplyPatch, tryApplyPatchInPlace, tryJsonPatchToCrdt, tryMergeDoc, tryMergeState, validateJsonPatch, vvHasDot, vvMerge };
@@ -1,4 +1,4 @@
1
- import { $ as ObjNode, A as ApplyPatchAsActorResult, B as ElemId, C as toJson, D as ActorId, E as validateJsonPatch, F as CompilePatchOptions, G as JsonPatchToCrdtOptions, H as IntentOp, I as CrdtState, J as LwwReg, K as JsonPrimitive, L as DiffOptions, M as ApplyPatchOptions, N as ApplyResult, O as ApplyError, P as Clock, Q as ObjEntry, R as Doc, S as forkState, T as tryApplyPatchInPlace, U as JsonPatch, V as ForkStateOptions, W as JsonPatchOp, X as MergeStateOptions, Y as MergeDocOptions, Z as Node, _ as PatchError, a as tryMergeState, at as SerializedClock, b as applyPatchInPlace, c as serializeDoc, ct as SerializedRgaElem, d as compileJsonPatchToIntent, dt as TryApplyPatchResult, et as PatchErrorReason, f as diffJsonPatch, ft as TryMergeDocResult, g as stringifyJsonPointer, h as parseJsonPointer, ht as VersionVector, i as tryMergeDoc, it as RgaSeq, j as ApplyPatchInPlaceOptions, k as ApplyPatchAsActorOptions, l as serializeState, lt as SerializedState, m as jsonEquals, mt as ValidatePatchResult, n as mergeDoc, nt as ROOT_KEY, o as deserializeDoc, ot as SerializedDoc, p as getAtJson, pt as TryMergeStateResult, q as JsonValue, r as mergeState, rt as RgaElem, s as deserializeState, st as SerializedNode, t as MergeError, tt as PatchSemantics, u as PatchCompileError, ut as TryApplyPatchInPlaceResult, v as applyPatch, w as tryApplyPatch, x as createState, y as applyPatchAsActor, z as Dot } from "./merge-B8nmGV-o.js";
1
+ import { $ as JsonPatchToCrdtOptions, A as tryApplyPatchInPlace, B as CompactDocTombstonesResult, C as applyPatch, Ct as TryMergeStateResult, D as forkState, E as createState, F as ApplyPatchAsActorResult, G as DiffOptions, H as CompilePatchOptions, I as ApplyPatchInPlaceOptions, J as ElemId, K as Doc, L as ApplyPatchOptions, M as ActorId, N as ApplyError, O as toJson, P as ApplyPatchAsActorOptions, Q as JsonPatchOp, R as ApplyResult, S as PatchError, St as TryMergeDocResult, T as applyPatchInPlace, Tt as VersionVector, U as CrdtState, V as CompactStateTombstonesResult, W as DeserializeErrorReason, X as IntentOp, Y as ForkStateOptions, Z as JsonPatch, _ as diffJsonPatch, _t as SerializedState, a as MergeError, at as Node, b as parseJsonPointer, bt as TryApplyPatchInPlaceResult, c as tryMergeDoc, ct as PatchErrorReason, d as deserializeDoc, dt as RgaElem, et as JsonPrimitive, f as deserializeState, ft as RgaSeq, g as compileJsonPatchToIntent, gt as SerializedRgaElem, h as PatchCompileError, ht as SerializedNode, i as compactStateTombstones, it as MergeStateOptions, j as validateJsonPatch, k as tryApplyPatch, l as tryMergeState, lt as PatchSemantics, m as serializeState, mt as SerializedDoc, n as TraversalDepthError, nt as LwwReg, o as mergeDoc, ot as ObjEntry, p as serializeDoc, pt as SerializedClock, q as Dot, r as compactDocTombstones, rt as MergeDocOptions, s as mergeState, st as ObjNode, t as MAX_TRAVERSAL_DEPTH, tt as JsonValue, u as DeserializeError, ut as ROOT_KEY, v as getAtJson, vt as TombstoneCompactionOptions, w as applyPatchAsActor, wt as ValidatePatchResult, x as stringifyJsonPointer, xt as TryApplyPatchResult, y as jsonEquals, yt as TombstoneCompactionStats, z as Clock } from "./depth-p6fX9Ak7.js";
2
2
 
3
3
  //#region src/clock.d.ts
4
4
  /**
@@ -75,7 +75,7 @@ declare function crdtToJsonPatch(base: Doc, head: Doc, options?: DiffOptions): J
75
75
  declare function crdtToFullReplace(doc: Doc): JsonPatchOp[];
76
76
  //#endregion
77
77
  //#region src/materialize.d.ts
78
- /** Recursively convert a CRDT node graph into a plain JSON value. */
78
+ /** Convert a CRDT node graph into a plain JSON value using an explicit stack. */
79
79
  declare function materialize(node: Node): JsonValue;
80
80
  //#endregion
81
81
  //#region src/dot.d.ts
@@ -91,13 +91,25 @@ declare function newReg(value: JsonValue, dot: Dot): LwwReg;
91
91
  declare function lwwSet(reg: LwwReg, value: JsonValue, dot: Dot): void;
92
92
  declare function objSet(obj: ObjNode, key: string, node: Node, dot: Dot): void;
93
93
  declare function objRemove(obj: ObjNode, key: string, dot: Dot): void;
94
+ /**
95
+ * Prune object tombstones that satisfy a caller-provided stability predicate.
96
+ * Returns the number of removed tombstone records.
97
+ */
98
+ declare function objCompactTombstones(obj: ObjNode, isStable: (dot: Dot) => boolean): number;
94
99
  //#endregion
95
100
  //#region src/rga.d.ts
96
101
  declare const HEAD: ElemId;
97
102
  declare function rgaLinearizeIds(seq: RgaSeq): ElemId[];
98
103
  declare function rgaInsertAfter(seq: RgaSeq, prev: ElemId, id: ElemId, insDot: Dot, value: Node): void;
99
104
  declare function rgaDelete(seq: RgaSeq, id: ElemId): void;
105
+ /**
106
+ * Prune tombstoned elements that are causally stable and have no live descendants
107
+ * depending on them for sequence traversal.
108
+ *
109
+ * Returns the number of removed elements.
110
+ */
111
+ declare function rgaCompactTombstones(seq: RgaSeq, isStable: (dot: Dot) => boolean): number;
100
112
  declare function rgaIdAtIndex(seq: RgaSeq, index: number): ElemId | undefined;
101
113
  declare function rgaPrevForInsertAtIndex(seq: RgaSeq, index: number): ElemId;
102
114
  //#endregion
103
- export { ActorId, ApplyError, type ApplyPatchAsActorOptions, type ApplyPatchAsActorResult, ApplyPatchInPlaceOptions, ApplyPatchOptions, type ApplyResult, type Clock, type CompilePatchOptions, CrdtState, DiffOptions, type Doc, type Dot, type ElemId, ForkStateOptions, HEAD, type IntentOp, JsonPatch, JsonPatchOp, type JsonPatchToCrdtOptions, JsonPrimitive, JsonValue, type LwwReg, type MergeDocOptions, MergeError, MergeStateOptions, type Node, type ObjEntry, type ObjNode, PatchCompileError, PatchError, PatchErrorReason, PatchSemantics, ROOT_KEY, type RgaElem, type RgaSeq, type SerializedClock, type SerializedDoc, type SerializedNode, type SerializedRgaElem, SerializedState, TryApplyPatchInPlaceResult, TryApplyPatchResult, type TryMergeDocResult, TryMergeStateResult, ValidatePatchResult, type VersionVector, applyIntentsToCrdt, applyPatch, applyPatchAsActor, applyPatchInPlace, cloneClock, cloneDoc, compareDot, compileJsonPatchToIntent, crdtToFullReplace, crdtToJsonPatch, createClock, createState, deserializeDoc, deserializeState, diffJsonPatch, docFromJson, docFromJsonWithDot, dotToElemId, forkState, getAtJson, jsonEquals, jsonPatchToCrdt, jsonPatchToCrdtSafe, lwwSet, materialize, mergeDoc, mergeState, newObj, newReg, newSeq, nextDotForActor, objRemove, objSet, observeDot, parseJsonPointer, rgaDelete, rgaIdAtIndex, rgaInsertAfter, rgaLinearizeIds, rgaPrevForInsertAtIndex, serializeDoc, serializeState, stringifyJsonPointer, toJson, tryApplyPatch, tryApplyPatchInPlace, tryJsonPatchToCrdt, tryMergeDoc, tryMergeState, validateJsonPatch, vvHasDot, vvMerge };
115
+ export { ActorId, ApplyError, type ApplyPatchAsActorOptions, type ApplyPatchAsActorResult, ApplyPatchInPlaceOptions, ApplyPatchOptions, type ApplyResult, type Clock, type CompactDocTombstonesResult, type CompactStateTombstonesResult, type CompilePatchOptions, CrdtState, DeserializeError, DeserializeErrorReason, DiffOptions, type Doc, type Dot, type ElemId, ForkStateOptions, HEAD, type IntentOp, JsonPatch, JsonPatchOp, type JsonPatchToCrdtOptions, JsonPrimitive, JsonValue, 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 SerializedClock, type SerializedDoc, type SerializedNode, type SerializedRgaElem, SerializedState, type TombstoneCompactionOptions, type TombstoneCompactionStats, TraversalDepthError, TryApplyPatchInPlaceResult, TryApplyPatchResult, type TryMergeDocResult, TryMergeStateResult, ValidatePatchResult, type VersionVector, applyIntentsToCrdt, applyPatch, applyPatchAsActor, applyPatchInPlace, cloneClock, cloneDoc, compactDocTombstones, compactStateTombstones, compareDot, compileJsonPatchToIntent, 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, rgaLinearizeIds, rgaPrevForInsertAtIndex, serializeDoc, serializeState, stringifyJsonPointer, toJson, tryApplyPatch, tryApplyPatchInPlace, tryJsonPatchToCrdt, tryMergeDoc, tryMergeState, validateJsonPatch, vvHasDot, vvMerge };
package/dist/internals.js CHANGED
@@ -1,60 +1,67 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_merge = require('./merge-BAfuC6bf.js');
2
+ const require_compact = require('./compact-CkLd4Yh5.js');
3
3
 
4
- exports.HEAD = require_merge.HEAD;
5
- exports.MergeError = require_merge.MergeError;
6
- exports.PatchCompileError = require_merge.PatchCompileError;
7
- exports.PatchError = require_merge.PatchError;
8
- exports.ROOT_KEY = require_merge.ROOT_KEY;
9
- exports.applyIntentsToCrdt = require_merge.applyIntentsToCrdt;
10
- exports.applyPatch = require_merge.applyPatch;
11
- exports.applyPatchAsActor = require_merge.applyPatchAsActor;
12
- exports.applyPatchInPlace = require_merge.applyPatchInPlace;
13
- exports.cloneClock = require_merge.cloneClock;
14
- exports.cloneDoc = require_merge.cloneDoc;
15
- exports.compareDot = require_merge.compareDot;
16
- exports.compileJsonPatchToIntent = require_merge.compileJsonPatchToIntent;
17
- exports.crdtToFullReplace = require_merge.crdtToFullReplace;
18
- exports.crdtToJsonPatch = require_merge.crdtToJsonPatch;
19
- exports.createClock = require_merge.createClock;
20
- exports.createState = require_merge.createState;
21
- exports.deserializeDoc = require_merge.deserializeDoc;
22
- exports.deserializeState = require_merge.deserializeState;
23
- exports.diffJsonPatch = require_merge.diffJsonPatch;
24
- exports.docFromJson = require_merge.docFromJson;
25
- exports.docFromJsonWithDot = require_merge.docFromJsonWithDot;
26
- exports.dotToElemId = require_merge.dotToElemId;
27
- exports.forkState = require_merge.forkState;
28
- exports.getAtJson = require_merge.getAtJson;
29
- exports.jsonEquals = require_merge.jsonEquals;
30
- exports.jsonPatchToCrdt = require_merge.jsonPatchToCrdt;
31
- exports.jsonPatchToCrdtSafe = require_merge.jsonPatchToCrdtSafe;
32
- exports.lwwSet = require_merge.lwwSet;
33
- exports.materialize = require_merge.materialize;
34
- exports.mergeDoc = require_merge.mergeDoc;
35
- exports.mergeState = require_merge.mergeState;
36
- exports.newObj = require_merge.newObj;
37
- exports.newReg = require_merge.newReg;
38
- exports.newSeq = require_merge.newSeq;
39
- exports.nextDotForActor = require_merge.nextDotForActor;
40
- exports.objRemove = require_merge.objRemove;
41
- exports.objSet = require_merge.objSet;
42
- exports.observeDot = require_merge.observeDot;
43
- exports.parseJsonPointer = require_merge.parseJsonPointer;
44
- exports.rgaDelete = require_merge.rgaDelete;
45
- exports.rgaIdAtIndex = require_merge.rgaIdAtIndex;
46
- exports.rgaInsertAfter = require_merge.rgaInsertAfter;
47
- exports.rgaLinearizeIds = require_merge.rgaLinearizeIds;
48
- exports.rgaPrevForInsertAtIndex = require_merge.rgaPrevForInsertAtIndex;
49
- exports.serializeDoc = require_merge.serializeDoc;
50
- exports.serializeState = require_merge.serializeState;
51
- exports.stringifyJsonPointer = require_merge.stringifyJsonPointer;
52
- exports.toJson = require_merge.toJson;
53
- exports.tryApplyPatch = require_merge.tryApplyPatch;
54
- exports.tryApplyPatchInPlace = require_merge.tryApplyPatchInPlace;
55
- exports.tryJsonPatchToCrdt = require_merge.tryJsonPatchToCrdt;
56
- exports.tryMergeDoc = require_merge.tryMergeDoc;
57
- exports.tryMergeState = require_merge.tryMergeState;
58
- exports.validateJsonPatch = require_merge.validateJsonPatch;
59
- exports.vvHasDot = require_merge.vvHasDot;
60
- exports.vvMerge = require_merge.vvMerge;
4
+ exports.DeserializeError = require_compact.DeserializeError;
5
+ exports.HEAD = require_compact.HEAD;
6
+ exports.MAX_TRAVERSAL_DEPTH = require_compact.MAX_TRAVERSAL_DEPTH;
7
+ exports.MergeError = require_compact.MergeError;
8
+ exports.PatchCompileError = require_compact.PatchCompileError;
9
+ exports.PatchError = require_compact.PatchError;
10
+ exports.ROOT_KEY = require_compact.ROOT_KEY;
11
+ exports.TraversalDepthError = require_compact.TraversalDepthError;
12
+ exports.applyIntentsToCrdt = require_compact.applyIntentsToCrdt;
13
+ exports.applyPatch = require_compact.applyPatch;
14
+ exports.applyPatchAsActor = require_compact.applyPatchAsActor;
15
+ exports.applyPatchInPlace = require_compact.applyPatchInPlace;
16
+ exports.cloneClock = require_compact.cloneClock;
17
+ exports.cloneDoc = require_compact.cloneDoc;
18
+ exports.compactDocTombstones = require_compact.compactDocTombstones;
19
+ exports.compactStateTombstones = require_compact.compactStateTombstones;
20
+ exports.compareDot = require_compact.compareDot;
21
+ exports.compileJsonPatchToIntent = require_compact.compileJsonPatchToIntent;
22
+ exports.crdtToFullReplace = require_compact.crdtToFullReplace;
23
+ exports.crdtToJsonPatch = require_compact.crdtToJsonPatch;
24
+ exports.createClock = require_compact.createClock;
25
+ exports.createState = require_compact.createState;
26
+ exports.deserializeDoc = require_compact.deserializeDoc;
27
+ exports.deserializeState = require_compact.deserializeState;
28
+ exports.diffJsonPatch = require_compact.diffJsonPatch;
29
+ exports.docFromJson = require_compact.docFromJson;
30
+ exports.docFromJsonWithDot = require_compact.docFromJsonWithDot;
31
+ exports.dotToElemId = require_compact.dotToElemId;
32
+ exports.forkState = require_compact.forkState;
33
+ exports.getAtJson = require_compact.getAtJson;
34
+ exports.jsonEquals = require_compact.jsonEquals;
35
+ exports.jsonPatchToCrdt = require_compact.jsonPatchToCrdt;
36
+ exports.jsonPatchToCrdtSafe = require_compact.jsonPatchToCrdtSafe;
37
+ exports.lwwSet = require_compact.lwwSet;
38
+ exports.materialize = require_compact.materialize;
39
+ exports.mergeDoc = require_compact.mergeDoc;
40
+ exports.mergeState = require_compact.mergeState;
41
+ exports.newObj = require_compact.newObj;
42
+ exports.newReg = require_compact.newReg;
43
+ exports.newSeq = require_compact.newSeq;
44
+ exports.nextDotForActor = require_compact.nextDotForActor;
45
+ exports.objCompactTombstones = require_compact.objCompactTombstones;
46
+ exports.objRemove = require_compact.objRemove;
47
+ exports.objSet = require_compact.objSet;
48
+ exports.observeDot = require_compact.observeDot;
49
+ exports.parseJsonPointer = require_compact.parseJsonPointer;
50
+ exports.rgaCompactTombstones = require_compact.rgaCompactTombstones;
51
+ exports.rgaDelete = require_compact.rgaDelete;
52
+ exports.rgaIdAtIndex = require_compact.rgaIdAtIndex;
53
+ exports.rgaInsertAfter = require_compact.rgaInsertAfter;
54
+ exports.rgaLinearizeIds = require_compact.rgaLinearizeIds;
55
+ exports.rgaPrevForInsertAtIndex = require_compact.rgaPrevForInsertAtIndex;
56
+ exports.serializeDoc = require_compact.serializeDoc;
57
+ exports.serializeState = require_compact.serializeState;
58
+ exports.stringifyJsonPointer = require_compact.stringifyJsonPointer;
59
+ exports.toJson = require_compact.toJson;
60
+ exports.tryApplyPatch = require_compact.tryApplyPatch;
61
+ exports.tryApplyPatchInPlace = require_compact.tryApplyPatchInPlace;
62
+ exports.tryJsonPatchToCrdt = require_compact.tryJsonPatchToCrdt;
63
+ exports.tryMergeDoc = require_compact.tryMergeDoc;
64
+ exports.tryMergeState = require_compact.tryMergeState;
65
+ exports.validateJsonPatch = require_compact.validateJsonPatch;
66
+ exports.vvHasDot = require_compact.vvHasDot;
67
+ exports.vvMerge = require_compact.vvMerge;
@@ -1,3 +1,3 @@
1
- import { $ as vvMerge, A as compileJsonPatchToIntent, B as newSeq, C as crdtToJsonPatch, D as jsonPatchToCrdtSafe, E as jsonPatchToCrdt, F as stringifyJsonPointer, G as rgaDelete, H as objSet, I as ROOT_KEY, J as rgaLinearizeIds, K as rgaIdAtIndex, L as lwwSet, M as getAtJson, N as jsonEquals, O as tryJsonPatchToCrdt, P as parseJsonPointer, Q as vvHasDot, R as newObj, S as crdtToFullReplace, T as docFromJsonWithDot, U as materialize, V as objRemove, W as HEAD, X as compareDot, Y as rgaPrevForInsertAtIndex, Z as dotToElemId, _ as tryApplyPatch, a as tryMergeState, b as applyIntentsToCrdt, c as serializeDoc, d as applyPatch, et as cloneClock, f as applyPatchAsActor, g as toJson, h as forkState, i as tryMergeDoc, j as diffJsonPatch, k as PatchCompileError, l as serializeState, m as createState, n as mergeDoc, nt as nextDotForActor, o as deserializeDoc, p as applyPatchInPlace, q as rgaInsertAfter, r as mergeState, rt as observeDot, s as deserializeState, t as MergeError, tt as createClock, u as PatchError, v as tryApplyPatchInPlace, w as docFromJson, x as cloneDoc, y as validateJsonPatch, z as newReg } from "./merge-CKcP1ZPt.mjs";
1
+ import { $ as rgaLinearizeIds, A as jsonPatchToCrdtSafe, B as lwwSet, C as applyIntentsToCrdt, D as docFromJson, E as crdtToJsonPatch, F as getAtJson, G as objRemove, H as newReg, I as jsonEquals, J as HEAD, K as objSet, L as parseJsonPointer, M as PatchCompileError, N as compileJsonPatchToIntent, O as docFromJsonWithDot, P as diffJsonPatch, Q as rgaInsertAfter, R as stringifyJsonPointer, S as validateJsonPatch, T as crdtToFullReplace, U as newSeq, V as newObj, W as objCompactTombstones, X as rgaDelete, Y as rgaCompactTombstones, Z as rgaIdAtIndex, _ as createState, a as mergeState, at as MAX_TRAVERSAL_DEPTH, b as tryApplyPatch, c as DeserializeError, ct as createClock, d as serializeDoc, et as rgaPrevForInsertAtIndex, f as serializeState, g as applyPatchInPlace, h as applyPatchAsActor, i as mergeDoc, it as vvMerge, j as tryJsonPatchToCrdt, k as jsonPatchToCrdt, l as deserializeDoc, lt as nextDotForActor, m as applyPatch, n as compactStateTombstones, nt as dotToElemId, o as tryMergeDoc, ot as TraversalDepthError, p as PatchError, q as materialize, r as MergeError, rt as vvHasDot, s as tryMergeState, st as cloneClock, t as compactDocTombstones, tt as compareDot, u as deserializeState, ut as observeDot, v as forkState, w as cloneDoc, x as tryApplyPatchInPlace, y as toJson, z as ROOT_KEY } from "./compact-BJBGW9tC.mjs";
2
2
 
3
- export { HEAD, MergeError, PatchCompileError, PatchError, ROOT_KEY, applyIntentsToCrdt, applyPatch, applyPatchAsActor, applyPatchInPlace, cloneClock, cloneDoc, compareDot, compileJsonPatchToIntent, crdtToFullReplace, crdtToJsonPatch, createClock, createState, deserializeDoc, deserializeState, diffJsonPatch, docFromJson, docFromJsonWithDot, dotToElemId, forkState, getAtJson, jsonEquals, jsonPatchToCrdt, jsonPatchToCrdtSafe, lwwSet, materialize, mergeDoc, mergeState, newObj, newReg, newSeq, nextDotForActor, objRemove, objSet, observeDot, parseJsonPointer, rgaDelete, rgaIdAtIndex, rgaInsertAfter, rgaLinearizeIds, rgaPrevForInsertAtIndex, serializeDoc, serializeState, stringifyJsonPointer, toJson, tryApplyPatch, tryApplyPatchInPlace, tryJsonPatchToCrdt, tryMergeDoc, tryMergeState, validateJsonPatch, vvHasDot, vvMerge };
3
+ export { DeserializeError, HEAD, MAX_TRAVERSAL_DEPTH, MergeError, PatchCompileError, PatchError, ROOT_KEY, TraversalDepthError, applyIntentsToCrdt, applyPatch, applyPatchAsActor, applyPatchInPlace, cloneClock, cloneDoc, compactDocTombstones, compactStateTombstones, compareDot, compileJsonPatchToIntent, 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, rgaLinearizeIds, rgaPrevForInsertAtIndex, serializeDoc, serializeState, stringifyJsonPointer, toJson, tryApplyPatch, tryApplyPatchInPlace, tryJsonPatchToCrdt, tryMergeDoc, tryMergeState, validateJsonPatch, vvHasDot, vvMerge };