@dabble/patches 0.7.14 → 0.7.16

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 (83) hide show
  1. package/README.md +4 -4
  2. package/dist/{BaseDoc-vaMreJL5.d.ts → BaseDoc-BRIP2YZp.d.ts} +16 -35
  3. package/dist/algorithms/ot/server/commitChanges.d.ts +1 -1
  4. package/dist/client/BaseDoc.d.ts +2 -2
  5. package/dist/client/BaseDoc.js +13 -38
  6. package/dist/client/ClientAlgorithm.d.ts +2 -2
  7. package/dist/client/IndexedDBStore.d.ts +2 -2
  8. package/dist/client/IndexedDBStore.js +3 -8
  9. package/dist/client/LWWAlgorithm.d.ts +2 -2
  10. package/dist/client/LWWDoc.d.ts +3 -3
  11. package/dist/client/LWWDoc.js +10 -7
  12. package/dist/client/LWWIndexedDBStore.d.ts +1 -1
  13. package/dist/client/LWWIndexedDBStore.js +4 -4
  14. package/dist/client/OTAlgorithm.d.ts +2 -2
  15. package/dist/client/OTDoc.d.ts +2 -2
  16. package/dist/client/OTDoc.js +7 -8
  17. package/dist/client/OTIndexedDBStore.d.ts +1 -1
  18. package/dist/client/OTIndexedDBStore.js +3 -3
  19. package/dist/client/Patches.d.ts +9 -8
  20. package/dist/client/Patches.js +9 -6
  21. package/dist/client/PatchesDoc.d.ts +2 -2
  22. package/dist/client/PatchesHistoryClient.d.ts +5 -11
  23. package/dist/client/PatchesHistoryClient.js +14 -29
  24. package/dist/client/factories.d.ts +2 -2
  25. package/dist/client/index.d.ts +2 -2
  26. package/dist/index.d.ts +3 -3
  27. package/dist/index.js +23 -2
  28. package/dist/net/PatchesClient.d.ts +3 -3
  29. package/dist/net/PatchesClient.js +1 -1
  30. package/dist/net/PatchesSync.d.ts +14 -29
  31. package/dist/net/PatchesSync.js +84 -98
  32. package/dist/net/http/FetchTransport.d.ts +2 -2
  33. package/dist/net/http/FetchTransport.js +1 -1
  34. package/dist/net/index.d.ts +2 -2
  35. package/dist/net/protocol/JSONRPCClient.d.ts +1 -1
  36. package/dist/net/protocol/JSONRPCClient.js +1 -1
  37. package/dist/net/protocol/JSONRPCServer.d.ts +1 -1
  38. package/dist/net/protocol/JSONRPCServer.js +1 -1
  39. package/dist/net/protocol/types.d.ts +1 -1
  40. package/dist/net/protocol/utils.d.ts +1 -1
  41. package/dist/net/webrtc/WebRTCAwareness.d.ts +2 -2
  42. package/dist/net/webrtc/WebRTCAwareness.js +1 -1
  43. package/dist/net/webrtc/WebRTCTransport.d.ts +5 -5
  44. package/dist/net/webrtc/WebRTCTransport.js +1 -1
  45. package/dist/net/webrtc/index.d.ts +1 -1
  46. package/dist/net/websocket/PatchesWebSocket.d.ts +1 -1
  47. package/dist/net/websocket/PatchesWebSocket.js +1 -1
  48. package/dist/net/websocket/SignalingService.d.ts +1 -1
  49. package/dist/net/websocket/WebSocketServer.d.ts +1 -1
  50. package/dist/net/websocket/WebSocketTransport.d.ts +4 -3
  51. package/dist/net/websocket/WebSocketTransport.js +1 -1
  52. package/dist/net/websocket/onlineState.d.ts +2 -2
  53. package/dist/net/websocket/onlineState.js +1 -1
  54. package/dist/server/LWWBranchManager.d.ts +1 -1
  55. package/dist/server/LWWServer.d.ts +3 -3
  56. package/dist/server/LWWServer.js +1 -1
  57. package/dist/server/OTBranchManager.d.ts +1 -1
  58. package/dist/server/OTServer.d.ts +3 -3
  59. package/dist/server/OTServer.js +1 -1
  60. package/dist/server/PatchesHistoryManager.d.ts +1 -1
  61. package/dist/server/PatchesServer.d.ts +1 -1
  62. package/dist/server/branchUtils.d.ts +1 -1
  63. package/dist/server/index.d.ts +1 -1
  64. package/dist/shared/doc-manager.d.ts +2 -2
  65. package/dist/shared/utils.d.ts +2 -2
  66. package/dist/shared/utils.js +2 -2
  67. package/dist/solid/context.d.ts +2 -2
  68. package/dist/solid/doc-manager.d.ts +2 -2
  69. package/dist/solid/index.d.ts +2 -2
  70. package/dist/solid/managed-docs.js +1 -1
  71. package/dist/solid/primitives.d.ts +2 -2
  72. package/dist/solid/primitives.js +7 -7
  73. package/dist/types.d.ts +4 -4
  74. package/dist/vue/composables.d.ts +2 -2
  75. package/dist/vue/composables.js +7 -7
  76. package/dist/vue/doc-manager.d.ts +2 -2
  77. package/dist/vue/index.d.ts +2 -2
  78. package/dist/vue/managed-docs.d.ts +2 -2
  79. package/dist/vue/managed-docs.js +1 -1
  80. package/dist/vue/provider.d.ts +2 -2
  81. package/package.json +2 -1
  82. package/dist/event-signal.d.ts +0 -32
  83. package/dist/event-signal.js +0 -25
@@ -1,4 +1,4 @@
1
- import { Signal } from '../event-signal.js';
1
+ import * as easy_signal from 'easy-signal';
2
2
  import { ApiDefinition } from '../net/protocol/JSONRPCServer.js';
3
3
  import { Change, CommitChangesOptions, DeleteDocOptions, PatchesState, ChangeInput, ChangeMutator, EditableVersionMetadata } from '../types.js';
4
4
  import { PatchesServer } from './PatchesServer.js';
@@ -55,9 +55,9 @@ declare class LWWServer implements PatchesServer {
55
55
  readonly store: LWWStoreBackend;
56
56
  private readonly snapshotInterval;
57
57
  /** Notifies listeners whenever a batch of changes is successfully committed. */
58
- readonly onChangesCommitted: Signal<(docId: string, changes: Change[], options?: CommitChangesOptions, originClientId?: string) => void>;
58
+ readonly onChangesCommitted: easy_signal.Signal<(docId: string, changes: Change[], options?: CommitChangesOptions, originClientId?: string) => void>;
59
59
  /** Notifies listeners when a document is deleted. */
60
- readonly onDocDeleted: Signal<(docId: string, options?: DeleteDocOptions, originClientId?: string) => void>;
60
+ readonly onDocDeleted: easy_signal.Signal<(docId: string, options?: DeleteDocOptions, originClientId?: string) => void>;
61
61
  constructor(store: LWWStoreBackend, options?: LWWServerOptions);
62
62
  /**
63
63
  * Get the current state of a document.
@@ -2,7 +2,7 @@ import "../chunk-IZ2YBCUP.js";
2
2
  import { createVersionMetadata } from "../data/version.js";
3
3
  import { consolidateOps, convertDeltaOps } from "../algorithms/lww/consolidateOps.js";
4
4
  import { createChange } from "../data/change.js";
5
- import { signal } from "../event-signal.js";
5
+ import { signal } from "easy-signal";
6
6
  import { createJSONPatch } from "../json-patch/createJSONPatch.js";
7
7
  import { JSONPatch } from "../json-patch/JSONPatch.js";
8
8
  import { getClientId } from "../net/serverContext.js";
@@ -4,7 +4,7 @@ import { BranchManager } from './BranchManager.js';
4
4
  import { PatchesServer } from './PatchesServer.js';
5
5
  import { OTStoreBackend, BranchingStoreBackend } from './types.js';
6
6
  export { assertBranchMetadata } from './branchUtils.js';
7
- import '../event-signal.js';
7
+ import 'easy-signal';
8
8
  import '../net/websocket/AuthorizationProvider.js';
9
9
  import '../json-patch/types.js';
10
10
  import '../json-patch/JSONPatch.js';
@@ -1,4 +1,4 @@
1
- import { Signal } from '../event-signal.js';
1
+ import * as easy_signal from 'easy-signal';
2
2
  import { PatchesServer } from './PatchesServer.js';
3
3
  import { OTStoreBackend } from './types.js';
4
4
  import { Change, CommitChangesOptions, DeleteDocOptions, PatchesState, ChangeInput, ChangeMutator, EditableVersionMetadata } from '../types.js';
@@ -48,9 +48,9 @@ declare class OTServer implements PatchesServer {
48
48
  private readonly maxStorageBytes?;
49
49
  readonly store: OTStoreBackend;
50
50
  /** Notifies listeners whenever a batch of changes is *successfully* committed. */
51
- readonly onChangesCommitted: Signal<(docId: string, changes: Change[], options?: CommitChangesOptions, originClientId?: string) => void>;
51
+ readonly onChangesCommitted: easy_signal.Signal<(docId: string, changes: Change[], options?: CommitChangesOptions, originClientId?: string) => void>;
52
52
  /** Notifies listeners when a document is deleted. */
53
- readonly onDocDeleted: Signal<(docId: string, options?: DeleteDocOptions, originClientId?: string) => void>;
53
+ readonly onDocDeleted: easy_signal.Signal<(docId: string, options?: DeleteDocOptions, originClientId?: string) => void>;
54
54
  constructor(store: OTStoreBackend, options?: OTServerOptions);
55
55
  /**
56
56
  * Get the current state of a document.
@@ -5,7 +5,7 @@ import { getSnapshotAtRevision } from "../algorithms/ot/server/getSnapshotAtRevi
5
5
  import { getStateAtRevision } from "../algorithms/ot/server/getStateAtRevision.js";
6
6
  import { applyChanges } from "../algorithms/ot/shared/applyChanges.js";
7
7
  import { createChange } from "../data/change.js";
8
- import { signal } from "../event-signal.js";
8
+ import { signal } from "easy-signal";
9
9
  import { createJSONPatch } from "../json-patch/createJSONPatch.js";
10
10
  import { getClientId } from "../net/serverContext.js";
11
11
  import { createTombstoneIfSupported, removeTombstoneIfExists } from "./tombstone.js";
@@ -2,7 +2,7 @@ import { ApiDefinition } from '../net/protocol/JSONRPCServer.js';
2
2
  import { ListVersionsOptions, VersionMetadata, EditableVersionMetadata, Change } from '../types.js';
3
3
  import { PatchesServer } from './PatchesServer.js';
4
4
  import { VersioningStoreBackend } from './types.js';
5
- import '../event-signal.js';
5
+ import 'easy-signal';
6
6
  import '../net/websocket/AuthorizationProvider.js';
7
7
  import '../json-patch/types.js';
8
8
  import '../json-patch/JSONPatch.js';
@@ -3,7 +3,7 @@ import { ApiDefinition } from '../net/protocol/JSONRPCServer.js';
3
3
  import '../json-patch/JSONPatch.js';
4
4
  import '@dabble/delta';
5
5
  import '../json-patch/types.js';
6
- import '../event-signal.js';
6
+ import 'easy-signal';
7
7
  import '../net/websocket/AuthorizationProvider.js';
8
8
  import './types.js';
9
9
  import '../net/protocol/types.js';
@@ -1,6 +1,6 @@
1
1
  import { ApiDefinition } from '../net/protocol/JSONRPCServer.js';
2
2
  import { EditableBranchMetadata, Branch, BranchStatus } from '../types.js';
3
- import '../event-signal.js';
3
+ import 'easy-signal';
4
4
  import '../net/websocket/AuthorizationProvider.js';
5
5
  import './types.js';
6
6
  import '../json-patch/types.js';
@@ -12,7 +12,7 @@ export { assertVersionMetadata } from './utils.js';
12
12
  export { CommitChangesOptions, DeleteDocOptions } from '../types.js';
13
13
  export { PatchesServer } from './PatchesServer.js';
14
14
  export { BranchingStoreBackend, LWWStoreBackend, ListFieldsOptions, OTStoreBackend, ServerStoreBackend, TombstoneStoreBackend, VersioningStoreBackend } from './types.js';
15
- import '../event-signal.js';
15
+ import 'easy-signal';
16
16
  import '../net/protocol/JSONRPCServer.js';
17
17
  import '../net/websocket/AuthorizationProvider.js';
18
18
  import '../net/protocol/types.js';
@@ -1,6 +1,6 @@
1
1
  import { Patches, OpenDocOptions } from '../client/Patches.js';
2
- import { a as PatchesDoc } from '../BaseDoc-vaMreJL5.js';
3
- import '../event-signal.js';
2
+ import { a as PatchesDoc } from '../BaseDoc-BRIP2YZp.js';
3
+ import 'easy-signal';
4
4
  import '../json-patch/types.js';
5
5
  import '../types.js';
6
6
  import '../json-patch/JSONPatch.js';
@@ -1,4 +1,4 @@
1
- import { SyncedDoc } from '../types.js';
1
+ import { DocSyncStatus } from '../types.js';
2
2
  import '../json-patch/JSONPatch.js';
3
3
  import '@dabble/delta';
4
4
  import '../json-patch/types.js';
@@ -7,7 +7,7 @@ import '../json-patch/types.js';
7
7
  * Returns true if a document has completed its initial load — i.e., it has data
8
8
  * to display (server data, cached data, or local changes) or sync has resolved.
9
9
  */
10
- declare function isDocLoaded(doc: Pick<SyncedDoc, 'committedRev' | 'hasPending' | 'syncStatus'>): boolean;
10
+ declare function isDocLoaded(committedRev: number, hasPending: boolean, syncStatus: DocSyncStatus): boolean;
11
11
  /**
12
12
  * Resolves a path template by replacing `:param` placeholders with values.
13
13
  *
@@ -1,6 +1,6 @@
1
1
  import "../chunk-IZ2YBCUP.js";
2
- function isDocLoaded(doc) {
3
- return doc.committedRev > 0 || doc.hasPending || doc.syncStatus === "synced" || doc.syncStatus === "error";
2
+ function isDocLoaded(committedRev, hasPending, syncStatus) {
3
+ return committedRev > 0 || hasPending || syncStatus === "synced" || syncStatus === "error";
4
4
  }
5
5
  function fillPath(template, params) {
6
6
  return template.replace(/:(\w+)/g, (match, name) => {
@@ -1,13 +1,13 @@
1
1
  import { JSX } from 'solid-js';
2
2
  import { Patches } from '../client/Patches.js';
3
3
  import { PatchesSync } from '../net/PatchesSync.js';
4
- import '../event-signal.js';
4
+ import 'easy-signal';
5
5
  import '../json-patch/types.js';
6
6
  import '../types.js';
7
7
  import '../json-patch/JSONPatch.js';
8
8
  import '@dabble/delta';
9
9
  import '../client/ClientAlgorithm.js';
10
- import '../BaseDoc-vaMreJL5.js';
10
+ import '../BaseDoc-BRIP2YZp.js';
11
11
  import '../client/PatchesStore.js';
12
12
  import '../net/protocol/types.js';
13
13
  import '../net/protocol/JSONRPCClient.js';
@@ -1,10 +1,10 @@
1
1
  export { DocManager, getDocManager } from '../shared/doc-manager.js';
2
2
  import '../client/Patches.js';
3
- import '../event-signal.js';
3
+ import 'easy-signal';
4
4
  import '../json-patch/types.js';
5
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-vaMreJL5.js';
9
+ import '../BaseDoc-BRIP2YZp.js';
10
10
  import '../client/PatchesStore.js';
@@ -5,13 +5,13 @@ export { fillPath } from '../shared/utils.js';
5
5
  export { DocManager, getDocManager } from '../shared/doc-manager.js';
6
6
  import 'solid-js';
7
7
  import '../client/Patches.js';
8
- import '../event-signal.js';
8
+ import 'easy-signal';
9
9
  import '../json-patch/types.js';
10
10
  import '../types.js';
11
11
  import '../json-patch/JSONPatch.js';
12
12
  import '@dabble/delta';
13
13
  import '../client/ClientAlgorithm.js';
14
- import '../BaseDoc-vaMreJL5.js';
14
+ import '../BaseDoc-BRIP2YZp.js';
15
15
  import '../client/PatchesStore.js';
16
16
  import '../net/PatchesSync.js';
17
17
  import '../net/protocol/types.js';
@@ -51,7 +51,7 @@ function createManagedDocs(paths, initialData, reducer, options) {
51
51
  }
52
52
  setData((prev) => reducer(prev, path, newState));
53
53
  }
54
- })
54
+ }, false)
55
55
  );
56
56
  } catch (error) {
57
57
  console.error(`Failed to open doc at path: ${path}`, error);
@@ -1,9 +1,9 @@
1
1
  import { Accessor } from 'solid-js';
2
2
  import { OpenDocOptions } from '../client/Patches.js';
3
- import { a as PatchesDoc } from '../BaseDoc-vaMreJL5.js';
3
+ import { a as PatchesDoc } from '../BaseDoc-BRIP2YZp.js';
4
4
  import { JSONPatch } from '../json-patch/JSONPatch.js';
5
5
  import { ChangeMutator } from '../types.js';
6
- import '../event-signal.js';
6
+ import 'easy-signal';
7
7
  import '../json-patch/types.js';
8
8
  import '../client/ClientAlgorithm.js';
9
9
  import '../client/PatchesStore.js';
@@ -23,10 +23,10 @@ function createDocReactiveState(options) {
23
23
  let loaded = false;
24
24
  function updateLoading() {
25
25
  if (loaded) return;
26
- if (patchesDoc.isLoaded) {
26
+ if (patchesDoc.isLoaded.state) {
27
27
  loaded = true;
28
28
  setLoading(false);
29
- } else if (patchesDoc.syncStatus === "syncing") {
29
+ } else if (patchesDoc.syncStatus.state === "syncing") {
30
30
  setLoading(true);
31
31
  } else if (!hasSyncContext) {
32
32
  loaded = true;
@@ -42,10 +42,10 @@ function createDocReactiveState(options) {
42
42
  setHasPending(patchesDoc.hasPending);
43
43
  updateLoading();
44
44
  });
45
- const unsubSync = patchesDoc.onSyncStatus((status) => {
45
+ const unsubSync = patchesDoc.syncStatus.subscribe((status) => {
46
46
  updateLoading();
47
- setError(status === "error" ? patchesDoc.syncError : void 0);
48
- });
47
+ setError(status === "error" ? patchesDoc.syncError.state : void 0);
48
+ }, false);
49
49
  return () => {
50
50
  unsubState();
51
51
  unsubSync();
@@ -218,11 +218,11 @@ function usePatchesSync() {
218
218
  const [connected, setConnected] = createSignal(sync.state.connected);
219
219
  const [syncing, setSyncing] = createSignal(sync.state.syncStatus === "syncing");
220
220
  const [online, setOnline] = createSignal(sync.state.online);
221
- const unsubscribe = sync.onStateChange((state) => {
221
+ const unsubscribe = sync.subscribe((state) => {
222
222
  setConnected(state.connected);
223
223
  setSyncing(state.syncStatus === "syncing");
224
224
  setOnline(state.online);
225
- });
225
+ }, false);
226
226
  onCleanup(() => {
227
227
  unsubscribe();
228
228
  });
package/dist/types.d.ts CHANGED
@@ -57,7 +57,7 @@ interface PatchesSnapshot<T = any> extends PatchesState<T> {
57
57
  changes: Change[];
58
58
  }
59
59
  /**
60
- * Sync status for a document, used by both PatchesDoc and PatchesSync's SyncedDoc.
60
+ * Sync status for a document, used by both PatchesDoc and DocSyncState.
61
61
  * - `'unsynced'` — not yet synced (initial state, or disconnected)
62
62
  * - `'syncing'` — actively syncing with the server
63
63
  * - `'synced'` — up to date with the server
@@ -65,7 +65,7 @@ interface PatchesSnapshot<T = any> extends PatchesState<T> {
65
65
  */
66
66
  type DocSyncStatus = 'unsynced' | 'syncing' | 'synced' | 'error';
67
67
  /**
68
- * Represents the synced state of a document.
68
+ * Plain snapshot of a document's sync state, used by PatchesSync to track per-document status.
69
69
  * @property committedRev - The last committed revision number from the server.
70
70
  * @property hasPending - Whether there are local changes that haven't been committed yet.
71
71
  * @property syncStatus - The current sync status of the document.
@@ -74,7 +74,7 @@ type DocSyncStatus = 'unsynced' | 'syncing' | 'synced' | 'error';
74
74
  * within a sync lifecycle. A document is considered loaded when it has data to display (server data, cached data,
75
75
  * or local changes) or sync has resolved (successfully or with error).
76
76
  */
77
- interface SyncedDoc {
77
+ interface DocSyncState {
78
78
  committedRev: number;
79
79
  hasPending: boolean;
80
80
  syncStatus: DocSyncStatus;
@@ -237,4 +237,4 @@ type PathProxy<T = any> = IsAny<T> extends true ? DeepPathProxy : {
237
237
  */
238
238
  type ChangeMutator<T> = (patch: JSONPatch, root: PathProxy<T>) => void;
239
239
 
240
- export type { Branch, BranchStatus, Change, ChangeInput, ChangeMutator, CommitChangesOptions, DeleteDocOptions, DocSyncStatus, DocumentTombstone, EditableBranchMetadata, EditableVersionMetadata, ListChangesOptions, ListVersionsOptions, PatchesSnapshot, PatchesState, PathProxy, SyncedDoc, VersionMetadata };
240
+ export type { Branch, BranchStatus, Change, ChangeInput, ChangeMutator, CommitChangesOptions, DeleteDocOptions, DocSyncState, DocSyncStatus, DocumentTombstone, EditableBranchMetadata, EditableVersionMetadata, ListChangesOptions, ListVersionsOptions, PatchesSnapshot, PatchesState, PathProxy, VersionMetadata };
@@ -1,9 +1,9 @@
1
1
  import { ShallowRef, Ref, MaybeRef } from 'vue';
2
2
  import { OpenDocOptions } from '../client/Patches.js';
3
- import { a as PatchesDoc } from '../BaseDoc-vaMreJL5.js';
3
+ import { a as PatchesDoc } from '../BaseDoc-BRIP2YZp.js';
4
4
  import { JSONPatch } from '../json-patch/JSONPatch.js';
5
5
  import { ChangeMutator } from '../types.js';
6
- import '../event-signal.js';
6
+ import 'easy-signal';
7
7
  import '../json-patch/types.js';
8
8
  import '../client/ClientAlgorithm.js';
9
9
  import '../client/PatchesStore.js';
@@ -24,10 +24,10 @@ function createDocReactiveState(options) {
24
24
  let loaded = false;
25
25
  function updateLoading() {
26
26
  if (loaded) return;
27
- if (patchesDoc.isLoaded) {
27
+ if (patchesDoc.isLoaded.state) {
28
28
  loaded = true;
29
29
  loading.value = false;
30
- } else if (patchesDoc.syncStatus === "syncing") {
30
+ } else if (patchesDoc.syncStatus.state === "syncing") {
31
31
  loading.value = true;
32
32
  } else if (!hasSyncContext) {
33
33
  loaded = true;
@@ -43,10 +43,10 @@ function createDocReactiveState(options) {
43
43
  hasPending.value = patchesDoc.hasPending;
44
44
  updateLoading();
45
45
  });
46
- const unsubSync = patchesDoc.onSyncStatus((status) => {
46
+ const unsubSync = patchesDoc.syncStatus.subscribe((status) => {
47
47
  updateLoading();
48
- error.value = status === "error" ? patchesDoc.syncError : void 0;
49
- });
48
+ error.value = status === "error" ? patchesDoc.syncError.state : void 0;
49
+ }, false);
50
50
  return () => {
51
51
  unsubState();
52
52
  unsubSync();
@@ -189,11 +189,11 @@ function usePatchesSync() {
189
189
  const connected = ref(sync.state.connected);
190
190
  const syncing = ref(sync.state.syncStatus === "syncing");
191
191
  const online = ref(sync.state.online);
192
- const unsubscribe = sync.onStateChange((state) => {
192
+ const unsubscribe = sync.subscribe((state) => {
193
193
  connected.value = state.connected;
194
194
  syncing.value = state.syncStatus === "syncing";
195
195
  online.value = state.online;
196
- });
196
+ }, false);
197
197
  onBeforeUnmount(() => {
198
198
  unsubscribe();
199
199
  });
@@ -1,10 +1,10 @@
1
1
  export { DocManager, getDocManager } from '../shared/doc-manager.js';
2
2
  import '../client/Patches.js';
3
- import '../event-signal.js';
3
+ import 'easy-signal';
4
4
  import '../json-patch/types.js';
5
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-vaMreJL5.js';
9
+ import '../BaseDoc-BRIP2YZp.js';
10
10
  import '../client/PatchesStore.js';
@@ -5,13 +5,13 @@ export { fillPath } from '../shared/utils.js';
5
5
  export { DocManager, getDocManager } from '../shared/doc-manager.js';
6
6
  import 'vue';
7
7
  import '../client/Patches.js';
8
- import '../event-signal.js';
8
+ import 'easy-signal';
9
9
  import '../json-patch/types.js';
10
10
  import '../types.js';
11
11
  import '../json-patch/JSONPatch.js';
12
12
  import '@dabble/delta';
13
13
  import '../client/ClientAlgorithm.js';
14
- import '../BaseDoc-vaMreJL5.js';
14
+ import '../BaseDoc-BRIP2YZp.js';
15
15
  import '../client/PatchesStore.js';
16
16
  import '../net/PatchesSync.js';
17
17
  import '../net/protocol/types.js';
@@ -1,12 +1,12 @@
1
1
  import { Ref, ShallowRef } from 'vue';
2
2
  import { OpenDocOptions } from '../client/Patches.js';
3
- import '../event-signal.js';
3
+ import 'easy-signal';
4
4
  import '../json-patch/types.js';
5
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-vaMreJL5.js';
9
+ import '../BaseDoc-BRIP2YZp.js';
10
10
  import '../client/PatchesStore.js';
11
11
 
12
12
  /**
@@ -46,7 +46,7 @@ function useManagedDocs(pathsRef, initialData, reducer, options) {
46
46
  }
47
47
  data.value = reducer(data.value, path, newState);
48
48
  }
49
- })
49
+ }, false)
50
50
  );
51
51
  } else {
52
52
  await patches.closeDoc(path);
@@ -1,13 +1,13 @@
1
1
  import { InjectionKey, App } from 'vue';
2
2
  import { Patches } from '../client/Patches.js';
3
3
  import { PatchesSync } from '../net/PatchesSync.js';
4
- import '../event-signal.js';
4
+ import 'easy-signal';
5
5
  import '../json-patch/types.js';
6
6
  import '../types.js';
7
7
  import '../json-patch/JSONPatch.js';
8
8
  import '@dabble/delta';
9
9
  import '../client/ClientAlgorithm.js';
10
- import '../BaseDoc-vaMreJL5.js';
10
+ import '../BaseDoc-BRIP2YZp.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.14",
3
+ "version": "0.7.16",
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": {
@@ -78,6 +78,7 @@
78
78
  "@dabble/delta": "^1.2.4",
79
79
  "alphacounter": "^2.1.1",
80
80
  "crypto-id": "^0.3.1",
81
+ "easy-signal": "^5.0.2",
81
82
  "simple-peer": "^9.11.1",
82
83
  "simplified-concurrency": "^0.2.0"
83
84
  },
@@ -1,32 +0,0 @@
1
- type SignalSubscriber = (...args: any[]) => any;
2
- type ErrorSubscriber = (error: Error) => any;
3
- type Unsubscriber = () => void;
4
- type Args<T> = T extends (...args: infer A) => any ? A : never;
5
- type Signal<T extends SignalSubscriber = SignalSubscriber> = {
6
- (subscriber: T): Unsubscriber;
7
- error: (errorListener: ErrorSubscriber) => Unsubscriber;
8
- emit: (...args: Args<T>) => Promise<void>;
9
- clear: () => void;
10
- };
11
- /**
12
- * Creates a signal, a function that can be used to subscribe to events. The signal can be called with a subscriber
13
- * function to register event listeners. It has methods for emitting events, handling errors, and managing subscriptions.
14
- *
15
- * @example
16
- * const onLoad = signal<(data: MyData) => void>();
17
- *
18
- * // Subscribe to data
19
- * onLoad((data) => console.log('loaded', data));
20
- *
21
- * // Subscribe to errors
22
- * onLoad.error((error) => console.error('error', error));
23
- *
24
- * // Emit data to subscribers
25
- * await onLoad.emit('data'); // logs 'loaded data'
26
- *
27
- * // Clear all subscribers
28
- * onLoad.clear();
29
- */
30
- declare function signal<T extends SignalSubscriber = SignalSubscriber>(): Signal<T>;
31
-
32
- export { type ErrorSubscriber, type Signal, type SignalSubscriber, type Unsubscriber, signal };
@@ -1,25 +0,0 @@
1
- import "./chunk-IZ2YBCUP.js";
2
- function signal() {
3
- const subscribers = /* @__PURE__ */ new Set();
4
- const errorListeners = /* @__PURE__ */ new Set();
5
- function signal2(subscriber) {
6
- subscribers.add(subscriber);
7
- return () => subscribers.delete(subscriber);
8
- }
9
- signal2.emit = async (...args) => {
10
- const listeners = args[0] instanceof Error ? errorListeners : subscribers;
11
- await Promise.all(Array.from(listeners).map((listener) => listener(...args)));
12
- };
13
- signal2.error = (errorListener) => {
14
- errorListeners.add(errorListener);
15
- return () => errorListeners.delete(errorListener);
16
- };
17
- signal2.clear = () => {
18
- subscribers.clear();
19
- errorListeners.clear();
20
- };
21
- return signal2;
22
- }
23
- export {
24
- signal
25
- };