@dabble/patches 0.2.15 → 0.2.17

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 (39) hide show
  1. package/dist/{persist → client}/InMemoryStore.d.ts +1 -1
  2. package/dist/{persist → client}/IndexedDBStore.d.ts +1 -1
  3. package/dist/client/Patches.d.ts +1 -1
  4. package/dist/client/PatchesHistoryClient.d.ts +7 -10
  5. package/dist/client/PatchesHistoryClient.js +16 -5
  6. package/dist/client/index.d.ts +3 -0
  7. package/dist/client/index.js +2 -0
  8. package/dist/index.d.ts +1 -3
  9. package/dist/index.js +1 -2
  10. package/dist/net/index.d.ts +3 -3
  11. package/dist/net/index.js +1 -1
  12. package/dist/net/protocol/JSONRPCClient.d.ts +2 -2
  13. package/dist/net/protocol/JSONRPCServer.d.ts +79 -0
  14. package/dist/net/protocol/JSONRPCServer.js +153 -0
  15. package/dist/net/protocol/types.d.ts +29 -27
  16. package/dist/net/webrtc/WebRTCTransport.d.ts +4 -4
  17. package/dist/net/webrtc/WebRTCTransport.js +1 -3
  18. package/dist/net/websocket/AuthorizationProvider.d.ts +37 -0
  19. package/dist/net/websocket/AuthorizationProvider.js +7 -0
  20. package/dist/net/websocket/PatchesWebSocket.d.ts +4 -4
  21. package/dist/net/websocket/PatchesWebSocket.js +3 -3
  22. package/dist/net/websocket/WebSocketServer.d.ts +144 -0
  23. package/dist/net/websocket/WebSocketServer.js +209 -0
  24. package/dist/net/websocket/WebSocketTransport.d.ts +24 -2
  25. package/dist/net/websocket/WebSocketTransport.js +31 -3
  26. package/dist/server/PatchesBranchManager.js +1 -1
  27. package/dist/server/PatchesHistoryManager.d.ts +17 -2
  28. package/dist/server/PatchesHistoryManager.js +24 -2
  29. package/dist/server/PatchesServer.d.ts +21 -46
  30. package/dist/server/PatchesServer.js +95 -131
  31. package/package.json +2 -6
  32. package/dist/net/AbstractTransport.d.ts +0 -47
  33. package/dist/net/AbstractTransport.js +0 -39
  34. package/dist/persist/index.d.ts +0 -3
  35. package/dist/persist/index.js +0 -3
  36. /package/dist/{persist → client}/InMemoryStore.js +0 -0
  37. /package/dist/{persist → client}/IndexedDBStore.js +0 -0
  38. /package/dist/{persist/PatchesStore.d.ts → client/types.d.ts} +0 -0
  39. /package/dist/{persist/PatchesStore.js → client/types.js} +0 -0
@@ -1,4 +1,4 @@
1
- import type { Change, ListVersionsOptions, PatchesSnapshot, PatchesState, VersionMetadata } from '../types.js';
1
+ import type { Change, PatchesSnapshot, PatchesState, VersionMetadata } from '../types.js';
2
2
  import type { PatchesStoreBackend } from './types.js';
3
3
  /**
4
4
  * Configuration options for the PatchesServer.
@@ -17,18 +17,21 @@ export interface PatchesServerOptions {
17
17
  * and persisting data using a backend store.
18
18
  */
19
19
  export declare class PatchesServer {
20
- private readonly store;
20
+ readonly store: PatchesStoreBackend;
21
21
  private readonly sessionTimeoutMillis;
22
22
  constructor(store: PatchesStoreBackend, options?: PatchesServerOptions);
23
23
  /**
24
24
  * Subscribes the connected client to one or more documents.
25
+ * @param clientId - The ID of the client.
25
26
  * @param ids Document ID(s) to subscribe to.
26
27
  * @returns A list of document IDs the client is now successfully subscribed to.
27
28
  */
28
29
  subscribe(clientId: string, ids: string | string[]): Promise<string[]>;
29
30
  /**
30
31
  * Unsubscribes the connected client from one or more documents.
32
+ * @param clientId - The ID of the client.
31
33
  * @param ids Document ID(s) to unsubscribe from.
34
+ * @returns A list of document IDs the client is now successfully unsubscribed from.
32
35
  */
33
36
  unsubscribe(clientId: string, ids: string | string[]): Promise<string[]>;
34
37
  /**
@@ -53,16 +56,6 @@ export declare class PatchesServer {
53
56
  * - transformedChanges: The client's changes after being transformed against concurrent changes
54
57
  */
55
58
  commitChanges(docId: string, changes: Change[]): Promise<[Change[], Change[]]>;
56
- /**
57
- * Handles offline/large batch versioning logic for multi-batch uploads.
58
- * Groups changes into sessions, merges with previous batch if needed, and creates/extends versions.
59
- * @param docId Document ID
60
- * @param changes The incoming changes (all with the same batchId)
61
- * @param baseRev The base revision for the batch
62
- * @param batchId The batch identifier
63
- * @returns The collapsed changes for transformation
64
- */
65
- private handleOfflineBatches;
66
59
  /**
67
60
  * Deletes a document.
68
61
  * @param docId The document ID.
@@ -76,33 +69,12 @@ export declare class PatchesServer {
76
69
  */
77
70
  createVersion(docId: string, name: string): Promise<string>;
78
71
  /**
79
- * Lists version metadata for a document, supporting various filters.
80
- * @param docId The document ID.
81
- * @param options Filtering and sorting options.
82
- * @returns A list of version metadata objects.
83
- */
84
- listVersions(docId: string, options: ListVersionsOptions): Promise<VersionMetadata[]>;
85
- /**
86
- * Get the state snapshot for a specific version ID.
87
- * @param docId The document ID.
88
- * @param versionId The ID of the version.
89
- * @returns The state snapshot for the specified version.
90
- */
91
- getVersionState(docId: string, versionId: string): Promise<PatchesState>;
92
- /**
93
- * Get the original Change objects associated with a specific version ID.
94
- * @param docId The document ID.
95
- * @param versionId The ID of the version.
96
- * @returns The original Change objects for the specified version.
97
- */
98
- getVersionChanges(docId: string, versionId: string): Promise<Change[]>;
99
- /**
100
- * Update the name of a specific version.
72
+ * Gets the state at a specific revision.
101
73
  * @param docId The document ID.
102
- * @param versionId The ID of the version.
103
- * @param name The new name for the version.
74
+ * @param rev The revision number. If not provided, the latest state and its revision is returned.
75
+ * @returns The state at the specified revision *and* its revision number.
104
76
  */
105
- updateVersion(docId: string, versionId: string, name: string): Promise<void>;
77
+ getStateAtRevision(docId: string, rev?: number): Promise<PatchesState>;
106
78
  /**
107
79
  * Retrieves the document state of the version before the given revision and changes after up to that revision or all
108
80
  * changes since that version.
@@ -110,14 +82,7 @@ export declare class PatchesServer {
110
82
  * @param rev The revision number. If not provided, the latest state, its revision, and all changes since are returned.
111
83
  * @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).
112
84
  */
113
- _getSnapshotAtRevision(docId: string, rev?: number): Promise<PatchesSnapshot>;
114
- /**
115
- * Gets the state at a specific revision.
116
- * @param docId The document ID.
117
- * @param rev The revision number. If not provided, the latest state and its revision is returned.
118
- * @returns The state at the specified revision *and* its revision number.
119
- */
120
- _getStateAtRevision(docId: string, rev?: number): Promise<PatchesState>;
85
+ protected _getSnapshotAtRevision(docId: string, rev?: number): Promise<PatchesSnapshot>;
121
86
  /**
122
87
  * Creates a new version snapshot of a document's current state.
123
88
  * @param docId The document ID.
@@ -126,5 +91,15 @@ export declare class PatchesServer {
126
91
  * @param name The name of the version.
127
92
  * @returns The ID of the created version.
128
93
  */
129
- _createVersion(docId: string, state: any, changes: Change[], name?: string): Promise<VersionMetadata | undefined>;
94
+ protected _createVersion(docId: string, state: any, changes: Change[], name?: string): Promise<VersionMetadata | undefined>;
95
+ /**
96
+ * Handles offline/large batch versioning logic for multi-batch uploads.
97
+ * Groups changes into sessions, merges with previous batch if needed, and creates/extends versions.
98
+ * @param docId Document ID
99
+ * @param changes The incoming changes (all with the same batchId)
100
+ * @param baseRev The base revision for the batch
101
+ * @param batchId The batch identifier
102
+ * @returns The collapsed changes for transformation
103
+ */
104
+ protected _handleOfflineBatches(docId: string, changes: Change[], baseRev: number, batchId?: string): Promise<Change[]>;
130
105
  }
@@ -16,6 +16,7 @@ export class PatchesServer {
16
16
  // === Subscription Operations ===
17
17
  /**
18
18
  * Subscribes the connected client to one or more documents.
19
+ * @param clientId - The ID of the client.
19
20
  * @param ids Document ID(s) to subscribe to.
20
21
  * @returns A list of document IDs the client is now successfully subscribed to.
21
22
  */
@@ -24,7 +25,9 @@ export class PatchesServer {
24
25
  }
25
26
  /**
26
27
  * Unsubscribes the connected client from one or more documents.
28
+ * @param clientId - The ID of the client.
27
29
  * @param ids Document ID(s) to unsubscribe from.
30
+ * @returns A list of document IDs the client is now successfully unsubscribed from.
28
31
  */
29
32
  unsubscribe(clientId, ids) {
30
33
  return this.store.removeSubscription(clientId, Array.isArray(ids) ? ids : [ids]);
@@ -109,12 +112,12 @@ export class PatchesServer {
109
112
  // - or the first change is older than the session timeout (single-batch offline)
110
113
  const isOfflineTimestamp = changes[0].created < Date.now() - this.sessionTimeoutMillis;
111
114
  if (isOfflineTimestamp || batchId) {
112
- changes = await this.handleOfflineBatches(docId, changes, baseRev, batchId);
115
+ changes = await this._handleOfflineBatches(docId, changes, baseRev, batchId);
113
116
  }
114
117
  // 5. Transform the *entire batch* of incoming (and potentially collapsed offline) changes
115
118
  // against committed changes that happened *after* the client's baseRev.
116
119
  // The state used for transformation should be the server state *at the client's baseRev*.
117
- let stateAtBaseRev = (await this._getStateAtRevision(docId, baseRev)).state;
120
+ let stateAtBaseRev = (await this.getStateAtRevision(docId, baseRev)).state;
118
121
  const committedOps = committedChanges.flatMap(c => c.ops);
119
122
  // Apply transformation based on state at baseRev
120
123
  const transformedChanges = changes
@@ -142,84 +145,6 @@ export class PatchesServer {
142
145
  // Return committed changes and newly transformed changes separately
143
146
  return [committedChanges, transformedChanges];
144
147
  }
145
- /**
146
- * Handles offline/large batch versioning logic for multi-batch uploads.
147
- * Groups changes into sessions, merges with previous batch if needed, and creates/extends versions.
148
- * @param docId Document ID
149
- * @param changes The incoming changes (all with the same batchId)
150
- * @param baseRev The base revision for the batch
151
- * @param batchId The batch identifier
152
- * @returns The collapsed changes for transformation
153
- */
154
- async handleOfflineBatches(docId, changes, baseRev, batchId) {
155
- // Use batchId as groupId for multi-batch uploads; default offline sessions have no groupId
156
- const groupId = batchId ?? createId();
157
- // Find the last version for this groupId (if any)
158
- const [lastVersion] = await this.store.listVersions(docId, {
159
- groupId,
160
- reverse: true,
161
- limit: 1,
162
- });
163
- let offlineBaseState;
164
- let parentId;
165
- if (lastVersion) {
166
- // Continue from the last version's state
167
- // loadVersionState returns a PatchState ({state, rev}); extract the .state
168
- const vs = await this.store.loadVersionState(docId, lastVersion.id);
169
- offlineBaseState = vs.state ?? vs;
170
- parentId = lastVersion.id;
171
- }
172
- else {
173
- // First batch for this batchId: start at baseRev
174
- offlineBaseState = (await this._getStateAtRevision(docId, baseRev)).state;
175
- }
176
- let sessionStartIndex = 0;
177
- for (let i = 1; i <= changes.length; i++) {
178
- const isLastChange = i === changes.length;
179
- const timeDiff = isLastChange ? Infinity : changes[i].created - changes[i - 1].created;
180
- // Session ends if timeout exceeded OR it's the last change in the batch
181
- if (timeDiff > this.sessionTimeoutMillis || isLastChange) {
182
- const sessionChanges = changes.slice(sessionStartIndex, i);
183
- if (sessionChanges.length > 0) {
184
- // Check if this is a continuation of the previous session (merge/extend)
185
- const isContinuation = !!lastVersion && sessionChanges[0].created - lastVersion.endDate <= this.sessionTimeoutMillis;
186
- if (isContinuation) {
187
- // Merge/extend the existing version
188
- const mergedState = applyChanges(offlineBaseState, sessionChanges);
189
- await this.store.saveChanges(docId, sessionChanges);
190
- await this.store.updateVersion(docId, lastVersion.id, {}); // metadata already updated above
191
- offlineBaseState = mergedState;
192
- parentId = lastVersion.parentId;
193
- }
194
- else {
195
- // Create a new version for this session
196
- offlineBaseState = applyChanges(offlineBaseState, sessionChanges);
197
- const versionId = createId();
198
- const sessionMetadata = {
199
- id: versionId,
200
- parentId,
201
- groupId,
202
- origin: 'offline',
203
- startDate: sessionChanges[0].created,
204
- endDate: sessionChanges[sessionChanges.length - 1].created,
205
- rev: sessionChanges[sessionChanges.length - 1].rev,
206
- baseRev,
207
- };
208
- await this.store.createVersion(docId, sessionMetadata, offlineBaseState, sessionChanges);
209
- parentId = versionId;
210
- }
211
- sessionStartIndex = i;
212
- }
213
- }
214
- }
215
- // Collapse all changes into one for transformation
216
- return [
217
- changes.reduce((firstChange, nextChange) => {
218
- firstChange.ops = [...firstChange.ops, ...nextChange.ops];
219
- return firstChange;
220
- }),
221
- ];
222
- }
223
148
  /**
224
149
  * Deletes a document.
225
150
  * @param docId The document ID.
@@ -244,43 +169,20 @@ export class PatchesServer {
244
169
  return version.id;
245
170
  }
246
171
  /**
247
- * Lists version metadata for a document, supporting various filters.
248
- * @param docId The document ID.
249
- * @param options Filtering and sorting options.
250
- * @returns A list of version metadata objects.
251
- */
252
- listVersions(docId, options) {
253
- if (!options.orderBy) {
254
- options.orderBy = 'startDate';
255
- }
256
- return this.store.listVersions(docId, options);
257
- }
258
- /**
259
- * Get the state snapshot for a specific version ID.
260
- * @param docId The document ID.
261
- * @param versionId The ID of the version.
262
- * @returns The state snapshot for the specified version.
263
- */
264
- getVersionState(docId, versionId) {
265
- return this.store.loadVersionState(docId, versionId);
266
- }
267
- /**
268
- * Get the original Change objects associated with a specific version ID.
269
- * @param docId The document ID.
270
- * @param versionId The ID of the version.
271
- * @returns The original Change objects for the specified version.
272
- */
273
- getVersionChanges(docId, versionId) {
274
- return this.store.loadVersionChanges(docId, versionId);
275
- }
276
- /**
277
- * Update the name of a specific version.
172
+ * Gets the state at a specific revision.
278
173
  * @param docId The document ID.
279
- * @param versionId The ID of the version.
280
- * @param name The new name for the version.
174
+ * @param rev The revision number. If not provided, the latest state and its revision is returned.
175
+ * @returns The state at the specified revision *and* its revision number.
281
176
  */
282
- updateVersion(docId, versionId, name) {
283
- return this.store.updateVersion(docId, versionId, { name });
177
+ async getStateAtRevision(docId, rev) {
178
+ // Note: _getSnapshotAtRevision now returns the state *of the version* and changes *since* it.
179
+ // We need to apply the changes to get the state *at* the target revision.
180
+ const { state: versionState, rev: snapshotRev, changes } = await this._getSnapshotAtRevision(docId, rev);
181
+ return {
182
+ // Ensure null is passed if versionState or versionState.state is null/undefined
183
+ state: applyChanges(versionState?.state ?? null, changes),
184
+ rev: changes.at(-1)?.rev ?? snapshotRev,
185
+ };
284
186
  }
285
187
  /**
286
188
  * Retrieves the document state of the version before the given revision and changes after up to that revision or all
@@ -311,22 +213,6 @@ export class PatchesServer {
311
213
  changes: changesSinceVersion, // Changes that occurred *after* the base version state
312
214
  };
313
215
  }
314
- /**
315
- * Gets the state at a specific revision.
316
- * @param docId The document ID.
317
- * @param rev The revision number. If not provided, the latest state and its revision is returned.
318
- * @returns The state at the specified revision *and* its revision number.
319
- */
320
- async _getStateAtRevision(docId, rev) {
321
- // Note: _getSnapshotAtRevision now returns the state *of the version* and changes *since* it.
322
- // We need to apply the changes to get the state *at* the target revision.
323
- const { state: versionState, rev: snapshotRev, changes } = await this._getSnapshotAtRevision(docId, rev);
324
- return {
325
- // Ensure null is passed if versionState or versionState.state is null/undefined
326
- state: applyChanges(versionState?.state ?? null, changes),
327
- rev: changes.at(-1)?.rev ?? snapshotRev,
328
- };
329
- }
330
216
  /**
331
217
  * Creates a new version snapshot of a document's current state.
332
218
  * @param docId The document ID.
@@ -355,4 +241,82 @@ export class PatchesServer {
355
241
  await this.store.createVersion(docId, sessionMetadata, state, changes);
356
242
  return sessionMetadata;
357
243
  }
244
+ /**
245
+ * Handles offline/large batch versioning logic for multi-batch uploads.
246
+ * Groups changes into sessions, merges with previous batch if needed, and creates/extends versions.
247
+ * @param docId Document ID
248
+ * @param changes The incoming changes (all with the same batchId)
249
+ * @param baseRev The base revision for the batch
250
+ * @param batchId The batch identifier
251
+ * @returns The collapsed changes for transformation
252
+ */
253
+ async _handleOfflineBatches(docId, changes, baseRev, batchId) {
254
+ // Use batchId as groupId for multi-batch uploads; default offline sessions have no groupId
255
+ const groupId = batchId ?? createId();
256
+ // Find the last version for this groupId (if any)
257
+ const [lastVersion] = await this.store.listVersions(docId, {
258
+ groupId,
259
+ reverse: true,
260
+ limit: 1,
261
+ });
262
+ let offlineBaseState;
263
+ let parentId;
264
+ if (lastVersion) {
265
+ // Continue from the last version's state
266
+ // loadVersionState returns a PatchState ({state, rev}); extract the .state
267
+ const vs = await this.store.loadVersionState(docId, lastVersion.id);
268
+ offlineBaseState = vs.state ?? vs;
269
+ parentId = lastVersion.id;
270
+ }
271
+ else {
272
+ // First batch for this batchId: start at baseRev
273
+ offlineBaseState = (await this.getStateAtRevision(docId, baseRev)).state;
274
+ }
275
+ let sessionStartIndex = 0;
276
+ for (let i = 1; i <= changes.length; i++) {
277
+ const isLastChange = i === changes.length;
278
+ const timeDiff = isLastChange ? Infinity : changes[i].created - changes[i - 1].created;
279
+ // Session ends if timeout exceeded OR it's the last change in the batch
280
+ if (timeDiff > this.sessionTimeoutMillis || isLastChange) {
281
+ const sessionChanges = changes.slice(sessionStartIndex, i);
282
+ if (sessionChanges.length > 0) {
283
+ // Check if this is a continuation of the previous session (merge/extend)
284
+ const isContinuation = !!lastVersion && sessionChanges[0].created - lastVersion.endDate <= this.sessionTimeoutMillis;
285
+ if (isContinuation) {
286
+ // Merge/extend the existing version
287
+ const mergedState = applyChanges(offlineBaseState, sessionChanges);
288
+ await this.store.saveChanges(docId, sessionChanges);
289
+ await this.store.updateVersion(docId, lastVersion.id, {}); // metadata already updated above
290
+ offlineBaseState = mergedState;
291
+ parentId = lastVersion.parentId;
292
+ }
293
+ else {
294
+ // Create a new version for this session
295
+ offlineBaseState = applyChanges(offlineBaseState, sessionChanges);
296
+ const versionId = createId();
297
+ const sessionMetadata = {
298
+ id: versionId,
299
+ parentId,
300
+ groupId,
301
+ origin: 'offline',
302
+ startDate: sessionChanges[0].created,
303
+ endDate: sessionChanges[sessionChanges.length - 1].created,
304
+ rev: sessionChanges[sessionChanges.length - 1].rev,
305
+ baseRev,
306
+ };
307
+ await this.store.createVersion(docId, sessionMetadata, offlineBaseState, sessionChanges);
308
+ parentId = versionId;
309
+ }
310
+ sessionStartIndex = i;
311
+ }
312
+ }
313
+ }
314
+ // Collapse all changes into one for transformation
315
+ return [
316
+ changes.reduce((firstChange, nextChange) => {
317
+ firstChange.ops = [...firstChange.ops, ...nextChange.ops];
318
+ return firstChange;
319
+ }),
320
+ ];
321
+ }
358
322
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dabble/patches",
3
- "version": "0.2.15",
3
+ "version": "0.2.17",
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": {
@@ -25,10 +25,6 @@
25
25
  "./net": {
26
26
  "import": "./dist/net/index.js",
27
27
  "types": "./dist/net/index.d.ts"
28
- },
29
- "./persist": {
30
- "import": "./dist/persist/index.js",
31
- "types": "./dist/persist/index.d.ts"
32
28
  }
33
29
  },
34
30
  "files": [
@@ -75,4 +71,4 @@
75
71
  "vite-plugin-dts": "^4.5.3",
76
72
  "vitest": "^3.1.3"
77
73
  }
78
- }
74
+ }
@@ -1,47 +0,0 @@
1
- import type { ConnectionState, Transport } from '../net/protocol/types.js';
2
- /**
3
- * Abstract base class that implements common functionality for various transport implementations.
4
- * Provides state management and event signaling for connection state changes and message reception.
5
- * Concrete transport implementations must extend this class and implement the abstract methods.
6
- */
7
- export declare abstract class AbstractTransport implements Transport {
8
- private _state;
9
- /**
10
- * Signal that emits when the connection state changes.
11
- * Subscribers will receive the new connection state as an argument.
12
- */
13
- readonly onStateChange: import("../event-signal.js").Signal<(state: ConnectionState) => void>;
14
- /**
15
- * Signal that emits when a message is received from the transport.
16
- * Subscribers will receive the message data as a string.
17
- */
18
- readonly onMessage: import("../event-signal.js").Signal<(data: string) => void>;
19
- /**
20
- * Gets the current connection state of the transport.
21
- * @returns The current connection state ('connecting', 'connected', 'disconnected', or 'error')
22
- */
23
- get state(): ConnectionState;
24
- /**
25
- * Sets the connection state and emits a state change event.
26
- * This method is protected and should only be called by subclasses.
27
- * @param state - The new connection state
28
- */
29
- protected set state(state: ConnectionState);
30
- /**
31
- * Establishes the connection for this transport.
32
- * Must be implemented by concrete subclasses.
33
- * @returns A promise that resolves when the connection is established
34
- */
35
- abstract connect(): Promise<void>;
36
- /**
37
- * Terminates the connection for this transport.
38
- * Must be implemented by concrete subclasses.
39
- */
40
- abstract disconnect(): void;
41
- /**
42
- * Sends data through this transport.
43
- * Must be implemented by concrete subclasses.
44
- * @param data - The string data to send
45
- */
46
- abstract send(data: string): void;
47
- }
@@ -1,39 +0,0 @@
1
- import { signal } from '../event-signal.js';
2
- /**
3
- * Abstract base class that implements common functionality for various transport implementations.
4
- * Provides state management and event signaling for connection state changes and message reception.
5
- * Concrete transport implementations must extend this class and implement the abstract methods.
6
- */
7
- export class AbstractTransport {
8
- constructor() {
9
- this._state = 'disconnected';
10
- /**
11
- * Signal that emits when the connection state changes.
12
- * Subscribers will receive the new connection state as an argument.
13
- */
14
- this.onStateChange = signal();
15
- /**
16
- * Signal that emits when a message is received from the transport.
17
- * Subscribers will receive the message data as a string.
18
- */
19
- this.onMessage = signal();
20
- }
21
- /**
22
- * Gets the current connection state of the transport.
23
- * @returns The current connection state ('connecting', 'connected', 'disconnected', or 'error')
24
- */
25
- get state() {
26
- return this._state;
27
- }
28
- /**
29
- * Sets the connection state and emits a state change event.
30
- * This method is protected and should only be called by subclasses.
31
- * @param state - The new connection state
32
- */
33
- set state(state) {
34
- if (state === this._state)
35
- return;
36
- this._state = state;
37
- this.onStateChange.emit(state);
38
- }
39
- }
@@ -1,3 +0,0 @@
1
- export * from './IndexedDBStore.js';
2
- export * from './InMemoryStore.js';
3
- export * from './PatchesStore.js';
@@ -1,3 +0,0 @@
1
- export * from './IndexedDBStore.js';
2
- export * from './InMemoryStore.js';
3
- export * from './PatchesStore.js';
File without changes
File without changes