@dxos/echo-pipeline 0.6.0 → 0.6.1-main.04e8aa0
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-HS77A4I4.mjs → chunk-A2LCXJVD.mjs} +16 -1
- package/dist/lib/browser/chunk-A2LCXJVD.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +170 -90
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/node/{chunk-Y5U7UXEL.cjs → chunk-GHBIMYZK.cjs} +19 -4
- package/dist/lib/node/chunk-GHBIMYZK.cjs.map +7 -0
- package/dist/lib/node/index.cjs +214 -136
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +11 -11
- package/dist/types/src/automerge/automerge-host.d.ts +12 -9
- package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
- package/dist/types/src/automerge/echo-network-adapter.d.ts +2 -2
- package/dist/types/src/automerge/echo-network-adapter.d.ts.map +1 -1
- package/dist/types/src/automerge/echo-replicator.d.ts +5 -6
- package/dist/types/src/automerge/echo-replicator.d.ts.map +1 -1
- package/dist/types/src/automerge/heads-store.d.ts +13 -0
- package/dist/types/src/automerge/heads-store.d.ts.map +1 -0
- package/dist/types/src/db-host/data-service.d.ts +4 -2
- package/dist/types/src/db-host/data-service.d.ts.map +1 -1
- package/package.json +33 -33
- package/src/automerge/automerge-doc-loader.ts +1 -1
- package/src/automerge/automerge-host.test.ts +34 -17
- package/src/automerge/automerge-host.ts +56 -16
- package/src/automerge/automerge-repo.test.ts +76 -1
- package/src/automerge/echo-network-adapter.ts +10 -6
- package/src/automerge/echo-replicator.ts +6 -9
- package/src/automerge/heads-store.ts +39 -0
- package/src/automerge/mesh-echo-replicator.ts +5 -5
- package/src/db-host/data-service.ts +22 -2
- package/dist/lib/browser/chunk-HS77A4I4.mjs.map +0 -7
- package/dist/lib/node/chunk-Y5U7UXEL.cjs.map +0 -7
package/dist/lib/node/index.cjs
CHANGED
|
@@ -18,71 +18,74 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var node_exports = {};
|
|
20
20
|
__export(node_exports, {
|
|
21
|
-
AuthExtension: () =>
|
|
22
|
-
AuthStatus: () =>
|
|
21
|
+
AuthExtension: () => import_chunk_GHBIMYZK.AuthExtension,
|
|
22
|
+
AuthStatus: () => import_chunk_GHBIMYZK.AuthStatus,
|
|
23
23
|
AutomergeDocumentLoaderImpl: () => AutomergeDocumentLoaderImpl,
|
|
24
24
|
AutomergeHost: () => AutomergeHost,
|
|
25
|
-
CredentialRetrieverExtension: () =>
|
|
26
|
-
CredentialServerExtension: () =>
|
|
27
|
-
DataServiceImpl: () =>
|
|
25
|
+
CredentialRetrieverExtension: () => import_chunk_GHBIMYZK.CredentialRetrieverExtension,
|
|
26
|
+
CredentialServerExtension: () => import_chunk_GHBIMYZK.CredentialServerExtension,
|
|
27
|
+
DataServiceImpl: () => import_chunk_GHBIMYZK.DataServiceImpl,
|
|
28
28
|
LevelDBStorageAdapter: () => LevelDBStorageAdapter,
|
|
29
29
|
LocalHostNetworkAdapter: () => LocalHostNetworkAdapter,
|
|
30
|
-
MOCK_AUTH_PROVIDER: () =>
|
|
31
|
-
MOCK_AUTH_VERIFIER: () =>
|
|
30
|
+
MOCK_AUTH_PROVIDER: () => import_chunk_GHBIMYZK.MOCK_AUTH_PROVIDER,
|
|
31
|
+
MOCK_AUTH_VERIFIER: () => import_chunk_GHBIMYZK.MOCK_AUTH_VERIFIER,
|
|
32
32
|
MeshEchoReplicator: () => MeshEchoReplicator,
|
|
33
|
-
MetadataStore: () =>
|
|
34
|
-
Pipeline: () =>
|
|
35
|
-
SnapshotManager: () =>
|
|
36
|
-
SnapshotStore: () =>
|
|
37
|
-
Space: () =>
|
|
38
|
-
SpaceManager: () =>
|
|
39
|
-
SpaceProtocol: () =>
|
|
40
|
-
SpaceProtocolSession: () =>
|
|
41
|
-
TimeframeClock: () =>
|
|
42
|
-
codec: () =>
|
|
43
|
-
createIdFromSpaceKey: () =>
|
|
44
|
-
createMappedFeedWriter: () =>
|
|
33
|
+
MetadataStore: () => import_chunk_GHBIMYZK.MetadataStore,
|
|
34
|
+
Pipeline: () => import_chunk_GHBIMYZK.Pipeline,
|
|
35
|
+
SnapshotManager: () => import_chunk_GHBIMYZK.SnapshotManager,
|
|
36
|
+
SnapshotStore: () => import_chunk_GHBIMYZK.SnapshotStore,
|
|
37
|
+
Space: () => import_chunk_GHBIMYZK.Space,
|
|
38
|
+
SpaceManager: () => import_chunk_GHBIMYZK.SpaceManager,
|
|
39
|
+
SpaceProtocol: () => import_chunk_GHBIMYZK.SpaceProtocol,
|
|
40
|
+
SpaceProtocolSession: () => import_chunk_GHBIMYZK.SpaceProtocolSession,
|
|
41
|
+
TimeframeClock: () => import_chunk_GHBIMYZK.TimeframeClock,
|
|
42
|
+
codec: () => import_chunk_GHBIMYZK.codec,
|
|
43
|
+
createIdFromSpaceKey: () => import_chunk_GHBIMYZK.createIdFromSpaceKey,
|
|
44
|
+
createMappedFeedWriter: () => import_chunk_GHBIMYZK.createMappedFeedWriter,
|
|
45
45
|
encodingOptions: () => encodingOptions,
|
|
46
46
|
getSpaceKeyFromDoc: () => getSpaceKeyFromDoc,
|
|
47
|
-
hasInvitationExpired: () =>
|
|
48
|
-
mapFeedIndexesToTimeframe: () =>
|
|
49
|
-
mapTimeframeToFeedIndexes: () =>
|
|
50
|
-
startAfter: () =>
|
|
51
|
-
valueEncoding: () =>
|
|
47
|
+
hasInvitationExpired: () => import_chunk_GHBIMYZK.hasInvitationExpired,
|
|
48
|
+
mapFeedIndexesToTimeframe: () => import_chunk_GHBIMYZK.mapFeedIndexesToTimeframe,
|
|
49
|
+
mapTimeframeToFeedIndexes: () => import_chunk_GHBIMYZK.mapTimeframeToFeedIndexes,
|
|
50
|
+
startAfter: () => import_chunk_GHBIMYZK.startAfter,
|
|
51
|
+
valueEncoding: () => import_chunk_GHBIMYZK.valueEncoding
|
|
52
52
|
});
|
|
53
53
|
module.exports = __toCommonJS(node_exports);
|
|
54
|
-
var
|
|
54
|
+
var import_chunk_GHBIMYZK = require("./chunk-GHBIMYZK.cjs");
|
|
55
55
|
var import_async = require("@dxos/async");
|
|
56
56
|
var import_automerge = require("@dxos/automerge/automerge");
|
|
57
57
|
var import_automerge_repo = require("@dxos/automerge/automerge-repo");
|
|
58
58
|
var import_context = require("@dxos/context");
|
|
59
|
+
var import_invariant = require("@dxos/invariant");
|
|
59
60
|
var import_keys = require("@dxos/keys");
|
|
61
|
+
var import_log = require("@dxos/log");
|
|
60
62
|
var import_protocols = require("@dxos/protocols");
|
|
61
63
|
var import_tracing = require("@dxos/tracing");
|
|
62
64
|
var import_util = require("@dxos/util");
|
|
63
65
|
var import_async2 = require("@dxos/async");
|
|
64
66
|
var import_automerge_repo2 = require("@dxos/automerge/automerge-repo");
|
|
65
67
|
var import_context2 = require("@dxos/context");
|
|
66
|
-
var
|
|
67
|
-
var
|
|
68
|
+
var import_invariant2 = require("@dxos/invariant");
|
|
69
|
+
var import_log2 = require("@dxos/log");
|
|
70
|
+
var import_indexing = require("@dxos/indexing");
|
|
68
71
|
var import_context3 = require("@dxos/context");
|
|
69
72
|
var import_async3 = require("@dxos/async");
|
|
70
73
|
var import_automerge_repo3 = require("@dxos/automerge/automerge-repo");
|
|
71
74
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
72
|
-
var
|
|
75
|
+
var import_invariant3 = require("@dxos/invariant");
|
|
73
76
|
var import_async4 = require("@dxos/async");
|
|
74
77
|
var import_automerge_repo4 = require("@dxos/automerge/automerge-repo");
|
|
75
78
|
var import_context4 = require("@dxos/context");
|
|
76
79
|
var import_debug = require("@dxos/debug");
|
|
77
80
|
var import_echo_protocol = require("@dxos/echo-protocol");
|
|
78
|
-
var
|
|
79
|
-
var
|
|
81
|
+
var import_invariant4 = require("@dxos/invariant");
|
|
82
|
+
var import_log3 = require("@dxos/log");
|
|
80
83
|
var import_tracing2 = require("@dxos/tracing");
|
|
81
84
|
var import_automerge_repo5 = require("@dxos/automerge/automerge-repo");
|
|
82
85
|
var import_context5 = require("@dxos/context");
|
|
83
|
-
var
|
|
86
|
+
var import_invariant5 = require("@dxos/invariant");
|
|
84
87
|
var import_keys2 = require("@dxos/keys");
|
|
85
|
-
var
|
|
88
|
+
var import_log4 = require("@dxos/log");
|
|
86
89
|
var import_teleport_extension_automerge_replicator = require("@dxos/teleport-extension-automerge-replicator");
|
|
87
90
|
var import_util2 = require("@dxos/util");
|
|
88
91
|
function _ts_decorate(decorators, target, key, desc) {
|
|
@@ -117,7 +120,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
117
120
|
}
|
|
118
121
|
connectionEntry.writer.write(message).catch((err) => {
|
|
119
122
|
if (connectionEntry.isOpen) {
|
|
120
|
-
|
|
123
|
+
import_log2.log.catch(err, void 0, {
|
|
121
124
|
F: __dxlog_file,
|
|
122
125
|
L: 49,
|
|
123
126
|
S: this,
|
|
@@ -129,19 +132,13 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
129
132
|
disconnect() {
|
|
130
133
|
}
|
|
131
134
|
async open() {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
S: this,
|
|
136
|
-
A: [
|
|
137
|
-
"this._lifecycleState === LifecycleState.CLOSED",
|
|
138
|
-
""
|
|
139
|
-
]
|
|
140
|
-
});
|
|
135
|
+
if (this._lifecycleState === import_context2.LifecycleState.OPEN) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
141
138
|
this._lifecycleState = import_context2.LifecycleState.OPEN;
|
|
142
|
-
(0,
|
|
139
|
+
(0, import_log2.log)("emit ready", void 0, {
|
|
143
140
|
F: __dxlog_file,
|
|
144
|
-
L:
|
|
141
|
+
L: 65,
|
|
145
142
|
S: this,
|
|
146
143
|
C: (f, a) => f(...a)
|
|
147
144
|
});
|
|
@@ -150,15 +147,9 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
150
147
|
});
|
|
151
148
|
}
|
|
152
149
|
async close() {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
S: this,
|
|
157
|
-
A: [
|
|
158
|
-
"this._lifecycleState === LifecycleState.OPEN",
|
|
159
|
-
""
|
|
160
|
-
]
|
|
161
|
-
});
|
|
150
|
+
if (this._lifecycleState === import_context2.LifecycleState.CLOSED) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
162
153
|
for (const replicator of this._replicators) {
|
|
163
154
|
await replicator.disconnect();
|
|
164
155
|
}
|
|
@@ -171,27 +162,27 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
171
162
|
});
|
|
172
163
|
}
|
|
173
164
|
async addReplicator(replicator) {
|
|
174
|
-
(0,
|
|
165
|
+
(0, import_invariant2.invariant)(this._lifecycleState === import_context2.LifecycleState.OPEN, void 0, {
|
|
175
166
|
F: __dxlog_file,
|
|
176
|
-
L:
|
|
167
|
+
L: 91,
|
|
177
168
|
S: this,
|
|
178
169
|
A: [
|
|
179
170
|
"this._lifecycleState === LifecycleState.OPEN",
|
|
180
171
|
""
|
|
181
172
|
]
|
|
182
173
|
});
|
|
183
|
-
(0,
|
|
174
|
+
(0, import_invariant2.invariant)(this.peerId, void 0, {
|
|
184
175
|
F: __dxlog_file,
|
|
185
|
-
L:
|
|
176
|
+
L: 92,
|
|
186
177
|
S: this,
|
|
187
178
|
A: [
|
|
188
179
|
"this.peerId",
|
|
189
180
|
""
|
|
190
181
|
]
|
|
191
182
|
});
|
|
192
|
-
(0,
|
|
183
|
+
(0, import_invariant2.invariant)(!this._replicators.has(replicator), void 0, {
|
|
193
184
|
F: __dxlog_file,
|
|
194
|
-
L:
|
|
185
|
+
L: 93,
|
|
195
186
|
S: this,
|
|
196
187
|
A: [
|
|
197
188
|
"!this._replicators.has(replicator)",
|
|
@@ -208,18 +199,18 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
208
199
|
});
|
|
209
200
|
}
|
|
210
201
|
async removeReplicator(replicator) {
|
|
211
|
-
(0,
|
|
202
|
+
(0, import_invariant2.invariant)(this._lifecycleState === import_context2.LifecycleState.OPEN, void 0, {
|
|
212
203
|
F: __dxlog_file,
|
|
213
|
-
L:
|
|
204
|
+
L: 107,
|
|
214
205
|
S: this,
|
|
215
206
|
A: [
|
|
216
207
|
"this._lifecycleState === LifecycleState.OPEN",
|
|
217
208
|
""
|
|
218
209
|
]
|
|
219
210
|
});
|
|
220
|
-
(0,
|
|
211
|
+
(0, import_invariant2.invariant)(this._replicators.has(replicator), void 0, {
|
|
221
212
|
F: __dxlog_file,
|
|
222
|
-
L:
|
|
213
|
+
L: 108,
|
|
223
214
|
S: this,
|
|
224
215
|
A: [
|
|
225
216
|
"this._replicators.has(replicator)",
|
|
@@ -234,20 +225,20 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
234
225
|
if (!connection) {
|
|
235
226
|
return false;
|
|
236
227
|
}
|
|
237
|
-
return connection.connection.
|
|
228
|
+
return connection.connection.shouldAdvertise(params);
|
|
238
229
|
}
|
|
239
230
|
_onConnectionOpen(connection) {
|
|
240
|
-
(0,
|
|
231
|
+
(0, import_log2.log)("Connection opened", {
|
|
241
232
|
peerId: connection.peerId
|
|
242
233
|
}, {
|
|
243
234
|
F: __dxlog_file,
|
|
244
|
-
L:
|
|
235
|
+
L: 123,
|
|
245
236
|
S: this,
|
|
246
237
|
C: (f, a) => f(...a)
|
|
247
238
|
});
|
|
248
|
-
(0,
|
|
239
|
+
(0, import_invariant2.invariant)(!this._connections.has(connection.peerId), void 0, {
|
|
249
240
|
F: __dxlog_file,
|
|
250
|
-
L:
|
|
241
|
+
L: 124,
|
|
251
242
|
S: this,
|
|
252
243
|
A: [
|
|
253
244
|
"!this._connections.has(connection.peerId as PeerId)",
|
|
@@ -274,20 +265,20 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
274
265
|
}
|
|
275
266
|
} catch (err) {
|
|
276
267
|
if (connectionEntry.isOpen) {
|
|
277
|
-
|
|
268
|
+
import_log2.log.catch(err, void 0, {
|
|
278
269
|
F: __dxlog_file,
|
|
279
|
-
L:
|
|
270
|
+
L: 143,
|
|
280
271
|
S: this,
|
|
281
272
|
C: (f, a) => f(...a)
|
|
282
273
|
});
|
|
283
274
|
}
|
|
284
275
|
}
|
|
285
276
|
});
|
|
286
|
-
(0,
|
|
277
|
+
(0, import_log2.log)("emit peer-candidate", {
|
|
287
278
|
peerId: connection.peerId
|
|
288
279
|
}, {
|
|
289
280
|
F: __dxlog_file,
|
|
290
|
-
L:
|
|
281
|
+
L: 148,
|
|
291
282
|
S: this,
|
|
292
283
|
C: (f, a) => f(...a)
|
|
293
284
|
});
|
|
@@ -298,18 +289,18 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
298
289
|
* TODO(y): replace with a proper API call when sharePolicy update becomes supported by automerge-repo
|
|
299
290
|
*/
|
|
300
291
|
_onConnectionAuthScopeChanged(connection) {
|
|
301
|
-
(0,
|
|
292
|
+
(0, import_log2.log)("Connection auth scope changed", {
|
|
302
293
|
peerId: connection.peerId
|
|
303
294
|
}, {
|
|
304
295
|
F: __dxlog_file,
|
|
305
|
-
L:
|
|
296
|
+
L: 157,
|
|
306
297
|
S: this,
|
|
307
298
|
C: (f, a) => f(...a)
|
|
308
299
|
});
|
|
309
300
|
const entry = this._connections.get(connection.peerId);
|
|
310
|
-
(0,
|
|
301
|
+
(0, import_invariant2.invariant)(entry, void 0, {
|
|
311
302
|
F: __dxlog_file,
|
|
312
|
-
L:
|
|
303
|
+
L: 159,
|
|
313
304
|
S: this,
|
|
314
305
|
A: [
|
|
315
306
|
"entry",
|
|
@@ -322,18 +313,18 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
322
313
|
this._emitPeerCandidate(connection);
|
|
323
314
|
}
|
|
324
315
|
_onConnectionClosed(connection) {
|
|
325
|
-
(0,
|
|
316
|
+
(0, import_log2.log)("Connection closed", {
|
|
326
317
|
peerId: connection.peerId
|
|
327
318
|
}, {
|
|
328
319
|
F: __dxlog_file,
|
|
329
|
-
L:
|
|
320
|
+
L: 165,
|
|
330
321
|
S: this,
|
|
331
322
|
C: (f, a) => f(...a)
|
|
332
323
|
});
|
|
333
324
|
const entry = this._connections.get(connection.peerId);
|
|
334
|
-
(0,
|
|
325
|
+
(0, import_invariant2.invariant)(entry, void 0, {
|
|
335
326
|
F: __dxlog_file,
|
|
336
|
-
L:
|
|
327
|
+
L: 167,
|
|
337
328
|
S: this,
|
|
338
329
|
A: [
|
|
339
330
|
"entry",
|
|
@@ -344,15 +335,15 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
344
335
|
this.emit("peer-disconnected", {
|
|
345
336
|
peerId: connection.peerId
|
|
346
337
|
});
|
|
347
|
-
void entry.reader.cancel().catch((err) =>
|
|
338
|
+
void entry.reader.cancel().catch((err) => import_log2.log.catch(err, void 0, {
|
|
348
339
|
F: __dxlog_file,
|
|
349
|
-
L:
|
|
340
|
+
L: 172,
|
|
350
341
|
S: this,
|
|
351
342
|
C: (f, a) => f(...a)
|
|
352
343
|
}));
|
|
353
|
-
void entry.writer.abort().catch((err) =>
|
|
344
|
+
void entry.writer.abort().catch((err) => import_log2.log.catch(err, void 0, {
|
|
354
345
|
F: __dxlog_file,
|
|
355
|
-
L:
|
|
346
|
+
L: 173,
|
|
356
347
|
S: this,
|
|
357
348
|
C: (f, a) => f(...a)
|
|
358
349
|
}));
|
|
@@ -382,6 +373,31 @@ var createEchoPeerMetadata = () => ({
|
|
|
382
373
|
dxos_peerSource: "EchoNetworkAdapter"
|
|
383
374
|
});
|
|
384
375
|
var isEchoPeerMetadata = (metadata) => metadata?.dxos_peerSource === "EchoNetworkAdapter";
|
|
376
|
+
var HeadsStore = class {
|
|
377
|
+
constructor({ db }) {
|
|
378
|
+
this._db = db;
|
|
379
|
+
}
|
|
380
|
+
setHeads(documentId, heads, batch) {
|
|
381
|
+
batch.put(documentId, heads, {
|
|
382
|
+
sublevel: this._db,
|
|
383
|
+
keyEncoding: "utf8",
|
|
384
|
+
valueEncoding: import_indexing.headsEncoding
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
async getHeads(documentId) {
|
|
388
|
+
try {
|
|
389
|
+
return await this._db.get(documentId, {
|
|
390
|
+
keyEncoding: "utf8",
|
|
391
|
+
valueEncoding: import_indexing.headsEncoding
|
|
392
|
+
});
|
|
393
|
+
} catch (err) {
|
|
394
|
+
if (err.notFound) {
|
|
395
|
+
return void 0;
|
|
396
|
+
}
|
|
397
|
+
throw err;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
};
|
|
385
401
|
var LevelDBStorageAdapter = class extends import_context3.Resource {
|
|
386
402
|
constructor(_params) {
|
|
387
403
|
super();
|
|
@@ -503,7 +519,7 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo3.NetworkAdapte
|
|
|
503
519
|
}
|
|
504
520
|
send(message) {
|
|
505
521
|
const peer = this._peers.get(message.targetId);
|
|
506
|
-
(0,
|
|
522
|
+
(0, import_invariant3.invariant)(peer, "Peer not found.", {
|
|
507
523
|
F: __dxlog_file2,
|
|
508
524
|
L: 51,
|
|
509
525
|
S: this,
|
|
@@ -528,7 +544,7 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo3.NetworkAdapte
|
|
|
528
544
|
syncRepo({ id, syncMessage }) {
|
|
529
545
|
const peerId = this._getPeerId(id);
|
|
530
546
|
return new import_codec_protobuf.Stream(({ next, close }) => {
|
|
531
|
-
(0,
|
|
547
|
+
(0, import_invariant3.invariant)(!this._peers.has(peerId), "Peer already connected.", {
|
|
532
548
|
F: __dxlog_file2,
|
|
533
549
|
L: 73,
|
|
534
550
|
S: this,
|
|
@@ -552,7 +568,7 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo3.NetworkAdapte
|
|
|
552
568
|
});
|
|
553
569
|
}
|
|
554
570
|
});
|
|
555
|
-
(0,
|
|
571
|
+
(0, import_invariant3.invariant)(this._isConnected, void 0, {
|
|
556
572
|
F: __dxlog_file2,
|
|
557
573
|
L: 90,
|
|
558
574
|
S: this,
|
|
@@ -568,7 +584,7 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo3.NetworkAdapte
|
|
|
568
584
|
});
|
|
569
585
|
}
|
|
570
586
|
async sendSyncMessage({ id, syncMessage }) {
|
|
571
|
-
(0,
|
|
587
|
+
(0, import_invariant3.invariant)(this._isConnected, void 0, {
|
|
572
588
|
F: __dxlog_file2,
|
|
573
589
|
L: 99,
|
|
574
590
|
S: this,
|
|
@@ -581,7 +597,7 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo3.NetworkAdapte
|
|
|
581
597
|
this.emit("message", message);
|
|
582
598
|
}
|
|
583
599
|
async getHostInfo() {
|
|
584
|
-
(0,
|
|
600
|
+
(0, import_invariant3.invariant)(this._isConnected, void 0, {
|
|
585
601
|
F: __dxlog_file2,
|
|
586
602
|
L: 105,
|
|
587
603
|
S: this,
|
|
@@ -590,7 +606,7 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo3.NetworkAdapte
|
|
|
590
606
|
""
|
|
591
607
|
]
|
|
592
608
|
});
|
|
593
|
-
(0,
|
|
609
|
+
(0, import_invariant3.invariant)(this.peerId, "Peer id not set.", {
|
|
594
610
|
F: __dxlog_file2,
|
|
595
611
|
L: 106,
|
|
596
612
|
S: this,
|
|
@@ -618,25 +634,26 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
618
634
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
619
635
|
}
|
|
620
636
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
|
|
621
|
-
var AutomergeHost = class {
|
|
637
|
+
var AutomergeHost = class extends import_context.Resource {
|
|
622
638
|
constructor({ db, indexMetadataStore }) {
|
|
623
|
-
|
|
624
|
-
F: __dxlog_file3,
|
|
625
|
-
L: 71
|
|
626
|
-
});
|
|
639
|
+
super();
|
|
627
640
|
this._echoNetworkAdapter = new EchoNetworkAdapter({
|
|
628
641
|
getContainingSpaceForDocument: this._getContainingSpaceForDocument.bind(this)
|
|
629
642
|
});
|
|
643
|
+
this._db = db;
|
|
630
644
|
this._storage = new LevelDBStorageAdapter({
|
|
631
|
-
db,
|
|
645
|
+
db: db.sublevel("automerge"),
|
|
632
646
|
callbacks: {
|
|
633
647
|
beforeSave: async (params) => this._beforeSave(params),
|
|
634
648
|
afterSave: async () => this._afterSave()
|
|
635
649
|
}
|
|
636
650
|
});
|
|
651
|
+
this._headsStore = new HeadsStore({
|
|
652
|
+
db: db.sublevel("heads")
|
|
653
|
+
});
|
|
637
654
|
this._indexMetadataStore = indexMetadataStore;
|
|
638
655
|
}
|
|
639
|
-
async
|
|
656
|
+
async _open() {
|
|
640
657
|
this._peerId = `host-${import_keys.PublicKey.random().toHex()}`;
|
|
641
658
|
await this._storage.open?.();
|
|
642
659
|
this._clientNetwork = new LocalHostNetworkAdapter();
|
|
@@ -656,7 +673,7 @@ var AutomergeHost = class {
|
|
|
656
673
|
await this._clientNetwork.whenConnected();
|
|
657
674
|
await this._echoNetworkAdapter.whenConnected();
|
|
658
675
|
}
|
|
659
|
-
async
|
|
676
|
+
async _close() {
|
|
660
677
|
await this._storage.close?.();
|
|
661
678
|
await this._clientNetwork.close();
|
|
662
679
|
await this._echoNetworkAdapter.close();
|
|
@@ -707,6 +724,56 @@ var AutomergeHost = class {
|
|
|
707
724
|
return this._repo.create(initialValue);
|
|
708
725
|
}
|
|
709
726
|
}
|
|
727
|
+
async reIndexHeads(documentIds) {
|
|
728
|
+
for (const documentId of documentIds) {
|
|
729
|
+
import_log.log.info("reindexing heads for document", {
|
|
730
|
+
documentId
|
|
731
|
+
}, {
|
|
732
|
+
F: __dxlog_file3,
|
|
733
|
+
L: 191,
|
|
734
|
+
S: this,
|
|
735
|
+
C: (f, a) => f(...a)
|
|
736
|
+
});
|
|
737
|
+
const handle = this._repo.find(documentId);
|
|
738
|
+
await handle.whenReady([
|
|
739
|
+
"ready",
|
|
740
|
+
"requesting"
|
|
741
|
+
]);
|
|
742
|
+
if (handle.inState([
|
|
743
|
+
"requesting"
|
|
744
|
+
])) {
|
|
745
|
+
import_log.log.warn("document is not available locally, skipping", {
|
|
746
|
+
documentId
|
|
747
|
+
}, {
|
|
748
|
+
F: __dxlog_file3,
|
|
749
|
+
L: 195,
|
|
750
|
+
S: this,
|
|
751
|
+
C: (f, a) => f(...a)
|
|
752
|
+
});
|
|
753
|
+
continue;
|
|
754
|
+
}
|
|
755
|
+
const doc = handle.docSync();
|
|
756
|
+
(0, import_invariant.invariant)(doc, void 0, {
|
|
757
|
+
F: __dxlog_file3,
|
|
758
|
+
L: 200,
|
|
759
|
+
S: this,
|
|
760
|
+
A: [
|
|
761
|
+
"doc",
|
|
762
|
+
""
|
|
763
|
+
]
|
|
764
|
+
});
|
|
765
|
+
const heads = (0, import_automerge.getHeads)(doc);
|
|
766
|
+
const batch = this._db.batch();
|
|
767
|
+
this._headsStore.setHeads(documentId, heads, batch);
|
|
768
|
+
await batch.write();
|
|
769
|
+
}
|
|
770
|
+
import_log.log.info("done reindexing heads", void 0, {
|
|
771
|
+
F: __dxlog_file3,
|
|
772
|
+
L: 207,
|
|
773
|
+
S: this,
|
|
774
|
+
C: (f, a) => f(...a)
|
|
775
|
+
});
|
|
776
|
+
}
|
|
710
777
|
// TODO(dmaretskyi): Share based on HALO permissions and space affinity.
|
|
711
778
|
// Hosts, running in the worker, don't share documents unless requested by other peers.
|
|
712
779
|
// NOTE: If both peers return sharePolicy=false the replication will not happen
|
|
@@ -736,7 +803,8 @@ var AutomergeHost = class {
|
|
|
736
803
|
return;
|
|
737
804
|
}
|
|
738
805
|
const spaceKey = getSpaceKeyFromDoc(doc) ?? void 0;
|
|
739
|
-
const
|
|
806
|
+
const heads = (0, import_automerge.getHeads)(doc);
|
|
807
|
+
this._headsStore.setHeads(handle.documentId, heads, batch);
|
|
740
808
|
const objectIds = Object.keys(doc.objects ?? {});
|
|
741
809
|
const encodedIds = objectIds.map((objectId) => import_protocols.objectPointerCodec.encode({
|
|
742
810
|
documentId: handle.documentId,
|
|
@@ -745,7 +813,7 @@ var AutomergeHost = class {
|
|
|
745
813
|
}));
|
|
746
814
|
const idToLastHash = new Map(encodedIds.map((id) => [
|
|
747
815
|
id,
|
|
748
|
-
|
|
816
|
+
heads
|
|
749
817
|
]));
|
|
750
818
|
this._indexMetadataStore.markDirty(idToLastHash, batch);
|
|
751
819
|
}
|
|
@@ -794,18 +862,30 @@ var AutomergeHost = class {
|
|
|
794
862
|
/**
|
|
795
863
|
* Flush documents to disk.
|
|
796
864
|
*/
|
|
797
|
-
async flush({ states }) {
|
|
865
|
+
async flush({ states } = {}) {
|
|
798
866
|
if (states) {
|
|
799
867
|
await Promise.all(states.map(async ({ heads, documentId }) => {
|
|
800
868
|
if (!heads) {
|
|
801
869
|
return;
|
|
802
870
|
}
|
|
803
|
-
const handle = this.
|
|
871
|
+
const handle = this._repo.handles[documentId] ?? this._repo.find(documentId);
|
|
804
872
|
await waitForHeads(handle, heads);
|
|
805
873
|
}) ?? []);
|
|
806
874
|
}
|
|
807
875
|
await this._repo.flush(states?.map(({ documentId }) => documentId));
|
|
808
876
|
}
|
|
877
|
+
async getHeads(documentId) {
|
|
878
|
+
const handle = this._repo.handles[documentId];
|
|
879
|
+
if (handle) {
|
|
880
|
+
const doc = handle.docSync();
|
|
881
|
+
if (!doc) {
|
|
882
|
+
return void 0;
|
|
883
|
+
}
|
|
884
|
+
return (0, import_automerge.getHeads)(doc);
|
|
885
|
+
} else {
|
|
886
|
+
return this._headsStore.getHeads(documentId);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
809
889
|
/**
|
|
810
890
|
* Host <-> Client sync.
|
|
811
891
|
*/
|
|
@@ -907,7 +987,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
907
987
|
}
|
|
908
988
|
const existingDocHandle = await this._initDocHandle(ctx, spaceState.rootUrl);
|
|
909
989
|
const doc = existingDocHandle.docSync();
|
|
910
|
-
(0,
|
|
990
|
+
(0, import_invariant4.invariant)(doc, void 0, {
|
|
911
991
|
F: __dxlog_file4,
|
|
912
992
|
L: 84,
|
|
913
993
|
S: this,
|
|
@@ -916,7 +996,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
916
996
|
""
|
|
917
997
|
]
|
|
918
998
|
});
|
|
919
|
-
(0,
|
|
999
|
+
(0, import_invariant4.invariant)(doc.version === import_echo_protocol.SpaceDocVersion.CURRENT, void 0, {
|
|
920
1000
|
F: __dxlog_file4,
|
|
921
1001
|
L: 85,
|
|
922
1002
|
S: this,
|
|
@@ -937,7 +1017,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
937
1017
|
let hasUrlsToLoad = false;
|
|
938
1018
|
const urlsToLoad = {};
|
|
939
1019
|
for (const objectId of objectIds) {
|
|
940
|
-
(0,
|
|
1020
|
+
(0, import_invariant4.invariant)(this._spaceRootDocHandle, void 0, {
|
|
941
1021
|
F: __dxlog_file4,
|
|
942
1022
|
L: 97,
|
|
943
1023
|
S: this,
|
|
@@ -950,7 +1030,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
950
1030
|
continue;
|
|
951
1031
|
}
|
|
952
1032
|
const spaceRootDoc = this._spaceRootDocHandle.docSync();
|
|
953
|
-
(0,
|
|
1033
|
+
(0, import_invariant4.invariant)(spaceRootDoc, void 0, {
|
|
954
1034
|
F: __dxlog_file4,
|
|
955
1035
|
L: 102,
|
|
956
1036
|
S: this,
|
|
@@ -962,7 +1042,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
962
1042
|
const documentUrl = (spaceRootDoc.links ?? {})[objectId];
|
|
963
1043
|
if (documentUrl == null) {
|
|
964
1044
|
this._objectsPendingDocumentLoad.add(objectId);
|
|
965
|
-
|
|
1045
|
+
import_log3.log.info("loading delayed until object links are initialized", {
|
|
966
1046
|
objectId
|
|
967
1047
|
}, {
|
|
968
1048
|
F: __dxlog_file4,
|
|
@@ -980,7 +1060,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
980
1060
|
}
|
|
981
1061
|
}
|
|
982
1062
|
getObjectDocumentId(objectId) {
|
|
983
|
-
(0,
|
|
1063
|
+
(0, import_invariant4.invariant)(this._spaceRootDocHandle, void 0, {
|
|
984
1064
|
F: __dxlog_file4,
|
|
985
1065
|
L: 118,
|
|
986
1066
|
S: this,
|
|
@@ -990,7 +1070,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
990
1070
|
]
|
|
991
1071
|
});
|
|
992
1072
|
const spaceRootDoc = this._spaceRootDocHandle.docSync();
|
|
993
|
-
(0,
|
|
1073
|
+
(0, import_invariant4.invariant)(spaceRootDoc, void 0, {
|
|
994
1074
|
F: __dxlog_file4,
|
|
995
1075
|
L: 120,
|
|
996
1076
|
S: this,
|
|
@@ -1014,7 +1094,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1014
1094
|
linksAwaitingLoad.forEach(([objectId]) => this._objectsPendingDocumentLoad.delete(objectId));
|
|
1015
1095
|
}
|
|
1016
1096
|
getSpaceRootDocHandle() {
|
|
1017
|
-
(0,
|
|
1097
|
+
(0, import_invariant4.invariant)(this._spaceRootDocHandle, void 0, {
|
|
1018
1098
|
F: __dxlog_file4,
|
|
1019
1099
|
L: 140,
|
|
1020
1100
|
S: this,
|
|
@@ -1026,7 +1106,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1026
1106
|
return this._spaceRootDocHandle;
|
|
1027
1107
|
}
|
|
1028
1108
|
createDocumentForObject(objectId) {
|
|
1029
|
-
(0,
|
|
1109
|
+
(0, import_invariant4.invariant)(this._spaceRootDocHandle, void 0, {
|
|
1030
1110
|
F: __dxlog_file4,
|
|
1031
1111
|
L: 145,
|
|
1032
1112
|
S: this,
|
|
@@ -1068,7 +1148,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1068
1148
|
};
|
|
1069
1149
|
const objectDocumentHandle = this._objectDocumentHandles.get(objectId);
|
|
1070
1150
|
if (objectDocumentHandle != null && objectDocumentHandle.url !== automergeUrl) {
|
|
1071
|
-
|
|
1151
|
+
import_log3.log.warn("object already inlined in a different document, ignoring the link", {
|
|
1072
1152
|
...logMeta,
|
|
1073
1153
|
actualDocumentUrl: objectDocumentHandle.url
|
|
1074
1154
|
}, {
|
|
@@ -1080,7 +1160,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1080
1160
|
continue;
|
|
1081
1161
|
}
|
|
1082
1162
|
if (objectDocumentHandle?.url === automergeUrl) {
|
|
1083
|
-
|
|
1163
|
+
import_log3.log.warn("object document was already loaded", logMeta, {
|
|
1084
1164
|
F: __dxlog_file4,
|
|
1085
1165
|
L: 184,
|
|
1086
1166
|
S: this,
|
|
@@ -1089,7 +1169,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1089
1169
|
continue;
|
|
1090
1170
|
}
|
|
1091
1171
|
const handle = this._repo.find(automergeUrl);
|
|
1092
|
-
|
|
1172
|
+
import_log3.log.debug("document loading triggered", logMeta, {
|
|
1093
1173
|
F: __dxlog_file4,
|
|
1094
1174
|
L: 188,
|
|
1095
1175
|
S: this,
|
|
@@ -1109,7 +1189,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1109
1189
|
break;
|
|
1110
1190
|
} catch (err) {
|
|
1111
1191
|
if (`${err}`.includes("Timeout")) {
|
|
1112
|
-
|
|
1192
|
+
import_log3.log.info("wraparound", {
|
|
1113
1193
|
id: docHandle.documentId,
|
|
1114
1194
|
state: docHandle.state
|
|
1115
1195
|
}, {
|
|
@@ -1138,15 +1218,13 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1138
1218
|
}
|
|
1139
1219
|
async _createObjectOnDocumentLoad(handle, objectId) {
|
|
1140
1220
|
try {
|
|
1141
|
-
await handle.
|
|
1142
|
-
"ready"
|
|
1143
|
-
]);
|
|
1221
|
+
await handle.whenReady();
|
|
1144
1222
|
const logMeta = {
|
|
1145
1223
|
objectId,
|
|
1146
1224
|
docUrl: handle.url
|
|
1147
1225
|
};
|
|
1148
1226
|
if (this.onObjectDocumentLoaded.listenerCount() === 0) {
|
|
1149
|
-
|
|
1227
|
+
import_log3.log.info("document loaded after all listeners were removed", logMeta, {
|
|
1150
1228
|
F: __dxlog_file4,
|
|
1151
1229
|
L: 231,
|
|
1152
1230
|
S: this,
|
|
@@ -1156,7 +1234,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1156
1234
|
}
|
|
1157
1235
|
const objectDocHandle = this._objectDocumentHandles.get(objectId);
|
|
1158
1236
|
if (objectDocHandle?.url !== handle.url) {
|
|
1159
|
-
|
|
1237
|
+
import_log3.log.warn("object was rebound while a document was loading, discarding handle", logMeta, {
|
|
1160
1238
|
F: __dxlog_file4,
|
|
1161
1239
|
L: 236,
|
|
1162
1240
|
S: this,
|
|
@@ -1170,7 +1248,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1170
1248
|
});
|
|
1171
1249
|
} catch (err) {
|
|
1172
1250
|
const shouldRetryLoading = this.onObjectDocumentLoaded.listenerCount() > 0;
|
|
1173
|
-
|
|
1251
|
+
import_log3.log.warn("failed to load a document", {
|
|
1174
1252
|
objectId,
|
|
1175
1253
|
automergeUrl: handle.url,
|
|
1176
1254
|
retryLoading: shouldRetryLoading,
|
|
@@ -1215,7 +1293,7 @@ var MeshEchoReplicator = class {
|
|
|
1215
1293
|
this._context = null;
|
|
1216
1294
|
}
|
|
1217
1295
|
createExtension() {
|
|
1218
|
-
(0,
|
|
1296
|
+
(0, import_invariant5.invariant)(this._context, void 0, {
|
|
1219
1297
|
F: __dxlog_file5,
|
|
1220
1298
|
L: 54,
|
|
1221
1299
|
S: this,
|
|
@@ -1227,7 +1305,7 @@ var MeshEchoReplicator = class {
|
|
|
1227
1305
|
const connection = new MeshReplicatorConnection({
|
|
1228
1306
|
ownPeerId: this._context.peerId,
|
|
1229
1307
|
onRemoteConnected: async () => {
|
|
1230
|
-
(0,
|
|
1308
|
+
(0, import_log4.log)("onRemoteConnected", {
|
|
1231
1309
|
peerId: connection.peerId
|
|
1232
1310
|
}, {
|
|
1233
1311
|
F: __dxlog_file5,
|
|
@@ -1235,7 +1313,7 @@ var MeshEchoReplicator = class {
|
|
|
1235
1313
|
S: this,
|
|
1236
1314
|
C: (f, a) => f(...a)
|
|
1237
1315
|
});
|
|
1238
|
-
(0,
|
|
1316
|
+
(0, import_invariant5.invariant)(this._context, void 0, {
|
|
1239
1317
|
F: __dxlog_file5,
|
|
1240
1318
|
L: 60,
|
|
1241
1319
|
S: this,
|
|
@@ -1253,7 +1331,7 @@ var MeshEchoReplicator = class {
|
|
|
1253
1331
|
}
|
|
1254
1332
|
},
|
|
1255
1333
|
onRemoteDisconnected: async () => {
|
|
1256
|
-
(0,
|
|
1334
|
+
(0, import_log4.log)("onRemoteDisconnected", {
|
|
1257
1335
|
peerId: connection.peerId
|
|
1258
1336
|
}, {
|
|
1259
1337
|
F: __dxlog_file5,
|
|
@@ -1267,7 +1345,7 @@ var MeshEchoReplicator = class {
|
|
|
1267
1345
|
this._connections.delete(connection);
|
|
1268
1346
|
},
|
|
1269
1347
|
shouldAdvertize: async (params) => {
|
|
1270
|
-
(0,
|
|
1348
|
+
(0, import_log4.log)("shouldAdvertize", {
|
|
1271
1349
|
peerId: connection.peerId,
|
|
1272
1350
|
documentId: params.documentId
|
|
1273
1351
|
}, {
|
|
@@ -1276,7 +1354,7 @@ var MeshEchoReplicator = class {
|
|
|
1276
1354
|
S: this,
|
|
1277
1355
|
C: (f, a) => f(...a)
|
|
1278
1356
|
});
|
|
1279
|
-
(0,
|
|
1357
|
+
(0, import_invariant5.invariant)(this._context, void 0, {
|
|
1280
1358
|
F: __dxlog_file5,
|
|
1281
1359
|
L: 79,
|
|
1282
1360
|
S: this,
|
|
@@ -1288,7 +1366,7 @@ var MeshEchoReplicator = class {
|
|
|
1288
1366
|
try {
|
|
1289
1367
|
const spaceKey = await this._context.getContainingSpaceForDocument(params.documentId);
|
|
1290
1368
|
if (!spaceKey) {
|
|
1291
|
-
(0,
|
|
1369
|
+
(0, import_log4.log)("space key not found for share policy check", {
|
|
1292
1370
|
peerId: connection.peerId,
|
|
1293
1371
|
documentId: params.documentId
|
|
1294
1372
|
}, {
|
|
@@ -1301,7 +1379,7 @@ var MeshEchoReplicator = class {
|
|
|
1301
1379
|
}
|
|
1302
1380
|
const authorizedDevices = this._authorizedDevices.get(spaceKey);
|
|
1303
1381
|
if (!connection.remoteDeviceKey) {
|
|
1304
|
-
(0,
|
|
1382
|
+
(0, import_log4.log)("device key not found for share policy check", {
|
|
1305
1383
|
peerId: connection.peerId,
|
|
1306
1384
|
documentId: params.documentId
|
|
1307
1385
|
}, {
|
|
@@ -1313,7 +1391,7 @@ var MeshEchoReplicator = class {
|
|
|
1313
1391
|
return false;
|
|
1314
1392
|
}
|
|
1315
1393
|
const isAuthorized = authorizedDevices?.has(connection.remoteDeviceKey) ?? false;
|
|
1316
|
-
(0,
|
|
1394
|
+
(0, import_log4.log)("share policy check", {
|
|
1317
1395
|
localPeer: this._context.peerId,
|
|
1318
1396
|
remotePeer: connection.peerId,
|
|
1319
1397
|
documentId: params.documentId,
|
|
@@ -1328,7 +1406,7 @@ var MeshEchoReplicator = class {
|
|
|
1328
1406
|
});
|
|
1329
1407
|
return isAuthorized;
|
|
1330
1408
|
} catch (err) {
|
|
1331
|
-
|
|
1409
|
+
import_log4.log.catch(err, void 0, {
|
|
1332
1410
|
F: __dxlog_file5,
|
|
1333
1411
|
L: 111,
|
|
1334
1412
|
S: this,
|
|
@@ -1342,7 +1420,7 @@ var MeshEchoReplicator = class {
|
|
|
1342
1420
|
return connection.replicatorExtension;
|
|
1343
1421
|
}
|
|
1344
1422
|
authorizeDevice(spaceKey, deviceKey) {
|
|
1345
|
-
(0,
|
|
1423
|
+
(0, import_log4.log)("authorizeDevice", {
|
|
1346
1424
|
spaceKey,
|
|
1347
1425
|
deviceKey
|
|
1348
1426
|
}, {
|
|
@@ -1388,7 +1466,7 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1388
1466
|
onStartReplication: async (info, remotePeerId) => {
|
|
1389
1467
|
this.remoteDeviceKey = remotePeerId;
|
|
1390
1468
|
this._remotePeerId = info.id;
|
|
1391
|
-
(0,
|
|
1469
|
+
(0, import_log4.log)("onStartReplication", {
|
|
1392
1470
|
id: info.id,
|
|
1393
1471
|
thisPeerId: this.peerId,
|
|
1394
1472
|
remotePeerId: remotePeerId.toHex()
|
|
@@ -1416,7 +1494,7 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1416
1494
|
});
|
|
1417
1495
|
}
|
|
1418
1496
|
get peerId() {
|
|
1419
|
-
(0,
|
|
1497
|
+
(0, import_invariant5.invariant)(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
1420
1498
|
F: __dxlog_file5,
|
|
1421
1499
|
L: 215,
|
|
1422
1500
|
S: this,
|
|
@@ -1427,7 +1505,7 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1427
1505
|
});
|
|
1428
1506
|
return this._remotePeerId;
|
|
1429
1507
|
}
|
|
1430
|
-
async
|
|
1508
|
+
async shouldAdvertise(params) {
|
|
1431
1509
|
return this._params.shouldAdvertize(params);
|
|
1432
1510
|
}
|
|
1433
1511
|
/**
|
|
@@ -1435,7 +1513,7 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1435
1513
|
* Call after the remote peer has connected.
|
|
1436
1514
|
*/
|
|
1437
1515
|
async enable() {
|
|
1438
|
-
(0,
|
|
1516
|
+
(0, import_invariant5.invariant)(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
1439
1517
|
F: __dxlog_file5,
|
|
1440
1518
|
L: 228,
|
|
1441
1519
|
S: this,
|