@dabble/patches 0.3.2 → 0.4.0
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/dist/algorithms/client/makeChange.d.ts +2 -3
- package/dist/algorithms/client/makeChange.js +1 -1
- package/dist/algorithms/server/getSnapshotAtRevision.d.ts +1 -1
- package/dist/algorithms/server/getStateAtRevision.d.ts +1 -1
- package/dist/algorithms/server/handleOfflineSessionsAndBatches.d.ts +1 -1
- package/dist/client/InMemoryStore.js +1 -3
- package/dist/client/IndexedDBStore.js +345 -342
- package/dist/client/Patches.js +156 -156
- package/dist/client/PatchesDoc.d.ts +4 -5
- package/dist/client/PatchesDoc.js +16 -13
- package/dist/client/PatchesHistoryClient.js +12 -8
- package/dist/json-patch/JSONPatch.js +2 -0
- package/dist/json-patch/createJSONPatch.d.ts +15 -18
- package/dist/json-patch/createJSONPatch.js +18 -20
- package/dist/json-patch/patchProxy.d.ts +16 -36
- package/dist/json-patch/patchProxy.js +30 -106
- package/dist/json-patch/utils/getType.d.ts +1 -1
- package/dist/net/PatchesSync.js +307 -303
- package/dist/net/error.js +1 -0
- package/dist/net/protocol/JSONRPCClient.js +4 -3
- package/dist/net/protocol/JSONRPCServer.js +6 -8
- package/dist/net/webrtc/WebRTCAwareness.js +12 -7
- package/dist/net/webrtc/WebRTCTransport.d.ts +1 -1
- package/dist/net/webrtc/WebRTCTransport.js +27 -21
- package/dist/net/websocket/PatchesWebSocket.js +7 -2
- package/dist/net/websocket/RPCServer.js +5 -0
- package/dist/net/websocket/SignalingService.js +1 -3
- package/dist/net/websocket/WebSocketServer.js +2 -0
- package/dist/net/websocket/WebSocketTransport.js +21 -19
- package/dist/net/websocket/onlineState.js +2 -2
- package/dist/server/PatchesBranchManager.js +2 -0
- package/dist/server/PatchesHistoryManager.js +2 -0
- package/dist/server/PatchesServer.d.ts +2 -2
- package/dist/server/PatchesServer.js +7 -5
- package/dist/types.d.ts +12 -7
- package/package.json +3 -2
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export declare function makeChange<T = any>(snapshot: PatchesSnapshot<T>, mutator: (draft: DeepRequired<T>, patch: JSONPatch) => void, changeMetadata?: Record<string, any>, maxPayloadBytes?: number): Change[];
|
|
1
|
+
import type { Change, ChangeMutator, PatchesSnapshot } from '../../types.js';
|
|
2
|
+
export declare function makeChange<T = any>(snapshot: PatchesSnapshot<T>, mutator: ChangeMutator<T>, changeMetadata?: Record<string, any>, maxPayloadBytes?: number): Change[];
|
|
@@ -6,7 +6,7 @@ export function makeChange(snapshot, mutator, changeMetadata, maxPayloadBytes) {
|
|
|
6
6
|
const pendingChanges = snapshot.changes;
|
|
7
7
|
const pendingRev = pendingChanges[pendingChanges.length - 1]?.rev ?? snapshot.rev;
|
|
8
8
|
const state = createStateFromSnapshot(snapshot); // Current state including pending
|
|
9
|
-
const patch = createJSONPatch(
|
|
9
|
+
const patch = createJSONPatch(mutator);
|
|
10
10
|
if (patch.ops.length === 0) {
|
|
11
11
|
return [];
|
|
12
12
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PatchesStoreBackend } from '../../server.js';
|
|
1
|
+
import type { PatchesStoreBackend } from '../../server/types.js';
|
|
2
2
|
import type { PatchesSnapshot } from '../../types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Retrieves the document state of the version before the given revision and changes after up to that revision or all
|
|
@@ -6,9 +6,7 @@ import { transformPatch } from '../json-patch/transformPatch.js';
|
|
|
6
6
|
* Useful for unit tests or when you want the old 'stateless realtime' behaviour.
|
|
7
7
|
*/
|
|
8
8
|
export class InMemoryStore {
|
|
9
|
-
|
|
10
|
-
this.docs = new Map();
|
|
11
|
-
}
|
|
9
|
+
docs = new Map();
|
|
12
10
|
// ─── Reconstruction ────────────────────────────────────────────────────
|
|
13
11
|
async getDoc(docId) {
|
|
14
12
|
const buf = this.docs.get(docId);
|