@dxos/echo-pipeline 0.5.8 → 0.5.9-main.079a532
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-GANAND63.mjs → chunk-I2J5TTHJ.mjs} +48 -23
- package/dist/lib/browser/{chunk-GANAND63.mjs.map → chunk-I2J5TTHJ.mjs.map} +3 -3
- package/dist/lib/browser/index.mjs +152 -230
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +99 -4
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node/{chunk-M475BGBI.cjs → chunk-QPCNQ4ZK.cjs} +51 -25
- package/dist/lib/node/chunk-QPCNQ4ZK.cjs.map +7 -0
- package/dist/lib/node/index.cjs +174 -247
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +107 -13
- package/dist/lib/node/testing/index.cjs.map +4 -4
- package/dist/types/src/automerge/automerge-doc-loader.d.ts +7 -3
- package/dist/types/src/automerge/automerge-doc-loader.d.ts.map +1 -1
- package/dist/types/src/automerge/automerge-host.d.ts +1 -8
- package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
- package/dist/types/src/automerge/echo-network-adapter.d.ts +6 -0
- package/dist/types/src/automerge/echo-network-adapter.d.ts.map +1 -1
- package/dist/types/src/automerge/echo-replicator.d.ts +1 -0
- package/dist/types/src/automerge/echo-replicator.d.ts.map +1 -1
- package/dist/types/src/automerge/index.d.ts +0 -1
- package/dist/types/src/automerge/index.d.ts.map +1 -1
- package/dist/types/src/automerge/mesh-echo-replicator.d.ts.map +1 -1
- package/dist/types/src/space/space-manager.d.ts +2 -2
- package/dist/types/src/space/space-manager.d.ts.map +1 -1
- package/dist/types/src/space/space-protocol.d.ts +2 -2
- package/dist/types/src/space/space-protocol.d.ts.map +1 -1
- package/dist/types/src/space/space.d.ts +9 -1
- package/dist/types/src/space/space.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +1 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-agent-builder.d.ts +2 -2
- package/dist/types/src/testing/test-agent-builder.d.ts.map +1 -1
- package/dist/types/src/testing/test-network-adapter.d.ts +18 -0
- package/dist/types/src/testing/test-network-adapter.d.ts.map +1 -0
- package/package.json +33 -33
- package/src/automerge/automerge-doc-loader.test.ts +5 -2
- package/src/automerge/automerge-doc-loader.ts +10 -6
- package/src/automerge/automerge-host.test.ts +1 -553
- package/src/automerge/automerge-host.ts +17 -23
- package/src/automerge/automerge-repo.test.ts +450 -2
- package/src/automerge/echo-network-adapter.ts +24 -8
- package/src/automerge/echo-replicator.ts +2 -0
- package/src/automerge/index.ts +0 -1
- package/src/automerge/mesh-echo-replicator.ts +3 -1
- package/src/automerge/storage-adapter.test.ts +96 -66
- package/src/space/space-manager.ts +6 -4
- package/src/space/space-protocol.test.ts +5 -3
- package/src/space/space-protocol.ts +3 -3
- package/src/space/space.ts +32 -2
- package/src/testing/index.ts +1 -0
- package/src/testing/test-agent-builder.ts +4 -4
- package/src/testing/test-network-adapter.ts +62 -0
- package/dist/lib/node/chunk-M475BGBI.cjs.map +0 -7
- package/dist/types/src/automerge/automerge-storage-adapter.d.ts +0 -16
- package/dist/types/src/automerge/automerge-storage-adapter.d.ts.map +0 -1
- package/dist/types/src/automerge/automerge-storage/342/200/223wrapper.d.ts +0 -25
- package/dist/types/src/automerge/automerge-storage/342/200/223wrapper.d.ts.map +0 -1
- package/dist/types/src/automerge/migrations.d.ts +0 -7
- package/dist/types/src/automerge/migrations.d.ts.map +0 -1
- package/src/automerge/automerge-storage-adapter.ts +0 -103
- package/src/automerge/automerge-storage/342/200/223wrapper.ts +0 -59
- package/src/automerge/migrations.ts +0 -41
package/dist/lib/node/index.cjs
CHANGED
|
@@ -18,38 +18,38 @@ 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_QPCNQ4ZK.AuthExtension,
|
|
22
|
+
AuthStatus: () => import_chunk_QPCNQ4ZK.AuthStatus,
|
|
23
23
|
AutomergeDocumentLoaderImpl: () => AutomergeDocumentLoaderImpl,
|
|
24
24
|
AutomergeHost: () => AutomergeHost,
|
|
25
|
-
|
|
26
|
-
DataServiceImpl: () => import_chunk_M475BGBI.DataServiceImpl,
|
|
25
|
+
DataServiceImpl: () => import_chunk_QPCNQ4ZK.DataServiceImpl,
|
|
27
26
|
LevelDBStorageAdapter: () => LevelDBStorageAdapter,
|
|
28
27
|
LocalHostNetworkAdapter: () => LocalHostNetworkAdapter,
|
|
29
|
-
MOCK_AUTH_PROVIDER: () =>
|
|
30
|
-
MOCK_AUTH_VERIFIER: () =>
|
|
28
|
+
MOCK_AUTH_PROVIDER: () => import_chunk_QPCNQ4ZK.MOCK_AUTH_PROVIDER,
|
|
29
|
+
MOCK_AUTH_VERIFIER: () => import_chunk_QPCNQ4ZK.MOCK_AUTH_VERIFIER,
|
|
31
30
|
MeshEchoReplicator: () => MeshEchoReplicator,
|
|
32
|
-
MetadataStore: () =>
|
|
33
|
-
Pipeline: () =>
|
|
34
|
-
SnapshotManager: () =>
|
|
35
|
-
SnapshotStore: () =>
|
|
36
|
-
Space: () =>
|
|
37
|
-
SpaceManager: () =>
|
|
38
|
-
SpaceProtocol: () =>
|
|
39
|
-
SpaceProtocolSession: () =>
|
|
40
|
-
TimeframeClock: () =>
|
|
41
|
-
codec: () =>
|
|
42
|
-
|
|
31
|
+
MetadataStore: () => import_chunk_QPCNQ4ZK.MetadataStore,
|
|
32
|
+
Pipeline: () => import_chunk_QPCNQ4ZK.Pipeline,
|
|
33
|
+
SnapshotManager: () => import_chunk_QPCNQ4ZK.SnapshotManager,
|
|
34
|
+
SnapshotStore: () => import_chunk_QPCNQ4ZK.SnapshotStore,
|
|
35
|
+
Space: () => import_chunk_QPCNQ4ZK.Space,
|
|
36
|
+
SpaceManager: () => import_chunk_QPCNQ4ZK.SpaceManager,
|
|
37
|
+
SpaceProtocol: () => import_chunk_QPCNQ4ZK.SpaceProtocol,
|
|
38
|
+
SpaceProtocolSession: () => import_chunk_QPCNQ4ZK.SpaceProtocolSession,
|
|
39
|
+
TimeframeClock: () => import_chunk_QPCNQ4ZK.TimeframeClock,
|
|
40
|
+
codec: () => import_chunk_QPCNQ4ZK.codec,
|
|
41
|
+
createIdFromSpaceKey: () => import_chunk_QPCNQ4ZK.createIdFromSpaceKey,
|
|
42
|
+
createMappedFeedWriter: () => import_chunk_QPCNQ4ZK.createMappedFeedWriter,
|
|
43
43
|
encodingOptions: () => encodingOptions,
|
|
44
44
|
getSpaceKeyFromDoc: () => getSpaceKeyFromDoc,
|
|
45
|
-
hasInvitationExpired: () =>
|
|
46
|
-
mapFeedIndexesToTimeframe: () =>
|
|
47
|
-
mapTimeframeToFeedIndexes: () =>
|
|
48
|
-
startAfter: () =>
|
|
49
|
-
valueEncoding: () =>
|
|
45
|
+
hasInvitationExpired: () => import_chunk_QPCNQ4ZK.hasInvitationExpired,
|
|
46
|
+
mapFeedIndexesToTimeframe: () => import_chunk_QPCNQ4ZK.mapFeedIndexesToTimeframe,
|
|
47
|
+
mapTimeframeToFeedIndexes: () => import_chunk_QPCNQ4ZK.mapTimeframeToFeedIndexes,
|
|
48
|
+
startAfter: () => import_chunk_QPCNQ4ZK.startAfter,
|
|
49
|
+
valueEncoding: () => import_chunk_QPCNQ4ZK.valueEncoding
|
|
50
50
|
});
|
|
51
51
|
module.exports = __toCommonJS(node_exports);
|
|
52
|
-
var
|
|
52
|
+
var import_chunk_QPCNQ4ZK = require("./chunk-QPCNQ4ZK.cjs");
|
|
53
53
|
var import_async = require("@dxos/async");
|
|
54
54
|
var import_automerge = require("@dxos/automerge/automerge");
|
|
55
55
|
var import_automerge_repo = require("@dxos/automerge/automerge-repo");
|
|
@@ -70,23 +70,20 @@ var import_async3 = require("@dxos/async");
|
|
|
70
70
|
var import_automerge_repo3 = require("@dxos/automerge/automerge-repo");
|
|
71
71
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
72
72
|
var import_invariant3 = require("@dxos/invariant");
|
|
73
|
-
var import_automerge_repo_storage_indexeddb = require("@dxos/automerge/automerge-repo-storage-indexeddb");
|
|
74
|
-
var import_log3 = require("@dxos/log");
|
|
75
|
-
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
76
|
-
var import_util2 = require("@dxos/util");
|
|
77
73
|
var import_async4 = require("@dxos/async");
|
|
78
74
|
var import_context4 = require("@dxos/context");
|
|
79
75
|
var import_debug = require("@dxos/debug");
|
|
76
|
+
var import_echo_protocol = require("@dxos/echo-protocol");
|
|
80
77
|
var import_invariant4 = require("@dxos/invariant");
|
|
81
|
-
var
|
|
78
|
+
var import_log3 = require("@dxos/log");
|
|
82
79
|
var import_tracing2 = require("@dxos/tracing");
|
|
83
80
|
var import_automerge_repo4 = require("@dxos/automerge/automerge-repo");
|
|
84
81
|
var import_context5 = require("@dxos/context");
|
|
85
82
|
var import_invariant5 = require("@dxos/invariant");
|
|
86
83
|
var import_keys2 = require("@dxos/keys");
|
|
87
|
-
var
|
|
84
|
+
var import_log4 = require("@dxos/log");
|
|
88
85
|
var import_teleport_extension_automerge_replicator = require("@dxos/teleport-extension-automerge-replicator");
|
|
89
|
-
var
|
|
86
|
+
var import_util2 = require("@dxos/util");
|
|
90
87
|
function _ts_decorate(decorators, target, key, desc) {
|
|
91
88
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
92
89
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -205,13 +202,14 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
205
202
|
peerId: this.peerId,
|
|
206
203
|
onConnectionOpen: this._onConnectionOpen.bind(this),
|
|
207
204
|
onConnectionClosed: this._onConnectionClosed.bind(this),
|
|
205
|
+
onConnectionAuthScopeChanged: this._onConnectionAuthScopeChanged.bind(this),
|
|
208
206
|
getContainingSpaceForDocument: this._params.getContainingSpaceForDocument
|
|
209
207
|
});
|
|
210
208
|
}
|
|
211
209
|
async removeReplicator(replicator) {
|
|
212
210
|
(0, import_invariant2.invariant)(this._lifecycleState === import_context2.LifecycleState.OPEN, void 0, {
|
|
213
211
|
F: __dxlog_file,
|
|
214
|
-
L:
|
|
212
|
+
L: 103,
|
|
215
213
|
S: this,
|
|
216
214
|
A: [
|
|
217
215
|
"this._lifecycleState === LifecycleState.OPEN",
|
|
@@ -220,14 +218,13 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
220
218
|
});
|
|
221
219
|
(0, import_invariant2.invariant)(this._replicators.has(replicator), void 0, {
|
|
222
220
|
F: __dxlog_file,
|
|
223
|
-
L:
|
|
221
|
+
L: 104,
|
|
224
222
|
S: this,
|
|
225
223
|
A: [
|
|
226
224
|
"this._replicators.has(replicator)",
|
|
227
225
|
""
|
|
228
226
|
]
|
|
229
227
|
});
|
|
230
|
-
"";
|
|
231
228
|
await replicator.disconnect();
|
|
232
229
|
this._replicators.delete(replicator);
|
|
233
230
|
}
|
|
@@ -293,27 +290,49 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
293
290
|
S: this,
|
|
294
291
|
C: (f, a) => f(...a)
|
|
295
292
|
});
|
|
296
|
-
this.
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
293
|
+
this._emitPeerCandidate(connection);
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Trigger doc-synchronizer shared documents set recalculation. Happens on peer-candidate.
|
|
297
|
+
* TODO(y): replace with a proper API call when sharePolicy update becomes supported by automerge-repo
|
|
298
|
+
*/
|
|
299
|
+
_onConnectionAuthScopeChanged(connection) {
|
|
300
|
+
(0, import_log2.log)("Connection auth scope changed", {
|
|
301
|
+
peerId: connection.peerId
|
|
302
|
+
}, {
|
|
303
|
+
F: __dxlog_file,
|
|
304
|
+
L: 153,
|
|
305
|
+
S: this,
|
|
306
|
+
C: (f, a) => f(...a)
|
|
307
|
+
});
|
|
308
|
+
const entry = this._connections.get(connection.peerId);
|
|
309
|
+
(0, import_invariant2.invariant)(entry, void 0, {
|
|
310
|
+
F: __dxlog_file,
|
|
311
|
+
L: 155,
|
|
312
|
+
S: this,
|
|
313
|
+
A: [
|
|
314
|
+
"entry",
|
|
315
|
+
""
|
|
316
|
+
]
|
|
302
317
|
});
|
|
318
|
+
this.emit("peer-disconnected", {
|
|
319
|
+
peerId: connection.peerId
|
|
320
|
+
});
|
|
321
|
+
this._emitPeerCandidate(connection);
|
|
303
322
|
}
|
|
304
323
|
_onConnectionClosed(connection) {
|
|
305
324
|
(0, import_log2.log)("Connection closed", {
|
|
306
325
|
peerId: connection.peerId
|
|
307
326
|
}, {
|
|
308
327
|
F: __dxlog_file,
|
|
309
|
-
L:
|
|
328
|
+
L: 161,
|
|
310
329
|
S: this,
|
|
311
330
|
C: (f, a) => f(...a)
|
|
312
331
|
});
|
|
313
332
|
const entry = this._connections.get(connection.peerId);
|
|
314
333
|
(0, import_invariant2.invariant)(entry, void 0, {
|
|
315
334
|
F: __dxlog_file,
|
|
316
|
-
L:
|
|
335
|
+
L: 163,
|
|
317
336
|
S: this,
|
|
318
337
|
A: [
|
|
319
338
|
"entry",
|
|
@@ -326,18 +345,27 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
326
345
|
});
|
|
327
346
|
void entry.reader.cancel().catch((err) => import_log2.log.catch(err, void 0, {
|
|
328
347
|
F: __dxlog_file,
|
|
329
|
-
L:
|
|
348
|
+
L: 168,
|
|
330
349
|
S: this,
|
|
331
350
|
C: (f, a) => f(...a)
|
|
332
351
|
}));
|
|
333
352
|
void entry.writer.abort().catch((err) => import_log2.log.catch(err, void 0, {
|
|
334
353
|
F: __dxlog_file,
|
|
335
|
-
L:
|
|
354
|
+
L: 169,
|
|
336
355
|
S: this,
|
|
337
356
|
C: (f, a) => f(...a)
|
|
338
357
|
}));
|
|
339
358
|
this._connections.delete(connection.peerId);
|
|
340
359
|
}
|
|
360
|
+
_emitPeerCandidate(connection) {
|
|
361
|
+
this.emit("peer-candidate", {
|
|
362
|
+
peerId: connection.peerId,
|
|
363
|
+
peerMetadata: {
|
|
364
|
+
// TODO(dmaretskyi): Refactor this.
|
|
365
|
+
dxos_peerSource: "EchoNetworkAdapter"
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
}
|
|
341
369
|
};
|
|
342
370
|
_ts_decorate([
|
|
343
371
|
import_async2.synchronized
|
|
@@ -576,108 +604,6 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo3.NetworkAdapte
|
|
|
576
604
|
return id;
|
|
577
605
|
}
|
|
578
606
|
};
|
|
579
|
-
var AutomergeStorageAdapter = class {
|
|
580
|
-
constructor(_directory) {
|
|
581
|
-
this._directory = _directory;
|
|
582
|
-
this._state = "opened";
|
|
583
|
-
}
|
|
584
|
-
async load(key) {
|
|
585
|
-
if (this._state !== "opened") {
|
|
586
|
-
return void 0;
|
|
587
|
-
}
|
|
588
|
-
const filename = this._getFilename(key);
|
|
589
|
-
const file = this._directory.getOrCreateFile(filename);
|
|
590
|
-
const { size } = await file.stat();
|
|
591
|
-
if (!size || size === 0) {
|
|
592
|
-
return void 0;
|
|
593
|
-
}
|
|
594
|
-
const buffer = await file.read(0, size);
|
|
595
|
-
return (0, import_util2.bufferToArray)(buffer);
|
|
596
|
-
}
|
|
597
|
-
async save(key, data) {
|
|
598
|
-
if (this._state !== "opened") {
|
|
599
|
-
return void 0;
|
|
600
|
-
}
|
|
601
|
-
const filename = this._getFilename(key);
|
|
602
|
-
const file = this._directory.getOrCreateFile(filename);
|
|
603
|
-
await file.write(0, (0, import_util2.arrayToBuffer)(data));
|
|
604
|
-
await file.truncate?.(data.length);
|
|
605
|
-
await file.flush?.();
|
|
606
|
-
}
|
|
607
|
-
async remove(key) {
|
|
608
|
-
if (this._state !== "opened") {
|
|
609
|
-
return void 0;
|
|
610
|
-
}
|
|
611
|
-
const filename = this._getFilename(key);
|
|
612
|
-
const file = this._directory.getOrCreateFile(filename);
|
|
613
|
-
await file.destroy();
|
|
614
|
-
}
|
|
615
|
-
async loadRange(keyPrefix) {
|
|
616
|
-
if (this._state !== "opened") {
|
|
617
|
-
return [];
|
|
618
|
-
}
|
|
619
|
-
const filename = this._getFilename(keyPrefix);
|
|
620
|
-
const entries = await this._directory.list();
|
|
621
|
-
return Promise.all(entries.filter((entry) => entry.startsWith(filename)).map(async (entry) => {
|
|
622
|
-
const file = this._directory.getOrCreateFile(entry);
|
|
623
|
-
const { size } = await file.stat();
|
|
624
|
-
const buffer = await file.read(0, size);
|
|
625
|
-
return {
|
|
626
|
-
key: this._getKeyFromFilename(entry),
|
|
627
|
-
data: (0, import_util2.bufferToArray)(buffer)
|
|
628
|
-
};
|
|
629
|
-
}));
|
|
630
|
-
}
|
|
631
|
-
async removeRange(keyPrefix) {
|
|
632
|
-
if (this._state !== "opened") {
|
|
633
|
-
return void 0;
|
|
634
|
-
}
|
|
635
|
-
const filename = this._getFilename(keyPrefix);
|
|
636
|
-
const entries = await this._directory.list();
|
|
637
|
-
await Promise.all(entries.filter((entry) => entry.startsWith(filename)).map(async (entry) => {
|
|
638
|
-
const file = this._directory.getOrCreateFile(entry);
|
|
639
|
-
await file.destroy();
|
|
640
|
-
}));
|
|
641
|
-
}
|
|
642
|
-
async close() {
|
|
643
|
-
this._state = "closed";
|
|
644
|
-
}
|
|
645
|
-
_getFilename(key) {
|
|
646
|
-
return key.map((k) => k.replaceAll("%", "%25").replaceAll("-", "%2D")).join("-");
|
|
647
|
-
}
|
|
648
|
-
_getKeyFromFilename(filename) {
|
|
649
|
-
return filename.split("-").map((k) => k.replaceAll("%2D", "-").replaceAll("%25", "%"));
|
|
650
|
-
}
|
|
651
|
-
};
|
|
652
|
-
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/migrations.ts";
|
|
653
|
-
var levelMigration = async ({ db, directory }) => {
|
|
654
|
-
const isNewLevel = !await db.iterator({
|
|
655
|
-
...encodingOptions
|
|
656
|
-
}).next();
|
|
657
|
-
if (!isNewLevel) {
|
|
658
|
-
return;
|
|
659
|
-
}
|
|
660
|
-
const oldStorageAdapter = directory.type === import_random_access_storage.StorageType.IDB ? new import_automerge_repo_storage_indexeddb.IndexedDBStorageAdapter(directory.path, "data") : new AutomergeStorageAdapter(directory);
|
|
661
|
-
const chunks = await oldStorageAdapter.loadRange([]);
|
|
662
|
-
if (chunks.length === 0) {
|
|
663
|
-
return;
|
|
664
|
-
}
|
|
665
|
-
const batch = db.batch();
|
|
666
|
-
import_log3.log.info("found chunks on old storage adapter", {
|
|
667
|
-
chunks: chunks.length
|
|
668
|
-
}, {
|
|
669
|
-
F: __dxlog_file3,
|
|
670
|
-
L: 36,
|
|
671
|
-
S: void 0,
|
|
672
|
-
C: (f, a) => f(...a)
|
|
673
|
-
});
|
|
674
|
-
for (const { key, data } of await oldStorageAdapter.loadRange([])) {
|
|
675
|
-
data && batch.put(key, data, {
|
|
676
|
-
...encodingOptions
|
|
677
|
-
});
|
|
678
|
-
}
|
|
679
|
-
await batch.write();
|
|
680
|
-
};
|
|
681
607
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
682
608
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
683
609
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -688,41 +614,37 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
688
614
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
689
615
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
690
616
|
}
|
|
691
|
-
var
|
|
617
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
|
|
692
618
|
var AutomergeHost = class {
|
|
693
|
-
constructor({
|
|
619
|
+
constructor({ db, indexMetadataStore }) {
|
|
694
620
|
this._ctx = new import_context.Context();
|
|
695
621
|
this._echoNetworkAdapter = new EchoNetworkAdapter({
|
|
696
622
|
getContainingSpaceForDocument: this._getContainingSpaceForDocument.bind(this)
|
|
697
623
|
});
|
|
698
624
|
this._requestedDocs = /* @__PURE__ */ new Set();
|
|
699
|
-
this._directory = directory;
|
|
700
|
-
this._db = db;
|
|
701
|
-
this._indexMetadataStore = indexMetadataStore;
|
|
702
|
-
}
|
|
703
|
-
async open() {
|
|
704
|
-
this._directory && await levelMigration({
|
|
705
|
-
db: this._db,
|
|
706
|
-
directory: this._directory
|
|
707
|
-
});
|
|
708
625
|
this._storage = new LevelDBStorageAdapter({
|
|
709
|
-
db
|
|
626
|
+
db,
|
|
710
627
|
callbacks: {
|
|
711
628
|
beforeSave: async (params) => this._beforeSave(params),
|
|
712
629
|
afterSave: async () => this._afterSave()
|
|
713
630
|
}
|
|
714
631
|
});
|
|
715
|
-
|
|
632
|
+
this._indexMetadataStore = indexMetadataStore;
|
|
633
|
+
}
|
|
634
|
+
async open() {
|
|
716
635
|
this._peerId = `host-${import_keys.PublicKey.random().toHex()}`;
|
|
636
|
+
await this._storage.open?.();
|
|
717
637
|
this._clientNetwork = new LocalHostNetworkAdapter();
|
|
718
638
|
this._repo = new import_automerge_repo.Repo({
|
|
719
639
|
peerId: this._peerId,
|
|
640
|
+
sharePolicy: this._sharePolicy.bind(this),
|
|
641
|
+
storage: this._storage,
|
|
720
642
|
network: [
|
|
643
|
+
// Downstream client.
|
|
721
644
|
this._clientNetwork,
|
|
645
|
+
// Upstream swarm.
|
|
722
646
|
this._echoNetworkAdapter
|
|
723
|
-
]
|
|
724
|
-
storage: this._storage,
|
|
725
|
-
sharePolicy: this._sharePolicy.bind(this)
|
|
647
|
+
]
|
|
726
648
|
});
|
|
727
649
|
this._clientNetwork.ready();
|
|
728
650
|
await this._echoNetworkAdapter.open();
|
|
@@ -763,8 +685,8 @@ var AutomergeHost = class {
|
|
|
763
685
|
documentId,
|
|
764
686
|
isRequested
|
|
765
687
|
}, {
|
|
766
|
-
F:
|
|
767
|
-
L:
|
|
688
|
+
F: __dxlog_file3,
|
|
689
|
+
L: 143,
|
|
768
690
|
S: this,
|
|
769
691
|
C: (f, a) => f(...a)
|
|
770
692
|
});
|
|
@@ -849,8 +771,8 @@ var AutomergeHost = class {
|
|
|
849
771
|
async flush({ states }) {
|
|
850
772
|
await Promise.all(states?.map(async ({ heads, documentId }) => {
|
|
851
773
|
(0, import_invariant.invariant)(heads, "heads are required for flush", {
|
|
852
|
-
F:
|
|
853
|
-
L:
|
|
774
|
+
F: __dxlog_file3,
|
|
775
|
+
L: 237,
|
|
854
776
|
S: this,
|
|
855
777
|
A: [
|
|
856
778
|
"heads",
|
|
@@ -928,11 +850,12 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
928
850
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
929
851
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
930
852
|
}
|
|
931
|
-
var
|
|
853
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-doc-loader.ts";
|
|
932
854
|
var AutomergeDocumentLoaderImpl = class {
|
|
933
|
-
constructor(
|
|
934
|
-
this.
|
|
855
|
+
constructor(_spaceId, _repo, _spaceKey) {
|
|
856
|
+
this._spaceId = _spaceId;
|
|
935
857
|
this._repo = _repo;
|
|
858
|
+
this._spaceKey = _spaceKey;
|
|
936
859
|
this._spaceRootDocHandle = null;
|
|
937
860
|
this._objectDocumentHandles = /* @__PURE__ */ new Map();
|
|
938
861
|
this._objectsPendingDocumentLoad = /* @__PURE__ */ new Set();
|
|
@@ -949,11 +872,11 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
949
872
|
return;
|
|
950
873
|
}
|
|
951
874
|
if (!spaceState.rootUrl) {
|
|
952
|
-
|
|
953
|
-
|
|
875
|
+
import_log3.log.error("Database opened with no rootUrl", {
|
|
876
|
+
spaceId: this._spaceId
|
|
954
877
|
}, {
|
|
955
|
-
F:
|
|
956
|
-
L:
|
|
878
|
+
F: __dxlog_file4,
|
|
879
|
+
L: 72,
|
|
957
880
|
S: this,
|
|
958
881
|
C: (f, a) => f(...a)
|
|
959
882
|
});
|
|
@@ -962,8 +885,8 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
962
885
|
const existingDocHandle = await this._initDocHandle(ctx, spaceState.rootUrl);
|
|
963
886
|
const doc = existingDocHandle.docSync();
|
|
964
887
|
(0, import_invariant4.invariant)(doc, void 0, {
|
|
965
|
-
F:
|
|
966
|
-
L:
|
|
888
|
+
F: __dxlog_file4,
|
|
889
|
+
L: 77,
|
|
967
890
|
S: this,
|
|
968
891
|
A: [
|
|
969
892
|
"doc",
|
|
@@ -984,8 +907,8 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
984
907
|
const urlsToLoad = {};
|
|
985
908
|
for (const objectId of objectIds) {
|
|
986
909
|
(0, import_invariant4.invariant)(this._spaceRootDocHandle, void 0, {
|
|
987
|
-
F:
|
|
988
|
-
L:
|
|
910
|
+
F: __dxlog_file4,
|
|
911
|
+
L: 90,
|
|
989
912
|
S: this,
|
|
990
913
|
A: [
|
|
991
914
|
"this._spaceRootDocHandle",
|
|
@@ -997,8 +920,8 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
997
920
|
}
|
|
998
921
|
const spaceRootDoc = this._spaceRootDocHandle.docSync();
|
|
999
922
|
(0, import_invariant4.invariant)(spaceRootDoc, void 0, {
|
|
1000
|
-
F:
|
|
1001
|
-
L:
|
|
923
|
+
F: __dxlog_file4,
|
|
924
|
+
L: 95,
|
|
1002
925
|
S: this,
|
|
1003
926
|
A: [
|
|
1004
927
|
"spaceRootDoc",
|
|
@@ -1008,11 +931,11 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1008
931
|
const documentUrl = (spaceRootDoc.links ?? {})[objectId];
|
|
1009
932
|
if (documentUrl == null) {
|
|
1010
933
|
this._objectsPendingDocumentLoad.add(objectId);
|
|
1011
|
-
|
|
934
|
+
import_log3.log.info("loading delayed until object links are initialized", {
|
|
1012
935
|
objectId
|
|
1013
936
|
}, {
|
|
1014
|
-
F:
|
|
1015
|
-
L:
|
|
937
|
+
F: __dxlog_file4,
|
|
938
|
+
L: 99,
|
|
1016
939
|
S: this,
|
|
1017
940
|
C: (f, a) => f(...a)
|
|
1018
941
|
});
|
|
@@ -1035,8 +958,8 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1035
958
|
}
|
|
1036
959
|
getSpaceRootDocHandle() {
|
|
1037
960
|
(0, import_invariant4.invariant)(this._spaceRootDocHandle, void 0, {
|
|
1038
|
-
F:
|
|
1039
|
-
L:
|
|
961
|
+
F: __dxlog_file4,
|
|
962
|
+
L: 122,
|
|
1040
963
|
S: this,
|
|
1041
964
|
A: [
|
|
1042
965
|
"this._spaceRootDocHandle",
|
|
@@ -1047,15 +970,17 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1047
970
|
}
|
|
1048
971
|
createDocumentForObject(objectId) {
|
|
1049
972
|
(0, import_invariant4.invariant)(this._spaceRootDocHandle, void 0, {
|
|
1050
|
-
F:
|
|
1051
|
-
L:
|
|
973
|
+
F: __dxlog_file4,
|
|
974
|
+
L: 127,
|
|
1052
975
|
S: this,
|
|
1053
976
|
A: [
|
|
1054
977
|
"this._spaceRootDocHandle",
|
|
1055
978
|
""
|
|
1056
979
|
]
|
|
1057
980
|
});
|
|
1058
|
-
const spaceDocHandle = this._repo.create(
|
|
981
|
+
const spaceDocHandle = this._repo.create({
|
|
982
|
+
version: import_echo_protocol.SpaceDocVersion.CURRENT
|
|
983
|
+
});
|
|
1059
984
|
this._initDocAccess(spaceDocHandle);
|
|
1060
985
|
this.onObjectBoundToDocument(spaceDocHandle, objectId);
|
|
1061
986
|
this._spaceRootDocHandle.change((newDoc) => {
|
|
@@ -1086,30 +1011,30 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1086
1011
|
};
|
|
1087
1012
|
const objectDocumentHandle = this._objectDocumentHandles.get(objectId);
|
|
1088
1013
|
if (objectDocumentHandle != null && objectDocumentHandle.url !== automergeUrl) {
|
|
1089
|
-
|
|
1014
|
+
import_log3.log.warn("object already inlined in a different document, ignoring the link", {
|
|
1090
1015
|
...logMeta,
|
|
1091
1016
|
actualDocumentUrl: objectDocumentHandle.url
|
|
1092
1017
|
}, {
|
|
1093
|
-
F:
|
|
1094
|
-
L:
|
|
1018
|
+
F: __dxlog_file4,
|
|
1019
|
+
L: 159,
|
|
1095
1020
|
S: this,
|
|
1096
1021
|
C: (f, a) => f(...a)
|
|
1097
1022
|
});
|
|
1098
1023
|
continue;
|
|
1099
1024
|
}
|
|
1100
1025
|
if (objectDocumentHandle?.url === automergeUrl) {
|
|
1101
|
-
|
|
1102
|
-
F:
|
|
1103
|
-
L:
|
|
1026
|
+
import_log3.log.warn("object document was already loaded", logMeta, {
|
|
1027
|
+
F: __dxlog_file4,
|
|
1028
|
+
L: 166,
|
|
1104
1029
|
S: this,
|
|
1105
1030
|
C: (f, a) => f(...a)
|
|
1106
1031
|
});
|
|
1107
1032
|
continue;
|
|
1108
1033
|
}
|
|
1109
1034
|
const handle = this._repo.find(automergeUrl);
|
|
1110
|
-
|
|
1111
|
-
F:
|
|
1112
|
-
L:
|
|
1035
|
+
import_log3.log.debug("document loading triggered", logMeta, {
|
|
1036
|
+
F: __dxlog_file4,
|
|
1037
|
+
L: 170,
|
|
1113
1038
|
S: this,
|
|
1114
1039
|
C: (f, a) => f(...a)
|
|
1115
1040
|
});
|
|
@@ -1121,18 +1046,18 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1121
1046
|
const docHandle = this._repo.find(url);
|
|
1122
1047
|
while (true) {
|
|
1123
1048
|
try {
|
|
1124
|
-
await (0, import_debug.warnAfterTimeout)(5e3, "Automerge root doc load timeout (
|
|
1049
|
+
await (0, import_debug.warnAfterTimeout)(5e3, "Automerge root doc load timeout (CoreDatabase)", async () => {
|
|
1125
1050
|
await (0, import_context4.cancelWithContext)(ctx, docHandle.whenReady());
|
|
1126
1051
|
});
|
|
1127
1052
|
break;
|
|
1128
1053
|
} catch (err) {
|
|
1129
1054
|
if (`${err}`.includes("Timeout")) {
|
|
1130
|
-
|
|
1055
|
+
import_log3.log.info("wraparound", {
|
|
1131
1056
|
id: docHandle.documentId,
|
|
1132
1057
|
state: docHandle.state
|
|
1133
1058
|
}, {
|
|
1134
|
-
F:
|
|
1135
|
-
L:
|
|
1059
|
+
F: __dxlog_file4,
|
|
1060
|
+
L: 186,
|
|
1136
1061
|
S: this,
|
|
1137
1062
|
C: (f, a) => f(...a)
|
|
1138
1063
|
});
|
|
@@ -1172,9 +1097,9 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1172
1097
|
docUrl: handle.url
|
|
1173
1098
|
};
|
|
1174
1099
|
if (this.onObjectDocumentLoaded.listenerCount() === 0) {
|
|
1175
|
-
|
|
1176
|
-
F:
|
|
1177
|
-
L:
|
|
1100
|
+
import_log3.log.info("document loaded after all listeners were removed", logMeta, {
|
|
1101
|
+
F: __dxlog_file4,
|
|
1102
|
+
L: 222,
|
|
1178
1103
|
S: this,
|
|
1179
1104
|
C: (f, a) => f(...a)
|
|
1180
1105
|
});
|
|
@@ -1182,9 +1107,9 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1182
1107
|
}
|
|
1183
1108
|
const objectDocHandle = this._objectDocumentHandles.get(objectId);
|
|
1184
1109
|
if (objectDocHandle?.url !== handle.url) {
|
|
1185
|
-
|
|
1186
|
-
F:
|
|
1187
|
-
L:
|
|
1110
|
+
import_log3.log.warn("object was rebound while a document was loading, discarding handle", logMeta, {
|
|
1111
|
+
F: __dxlog_file4,
|
|
1112
|
+
L: 227,
|
|
1188
1113
|
S: this,
|
|
1189
1114
|
C: (f, a) => f(...a)
|
|
1190
1115
|
});
|
|
@@ -1196,14 +1121,14 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1196
1121
|
});
|
|
1197
1122
|
} catch (err) {
|
|
1198
1123
|
const shouldRetryLoading = this.onObjectDocumentLoaded.listenerCount() > 0;
|
|
1199
|
-
|
|
1124
|
+
import_log3.log.warn("failed to load a document", {
|
|
1200
1125
|
objectId,
|
|
1201
1126
|
automergeUrl: handle.url,
|
|
1202
1127
|
retryLoading: shouldRetryLoading,
|
|
1203
1128
|
err
|
|
1204
1129
|
}, {
|
|
1205
|
-
F:
|
|
1206
|
-
L:
|
|
1130
|
+
F: __dxlog_file4,
|
|
1131
|
+
L: 233,
|
|
1207
1132
|
S: this,
|
|
1208
1133
|
C: (f, a) => f(...a)
|
|
1209
1134
|
});
|
|
@@ -1221,12 +1146,12 @@ _ts_decorate3([
|
|
|
1221
1146
|
AutomergeDocumentLoaderImpl = _ts_decorate3([
|
|
1222
1147
|
import_tracing2.trace.resource()
|
|
1223
1148
|
], AutomergeDocumentLoaderImpl);
|
|
1224
|
-
var
|
|
1149
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/mesh-echo-replicator.ts";
|
|
1225
1150
|
var MeshEchoReplicator = class {
|
|
1226
1151
|
constructor() {
|
|
1227
1152
|
this._connections = /* @__PURE__ */ new Set();
|
|
1228
1153
|
this._connectionsPerPeer = /* @__PURE__ */ new Map();
|
|
1229
|
-
this._authorizedDevices = new
|
|
1154
|
+
this._authorizedDevices = new import_util2.ComplexMap(import_keys2.PublicKey.hash);
|
|
1230
1155
|
this._context = null;
|
|
1231
1156
|
}
|
|
1232
1157
|
async connect(context) {
|
|
@@ -1242,7 +1167,7 @@ var MeshEchoReplicator = class {
|
|
|
1242
1167
|
}
|
|
1243
1168
|
createExtension() {
|
|
1244
1169
|
(0, import_invariant5.invariant)(this._context, void 0, {
|
|
1245
|
-
F:
|
|
1170
|
+
F: __dxlog_file5,
|
|
1246
1171
|
L: 54,
|
|
1247
1172
|
S: this,
|
|
1248
1173
|
A: [
|
|
@@ -1253,16 +1178,16 @@ var MeshEchoReplicator = class {
|
|
|
1253
1178
|
const connection = new MeshReplicatorConnection({
|
|
1254
1179
|
ownPeerId: this._context.peerId,
|
|
1255
1180
|
onRemoteConnected: async () => {
|
|
1256
|
-
(0,
|
|
1181
|
+
(0, import_log4.log)("onRemoteConnected", {
|
|
1257
1182
|
peerId: connection.peerId
|
|
1258
1183
|
}, {
|
|
1259
|
-
F:
|
|
1184
|
+
F: __dxlog_file5,
|
|
1260
1185
|
L: 59,
|
|
1261
1186
|
S: this,
|
|
1262
1187
|
C: (f, a) => f(...a)
|
|
1263
1188
|
});
|
|
1264
1189
|
(0, import_invariant5.invariant)(this._context, void 0, {
|
|
1265
|
-
F:
|
|
1190
|
+
F: __dxlog_file5,
|
|
1266
1191
|
L: 60,
|
|
1267
1192
|
S: this,
|
|
1268
1193
|
A: [
|
|
@@ -1270,18 +1195,20 @@ var MeshEchoReplicator = class {
|
|
|
1270
1195
|
""
|
|
1271
1196
|
]
|
|
1272
1197
|
});
|
|
1273
|
-
if (
|
|
1198
|
+
if (this._connectionsPerPeer.has(connection.peerId)) {
|
|
1199
|
+
this._context.onConnectionAuthScopeChanged(connection);
|
|
1200
|
+
} else {
|
|
1274
1201
|
this._connectionsPerPeer.set(connection.peerId, connection);
|
|
1275
1202
|
await connection.enable();
|
|
1276
1203
|
this._context.onConnectionOpen(connection);
|
|
1277
1204
|
}
|
|
1278
1205
|
},
|
|
1279
1206
|
onRemoteDisconnected: async () => {
|
|
1280
|
-
(0,
|
|
1207
|
+
(0, import_log4.log)("onRemoteDisconnected", {
|
|
1281
1208
|
peerId: connection.peerId
|
|
1282
1209
|
}, {
|
|
1283
|
-
F:
|
|
1284
|
-
L:
|
|
1210
|
+
F: __dxlog_file5,
|
|
1211
|
+
L: 71,
|
|
1285
1212
|
S: this,
|
|
1286
1213
|
C: (f, a) => f(...a)
|
|
1287
1214
|
});
|
|
@@ -1291,18 +1218,18 @@ var MeshEchoReplicator = class {
|
|
|
1291
1218
|
this._connections.delete(connection);
|
|
1292
1219
|
},
|
|
1293
1220
|
shouldAdvertize: async (params) => {
|
|
1294
|
-
(0,
|
|
1221
|
+
(0, import_log4.log)("shouldAdvertize", {
|
|
1295
1222
|
peerId: connection.peerId,
|
|
1296
1223
|
documentId: params.documentId
|
|
1297
1224
|
}, {
|
|
1298
|
-
F:
|
|
1299
|
-
L:
|
|
1225
|
+
F: __dxlog_file5,
|
|
1226
|
+
L: 78,
|
|
1300
1227
|
S: this,
|
|
1301
1228
|
C: (f, a) => f(...a)
|
|
1302
1229
|
});
|
|
1303
1230
|
(0, import_invariant5.invariant)(this._context, void 0, {
|
|
1304
|
-
F:
|
|
1305
|
-
L:
|
|
1231
|
+
F: __dxlog_file5,
|
|
1232
|
+
L: 79,
|
|
1306
1233
|
S: this,
|
|
1307
1234
|
A: [
|
|
1308
1235
|
"this._context",
|
|
@@ -1312,12 +1239,12 @@ var MeshEchoReplicator = class {
|
|
|
1312
1239
|
try {
|
|
1313
1240
|
const spaceKey = await this._context.getContainingSpaceForDocument(params.documentId);
|
|
1314
1241
|
if (!spaceKey) {
|
|
1315
|
-
(0,
|
|
1242
|
+
(0, import_log4.log)("space key not found for share policy check", {
|
|
1316
1243
|
peerId: connection.peerId,
|
|
1317
1244
|
documentId: params.documentId
|
|
1318
1245
|
}, {
|
|
1319
|
-
F:
|
|
1320
|
-
L:
|
|
1246
|
+
F: __dxlog_file5,
|
|
1247
|
+
L: 83,
|
|
1321
1248
|
S: this,
|
|
1322
1249
|
C: (f, a) => f(...a)
|
|
1323
1250
|
});
|
|
@@ -1325,19 +1252,19 @@ var MeshEchoReplicator = class {
|
|
|
1325
1252
|
}
|
|
1326
1253
|
const authorizedDevices = this._authorizedDevices.get(spaceKey);
|
|
1327
1254
|
if (!connection.remoteDeviceKey) {
|
|
1328
|
-
(0,
|
|
1255
|
+
(0, import_log4.log)("device key not found for share policy check", {
|
|
1329
1256
|
peerId: connection.peerId,
|
|
1330
1257
|
documentId: params.documentId
|
|
1331
1258
|
}, {
|
|
1332
|
-
F:
|
|
1333
|
-
L:
|
|
1259
|
+
F: __dxlog_file5,
|
|
1260
|
+
L: 93,
|
|
1334
1261
|
S: this,
|
|
1335
1262
|
C: (f, a) => f(...a)
|
|
1336
1263
|
});
|
|
1337
1264
|
return false;
|
|
1338
1265
|
}
|
|
1339
1266
|
const isAuthorized = authorizedDevices?.has(connection.remoteDeviceKey) ?? false;
|
|
1340
|
-
(0,
|
|
1267
|
+
(0, import_log4.log)("share policy check", {
|
|
1341
1268
|
localPeer: this._context.peerId,
|
|
1342
1269
|
remotePeer: connection.peerId,
|
|
1343
1270
|
documentId: params.documentId,
|
|
@@ -1345,16 +1272,16 @@ var MeshEchoReplicator = class {
|
|
|
1345
1272
|
spaceKey,
|
|
1346
1273
|
isAuthorized
|
|
1347
1274
|
}, {
|
|
1348
|
-
F:
|
|
1349
|
-
L:
|
|
1275
|
+
F: __dxlog_file5,
|
|
1276
|
+
L: 101,
|
|
1350
1277
|
S: this,
|
|
1351
1278
|
C: (f, a) => f(...a)
|
|
1352
1279
|
});
|
|
1353
1280
|
return isAuthorized;
|
|
1354
1281
|
} catch (err) {
|
|
1355
|
-
|
|
1356
|
-
F:
|
|
1357
|
-
L:
|
|
1282
|
+
import_log4.log.catch(err, void 0, {
|
|
1283
|
+
F: __dxlog_file5,
|
|
1284
|
+
L: 111,
|
|
1358
1285
|
S: this,
|
|
1359
1286
|
C: (f, a) => f(...a)
|
|
1360
1287
|
});
|
|
@@ -1366,16 +1293,16 @@ var MeshEchoReplicator = class {
|
|
|
1366
1293
|
return connection.replicatorExtension;
|
|
1367
1294
|
}
|
|
1368
1295
|
authorizeDevice(spaceKey, deviceKey) {
|
|
1369
|
-
(0,
|
|
1296
|
+
(0, import_log4.log)("authorizeDevice", {
|
|
1370
1297
|
spaceKey,
|
|
1371
1298
|
deviceKey
|
|
1372
1299
|
}, {
|
|
1373
|
-
F:
|
|
1374
|
-
L:
|
|
1300
|
+
F: __dxlog_file5,
|
|
1301
|
+
L: 122,
|
|
1375
1302
|
S: this,
|
|
1376
1303
|
C: (f, a) => f(...a)
|
|
1377
1304
|
});
|
|
1378
|
-
(0,
|
|
1305
|
+
(0, import_util2.defaultMap)(this._authorizedDevices, spaceKey, () => new import_util2.ComplexSet(import_keys2.PublicKey.hash)).add(deviceKey);
|
|
1379
1306
|
}
|
|
1380
1307
|
};
|
|
1381
1308
|
var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
@@ -1407,13 +1334,13 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1407
1334
|
onStartReplication: async (info, remotePeerId) => {
|
|
1408
1335
|
this.remoteDeviceKey = remotePeerId;
|
|
1409
1336
|
this._remotePeerId = info.id;
|
|
1410
|
-
(0,
|
|
1337
|
+
(0, import_log4.log)("onStartReplication", {
|
|
1411
1338
|
id: info.id,
|
|
1412
1339
|
thisPeerId: this.peerId,
|
|
1413
1340
|
remotePeerId: remotePeerId.toHex()
|
|
1414
1341
|
}, {
|
|
1415
|
-
F:
|
|
1416
|
-
L:
|
|
1342
|
+
F: __dxlog_file5,
|
|
1343
|
+
L: 187,
|
|
1417
1344
|
S: this,
|
|
1418
1345
|
C: (f, a) => f(...a)
|
|
1419
1346
|
});
|
|
@@ -1436,8 +1363,8 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1436
1363
|
}
|
|
1437
1364
|
get peerId() {
|
|
1438
1365
|
(0, import_invariant5.invariant)(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
1439
|
-
F:
|
|
1440
|
-
L:
|
|
1366
|
+
F: __dxlog_file5,
|
|
1367
|
+
L: 210,
|
|
1441
1368
|
S: this,
|
|
1442
1369
|
A: [
|
|
1443
1370
|
"this._remotePeerId != null",
|
|
@@ -1455,8 +1382,8 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1455
1382
|
*/
|
|
1456
1383
|
async enable() {
|
|
1457
1384
|
(0, import_invariant5.invariant)(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
1458
|
-
F:
|
|
1459
|
-
L:
|
|
1385
|
+
F: __dxlog_file5,
|
|
1386
|
+
L: 223,
|
|
1460
1387
|
S: this,
|
|
1461
1388
|
A: [
|
|
1462
1389
|
"this._remotePeerId != null",
|
|
@@ -1478,7 +1405,6 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1478
1405
|
AuthStatus,
|
|
1479
1406
|
AutomergeDocumentLoaderImpl,
|
|
1480
1407
|
AutomergeHost,
|
|
1481
|
-
AutomergeStorageAdapter,
|
|
1482
1408
|
DataServiceImpl,
|
|
1483
1409
|
LevelDBStorageAdapter,
|
|
1484
1410
|
LocalHostNetworkAdapter,
|
|
@@ -1495,6 +1421,7 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1495
1421
|
SpaceProtocolSession,
|
|
1496
1422
|
TimeframeClock,
|
|
1497
1423
|
codec,
|
|
1424
|
+
createIdFromSpaceKey,
|
|
1498
1425
|
createMappedFeedWriter,
|
|
1499
1426
|
encodingOptions,
|
|
1500
1427
|
getSpaceKeyFromDoc,
|