@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.
- package/README.md +4 -4
- package/dist/{BaseDoc-vaMreJL5.d.ts → BaseDoc-BRIP2YZp.d.ts} +16 -35
- package/dist/algorithms/ot/server/commitChanges.d.ts +1 -1
- package/dist/client/BaseDoc.d.ts +2 -2
- package/dist/client/BaseDoc.js +13 -38
- package/dist/client/ClientAlgorithm.d.ts +2 -2
- package/dist/client/IndexedDBStore.d.ts +2 -2
- package/dist/client/IndexedDBStore.js +3 -8
- package/dist/client/LWWAlgorithm.d.ts +2 -2
- package/dist/client/LWWDoc.d.ts +3 -3
- package/dist/client/LWWDoc.js +10 -7
- package/dist/client/LWWIndexedDBStore.d.ts +1 -1
- package/dist/client/LWWIndexedDBStore.js +4 -4
- package/dist/client/OTAlgorithm.d.ts +2 -2
- package/dist/client/OTDoc.d.ts +2 -2
- package/dist/client/OTDoc.js +7 -8
- package/dist/client/OTIndexedDBStore.d.ts +1 -1
- package/dist/client/OTIndexedDBStore.js +3 -3
- package/dist/client/Patches.d.ts +9 -8
- package/dist/client/Patches.js +9 -6
- package/dist/client/PatchesDoc.d.ts +2 -2
- package/dist/client/PatchesHistoryClient.d.ts +5 -11
- package/dist/client/PatchesHistoryClient.js +14 -29
- package/dist/client/factories.d.ts +2 -2
- package/dist/client/index.d.ts +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +23 -2
- package/dist/net/PatchesClient.d.ts +3 -3
- package/dist/net/PatchesClient.js +1 -1
- package/dist/net/PatchesSync.d.ts +14 -29
- package/dist/net/PatchesSync.js +84 -98
- package/dist/net/http/FetchTransport.d.ts +2 -2
- package/dist/net/http/FetchTransport.js +1 -1
- package/dist/net/index.d.ts +2 -2
- package/dist/net/protocol/JSONRPCClient.d.ts +1 -1
- package/dist/net/protocol/JSONRPCClient.js +1 -1
- package/dist/net/protocol/JSONRPCServer.d.ts +1 -1
- package/dist/net/protocol/JSONRPCServer.js +1 -1
- package/dist/net/protocol/types.d.ts +1 -1
- package/dist/net/protocol/utils.d.ts +1 -1
- package/dist/net/webrtc/WebRTCAwareness.d.ts +2 -2
- package/dist/net/webrtc/WebRTCAwareness.js +1 -1
- package/dist/net/webrtc/WebRTCTransport.d.ts +5 -5
- package/dist/net/webrtc/WebRTCTransport.js +1 -1
- package/dist/net/webrtc/index.d.ts +1 -1
- package/dist/net/websocket/PatchesWebSocket.d.ts +1 -1
- package/dist/net/websocket/PatchesWebSocket.js +1 -1
- package/dist/net/websocket/SignalingService.d.ts +1 -1
- package/dist/net/websocket/WebSocketServer.d.ts +1 -1
- package/dist/net/websocket/WebSocketTransport.d.ts +4 -3
- package/dist/net/websocket/WebSocketTransport.js +1 -1
- package/dist/net/websocket/onlineState.d.ts +2 -2
- package/dist/net/websocket/onlineState.js +1 -1
- package/dist/server/LWWBranchManager.d.ts +1 -1
- package/dist/server/LWWServer.d.ts +3 -3
- package/dist/server/LWWServer.js +1 -1
- package/dist/server/OTBranchManager.d.ts +1 -1
- package/dist/server/OTServer.d.ts +3 -3
- package/dist/server/OTServer.js +1 -1
- package/dist/server/PatchesHistoryManager.d.ts +1 -1
- package/dist/server/PatchesServer.d.ts +1 -1
- package/dist/server/branchUtils.d.ts +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/shared/doc-manager.d.ts +2 -2
- package/dist/shared/utils.d.ts +2 -2
- package/dist/shared/utils.js +2 -2
- package/dist/solid/context.d.ts +2 -2
- package/dist/solid/doc-manager.d.ts +2 -2
- package/dist/solid/index.d.ts +2 -2
- package/dist/solid/managed-docs.js +1 -1
- package/dist/solid/primitives.d.ts +2 -2
- package/dist/solid/primitives.js +7 -7
- package/dist/types.d.ts +4 -4
- package/dist/vue/composables.d.ts +2 -2
- package/dist/vue/composables.js +7 -7
- package/dist/vue/doc-manager.d.ts +2 -2
- package/dist/vue/index.d.ts +2 -2
- package/dist/vue/managed-docs.d.ts +2 -2
- package/dist/vue/managed-docs.js +1 -1
- package/dist/vue/provider.d.ts +2 -2
- package/package.json +2 -1
- package/dist/event-signal.d.ts +0 -32
- package/dist/event-signal.js +0 -25
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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.
|
package/dist/server/LWWServer.js
CHANGED
|
@@ -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 "
|
|
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 '
|
|
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
|
|
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.
|
package/dist/server/OTServer.js
CHANGED
|
@@ -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 "
|
|
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 '
|
|
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 '
|
|
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 '
|
|
3
|
+
import 'easy-signal';
|
|
4
4
|
import '../net/websocket/AuthorizationProvider.js';
|
|
5
5
|
import './types.js';
|
|
6
6
|
import '../json-patch/types.js';
|
package/dist/server/index.d.ts
CHANGED
|
@@ -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 '
|
|
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-
|
|
3
|
-
import '
|
|
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';
|
package/dist/shared/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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(
|
|
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
|
*
|
package/dist/shared/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../chunk-IZ2YBCUP.js";
|
|
2
|
-
function isDocLoaded(
|
|
3
|
-
return
|
|
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) => {
|
package/dist/solid/context.d.ts
CHANGED
|
@@ -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 '
|
|
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-
|
|
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 '
|
|
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-
|
|
9
|
+
import '../BaseDoc-BRIP2YZp.js';
|
|
10
10
|
import '../client/PatchesStore.js';
|
package/dist/solid/index.d.ts
CHANGED
|
@@ -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 '
|
|
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-
|
|
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,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-
|
|
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 '
|
|
6
|
+
import 'easy-signal';
|
|
7
7
|
import '../json-patch/types.js';
|
|
8
8
|
import '../client/ClientAlgorithm.js';
|
|
9
9
|
import '../client/PatchesStore.js';
|
package/dist/solid/primitives.js
CHANGED
|
@@ -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.
|
|
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.
|
|
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
|
|
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
|
-
*
|
|
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
|
|
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,
|
|
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-
|
|
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 '
|
|
6
|
+
import 'easy-signal';
|
|
7
7
|
import '../json-patch/types.js';
|
|
8
8
|
import '../client/ClientAlgorithm.js';
|
|
9
9
|
import '../client/PatchesStore.js';
|
package/dist/vue/composables.js
CHANGED
|
@@ -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.
|
|
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.
|
|
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 '
|
|
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-
|
|
9
|
+
import '../BaseDoc-BRIP2YZp.js';
|
|
10
10
|
import '../client/PatchesStore.js';
|
package/dist/vue/index.d.ts
CHANGED
|
@@ -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 '
|
|
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-
|
|
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 '
|
|
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-
|
|
9
|
+
import '../BaseDoc-BRIP2YZp.js';
|
|
10
10
|
import '../client/PatchesStore.js';
|
|
11
11
|
|
|
12
12
|
/**
|
package/dist/vue/managed-docs.js
CHANGED
package/dist/vue/provider.d.ts
CHANGED
|
@@ -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 '
|
|
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-
|
|
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.
|
|
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
|
},
|
package/dist/event-signal.d.ts
DELETED
|
@@ -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 };
|
package/dist/event-signal.js
DELETED
|
@@ -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
|
-
};
|