@dabble/patches 0.7.0 → 0.7.1

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.
Files changed (56) hide show
  1. package/dist/algorithms/{client → ot/client}/applyCommittedChanges.d.ts +3 -3
  2. package/dist/algorithms/{client → ot/client}/applyCommittedChanges.js +1 -1
  3. package/dist/algorithms/{client → ot/client}/createStateFromSnapshot.d.ts +3 -3
  4. package/dist/algorithms/{client → ot/client}/createStateFromSnapshot.js +1 -1
  5. package/dist/algorithms/{server → ot/server}/commitChanges.d.ts +10 -10
  6. package/dist/algorithms/{server → ot/server}/commitChanges.js +2 -2
  7. package/dist/algorithms/{server → ot/server}/createVersion.d.ts +5 -5
  8. package/dist/algorithms/{server → ot/server}/createVersion.js +2 -2
  9. package/dist/algorithms/{server → ot/server}/getSnapshotAtRevision.d.ts +5 -5
  10. package/dist/algorithms/{server → ot/server}/getSnapshotAtRevision.js +1 -1
  11. package/dist/algorithms/{server → ot/server}/getStateAtRevision.d.ts +5 -5
  12. package/dist/algorithms/{server → ot/server}/getStateAtRevision.js +1 -1
  13. package/dist/algorithms/{server → ot/server}/handleOfflineSessionsAndBatches.d.ts +5 -5
  14. package/dist/algorithms/{server → ot/server}/handleOfflineSessionsAndBatches.js +3 -3
  15. package/dist/algorithms/{server → ot/server}/transformIncomingChanges.d.ts +3 -3
  16. package/dist/algorithms/{server → ot/server}/transformIncomingChanges.js +3 -3
  17. package/dist/algorithms/{shared → ot/shared}/applyChanges.d.ts +3 -3
  18. package/dist/algorithms/{shared → ot/shared}/applyChanges.js +2 -2
  19. package/dist/algorithms/{shared → ot/shared}/changeBatching.d.ts +3 -3
  20. package/dist/algorithms/{shared → ot/shared}/changeBatching.js +2 -2
  21. package/dist/algorithms/{shared → ot/shared}/rebaseChanges.d.ts +3 -3
  22. package/dist/algorithms/{shared → ot/shared}/rebaseChanges.js +2 -2
  23. package/dist/client/InMemoryStore.js +1 -1
  24. package/dist/client/OTAlgorithm.js +2 -2
  25. package/dist/client/OTDoc.js +2 -2
  26. package/dist/client/OTIndexedDBStore.js +1 -1
  27. package/dist/client/PatchesHistoryClient.js +1 -1
  28. package/dist/compression/index.d.ts +1 -1
  29. package/dist/compression/index.js +1 -1
  30. package/dist/{algorithms/shared → compression}/lz.js +1 -1
  31. package/dist/net/PatchesSync.d.ts +8 -8
  32. package/dist/net/PatchesSync.js +1 -1
  33. package/dist/net/index.d.ts +1 -1
  34. package/dist/net/websocket/AuthorizationProvider.d.ts +2 -2
  35. package/dist/server/CompressedStoreBackend.d.ts +3 -3
  36. package/dist/server/CompressedStoreBackend.js +4 -4
  37. package/dist/server/LWWMemoryStoreBackend.d.ts +5 -5
  38. package/dist/server/LWWMemoryStoreBackend.js +2 -11
  39. package/dist/server/LWWServer.d.ts +1 -1
  40. package/dist/server/LWWServer.js +13 -6
  41. package/dist/server/OTBranchManager.js +3 -3
  42. package/dist/server/OTServer.js +5 -5
  43. package/dist/server/PatchesHistoryManager.d.ts +6 -14
  44. package/dist/server/PatchesHistoryManager.js +2 -13
  45. package/dist/server/index.d.ts +2 -2
  46. package/dist/server/types.d.ts +9 -29
  47. package/dist/solid/context.d.ts +2 -2
  48. package/dist/solid/index.d.ts +2 -2
  49. package/dist/vue/index.d.ts +2 -2
  50. package/dist/vue/provider.d.ts +2 -2
  51. package/package.json +1 -1
  52. package/dist/algorithms/client/makeChange.d.ts +0 -9
  53. package/dist/algorithms/client/makeChange.js +0 -29
  54. package/dist/algorithms/lww/index.d.ts +0 -2
  55. package/dist/algorithms/lww/index.js +0 -1
  56. /package/dist/{algorithms/shared → compression}/lz.d.ts +0 -0
@@ -1,7 +1,7 @@
1
- import { PatchesSnapshot, Change } from '../../types.js';
2
- import '../../json-patch/JSONPatch.js';
1
+ import { PatchesSnapshot, Change } from '../../../types.js';
2
+ import '../../../json-patch/JSONPatch.js';
3
3
  import '@dabble/delta';
4
- import '../../json-patch/types.js';
4
+ import '../../../json-patch/types.js';
5
5
 
6
6
  /**
7
7
  * Applies incoming changes from the server that were *not* initiated by this client.
@@ -1,4 +1,4 @@
1
- import "../../chunk-IZ2YBCUP.js";
1
+ import "../../../chunk-IZ2YBCUP.js";
2
2
  import { applyChanges } from "../shared/applyChanges.js";
3
3
  import { rebaseChanges } from "../shared/rebaseChanges.js";
4
4
  function applyCommittedChanges(snapshot, committedChangesFromServer) {
@@ -1,7 +1,7 @@
1
- import { PatchesSnapshot } from '../../types.js';
2
- import '../../json-patch/JSONPatch.js';
1
+ import { PatchesSnapshot } from '../../../types.js';
2
+ import '../../../json-patch/JSONPatch.js';
3
3
  import '@dabble/delta';
4
- import '../../json-patch/types.js';
4
+ import '../../../json-patch/types.js';
5
5
 
6
6
  /**
7
7
  * Creates the in-memory state from a snapshot.
@@ -1,4 +1,4 @@
1
- import "../../chunk-IZ2YBCUP.js";
1
+ import "../../../chunk-IZ2YBCUP.js";
2
2
  import { applyChanges } from "../shared/applyChanges.js";
3
3
  function createStateFromSnapshot(snapshot) {
4
4
  return applyChanges(snapshot.state, snapshot.changes);
@@ -1,13 +1,13 @@
1
- import { CommitResult } from '../../server/PatchesServer.js';
2
- import { PatchesStoreBackend } from '../../server/types.js';
3
- import { ChangeInput, CommitChangesOptions } from '../../types.js';
4
- import '../../net/protocol/JSONRPCServer.js';
5
- import '../../event-signal.js';
6
- import '../../net/websocket/AuthorizationProvider.js';
7
- import '../../json-patch/types.js';
8
- import '../../json-patch/JSONPatch.js';
1
+ import { CommitResult } from '../../../server/PatchesServer.js';
2
+ import { OTStoreBackend } from '../../../server/types.js';
3
+ import { ChangeInput, CommitChangesOptions } from '../../../types.js';
4
+ import '../../../net/protocol/JSONRPCServer.js';
5
+ import '../../../event-signal.js';
6
+ import '../../../net/websocket/AuthorizationProvider.js';
7
+ import '../../../json-patch/types.js';
8
+ import '../../../json-patch/JSONPatch.js';
9
9
  import '@dabble/delta';
10
- import '../../net/protocol/types.js';
10
+ import '../../../net/protocol/types.js';
11
11
 
12
12
  /**
13
13
  * Commits a set of changes to a document, applying operational transformation as needed.
@@ -38,6 +38,6 @@ import '../../net/protocol/types.js';
38
38
  * - catchupChanges: Changes the client missed (or a synthetic root-replace for offline-first clients)
39
39
  * - newChanges: The client's changes after transformation
40
40
  */
41
- declare function commitChanges(store: PatchesStoreBackend, docId: string, changes: ChangeInput[], sessionTimeoutMillis: number, options?: CommitChangesOptions, maxStorageBytes?: number): Promise<CommitResult>;
41
+ declare function commitChanges(store: OTStoreBackend, docId: string, changes: ChangeInput[], sessionTimeoutMillis: number, options?: CommitChangesOptions, maxStorageBytes?: number): Promise<CommitResult>;
42
42
 
43
43
  export { CommitChangesOptions, CommitResult, commitChanges };
@@ -1,6 +1,6 @@
1
- import "../../chunk-IZ2YBCUP.js";
1
+ import "../../../chunk-IZ2YBCUP.js";
2
2
  import { createId } from "crypto-id";
3
- import { filterSoftWritesAgainstState } from "../../json-patch/utils/softWrites.js";
3
+ import { filterSoftWritesAgainstState } from "../../../json-patch/utils/softWrites.js";
4
4
  import { applyChanges } from "../shared/applyChanges.js";
5
5
  import { createVersion } from "./createVersion.js";
6
6
  import { getSnapshotAtRevision } from "./getSnapshotAtRevision.js";
@@ -1,7 +1,7 @@
1
- import { PatchesStoreBackend } from '../../server/types.js';
2
- import { Change, EditableVersionMetadata, VersionMetadata } from '../../types.js';
3
- import '../../json-patch/types.js';
4
- import '../../json-patch/JSONPatch.js';
1
+ import { OTStoreBackend } from '../../../server/types.js';
2
+ import { Change, EditableVersionMetadata, VersionMetadata } from '../../../types.js';
3
+ import '../../../json-patch/types.js';
4
+ import '../../../json-patch/JSONPatch.js';
5
5
  import '@dabble/delta';
6
6
 
7
7
  /**
@@ -13,6 +13,6 @@ import '@dabble/delta';
13
13
  * @param metadata Optional additional metadata for the version.
14
14
  * @returns The created version metadata, or undefined if no changes provided.
15
15
  */
16
- declare function createVersion(store: PatchesStoreBackend, docId: string, state: any, changes: Change[], metadata?: EditableVersionMetadata): Promise<VersionMetadata | undefined>;
16
+ declare function createVersion(store: OTStoreBackend, docId: string, state: any, changes: Change[], metadata?: EditableVersionMetadata): Promise<VersionMetadata | undefined>;
17
17
 
18
18
  export { createVersion };
@@ -1,5 +1,5 @@
1
- import "../../chunk-IZ2YBCUP.js";
2
- import { createVersionMetadata } from "../../data/version.js";
1
+ import "../../../chunk-IZ2YBCUP.js";
2
+ import { createVersionMetadata } from "../../../data/version.js";
3
3
  async function createVersion(store, docId, state, changes, metadata) {
4
4
  if (changes.length === 0) return;
5
5
  const startRev = changes[0].rev;
@@ -1,7 +1,7 @@
1
- import { PatchesStoreBackend } from '../../server/types.js';
2
- import { PatchesSnapshot } from '../../types.js';
3
- import '../../json-patch/types.js';
4
- import '../../json-patch/JSONPatch.js';
1
+ import { OTStoreBackend } from '../../../server/types.js';
2
+ import { PatchesSnapshot } from '../../../types.js';
3
+ import '../../../json-patch/types.js';
4
+ import '../../../json-patch/JSONPatch.js';
5
5
  import '@dabble/delta';
6
6
 
7
7
  /**
@@ -11,6 +11,6 @@ import '@dabble/delta';
11
11
  * @param rev The revision number. If not provided, the latest state, its revision, and all changes since are returned.
12
12
  * @returns The document state at the last version before the revision, its revision number, and all changes up to the specified revision (or all changes if no revision is provided).
13
13
  */
14
- declare function getSnapshotAtRevision(store: PatchesStoreBackend, docId: string, rev?: number): Promise<PatchesSnapshot>;
14
+ declare function getSnapshotAtRevision(store: OTStoreBackend, docId: string, rev?: number): Promise<PatchesSnapshot>;
15
15
 
16
16
  export { getSnapshotAtRevision };
@@ -1,4 +1,4 @@
1
- import "../../chunk-IZ2YBCUP.js";
1
+ import "../../../chunk-IZ2YBCUP.js";
2
2
  async function getSnapshotAtRevision(store, docId, rev) {
3
3
  const versions = await store.listVersions(docId, {
4
4
  limit: 1,
@@ -1,7 +1,7 @@
1
- import { PatchesStoreBackend } from '../../server/types.js';
2
- import { PatchesState } from '../../types.js';
3
- import '../../json-patch/types.js';
4
- import '../../json-patch/JSONPatch.js';
1
+ import { OTStoreBackend } from '../../../server/types.js';
2
+ import { PatchesState } from '../../../types.js';
3
+ import '../../../json-patch/types.js';
4
+ import '../../../json-patch/JSONPatch.js';
5
5
  import '@dabble/delta';
6
6
 
7
7
  /**
@@ -10,6 +10,6 @@ import '@dabble/delta';
10
10
  * @param rev The revision number. If not provided, the latest state and its revision is returned.
11
11
  * @returns The state at the specified revision *and* its revision number.
12
12
  */
13
- declare function getStateAtRevision(store: PatchesStoreBackend, docId: string, rev?: number): Promise<PatchesState>;
13
+ declare function getStateAtRevision(store: OTStoreBackend, docId: string, rev?: number): Promise<PatchesState>;
14
14
 
15
15
  export { getStateAtRevision };
@@ -1,4 +1,4 @@
1
- import "../../chunk-IZ2YBCUP.js";
1
+ import "../../../chunk-IZ2YBCUP.js";
2
2
  import { applyChanges } from "../shared/applyChanges.js";
3
3
  import { getSnapshotAtRevision } from "./getSnapshotAtRevision.js";
4
4
  async function getStateAtRevision(store, docId, rev) {
@@ -1,7 +1,7 @@
1
- import { PatchesStoreBackend } from '../../server/types.js';
2
- import { Change } from '../../types.js';
3
- import '../../json-patch/types.js';
4
- import '../../json-patch/JSONPatch.js';
1
+ import { OTStoreBackend } from '../../../server/types.js';
2
+ import { Change } from '../../../types.js';
3
+ import '../../../json-patch/types.js';
4
+ import '../../../json-patch/JSONPatch.js';
5
5
  import '@dabble/delta';
6
6
 
7
7
  /**
@@ -16,6 +16,6 @@ import '@dabble/delta';
16
16
  * @param maxStorageBytes If set, break collapsed changes that exceed this size
17
17
  * @returns The changes (collapsed into one if divergent, unchanged if fast-forward)
18
18
  */
19
- declare function handleOfflineSessionsAndBatches(store: PatchesStoreBackend, sessionTimeoutMillis: number, docId: string, changes: Change[], baseRev: number, batchId?: string, origin?: 'main' | 'offline-branch', isOffline?: boolean, maxStorageBytes?: number): Promise<Change[]>;
19
+ declare function handleOfflineSessionsAndBatches(store: OTStoreBackend, sessionTimeoutMillis: number, docId: string, changes: Change[], baseRev: number, batchId?: string, origin?: 'main' | 'offline-branch', isOffline?: boolean, maxStorageBytes?: number): Promise<Change[]>;
20
20
 
21
21
  export { handleOfflineSessionsAndBatches };
@@ -1,5 +1,5 @@
1
- import "../../chunk-IZ2YBCUP.js";
2
- import { createVersionMetadata } from "../../data/version.js";
1
+ import "../../../chunk-IZ2YBCUP.js";
2
+ import { createVersionMetadata } from "../../../data/version.js";
3
3
  import { applyChanges } from "../shared/applyChanges.js";
4
4
  import { breakChanges } from "../shared/changeBatching.js";
5
5
  import { getStateAtRevision } from "./getStateAtRevision.js";
@@ -26,7 +26,7 @@ async function handleOfflineSessionsAndBatches(store, sessionTimeoutMillis, docI
26
26
  const sessionChanges = changes.slice(sessionStartIndex, i);
27
27
  if (sessionChanges.length > 0) {
28
28
  const isContinuation = !!lastVersion && sessionChanges[0].createdAt - lastVersion.endedAt <= sessionTimeoutMillis;
29
- if (isContinuation) {
29
+ if (isContinuation && store.appendVersionChanges) {
30
30
  const mergedState = applyChanges(offlineBaseState, sessionChanges);
31
31
  const newEndedAt = sessionChanges[sessionChanges.length - 1].createdAt;
32
32
  const newRev = sessionChanges[sessionChanges.length - 1].rev;
@@ -1,7 +1,7 @@
1
- import { Change } from '../../types.js';
2
- import '../../json-patch/JSONPatch.js';
1
+ import { Change } from '../../../types.js';
2
+ import '../../../json-patch/JSONPatch.js';
3
3
  import '@dabble/delta';
4
- import '../../json-patch/types.js';
4
+ import '../../../json-patch/types.js';
5
5
 
6
6
  /**
7
7
  * Transforms incoming changes against committed changes that happened *after* the client's baseRev.
@@ -1,6 +1,6 @@
1
- import "../../chunk-IZ2YBCUP.js";
2
- import { applyPatch } from "../../json-patch/applyPatch.js";
3
- import { transformPatch } from "../../json-patch/transformPatch.js";
1
+ import "../../../chunk-IZ2YBCUP.js";
2
+ import { applyPatch } from "../../../json-patch/applyPatch.js";
3
+ import { transformPatch } from "../../../json-patch/transformPatch.js";
4
4
  function transformIncomingChanges(changes, stateAtBaseRev, committedChanges, currentRev, forceCommit = false) {
5
5
  const committedOps = committedChanges.flatMap((c) => c.ops);
6
6
  let state = stateAtBaseRev;
@@ -1,7 +1,7 @@
1
- import { Change } from '../../types.js';
2
- import '../../json-patch/JSONPatch.js';
1
+ import { Change } from '../../../types.js';
2
+ import '../../../json-patch/JSONPatch.js';
3
3
  import '@dabble/delta';
4
- import '../../json-patch/types.js';
4
+ import '../../../json-patch/types.js';
5
5
 
6
6
  /**
7
7
  * Applies a sequence of changes to a state object.
@@ -1,5 +1,5 @@
1
- import "../../chunk-IZ2YBCUP.js";
2
- import { applyPatch } from "../../json-patch/applyPatch.js";
1
+ import "../../../chunk-IZ2YBCUP.js";
2
+ import { applyPatch } from "../../../json-patch/applyPatch.js";
3
3
  function applyChanges(state, changes) {
4
4
  if (!changes.length) return state;
5
5
  for (const change of changes) {
@@ -1,7 +1,7 @@
1
- import { Change } from '../../types.js';
2
- import '../../json-patch/JSONPatch.js';
1
+ import { Change } from '../../../types.js';
2
+ import '../../../json-patch/JSONPatch.js';
3
3
  import '@dabble/delta';
4
- import '../../json-patch/types.js';
4
+ import '../../../json-patch/types.js';
5
5
 
6
6
  /**
7
7
  * Function that calculates the storage size of data.
@@ -1,6 +1,6 @@
1
- import "../../chunk-IZ2YBCUP.js";
1
+ import "../../../chunk-IZ2YBCUP.js";
2
2
  import { createId } from "crypto-id";
3
- import { createChange } from "../../data/change.js";
3
+ import { createChange } from "../../../data/change.js";
4
4
  function getJSONByteSize(data) {
5
5
  try {
6
6
  const stringified = JSON.stringify(data);
@@ -1,7 +1,7 @@
1
- import { Change } from '../../types.js';
2
- import '../../json-patch/JSONPatch.js';
1
+ import { Change } from '../../../types.js';
2
+ import '../../../json-patch/JSONPatch.js';
3
3
  import '@dabble/delta';
4
- import '../../json-patch/types.js';
4
+ import '../../../json-patch/types.js';
5
5
 
6
6
  /**
7
7
  * Rebases local changes against server changes using operational transformation.
@@ -1,5 +1,5 @@
1
- import "../../chunk-IZ2YBCUP.js";
2
- import { JSONPatch } from "../../json-patch/JSONPatch.js";
1
+ import "../../../chunk-IZ2YBCUP.js";
2
+ import { JSONPatch } from "../../../json-patch/JSONPatch.js";
3
3
  function rebaseChanges(serverChanges, localChanges) {
4
4
  if (!serverChanges.length || !localChanges.length) {
5
5
  return localChanges;
@@ -1,5 +1,5 @@
1
1
  import "../chunk-IZ2YBCUP.js";
2
- import { applyChanges } from "../algorithms/shared/applyChanges.js";
2
+ import { applyChanges } from "../algorithms/ot/shared/applyChanges.js";
3
3
  class InMemoryStore {
4
4
  docs = /* @__PURE__ */ new Map();
5
5
  // ─── Reconstruction ────────────────────────────────────────────────────
@@ -1,6 +1,6 @@
1
1
  import "../chunk-IZ2YBCUP.js";
2
- import { applyCommittedChanges } from "../algorithms/client/applyCommittedChanges.js";
3
- import { breakChanges } from "../algorithms/shared/changeBatching.js";
2
+ import { applyCommittedChanges } from "../algorithms/ot/client/applyCommittedChanges.js";
3
+ import { breakChanges } from "../algorithms/ot/shared/changeBatching.js";
4
4
  import { createChange } from "../data/change.js";
5
5
  import { OTDoc } from "./OTDoc.js";
6
6
  class OTAlgorithm {
@@ -1,6 +1,6 @@
1
1
  import "../chunk-IZ2YBCUP.js";
2
- import { createStateFromSnapshot } from "../algorithms/client/createStateFromSnapshot.js";
3
- import { applyChanges as applyChangesToState } from "../algorithms/shared/applyChanges.js";
2
+ import { createStateFromSnapshot } from "../algorithms/ot/client/createStateFromSnapshot.js";
3
+ import { applyChanges as applyChangesToState } from "../algorithms/ot/shared/applyChanges.js";
4
4
  import { BaseDoc } from "./BaseDoc.js";
5
5
  class OTDoc extends BaseDoc {
6
6
  /** Base state from the server at the committed revision. */
@@ -5,7 +5,7 @@ import {
5
5
  __runInitializers
6
6
  } from "../chunk-IZ2YBCUP.js";
7
7
  var _applyServerChanges_dec, _getPendingChanges_dec, _savePendingChanges_dec, _saveDoc_dec, _deleteDoc_dec, _getDoc_dec, _a, _init;
8
- import { applyChanges } from "../algorithms/shared/applyChanges.js";
8
+ import { applyChanges } from "../algorithms/ot/shared/applyChanges.js";
9
9
  import { blockable } from "../utils/concurrency.js";
10
10
  import { IndexedDBStore } from "./IndexedDBStore.js";
11
11
  const DB_VERSION = 1;
@@ -1,5 +1,5 @@
1
1
  import "../chunk-IZ2YBCUP.js";
2
- import { applyChanges } from "../algorithms/shared/applyChanges.js";
2
+ import { applyChanges } from "../algorithms/ot/shared/applyChanges.js";
3
3
  import { signal } from "../event-signal.js";
4
4
  class LRUCache {
5
5
  constructor(maxSize) {
@@ -1,4 +1,4 @@
1
- export { compressToBase64, compressToUint8Array, decompressFromBase64, decompressFromUint8Array } from '../algorithms/shared/lz.js';
1
+ export { compressToBase64, compressToUint8Array, decompressFromBase64, decompressFromUint8Array } from './lz.js';
2
2
  import { JSONPatchOp } from '../json-patch/types.js';
3
3
 
4
4
  /**
@@ -4,7 +4,7 @@ import {
4
4
  compressToUint8Array,
5
5
  decompressFromBase64,
6
6
  decompressFromUint8Array
7
- } from "../algorithms/shared/lz.js";
7
+ } from "./lz.js";
8
8
  const compressedSizeBase64 = (data) => {
9
9
  if (data === void 0) return 0;
10
10
  try {
@@ -1,4 +1,4 @@
1
- import "../../chunk-IZ2YBCUP.js";
1
+ import "../chunk-IZ2YBCUP.js";
2
2
  const f = String.fromCharCode;
3
3
  const keyStrBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
4
4
  const keyStrUriSafe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$";
@@ -1,19 +1,19 @@
1
- import { JSONRPCClient } from './protocol/JSONRPCClient.js';
2
1
  import { Signal } from '../event-signal.js';
3
- import { SizeCalculator } from '../algorithms/shared/changeBatching.js';
4
- import { Patches } from '../client/Patches.js';
5
- import { AlgorithmName, ClientAlgorithm } from '../client/ClientAlgorithm.js';
6
- import { SyncingState, Change } from '../types.js';
7
2
  import { ConnectionState } from './protocol/types.js';
3
+ import { SyncingState, Change } from '../types.js';
4
+ import { JSONRPCClient } from './protocol/JSONRPCClient.js';
8
5
  import { PatchesWebSocket } from './websocket/PatchesWebSocket.js';
9
6
  import { WebSocketOptions } from './websocket/WebSocketTransport.js';
10
- import '../json-patch/types.js';
11
- import '../BaseDoc-DkP3tUhT.js';
7
+ import { SizeCalculator } from '../algorithms/ot/shared/changeBatching.js';
8
+ import { Patches } from '../client/Patches.js';
9
+ import { AlgorithmName, ClientAlgorithm } from '../client/ClientAlgorithm.js';
12
10
  import '../json-patch/JSONPatch.js';
13
11
  import '@dabble/delta';
14
- import '../client/PatchesStore.js';
12
+ import '../json-patch/types.js';
15
13
  import './PatchesClient.js';
16
14
  import '../utils/deferred.js';
15
+ import '../BaseDoc-DkP3tUhT.js';
16
+ import '../client/PatchesStore.js';
17
17
 
18
18
  interface PatchesSyncState {
19
19
  online: boolean;
@@ -7,7 +7,7 @@ import {
7
7
  } from "../chunk-IZ2YBCUP.js";
8
8
  var __receiveCommittedChanges_dec, _syncDoc_dec, _init;
9
9
  import { isEqual } from "@dabble/delta";
10
- import { breakChangesIntoBatches } from "../algorithms/shared/changeBatching.js";
10
+ import { breakChangesIntoBatches } from "../algorithms/ot/shared/changeBatching.js";
11
11
  import { BaseDoc } from "../client/BaseDoc.js";
12
12
  import { Patches } from "../client/Patches.js";
13
13
  import { signal } from "../event-signal.js";
@@ -15,7 +15,7 @@ export { WebSocketServer, WebSocketServerOptions } from './websocket/WebSocketSe
15
15
  export { WebSocketOptions, WebSocketTransport } from './websocket/WebSocketTransport.js';
16
16
  export { CommitChangesOptions } from '../types.js';
17
17
  import '../event-signal.js';
18
- import '../algorithms/shared/changeBatching.js';
18
+ import '../algorithms/ot/shared/changeBatching.js';
19
19
  import '../client/Patches.js';
20
20
  import '../json-patch/types.js';
21
21
  import '../client/ClientAlgorithm.js';
@@ -1,4 +1,4 @@
1
- import { PatchesStoreBackend, TombstoneStoreBackend } from '../../server/types.js';
1
+ import { ServerStoreBackend, TombstoneStoreBackend } from '../../server/types.js';
2
2
  import '../../json-patch/types.js';
3
3
  import '../../types.js';
4
4
  import '../../json-patch/JSONPatch.js';
@@ -75,6 +75,6 @@ declare const denyAll: AuthorizationProvider;
75
75
  * }
76
76
  * };
77
77
  */
78
- declare function assertNotDeleted(store: PatchesStoreBackend & Partial<TombstoneStoreBackend>, docId: string): Promise<void>;
78
+ declare function assertNotDeleted(store: ServerStoreBackend & Partial<TombstoneStoreBackend>, docId: string): Promise<void>;
79
79
 
80
80
  export { type Access, type AuthContext, type AuthorizationProvider, allowAll, assertNotDeleted, denyAll };
@@ -1,7 +1,7 @@
1
1
  import { OpsCompressor } from '../compression/index.js';
2
2
  import { Change, ListChangesOptions, VersionMetadata, EditableVersionMetadata, ListVersionsOptions, DocumentTombstone } from '../types.js';
3
3
  import { OTStoreBackend, TombstoneStoreBackend } from './types.js';
4
- import '../algorithms/shared/lz.js';
4
+ import '../compression/lz.js';
5
5
  import '../json-patch/types.js';
6
6
  import '../json-patch/JSONPatch.js';
7
7
  import '@dabble/delta';
@@ -11,7 +11,7 @@ import '@dabble/delta';
11
11
  */
12
12
  type CompressibleStore = OTStoreBackend & Partial<TombstoneStoreBackend>;
13
13
  /**
14
- * Wraps a PatchesStoreBackend to transparently compress/decompress the ops field of Changes.
14
+ * Wraps an OTStoreBackend to transparently compress/decompress the ops field of Changes.
15
15
  * Compression happens before save and decompression happens after load.
16
16
  *
17
17
  * This allows backends with row-size limits to store larger changes by compressing the payload.
@@ -34,7 +34,7 @@ declare class CompressedStoreBackend implements OTStoreBackend, Partial<Tombston
34
34
  private decompressChange;
35
35
  saveChanges(docId: string, changes: Change[]): Promise<void>;
36
36
  listChanges(docId: string, options: ListChangesOptions): Promise<Change[]>;
37
- createVersion(docId: string, metadata: VersionMetadata, state: any, changes: Change[]): Promise<void>;
37
+ createVersion(docId: string, metadata: VersionMetadata, state: any, changes?: Change[]): Promise<void>;
38
38
  appendVersionChanges(docId: string, versionId: string, changes: Change[], newEndedAt: number, newRev: number, newState: any): Promise<void>;
39
39
  loadVersionChanges(docId: string, versionId: string): Promise<Change[]>;
40
40
  updateVersion(docId: string, versionId: string, metadata: EditableVersionMetadata): Promise<void>;
@@ -36,12 +36,12 @@ class CompressedStoreBackend {
36
36
  }
37
37
  // === Version Operations (compress changes and state ops) ===
38
38
  async createVersion(docId, metadata, state, changes) {
39
- const compressedChanges = changes.map((c) => this.compressChange(c));
39
+ const compressedChanges = changes?.map((c) => this.compressChange(c));
40
40
  return this.store.createVersion(docId, metadata, state, compressedChanges);
41
41
  }
42
42
  async appendVersionChanges(docId, versionId, changes, newEndedAt, newRev, newState) {
43
43
  const compressedChanges = changes.map((c) => this.compressChange(c));
44
- return this.store.appendVersionChanges(
44
+ return this.store.appendVersionChanges?.(
45
45
  docId,
46
46
  versionId,
47
47
  compressedChanges,
@@ -51,8 +51,8 @@ class CompressedStoreBackend {
51
51
  );
52
52
  }
53
53
  async loadVersionChanges(docId, versionId) {
54
- const stored = await this.store.loadVersionChanges(docId, versionId);
55
- return stored.map((s) => this.decompressChange(s));
54
+ const stored = await this.store.loadVersionChanges?.(docId, versionId);
55
+ return stored?.map((s) => this.decompressChange(s)) ?? [];
56
56
  }
57
57
  // === Pass-through Operations (no compression needed) ===
58
58
  async updateVersion(docId, versionId, metadata) {
@@ -1,6 +1,6 @@
1
1
  import { JSONPatchOp } from '../json-patch/types.js';
2
- import { DocumentTombstone, EditableVersionMetadata, ListVersionsOptions, VersionMetadata, Branch } from '../types.js';
3
- import { LWWStoreBackend, LWWVersioningStoreBackend, TombstoneStoreBackend, BranchingStoreBackend, ListFieldsOptions } from './types.js';
2
+ import { DocumentTombstone, VersionMetadata, Change, ListVersionsOptions, EditableVersionMetadata, Branch } from '../types.js';
3
+ import { LWWStoreBackend, VersioningStoreBackend, TombstoneStoreBackend, BranchingStoreBackend, ListFieldsOptions } from './types.js';
4
4
  import '../json-patch/JSONPatch.js';
5
5
  import '@dabble/delta';
6
6
 
@@ -18,7 +18,7 @@ interface VersionData {
18
18
  }
19
19
  /**
20
20
  * In-memory implementation of LWWStoreBackend for testing.
21
- * Also implements TombstoneStoreBackend, LWWVersioningStoreBackend, and BranchingStoreBackend
21
+ * Also implements TombstoneStoreBackend, VersioningStoreBackend, and BranchingStoreBackend
22
22
  * for comprehensive testing of all LWW functionality.
23
23
  *
24
24
  * @example
@@ -30,7 +30,7 @@ interface VersionData {
30
30
  * const server = new LWWServer(store);
31
31
  * ```
32
32
  */
33
- declare class LWWMemoryStoreBackend implements LWWStoreBackend, LWWVersioningStoreBackend, TombstoneStoreBackend, BranchingStoreBackend {
33
+ declare class LWWMemoryStoreBackend implements LWWStoreBackend, VersioningStoreBackend, TombstoneStoreBackend, BranchingStoreBackend {
34
34
  private docs;
35
35
  private tombstones;
36
36
  private versions;
@@ -48,7 +48,7 @@ declare class LWWMemoryStoreBackend implements LWWStoreBackend, LWWVersioningSto
48
48
  createTombstone(tombstone: DocumentTombstone): Promise<void>;
49
49
  getTombstone(docId: string): Promise<DocumentTombstone | undefined>;
50
50
  removeTombstone(docId: string): Promise<void>;
51
- createVersion(docId: string, versionId: string, state: any, rev: number, metadata?: EditableVersionMetadata): Promise<void>;
51
+ createVersion(docId: string, metadata: VersionMetadata, state: any, _changes?: Change[]): Promise<void>;
52
52
  listVersions(docId: string, options?: ListVersionsOptions): Promise<VersionMetadata[]>;
53
53
  loadVersionState(docId: string, versionId: string): Promise<any | undefined>;
54
54
  updateVersion(docId: string, versionId: string, metadata: EditableVersionMetadata): Promise<void>;
@@ -74,18 +74,9 @@ class LWWMemoryStoreBackend {
74
74
  this.tombstones.delete(docId);
75
75
  }
76
76
  // === Versioning ===
77
- async createVersion(docId, versionId, state, rev, metadata) {
77
+ async createVersion(docId, metadata, state, _changes) {
78
78
  const versions = this.versions.get(docId) || [];
79
- const versionMetadata = {
80
- id: versionId,
81
- origin: "main",
82
- startedAt: Date.now(),
83
- endedAt: Date.now(),
84
- startRev: rev,
85
- endRev: rev,
86
- ...metadata
87
- };
88
- versions.push({ metadata: versionMetadata, state });
79
+ versions.push({ metadata, state });
89
80
  this.versions.set(docId, versions);
90
81
  }
91
82
  async listVersions(docId, options) {
@@ -114,7 +114,7 @@ declare class LWWServer implements PatchesServer {
114
114
  change<T = Record<string, any>>(docId: string, mutator: ChangeMutator<T>, metadata?: Record<string, any>): Promise<Change | null>;
115
115
  /**
116
116
  * Captures the current state of a document as a new version.
117
- * Only works if store implements LWWVersioningStoreBackend.
117
+ * Only works if store implements VersioningStoreBackend.
118
118
  *
119
119
  * @param docId - The document ID.
120
120
  * @param metadata - Optional metadata for the version.
@@ -1,5 +1,5 @@
1
1
  import "../chunk-IZ2YBCUP.js";
2
- import { createId } from "crypto-id";
2
+ import { createVersionMetadata } from "../data/version.js";
3
3
  import { consolidateOps, convertDeltaOps } from "../algorithms/lww/consolidateOps.js";
4
4
  import { createChange } from "../data/change.js";
5
5
  import { signal } from "../event-signal.js";
@@ -168,7 +168,7 @@ class LWWServer {
168
168
  }
169
169
  /**
170
170
  * Captures the current state of a document as a new version.
171
- * Only works if store implements LWWVersioningStoreBackend.
171
+ * Only works if store implements VersioningStoreBackend.
172
172
  *
173
173
  * @param docId - The document ID.
174
174
  * @param metadata - Optional metadata for the version.
@@ -177,15 +177,22 @@ class LWWServer {
177
177
  async captureCurrentVersion(docId, metadata) {
178
178
  assertVersionMetadata(metadata);
179
179
  if (!this.isVersioningStore(this.store)) {
180
- throw new Error("LWW versioning requires a store that implements LWWVersioningStoreBackend");
180
+ throw new Error("LWW versioning requires a store that implements VersioningStoreBackend");
181
181
  }
182
182
  const { state, rev } = await this.getDoc(docId);
183
183
  if (rev === 0) {
184
184
  return null;
185
185
  }
186
- const versionId = createId(8);
187
- await this.store.createVersion(docId, versionId, state, rev, metadata);
188
- return versionId;
186
+ const versionMetadata = createVersionMetadata({
187
+ origin: "main",
188
+ startedAt: Date.now(),
189
+ endedAt: Date.now(),
190
+ startRev: rev,
191
+ endRev: rev,
192
+ ...metadata
193
+ });
194
+ await this.store.createVersion(docId, versionMetadata, state);
195
+ return versionMetadata.id;
189
196
  }
190
197
  /**
191
198
  * Type guard to check if the store supports versioning.
@@ -1,6 +1,6 @@
1
1
  import "../chunk-IZ2YBCUP.js";
2
- import { getStateAtRevision } from "../algorithms/server/getStateAtRevision.js";
3
- import { breakChanges } from "../algorithms/shared/changeBatching.js";
2
+ import { getStateAtRevision } from "../algorithms/ot/server/getStateAtRevision.js";
3
+ import { breakChanges } from "../algorithms/ot/shared/changeBatching.js";
4
4
  import { createChange } from "../data/change.js";
5
5
  import { createVersionMetadata } from "../data/version.js";
6
6
  import {
@@ -108,7 +108,7 @@ class OTBranchManager {
108
108
  parentId: lastVersionId
109
109
  });
110
110
  const state = await this.store.loadVersionState(branchId, v.id);
111
- const changes = await this.store.loadVersionChanges(branchId, v.id);
111
+ const changes = await this.store.loadVersionChanges?.(branchId, v.id);
112
112
  await this.store.createVersion(sourceDocId, newVersionMetadata, state, changes);
113
113
  lastVersionId = newVersionMetadata.id;
114
114
  }
@@ -1,9 +1,9 @@
1
1
  import "../chunk-IZ2YBCUP.js";
2
- import { commitChanges } from "../algorithms/server/commitChanges.js";
3
- import { createVersion } from "../algorithms/server/createVersion.js";
4
- import { getSnapshotAtRevision } from "../algorithms/server/getSnapshotAtRevision.js";
5
- import { getStateAtRevision } from "../algorithms/server/getStateAtRevision.js";
6
- import { applyChanges } from "../algorithms/shared/applyChanges.js";
2
+ import { commitChanges } from "../algorithms/ot/server/commitChanges.js";
3
+ import { createVersion } from "../algorithms/ot/server/createVersion.js";
4
+ import { getSnapshotAtRevision } from "../algorithms/ot/server/getSnapshotAtRevision.js";
5
+ import { getStateAtRevision } from "../algorithms/ot/server/getStateAtRevision.js";
6
+ import { applyChanges } from "../algorithms/ot/shared/applyChanges.js";
7
7
  import { createChange } from "../data/change.js";
8
8
  import { signal } from "../event-signal.js";
9
9
  import { createJSONPatch } from "../json-patch/createJSONPatch.js";
@@ -1,7 +1,7 @@
1
1
  import { ApiDefinition } from '../net/protocol/JSONRPCServer.js';
2
- import { ListVersionsOptions, VersionMetadata, EditableVersionMetadata, Change, ListChangesOptions } from '../types.js';
2
+ import { ListVersionsOptions, VersionMetadata, EditableVersionMetadata, Change } from '../types.js';
3
3
  import { PatchesServer } from './PatchesServer.js';
4
- import { PatchesStoreBackend } from './types.js';
4
+ import { VersioningStoreBackend } from './types.js';
5
5
  import '../event-signal.js';
6
6
  import '../net/websocket/AuthorizationProvider.js';
7
7
  import '../json-patch/types.js';
@@ -14,13 +14,13 @@ import '../net/protocol/types.js';
14
14
  * using the versioning model based on IDs and metadata.
15
15
  *
16
16
  * Works with any PatchesServer that implements captureCurrentVersion
17
- * (both OTServer and LWWServer with LWWVersioningStoreBackend).
17
+ * (both OTServer and LWWServer with VersioningStoreBackend).
18
18
  */
19
19
  declare class PatchesHistoryManager {
20
- private readonly patches;
20
+ protected readonly patches: PatchesServer;
21
21
  static api: ApiDefinition;
22
- private readonly store;
23
- constructor(patches: PatchesServer, store: PatchesStoreBackend);
22
+ protected readonly store: VersioningStoreBackend;
23
+ constructor(patches: PatchesServer, store: VersioningStoreBackend);
24
24
  /**
25
25
  * Lists version metadata for the document, supporting various filters.
26
26
  * @param docId - The ID of the document.
@@ -59,14 +59,6 @@ declare class PatchesHistoryManager {
59
59
  * @throws Error if the version ID is not found or change loading fails.
60
60
  */
61
61
  getChangesForVersion(docId: string, versionId: string): Promise<Change[]>;
62
- /**
63
- * Lists committed server changes for the document, typically used for server-side processing
64
- * or deep history analysis based on raw revisions.
65
- * @param docId - The ID of the document.
66
- * @param options - Options like start/end revision, limit.
67
- * @returns The list of committed Change objects.
68
- */
69
- listServerChanges(docId: string, options?: ListChangesOptions): Promise<Change[]>;
70
62
  /**
71
63
  * Alias for getStateAtVersion for RPC API compatibility.
72
64
  */
@@ -10,8 +10,7 @@ class PatchesHistoryManager {
10
10
  createVersion: "write",
11
11
  updateVersion: "write",
12
12
  getVersionState: "read",
13
- getVersionChanges: "read",
14
- listServerChanges: "read"
13
+ getVersionChanges: "read"
15
14
  };
16
15
  store;
17
16
  /**
@@ -71,22 +70,12 @@ class PatchesHistoryManager {
71
70
  */
72
71
  async getChangesForVersion(docId, versionId) {
73
72
  try {
74
- return await this.store.loadVersionChanges(docId, versionId);
73
+ return await this.store.loadVersionChanges?.(docId, versionId) ?? [];
75
74
  } catch (error) {
76
75
  console.error(`Failed to load changes for version ${versionId} of doc ${docId}.`, error);
77
76
  throw new Error(`Could not load changes for version ${versionId}.`);
78
77
  }
79
78
  }
80
- /**
81
- * Lists committed server changes for the document, typically used for server-side processing
82
- * or deep history analysis based on raw revisions.
83
- * @param docId - The ID of the document.
84
- * @param options - Options like start/end revision, limit.
85
- * @returns The list of committed Change objects.
86
- */
87
- async listServerChanges(docId, options = {}) {
88
- return await this.store.listChanges(docId, options);
89
- }
90
79
  // ---------------------------------------------------------------------------
91
80
  // Alias methods for RPC API compatibility
92
81
  // ---------------------------------------------------------------------------
@@ -11,13 +11,13 @@ export { createTombstoneIfSupported, isTombstoneStore, removeTombstoneIfExists }
11
11
  export { assertVersionMetadata } from './utils.js';
12
12
  export { CommitChangesOptions, DeleteDocOptions } from '../types.js';
13
13
  export { PatchesServer } from './PatchesServer.js';
14
- export { BranchingStoreBackend, LWWStoreBackend, LWWVersioningStoreBackend, ListFieldsOptions, OTStoreBackend, PatchesStoreBackend, ServerStoreBackend, TombstoneStoreBackend, VersioningStoreBackend } from './types.js';
14
+ export { BranchingStoreBackend, LWWStoreBackend, ListFieldsOptions, OTStoreBackend, ServerStoreBackend, TombstoneStoreBackend, VersioningStoreBackend } from './types.js';
15
15
  import '../event-signal.js';
16
16
  import '../net/protocol/JSONRPCServer.js';
17
17
  import '../net/websocket/AuthorizationProvider.js';
18
18
  import '../net/protocol/types.js';
19
19
  import '../json-patch/types.js';
20
20
  import '../compression/index.js';
21
- import '../algorithms/shared/lz.js';
21
+ import '../compression/lz.js';
22
22
  import '../json-patch/JSONPatch.js';
23
23
  import '@dabble/delta';
@@ -1,5 +1,5 @@
1
1
  import { JSONPatchOp } from '../json-patch/types.js';
2
- import { VersionMetadata, Change, ListVersionsOptions, EditableVersionMetadata, ListChangesOptions, DocumentTombstone, Branch } from '../types.js';
2
+ import { DocumentTombstone, VersionMetadata, Change, ListVersionsOptions, EditableVersionMetadata, ListChangesOptions, Branch } from '../types.js';
3
3
  import '../json-patch/JSONPatch.js';
4
4
  import '@dabble/delta';
5
5
 
@@ -28,6 +28,13 @@ interface VersioningStoreBackend {
28
28
  loadVersionState(docId: string, versionId: string): Promise<any | undefined>;
29
29
  /** Update a version's metadata. */
30
30
  updateVersion(docId: string, versionId: string, metadata: EditableVersionMetadata): Promise<void>;
31
+ /** Loads the original Change objects associated with a specific version ID. */
32
+ loadVersionChanges?(docId: string, versionId: string): Promise<Change[]>;
33
+ /**
34
+ * Appends changes to an existing version, updating its state snapshot, endedAt, and endRev.
35
+ * Used when a session spans multiple batch submissions.
36
+ */
37
+ appendVersionChanges?(docId: string, versionId: string, changes: Change[], newEndedAt: number, newEndRev: number, newState: any): Promise<void>;
31
38
  }
32
39
  /**
33
40
  * Interface for OT (Operational Transformation) storage backend.
@@ -39,13 +46,6 @@ interface OTStoreBackend extends ServerStoreBackend, VersioningStoreBackend {
39
46
  saveChanges(docId: string, changes: Change[]): Promise<void>;
40
47
  /** Lists committed server changes based on revision numbers. */
41
48
  listChanges(docId: string, options: ListChangesOptions): Promise<Change[]>;
42
- /** Loads the original Change objects associated with a specific version ID. */
43
- loadVersionChanges(docId: string, versionId: string): Promise<Change[]>;
44
- /**
45
- * Appends changes to an existing version, updating its state snapshot, endedAt, and endRev.
46
- * Used when a session spans multiple batch submissions.
47
- */
48
- appendVersionChanges(docId: string, versionId: string, changes: Change[], newEndedAt: number, newEndRev: number, newState: any): Promise<void>;
49
49
  }
50
50
  /**
51
51
  * Options for listing fields. Use either sinceRev OR paths, not both.
@@ -112,21 +112,6 @@ interface LWWStoreBackend extends ServerStoreBackend {
112
112
  */
113
113
  saveOps(docId: string, ops: JSONPatchOp[], pathsToDelete?: string[]): Promise<number>;
114
114
  }
115
- /**
116
- * Extended storage interface for LWWServer with versioning support.
117
- * Versioning is optional - not all LWW docs need it.
118
- */
119
- interface LWWVersioningStoreBackend extends LWWStoreBackend {
120
- /**
121
- * Creates a new version snapshot.
122
- * @param docId - The document ID.
123
- * @param versionId - The version ID.
124
- * @param state - The document state snapshot.
125
- * @param rev - The revision number.
126
- * @param metadata - Optional version metadata.
127
- */
128
- createVersion(docId: string, versionId: string, state: any, rev: number, metadata?: EditableVersionMetadata): Promise<void>;
129
- }
130
115
  /**
131
116
  * Interface for tombstone storage, providing soft-delete capabilities.
132
117
  * Optional add-on for servers that need to track deleted documents.
@@ -164,10 +149,5 @@ interface BranchingStoreBackend {
164
149
  */
165
150
  closeBranch(branchId: string): Promise<void>;
166
151
  }
167
- /**
168
- * @deprecated Use OTStoreBackend instead.
169
- * Alias for backwards compatibility.
170
- */
171
- type PatchesStoreBackend = OTStoreBackend;
172
152
 
173
- export type { BranchingStoreBackend, LWWStoreBackend, LWWVersioningStoreBackend, ListFieldsOptions, OTStoreBackend, PatchesStoreBackend, ServerStoreBackend, TombstoneStoreBackend, VersioningStoreBackend };
153
+ export type { BranchingStoreBackend, LWWStoreBackend, ListFieldsOptions, OTStoreBackend, ServerStoreBackend, TombstoneStoreBackend, VersioningStoreBackend };
@@ -9,13 +9,13 @@ import '@dabble/delta';
9
9
  import '../client/ClientAlgorithm.js';
10
10
  import '../BaseDoc-DkP3tUhT.js';
11
11
  import '../client/PatchesStore.js';
12
- import '../net/protocol/JSONRPCClient.js';
13
12
  import '../net/protocol/types.js';
14
- import '../algorithms/shared/changeBatching.js';
13
+ import '../net/protocol/JSONRPCClient.js';
15
14
  import '../net/websocket/PatchesWebSocket.js';
16
15
  import '../net/PatchesClient.js';
17
16
  import '../net/websocket/WebSocketTransport.js';
18
17
  import '../utils/deferred.js';
18
+ import '../algorithms/ot/shared/changeBatching.js';
19
19
 
20
20
  /**
21
21
  * Context value containing Patches and optional PatchesSync instances.
@@ -12,10 +12,10 @@ import '../client/ClientAlgorithm.js';
12
12
  import '../BaseDoc-DkP3tUhT.js';
13
13
  import '../client/PatchesStore.js';
14
14
  import '../net/PatchesSync.js';
15
- import '../net/protocol/JSONRPCClient.js';
16
15
  import '../net/protocol/types.js';
17
- import '../algorithms/shared/changeBatching.js';
16
+ import '../net/protocol/JSONRPCClient.js';
18
17
  import '../net/websocket/PatchesWebSocket.js';
19
18
  import '../net/PatchesClient.js';
20
19
  import '../net/websocket/WebSocketTransport.js';
21
20
  import '../utils/deferred.js';
21
+ import '../algorithms/ot/shared/changeBatching.js';
@@ -12,10 +12,10 @@ import '../client/ClientAlgorithm.js';
12
12
  import '../BaseDoc-DkP3tUhT.js';
13
13
  import '../client/PatchesStore.js';
14
14
  import '../net/PatchesSync.js';
15
- import '../net/protocol/JSONRPCClient.js';
16
15
  import '../net/protocol/types.js';
17
- import '../algorithms/shared/changeBatching.js';
16
+ import '../net/protocol/JSONRPCClient.js';
18
17
  import '../net/websocket/PatchesWebSocket.js';
19
18
  import '../net/PatchesClient.js';
20
19
  import '../net/websocket/WebSocketTransport.js';
21
20
  import '../utils/deferred.js';
21
+ import '../algorithms/ot/shared/changeBatching.js';
@@ -9,13 +9,13 @@ import '@dabble/delta';
9
9
  import '../client/ClientAlgorithm.js';
10
10
  import '../BaseDoc-DkP3tUhT.js';
11
11
  import '../client/PatchesStore.js';
12
- import '../net/protocol/JSONRPCClient.js';
13
12
  import '../net/protocol/types.js';
14
- import '../algorithms/shared/changeBatching.js';
13
+ import '../net/protocol/JSONRPCClient.js';
15
14
  import '../net/websocket/PatchesWebSocket.js';
16
15
  import '../net/PatchesClient.js';
17
16
  import '../net/websocket/WebSocketTransport.js';
18
17
  import '../utils/deferred.js';
18
+ import '../algorithms/ot/shared/changeBatching.js';
19
19
 
20
20
  /**
21
21
  * Injection key for Patches instance.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dabble/patches",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Immutable JSON Patch implementation based on RFC 6902 supporting operational transformation and last-writer-wins",
5
5
  "author": "Jacob Wright <jacwright@gmail.com>",
6
6
  "bugs": {
@@ -1,9 +0,0 @@
1
- import { PatchesSnapshot, ChangeMutator, Change } from '../../types.js';
2
- import { SizeCalculator } from '../shared/changeBatching.js';
3
- import '../../json-patch/JSONPatch.js';
4
- import '@dabble/delta';
5
- import '../../json-patch/types.js';
6
-
7
- declare function makeChange<T = any>(snapshot: PatchesSnapshot<T>, mutator: ChangeMutator<T>, changeMetadata?: Record<string, any>, maxStorageBytes?: number, sizeCalculator?: SizeCalculator): Change[];
8
-
9
- export { makeChange };
@@ -1,29 +0,0 @@
1
- import "../../chunk-IZ2YBCUP.js";
2
- import { createChange } from "../../data/change.js";
3
- import { createJSONPatch } from "../../json-patch/createJSONPatch.js";
4
- import { breakChanges } from "../shared/changeBatching.js";
5
- import { createStateFromSnapshot } from "./createStateFromSnapshot.js";
6
- function makeChange(snapshot, mutator, changeMetadata, maxStorageBytes, sizeCalculator) {
7
- const pendingChanges = snapshot.changes;
8
- const pendingRev = pendingChanges[pendingChanges.length - 1]?.rev ?? snapshot.rev;
9
- const state = createStateFromSnapshot(snapshot);
10
- const patch = createJSONPatch(mutator);
11
- if (patch.ops.length === 0) {
12
- return [];
13
- }
14
- const rev = pendingRev + 1;
15
- let newChangesArray = [createChange(snapshot.rev, rev, patch.ops, changeMetadata)];
16
- try {
17
- patch.apply(state);
18
- } catch (error) {
19
- console.error("Failed to apply change to state during makeChange:", error);
20
- throw new Error(`Failed to apply change to state during makeChange: ${error}`);
21
- }
22
- if (maxStorageBytes) {
23
- newChangesArray = breakChanges(newChangesArray, maxStorageBytes, sizeCalculator);
24
- }
25
- return newChangesArray;
26
- }
27
- export {
28
- makeChange
29
- };
@@ -1,2 +0,0 @@
1
- export { Combiner, combinableOps, consolidateFieldOp, consolidateOps, convertDeltaOps } from './consolidateOps.js';
2
- import '../../json-patch/types.js';
@@ -1 +0,0 @@
1
- export * from "./consolidateOps.js";
File without changes