@dxos/echo-pipeline 0.5.9-main.1c1903d → 0.5.9-main.1ea2105
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/index.mjs +40 -49
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +50 -59
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/types/src/automerge/automerge-doc-loader.d.ts.map +1 -1
- package/dist/types/src/automerge/automerge-host.d.ts +0 -1
- package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
- package/dist/types/src/automerge/mesh-echo-replicator.d.ts.map +1 -1
- package/package.json +33 -33
- package/src/automerge/automerge-doc-loader.test.ts +2 -3
- package/src/automerge/automerge-doc-loader.ts +4 -2
- package/src/automerge/automerge-host.ts +0 -14
- package/src/automerge/mesh-echo-replicator.ts +5 -0
package/dist/lib/node/index.cjs
CHANGED
|
@@ -56,7 +56,6 @@ var import_automerge_repo = require("@dxos/automerge/automerge-repo");
|
|
|
56
56
|
var import_context = require("@dxos/context");
|
|
57
57
|
var import_invariant = require("@dxos/invariant");
|
|
58
58
|
var import_keys = require("@dxos/keys");
|
|
59
|
-
var import_log = require("@dxos/log");
|
|
60
59
|
var import_protocols = require("@dxos/protocols");
|
|
61
60
|
var import_tracing = require("@dxos/tracing");
|
|
62
61
|
var import_util = require("@dxos/util");
|
|
@@ -64,7 +63,7 @@ var import_async2 = require("@dxos/async");
|
|
|
64
63
|
var import_automerge_repo2 = require("@dxos/automerge/automerge-repo");
|
|
65
64
|
var import_context2 = require("@dxos/context");
|
|
66
65
|
var import_invariant2 = require("@dxos/invariant");
|
|
67
|
-
var
|
|
66
|
+
var import_log = require("@dxos/log");
|
|
68
67
|
var import_context3 = require("@dxos/context");
|
|
69
68
|
var import_async3 = require("@dxos/async");
|
|
70
69
|
var import_automerge_repo3 = require("@dxos/automerge/automerge-repo");
|
|
@@ -73,14 +72,15 @@ var import_invariant3 = require("@dxos/invariant");
|
|
|
73
72
|
var import_async4 = require("@dxos/async");
|
|
74
73
|
var import_context4 = require("@dxos/context");
|
|
75
74
|
var import_debug = require("@dxos/debug");
|
|
75
|
+
var import_echo_protocol = require("@dxos/echo-protocol");
|
|
76
76
|
var import_invariant4 = require("@dxos/invariant");
|
|
77
|
-
var
|
|
77
|
+
var import_log2 = require("@dxos/log");
|
|
78
78
|
var import_tracing2 = require("@dxos/tracing");
|
|
79
79
|
var import_automerge_repo4 = require("@dxos/automerge/automerge-repo");
|
|
80
80
|
var import_context5 = require("@dxos/context");
|
|
81
81
|
var import_invariant5 = require("@dxos/invariant");
|
|
82
82
|
var import_keys2 = require("@dxos/keys");
|
|
83
|
-
var
|
|
83
|
+
var import_log3 = require("@dxos/log");
|
|
84
84
|
var import_teleport_extension_automerge_replicator = require("@dxos/teleport-extension-automerge-replicator");
|
|
85
85
|
var import_util2 = require("@dxos/util");
|
|
86
86
|
function _ts_decorate(decorators, target, key, desc) {
|
|
@@ -115,7 +115,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
115
115
|
}
|
|
116
116
|
connectionEntry.writer.write(message).catch((err) => {
|
|
117
117
|
if (connectionEntry.isOpen) {
|
|
118
|
-
|
|
118
|
+
import_log.log.catch(err, void 0, {
|
|
119
119
|
F: __dxlog_file,
|
|
120
120
|
L: 49,
|
|
121
121
|
S: this,
|
|
@@ -137,7 +137,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
137
137
|
]
|
|
138
138
|
});
|
|
139
139
|
this._lifecycleState = import_context2.LifecycleState.OPEN;
|
|
140
|
-
(0,
|
|
140
|
+
(0, import_log.log)("emit ready", void 0, {
|
|
141
141
|
F: __dxlog_file,
|
|
142
142
|
L: 63,
|
|
143
143
|
S: this,
|
|
@@ -235,7 +235,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
235
235
|
return connection.connection.shouldAdvertize(params);
|
|
236
236
|
}
|
|
237
237
|
_onConnectionOpen(connection) {
|
|
238
|
-
(0,
|
|
238
|
+
(0, import_log.log)("Connection opened", {
|
|
239
239
|
peerId: connection.peerId
|
|
240
240
|
}, {
|
|
241
241
|
F: __dxlog_file,
|
|
@@ -272,7 +272,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
272
272
|
}
|
|
273
273
|
} catch (err) {
|
|
274
274
|
if (connectionEntry.isOpen) {
|
|
275
|
-
|
|
275
|
+
import_log.log.catch(err, void 0, {
|
|
276
276
|
F: __dxlog_file,
|
|
277
277
|
L: 139,
|
|
278
278
|
S: this,
|
|
@@ -281,7 +281,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
});
|
|
284
|
-
(0,
|
|
284
|
+
(0, import_log.log)("emit peer-candidate", {
|
|
285
285
|
peerId: connection.peerId
|
|
286
286
|
}, {
|
|
287
287
|
F: __dxlog_file,
|
|
@@ -296,7 +296,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
296
296
|
* TODO(y): replace with a proper API call when sharePolicy update becomes supported by automerge-repo
|
|
297
297
|
*/
|
|
298
298
|
_onConnectionAuthScopeChanged(connection) {
|
|
299
|
-
(0,
|
|
299
|
+
(0, import_log.log)("Connection auth scope changed", {
|
|
300
300
|
peerId: connection.peerId
|
|
301
301
|
}, {
|
|
302
302
|
F: __dxlog_file,
|
|
@@ -320,7 +320,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
320
320
|
this._emitPeerCandidate(connection);
|
|
321
321
|
}
|
|
322
322
|
_onConnectionClosed(connection) {
|
|
323
|
-
(0,
|
|
323
|
+
(0, import_log.log)("Connection closed", {
|
|
324
324
|
peerId: connection.peerId
|
|
325
325
|
}, {
|
|
326
326
|
F: __dxlog_file,
|
|
@@ -342,13 +342,13 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
342
342
|
this.emit("peer-disconnected", {
|
|
343
343
|
peerId: connection.peerId
|
|
344
344
|
});
|
|
345
|
-
void entry.reader.cancel().catch((err) =>
|
|
345
|
+
void entry.reader.cancel().catch((err) => import_log.log.catch(err, void 0, {
|
|
346
346
|
F: __dxlog_file,
|
|
347
347
|
L: 168,
|
|
348
348
|
S: this,
|
|
349
349
|
C: (f, a) => f(...a)
|
|
350
350
|
}));
|
|
351
|
-
void entry.writer.abort().catch((err) =>
|
|
351
|
+
void entry.writer.abort().catch((err) => import_log.log.catch(err, void 0, {
|
|
352
352
|
F: __dxlog_file,
|
|
353
353
|
L: 169,
|
|
354
354
|
S: this,
|
|
@@ -620,7 +620,6 @@ var AutomergeHost = class {
|
|
|
620
620
|
this._echoNetworkAdapter = new EchoNetworkAdapter({
|
|
621
621
|
getContainingSpaceForDocument: this._getContainingSpaceForDocument.bind(this)
|
|
622
622
|
});
|
|
623
|
-
this._requestedDocs = /* @__PURE__ */ new Set();
|
|
624
623
|
this._storage = new LevelDBStorageAdapter({
|
|
625
624
|
db,
|
|
626
625
|
callbacks: {
|
|
@@ -676,21 +675,6 @@ var AutomergeHost = class {
|
|
|
676
675
|
if (!documentId) {
|
|
677
676
|
return false;
|
|
678
677
|
}
|
|
679
|
-
const doc = this._repo.handles[documentId]?.docSync();
|
|
680
|
-
if (!doc) {
|
|
681
|
-
const isRequested = this._requestedDocs.has(`automerge:${documentId}`);
|
|
682
|
-
(0, import_log.log)("doc share policy check", {
|
|
683
|
-
peerId,
|
|
684
|
-
documentId,
|
|
685
|
-
isRequested
|
|
686
|
-
}, {
|
|
687
|
-
F: __dxlog_file3,
|
|
688
|
-
L: 143,
|
|
689
|
-
S: this,
|
|
690
|
-
C: (f, a) => f(...a)
|
|
691
|
-
});
|
|
692
|
-
return isRequested;
|
|
693
|
-
}
|
|
694
678
|
const peerMetadata = this.repo.peerMetadataByPeerId[peerId];
|
|
695
679
|
if (peerMetadata?.dxos_peerSource === "EchoNetworkAdapter") {
|
|
696
680
|
return this._echoNetworkAdapter.shouldAdvertize(peerId, {
|
|
@@ -771,7 +755,7 @@ var AutomergeHost = class {
|
|
|
771
755
|
await Promise.all(states?.map(async ({ heads, documentId }) => {
|
|
772
756
|
(0, import_invariant.invariant)(heads, "heads are required for flush", {
|
|
773
757
|
F: __dxlog_file3,
|
|
774
|
-
L:
|
|
758
|
+
L: 223,
|
|
775
759
|
S: this,
|
|
776
760
|
A: [
|
|
777
761
|
"heads",
|
|
@@ -871,7 +855,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
871
855
|
return;
|
|
872
856
|
}
|
|
873
857
|
if (!spaceState.rootUrl) {
|
|
874
|
-
|
|
858
|
+
import_log2.log.error("Database opened with no rootUrl", {
|
|
875
859
|
spaceId: this._spaceId
|
|
876
860
|
}, {
|
|
877
861
|
F: __dxlog_file4,
|
|
@@ -930,7 +914,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
930
914
|
const documentUrl = (spaceRootDoc.links ?? {})[objectId];
|
|
931
915
|
if (documentUrl == null) {
|
|
932
916
|
this._objectsPendingDocumentLoad.add(objectId);
|
|
933
|
-
|
|
917
|
+
import_log2.log.info("loading delayed until object links are initialized", {
|
|
934
918
|
objectId
|
|
935
919
|
}, {
|
|
936
920
|
F: __dxlog_file4,
|
|
@@ -977,7 +961,9 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
977
961
|
""
|
|
978
962
|
]
|
|
979
963
|
});
|
|
980
|
-
const spaceDocHandle = this._repo.create(
|
|
964
|
+
const spaceDocHandle = this._repo.create({
|
|
965
|
+
version: import_echo_protocol.SpaceDocVersion.CURRENT
|
|
966
|
+
});
|
|
981
967
|
this._initDocAccess(spaceDocHandle);
|
|
982
968
|
this.onObjectBoundToDocument(spaceDocHandle, objectId);
|
|
983
969
|
this._spaceRootDocHandle.change((newDoc) => {
|
|
@@ -1008,30 +994,30 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1008
994
|
};
|
|
1009
995
|
const objectDocumentHandle = this._objectDocumentHandles.get(objectId);
|
|
1010
996
|
if (objectDocumentHandle != null && objectDocumentHandle.url !== automergeUrl) {
|
|
1011
|
-
|
|
997
|
+
import_log2.log.warn("object already inlined in a different document, ignoring the link", {
|
|
1012
998
|
...logMeta,
|
|
1013
999
|
actualDocumentUrl: objectDocumentHandle.url
|
|
1014
1000
|
}, {
|
|
1015
1001
|
F: __dxlog_file4,
|
|
1016
|
-
L:
|
|
1002
|
+
L: 159,
|
|
1017
1003
|
S: this,
|
|
1018
1004
|
C: (f, a) => f(...a)
|
|
1019
1005
|
});
|
|
1020
1006
|
continue;
|
|
1021
1007
|
}
|
|
1022
1008
|
if (objectDocumentHandle?.url === automergeUrl) {
|
|
1023
|
-
|
|
1009
|
+
import_log2.log.warn("object document was already loaded", logMeta, {
|
|
1024
1010
|
F: __dxlog_file4,
|
|
1025
|
-
L:
|
|
1011
|
+
L: 166,
|
|
1026
1012
|
S: this,
|
|
1027
1013
|
C: (f, a) => f(...a)
|
|
1028
1014
|
});
|
|
1029
1015
|
continue;
|
|
1030
1016
|
}
|
|
1031
1017
|
const handle = this._repo.find(automergeUrl);
|
|
1032
|
-
|
|
1018
|
+
import_log2.log.debug("document loading triggered", logMeta, {
|
|
1033
1019
|
F: __dxlog_file4,
|
|
1034
|
-
L:
|
|
1020
|
+
L: 170,
|
|
1035
1021
|
S: this,
|
|
1036
1022
|
C: (f, a) => f(...a)
|
|
1037
1023
|
});
|
|
@@ -1049,12 +1035,12 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1049
1035
|
break;
|
|
1050
1036
|
} catch (err) {
|
|
1051
1037
|
if (`${err}`.includes("Timeout")) {
|
|
1052
|
-
|
|
1038
|
+
import_log2.log.info("wraparound", {
|
|
1053
1039
|
id: docHandle.documentId,
|
|
1054
1040
|
state: docHandle.state
|
|
1055
1041
|
}, {
|
|
1056
1042
|
F: __dxlog_file4,
|
|
1057
|
-
L:
|
|
1043
|
+
L: 186,
|
|
1058
1044
|
S: this,
|
|
1059
1045
|
C: (f, a) => f(...a)
|
|
1060
1046
|
});
|
|
@@ -1094,9 +1080,9 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1094
1080
|
docUrl: handle.url
|
|
1095
1081
|
};
|
|
1096
1082
|
if (this.onObjectDocumentLoaded.listenerCount() === 0) {
|
|
1097
|
-
|
|
1083
|
+
import_log2.log.info("document loaded after all listeners were removed", logMeta, {
|
|
1098
1084
|
F: __dxlog_file4,
|
|
1099
|
-
L:
|
|
1085
|
+
L: 222,
|
|
1100
1086
|
S: this,
|
|
1101
1087
|
C: (f, a) => f(...a)
|
|
1102
1088
|
});
|
|
@@ -1104,9 +1090,9 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1104
1090
|
}
|
|
1105
1091
|
const objectDocHandle = this._objectDocumentHandles.get(objectId);
|
|
1106
1092
|
if (objectDocHandle?.url !== handle.url) {
|
|
1107
|
-
|
|
1093
|
+
import_log2.log.warn("object was rebound while a document was loading, discarding handle", logMeta, {
|
|
1108
1094
|
F: __dxlog_file4,
|
|
1109
|
-
L:
|
|
1095
|
+
L: 227,
|
|
1110
1096
|
S: this,
|
|
1111
1097
|
C: (f, a) => f(...a)
|
|
1112
1098
|
});
|
|
@@ -1118,14 +1104,14 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1118
1104
|
});
|
|
1119
1105
|
} catch (err) {
|
|
1120
1106
|
const shouldRetryLoading = this.onObjectDocumentLoaded.listenerCount() > 0;
|
|
1121
|
-
|
|
1107
|
+
import_log2.log.warn("failed to load a document", {
|
|
1122
1108
|
objectId,
|
|
1123
1109
|
automergeUrl: handle.url,
|
|
1124
1110
|
retryLoading: shouldRetryLoading,
|
|
1125
1111
|
err
|
|
1126
1112
|
}, {
|
|
1127
1113
|
F: __dxlog_file4,
|
|
1128
|
-
L:
|
|
1114
|
+
L: 233,
|
|
1129
1115
|
S: this,
|
|
1130
1116
|
C: (f, a) => f(...a)
|
|
1131
1117
|
});
|
|
@@ -1175,7 +1161,7 @@ var MeshEchoReplicator = class {
|
|
|
1175
1161
|
const connection = new MeshReplicatorConnection({
|
|
1176
1162
|
ownPeerId: this._context.peerId,
|
|
1177
1163
|
onRemoteConnected: async () => {
|
|
1178
|
-
(0,
|
|
1164
|
+
(0, import_log3.log)("onRemoteConnected", {
|
|
1179
1165
|
peerId: connection.peerId
|
|
1180
1166
|
}, {
|
|
1181
1167
|
F: __dxlog_file5,
|
|
@@ -1201,7 +1187,7 @@ var MeshEchoReplicator = class {
|
|
|
1201
1187
|
}
|
|
1202
1188
|
},
|
|
1203
1189
|
onRemoteDisconnected: async () => {
|
|
1204
|
-
(0,
|
|
1190
|
+
(0, import_log3.log)("onRemoteDisconnected", {
|
|
1205
1191
|
peerId: connection.peerId
|
|
1206
1192
|
}, {
|
|
1207
1193
|
F: __dxlog_file5,
|
|
@@ -1215,7 +1201,7 @@ var MeshEchoReplicator = class {
|
|
|
1215
1201
|
this._connections.delete(connection);
|
|
1216
1202
|
},
|
|
1217
1203
|
shouldAdvertize: async (params) => {
|
|
1218
|
-
(0,
|
|
1204
|
+
(0, import_log3.log)("shouldAdvertize", {
|
|
1219
1205
|
peerId: connection.peerId,
|
|
1220
1206
|
documentId: params.documentId
|
|
1221
1207
|
}, {
|
|
@@ -1236,7 +1222,7 @@ var MeshEchoReplicator = class {
|
|
|
1236
1222
|
try {
|
|
1237
1223
|
const spaceKey = await this._context.getContainingSpaceForDocument(params.documentId);
|
|
1238
1224
|
if (!spaceKey) {
|
|
1239
|
-
(0,
|
|
1225
|
+
(0, import_log3.log)("space key not found for share policy check", {
|
|
1240
1226
|
peerId: connection.peerId,
|
|
1241
1227
|
documentId: params.documentId
|
|
1242
1228
|
}, {
|
|
@@ -1249,7 +1235,7 @@ var MeshEchoReplicator = class {
|
|
|
1249
1235
|
}
|
|
1250
1236
|
const authorizedDevices = this._authorizedDevices.get(spaceKey);
|
|
1251
1237
|
if (!connection.remoteDeviceKey) {
|
|
1252
|
-
(0,
|
|
1238
|
+
(0, import_log3.log)("device key not found for share policy check", {
|
|
1253
1239
|
peerId: connection.peerId,
|
|
1254
1240
|
documentId: params.documentId
|
|
1255
1241
|
}, {
|
|
@@ -1261,7 +1247,7 @@ var MeshEchoReplicator = class {
|
|
|
1261
1247
|
return false;
|
|
1262
1248
|
}
|
|
1263
1249
|
const isAuthorized = authorizedDevices?.has(connection.remoteDeviceKey) ?? false;
|
|
1264
|
-
(0,
|
|
1250
|
+
(0, import_log3.log)("share policy check", {
|
|
1265
1251
|
localPeer: this._context.peerId,
|
|
1266
1252
|
remotePeer: connection.peerId,
|
|
1267
1253
|
documentId: params.documentId,
|
|
@@ -1276,7 +1262,7 @@ var MeshEchoReplicator = class {
|
|
|
1276
1262
|
});
|
|
1277
1263
|
return isAuthorized;
|
|
1278
1264
|
} catch (err) {
|
|
1279
|
-
|
|
1265
|
+
import_log3.log.catch(err, void 0, {
|
|
1280
1266
|
F: __dxlog_file5,
|
|
1281
1267
|
L: 111,
|
|
1282
1268
|
S: this,
|
|
@@ -1290,7 +1276,7 @@ var MeshEchoReplicator = class {
|
|
|
1290
1276
|
return connection.replicatorExtension;
|
|
1291
1277
|
}
|
|
1292
1278
|
authorizeDevice(spaceKey, deviceKey) {
|
|
1293
|
-
(0,
|
|
1279
|
+
(0, import_log3.log)("authorizeDevice", {
|
|
1294
1280
|
spaceKey,
|
|
1295
1281
|
deviceKey
|
|
1296
1282
|
}, {
|
|
@@ -1300,6 +1286,11 @@ var MeshEchoReplicator = class {
|
|
|
1300
1286
|
C: (f, a) => f(...a)
|
|
1301
1287
|
});
|
|
1302
1288
|
(0, import_util2.defaultMap)(this._authorizedDevices, spaceKey, () => new import_util2.ComplexSet(import_keys2.PublicKey.hash)).add(deviceKey);
|
|
1289
|
+
for (const connection of this._connections) {
|
|
1290
|
+
if (connection.remoteDeviceKey && connection.remoteDeviceKey.equals(deviceKey)) {
|
|
1291
|
+
this._context?.onConnectionAuthScopeChanged(connection);
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1303
1294
|
}
|
|
1304
1295
|
};
|
|
1305
1296
|
var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
@@ -1331,13 +1322,13 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1331
1322
|
onStartReplication: async (info, remotePeerId) => {
|
|
1332
1323
|
this.remoteDeviceKey = remotePeerId;
|
|
1333
1324
|
this._remotePeerId = info.id;
|
|
1334
|
-
(0,
|
|
1325
|
+
(0, import_log3.log)("onStartReplication", {
|
|
1335
1326
|
id: info.id,
|
|
1336
1327
|
thisPeerId: this.peerId,
|
|
1337
1328
|
remotePeerId: remotePeerId.toHex()
|
|
1338
1329
|
}, {
|
|
1339
1330
|
F: __dxlog_file5,
|
|
1340
|
-
L:
|
|
1331
|
+
L: 192,
|
|
1341
1332
|
S: this,
|
|
1342
1333
|
C: (f, a) => f(...a)
|
|
1343
1334
|
});
|
|
@@ -1361,7 +1352,7 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1361
1352
|
get peerId() {
|
|
1362
1353
|
(0, import_invariant5.invariant)(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
1363
1354
|
F: __dxlog_file5,
|
|
1364
|
-
L:
|
|
1355
|
+
L: 215,
|
|
1365
1356
|
S: this,
|
|
1366
1357
|
A: [
|
|
1367
1358
|
"this._remotePeerId != null",
|
|
@@ -1380,7 +1371,7 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1380
1371
|
async enable() {
|
|
1381
1372
|
(0, import_invariant5.invariant)(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
1382
1373
|
F: __dxlog_file5,
|
|
1383
|
-
L:
|
|
1374
|
+
L: 228,
|
|
1384
1375
|
S: this,
|
|
1385
1376
|
A: [
|
|
1386
1377
|
"this._remotePeerId != null",
|