@dabble/patches 0.7.12 → 0.7.14

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 | undefined;
113
+ readonly syncError?: Error;
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 | undefined;
151
+ protected _syncError?: Error;
152
152
  protected _isLoaded: boolean;
153
153
  /**
154
154
  * Subscribe to be notified when the user makes local changes.
@@ -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-CYjP_zPU.js';
4
+ export { B as BaseDoc } from '../BaseDoc-vaMreJL5.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-CYjP_zPU.js';
3
+ import { a as PatchesDoc } from '../BaseDoc-vaMreJL5.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-CYjP_zPU.js';
5
+ import { a as PatchesDoc } from '../BaseDoc-vaMreJL5.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-CYjP_zPU.js';
2
+ import { B as BaseDoc } from '../BaseDoc-vaMreJL5.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-CYjP_zPU.js';
5
+ import { P as PatchesDocOptions, a as PatchesDoc } from '../BaseDoc-vaMreJL5.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-CYjP_zPU.js';
2
+ export { O as OTDoc } from '../BaseDoc-vaMreJL5.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-CYjP_zPU.js';
5
+ import { P as PatchesDocOptions, a as PatchesDoc } from '../BaseDoc-vaMreJL5.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-CYjP_zPU.js';
4
+ export { O as OTDoc, a as PatchesDoc, O as PatchesDocClass, P as PatchesDocOptions } from '../BaseDoc-vaMreJL5.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-CYjP_zPU.js';
3
+ import { P as PatchesDocOptions } from '../BaseDoc-vaMreJL5.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-CYjP_zPU.js';
1
+ export { B as BaseDoc, O as OTDoc, a as PatchesDoc, O as PatchesDocClass, P as PatchesDocOptions } from '../BaseDoc-vaMreJL5.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';
@@ -202,9 +202,11 @@ function createOrderGetter(orderField) {
202
202
  function sortByOrder(items, orderField = "order") {
203
203
  const getOrder = createOrderGetter(orderField);
204
204
  return Object.entries(items).sort((a, b) => {
205
- const orderCmp = getOrder(a[1]).localeCompare(getOrder(b[1]));
205
+ const orderA = getOrder(a[1]);
206
+ const orderB = getOrder(b[1]);
207
+ const orderCmp = orderA < orderB ? -1 : orderA > orderB ? 1 : 0;
206
208
  if (orderCmp !== 0) return orderCmp;
207
- return a[0].localeCompare(b[0]);
209
+ return a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0;
208
210
  });
209
211
  }
210
212
  function healDuplicateOrders(items, orderField = "order") {
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-CYjP_zPU.js';
2
+ export { B as BaseDoc, O as OTDoc, a as PatchesDoc, O as PatchesDocClass, P as PatchesDocOptions } from './BaseDoc-vaMreJL5.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';
@@ -1,4 +1,5 @@
1
1
  import "../chunk-IZ2YBCUP.js";
2
+ import { escapePathComponent } from "./utils/escapePathComponent.js";
2
3
  const proxyFodder = {};
3
4
  const createPathProxy = pathProxy;
4
5
  function pathProxy(path = "") {
@@ -9,7 +10,7 @@ function pathProxy(path = "") {
9
10
  return path;
10
11
  };
11
12
  }
12
- return pathProxy(`${path}/${prop}`);
13
+ return pathProxy(`${path}/${escapePathComponent(prop)}`);
13
14
  },
14
15
  set(_, prop) {
15
16
  throw new Error(
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Escapes a single path component for use in a JSON Pointer (RFC 6901).
3
+ * `~` is escaped as `~0` and `/` is escaped as `~1`.
4
+ */
5
+ declare function escapePathComponent(component: string): string;
6
+
7
+ export { escapePathComponent };
@@ -0,0 +1,7 @@
1
+ import "../../chunk-IZ2YBCUP.js";
2
+ function escapePathComponent(component) {
3
+ return component.replace(/~/g, "~0").replace(/\//g, "~1");
4
+ }
5
+ export {
6
+ escapePathComponent
7
+ };
@@ -1,4 +1,5 @@
1
1
  export { deepEqual } from './deepEqual.js';
2
+ export { escapePathComponent } from './escapePathComponent.js';
2
3
  export { get } from './get.js';
3
4
  export { getOpData } from './getOpData.js';
4
5
  export { getType, getTypeLike } from './getType.js';
@@ -1,4 +1,5 @@
1
1
  export * from "./deepEqual.js";
2
+ export * from "./escapePathComponent.js";
2
3
  export * from "./get.js";
3
4
  export * from "./getOpData.js";
4
5
  export * from "./getType.js";
@@ -13,13 +13,13 @@ import '@dabble/delta';
13
13
  import '../json-patch/types.js';
14
14
  import './PatchesClient.js';
15
15
  import '../utils/deferred.js';
16
- import '../BaseDoc-CYjP_zPU.js';
16
+ import '../BaseDoc-vaMreJL5.js';
17
17
 
18
18
  interface PatchesSyncState {
19
19
  online: boolean;
20
20
  connected: boolean;
21
21
  syncStatus: DocSyncStatus;
22
- syncError: Error | undefined;
22
+ syncError?: Error;
23
23
  }
24
24
  interface PatchesSyncOptions {
25
25
  subscribeFilter?: (docIds: string[]) => string[];
@@ -19,7 +19,6 @@ const EMPTY_SYNCED_DOC = {
19
19
  committedRev: 0,
20
20
  hasPending: false,
21
21
  syncStatus: "unsynced",
22
- syncError: void 0,
23
22
  isLoaded: false
24
23
  };
25
24
  _syncDoc_dec = [blockable], __receiveCommittedChanges_dec = [blockable];
@@ -17,7 +17,7 @@ import '../event-signal.js';
17
17
  import '../algorithms/ot/shared/changeBatching.js';
18
18
  import '../client/ClientAlgorithm.js';
19
19
  import '../json-patch/types.js';
20
- import '../BaseDoc-CYjP_zPU.js';
20
+ import '../BaseDoc-vaMreJL5.js';
21
21
  import '../client/PatchesStore.js';
22
22
  import '../client/Patches.js';
23
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-CYjP_zPU.js';
2
+ import { a as PatchesDoc } from '../BaseDoc-vaMreJL5.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-CYjP_zPU.js';
10
+ import '../BaseDoc-vaMreJL5.js';
11
11
  import '../client/PatchesStore.js';
12
12
  import '../net/protocol/types.js';
13
13
  import '../net/protocol/JSONRPCClient.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-CYjP_zPU.js';
9
+ import '../BaseDoc-vaMreJL5.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-CYjP_zPU.js';
14
+ import '../BaseDoc-vaMreJL5.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-CYjP_zPU.js';
3
+ import { a as PatchesDoc } from '../BaseDoc-vaMreJL5.js';
4
4
  import { JSONPatch } from '../json-patch/JSONPatch.js';
5
5
  import { ChangeMutator } from '../types.js';
6
6
  import '../event-signal.js';
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 | undefined;
81
+ syncError?: Error;
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-CYjP_zPU.js';
3
+ import { a as PatchesDoc } from '../BaseDoc-vaMreJL5.js';
4
4
  import { JSONPatch } from '../json-patch/JSONPatch.js';
5
5
  import { ChangeMutator } from '../types.js';
6
6
  import '../event-signal.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-CYjP_zPU.js';
9
+ import '../BaseDoc-vaMreJL5.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-CYjP_zPU.js';
14
+ import '../BaseDoc-vaMreJL5.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-CYjP_zPU.js';
9
+ import '../BaseDoc-vaMreJL5.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-CYjP_zPU.js';
10
+ import '../BaseDoc-vaMreJL5.js';
11
11
  import '../client/PatchesStore.js';
12
12
  import '../net/protocol/types.js';
13
13
  import '../net/protocol/JSONRPCClient.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dabble/patches",
3
- "version": "0.7.12",
3
+ "version": "0.7.14",
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": {