@dxos/echo-pipeline 0.8.4-main.e098934 → 0.8.4-main.ead640a
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/lib/browser/{chunk-KQYT6ADL.mjs → chunk-WJJXJTNS.mjs} +11 -3
- package/dist/lib/browser/chunk-WJJXJTNS.mjs.map +7 -0
- package/dist/lib/browser/{chunk-I4JBIZSN.mjs → chunk-XGG76KKU.mjs} +3 -3
- package/dist/lib/browser/{chunk-I4JBIZSN.mjs.map → chunk-XGG76KKU.mjs.map} +1 -1
- package/dist/lib/browser/filter/index.mjs +1 -1
- package/dist/lib/browser/index.mjs +265 -145
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +3 -3
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/{chunk-YOL7JY5W.mjs → chunk-CHMJJ4DG.mjs} +3 -3
- package/dist/lib/node-esm/{chunk-YOL7JY5W.mjs.map → chunk-CHMJJ4DG.mjs.map} +1 -1
- package/dist/lib/node-esm/{chunk-W4ACY3YC.mjs → chunk-LEQ77KAT.mjs} +11 -3
- package/dist/lib/node-esm/chunk-LEQ77KAT.mjs.map +7 -0
- package/dist/lib/node-esm/filter/index.mjs +1 -1
- package/dist/lib/node-esm/index.mjs +265 -145
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +3 -3
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
- package/dist/types/src/automerge/collection-synchronizer.d.ts +2 -1
- package/dist/types/src/automerge/collection-synchronizer.d.ts.map +1 -1
- package/dist/types/src/edge/echo-edge-replicator.d.ts.map +1 -1
- package/dist/types/src/filter/filter-match.d.ts +2 -2
- package/dist/types/src/filter/filter-match.d.ts.map +1 -1
- package/dist/types/src/query/errors.d.ts +4 -4
- package/dist/types/src/query/query-executor.d.ts +4 -0
- package/dist/types/src/query/query-executor.d.ts.map +1 -1
- package/dist/types/src/query/query-planner.d.ts.map +1 -1
- package/dist/types/src/testing/test-data.d.ts.map +1 -1
- package/dist/types/src/testing/test-schema.d.ts +1 -1
- package/dist/types/src/testing/test-schema.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +37 -39
- package/src/automerge/automerge-host.ts +34 -21
- package/src/automerge/collection-synchronizer.test.ts +4 -3
- package/src/automerge/collection-synchronizer.ts +13 -9
- package/src/db-host/echo-host.ts +1 -1
- package/src/db-host/query-service.ts +1 -1
- package/src/edge/echo-edge-replicator.ts +30 -9
- package/src/filter/filter-match.test.ts +22 -22
- package/src/filter/filter-match.ts +19 -10
- package/src/query/query-executor.ts +48 -3
- package/src/query/query-planner.ts +29 -3
- package/src/testing/test-data.ts +1 -1
- package/src/testing/test-schema.ts +1 -1
- package/dist/lib/browser/chunk-KQYT6ADL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-W4ACY3YC.mjs.map +0 -7
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
filterMatchObject,
|
|
4
4
|
filterMatchObjectJSON,
|
|
5
5
|
filterMatchValue
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-WJJXJTNS.mjs";
|
|
7
7
|
import {
|
|
8
8
|
AuthExtension,
|
|
9
9
|
AuthStatus,
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
mapTimeframeToFeedIndexes,
|
|
27
27
|
startAfter,
|
|
28
28
|
valueEncoding
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-XGG76KKU.mjs";
|
|
30
30
|
import "./chunk-CGS2ULMK.mjs";
|
|
31
31
|
|
|
32
32
|
// src/db-host/data-service.ts
|
|
@@ -39,7 +39,6 @@ import { log as log7 } from "@dxos/log";
|
|
|
39
39
|
// src/automerge/automerge-host.ts
|
|
40
40
|
import { getBackend, getHeads, equals as headsEquals, isAutomerge, save } from "@automerge/automerge";
|
|
41
41
|
import { Repo, interpretAsDocumentId } from "@automerge/automerge-repo";
|
|
42
|
-
import { exportBundle } from "@automerge/automerge-repo-bundles";
|
|
43
42
|
import { DeferredTask, Event as Event2, asyncTimeout } from "@dxos/async";
|
|
44
43
|
import { Context, Resource as Resource3, cancelWithContext } from "@dxos/context";
|
|
45
44
|
import { DatabaseDirectory } from "@dxos/echo-protocol";
|
|
@@ -48,10 +47,12 @@ import { PublicKey } from "@dxos/keys";
|
|
|
48
47
|
import { log as log3 } from "@dxos/log";
|
|
49
48
|
import { objectPointerCodec } from "@dxos/protocols";
|
|
50
49
|
import { trace as trace2 } from "@dxos/tracing";
|
|
51
|
-
import { ComplexSet, bufferToArray, range } from "@dxos/util";
|
|
50
|
+
import { ComplexSet, bufferToArray, isNonNullable as isNonNullable2, range } from "@dxos/util";
|
|
52
51
|
|
|
53
52
|
// src/automerge/collection-synchronizer.ts
|
|
54
|
-
import { next as
|
|
53
|
+
import { next as A } from "@automerge/automerge";
|
|
54
|
+
import * as Array2 from "effect/Array";
|
|
55
|
+
import * as Record from "effect/Record";
|
|
55
56
|
import { Event, asyncReturn, scheduleTask, scheduleTaskInterval } from "@dxos/async";
|
|
56
57
|
import { Resource } from "@dxos/context";
|
|
57
58
|
import { log } from "@dxos/log";
|
|
@@ -105,7 +106,7 @@ var CollectionSynchronizer = class extends Resource {
|
|
|
105
106
|
state
|
|
106
107
|
}, {
|
|
107
108
|
F: __dxlog_file,
|
|
108
|
-
L:
|
|
109
|
+
L: 78,
|
|
109
110
|
S: this,
|
|
110
111
|
C: (f, a) => f(...a)
|
|
111
112
|
});
|
|
@@ -124,7 +125,7 @@ var CollectionSynchronizer = class extends Resource {
|
|
|
124
125
|
collectionId
|
|
125
126
|
}, {
|
|
126
127
|
F: __dxlog_file,
|
|
127
|
-
L:
|
|
128
|
+
L: 92,
|
|
128
129
|
S: this,
|
|
129
130
|
C: (f, a) => f(...a)
|
|
130
131
|
});
|
|
@@ -207,7 +208,7 @@ var CollectionSynchronizer = class extends Resource {
|
|
|
207
208
|
state
|
|
208
209
|
}, {
|
|
209
210
|
F: __dxlog_file,
|
|
210
|
-
L:
|
|
211
|
+
L: 173,
|
|
211
212
|
S: this,
|
|
212
213
|
C: (f, a) => f(...a)
|
|
213
214
|
});
|
|
@@ -272,19 +273,18 @@ CollectionSynchronizer = _ts_decorate([
|
|
|
272
273
|
trace.resource()
|
|
273
274
|
], CollectionSynchronizer);
|
|
274
275
|
var diffCollectionState = (local, remote) => {
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
]);
|
|
276
|
+
const localDocuments = Record.filter(local.documents, (heads) => heads.length > 0);
|
|
277
|
+
const remoteDocuments = Record.filter(remote.documents, (heads) => heads.length > 0);
|
|
278
|
+
const allDocuments = Array2.union(Record.keys(localDocuments), Record.keys(remoteDocuments));
|
|
279
279
|
const missingOnRemote = [];
|
|
280
280
|
const missingOnLocal = [];
|
|
281
281
|
const different = [];
|
|
282
282
|
for (const documentId of allDocuments) {
|
|
283
|
-
if (!
|
|
283
|
+
if (!localDocuments[documentId]) {
|
|
284
284
|
missingOnLocal.push(documentId);
|
|
285
|
-
} else if (!
|
|
285
|
+
} else if (!remoteDocuments[documentId]) {
|
|
286
286
|
missingOnRemote.push(documentId);
|
|
287
|
-
} else if (!
|
|
287
|
+
} else if (!A.equals(local.documents[documentId], remote.documents[documentId])) {
|
|
288
288
|
different.push(documentId);
|
|
289
289
|
}
|
|
290
290
|
}
|
|
@@ -299,7 +299,7 @@ var validateCollectionState = (state) => {
|
|
|
299
299
|
if (!isValidDocumentId(documentId)) {
|
|
300
300
|
throw new Error(`Invalid documentId: ${documentId}`);
|
|
301
301
|
}
|
|
302
|
-
if (
|
|
302
|
+
if (Array2.isArray(heads) && heads.some((head) => typeof head !== "string")) {
|
|
303
303
|
throw new Error(`Invalid heads: ${heads}`);
|
|
304
304
|
}
|
|
305
305
|
});
|
|
@@ -934,7 +934,7 @@ var AutomergeHost = class extends Resource3 {
|
|
|
934
934
|
err
|
|
935
935
|
}, {
|
|
936
936
|
F: __dxlog_file3,
|
|
937
|
-
L:
|
|
937
|
+
L: 223,
|
|
938
938
|
S: this,
|
|
939
939
|
C: (f, a) => f(...a)
|
|
940
940
|
});
|
|
@@ -968,7 +968,7 @@ var AutomergeHost = class extends Resource3 {
|
|
|
968
968
|
async addReplicator(replicator) {
|
|
969
969
|
invariant2(this.isOpen, "AutomergeHost is not open", {
|
|
970
970
|
F: __dxlog_file3,
|
|
971
|
-
L:
|
|
971
|
+
L: 259,
|
|
972
972
|
S: this,
|
|
973
973
|
A: [
|
|
974
974
|
"this.isOpen",
|
|
@@ -980,7 +980,7 @@ var AutomergeHost = class extends Resource3 {
|
|
|
980
980
|
async removeReplicator(replicator) {
|
|
981
981
|
invariant2(this.isOpen, "AutomergeHost is not open", {
|
|
982
982
|
F: __dxlog_file3,
|
|
983
|
-
L:
|
|
983
|
+
L: 264,
|
|
984
984
|
S: this,
|
|
985
985
|
A: [
|
|
986
986
|
"this.isOpen",
|
|
@@ -995,7 +995,7 @@ var AutomergeHost = class extends Resource3 {
|
|
|
995
995
|
async loadDoc(ctx, documentId, opts) {
|
|
996
996
|
invariant2(this.isOpen, "AutomergeHost is not open", {
|
|
997
997
|
F: __dxlog_file3,
|
|
998
|
-
L:
|
|
998
|
+
L: 272,
|
|
999
999
|
S: this,
|
|
1000
1000
|
A: [
|
|
1001
1001
|
"this.isOpen",
|
|
@@ -1021,7 +1021,7 @@ var AutomergeHost = class extends Resource3 {
|
|
|
1021
1021
|
async exportDoc(ctx, id) {
|
|
1022
1022
|
invariant2(this.isOpen, "AutomergeHost is not open", {
|
|
1023
1023
|
F: __dxlog_file3,
|
|
1024
|
-
L:
|
|
1024
|
+
L: 295,
|
|
1025
1025
|
S: this,
|
|
1026
1026
|
A: [
|
|
1027
1027
|
"this.isOpen",
|
|
@@ -1040,7 +1040,7 @@ var AutomergeHost = class extends Resource3 {
|
|
|
1040
1040
|
createDoc(initialValue, opts) {
|
|
1041
1041
|
invariant2(this.isOpen, "AutomergeHost is not open", {
|
|
1042
1042
|
F: __dxlog_file3,
|
|
1043
|
-
L:
|
|
1043
|
+
L: 306,
|
|
1044
1044
|
S: this,
|
|
1045
1045
|
A: [
|
|
1046
1046
|
"this.isOpen",
|
|
@@ -1065,7 +1065,7 @@ var AutomergeHost = class extends Resource3 {
|
|
|
1065
1065
|
async waitUntilHeadsReplicated(heads) {
|
|
1066
1066
|
invariant2(this.isOpen, "AutomergeHost is not open", {
|
|
1067
1067
|
F: __dxlog_file3,
|
|
1068
|
-
L:
|
|
1068
|
+
L: 328,
|
|
1069
1069
|
S: this,
|
|
1070
1070
|
A: [
|
|
1071
1071
|
"this.isOpen",
|
|
@@ -1087,10 +1087,10 @@ var AutomergeHost = class extends Resource3 {
|
|
|
1087
1087
|
return !(currentHeads !== null && headsEquals(currentHeads, targetHeads));
|
|
1088
1088
|
});
|
|
1089
1089
|
if (headsToWait.length > 0) {
|
|
1090
|
-
await Promise.all(headsToWait.map(async (entry
|
|
1090
|
+
await Promise.all(headsToWait.map(async (entry) => {
|
|
1091
1091
|
const handle = await this.loadDoc(Context.default(void 0, {
|
|
1092
1092
|
F: __dxlog_file3,
|
|
1093
|
-
L:
|
|
1093
|
+
L: 346
|
|
1094
1094
|
}), entry.documentId);
|
|
1095
1095
|
await waitForHeads(handle, entry.heads);
|
|
1096
1096
|
}));
|
|
@@ -1100,7 +1100,7 @@ var AutomergeHost = class extends Resource3 {
|
|
|
1100
1100
|
async reIndexHeads(documentIds) {
|
|
1101
1101
|
invariant2(this.isOpen, "AutomergeHost is not open", {
|
|
1102
1102
|
F: __dxlog_file3,
|
|
1103
|
-
L:
|
|
1103
|
+
L: 359,
|
|
1104
1104
|
S: this,
|
|
1105
1105
|
A: [
|
|
1106
1106
|
"this.isOpen",
|
|
@@ -1112,7 +1112,7 @@ var AutomergeHost = class extends Resource3 {
|
|
|
1112
1112
|
documentId
|
|
1113
1113
|
}, {
|
|
1114
1114
|
F: __dxlog_file3,
|
|
1115
|
-
L:
|
|
1115
|
+
L: 361,
|
|
1116
1116
|
S: this,
|
|
1117
1117
|
C: (f, a) => f(...a)
|
|
1118
1118
|
});
|
|
@@ -1122,7 +1122,7 @@ var AutomergeHost = class extends Resource3 {
|
|
|
1122
1122
|
documentId
|
|
1123
1123
|
}, {
|
|
1124
1124
|
F: __dxlog_file3,
|
|
1125
|
-
L:
|
|
1125
|
+
L: 364,
|
|
1126
1126
|
S: this,
|
|
1127
1127
|
C: (f, a) => f(...a)
|
|
1128
1128
|
});
|
|
@@ -1135,7 +1135,7 @@ var AutomergeHost = class extends Resource3 {
|
|
|
1135
1135
|
}
|
|
1136
1136
|
log3("done re-indexing heads", void 0, {
|
|
1137
1137
|
F: __dxlog_file3,
|
|
1138
|
-
L:
|
|
1138
|
+
L: 373,
|
|
1139
1139
|
S: this,
|
|
1140
1140
|
C: (f, a) => f(...a)
|
|
1141
1141
|
});
|
|
@@ -1145,9 +1145,6 @@ var AutomergeHost = class extends Resource3 {
|
|
|
1145
1145
|
// NOTE: If both peers return sharePolicy=false the replication will not happen
|
|
1146
1146
|
// https://github.com/automerge/automerge-repo/pull/292
|
|
1147
1147
|
async _sharePolicy(peerId, documentId) {
|
|
1148
|
-
if (peerId.startsWith("client-")) {
|
|
1149
|
-
return false;
|
|
1150
|
-
}
|
|
1151
1148
|
if (!documentId) {
|
|
1152
1149
|
return false;
|
|
1153
1150
|
}
|
|
@@ -1213,7 +1210,7 @@ var AutomergeHost = class extends Resource3 {
|
|
|
1213
1210
|
this._headsUpdates.set(documentId, heads);
|
|
1214
1211
|
invariant2(this._onHeadsChangedTask, "onHeadsChangedTask is not initialized", {
|
|
1215
1212
|
F: __dxlog_file3,
|
|
1216
|
-
L:
|
|
1213
|
+
L: 445,
|
|
1217
1214
|
S: this,
|
|
1218
1215
|
A: [
|
|
1219
1216
|
"this._onHeadsChangedTask",
|
|
@@ -1257,11 +1254,12 @@ var AutomergeHost = class extends Resource3 {
|
|
|
1257
1254
|
* Flush documents to disk.
|
|
1258
1255
|
*/
|
|
1259
1256
|
async flush({ documentIds } = {}) {
|
|
1260
|
-
const loadedDocuments = documentIds
|
|
1257
|
+
const loadedDocuments = (documentIds ?? Object.keys(this._repo.handles)).filter((documentId) => {
|
|
1261
1258
|
const handle = this._repo.handles[documentId];
|
|
1262
1259
|
return handle && handle.isReady();
|
|
1263
1260
|
});
|
|
1264
1261
|
await this._repo.flush(loadedDocuments);
|
|
1262
|
+
await this._onHeadsChangedTask?.runBlocking();
|
|
1265
1263
|
}
|
|
1266
1264
|
async getHeads(documentIds) {
|
|
1267
1265
|
const result = [];
|
|
@@ -1396,7 +1394,7 @@ var AutomergeHost = class extends Resource3 {
|
|
|
1396
1394
|
amount: missingOnRemote.length
|
|
1397
1395
|
}, {
|
|
1398
1396
|
F: __dxlog_file3,
|
|
1399
|
-
L:
|
|
1397
|
+
L: 650,
|
|
1400
1398
|
S: this,
|
|
1401
1399
|
C: (f, a) => f(...a)
|
|
1402
1400
|
});
|
|
@@ -1409,7 +1407,7 @@ var AutomergeHost = class extends Resource3 {
|
|
|
1409
1407
|
amount: missingOnRemote.length
|
|
1410
1408
|
}, {
|
|
1411
1409
|
F: __dxlog_file3,
|
|
1412
|
-
L:
|
|
1410
|
+
L: 654,
|
|
1413
1411
|
S: this,
|
|
1414
1412
|
C: (f, a) => f(...a)
|
|
1415
1413
|
});
|
|
@@ -1420,7 +1418,7 @@ var AutomergeHost = class extends Resource3 {
|
|
|
1420
1418
|
amount: missingOnLocal.length
|
|
1421
1419
|
}, {
|
|
1422
1420
|
F: __dxlog_file3,
|
|
1423
|
-
L:
|
|
1421
|
+
L: 662,
|
|
1424
1422
|
S: this,
|
|
1425
1423
|
C: (f, a) => f(...a)
|
|
1426
1424
|
});
|
|
@@ -1433,7 +1431,7 @@ var AutomergeHost = class extends Resource3 {
|
|
|
1433
1431
|
amount: missingOnLocal.length
|
|
1434
1432
|
}, {
|
|
1435
1433
|
F: __dxlog_file3,
|
|
1436
|
-
L:
|
|
1434
|
+
L: 666,
|
|
1437
1435
|
S: this,
|
|
1438
1436
|
C: (f, a) => f(...a)
|
|
1439
1437
|
});
|
|
@@ -1449,7 +1447,7 @@ var AutomergeHost = class extends Resource3 {
|
|
|
1449
1447
|
count: toReplicateWithoutBatching.length
|
|
1450
1448
|
}, {
|
|
1451
1449
|
F: __dxlog_file3,
|
|
1452
|
-
L:
|
|
1450
|
+
L: 678,
|
|
1453
1451
|
S: this,
|
|
1454
1452
|
C: (f, a) => f(...a)
|
|
1455
1453
|
});
|
|
@@ -1477,7 +1475,7 @@ var AutomergeHost = class extends Resource3 {
|
|
|
1477
1475
|
err
|
|
1478
1476
|
}, {
|
|
1479
1477
|
F: __dxlog_file3,
|
|
1480
|
-
L:
|
|
1478
|
+
L: 709,
|
|
1481
1479
|
S: this,
|
|
1482
1480
|
C: (f, a) => f(...a)
|
|
1483
1481
|
});
|
|
@@ -1493,13 +1491,38 @@ var AutomergeHost = class extends Resource3 {
|
|
|
1493
1491
|
if (this._ctx.disposed) {
|
|
1494
1492
|
return;
|
|
1495
1493
|
}
|
|
1496
|
-
const
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1494
|
+
const docs = documentIds.map((documentId) => {
|
|
1495
|
+
const handle = this._repo.handles[documentId];
|
|
1496
|
+
if (!handle || !handle.isReady()) {
|
|
1497
|
+
log3.warn("document not ready, skipping", {
|
|
1498
|
+
documentId
|
|
1499
|
+
}, {
|
|
1500
|
+
F: __dxlog_file3,
|
|
1501
|
+
L: 727,
|
|
1502
|
+
S: this,
|
|
1503
|
+
C: (f, a) => f(...a)
|
|
1504
|
+
});
|
|
1505
|
+
return;
|
|
1506
|
+
}
|
|
1507
|
+
const doc = handle.doc();
|
|
1508
|
+
if (!doc) {
|
|
1509
|
+
log3.warn("document not available, skipping", {
|
|
1510
|
+
documentId
|
|
1511
|
+
}, {
|
|
1512
|
+
F: __dxlog_file3,
|
|
1513
|
+
L: 732,
|
|
1514
|
+
S: this,
|
|
1515
|
+
C: (f, a) => f(...a)
|
|
1516
|
+
});
|
|
1517
|
+
return;
|
|
1518
|
+
}
|
|
1519
|
+
return {
|
|
1520
|
+
documentId,
|
|
1521
|
+
data: save(doc),
|
|
1522
|
+
heads: getHeads(doc)
|
|
1523
|
+
};
|
|
1524
|
+
});
|
|
1525
|
+
await this._echoNetworkAdapter.pushBundle(peerId, docs.filter(isNonNullable2));
|
|
1503
1526
|
}
|
|
1504
1527
|
async _pullInBundles(peerId, documentIds) {
|
|
1505
1528
|
const documentsToPull = [
|
|
@@ -1520,7 +1543,7 @@ var AutomergeHost = class extends Resource3 {
|
|
|
1520
1543
|
err
|
|
1521
1544
|
}, {
|
|
1522
1545
|
F: __dxlog_file3,
|
|
1523
|
-
L:
|
|
1546
|
+
L: 762,
|
|
1524
1547
|
S: this,
|
|
1525
1548
|
C: (f, a) => f(...a)
|
|
1526
1549
|
});
|
|
@@ -1558,9 +1581,12 @@ var AutomergeHost = class extends Resource3 {
|
|
|
1558
1581
|
const collectionsChanged = /* @__PURE__ */ new Set();
|
|
1559
1582
|
for (const collectionId of this._collectionSynchronizer.getRegisteredCollectionIds()) {
|
|
1560
1583
|
const state = this._collectionSynchronizer.getLocalCollectionState(collectionId);
|
|
1584
|
+
if (!state) {
|
|
1585
|
+
continue;
|
|
1586
|
+
}
|
|
1561
1587
|
let newState;
|
|
1562
1588
|
for (const [documentId, heads] of docHeads) {
|
|
1563
|
-
if (state
|
|
1589
|
+
if (documentId in state.documents) {
|
|
1564
1590
|
if (!newState) {
|
|
1565
1591
|
newState = structuredClone(state);
|
|
1566
1592
|
}
|
|
@@ -1648,7 +1674,7 @@ var changeIsPresentInDoc = (doc, changeHash) => {
|
|
|
1648
1674
|
var decodeCollectionState = (state) => {
|
|
1649
1675
|
invariant2(typeof state === "object" && state !== null, "Invalid state", {
|
|
1650
1676
|
F: __dxlog_file3,
|
|
1651
|
-
L:
|
|
1677
|
+
L: 845,
|
|
1652
1678
|
S: void 0,
|
|
1653
1679
|
A: [
|
|
1654
1680
|
"typeof state === 'object' && state !== null",
|
|
@@ -1668,7 +1694,7 @@ import { log as log5 } from "@dxos/log";
|
|
|
1668
1694
|
import { ComplexSet as ComplexSet2, defaultMap as defaultMap2 } from "@dxos/util";
|
|
1669
1695
|
|
|
1670
1696
|
// src/automerge/mesh-echo-replicator-connection.ts
|
|
1671
|
-
import * as
|
|
1697
|
+
import * as A2 from "@automerge/automerge";
|
|
1672
1698
|
import { cbor } from "@automerge/automerge-repo";
|
|
1673
1699
|
import { Resource as Resource4 } from "@dxos/context";
|
|
1674
1700
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
@@ -1809,7 +1835,7 @@ var MeshReplicatorConnection = class extends Resource4 {
|
|
|
1809
1835
|
};
|
|
1810
1836
|
var logSendSync = (message) => {
|
|
1811
1837
|
log4("sendSyncMessage", () => {
|
|
1812
|
-
const decodedSyncMessage = message.type === "sync" && message.data ?
|
|
1838
|
+
const decodedSyncMessage = message.type === "sync" && message.data ? A2.decodeSyncMessage(message.data) : void 0;
|
|
1813
1839
|
return {
|
|
1814
1840
|
sync: decodedSyncMessage && {
|
|
1815
1841
|
headsLength: decodedSyncMessage.heads.length,
|
|
@@ -2472,7 +2498,7 @@ var getByteCount = (message) => {
|
|
|
2472
2498
|
};
|
|
2473
2499
|
|
|
2474
2500
|
// src/db-host/documents-synchronizer.ts
|
|
2475
|
-
import { next as
|
|
2501
|
+
import { next as A3 } from "@automerge/automerge";
|
|
2476
2502
|
import { UpdateScheduler, sleep } from "@dxos/async";
|
|
2477
2503
|
import { LifecycleState as LifecycleState2, Resource as Resource5, cancelWithContext as cancelWithContext2 } from "@dxos/context";
|
|
2478
2504
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
@@ -2613,11 +2639,11 @@ var DocumentsSynchronizer = class extends Resource5 {
|
|
|
2613
2639
|
return;
|
|
2614
2640
|
}
|
|
2615
2641
|
const doc = handle.doc();
|
|
2616
|
-
const mutation = syncState.lastSentHead ?
|
|
2642
|
+
const mutation = syncState.lastSentHead ? A3.saveSince(doc, syncState.lastSentHead) : A3.save(doc);
|
|
2617
2643
|
if (mutation.length === 0) {
|
|
2618
2644
|
return;
|
|
2619
2645
|
}
|
|
2620
|
-
syncState.lastSentHead =
|
|
2646
|
+
syncState.lastSentHead = A3.getHeads(doc);
|
|
2621
2647
|
return mutation;
|
|
2622
2648
|
}
|
|
2623
2649
|
_writeMutation(documentId, mutation, isNew) {
|
|
@@ -2629,7 +2655,7 @@ var DocumentsSynchronizer = class extends Resource5 {
|
|
|
2629
2655
|
docId: documentId
|
|
2630
2656
|
});
|
|
2631
2657
|
const syncState = this._startSync(newHandle);
|
|
2632
|
-
syncState.lastSentHead =
|
|
2658
|
+
syncState.lastSentHead = A3.getHeads(newHandle.doc());
|
|
2633
2659
|
} else {
|
|
2634
2660
|
const syncState = this._syncStates.get(documentId);
|
|
2635
2661
|
invariant6(syncState, "Sync state for document not found", {
|
|
@@ -2641,12 +2667,12 @@ var DocumentsSynchronizer = class extends Resource5 {
|
|
|
2641
2667
|
"'Sync state for document not found'"
|
|
2642
2668
|
]
|
|
2643
2669
|
});
|
|
2644
|
-
const headsBefore =
|
|
2670
|
+
const headsBefore = A3.getHeads(syncState.handle.doc());
|
|
2645
2671
|
this._params.repo.import(mutation, {
|
|
2646
2672
|
docId: documentId
|
|
2647
2673
|
});
|
|
2648
|
-
if (
|
|
2649
|
-
syncState.lastSentHead =
|
|
2674
|
+
if (A3.equals(headsBefore, syncState.lastSentHead)) {
|
|
2675
|
+
syncState.lastSentHead = A3.getHeads(syncState.handle.doc());
|
|
2650
2676
|
}
|
|
2651
2677
|
}
|
|
2652
2678
|
}
|
|
@@ -2819,7 +2845,7 @@ import { IndexKind } from "@dxos/protocols/proto/dxos/echo/indexing";
|
|
|
2819
2845
|
import { trace as trace5 } from "@dxos/tracing";
|
|
2820
2846
|
|
|
2821
2847
|
// src/db-host/documents-iterator.ts
|
|
2822
|
-
import * as
|
|
2848
|
+
import * as A4 from "@automerge/automerge";
|
|
2823
2849
|
import { Context as Context2 } from "@dxos/context";
|
|
2824
2850
|
import { DatabaseDirectory as DatabaseDirectory2, SpaceDocVersion } from "@dxos/echo-protocol";
|
|
2825
2851
|
import { invariant as invariant8 } from "@dxos/invariant";
|
|
@@ -2850,10 +2876,10 @@ var createSelectedDocumentsIterator = (automergeHost) => (
|
|
|
2850
2876
|
""
|
|
2851
2877
|
]
|
|
2852
2878
|
});
|
|
2853
|
-
const currentHeads =
|
|
2854
|
-
if (!
|
|
2879
|
+
const currentHeads = A4.getHeads(doc);
|
|
2880
|
+
if (!A4.equals(currentHeads, heads)) {
|
|
2855
2881
|
const begin = Date.now();
|
|
2856
|
-
doc =
|
|
2882
|
+
doc = A4.view(doc, heads);
|
|
2857
2883
|
const end = Date.now();
|
|
2858
2884
|
if (end - begin > LOG_VIEW_OPERATION_THRESHOLD) {
|
|
2859
2885
|
log8("Checking out document version is taking too long", {
|
|
@@ -2908,7 +2934,7 @@ var createSelectedDocumentsIterator = (automergeHost) => (
|
|
|
2908
2934
|
|
|
2909
2935
|
// src/db-host/query-service.ts
|
|
2910
2936
|
import { getHeads as getHeads3 } from "@automerge/automerge";
|
|
2911
|
-
import
|
|
2937
|
+
import * as Schema from "effect/Schema";
|
|
2912
2938
|
import { DeferredTask as DeferredTask2, scheduleMicroTask, synchronized as synchronized2 } from "@dxos/async";
|
|
2913
2939
|
import { Stream as Stream2 } from "@dxos/codec-protobuf/stream";
|
|
2914
2940
|
import { Context as Context4, Resource as Resource7 } from "@dxos/context";
|
|
@@ -2919,7 +2945,8 @@ import { objectPointerCodec as objectPointerCodec4 } from "@dxos/protocols";
|
|
|
2919
2945
|
import { trace as trace4 } from "@dxos/tracing";
|
|
2920
2946
|
|
|
2921
2947
|
// src/query/query-executor.ts
|
|
2922
|
-
import
|
|
2948
|
+
import * as Match from "effect/Match";
|
|
2949
|
+
import * as Predicate from "effect/Predicate";
|
|
2923
2950
|
import { Context as Context3, ContextDisposedError, LifecycleState as LifecycleState3, Resource as Resource6 } from "@dxos/context";
|
|
2924
2951
|
import { DatabaseDirectory as DatabaseDirectory3, ObjectStructure, isEncodedReference } from "@dxos/echo-protocol";
|
|
2925
2952
|
import { EscapedPropPath } from "@dxos/indexing";
|
|
@@ -2927,7 +2954,7 @@ import { invariant as invariant10 } from "@dxos/invariant";
|
|
|
2927
2954
|
import { DXN, PublicKey as PublicKey3 } from "@dxos/keys";
|
|
2928
2955
|
import { log as log9 } from "@dxos/log";
|
|
2929
2956
|
import { objectPointerCodec as objectPointerCodec3 } from "@dxos/protocols";
|
|
2930
|
-
import { getDeep, isNonNullable as
|
|
2957
|
+
import { getDeep, isNonNullable as isNonNullable3 } from "@dxos/util";
|
|
2931
2958
|
|
|
2932
2959
|
// src/query/query-planner.ts
|
|
2933
2960
|
import { Order } from "@dxos/echo";
|
|
@@ -3038,10 +3065,11 @@ var QueryPlanner = class {
|
|
|
3038
3065
|
}
|
|
3039
3066
|
// TODO(dmaretskyi): This can be rewritten as a function of (filter[]) -> (selection ? undefined, rest: filter[]) that recurses onto itself.
|
|
3040
3067
|
// TODO(dmaretskyi): If the tip of the query ast is a [select, ...filter] shape we can reorder the filters so the query is most efficient.
|
|
3041
|
-
_generateSelectionFromFilter(
|
|
3042
|
-
switch (
|
|
3068
|
+
_generateSelectionFromFilter(filter2, context) {
|
|
3069
|
+
switch (filter2.type) {
|
|
3070
|
+
// Props
|
|
3043
3071
|
case "object": {
|
|
3044
|
-
if (context.selectionInverted &&
|
|
3072
|
+
if (context.selectionInverted && filter2.id === void 0 && filter2.typename === null && Object.keys(filter2.props).length === 0) {
|
|
3045
3073
|
return QueryPlan.Plan.make([
|
|
3046
3074
|
{
|
|
3047
3075
|
_tag: "ClearWorkingSetStep"
|
|
@@ -3057,26 +3085,26 @@ var QueryPlanner = class {
|
|
|
3057
3085
|
}
|
|
3058
3086
|
});
|
|
3059
3087
|
}
|
|
3060
|
-
if (
|
|
3088
|
+
if (filter2.id && filter2.id?.length > 0) {
|
|
3061
3089
|
return QueryPlan.Plan.make([
|
|
3062
3090
|
{
|
|
3063
3091
|
_tag: "SelectStep",
|
|
3064
3092
|
spaces: context.selectionSpaces,
|
|
3065
3093
|
selector: {
|
|
3066
3094
|
_tag: "IdSelector",
|
|
3067
|
-
objectIds:
|
|
3095
|
+
objectIds: filter2.id
|
|
3068
3096
|
}
|
|
3069
3097
|
},
|
|
3070
3098
|
...this._generateDeletedHandlingSteps(context),
|
|
3071
3099
|
{
|
|
3072
3100
|
_tag: "FilterStep",
|
|
3073
3101
|
filter: {
|
|
3074
|
-
...
|
|
3102
|
+
...filter2,
|
|
3075
3103
|
id: void 0
|
|
3076
3104
|
}
|
|
3077
3105
|
}
|
|
3078
3106
|
]);
|
|
3079
|
-
} else if (
|
|
3107
|
+
} else if (filter2.typename) {
|
|
3080
3108
|
return QueryPlan.Plan.make([
|
|
3081
3109
|
{
|
|
3082
3110
|
_tag: "SelectStep",
|
|
@@ -3084,7 +3112,7 @@ var QueryPlanner = class {
|
|
|
3084
3112
|
selector: {
|
|
3085
3113
|
_tag: "TypeSelector",
|
|
3086
3114
|
typename: [
|
|
3087
|
-
|
|
3115
|
+
filter2.typename
|
|
3088
3116
|
],
|
|
3089
3117
|
inverted: false
|
|
3090
3118
|
}
|
|
@@ -3093,7 +3121,7 @@ var QueryPlanner = class {
|
|
|
3093
3121
|
{
|
|
3094
3122
|
_tag: "FilterStep",
|
|
3095
3123
|
filter: {
|
|
3096
|
-
...
|
|
3124
|
+
...filter2,
|
|
3097
3125
|
typename: null
|
|
3098
3126
|
}
|
|
3099
3127
|
}
|
|
@@ -3111,12 +3139,32 @@ var QueryPlanner = class {
|
|
|
3111
3139
|
{
|
|
3112
3140
|
_tag: "FilterStep",
|
|
3113
3141
|
filter: {
|
|
3114
|
-
...
|
|
3142
|
+
...filter2
|
|
3115
3143
|
}
|
|
3116
3144
|
}
|
|
3117
3145
|
]);
|
|
3118
3146
|
}
|
|
3119
3147
|
}
|
|
3148
|
+
// Tag
|
|
3149
|
+
case "tag": {
|
|
3150
|
+
return QueryPlan.Plan.make([
|
|
3151
|
+
{
|
|
3152
|
+
_tag: "SelectStep",
|
|
3153
|
+
spaces: context.selectionSpaces,
|
|
3154
|
+
selector: {
|
|
3155
|
+
_tag: "WildcardSelector"
|
|
3156
|
+
}
|
|
3157
|
+
},
|
|
3158
|
+
...this._generateDeletedHandlingSteps(context),
|
|
3159
|
+
{
|
|
3160
|
+
_tag: "FilterStep",
|
|
3161
|
+
filter: {
|
|
3162
|
+
...filter2
|
|
3163
|
+
}
|
|
3164
|
+
}
|
|
3165
|
+
]);
|
|
3166
|
+
}
|
|
3167
|
+
// Text
|
|
3120
3168
|
case "text-search": {
|
|
3121
3169
|
return QueryPlan.Plan.make([
|
|
3122
3170
|
{
|
|
@@ -3124,13 +3172,14 @@ var QueryPlanner = class {
|
|
|
3124
3172
|
spaces: context.selectionSpaces,
|
|
3125
3173
|
selector: {
|
|
3126
3174
|
_tag: "TextSelector",
|
|
3127
|
-
text:
|
|
3128
|
-
searchKind:
|
|
3175
|
+
text: filter2.text,
|
|
3176
|
+
searchKind: filter2.searchKind ?? this._options.defaultTextSearchKind
|
|
3129
3177
|
}
|
|
3130
3178
|
},
|
|
3131
3179
|
...this._generateDeletedHandlingSteps(context)
|
|
3132
3180
|
]);
|
|
3133
3181
|
}
|
|
3182
|
+
// Compare
|
|
3134
3183
|
case "compare":
|
|
3135
3184
|
throw new QueryError({
|
|
3136
3185
|
message: "Query too complex",
|
|
@@ -3152,8 +3201,9 @@ var QueryPlanner = class {
|
|
|
3152
3201
|
query: context.originalQuery
|
|
3153
3202
|
}
|
|
3154
3203
|
});
|
|
3204
|
+
// Boolean
|
|
3155
3205
|
case "not":
|
|
3156
|
-
return this._generateSelectionFromFilter(
|
|
3206
|
+
return this._generateSelectionFromFilter(filter2.filter, {
|
|
3157
3207
|
...context,
|
|
3158
3208
|
selectionInverted: !context.selectionInverted
|
|
3159
3209
|
});
|
|
@@ -3165,18 +3215,18 @@ var QueryPlanner = class {
|
|
|
3165
3215
|
}
|
|
3166
3216
|
});
|
|
3167
3217
|
case "or":
|
|
3168
|
-
if (
|
|
3169
|
-
const typenames =
|
|
3170
|
-
invariant9(
|
|
3218
|
+
if (filter2.filters.every(isTrivialTypenameFilter)) {
|
|
3219
|
+
const typenames = filter2.filters.map((filter3) => {
|
|
3220
|
+
invariant9(filter3.type === "object" && filter3.typename !== null, void 0, {
|
|
3171
3221
|
F: __dxlog_file10,
|
|
3172
|
-
L:
|
|
3222
|
+
L: 224,
|
|
3173
3223
|
S: this,
|
|
3174
3224
|
A: [
|
|
3175
|
-
"
|
|
3225
|
+
"filter.type === 'object' && filter.typename !== null",
|
|
3176
3226
|
""
|
|
3177
3227
|
]
|
|
3178
3228
|
});
|
|
3179
|
-
return
|
|
3229
|
+
return filter3.typename;
|
|
3180
3230
|
});
|
|
3181
3231
|
return QueryPlan.Plan.make([
|
|
3182
3232
|
{
|
|
@@ -3200,7 +3250,7 @@ var QueryPlanner = class {
|
|
|
3200
3250
|
}
|
|
3201
3251
|
default:
|
|
3202
3252
|
throw new QueryError({
|
|
3203
|
-
message: `Unsupported filter type: ${
|
|
3253
|
+
message: `Unsupported filter type: ${filter2.type}`,
|
|
3204
3254
|
context: {
|
|
3205
3255
|
query: context.originalQuery
|
|
3206
3256
|
}
|
|
@@ -3466,8 +3516,8 @@ var createRelationTraversalStep = (direction) => ({
|
|
|
3466
3516
|
direction
|
|
3467
3517
|
}
|
|
3468
3518
|
});
|
|
3469
|
-
var isTrivialTypenameFilter = (
|
|
3470
|
-
return
|
|
3519
|
+
var isTrivialTypenameFilter = (filter2) => {
|
|
3520
|
+
return filter2.type === "object" && filter2.typename !== null && Object.keys(filter2.props).length === 0 && (filter2.id === void 0 || filter2.id.length === 0) && (filter2.foreignKeys === void 0 || filter2.foreignKeys.length === 0);
|
|
3471
3521
|
};
|
|
3472
3522
|
|
|
3473
3523
|
// src/query/query-executor.ts
|
|
@@ -3485,7 +3535,7 @@ function _define_property12(obj, key, value) {
|
|
|
3485
3535
|
return obj;
|
|
3486
3536
|
}
|
|
3487
3537
|
var __dxlog_file11 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/query/query-executor.ts";
|
|
3488
|
-
var
|
|
3538
|
+
var isNullable2 = Predicate.isNullable;
|
|
3489
3539
|
var ExecutionTrace = Object.freeze({
|
|
3490
3540
|
makeEmpty: () => ({
|
|
3491
3541
|
name: "Empty",
|
|
@@ -3493,11 +3543,57 @@ var ExecutionTrace = Object.freeze({
|
|
|
3493
3543
|
objectCount: 0,
|
|
3494
3544
|
documentsLoaded: 0,
|
|
3495
3545
|
indexHits: 0,
|
|
3546
|
+
beginTs: 0,
|
|
3547
|
+
endTs: 0,
|
|
3496
3548
|
indexQueryTime: 0,
|
|
3497
3549
|
documentLoadTime: 0,
|
|
3498
3550
|
executionTime: 0,
|
|
3499
3551
|
children: []
|
|
3500
3552
|
}),
|
|
3553
|
+
markEnd: (trace6) => {
|
|
3554
|
+
trace6.endTs = performance.now();
|
|
3555
|
+
trace6.executionTime = trace6.endTs - trace6.beginTs;
|
|
3556
|
+
},
|
|
3557
|
+
putOnPerformanceTimeline: (trace6) => {
|
|
3558
|
+
performance.measure(trace6.name, {
|
|
3559
|
+
start: trace6.beginTs,
|
|
3560
|
+
end: trace6.endTs,
|
|
3561
|
+
detail: {
|
|
3562
|
+
devtools: {
|
|
3563
|
+
dataType: "track-entry",
|
|
3564
|
+
track: "Query Execution",
|
|
3565
|
+
trackGroup: "ECHO",
|
|
3566
|
+
color: "tertiary-dark",
|
|
3567
|
+
properties: [
|
|
3568
|
+
[
|
|
3569
|
+
"objectCount",
|
|
3570
|
+
trace6.objectCount
|
|
3571
|
+
],
|
|
3572
|
+
[
|
|
3573
|
+
"documentsLoaded",
|
|
3574
|
+
trace6.documentsLoaded
|
|
3575
|
+
],
|
|
3576
|
+
[
|
|
3577
|
+
"index hits",
|
|
3578
|
+
trace6.indexHits
|
|
3579
|
+
],
|
|
3580
|
+
[
|
|
3581
|
+
"indexQueryTime",
|
|
3582
|
+
trace6.indexQueryTime
|
|
3583
|
+
],
|
|
3584
|
+
[
|
|
3585
|
+
"documentLoadTime",
|
|
3586
|
+
trace6.documentLoadTime
|
|
3587
|
+
]
|
|
3588
|
+
],
|
|
3589
|
+
tooltipText: trace6.details
|
|
3590
|
+
}
|
|
3591
|
+
}
|
|
3592
|
+
});
|
|
3593
|
+
for (const child of trace6.children) {
|
|
3594
|
+
ExecutionTrace.putOnPerformanceTimeline(child);
|
|
3595
|
+
}
|
|
3596
|
+
},
|
|
3501
3597
|
format: (trace6) => {
|
|
3502
3598
|
const go = (trace7, indent) => {
|
|
3503
3599
|
return [
|
|
@@ -3537,7 +3633,7 @@ var QueryExecutor = class extends Resource6 {
|
|
|
3537
3633
|
async execQuery() {
|
|
3538
3634
|
invariant10(this._lifecycleState === LifecycleState3.OPEN, void 0, {
|
|
3539
3635
|
F: __dxlog_file11,
|
|
3540
|
-
L:
|
|
3636
|
+
L: 211,
|
|
3541
3637
|
S: this,
|
|
3542
3638
|
A: [
|
|
3543
3639
|
"this._lifecycleState === LifecycleState.OPEN",
|
|
@@ -3572,7 +3668,7 @@ var QueryExecutor = class extends Resource6 {
|
|
|
3572
3668
|
trace6.children.push(result.trace);
|
|
3573
3669
|
}
|
|
3574
3670
|
trace6.objectCount = workingSet.length;
|
|
3575
|
-
|
|
3671
|
+
ExecutionTrace.markEnd(trace6);
|
|
3576
3672
|
return {
|
|
3577
3673
|
workingSet,
|
|
3578
3674
|
trace: trace6
|
|
@@ -3616,7 +3712,8 @@ var QueryExecutor = class extends Resource6 {
|
|
|
3616
3712
|
default:
|
|
3617
3713
|
throw new Error(`Unknown step type: ${step._tag}`);
|
|
3618
3714
|
}
|
|
3619
|
-
trace6.
|
|
3715
|
+
trace6.beginTs = begin;
|
|
3716
|
+
ExecutionTrace.markEnd(trace6);
|
|
3620
3717
|
return {
|
|
3621
3718
|
workingSet: newWorkingSet,
|
|
3622
3719
|
trace: trace6
|
|
@@ -3629,7 +3726,8 @@ var QueryExecutor = class extends Resource6 {
|
|
|
3629
3726
|
const trace6 = {
|
|
3630
3727
|
...ExecutionTrace.makeEmpty(),
|
|
3631
3728
|
name: "Select",
|
|
3632
|
-
details: JSON.stringify(step.selector)
|
|
3729
|
+
details: JSON.stringify(step.selector),
|
|
3730
|
+
beginTs: performance.now()
|
|
3633
3731
|
};
|
|
3634
3732
|
switch (step.selector._tag) {
|
|
3635
3733
|
case "WildcardSelector": {
|
|
@@ -3650,7 +3748,7 @@ var QueryExecutor = class extends Resource6 {
|
|
|
3650
3748
|
const results = await this._loadDocumentsAfterIndexQuery(indexHits);
|
|
3651
3749
|
trace6.documentsLoaded += results.length;
|
|
3652
3750
|
trace6.documentLoadTime += performance.now() - documentLoadStart;
|
|
3653
|
-
workingSet.push(...results.filter(
|
|
3751
|
+
workingSet.push(...results.filter(isNonNullable3).filter((item) => step.spaces.includes(item.spaceId)));
|
|
3654
3752
|
trace6.objectCount = workingSet.length;
|
|
3655
3753
|
break;
|
|
3656
3754
|
}
|
|
@@ -3660,7 +3758,7 @@ var QueryExecutor = class extends Resource6 {
|
|
|
3660
3758
|
sourceSpaceId: step.spaces[0]
|
|
3661
3759
|
})));
|
|
3662
3760
|
trace6.documentLoadTime += performance.now() - beginLoad;
|
|
3663
|
-
workingSet.push(...items.filter(
|
|
3761
|
+
workingSet.push(...items.filter(isNonNullable3));
|
|
3664
3762
|
trace6.objectCount = workingSet.length;
|
|
3665
3763
|
break;
|
|
3666
3764
|
}
|
|
@@ -3682,7 +3780,7 @@ var QueryExecutor = class extends Resource6 {
|
|
|
3682
3780
|
const results = await this._loadDocumentsAfterIndexQuery(indexHits);
|
|
3683
3781
|
trace6.documentsLoaded += results.length;
|
|
3684
3782
|
trace6.documentLoadTime += performance.now() - documentLoadStart;
|
|
3685
|
-
workingSet.push(...results.filter(
|
|
3783
|
+
workingSet.push(...results.filter(isNonNullable3).filter((item) => step.spaces.includes(item.spaceId)));
|
|
3686
3784
|
trace6.objectCount = workingSet.length;
|
|
3687
3785
|
break;
|
|
3688
3786
|
}
|
|
@@ -3707,7 +3805,7 @@ var QueryExecutor = class extends Resource6 {
|
|
|
3707
3805
|
const results = await this._loadDocumentsAfterIndexQuery(indexHits);
|
|
3708
3806
|
trace6.documentsLoaded += results.length;
|
|
3709
3807
|
trace6.documentLoadTime += performance.now() - documentLoadStart;
|
|
3710
|
-
workingSet.push(...results.filter(
|
|
3808
|
+
workingSet.push(...results.filter(isNonNullable3).filter((item) => step.spaces.includes(item.spaceId)));
|
|
3711
3809
|
trace6.objectCount = workingSet.length;
|
|
3712
3810
|
break;
|
|
3713
3811
|
}
|
|
@@ -3777,20 +3875,20 @@ var QueryExecutor = class extends Resource6 {
|
|
|
3777
3875
|
ref: ref2["/"]
|
|
3778
3876
|
}, {
|
|
3779
3877
|
F: __dxlog_file11,
|
|
3780
|
-
L:
|
|
3878
|
+
L: 477,
|
|
3781
3879
|
S: this,
|
|
3782
3880
|
C: (f, a) => f(...a)
|
|
3783
3881
|
});
|
|
3784
3882
|
return null;
|
|
3785
3883
|
}
|
|
3786
3884
|
});
|
|
3787
|
-
}).filter(
|
|
3885
|
+
}).filter(isNonNullable3);
|
|
3788
3886
|
const beginLoad = performance.now();
|
|
3789
3887
|
const items = await Promise.all(refs.map(({ ref, spaceId }) => this._loadFromDXN(ref, {
|
|
3790
3888
|
sourceSpaceId: spaceId
|
|
3791
3889
|
})));
|
|
3792
3890
|
trace6.documentLoadTime += performance.now() - beginLoad;
|
|
3793
|
-
newWorkingSet.push(...items.filter(
|
|
3891
|
+
newWorkingSet.push(...items.filter(isNonNullable3));
|
|
3794
3892
|
trace6.objectCount = newWorkingSet.length;
|
|
3795
3893
|
break;
|
|
3796
3894
|
}
|
|
@@ -3809,7 +3907,7 @@ var QueryExecutor = class extends Resource6 {
|
|
|
3809
3907
|
const results = await this._loadDocumentsAfterIndexQuery(indexHits);
|
|
3810
3908
|
trace6.documentsLoaded += results.length;
|
|
3811
3909
|
trace6.documentLoadTime += performance.now() - documentLoadStart;
|
|
3812
|
-
newWorkingSet.push(...results.filter(
|
|
3910
|
+
newWorkingSet.push(...results.filter(isNonNullable3));
|
|
3813
3911
|
trace6.objectCount = newWorkingSet.length;
|
|
3814
3912
|
break;
|
|
3815
3913
|
}
|
|
@@ -3835,19 +3933,19 @@ var QueryExecutor = class extends Resource6 {
|
|
|
3835
3933
|
ref: ref["/"]
|
|
3836
3934
|
}, {
|
|
3837
3935
|
F: __dxlog_file11,
|
|
3838
|
-
L:
|
|
3936
|
+
L: 540,
|
|
3839
3937
|
S: this,
|
|
3840
3938
|
C: (f, a) => f(...a)
|
|
3841
3939
|
});
|
|
3842
3940
|
return null;
|
|
3843
3941
|
}
|
|
3844
|
-
}).filter(
|
|
3942
|
+
}).filter(isNonNullable3);
|
|
3845
3943
|
const beginLoad = performance.now();
|
|
3846
3944
|
const items = await Promise.all(refs.map(({ ref, spaceId }) => this._loadFromDXN(ref, {
|
|
3847
3945
|
sourceSpaceId: spaceId
|
|
3848
3946
|
})));
|
|
3849
3947
|
trace6.documentLoadTime += performance.now() - beginLoad;
|
|
3850
|
-
newWorkingSet.push(...items.filter(
|
|
3948
|
+
newWorkingSet.push(...items.filter(isNonNullable3));
|
|
3851
3949
|
trace6.objectCount = newWorkingSet.length;
|
|
3852
3950
|
break;
|
|
3853
3951
|
}
|
|
@@ -3867,7 +3965,7 @@ var QueryExecutor = class extends Resource6 {
|
|
|
3867
3965
|
const results = await this._loadDocumentsAfterIndexQuery(indexHits);
|
|
3868
3966
|
trace6.documentsLoaded += results.length;
|
|
3869
3967
|
trace6.documentLoadTime += performance.now() - documentLoadStart;
|
|
3870
|
-
newWorkingSet.push(...results.filter(
|
|
3968
|
+
newWorkingSet.push(...results.filter(isNonNullable3));
|
|
3871
3969
|
trace6.objectCount = newWorkingSet.length;
|
|
3872
3970
|
break;
|
|
3873
3971
|
}
|
|
@@ -3960,14 +4058,14 @@ var QueryExecutor = class extends Resource6 {
|
|
|
3960
4058
|
return Match.type().pipe(
|
|
3961
4059
|
Match.withReturnType(),
|
|
3962
4060
|
Match.when({
|
|
3963
|
-
a:
|
|
3964
|
-
b:
|
|
4061
|
+
a: isNullable2,
|
|
4062
|
+
b: isNullable2
|
|
3965
4063
|
}, () => 0),
|
|
3966
4064
|
Match.when({
|
|
3967
|
-
a:
|
|
4065
|
+
a: isNullable2
|
|
3968
4066
|
}, () => 1),
|
|
3969
4067
|
Match.when({
|
|
3970
|
-
b:
|
|
4068
|
+
b: isNullable2
|
|
3971
4069
|
}, () => -1),
|
|
3972
4070
|
Match.when({
|
|
3973
4071
|
a: Match.string,
|
|
@@ -4001,7 +4099,7 @@ var QueryExecutor = class extends Resource6 {
|
|
|
4001
4099
|
const { objectId, documentId, spaceKey: spaceKeyInIndex } = objectPointerCodec3.decode(hit.id);
|
|
4002
4100
|
const handle = await this._automergeHost.loadDoc(Context3.default(void 0, {
|
|
4003
4101
|
F: __dxlog_file11,
|
|
4004
|
-
L:
|
|
4102
|
+
L: 704
|
|
4005
4103
|
}), documentId);
|
|
4006
4104
|
const doc = handle.doc();
|
|
4007
4105
|
if (!doc) {
|
|
@@ -4029,7 +4127,7 @@ var QueryExecutor = class extends Resource6 {
|
|
|
4029
4127
|
dxn
|
|
4030
4128
|
}, {
|
|
4031
4129
|
F: __dxlog_file11,
|
|
4032
|
-
L:
|
|
4130
|
+
L: 731,
|
|
4033
4131
|
S: this,
|
|
4034
4132
|
C: (f, a) => f(...a)
|
|
4035
4133
|
});
|
|
@@ -4042,7 +4140,7 @@ var QueryExecutor = class extends Resource6 {
|
|
|
4042
4140
|
spaceId
|
|
4043
4141
|
}, {
|
|
4044
4142
|
F: __dxlog_file11,
|
|
4045
|
-
L:
|
|
4143
|
+
L: 739,
|
|
4046
4144
|
S: this,
|
|
4047
4145
|
C: (f, a) => f(...a)
|
|
4048
4146
|
});
|
|
@@ -4054,7 +4152,7 @@ var QueryExecutor = class extends Resource6 {
|
|
|
4054
4152
|
spaceId
|
|
4055
4153
|
}, {
|
|
4056
4154
|
F: __dxlog_file11,
|
|
4057
|
-
L:
|
|
4155
|
+
L: 744,
|
|
4058
4156
|
S: this,
|
|
4059
4157
|
C: (f, a) => f(...a)
|
|
4060
4158
|
});
|
|
@@ -4075,7 +4173,7 @@ var QueryExecutor = class extends Resource6 {
|
|
|
4075
4173
|
}
|
|
4076
4174
|
const handle = await this._automergeHost.loadDoc(Context3.default(void 0, {
|
|
4077
4175
|
F: __dxlog_file11,
|
|
4078
|
-
L:
|
|
4176
|
+
L: 763
|
|
4079
4177
|
}), link);
|
|
4080
4178
|
const doc = handle.doc();
|
|
4081
4179
|
if (!doc) {
|
|
@@ -4375,17 +4473,17 @@ import { DatabaseDirectory as DatabaseDirectory5, SpaceDocVersion as SpaceDocVer
|
|
|
4375
4473
|
import { invariant as invariant11 } from "@dxos/invariant";
|
|
4376
4474
|
|
|
4377
4475
|
// src/db-host/automerge-metrics.ts
|
|
4378
|
-
import * as
|
|
4476
|
+
import * as A5 from "@automerge/automerge";
|
|
4379
4477
|
import { log as log11 } from "@dxos/log";
|
|
4380
4478
|
var __dxlog_file13 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/automerge-metrics.ts";
|
|
4381
4479
|
var measureDocMetrics = (doc) => {
|
|
4382
|
-
const snapshot =
|
|
4480
|
+
const snapshot = A5.save(doc);
|
|
4383
4481
|
const start = Date.now();
|
|
4384
|
-
const temp =
|
|
4482
|
+
const temp = A5.load(snapshot);
|
|
4385
4483
|
const end = Date.now();
|
|
4386
|
-
|
|
4484
|
+
A5.free(temp);
|
|
4387
4485
|
const getAllChangesStart = Date.now();
|
|
4388
|
-
const mutationCount =
|
|
4486
|
+
const mutationCount = A5.getAllChanges(doc).length;
|
|
4389
4487
|
const getAllChangesEnd = Date.now();
|
|
4390
4488
|
if (getAllChangesEnd - getAllChangesStart > 300) {
|
|
4391
4489
|
log11.warn("getAllChanges took too long", {
|
|
@@ -4668,7 +4766,7 @@ var EchoHost = class extends Resource9 {
|
|
|
4668
4766
|
* Flush all pending writes to the underlying storage.
|
|
4669
4767
|
*/
|
|
4670
4768
|
async flush() {
|
|
4671
|
-
await this._automergeHost.
|
|
4769
|
+
await this._automergeHost.flush();
|
|
4672
4770
|
}
|
|
4673
4771
|
/**
|
|
4674
4772
|
* Perform any pending index updates.
|
|
@@ -4853,6 +4951,7 @@ var EchoHost = class extends Resource9 {
|
|
|
4853
4951
|
};
|
|
4854
4952
|
|
|
4855
4953
|
// src/edge/echo-edge-replicator.ts
|
|
4954
|
+
import * as Automerge from "@automerge/automerge";
|
|
4856
4955
|
import { cbor as cbor2 } from "@automerge/automerge-repo";
|
|
4857
4956
|
import { Mutex, scheduleMicroTask as scheduleMicroTask2, scheduleTask as scheduleTask2 } from "@dxos/async";
|
|
4858
4957
|
import { Context as Context6, Resource as Resource11 } from "@dxos/context";
|
|
@@ -4862,7 +4961,7 @@ import { log as log13 } from "@dxos/log";
|
|
|
4862
4961
|
import { DocumentCodec, EdgeService } from "@dxos/protocols";
|
|
4863
4962
|
import { buf } from "@dxos/protocols/buf";
|
|
4864
4963
|
import { MessageSchema as RouterMessageSchema } from "@dxos/protocols/buf/dxos/edge/messenger_pb";
|
|
4865
|
-
import { bufferToArray as bufferToArray2 } from "@dxos/util";
|
|
4964
|
+
import { bufferToArray as bufferToArray2, setDeep } from "@dxos/util";
|
|
4866
4965
|
|
|
4867
4966
|
// src/edge/inflight-request-limiter.ts
|
|
4868
4967
|
import { Trigger as Trigger2 } from "@dxos/async";
|
|
@@ -5025,14 +5124,14 @@ var EchoEdgeReplicator = class {
|
|
|
5025
5124
|
connectedSpaces: this._connectedSpaces.size
|
|
5026
5125
|
}, {
|
|
5027
5126
|
F: __dxlog_file18,
|
|
5028
|
-
L:
|
|
5127
|
+
L: 73,
|
|
5029
5128
|
S: this,
|
|
5030
5129
|
C: (f, a) => f(...a)
|
|
5031
5130
|
});
|
|
5032
5131
|
this._context = context;
|
|
5033
5132
|
this._ctx = Context6.default(void 0, {
|
|
5034
5133
|
F: __dxlog_file18,
|
|
5035
|
-
L:
|
|
5134
|
+
L: 75
|
|
5036
5135
|
});
|
|
5037
5136
|
this._ctx.onDispose(this._edgeConnection.onReconnected(() => {
|
|
5038
5137
|
this._ctx && scheduleMicroTask2(this._ctx, () => this._handleReconnect());
|
|
@@ -5131,7 +5230,7 @@ var EchoEdgeReplicator = class {
|
|
|
5131
5230
|
async _openConnection(spaceId, reconnects = 0) {
|
|
5132
5231
|
invariant14(this._context, void 0, {
|
|
5133
5232
|
F: __dxlog_file18,
|
|
5134
|
-
L:
|
|
5233
|
+
L: 136,
|
|
5135
5234
|
S: this,
|
|
5136
5235
|
A: [
|
|
5137
5236
|
"this._context",
|
|
@@ -5140,7 +5239,7 @@ var EchoEdgeReplicator = class {
|
|
|
5140
5239
|
});
|
|
5141
5240
|
invariant14(!this._connections.has(spaceId), void 0, {
|
|
5142
5241
|
F: __dxlog_file18,
|
|
5143
|
-
L:
|
|
5242
|
+
L: 137,
|
|
5144
5243
|
S: this,
|
|
5145
5244
|
A: [
|
|
5146
5245
|
"!this._connections.has(spaceId)",
|
|
@@ -5159,7 +5258,7 @@ var EchoEdgeReplicator = class {
|
|
|
5159
5258
|
spaceId
|
|
5160
5259
|
}, {
|
|
5161
5260
|
F: __dxlog_file18,
|
|
5162
|
-
L:
|
|
5261
|
+
L: 148,
|
|
5163
5262
|
S: this,
|
|
5164
5263
|
C: (f, a) => f(...a)
|
|
5165
5264
|
});
|
|
@@ -5170,7 +5269,7 @@ var EchoEdgeReplicator = class {
|
|
|
5170
5269
|
spaceId
|
|
5171
5270
|
}, {
|
|
5172
5271
|
F: __dxlog_file18,
|
|
5173
|
-
L:
|
|
5272
|
+
L: 152,
|
|
5174
5273
|
S: this,
|
|
5175
5274
|
C: (f, a) => f(...a)
|
|
5176
5275
|
});
|
|
@@ -5187,7 +5286,7 @@ var EchoEdgeReplicator = class {
|
|
|
5187
5286
|
restartDelay
|
|
5188
5287
|
}, {
|
|
5189
5288
|
F: __dxlog_file18,
|
|
5190
|
-
L:
|
|
5289
|
+
L: 163,
|
|
5191
5290
|
S: this,
|
|
5192
5291
|
C: (f, a) => f(...a)
|
|
5193
5292
|
});
|
|
@@ -5215,7 +5314,7 @@ var EchoEdgeReplicator = class {
|
|
|
5215
5314
|
restartDelay
|
|
5216
5315
|
}, {
|
|
5217
5316
|
F: __dxlog_file18,
|
|
5218
|
-
L:
|
|
5317
|
+
L: 180,
|
|
5219
5318
|
S: this,
|
|
5220
5319
|
C: (f, a) => f(...a)
|
|
5221
5320
|
});
|
|
@@ -5252,7 +5351,7 @@ var EdgeReplicatorConnection = class extends Resource11 {
|
|
|
5252
5351
|
async _open(ctx) {
|
|
5253
5352
|
log13("opening...", void 0, {
|
|
5254
5353
|
F: __dxlog_file18,
|
|
5255
|
-
L:
|
|
5354
|
+
L: 273,
|
|
5256
5355
|
S: this,
|
|
5257
5356
|
C: (f, a) => f(...a)
|
|
5258
5357
|
});
|
|
@@ -5267,7 +5366,7 @@ var EdgeReplicatorConnection = class extends Resource11 {
|
|
|
5267
5366
|
if (firstReconnect) {
|
|
5268
5367
|
log13.verbose("first reconnect skipped", void 0, {
|
|
5269
5368
|
F: __dxlog_file18,
|
|
5270
|
-
L:
|
|
5369
|
+
L: 288,
|
|
5271
5370
|
S: this,
|
|
5272
5371
|
C: (f, a) => f(...a)
|
|
5273
5372
|
});
|
|
@@ -5282,7 +5381,7 @@ var EdgeReplicatorConnection = class extends Resource11 {
|
|
|
5282
5381
|
async _close() {
|
|
5283
5382
|
log13("closing...", void 0, {
|
|
5284
5383
|
F: __dxlog_file18,
|
|
5285
|
-
L:
|
|
5384
|
+
L: 301,
|
|
5286
5385
|
S: this,
|
|
5287
5386
|
C: (f, a) => f(...a)
|
|
5288
5387
|
});
|
|
@@ -5293,7 +5392,7 @@ var EdgeReplicatorConnection = class extends Resource11 {
|
|
|
5293
5392
|
get peerId() {
|
|
5294
5393
|
invariant14(this._remotePeerId, "Not connected", {
|
|
5295
5394
|
F: __dxlog_file18,
|
|
5296
|
-
L:
|
|
5395
|
+
L: 310,
|
|
5297
5396
|
S: this,
|
|
5298
5397
|
A: [
|
|
5299
5398
|
"this._remotePeerId",
|
|
@@ -5318,7 +5417,7 @@ var EdgeReplicatorConnection = class extends Resource11 {
|
|
|
5318
5417
|
remoteId: this._remotePeerId
|
|
5319
5418
|
}, {
|
|
5320
5419
|
F: __dxlog_file18,
|
|
5321
|
-
L:
|
|
5420
|
+
L: 325,
|
|
5322
5421
|
S: this,
|
|
5323
5422
|
C: (f, a) => f(...a)
|
|
5324
5423
|
});
|
|
@@ -5339,12 +5438,11 @@ var EdgeReplicatorConnection = class extends Resource11 {
|
|
|
5339
5438
|
}
|
|
5340
5439
|
const payload = cbor2.decode(message.payload.value);
|
|
5341
5440
|
log13.verbose("received", {
|
|
5342
|
-
|
|
5343
|
-
documentId: payload.type === "sync" && payload.documentId,
|
|
5441
|
+
...getMessageInfo(payload),
|
|
5344
5442
|
remoteId: this._remotePeerId
|
|
5345
5443
|
}, {
|
|
5346
5444
|
F: __dxlog_file18,
|
|
5347
|
-
L:
|
|
5445
|
+
L: 354,
|
|
5348
5446
|
S: this,
|
|
5349
5447
|
C: (f, a) => f(...a)
|
|
5350
5448
|
});
|
|
@@ -5375,7 +5473,7 @@ var EdgeReplicatorConnection = class extends Resource11 {
|
|
|
5375
5473
|
]));
|
|
5376
5474
|
}
|
|
5377
5475
|
_processMessage(message) {
|
|
5378
|
-
if (
|
|
5476
|
+
if (isErrorMessage(message)) {
|
|
5379
5477
|
this._onRestartRequested();
|
|
5380
5478
|
return;
|
|
5381
5479
|
}
|
|
@@ -5384,13 +5482,20 @@ var EdgeReplicatorConnection = class extends Resource11 {
|
|
|
5384
5482
|
}
|
|
5385
5483
|
async _sendMessage(message) {
|
|
5386
5484
|
message.targetId = this._targetServiceId;
|
|
5485
|
+
setDeep(message, [
|
|
5486
|
+
"metadata",
|
|
5487
|
+
"dxos_sequence"
|
|
5488
|
+
], this._getSequence());
|
|
5489
|
+
setDeep(message, [
|
|
5490
|
+
"metadata",
|
|
5491
|
+
"dxos_connectionId"
|
|
5492
|
+
], this._connectionId);
|
|
5387
5493
|
log13.verbose("sending...", {
|
|
5388
|
-
|
|
5389
|
-
documentId: message.type === "sync" && message.documentId,
|
|
5494
|
+
...getMessageInfo(message),
|
|
5390
5495
|
remoteId: this._remotePeerId
|
|
5391
5496
|
}, {
|
|
5392
5497
|
F: __dxlog_file18,
|
|
5393
|
-
L:
|
|
5498
|
+
L: 407,
|
|
5394
5499
|
S: this,
|
|
5395
5500
|
C: (f, a) => f(...a)
|
|
5396
5501
|
});
|
|
@@ -5411,14 +5516,17 @@ var EdgeReplicatorConnection = class extends Resource11 {
|
|
|
5411
5516
|
err
|
|
5412
5517
|
}, {
|
|
5413
5518
|
F: __dxlog_file18,
|
|
5414
|
-
L:
|
|
5519
|
+
L: 426,
|
|
5415
5520
|
S: this,
|
|
5416
5521
|
C: (f, a) => f(...a)
|
|
5417
5522
|
});
|
|
5418
5523
|
}
|
|
5419
5524
|
}
|
|
5525
|
+
_getSequence() {
|
|
5526
|
+
return this._sequence++;
|
|
5527
|
+
}
|
|
5420
5528
|
constructor({ edgeConnection, edgeHttpClient, spaceId, context, sharedPolicyEnabled, onRemoteConnected, onRemoteDisconnected, onRestartRequested }) {
|
|
5421
|
-
super(), _define_property18(this, "_edgeConnection", void 0), _define_property18(this, "_edgeHttpClient", void 0), _define_property18(this, "_remotePeerId", null), _define_property18(this, "_targetServiceId", void 0), _define_property18(this, "_spaceId", void 0), _define_property18(this, "_context", void 0), _define_property18(this, "_sharedPolicyEnabled", void 0), _define_property18(this, "_onRemoteConnected", void 0), _define_property18(this, "_onRemoteDisconnected", void 0), _define_property18(this, "_onRestartRequested", void 0), _define_property18(this, "_requestLimiter", new InflightRequestLimiter({
|
|
5529
|
+
super(), _define_property18(this, "_connectionId", randomUUID()), _define_property18(this, "_edgeConnection", void 0), _define_property18(this, "_edgeHttpClient", void 0), _define_property18(this, "_remotePeerId", null), _define_property18(this, "_targetServiceId", void 0), _define_property18(this, "_spaceId", void 0), _define_property18(this, "_context", void 0), _define_property18(this, "_sharedPolicyEnabled", void 0), _define_property18(this, "_onRemoteConnected", void 0), _define_property18(this, "_onRemoteDisconnected", void 0), _define_property18(this, "_onRestartRequested", void 0), _define_property18(this, "_sequence", 0), _define_property18(this, "_requestLimiter", new InflightRequestLimiter({
|
|
5422
5530
|
maxInflightRequests: MAX_INFLIGHT_REQUESTS,
|
|
5423
5531
|
resetBalanceTimeoutMs: MAX_RATE_LIMIT_WAIT_TIME_MS
|
|
5424
5532
|
})), _define_property18(this, "_readableStreamController", void 0), _define_property18(this, "readable", void 0), _define_property18(this, "writable", void 0);
|
|
@@ -5426,7 +5534,7 @@ var EdgeReplicatorConnection = class extends Resource11 {
|
|
|
5426
5534
|
this._edgeHttpClient = edgeHttpClient;
|
|
5427
5535
|
this._spaceId = spaceId;
|
|
5428
5536
|
this._context = context;
|
|
5429
|
-
this._remotePeerId = `${EdgeService.AUTOMERGE_REPLICATOR}:${spaceId}-${
|
|
5537
|
+
this._remotePeerId = `${EdgeService.AUTOMERGE_REPLICATOR}:${spaceId}-${this._connectionId}`;
|
|
5430
5538
|
this._targetServiceId = `${EdgeService.AUTOMERGE_REPLICATOR}:${spaceId}`;
|
|
5431
5539
|
this._sharedPolicyEnabled = sharedPolicyEnabled;
|
|
5432
5540
|
this._onRemoteConnected = onRemoteConnected;
|
|
@@ -5445,7 +5553,19 @@ var EdgeReplicatorConnection = class extends Resource11 {
|
|
|
5445
5553
|
});
|
|
5446
5554
|
}
|
|
5447
5555
|
};
|
|
5448
|
-
var
|
|
5556
|
+
var isErrorMessage = (message) => message.type === "error";
|
|
5557
|
+
var getMessageInfo = (msg) => {
|
|
5558
|
+
const { have, heads, need, changes } = msg.type === "sync" ? Automerge.decodeSyncMessage(msg.data) : {};
|
|
5559
|
+
return {
|
|
5560
|
+
type: msg.type,
|
|
5561
|
+
documentId: "documentId" in msg ? msg.documentId : void 0,
|
|
5562
|
+
have,
|
|
5563
|
+
heads,
|
|
5564
|
+
need,
|
|
5565
|
+
changes: changes?.length,
|
|
5566
|
+
sequence: msg.metadata?.dxos_sequence
|
|
5567
|
+
};
|
|
5568
|
+
};
|
|
5449
5569
|
|
|
5450
5570
|
// src/util.ts
|
|
5451
5571
|
import { ObjectStructure as ObjectStructure2, decodeReference } from "@dxos/echo-protocol";
|