@dabble/patches 0.8.20 → 0.8.21

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.
@@ -246,4 +246,4 @@ declare abstract class BaseDoc<T extends object = object> extends ReadonlyStoreC
246
246
  abstract import(snapshot: PatchesSnapshot<T>): void;
247
247
  }
248
248
 
249
- export { BaseDoc as B, OTDoc as O, type PatchesDocOptions as P, type PatchesDoc as a };
249
+ export { BaseDoc as B, OTDoc as O, type PatchesDoc as P, type PatchesDocOptions as a };
@@ -1,5 +1,5 @@
1
1
  import { OTStoreBackend } from '../../../server/types.js';
2
- import { EditableVersionMetadata, VersionMetadata, Change } from '../../../types.js';
2
+ import { EditableVersionMetadata, Change, VersionMetadata } from '../../../types.js';
3
3
  import '../../../json-patch/types.js';
4
4
  import '../../../json-patch/JSONPatch.js';
5
5
  import '@dabble/delta';
@@ -1,6 +1,6 @@
1
1
  import 'easy-signal';
2
2
  import '../json-patch/types.js';
3
3
  import '../types.js';
4
- export { B as BaseDoc } from '../BaseDoc-CXHXcW18.js';
4
+ export { B as BaseDoc } from '../BaseDoc-rCKMFV6B.js';
5
5
  import '../json-patch/JSONPatch.js';
6
6
  import '@dabble/delta';
@@ -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-CXHXcW18.js';
3
+ import { P as PatchesDoc } from '../BaseDoc-rCKMFV6B.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-CXHXcW18.js';
5
+ import { P as PatchesDoc } from '../BaseDoc-rCKMFV6B.js';
6
6
  import { TrackedDoc } from './PatchesStore.js';
7
7
  import '../json-patch/JSONPatch.js';
8
8
  import '@dabble/delta';
@@ -1,6 +1,6 @@
1
1
  import { JSONPatchOp } from '../json-patch/types.js';
2
2
  import { PatchesSnapshot, Change } from '../types.js';
3
- import { B as BaseDoc } from '../BaseDoc-CXHXcW18.js';
3
+ import { B as BaseDoc } from '../BaseDoc-rCKMFV6B.js';
4
4
  import '../json-patch/JSONPatch.js';
5
5
  import '@dabble/delta';
6
6
  import 'easy-signal';
@@ -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-CXHXcW18.js';
5
+ import { a as PatchesDocOptions, P as PatchesDoc } from '../BaseDoc-rCKMFV6B.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-CXHXcW18.js';
2
+ export { O as OTDoc } from '../BaseDoc-rCKMFV6B.js';
3
3
  import '../json-patch/JSONPatch.js';
4
4
  import '@dabble/delta';
5
5
  import '../json-patch/types.js';
@@ -3,7 +3,7 @@ import { Unsubscriber } from 'easy-signal';
3
3
  import { JSONPatchOp } from '../json-patch/types.js';
4
4
  import { Change } from '../types.js';
5
5
  import { ClientAlgorithm } from './ClientAlgorithm.js';
6
- import { P as PatchesDocOptions, a as PatchesDoc } from '../BaseDoc-CXHXcW18.js';
6
+ import { a as PatchesDocOptions, P as PatchesDoc } from '../BaseDoc-rCKMFV6B.js';
7
7
  import { AlgorithmName } from './PatchesStore.js';
8
8
  import '../json-patch/JSONPatch.js';
9
9
  import '@dabble/delta';
@@ -8,7 +8,7 @@ import '../json-patch/JSONPatch.js';
8
8
  import '@dabble/delta';
9
9
  import '../json-patch/types.js';
10
10
  import './ClientAlgorithm.js';
11
- import '../BaseDoc-CXHXcW18.js';
11
+ import '../BaseDoc-rCKMFV6B.js';
12
12
 
13
13
  interface PatchesBranchClientOptions {
14
14
  /** Algorithm to use for the branch document (defaults to the Patches instance default). */
@@ -1,6 +1,6 @@
1
1
  import 'easy-signal';
2
2
  import '../json-patch/types.js';
3
3
  import '../types.js';
4
- export { O as OTDoc, a as PatchesDoc, P as PatchesDocOptions } from '../BaseDoc-CXHXcW18.js';
4
+ export { O as OTDoc, P as PatchesDoc, a as PatchesDocOptions } from '../BaseDoc-rCKMFV6B.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-CXHXcW18.js';
3
+ import { a as PatchesDocOptions } from '../BaseDoc-rCKMFV6B.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, P as PatchesDocOptions } from '../BaseDoc-CXHXcW18.js';
1
+ export { B as BaseDoc, O as OTDoc, P as PatchesDoc, a as PatchesDocOptions } from '../BaseDoc-rCKMFV6B.js';
2
2
  export { IndexedDBFactoryOptions, MultiAlgorithmFactoryOptions, MultiAlgorithmIndexedDBFactoryOptions, PatchesFactoryOptions, createLWWIndexedDBPatches, createLWWPatches, createMultiAlgorithmExternalDBPatches, createMultiAlgorithmIndexedDBPatches, createMultiAlgorithmPatches, createOTIndexedDBPatches, createOTPatches, upgradePatchesDB } 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, P as PatchesDocOptions } from './BaseDoc-CXHXcW18.js';
2
+ export { B as BaseDoc, O as OTDoc, P as PatchesDoc, a as PatchesDocOptions } from './BaseDoc-rCKMFV6B.js';
3
3
  export { IndexedDBFactoryOptions, MultiAlgorithmFactoryOptions, MultiAlgorithmIndexedDBFactoryOptions, PatchesFactoryOptions, createLWWIndexedDBPatches, createLWWPatches, createMultiAlgorithmExternalDBPatches, createMultiAlgorithmIndexedDBPatches, createMultiAlgorithmPatches, createOTIndexedDBPatches, createOTPatches, upgradePatchesDB } from './client/factories.js';
4
4
  export { IDBStoreWrapper, IDBTransactionWrapper, IndexedDBStore } from './client/IndexedDBStore.js';
5
5
  export { OTIndexedDBStore } from './client/OTIndexedDBStore.js';
@@ -13,7 +13,7 @@ import { WebSocketOptions } from './websocket/WebSocketTransport.js';
13
13
  import '../json-patch/JSONPatch.js';
14
14
  import '@dabble/delta';
15
15
  import '../json-patch/types.js';
16
- import '../BaseDoc-CXHXcW18.js';
16
+ import '../BaseDoc-rCKMFV6B.js';
17
17
  import '../utils/deferred.js';
18
18
 
19
19
  interface PatchesSyncState {
@@ -22,7 +22,7 @@ import '../algorithms/ot/shared/changeBatching.js';
22
22
  import '../client/BranchClientStore.js';
23
23
  import '../client/ClientAlgorithm.js';
24
24
  import '../json-patch/types.js';
25
- import '../BaseDoc-CXHXcW18.js';
25
+ import '../BaseDoc-rCKMFV6B.js';
26
26
  import '../client/PatchesStore.js';
27
27
  import '../client/Patches.js';
28
28
  import '../server/types.js';
@@ -4,6 +4,8 @@ import { StatusError } from "../error.js";
4
4
  import { onlineState } from "../websocket/onlineState.js";
5
5
  import { normalizeIds } from "./utils.js";
6
6
  const SESSION_STORAGE_KEY = "patches-clientId";
7
+ const REQUEST_TIMEOUT_MS = 3e4;
8
+ const CONNECT_TIMEOUT_MS = 3e4;
7
9
  class PatchesREST {
8
10
  /** The client ID used for SSE connection and subscription management. */
9
11
  clientId;
@@ -49,16 +51,26 @@ class PatchesREST {
49
51
  const es = new EventSource(`${this._url}/events/${this.clientId}`);
50
52
  this.eventSource = es;
51
53
  let settled = false;
54
+ const timer = globalThis.setTimeout(() => {
55
+ if (settled) return;
56
+ settled = true;
57
+ es.close();
58
+ if (this.eventSource === es) this.eventSource = null;
59
+ this._setState("error");
60
+ reject(new Error("SSE connection timed out"));
61
+ }, CONNECT_TIMEOUT_MS);
52
62
  es.onopen = () => {
53
63
  this._setState("connected");
54
64
  if (!settled) {
55
65
  settled = true;
66
+ globalThis.clearTimeout(timer);
56
67
  resolve();
57
68
  }
58
69
  };
59
70
  es.onerror = () => {
60
71
  if (!settled) {
61
72
  settled = true;
73
+ globalThis.clearTimeout(timer);
62
74
  this._setState("error");
63
75
  reject(new Error("SSE connection failed"));
64
76
  return;
@@ -202,7 +214,8 @@ class PatchesREST {
202
214
  ...hasBody ? { "Content-Type": "application/json" } : {},
203
215
  ...headers
204
216
  },
205
- body: hasBody ? JSON.stringify(init.body) : void 0
217
+ body: hasBody ? JSON.stringify(init.body) : void 0,
218
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
206
219
  });
207
220
  if (!response.ok) {
208
221
  let message = response.statusText;
@@ -5,10 +5,10 @@ import { LWWServer } from './LWWServer.js';
5
5
  import { LWWStoreBackend, BranchingStoreBackend } from './types.js';
6
6
  import 'easy-signal';
7
7
  import '../net/websocket/AuthorizationProvider.js';
8
- import '../json-patch/types.js';
8
+ import '../net/protocol/types.js';
9
9
  import '../json-patch/JSONPatch.js';
10
10
  import '@dabble/delta';
11
- import '../net/protocol/types.js';
11
+ import '../json-patch/types.js';
12
12
  import './PatchesServer.js';
13
13
 
14
14
  /**
@@ -4,10 +4,10 @@ import { Change, CommitChangesOptions, DeleteDocOptions, ChangeInput, ChangeMuta
4
4
  import { PatchesServer } from './PatchesServer.js';
5
5
  import { LWWStoreBackend } from './types.js';
6
6
  import '../net/websocket/AuthorizationProvider.js';
7
- import '../json-patch/types.js';
7
+ import '../net/protocol/types.js';
8
8
  import '../json-patch/JSONPatch.js';
9
9
  import '@dabble/delta';
10
- import '../net/protocol/types.js';
10
+ import '../json-patch/types.js';
11
11
 
12
12
  /**
13
13
  * Configuration options for LWWServer.
@@ -1,5 +1,5 @@
1
1
  import { ApiDefinition } from '../net/protocol/JSONRPCServer.js';
2
- import { EditableBranchMetadata, CreateBranchMetadata, Branch } from '../types.js';
2
+ import { EditableBranchMetadata, Branch, CreateBranchMetadata } from '../types.js';
3
3
  import 'easy-signal';
4
4
  import '../net/websocket/AuthorizationProvider.js';
5
5
  import './types.js';
@@ -1,5 +1,5 @@
1
1
  import { JSONPatchOp } from '../json-patch/types.js';
2
- import { DocumentTombstone, VersionMetadata, Change, ListVersionsOptions, EditableVersionMetadata, ListChangesOptions, ListBranchesOptions, Branch } from '../types.js';
2
+ import { VersionMetadata, Change, ListVersionsOptions, EditableVersionMetadata, ListChangesOptions, DocumentTombstone, ListBranchesOptions, Branch } from '../types.js';
3
3
  import '../json-patch/JSONPatch.js';
4
4
  import '@dabble/delta';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { Patches, OpenDocOptions } from '../client/Patches.js';
2
- import { a as PatchesDoc } from '../BaseDoc-CXHXcW18.js';
2
+ import { P as PatchesDoc } from '../BaseDoc-rCKMFV6B.js';
3
3
  import 'easy-signal';
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-CXHXcW18.js';
10
+ import '../BaseDoc-rCKMFV6B.js';
11
11
  import '../client/PatchesStore.js';
12
12
  import '../algorithms/ot/shared/changeBatching.js';
13
13
  import '../client/BranchClientStore.js';
@@ -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-CXHXcW18.js';
9
+ import '../BaseDoc-rCKMFV6B.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-CXHXcW18.js';
14
+ import '../BaseDoc-rCKMFV6B.js';
15
15
  import '../client/PatchesStore.js';
16
16
  import '../net/PatchesSync.js';
17
17
  import '../algorithms/ot/shared/changeBatching.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-CXHXcW18.js';
3
+ import { P as PatchesDoc } from '../BaseDoc-rCKMFV6B.js';
4
4
  import { ChangeMutator } from '../types.js';
5
5
  import 'easy-signal';
6
6
  import '../json-patch/types.js';
@@ -1,6 +1,6 @@
1
- import { ShallowRef, Ref, MaybeRefOrGetter, MaybeRef } from 'vue';
1
+ import { ShallowRef, Ref, MaybeRef, MaybeRefOrGetter } from 'vue';
2
2
  import { OpenDocOptions } from '../client/Patches.js';
3
- import { a as PatchesDoc } from '../BaseDoc-CXHXcW18.js';
3
+ import { P as PatchesDoc } from '../BaseDoc-rCKMFV6B.js';
4
4
  import { ChangeMutator } from '../types.js';
5
5
  import 'easy-signal';
6
6
  import '../json-patch/types.js';
@@ -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-CXHXcW18.js';
9
+ import '../BaseDoc-rCKMFV6B.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-CXHXcW18.js';
14
+ import '../BaseDoc-rCKMFV6B.js';
15
15
  import '../client/PatchesStore.js';
16
16
  import '../net/PatchesSync.js';
17
17
  import '../algorithms/ot/shared/changeBatching.js';
@@ -1,4 +1,4 @@
1
- import { Ref, ShallowRef } from 'vue';
1
+ import { ShallowRef, Ref } from 'vue';
2
2
  import { OpenDocOptions } from '../client/Patches.js';
3
3
  import 'easy-signal';
4
4
  import '../json-patch/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-CXHXcW18.js';
9
+ import '../BaseDoc-rCKMFV6B.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-CXHXcW18.js';
10
+ import '../BaseDoc-rCKMFV6B.js';
11
11
  import '../client/PatchesStore.js';
12
12
  import '../algorithms/ot/shared/changeBatching.js';
13
13
  import '../client/BranchClientStore.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dabble/patches",
3
- "version": "0.8.20",
3
+ "version": "0.8.21",
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": {