@dabble/patches 0.7.10 → 0.7.12

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.
@@ -110,7 +110,7 @@ interface PatchesDoc<T extends object = object> extends SyncedDoc {
110
110
  /** Current sync status of this document. */
111
111
  readonly syncStatus: DocSyncStatus;
112
112
  /** Error from the last failed sync attempt, if any. */
113
- readonly syncError: Error | null;
113
+ readonly syncError: Error | undefined;
114
114
  /** Whether the document has completed its initial load. Sticky: once true, never reverts to false. */
115
115
  readonly isLoaded: boolean;
116
116
  /**
@@ -148,7 +148,7 @@ declare abstract class BaseDoc<T extends object = object> implements PatchesDoc<
148
148
  protected _id: string;
149
149
  protected _state: T;
150
150
  protected _syncStatus: DocSyncStatus;
151
- protected _syncError: Error | null;
151
+ protected _syncError: Error | undefined;
152
152
  protected _isLoaded: boolean;
153
153
  /**
154
154
  * Subscribe to be notified when the user makes local changes.
@@ -173,7 +173,7 @@ declare abstract class BaseDoc<T extends object = object> implements PatchesDoc<
173
173
  /** Current sync status of this document. */
174
174
  get syncStatus(): DocSyncStatus;
175
175
  /** Error from the last failed sync attempt, if any. */
176
- get syncError(): Error | null;
176
+ get syncError(): Error | undefined;
177
177
  /** Whether the document has completed its initial load. Sticky: once true, never reverts to false. */
178
178
  get isLoaded(): boolean;
179
179
  /** Last committed revision number from the server. */
@@ -1,6 +1,6 @@
1
1
  import '../event-signal.js';
2
2
  import '../json-patch/types.js';
3
3
  import '../types.js';
4
- export { B as BaseDoc } from '../BaseDoc-BfVJNeCi.js';
4
+ export { B as BaseDoc } from '../BaseDoc-CYjP_zPU.js';
5
5
  import '../json-patch/JSONPatch.js';
6
6
  import '@dabble/delta';
@@ -6,7 +6,7 @@ class BaseDoc {
6
6
  _id;
7
7
  _state;
8
8
  _syncStatus = "unsynced";
9
- _syncError = null;
9
+ _syncError;
10
10
  _isLoaded = false;
11
11
  /**
12
12
  * Subscribe to be notified when the user makes local changes.
@@ -74,7 +74,7 @@ class BaseDoc {
74
74
  */
75
75
  updateSyncStatus(status, error) {
76
76
  this._syncStatus = status;
77
- this._syncError = status === "error" ? error ?? null : null;
77
+ this._syncError = status === "error" ? error : void 0;
78
78
  this._checkLoaded();
79
79
  this.onSyncStatus.emit(status);
80
80
  }
@@ -1,6 +1,6 @@
1
1
  import { JSONPatchOp } from '../json-patch/types.js';
2
2
  import { PatchesSnapshot, Change } from '../types.js';
3
- import { a as PatchesDoc } from '../BaseDoc-BfVJNeCi.js';
3
+ import { a as PatchesDoc } from '../BaseDoc-CYjP_zPU.js';
4
4
  import { PatchesStore, TrackedDoc } from './PatchesStore.js';
5
5
  import '../json-patch/JSONPatch.js';
6
6
  import '@dabble/delta';
@@ -2,7 +2,7 @@ import { JSONPatchOp } from '../json-patch/types.js';
2
2
  import { PatchesSnapshot, Change } from '../types.js';
3
3
  import { ClientAlgorithm } from './ClientAlgorithm.js';
4
4
  import { LWWClientStore } from './LWWClientStore.js';
5
- import { a as PatchesDoc } from '../BaseDoc-BfVJNeCi.js';
5
+ import { a as PatchesDoc } from '../BaseDoc-CYjP_zPU.js';
6
6
  import { TrackedDoc } from './PatchesStore.js';
7
7
  import '../json-patch/JSONPatch.js';
8
8
  import '@dabble/delta';
@@ -1,5 +1,5 @@
1
1
  import { PatchesSnapshot, Change } from '../types.js';
2
- import { B as BaseDoc } from '../BaseDoc-BfVJNeCi.js';
2
+ import { B as BaseDoc } from '../BaseDoc-CYjP_zPU.js';
3
3
  import '../json-patch/JSONPatch.js';
4
4
  import '@dabble/delta';
5
5
  import '../json-patch/types.js';
@@ -2,7 +2,7 @@ import { JSONPatchOp } from '../json-patch/types.js';
2
2
  import { PatchesSnapshot, Change } from '../types.js';
3
3
  import { ClientAlgorithm } from './ClientAlgorithm.js';
4
4
  import { OTClientStore } from './OTClientStore.js';
5
- import { P as PatchesDocOptions, a as PatchesDoc } from '../BaseDoc-BfVJNeCi.js';
5
+ import { P as PatchesDocOptions, a as PatchesDoc } from '../BaseDoc-CYjP_zPU.js';
6
6
  import { TrackedDoc } from './PatchesStore.js';
7
7
  import '../json-patch/JSONPatch.js';
8
8
  import '@dabble/delta';
@@ -1,5 +1,5 @@
1
1
  import '../types.js';
2
- export { O as OTDoc } from '../BaseDoc-BfVJNeCi.js';
2
+ export { O as OTDoc } from '../BaseDoc-CYjP_zPU.js';
3
3
  import '../json-patch/JSONPatch.js';
4
4
  import '@dabble/delta';
5
5
  import '../json-patch/types.js';
@@ -2,7 +2,7 @@ import { Unsubscriber, Signal } from '../event-signal.js';
2
2
  import { JSONPatchOp } from '../json-patch/types.js';
3
3
  import { Change } from '../types.js';
4
4
  import { ClientAlgorithm } from './ClientAlgorithm.js';
5
- import { P as PatchesDocOptions, a as PatchesDoc } from '../BaseDoc-BfVJNeCi.js';
5
+ import { P as PatchesDocOptions, a as PatchesDoc } from '../BaseDoc-CYjP_zPU.js';
6
6
  import { AlgorithmName } from './PatchesStore.js';
7
7
  import '../json-patch/JSONPatch.js';
8
8
  import '@dabble/delta';
@@ -1,6 +1,6 @@
1
1
  import '../event-signal.js';
2
2
  import '../json-patch/types.js';
3
3
  import '../types.js';
4
- export { O as OTDoc, a as PatchesDoc, O as PatchesDocClass, P as PatchesDocOptions } from '../BaseDoc-BfVJNeCi.js';
4
+ export { O as OTDoc, a as PatchesDoc, O as PatchesDocClass, P as PatchesDocOptions } from '../BaseDoc-CYjP_zPU.js';
5
5
  import '../json-patch/JSONPatch.js';
6
6
  import '@dabble/delta';
@@ -1,6 +1,6 @@
1
1
  import { AlgorithmName } from './PatchesStore.js';
2
2
  import { Patches } from './Patches.js';
3
- import { P as PatchesDocOptions } from '../BaseDoc-BfVJNeCi.js';
3
+ import { P as PatchesDocOptions } from '../BaseDoc-CYjP_zPU.js';
4
4
  import '../types.js';
5
5
  import '../json-patch/JSONPatch.js';
6
6
  import '@dabble/delta';
@@ -1,4 +1,4 @@
1
- export { B as BaseDoc, O as OTDoc, a as PatchesDoc, O as PatchesDocClass, P as PatchesDocOptions } from '../BaseDoc-BfVJNeCi.js';
1
+ export { B as BaseDoc, O as OTDoc, a as PatchesDoc, O as PatchesDocClass, P as PatchesDocOptions } from '../BaseDoc-CYjP_zPU.js';
2
2
  export { IndexedDBFactoryOptions, MultiAlgorithmFactoryOptions, MultiAlgorithmIndexedDBFactoryOptions, PatchesFactoryOptions, createLWWIndexedDBPatches, createLWWPatches, createMultiAlgorithmIndexedDBPatches, createMultiAlgorithmPatches, createOTIndexedDBPatches, createOTPatches } from './factories.js';
3
3
  export { IDBStoreWrapper, IDBTransactionWrapper, IndexedDBStore } from './IndexedDBStore.js';
4
4
  export { OTIndexedDBStore } from './OTIndexedDBStore.js';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { Delta } from '@dabble/delta';
2
- export { B as BaseDoc, O as OTDoc, a as PatchesDoc, O as PatchesDocClass, P as PatchesDocOptions } from './BaseDoc-BfVJNeCi.js';
2
+ export { B as BaseDoc, O as OTDoc, a as PatchesDoc, O as PatchesDocClass, P as PatchesDocOptions } from './BaseDoc-CYjP_zPU.js';
3
3
  export { IndexedDBFactoryOptions, MultiAlgorithmFactoryOptions, MultiAlgorithmIndexedDBFactoryOptions, PatchesFactoryOptions, createLWWIndexedDBPatches, createLWWPatches, createMultiAlgorithmIndexedDBPatches, createMultiAlgorithmPatches, createOTIndexedDBPatches, createOTPatches } from './client/factories.js';
4
4
  export { IDBStoreWrapper, IDBTransactionWrapper, IndexedDBStore } from './client/IndexedDBStore.js';
5
5
  export { OTIndexedDBStore } from './client/OTIndexedDBStore.js';
@@ -8,19 +8,18 @@ import { SizeCalculator } from '../algorithms/ot/shared/changeBatching.js';
8
8
  import { ClientAlgorithm } from '../client/ClientAlgorithm.js';
9
9
  import { Patches } from '../client/Patches.js';
10
10
  import { AlgorithmName } from '../client/PatchesStore.js';
11
- export { isDocLoaded } from '../shared/utils.js';
12
11
  import '../json-patch/JSONPatch.js';
13
12
  import '@dabble/delta';
14
13
  import '../json-patch/types.js';
15
14
  import './PatchesClient.js';
16
15
  import '../utils/deferred.js';
17
- import '../BaseDoc-BfVJNeCi.js';
16
+ import '../BaseDoc-CYjP_zPU.js';
18
17
 
19
18
  interface PatchesSyncState {
20
19
  online: boolean;
21
20
  connected: boolean;
22
21
  syncStatus: DocSyncStatus;
23
- syncError: Error | null;
22
+ syncError: Error | undefined;
24
23
  }
25
24
  interface PatchesSyncOptions {
26
25
  subscribeFilter?: (docIds: string[]) => string[];
@@ -32,7 +31,6 @@ interface PatchesSyncOptions {
32
31
  /** Custom size calculator for storage limit. Falls back to patches.docOptions.sizeCalculator. */
33
32
  sizeCalculator?: SizeCalculator;
34
33
  }
35
-
36
34
  /**
37
35
  * Handles WebSocket connection, document subscriptions, and syncing logic between
38
36
  * the Patches instance and the server.
@@ -19,7 +19,7 @@ const EMPTY_SYNCED_DOC = {
19
19
  committedRev: 0,
20
20
  hasPending: false,
21
21
  syncStatus: "unsynced",
22
- syncError: null,
22
+ syncError: void 0,
23
23
  isLoaded: false
24
24
  };
25
25
  _syncDoc_dec = [blockable], __receiveCommittedChanges_dec = [blockable];
@@ -35,7 +35,12 @@ class PatchesSync {
35
35
  __publicField(this, "trackedDocs");
36
36
  /** Maps docId to the algorithm name used for that doc */
37
37
  __publicField(this, "docAlgorithms", /* @__PURE__ */ new Map());
38
- __publicField(this, "_state", { online: false, connected: false, syncStatus: "unsynced", syncError: null });
38
+ __publicField(this, "_state", {
39
+ online: false,
40
+ connected: false,
41
+ syncStatus: "unsynced",
42
+ syncError: void 0
43
+ });
39
44
  __publicField(this, "_syncedDocs", {});
40
45
  /**
41
46
  * Signal emitted when the sync state changes.
@@ -127,7 +132,7 @@ class PatchesSync {
127
132
  updateState(update) {
128
133
  const newState = { ...this._state, ...update };
129
134
  if (newState.syncStatus !== "error" && newState.syncError) {
130
- newState.syncError = null;
135
+ newState.syncError = void 0;
131
136
  }
132
137
  if (!isEqual(this._state, newState)) {
133
138
  this._state = newState;
@@ -186,7 +191,7 @@ class PatchesSync {
186
191
  committedRev: doc.committedRev,
187
192
  hasPending: pending != null && pending.length > 0,
188
193
  syncStatus: doc.committedRev === 0 ? "unsynced" : "synced",
189
- syncError: null,
194
+ syncError: void 0,
190
195
  isLoaded: false
191
196
  };
192
197
  const existing = this._syncedDocs[doc.docId];
@@ -251,6 +256,7 @@ class PatchesSync {
251
256
  } else {
252
257
  const snapshot = await this.ws.getDoc(docId);
253
258
  await algorithm.store.saveDoc(docId, snapshot);
259
+ this._updateSyncedDoc(docId, { committedRev: snapshot.rev });
254
260
  if (baseDoc) {
255
261
  baseDoc.import({ ...snapshot, changes: [] });
256
262
  }
@@ -471,7 +477,7 @@ class PatchesSync {
471
477
  } else {
472
478
  const updated = { ...EMPTY_SYNCED_DOC, ...this._syncedDocs[docId], ...updates };
473
479
  if (updated.syncStatus !== "error" && updated.syncError) {
474
- updated.syncError = null;
480
+ updated.syncError = void 0;
475
481
  }
476
482
  if (!updated.isLoaded) {
477
483
  updated.isLoaded = isDocLoaded(updated);
@@ -526,6 +532,5 @@ __decorateElement(_init, 1, "syncDoc", _syncDoc_dec, PatchesSync);
526
532
  __decorateElement(_init, 1, "_receiveCommittedChanges", __receiveCommittedChanges_dec, PatchesSync);
527
533
  __decoratorMetadata(_init, PatchesSync);
528
534
  export {
529
- PatchesSync,
530
- isDocLoaded
535
+ PatchesSync
531
536
  };
@@ -12,13 +12,12 @@ export { PatchesWebSocket } from './websocket/PatchesWebSocket.js';
12
12
  export { JsonRpcMessage, SignalingService } from './websocket/SignalingService.js';
13
13
  export { WebSocketServer, WebSocketServerOptions } from './websocket/WebSocketServer.js';
14
14
  export { WebSocketOptions, WebSocketTransport } from './websocket/WebSocketTransport.js';
15
- export { isDocLoaded } from '../shared/utils.js';
16
15
  export { CommitChangesOptions } from '../types.js';
17
16
  import '../event-signal.js';
18
17
  import '../algorithms/ot/shared/changeBatching.js';
19
18
  import '../client/ClientAlgorithm.js';
20
19
  import '../json-patch/types.js';
21
- import '../BaseDoc-BfVJNeCi.js';
20
+ import '../BaseDoc-CYjP_zPU.js';
22
21
  import '../client/PatchesStore.js';
23
22
  import '../client/Patches.js';
24
23
  import '../server/types.js';
@@ -1,5 +1,5 @@
1
1
  import { Patches, OpenDocOptions } from '../client/Patches.js';
2
- import { a as PatchesDoc } from '../BaseDoc-BfVJNeCi.js';
2
+ import { a as PatchesDoc } from '../BaseDoc-CYjP_zPU.js';
3
3
  import '../event-signal.js';
4
4
  import '../json-patch/types.js';
5
5
  import '../types.js';
@@ -7,7 +7,7 @@ import '../types.js';
7
7
  import '../json-patch/JSONPatch.js';
8
8
  import '@dabble/delta';
9
9
  import '../client/ClientAlgorithm.js';
10
- import '../BaseDoc-BfVJNeCi.js';
10
+ import '../BaseDoc-CYjP_zPU.js';
11
11
  import '../client/PatchesStore.js';
12
12
  import '../net/protocol/types.js';
13
13
  import '../net/protocol/JSONRPCClient.js';
@@ -16,7 +16,6 @@ import '../net/PatchesClient.js';
16
16
  import '../net/websocket/WebSocketTransport.js';
17
17
  import '../utils/deferred.js';
18
18
  import '../algorithms/ot/shared/changeBatching.js';
19
- import '../shared/utils.js';
20
19
 
21
20
  /**
22
21
  * Context value containing Patches and optional PatchesSync instances.
@@ -6,5 +6,5 @@ import '../types.js';
6
6
  import '../json-patch/JSONPatch.js';
7
7
  import '@dabble/delta';
8
8
  import '../client/ClientAlgorithm.js';
9
- import '../BaseDoc-BfVJNeCi.js';
9
+ import '../BaseDoc-CYjP_zPU.js';
10
10
  import '../client/PatchesStore.js';
@@ -11,7 +11,7 @@ import '../types.js';
11
11
  import '../json-patch/JSONPatch.js';
12
12
  import '@dabble/delta';
13
13
  import '../client/ClientAlgorithm.js';
14
- import '../BaseDoc-BfVJNeCi.js';
14
+ import '../BaseDoc-CYjP_zPU.js';
15
15
  import '../client/PatchesStore.js';
16
16
  import '../net/PatchesSync.js';
17
17
  import '../net/protocol/types.js';
@@ -1,6 +1,6 @@
1
1
  import { Accessor } from 'solid-js';
2
2
  import { OpenDocOptions } from '../client/Patches.js';
3
- import { a as PatchesDoc } from '../BaseDoc-BfVJNeCi.js';
3
+ import { a as PatchesDoc } from '../BaseDoc-CYjP_zPU.js';
4
4
  import { JSONPatch } from '../json-patch/JSONPatch.js';
5
5
  import { ChangeMutator } from '../types.js';
6
6
  import '../event-signal.js';
@@ -52,7 +52,7 @@ interface UsePatchesDocReturn<T extends object> {
52
52
  /**
53
53
  * Error that occurred during sync, if any.
54
54
  */
55
- error: Accessor<Error | null>;
55
+ error: Accessor<Error | undefined>;
56
56
  /**
57
57
  * The committed revision number.
58
58
  * Increments each time the server confirms changes.
@@ -15,7 +15,7 @@ function createDocReactiveState(options) {
15
15
  const [doc, setDoc] = createSignal(void 0);
16
16
  const [data, setData] = createSignal(void 0);
17
17
  const [loading, setLoading] = createSignal(initialLoading);
18
- const [error, setError] = createSignal(null);
18
+ const [error, setError] = createSignal();
19
19
  const [rev, setRev] = createSignal(0);
20
20
  const [hasPending, setHasPending] = createSignal(false);
21
21
  function setupDoc(patchesDoc) {
@@ -44,7 +44,7 @@ function createDocReactiveState(options) {
44
44
  });
45
45
  const unsubSync = patchesDoc.onSyncStatus((status) => {
46
46
  updateLoading();
47
- setError(status === "error" ? patchesDoc.syncError : null);
47
+ setError(status === "error" ? patchesDoc.syncError : void 0);
48
48
  });
49
49
  return () => {
50
50
  unsubState();
@@ -55,7 +55,7 @@ function createDocReactiveState(options) {
55
55
  setDoc(void 0);
56
56
  setData(void 0);
57
57
  setLoading(false);
58
- setError(null);
58
+ setError(void 0);
59
59
  setRev(0);
60
60
  setHasPending(false);
61
61
  }
package/dist/types.d.ts CHANGED
@@ -78,7 +78,7 @@ interface SyncedDoc {
78
78
  committedRev: number;
79
79
  hasPending: boolean;
80
80
  syncStatus: DocSyncStatus;
81
- syncError: Error | null;
81
+ syncError: Error | undefined;
82
82
  isLoaded: boolean;
83
83
  }
84
84
  /** Status options for a branch */
@@ -1,6 +1,6 @@
1
1
  import { ShallowRef, Ref, MaybeRef } from 'vue';
2
2
  import { OpenDocOptions } from '../client/Patches.js';
3
- import { a as PatchesDoc } from '../BaseDoc-BfVJNeCi.js';
3
+ import { a as PatchesDoc } from '../BaseDoc-CYjP_zPU.js';
4
4
  import { JSONPatch } from '../json-patch/JSONPatch.js';
5
5
  import { ChangeMutator } from '../types.js';
6
6
  import '../event-signal.js';
@@ -52,7 +52,7 @@ interface UsePatchesDocReturn<T extends object> {
52
52
  /**
53
53
  * Error that occurred during sync, if any.
54
54
  */
55
- error: Ref<Error | null>;
55
+ error: Ref<Error | undefined>;
56
56
  /**
57
57
  * The committed revision number.
58
58
  * Increments each time the server confirms changes.
@@ -16,7 +16,7 @@ function createDocReactiveState(options) {
16
16
  const doc = ref(void 0);
17
17
  const data = shallowRef(void 0);
18
18
  const loading = ref(initialLoading);
19
- const error = ref(null);
19
+ const error = ref();
20
20
  const rev = ref(0);
21
21
  const hasPending = ref(false);
22
22
  function setupDoc(patchesDoc) {
@@ -45,7 +45,7 @@ function createDocReactiveState(options) {
45
45
  });
46
46
  const unsubSync = patchesDoc.onSyncStatus((status) => {
47
47
  updateLoading();
48
- error.value = status === "error" ? patchesDoc.syncError : null;
48
+ error.value = status === "error" ? patchesDoc.syncError : void 0;
49
49
  });
50
50
  return () => {
51
51
  unsubState();
@@ -56,7 +56,7 @@ function createDocReactiveState(options) {
56
56
  doc.value = void 0;
57
57
  data.value = void 0;
58
58
  loading.value = false;
59
- error.value = null;
59
+ error.value = void 0;
60
60
  rev.value = 0;
61
61
  hasPending.value = false;
62
62
  }
@@ -6,5 +6,5 @@ import '../types.js';
6
6
  import '../json-patch/JSONPatch.js';
7
7
  import '@dabble/delta';
8
8
  import '../client/ClientAlgorithm.js';
9
- import '../BaseDoc-BfVJNeCi.js';
9
+ import '../BaseDoc-CYjP_zPU.js';
10
10
  import '../client/PatchesStore.js';
@@ -11,7 +11,7 @@ import '../types.js';
11
11
  import '../json-patch/JSONPatch.js';
12
12
  import '@dabble/delta';
13
13
  import '../client/ClientAlgorithm.js';
14
- import '../BaseDoc-BfVJNeCi.js';
14
+ import '../BaseDoc-CYjP_zPU.js';
15
15
  import '../client/PatchesStore.js';
16
16
  import '../net/PatchesSync.js';
17
17
  import '../net/protocol/types.js';
@@ -6,7 +6,7 @@ import '../types.js';
6
6
  import '../json-patch/JSONPatch.js';
7
7
  import '@dabble/delta';
8
8
  import '../client/ClientAlgorithm.js';
9
- import '../BaseDoc-BfVJNeCi.js';
9
+ import '../BaseDoc-CYjP_zPU.js';
10
10
  import '../client/PatchesStore.js';
11
11
 
12
12
  /**
@@ -7,7 +7,7 @@ import '../types.js';
7
7
  import '../json-patch/JSONPatch.js';
8
8
  import '@dabble/delta';
9
9
  import '../client/ClientAlgorithm.js';
10
- import '../BaseDoc-BfVJNeCi.js';
10
+ import '../BaseDoc-CYjP_zPU.js';
11
11
  import '../client/PatchesStore.js';
12
12
  import '../net/protocol/types.js';
13
13
  import '../net/protocol/JSONRPCClient.js';
@@ -16,7 +16,6 @@ import '../net/PatchesClient.js';
16
16
  import '../net/websocket/WebSocketTransport.js';
17
17
  import '../utils/deferred.js';
18
18
  import '../algorithms/ot/shared/changeBatching.js';
19
- import '../shared/utils.js';
20
19
 
21
20
  /**
22
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.10",
3
+ "version": "0.7.12",
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": {