json-patch-to-crdt 0.0.0 → 0.1.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 +66 -78
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +8 -23
- package/dist/index.mjs +2 -2
- package/dist/internals.d.mts +80 -2
- package/dist/internals.d.ts +80 -2
- package/dist/internals.js +10 -1
- package/dist/internals.mjs +2 -2
- package/dist/{merge-DikOFBWc.mjs → merge-BqROEw61.mjs} +491 -162
- package/dist/{merge-BpAUNaPe.d.mts → merge-BrNGGkXj.d.mts} +124 -98
- package/dist/{merge-B1BFMhJJ.js → merge-CtJfKEt1.js} +544 -161
- package/dist/{merge-QmPXxE6_.d.ts → merge-DW1-p9Hj.d.ts} +124 -98
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -58,28 +58,14 @@ try {
|
|
|
58
58
|
Two peers can start from a shared state, apply patches independently, and merge:
|
|
59
59
|
|
|
60
60
|
```ts
|
|
61
|
-
import {
|
|
62
|
-
applyPatch,
|
|
63
|
-
cloneDoc,
|
|
64
|
-
createClock,
|
|
65
|
-
createState,
|
|
66
|
-
mergeState,
|
|
67
|
-
toJson,
|
|
68
|
-
type CrdtState,
|
|
69
|
-
} from "json-patch-to-crdt";
|
|
61
|
+
import { applyPatch, createState, forkState, mergeState, toJson } from "json-patch-to-crdt";
|
|
70
62
|
|
|
71
63
|
// Both peers start from the same origin state.
|
|
72
64
|
const origin = createState({ count: 0, items: ["a"] }, { actor: "origin" });
|
|
73
65
|
|
|
74
|
-
//
|
|
75
|
-
const peerA
|
|
76
|
-
|
|
77
|
-
clock: createClock("A", origin.clock.ctr),
|
|
78
|
-
};
|
|
79
|
-
const peerB: CrdtState = {
|
|
80
|
-
doc: cloneDoc(origin.doc),
|
|
81
|
-
clock: createClock("B", origin.clock.ctr),
|
|
82
|
-
};
|
|
66
|
+
// Fork shared-origin replicas with local actor identities.
|
|
67
|
+
const peerA = forkState(origin, "A");
|
|
68
|
+
const peerB = forkState(origin, "B");
|
|
83
69
|
|
|
84
70
|
// Peers diverge with independent edits.
|
|
85
71
|
const a1 = applyPatch(peerA, [
|
|
@@ -112,9 +98,9 @@ console.log(toJson(converged));
|
|
|
112
98
|
|
|
113
99
|
## Concepts
|
|
114
100
|
|
|
115
|
-
- **Doc**: CRDT document node graph.
|
|
116
|
-
- **State**: `{ doc, clock }`,
|
|
117
|
-
- **Base snapshot**:
|
|
101
|
+
- **Doc**: CRDT document node graph (primarily an internals concept).
|
|
102
|
+
- **State**: `{ doc, clock }`, used by the main API.
|
|
103
|
+
- **Base snapshot**: for `applyPatch`, pass a prior `CrdtState`; internals APIs may use raw `Doc` snapshots.
|
|
118
104
|
|
|
119
105
|
## Ordered Event Log Server Pattern
|
|
120
106
|
|
|
@@ -126,7 +112,7 @@ If your service contract is "JSON Patch in / JSON Patch out", and your backend k
|
|
|
126
112
|
- Append the accepted event to your ordered log.
|
|
127
113
|
- For downstream clients, emit `crdtToJsonPatch(clientBaseDoc, currentHeadDoc)`.
|
|
128
114
|
|
|
129
|
-
Minimal shape:
|
|
115
|
+
Minimal shape (advanced API via `json-patch-to-crdt/internals`):
|
|
130
116
|
|
|
131
117
|
```ts
|
|
132
118
|
import {
|
|
@@ -137,7 +123,7 @@ import {
|
|
|
137
123
|
type Doc,
|
|
138
124
|
type JsonPatchOp,
|
|
139
125
|
type VersionVector,
|
|
140
|
-
} from "json-patch-to-crdt";
|
|
126
|
+
} from "json-patch-to-crdt/internals";
|
|
141
127
|
|
|
142
128
|
let head: Doc = createState({ list: [] }, { actor: "server" }).doc;
|
|
143
129
|
let vv: VersionVector = {};
|
|
@@ -165,24 +151,23 @@ function applyIncomingPatch(
|
|
|
165
151
|
}
|
|
166
152
|
```
|
|
167
153
|
|
|
168
|
-
If you prefer a non-throwing low-level compile+apply path, use `jsonPatchToCrdtSafe`.
|
|
154
|
+
If you prefer a non-throwing low-level compile+apply path, use `jsonPatchToCrdtSafe` from `json-patch-to-crdt/internals`.
|
|
169
155
|
|
|
170
156
|
## Patch Semantics
|
|
171
157
|
|
|
172
158
|
- Patches are interpreted relative to a base snapshot.
|
|
173
|
-
- `applyPatch` defaults to
|
|
174
|
-
- You can pass an explicit base
|
|
175
|
-
- Patch semantics are configurable: `semantics: "
|
|
159
|
+
- `applyPatch` defaults to RFC-style sequential patch execution.
|
|
160
|
+
- You can pass an explicit base state via `applyPatch(state, patch, { base })`.
|
|
161
|
+
- Patch semantics are configurable: `semantics: "sequential"` (default) or `"base"`.
|
|
176
162
|
- In `sequential` mode with an explicit `base`, operations are interpreted against a rolling base snapshot while being applied step-by-step to the evolving head.
|
|
177
163
|
- Array indexes are mapped to element IDs based on the base snapshot.
|
|
178
164
|
- `"-"` is treated as append for array inserts.
|
|
179
|
-
- Missing arrays in the base snapshot only allow inserts at index `0` or `"-"`; other indexes throw a `PatchError` with code `409`.
|
|
180
165
|
- `test` operations can be evaluated against `head` or `base` using the `testAgainst` option.
|
|
181
166
|
|
|
182
167
|
### Semantics Modes
|
|
183
168
|
|
|
184
|
-
- `semantics: "
|
|
185
|
-
- `semantics: "
|
|
169
|
+
- `semantics: "sequential"` (default): applies operations one-by-one against the evolving head (RFC-like execution).
|
|
170
|
+
- `semantics: "base"`: interprets the full patch relative to one fixed snapshot.
|
|
186
171
|
|
|
187
172
|
#### Which Mode Should You Use?
|
|
188
173
|
|
|
@@ -206,26 +191,26 @@ const sequentialMode = applyPatch(state, [{ op: "add", path: "/list/0", value: "
|
|
|
206
191
|
|
|
207
192
|
## Delta Patches (First-Class)
|
|
208
193
|
|
|
209
|
-
|
|
194
|
+
For most applications, diff JSON values directly:
|
|
210
195
|
|
|
211
196
|
```ts
|
|
212
|
-
import {
|
|
197
|
+
import { diffJsonPatch } from "json-patch-to-crdt";
|
|
213
198
|
|
|
214
|
-
const delta =
|
|
199
|
+
const delta = diffJsonPatch(baseJson, nextJson);
|
|
215
200
|
```
|
|
216
201
|
|
|
217
|
-
|
|
202
|
+
If you already keep CRDT documents and need doc-level deltas, use the internals entry point:
|
|
218
203
|
|
|
219
204
|
```ts
|
|
220
|
-
import {
|
|
205
|
+
import { crdtToJsonPatch } from "json-patch-to-crdt/internals";
|
|
221
206
|
|
|
222
|
-
const delta =
|
|
207
|
+
const delta = crdtToJsonPatch(baseDoc, headDoc);
|
|
223
208
|
```
|
|
224
209
|
|
|
225
|
-
If you need a full-state root `replace` patch (no delta), use
|
|
210
|
+
If you need a full-state root `replace` patch (no delta), use internals:
|
|
226
211
|
|
|
227
212
|
```ts
|
|
228
|
-
import { crdtToFullReplace } from "json-patch-to-crdt";
|
|
213
|
+
import { crdtToFullReplace } from "json-patch-to-crdt/internals";
|
|
229
214
|
|
|
230
215
|
const fullPatch = crdtToFullReplace(doc);
|
|
231
216
|
// [{ op: "replace", path: "", value: { ... } }]
|
|
@@ -238,7 +223,7 @@ By default, arrays are diffed with deterministic LCS edits.
|
|
|
238
223
|
If you want atomic array replacement, pass `{ arrayStrategy: "atomic" }`:
|
|
239
224
|
|
|
240
225
|
```ts
|
|
241
|
-
const delta =
|
|
226
|
+
const delta = diffJsonPatch(baseJson, nextJson, { arrayStrategy: "atomic" });
|
|
242
227
|
```
|
|
243
228
|
|
|
244
229
|
Notes:
|
|
@@ -248,22 +233,23 @@ Notes:
|
|
|
248
233
|
|
|
249
234
|
## Merging
|
|
250
235
|
|
|
251
|
-
Merge
|
|
236
|
+
Merge full states:
|
|
252
237
|
|
|
253
238
|
```ts
|
|
254
|
-
import {
|
|
255
|
-
|
|
256
|
-
// Merge documents (low-level):
|
|
257
|
-
const mergedDoc = mergeDoc(docA, docB);
|
|
239
|
+
import { mergeState } from "json-patch-to-crdt";
|
|
258
240
|
|
|
259
241
|
// Merge full states (preserve local actor identity):
|
|
260
242
|
const mergedState = mergeState(stateA, stateB, { actor: "A" });
|
|
261
243
|
```
|
|
262
244
|
|
|
245
|
+
If you need low-level document-only merging, use `mergeDoc` from `json-patch-to-crdt/internals`.
|
|
246
|
+
|
|
263
247
|
By default, merge checks that non-empty arrays share lineage (common element IDs).
|
|
264
248
|
If you intentionally need best-effort merging of unrelated array histories, disable this guard:
|
|
265
249
|
|
|
266
250
|
```ts
|
|
251
|
+
import { mergeDoc } from "json-patch-to-crdt/internals";
|
|
252
|
+
|
|
267
253
|
const mergedDoc = mergeDoc(docA, docB, { requireSharedOrigin: false });
|
|
268
254
|
```
|
|
269
255
|
|
|
@@ -314,67 +300,69 @@ try {
|
|
|
314
300
|
const next = applyPatch(state, patch);
|
|
315
301
|
} catch (err) {
|
|
316
302
|
if (err instanceof PatchError) {
|
|
317
|
-
console.error(err.code, err.message);
|
|
303
|
+
console.error(err.code, err.reason, err.message);
|
|
318
304
|
}
|
|
319
305
|
}
|
|
320
306
|
```
|
|
321
307
|
|
|
322
|
-
|
|
323
|
-
|
|
308
|
+
Non-throwing APIs (`tryApplyPatch`, `tryApplyPatchInPlace`, `tryMergeState`) return structured conflicts.
|
|
309
|
+
Internals helpers like `jsonPatchToCrdtSafe` and `tryMergeDoc` return the same shape:
|
|
310
|
+
|
|
311
|
+
- `{ ok: false, code: 409, reason, message, path?, opIndex? }`
|
|
324
312
|
|
|
325
313
|
## API Summary
|
|
326
314
|
|
|
327
315
|
### State helpers
|
|
328
316
|
|
|
329
317
|
- `createState(initial, { actor, start? })` - Create a new CRDT state from JSON.
|
|
330
|
-
- `
|
|
331
|
-
- `
|
|
332
|
-
- `
|
|
318
|
+
- `forkState(origin, actor)` - Fork a shared-origin replica with a new local actor ID.
|
|
319
|
+
- `applyPatch(state, patch, options?)` - Apply a patch immutably, returning a new state (`semantics: "sequential"` by default).
|
|
320
|
+
- `applyPatchInPlace(state, patch, options?)` - Apply a patch by mutating state in place (`atomic: true` by default).
|
|
321
|
+
- `tryApplyPatch(state, patch, options?)` - Non-throwing immutable apply (`{ ok: true, state }` or `{ ok: false, error }`).
|
|
322
|
+
- `tryApplyPatchInPlace(state, patch, options?)` - Non-throwing in-place apply result.
|
|
323
|
+
- `validateJsonPatch(baseJson, patch, options?)` - Preflight patch validation (non-mutating).
|
|
333
324
|
- `toJson(docOrState)` - Materialize a JSON value from a doc or state.
|
|
334
|
-
- `
|
|
335
|
-
|
|
336
|
-
### Clock helpers
|
|
337
|
-
|
|
338
|
-
- `createClock(actor, start?)` - Create a new clock for dot generation.
|
|
339
|
-
- `cloneClock(clock)` - Clone a clock independently.
|
|
340
|
-
- `nextDotForActor(vv, actor)` - Generate a dot for any actor from a shared version-vector map.
|
|
341
|
-
- `observeDot(vv, dot)` - Record observed dots into that map.
|
|
342
|
-
|
|
343
|
-
### Document helpers
|
|
344
|
-
|
|
345
|
-
- `docFromJson(value, nextDot)` - Create a CRDT doc using fresh dots per node.
|
|
346
|
-
- `cloneDoc(doc)` - Deep-clone a document.
|
|
347
|
-
- `materialize(node)` - Convert a CRDT node to a JSON value.
|
|
325
|
+
- `applyPatch`/`tryApplyPatch` options: `base` expects a prior `CrdtState` snapshot (not a raw doc), plus `semantics` and `testAgainst`.
|
|
326
|
+
- `PatchError` - Error class thrown for failed patches (`code`, `reason`, `message`, optional `path`/`opIndex`).
|
|
348
327
|
|
|
349
328
|
### Merge helpers
|
|
350
329
|
|
|
351
|
-
- `mergeDoc(a, b, options?)` - Merge two CRDT documents (`options.requireSharedOrigin` defaults to `true`).
|
|
352
330
|
- `mergeState(a, b, options?)` - Merge two CRDT states (doc + clock), preserving actor identity (`options.actor`) and optional shared-origin checks.
|
|
331
|
+
- `tryMergeState(a, b, options?)` - Non-throwing merge-state result.
|
|
332
|
+
- `MergeError` - Error class thrown by throwing merge helpers.
|
|
353
333
|
|
|
354
334
|
### Patch helpers
|
|
355
335
|
|
|
356
|
-
- `compileJsonPatchToIntent(baseJson, patch)` - Compile JSON Patch to intent operations.
|
|
357
|
-
- `applyIntentsToCrdt(base, head, intents, newDot, evalTestAgainst?, bumpCounterAbove?)` - Apply intents to a document.
|
|
358
|
-
- `jsonPatchToCrdt(base, head, patch, newDot, evalTestAgainst?, bumpCounterAbove?)` - Compile and apply in one step.
|
|
359
|
-
- `jsonPatchToCrdtSafe(base, head, patch, newDot, evalTestAgainst?, bumpCounterAbove?)` - Safe compile+apply wrapper that returns `409` results instead of throwing on compile-time patch issues.
|
|
360
336
|
- `diffJsonPatch(baseJson, nextJson, options?)` - Compute a JSON Patch delta between two JSON values.
|
|
361
|
-
- `crdtToJsonPatch(baseDoc, headDoc, options?)` - Compute a JSON Patch delta between two CRDT docs.
|
|
362
|
-
- `crdtToFullReplace(doc)` - Emit a full-state root `replace` patch.
|
|
363
337
|
|
|
364
338
|
### Serialization
|
|
365
339
|
|
|
366
|
-
- `serializeDoc(doc)` / `deserializeDoc(payload)` - Serialize/restore a document.
|
|
367
340
|
- `serializeState(state)` / `deserializeState(payload)` - Serialize/restore a full state.
|
|
368
341
|
|
|
369
342
|
### Internals (`json-patch-to-crdt/internals`)
|
|
370
343
|
|
|
371
|
-
|
|
344
|
+
Advanced helpers are available via a separate entry point:
|
|
372
345
|
|
|
373
346
|
```ts
|
|
374
|
-
import {
|
|
347
|
+
import {
|
|
348
|
+
applyPatchAsActor,
|
|
349
|
+
createClock,
|
|
350
|
+
docFromJson,
|
|
351
|
+
mergeDoc,
|
|
352
|
+
jsonPatchToCrdtSafe,
|
|
353
|
+
compareDot,
|
|
354
|
+
rgaInsertAfter,
|
|
355
|
+
HEAD,
|
|
356
|
+
} from "json-patch-to-crdt/internals";
|
|
375
357
|
```
|
|
376
358
|
|
|
377
|
-
|
|
359
|
+
Internals includes low-level helpers such as:
|
|
360
|
+
|
|
361
|
+
- Actor/version-vector helpers: `applyPatchAsActor`, `createClock`, `cloneClock`, `nextDotForActor`, `observeDot`.
|
|
362
|
+
- Doc-level APIs: `docFromJson`, `docFromJsonWithDot`, `cloneDoc`, `materialize`, `mergeDoc`, `tryMergeDoc`.
|
|
363
|
+
- Intent compiler/apply pipeline: `compileJsonPatchToIntent`, `applyIntentsToCrdt`, `jsonPatchToCrdt`, `jsonPatchToCrdtSafe`, `tryJsonPatchToCrdt`.
|
|
364
|
+
- Doc delta/serialization helpers: `crdtToJsonPatch`, `crdtToFullReplace`, `serializeDoc`, `deserializeDoc`.
|
|
365
|
+
- CRDT primitives/utilities: `compareDot`, `vvHasDot`, `vvMerge`, `dotToElemId`, `newObj`, `newSeq`, `newReg`, `lwwSet`, `objSet`, `objRemove`, `HEAD`, `rgaInsertAfter`, `rgaDelete`, `rgaLinearizeIds`, `rgaPrevForInsertAtIndex`, `rgaIdAtIndex`.
|
|
378
366
|
|
|
379
367
|
## Determinism
|
|
380
368
|
|
|
@@ -392,10 +380,10 @@ This typically means the patch could not be applied against the base snapshot. C
|
|
|
392
380
|
- Base array missing for a non-append insert.
|
|
393
381
|
|
|
394
382
|
**How do I avoid `409` for arrays?**
|
|
395
|
-
Always pass a base snapshot that matches the array you are patching. If the array may be missing,
|
|
383
|
+
Always pass a base state snapshot that matches the array you are patching. If the array may be missing, create the parent path explicitly before inserting into it.
|
|
396
384
|
|
|
397
385
|
**How do I get a full-state patch instead of a delta?**
|
|
398
|
-
Use `crdtToFullReplace(doc)` which emits a single root `replace` patch.
|
|
386
|
+
Use `crdtToFullReplace(doc)` from `json-patch-to-crdt/internals`, which emits a single root `replace` patch.
|
|
399
387
|
|
|
400
388
|
**Why do array deltas look bigger than expected?**
|
|
401
389
|
LCS diffs are deterministic, not minimal. If you prefer one-op array replacement, use `{ arrayStrategy: "atomic" }`.
|
|
@@ -404,7 +392,7 @@ LCS diffs are deterministic, not minimal. If you prefer one-op array replacement
|
|
|
404
392
|
No. It is deterministic and usually compact, but not guaranteed to be minimal.
|
|
405
393
|
|
|
406
394
|
**How do I merge states from two peers?**
|
|
407
|
-
Use `
|
|
395
|
+
Use `forkState(origin, actor)` to create each peer from the same origin, then `mergeState(local, remote, { actor: localActorId })`. Each peer should keep a stable unique actor ID across merges. See the [Multi-Peer Sync](#multi-peer-sync) example above.
|
|
408
396
|
|
|
409
397
|
**Why can my local counter jump after a merge?**
|
|
410
398
|
Array inserts that target an existing predecessor may need to outrank sibling insert dots for deterministic ordering. The library can fast-forward the local counter in constant time to avoid expensive loops, but the resulting counter value may still jump upward when merging with peers that already have high counters.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { type ActorId, type
|
|
1
|
+
import { $ as PatchErrorReason, C as toJson, D as ActorId, E as validateJsonPatch, G as JsonPrimitive, H as JsonPatch, I as CrdtState, K as JsonValue, L as DiffOptions, M as ApplyPatchOptions, O as ApplyError, S as forkState, T as tryApplyPatchInPlace, U as JsonPatchOp, Y as MergeStateOptions, _ as PatchError, a as tryMergeState, b as applyPatchInPlace, ct as SerializedState, et as PatchSemantics, f as diffJsonPatch, ft as TryMergeStateResult, j as ApplyPatchInPlaceOptions, l as serializeState, lt as TryApplyPatchInPlaceResult, pt as ValidatePatchResult, r as mergeState, s as deserializeState, t as MergeError, ut as TryApplyPatchResult, v as applyPatch, w as tryApplyPatch, x as createState } from "./merge-BrNGGkXj.mjs";
|
|
2
|
+
export { type ActorId, type ApplyError, type ApplyPatchInPlaceOptions, type ApplyPatchOptions, type CrdtState, type DiffOptions, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { type ActorId, type
|
|
1
|
+
import { $ as PatchErrorReason, C as toJson, D as ActorId, E as validateJsonPatch, G as JsonPrimitive, H as JsonPatch, I as CrdtState, K as JsonValue, L as DiffOptions, M as ApplyPatchOptions, O as ApplyError, S as forkState, T as tryApplyPatchInPlace, U as JsonPatchOp, Y as MergeStateOptions, _ as PatchError, a as tryMergeState, b as applyPatchInPlace, ct as SerializedState, et as PatchSemantics, f as diffJsonPatch, ft as TryMergeStateResult, j as ApplyPatchInPlaceOptions, l as serializeState, lt as TryApplyPatchInPlaceResult, pt as ValidatePatchResult, r as mergeState, s as deserializeState, t as MergeError, ut as TryApplyPatchResult, v as applyPatch, w as tryApplyPatch, x as createState } from "./merge-DW1-p9Hj.js";
|
|
2
|
+
export { type ActorId, type ApplyError, type ApplyPatchInPlaceOptions, type ApplyPatchOptions, type CrdtState, type DiffOptions, 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 };
|
package/dist/index.js
CHANGED
|
@@ -1,33 +1,18 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_merge = require('./merge-
|
|
2
|
+
const require_merge = require('./merge-CtJfKEt1.js');
|
|
3
3
|
|
|
4
|
+
exports.MergeError = require_merge.MergeError;
|
|
4
5
|
exports.PatchError = require_merge.PatchError;
|
|
5
|
-
exports.applyIntentsToCrdt = require_merge.applyIntentsToCrdt;
|
|
6
6
|
exports.applyPatch = require_merge.applyPatch;
|
|
7
|
-
exports.applyPatchAsActor = require_merge.applyPatchAsActor;
|
|
8
7
|
exports.applyPatchInPlace = require_merge.applyPatchInPlace;
|
|
9
|
-
exports.cloneClock = require_merge.cloneClock;
|
|
10
|
-
exports.cloneDoc = require_merge.cloneDoc;
|
|
11
|
-
exports.compileJsonPatchToIntent = require_merge.compileJsonPatchToIntent;
|
|
12
|
-
exports.crdtToFullReplace = require_merge.crdtToFullReplace;
|
|
13
|
-
exports.crdtToJsonPatch = require_merge.crdtToJsonPatch;
|
|
14
|
-
exports.createClock = require_merge.createClock;
|
|
15
8
|
exports.createState = require_merge.createState;
|
|
16
|
-
exports.deserializeDoc = require_merge.deserializeDoc;
|
|
17
9
|
exports.deserializeState = require_merge.deserializeState;
|
|
18
10
|
exports.diffJsonPatch = require_merge.diffJsonPatch;
|
|
19
|
-
exports.
|
|
20
|
-
exports.getAtJson = require_merge.getAtJson;
|
|
21
|
-
exports.jsonEquals = require_merge.jsonEquals;
|
|
22
|
-
exports.jsonPatchToCrdt = require_merge.jsonPatchToCrdt;
|
|
23
|
-
exports.jsonPatchToCrdtSafe = require_merge.jsonPatchToCrdtSafe;
|
|
24
|
-
exports.materialize = require_merge.materialize;
|
|
25
|
-
exports.mergeDoc = require_merge.mergeDoc;
|
|
11
|
+
exports.forkState = require_merge.forkState;
|
|
26
12
|
exports.mergeState = require_merge.mergeState;
|
|
27
|
-
exports.nextDotForActor = require_merge.nextDotForActor;
|
|
28
|
-
exports.observeDot = require_merge.observeDot;
|
|
29
|
-
exports.parseJsonPointer = require_merge.parseJsonPointer;
|
|
30
|
-
exports.serializeDoc = require_merge.serializeDoc;
|
|
31
13
|
exports.serializeState = require_merge.serializeState;
|
|
32
|
-
exports.
|
|
33
|
-
exports.
|
|
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;
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
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-BqROEw61.mjs";
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { MergeError, PatchError, applyPatch, applyPatchInPlace, createState, deserializeState, diffJsonPatch, forkState, mergeState, serializeState, toJson, tryApplyPatch, tryApplyPatchInPlace, tryMergeState, validateJsonPatch };
|
package/dist/internals.d.mts
CHANGED
|
@@ -1,5 +1,83 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as PatchErrorReason, A as ApplyPatchAsActorResult, B as ElemId, C as toJson, D as ActorId, E as validateJsonPatch, F as CompilePatchOptions, G as JsonPrimitive, H as JsonPatch, I as CrdtState, J as MergeDocOptions, K as JsonValue, L as DiffOptions, M as ApplyPatchOptions, N as ApplyResult, O as ApplyError, P as Clock, Q as ObjNode, R as Doc, S as forkState, T as tryApplyPatchInPlace, U as JsonPatchOp, V as IntentOp, W as JsonPatchToCrdtOptions, X as Node, Y as MergeStateOptions, Z as ObjEntry, _ as PatchError, a as tryMergeState, at as SerializedDoc, b as applyPatchInPlace, c as serializeDoc, ct as SerializedState, d as compileJsonPatchToIntent, dt as TryMergeDocResult, et as PatchSemantics, f as diffJsonPatch, ft as TryMergeStateResult, g as stringifyJsonPointer, h as parseJsonPointer, i as tryMergeDoc, it as SerializedClock, j as ApplyPatchInPlaceOptions, k as ApplyPatchAsActorOptions, l as serializeState, lt as TryApplyPatchInPlaceResult, m as jsonEquals, mt as VersionVector, n as mergeDoc, nt as RgaElem, o as deserializeDoc, ot as SerializedNode, p as getAtJson, pt as ValidatePatchResult, q as LwwReg, r as mergeState, rt as RgaSeq, s as deserializeState, st as SerializedRgaElem, t as MergeError, tt as ROOT_KEY, u as PatchCompileError, ut as TryApplyPatchResult, v as applyPatch, w as tryApplyPatch, x as createState, y as applyPatchAsActor, z as Dot } from "./merge-BrNGGkXj.mjs";
|
|
2
2
|
|
|
3
|
+
//#region src/clock.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Create a new clock for the given actor. Each call to `clock.next()` yields a fresh `Dot`.
|
|
6
|
+
* @param actor - Unique identifier for this peer.
|
|
7
|
+
* @param start - Initial counter value (defaults to 0).
|
|
8
|
+
*/
|
|
9
|
+
declare function createClock(actor: ActorId, start?: number): Clock;
|
|
10
|
+
/** Create an independent copy of a clock at the same counter position. */
|
|
11
|
+
declare function cloneClock(clock: Clock): Clock;
|
|
12
|
+
/**
|
|
13
|
+
* Generate the next per-actor dot from a mutable version vector.
|
|
14
|
+
* Useful when a server needs to mint dots for many actors.
|
|
15
|
+
*/
|
|
16
|
+
declare function nextDotForActor(vv: VersionVector, actor: ActorId): Dot;
|
|
17
|
+
/** Record an observed dot in a version vector. */
|
|
18
|
+
declare function observeDot(vv: VersionVector, dot: Dot): void;
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/doc.d.ts
|
|
21
|
+
/**
|
|
22
|
+
* Create a CRDT document from a JSON value, using fresh dots for each node.
|
|
23
|
+
* @param value - The JSON value to convert.
|
|
24
|
+
* @param nextDot - A function that generates a unique `Dot` on each call.
|
|
25
|
+
* @returns A new CRDT `Doc`.
|
|
26
|
+
*/
|
|
27
|
+
declare function docFromJson(value: JsonValue, nextDot: () => Dot): Doc;
|
|
28
|
+
/**
|
|
29
|
+
* Legacy: create a doc using a single dot with counter offsets for array children.
|
|
30
|
+
* Prefer `docFromJson(value, nextDot)` to ensure unique dots per node.
|
|
31
|
+
*/
|
|
32
|
+
declare function docFromJsonWithDot(value: JsonValue, dot: Dot): Doc;
|
|
33
|
+
/** Deep-clone a CRDT document. The clone is fully independent of the original. */
|
|
34
|
+
declare function cloneDoc(doc: Doc): Doc;
|
|
35
|
+
/**
|
|
36
|
+
* Apply compiled intent operations to a CRDT document.
|
|
37
|
+
* Array indices are resolved against the base document.
|
|
38
|
+
* @param base - The base document snapshot used for index mapping and test evaluation.
|
|
39
|
+
* @param head - The target document to mutate.
|
|
40
|
+
* @param intents - Compiled intent operations from `compileJsonPatchToIntent`.
|
|
41
|
+
* @param newDot - A function that generates a unique `Dot` per mutation.
|
|
42
|
+
* @param evalTestAgainst - Whether `test` ops are evaluated against `"head"` or `"base"`.
|
|
43
|
+
* @param bumpCounterAbove - Optional hook that can fast-forward the underlying counter before inserts.
|
|
44
|
+
* @returns `{ ok: true }` on success, or `{ ok: false, code: 409, message }` on conflict.
|
|
45
|
+
*/
|
|
46
|
+
declare function applyIntentsToCrdt(base: Doc, head: Doc, intents: IntentOp[], newDot: () => Dot, evalTestAgainst?: "head" | "base", bumpCounterAbove?: (ctr: number) => void): ApplyResult;
|
|
47
|
+
/**
|
|
48
|
+
* Convenience wrapper: compile a JSON Patch and apply it to a CRDT document.
|
|
49
|
+
* Overloads:
|
|
50
|
+
* - positional: `jsonPatchToCrdt(base, head, patch, newDot, evalTestAgainst?, bumpCounterAbove?)`
|
|
51
|
+
* - object: `jsonPatchToCrdt({ base, head, patch, newDot, evalTestAgainst?, bumpCounterAbove?, semantics? })`
|
|
52
|
+
*/
|
|
53
|
+
declare function jsonPatchToCrdt(options: JsonPatchToCrdtOptions): ApplyResult;
|
|
54
|
+
declare function jsonPatchToCrdt(base: Doc, head: Doc, patch: JsonPatchOp[], newDot: () => Dot, evalTestAgainst?: "head" | "base", bumpCounterAbove?: (ctr: number) => void): ApplyResult;
|
|
55
|
+
/**
|
|
56
|
+
* Safe wrapper around `jsonPatchToCrdt`.
|
|
57
|
+
* This function never throws and always returns an `ApplyResult`.
|
|
58
|
+
*/
|
|
59
|
+
declare function jsonPatchToCrdtSafe(options: JsonPatchToCrdtOptions): ApplyResult;
|
|
60
|
+
declare function jsonPatchToCrdtSafe(base: Doc, head: Doc, patch: JsonPatchOp[], newDot: () => Dot, evalTestAgainst?: "head" | "base", bumpCounterAbove?: (ctr: number) => void): ApplyResult;
|
|
61
|
+
/** Alias for codebases that prefer `try*` naming for non-throwing APIs. */
|
|
62
|
+
declare const tryJsonPatchToCrdt: typeof jsonPatchToCrdtSafe;
|
|
63
|
+
/**
|
|
64
|
+
* Generate a JSON Patch delta between two CRDT documents.
|
|
65
|
+
* @param base - The base document snapshot.
|
|
66
|
+
* @param head - The current document state.
|
|
67
|
+
* @param options - Diff options (e.g. `{ arrayStrategy: "lcs" }`).
|
|
68
|
+
* @returns An array of JSON Patch operations that transform base into head.
|
|
69
|
+
*/
|
|
70
|
+
declare function crdtToJsonPatch(base: Doc, head: Doc, options?: DiffOptions): JsonPatchOp[];
|
|
71
|
+
/**
|
|
72
|
+
* Emit a single root `replace` patch representing the full document state.
|
|
73
|
+
* Use `crdtToJsonPatch(base, head)` for delta patches instead.
|
|
74
|
+
*/
|
|
75
|
+
declare function crdtToFullReplace(doc: Doc): JsonPatchOp[];
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/materialize.d.ts
|
|
78
|
+
/** Recursively convert a CRDT node graph into a plain JSON value. */
|
|
79
|
+
declare function materialize(node: Node): JsonValue;
|
|
80
|
+
//#endregion
|
|
3
81
|
//#region src/dot.d.ts
|
|
4
82
|
declare function compareDot(a: Dot, b: Dot): number;
|
|
5
83
|
declare function vvHasDot(vv: VersionVector, d: Dot): boolean;
|
|
@@ -22,4 +100,4 @@ declare function rgaDelete(seq: RgaSeq, id: ElemId): void;
|
|
|
22
100
|
declare function rgaIdAtIndex(seq: RgaSeq, index: number): ElemId | undefined;
|
|
23
101
|
declare function rgaPrevForInsertAtIndex(seq: RgaSeq, index: number): ElemId;
|
|
24
102
|
//#endregion
|
|
25
|
-
export { ActorId, ApplyPatchAsActorResult, ApplyPatchOptions, ApplyResult, Clock, CrdtState, DiffOptions, Doc, Dot, ElemId, HEAD, IntentOp, JsonPatch, JsonPatchOp, JsonPrimitive, JsonValue, LwwReg, MergeDocOptions, MergeStateOptions, Node, ObjEntry, ObjNode, PatchError, PatchSemantics, ROOT_KEY, RgaElem, RgaSeq, SerializedDoc, SerializedNode, SerializedState, VersionVector, applyIntentsToCrdt, applyPatch, applyPatchAsActor, applyPatchInPlace, cloneClock, cloneDoc, compareDot, compileJsonPatchToIntent, crdtToFullReplace, crdtToJsonPatch, createClock, createState, deserializeDoc, deserializeState, diffJsonPatch, docFromJson, docFromJsonWithDot, dotToElemId, 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, vvHasDot, vvMerge };
|
|
103
|
+
export { ActorId, ApplyError, type ApplyPatchAsActorOptions, type ApplyPatchAsActorResult, ApplyPatchInPlaceOptions, ApplyPatchOptions, type ApplyResult, type Clock, type CompilePatchOptions, CrdtState, DiffOptions, type Doc, type Dot, type ElemId, 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 };
|
package/dist/internals.d.ts
CHANGED
|
@@ -1,5 +1,83 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as PatchErrorReason, A as ApplyPatchAsActorResult, B as ElemId, C as toJson, D as ActorId, E as validateJsonPatch, F as CompilePatchOptions, G as JsonPrimitive, H as JsonPatch, I as CrdtState, J as MergeDocOptions, K as JsonValue, L as DiffOptions, M as ApplyPatchOptions, N as ApplyResult, O as ApplyError, P as Clock, Q as ObjNode, R as Doc, S as forkState, T as tryApplyPatchInPlace, U as JsonPatchOp, V as IntentOp, W as JsonPatchToCrdtOptions, X as Node, Y as MergeStateOptions, Z as ObjEntry, _ as PatchError, a as tryMergeState, at as SerializedDoc, b as applyPatchInPlace, c as serializeDoc, ct as SerializedState, d as compileJsonPatchToIntent, dt as TryMergeDocResult, et as PatchSemantics, f as diffJsonPatch, ft as TryMergeStateResult, g as stringifyJsonPointer, h as parseJsonPointer, i as tryMergeDoc, it as SerializedClock, j as ApplyPatchInPlaceOptions, k as ApplyPatchAsActorOptions, l as serializeState, lt as TryApplyPatchInPlaceResult, m as jsonEquals, mt as VersionVector, n as mergeDoc, nt as RgaElem, o as deserializeDoc, ot as SerializedNode, p as getAtJson, pt as ValidatePatchResult, q as LwwReg, r as mergeState, rt as RgaSeq, s as deserializeState, st as SerializedRgaElem, t as MergeError, tt as ROOT_KEY, u as PatchCompileError, ut as TryApplyPatchResult, v as applyPatch, w as tryApplyPatch, x as createState, y as applyPatchAsActor, z as Dot } from "./merge-DW1-p9Hj.js";
|
|
2
2
|
|
|
3
|
+
//#region src/clock.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Create a new clock for the given actor. Each call to `clock.next()` yields a fresh `Dot`.
|
|
6
|
+
* @param actor - Unique identifier for this peer.
|
|
7
|
+
* @param start - Initial counter value (defaults to 0).
|
|
8
|
+
*/
|
|
9
|
+
declare function createClock(actor: ActorId, start?: number): Clock;
|
|
10
|
+
/** Create an independent copy of a clock at the same counter position. */
|
|
11
|
+
declare function cloneClock(clock: Clock): Clock;
|
|
12
|
+
/**
|
|
13
|
+
* Generate the next per-actor dot from a mutable version vector.
|
|
14
|
+
* Useful when a server needs to mint dots for many actors.
|
|
15
|
+
*/
|
|
16
|
+
declare function nextDotForActor(vv: VersionVector, actor: ActorId): Dot;
|
|
17
|
+
/** Record an observed dot in a version vector. */
|
|
18
|
+
declare function observeDot(vv: VersionVector, dot: Dot): void;
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/doc.d.ts
|
|
21
|
+
/**
|
|
22
|
+
* Create a CRDT document from a JSON value, using fresh dots for each node.
|
|
23
|
+
* @param value - The JSON value to convert.
|
|
24
|
+
* @param nextDot - A function that generates a unique `Dot` on each call.
|
|
25
|
+
* @returns A new CRDT `Doc`.
|
|
26
|
+
*/
|
|
27
|
+
declare function docFromJson(value: JsonValue, nextDot: () => Dot): Doc;
|
|
28
|
+
/**
|
|
29
|
+
* Legacy: create a doc using a single dot with counter offsets for array children.
|
|
30
|
+
* Prefer `docFromJson(value, nextDot)` to ensure unique dots per node.
|
|
31
|
+
*/
|
|
32
|
+
declare function docFromJsonWithDot(value: JsonValue, dot: Dot): Doc;
|
|
33
|
+
/** Deep-clone a CRDT document. The clone is fully independent of the original. */
|
|
34
|
+
declare function cloneDoc(doc: Doc): Doc;
|
|
35
|
+
/**
|
|
36
|
+
* Apply compiled intent operations to a CRDT document.
|
|
37
|
+
* Array indices are resolved against the base document.
|
|
38
|
+
* @param base - The base document snapshot used for index mapping and test evaluation.
|
|
39
|
+
* @param head - The target document to mutate.
|
|
40
|
+
* @param intents - Compiled intent operations from `compileJsonPatchToIntent`.
|
|
41
|
+
* @param newDot - A function that generates a unique `Dot` per mutation.
|
|
42
|
+
* @param evalTestAgainst - Whether `test` ops are evaluated against `"head"` or `"base"`.
|
|
43
|
+
* @param bumpCounterAbove - Optional hook that can fast-forward the underlying counter before inserts.
|
|
44
|
+
* @returns `{ ok: true }` on success, or `{ ok: false, code: 409, message }` on conflict.
|
|
45
|
+
*/
|
|
46
|
+
declare function applyIntentsToCrdt(base: Doc, head: Doc, intents: IntentOp[], newDot: () => Dot, evalTestAgainst?: "head" | "base", bumpCounterAbove?: (ctr: number) => void): ApplyResult;
|
|
47
|
+
/**
|
|
48
|
+
* Convenience wrapper: compile a JSON Patch and apply it to a CRDT document.
|
|
49
|
+
* Overloads:
|
|
50
|
+
* - positional: `jsonPatchToCrdt(base, head, patch, newDot, evalTestAgainst?, bumpCounterAbove?)`
|
|
51
|
+
* - object: `jsonPatchToCrdt({ base, head, patch, newDot, evalTestAgainst?, bumpCounterAbove?, semantics? })`
|
|
52
|
+
*/
|
|
53
|
+
declare function jsonPatchToCrdt(options: JsonPatchToCrdtOptions): ApplyResult;
|
|
54
|
+
declare function jsonPatchToCrdt(base: Doc, head: Doc, patch: JsonPatchOp[], newDot: () => Dot, evalTestAgainst?: "head" | "base", bumpCounterAbove?: (ctr: number) => void): ApplyResult;
|
|
55
|
+
/**
|
|
56
|
+
* Safe wrapper around `jsonPatchToCrdt`.
|
|
57
|
+
* This function never throws and always returns an `ApplyResult`.
|
|
58
|
+
*/
|
|
59
|
+
declare function jsonPatchToCrdtSafe(options: JsonPatchToCrdtOptions): ApplyResult;
|
|
60
|
+
declare function jsonPatchToCrdtSafe(base: Doc, head: Doc, patch: JsonPatchOp[], newDot: () => Dot, evalTestAgainst?: "head" | "base", bumpCounterAbove?: (ctr: number) => void): ApplyResult;
|
|
61
|
+
/** Alias for codebases that prefer `try*` naming for non-throwing APIs. */
|
|
62
|
+
declare const tryJsonPatchToCrdt: typeof jsonPatchToCrdtSafe;
|
|
63
|
+
/**
|
|
64
|
+
* Generate a JSON Patch delta between two CRDT documents.
|
|
65
|
+
* @param base - The base document snapshot.
|
|
66
|
+
* @param head - The current document state.
|
|
67
|
+
* @param options - Diff options (e.g. `{ arrayStrategy: "lcs" }`).
|
|
68
|
+
* @returns An array of JSON Patch operations that transform base into head.
|
|
69
|
+
*/
|
|
70
|
+
declare function crdtToJsonPatch(base: Doc, head: Doc, options?: DiffOptions): JsonPatchOp[];
|
|
71
|
+
/**
|
|
72
|
+
* Emit a single root `replace` patch representing the full document state.
|
|
73
|
+
* Use `crdtToJsonPatch(base, head)` for delta patches instead.
|
|
74
|
+
*/
|
|
75
|
+
declare function crdtToFullReplace(doc: Doc): JsonPatchOp[];
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/materialize.d.ts
|
|
78
|
+
/** Recursively convert a CRDT node graph into a plain JSON value. */
|
|
79
|
+
declare function materialize(node: Node): JsonValue;
|
|
80
|
+
//#endregion
|
|
3
81
|
//#region src/dot.d.ts
|
|
4
82
|
declare function compareDot(a: Dot, b: Dot): number;
|
|
5
83
|
declare function vvHasDot(vv: VersionVector, d: Dot): boolean;
|
|
@@ -22,4 +100,4 @@ declare function rgaDelete(seq: RgaSeq, id: ElemId): void;
|
|
|
22
100
|
declare function rgaIdAtIndex(seq: RgaSeq, index: number): ElemId | undefined;
|
|
23
101
|
declare function rgaPrevForInsertAtIndex(seq: RgaSeq, index: number): ElemId;
|
|
24
102
|
//#endregion
|
|
25
|
-
export { ActorId, ApplyPatchAsActorResult, ApplyPatchOptions, ApplyResult, Clock, CrdtState, DiffOptions, Doc, Dot, ElemId, HEAD, IntentOp, JsonPatch, JsonPatchOp, JsonPrimitive, JsonValue, LwwReg, MergeDocOptions, MergeStateOptions, Node, ObjEntry, ObjNode, PatchError, PatchSemantics, ROOT_KEY, RgaElem, RgaSeq, SerializedDoc, SerializedNode, SerializedState, VersionVector, applyIntentsToCrdt, applyPatch, applyPatchAsActor, applyPatchInPlace, cloneClock, cloneDoc, compareDot, compileJsonPatchToIntent, crdtToFullReplace, crdtToJsonPatch, createClock, createState, deserializeDoc, deserializeState, diffJsonPatch, docFromJson, docFromJsonWithDot, dotToElemId, 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, vvHasDot, vvMerge };
|
|
103
|
+
export { ActorId, ApplyError, type ApplyPatchAsActorOptions, type ApplyPatchAsActorResult, ApplyPatchInPlaceOptions, ApplyPatchOptions, type ApplyResult, type Clock, type CompilePatchOptions, CrdtState, DiffOptions, type Doc, type Dot, type ElemId, 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 };
|
package/dist/internals.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_merge = require('./merge-
|
|
2
|
+
const require_merge = require('./merge-CtJfKEt1.js');
|
|
3
3
|
|
|
4
4
|
exports.HEAD = require_merge.HEAD;
|
|
5
|
+
exports.MergeError = require_merge.MergeError;
|
|
6
|
+
exports.PatchCompileError = require_merge.PatchCompileError;
|
|
5
7
|
exports.PatchError = require_merge.PatchError;
|
|
6
8
|
exports.ROOT_KEY = require_merge.ROOT_KEY;
|
|
7
9
|
exports.applyIntentsToCrdt = require_merge.applyIntentsToCrdt;
|
|
@@ -22,6 +24,7 @@ exports.diffJsonPatch = require_merge.diffJsonPatch;
|
|
|
22
24
|
exports.docFromJson = require_merge.docFromJson;
|
|
23
25
|
exports.docFromJsonWithDot = require_merge.docFromJsonWithDot;
|
|
24
26
|
exports.dotToElemId = require_merge.dotToElemId;
|
|
27
|
+
exports.forkState = require_merge.forkState;
|
|
25
28
|
exports.getAtJson = require_merge.getAtJson;
|
|
26
29
|
exports.jsonEquals = require_merge.jsonEquals;
|
|
27
30
|
exports.jsonPatchToCrdt = require_merge.jsonPatchToCrdt;
|
|
@@ -47,5 +50,11 @@ exports.serializeDoc = require_merge.serializeDoc;
|
|
|
47
50
|
exports.serializeState = require_merge.serializeState;
|
|
48
51
|
exports.stringifyJsonPointer = require_merge.stringifyJsonPointer;
|
|
49
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;
|
|
50
59
|
exports.vvHasDot = require_merge.vvHasDot;
|
|
51
60
|
exports.vvMerge = require_merge.vvMerge;
|
package/dist/internals.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as
|
|
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-BqROEw61.mjs";
|
|
2
2
|
|
|
3
|
-
export { HEAD, PatchError, ROOT_KEY, applyIntentsToCrdt, applyPatch, applyPatchAsActor, applyPatchInPlace, cloneClock, cloneDoc, compareDot, compileJsonPatchToIntent, crdtToFullReplace, crdtToJsonPatch, createClock, createState, deserializeDoc, deserializeState, diffJsonPatch, docFromJson, docFromJsonWithDot, dotToElemId, 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, vvHasDot, vvMerge };
|
|
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 };
|