@dabble/patches 0.7.24 → 0.8.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.
@@ -0,0 +1,12 @@
1
+ export { PatchesREST, PatchesRESTOptions } from './PatchesREST.js';
2
+ export { BufferedEvent, SSEServer, SSEServerOptions } from './SSEServer.js';
3
+ export { encodeDocId, normalizeIds } from './utils.js';
4
+ import 'easy-signal';
5
+ import '../../types.js';
6
+ import '../../json-patch/JSONPatch.js';
7
+ import '@dabble/delta';
8
+ import '../../json-patch/types.js';
9
+ import '../PatchesConnection.js';
10
+ import '../protocol/types.js';
11
+ import '../websocket/AuthorizationProvider.js';
12
+ import '../../server/types.js';
@@ -0,0 +1,8 @@
1
+ import "../../chunk-IZ2YBCUP.js";
2
+ export * from "./PatchesREST.js";
3
+ export * from "./SSEServer.js";
4
+ import { encodeDocId, normalizeIds } from "./utils.js";
5
+ export {
6
+ encodeDocId,
7
+ normalizeIds
8
+ };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Encode a hierarchical doc ID for use in URL path segments.
3
+ * Each segment is individually encoded so slashes are preserved as path separators.
4
+ *
5
+ * @example encodeDocId('users/abc/stats/2026-01') => 'users/abc/stats/2026-01'
6
+ * @example encodeDocId('docs/hello world') => 'docs/hello%20world'
7
+ */
8
+ declare function encodeDocId(docId: string): string;
9
+ /**
10
+ * Normalize a string or string array to a string array.
11
+ */
12
+ declare function normalizeIds(ids: string | string[]): string[];
13
+
14
+ export { encodeDocId, normalizeIds };
@@ -0,0 +1,11 @@
1
+ import "../../chunk-IZ2YBCUP.js";
2
+ function encodeDocId(docId) {
3
+ return docId.split("/").map(encodeURIComponent).join("/");
4
+ }
5
+ function normalizeIds(ids) {
6
+ return Array.isArray(ids) ? ids : [ids];
7
+ }
8
+ export {
9
+ encodeDocId,
10
+ normalizeIds
11
+ };
@@ -1,5 +1,6 @@
1
1
  import { Signal } from 'easy-signal';
2
2
  import { PatchesClient } from '../PatchesClient.js';
3
+ import { PatchesConnection } from '../PatchesConnection.js';
3
4
  import { ConnectionState } from '../protocol/types.js';
4
5
  import { WebSocketTransport, WebSocketOptions } from './WebSocketTransport.js';
5
6
  import '../../types.js';
@@ -15,7 +16,7 @@ import '../../utils/deferred.js';
15
16
  * versioning, and other OT-specific functionality
16
17
  * over a WebSocket connection.
17
18
  */
18
- declare class PatchesWebSocket extends PatchesClient {
19
+ declare class PatchesWebSocket extends PatchesClient implements PatchesConnection {
19
20
  transport: WebSocketTransport;
20
21
  /** Signal emitted when the underlying WebSocket connection state changes. */
21
22
  readonly onStateChange: Signal<(state: ConnectionState) => void>;
@@ -25,6 +26,9 @@ declare class PatchesWebSocket extends PatchesClient {
25
26
  * @param wsOptions - Optional configuration for the underlying WebSocket connection
26
27
  */
27
28
  constructor(url: string, wsOptions?: WebSocketOptions);
29
+ /** The WebSocket server URL. */
30
+ get url(): string;
31
+ set url(url: string);
28
32
  /**
29
33
  * Establishes a connection to the Patches server.
30
34
  * @returns A promise that resolves when the connection is established
@@ -18,6 +18,14 @@ class PatchesWebSocket extends PatchesClient {
18
18
  this.transport = transport;
19
19
  this.onStateChange = this.transport.onStateChange;
20
20
  }
21
+ // --- URL ---
22
+ /** The WebSocket server URL. */
23
+ get url() {
24
+ return this.transport.url;
25
+ }
26
+ set url(url) {
27
+ this.transport.url = url;
28
+ }
21
29
  // --- Connection Management ---
22
30
  /**
23
31
  * Establishes a connection to the Patches server.
@@ -9,13 +9,12 @@ import '@dabble/delta';
9
9
  import '../client/ClientAlgorithm.js';
10
10
  import '../BaseDoc-BT18xPxU.js';
11
11
  import '../client/PatchesStore.js';
12
+ import '../algorithms/ot/shared/changeBatching.js';
13
+ import '../net/PatchesConnection.js';
12
14
  import '../net/protocol/types.js';
13
15
  import '../net/protocol/JSONRPCClient.js';
14
- import '../net/websocket/PatchesWebSocket.js';
15
- import '../net/PatchesClient.js';
16
16
  import '../net/websocket/WebSocketTransport.js';
17
17
  import '../utils/deferred.js';
18
- import '../algorithms/ot/shared/changeBatching.js';
19
18
 
20
19
  /**
21
20
  * Context value containing Patches and optional PatchesSync instances.
@@ -14,10 +14,9 @@ import '../client/ClientAlgorithm.js';
14
14
  import '../BaseDoc-BT18xPxU.js';
15
15
  import '../client/PatchesStore.js';
16
16
  import '../net/PatchesSync.js';
17
+ import '../algorithms/ot/shared/changeBatching.js';
18
+ import '../net/PatchesConnection.js';
17
19
  import '../net/protocol/types.js';
18
20
  import '../net/protocol/JSONRPCClient.js';
19
- import '../net/websocket/PatchesWebSocket.js';
20
- import '../net/PatchesClient.js';
21
21
  import '../net/websocket/WebSocketTransport.js';
22
22
  import '../utils/deferred.js';
23
- import '../algorithms/ot/shared/changeBatching.js';
@@ -14,10 +14,9 @@ import '../client/ClientAlgorithm.js';
14
14
  import '../BaseDoc-BT18xPxU.js';
15
15
  import '../client/PatchesStore.js';
16
16
  import '../net/PatchesSync.js';
17
+ import '../algorithms/ot/shared/changeBatching.js';
18
+ import '../net/PatchesConnection.js';
17
19
  import '../net/protocol/types.js';
18
20
  import '../net/protocol/JSONRPCClient.js';
19
- import '../net/websocket/PatchesWebSocket.js';
20
- import '../net/PatchesClient.js';
21
21
  import '../net/websocket/WebSocketTransport.js';
22
22
  import '../utils/deferred.js';
23
- import '../algorithms/ot/shared/changeBatching.js';
@@ -9,13 +9,12 @@ import '@dabble/delta';
9
9
  import '../client/ClientAlgorithm.js';
10
10
  import '../BaseDoc-BT18xPxU.js';
11
11
  import '../client/PatchesStore.js';
12
+ import '../algorithms/ot/shared/changeBatching.js';
13
+ import '../net/PatchesConnection.js';
12
14
  import '../net/protocol/types.js';
13
15
  import '../net/protocol/JSONRPCClient.js';
14
- import '../net/websocket/PatchesWebSocket.js';
15
- import '../net/PatchesClient.js';
16
16
  import '../net/websocket/WebSocketTransport.js';
17
17
  import '../utils/deferred.js';
18
- import '../algorithms/ot/shared/changeBatching.js';
19
18
 
20
19
  /**
21
20
  * Injection key for Patches instance.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dabble/patches",
3
- "version": "0.7.24",
3
+ "version": "0.8.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": {
@@ -41,6 +41,10 @@
41
41
  "./solid": {
42
42
  "import": "./dist/solid/index.js",
43
43
  "types": "./dist/solid/index.d.ts"
44
+ },
45
+ "./micro": {
46
+ "import": "./dist/micro/index.js",
47
+ "types": "./dist/micro/index.d.ts"
44
48
  }
45
49
  },
46
50
  "files": [