@dxos/echo-pipeline 0.6.2-main.d41f0d2 → 0.6.2-main.e09770c
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-SJUDZ3CQ.mjs → chunk-UJQ5VS5V.mjs} +7 -17
- package/dist/lib/browser/chunk-UJQ5VS5V.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +71 -573
- 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-NLHNTXVQ.cjs → chunk-RH6TDRML.cjs} +10 -20
- package/dist/lib/node/chunk-RH6TDRML.cjs.map +7 -0
- package/dist/lib/node/index.cjs +93 -593
- 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 +2 -17
- package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
- package/dist/types/src/automerge/echo-network-adapter.d.ts +1 -1
- package/dist/types/src/automerge/index.d.ts +0 -2
- 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/db-host/data-service.d.ts +2 -5
- package/dist/types/src/db-host/data-service.d.ts.map +1 -1
- package/dist/types/src/db-host/documents-synchronizer.d.ts +1 -1
- package/dist/types/src/db-host/documents-synchronizer.d.ts.map +1 -1
- package/package.json +33 -33
- package/src/automerge/automerge-host.ts +6 -56
- package/src/automerge/automerge-repo.test.ts +124 -1
- package/src/automerge/echo-network-adapter.test.ts +11 -0
- package/src/automerge/echo-network-adapter.ts +1 -1
- package/src/automerge/index.ts +0 -2
- package/src/automerge/mesh-echo-replicator.ts +3 -0
- package/src/db-host/data-service.ts +3 -20
- package/src/db-host/documents-synchronizer.test.ts +1 -1
- package/src/db-host/documents-synchronizer.ts +1 -1
- package/dist/lib/browser/chunk-SJUDZ3CQ.mjs.map +0 -7
- package/dist/lib/node/chunk-NLHNTXVQ.cjs.map +0 -7
- package/dist/types/src/automerge/automerge-doc-loader.d.ts +0 -71
- package/dist/types/src/automerge/automerge-doc-loader.d.ts.map +0 -1
- package/dist/types/src/automerge/automerge-doc-loader.test.d.ts +0 -2
- package/dist/types/src/automerge/automerge-doc-loader.test.d.ts.map +0 -1
- package/dist/types/src/automerge/local-host-network-adapter.d.ts +0 -30
- package/dist/types/src/automerge/local-host-network-adapter.d.ts.map +0 -1
- package/src/automerge/automerge-doc-loader.test.ts +0 -103
- package/src/automerge/automerge-doc-loader.ts +0 -267
- package/src/automerge/local-host-network-adapter.ts +0 -115
package/dist/lib/node/index.cjs
CHANGED
|
@@ -18,41 +18,39 @@ 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: () =>
|
|
23
|
-
AutomergeDocumentLoaderImpl: () => AutomergeDocumentLoaderImpl,
|
|
21
|
+
AuthExtension: () => import_chunk_RH6TDRML.AuthExtension,
|
|
22
|
+
AuthStatus: () => import_chunk_RH6TDRML.AuthStatus,
|
|
24
23
|
AutomergeHost: () => AutomergeHost,
|
|
25
|
-
CredentialRetrieverExtension: () =>
|
|
26
|
-
CredentialServerExtension: () =>
|
|
27
|
-
DataServiceImpl: () =>
|
|
28
|
-
DocumentsSynchronizer: () =>
|
|
24
|
+
CredentialRetrieverExtension: () => import_chunk_RH6TDRML.CredentialRetrieverExtension,
|
|
25
|
+
CredentialServerExtension: () => import_chunk_RH6TDRML.CredentialServerExtension,
|
|
26
|
+
DataServiceImpl: () => import_chunk_RH6TDRML.DataServiceImpl,
|
|
27
|
+
DocumentsSynchronizer: () => import_chunk_RH6TDRML.DocumentsSynchronizer,
|
|
29
28
|
LevelDBStorageAdapter: () => LevelDBStorageAdapter,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
MOCK_AUTH_VERIFIER: () => import_chunk_NLHNTXVQ.MOCK_AUTH_VERIFIER,
|
|
29
|
+
MOCK_AUTH_PROVIDER: () => import_chunk_RH6TDRML.MOCK_AUTH_PROVIDER,
|
|
30
|
+
MOCK_AUTH_VERIFIER: () => import_chunk_RH6TDRML.MOCK_AUTH_VERIFIER,
|
|
33
31
|
MeshEchoReplicator: () => MeshEchoReplicator,
|
|
34
|
-
MetadataStore: () =>
|
|
35
|
-
Pipeline: () =>
|
|
36
|
-
SnapshotManager: () =>
|
|
37
|
-
SnapshotStore: () =>
|
|
38
|
-
Space: () =>
|
|
39
|
-
SpaceManager: () =>
|
|
40
|
-
SpaceProtocol: () =>
|
|
41
|
-
SpaceProtocolSession: () =>
|
|
42
|
-
TimeframeClock: () =>
|
|
43
|
-
codec: () =>
|
|
44
|
-
createIdFromSpaceKey: () =>
|
|
45
|
-
createMappedFeedWriter: () =>
|
|
32
|
+
MetadataStore: () => import_chunk_RH6TDRML.MetadataStore,
|
|
33
|
+
Pipeline: () => import_chunk_RH6TDRML.Pipeline,
|
|
34
|
+
SnapshotManager: () => import_chunk_RH6TDRML.SnapshotManager,
|
|
35
|
+
SnapshotStore: () => import_chunk_RH6TDRML.SnapshotStore,
|
|
36
|
+
Space: () => import_chunk_RH6TDRML.Space,
|
|
37
|
+
SpaceManager: () => import_chunk_RH6TDRML.SpaceManager,
|
|
38
|
+
SpaceProtocol: () => import_chunk_RH6TDRML.SpaceProtocol,
|
|
39
|
+
SpaceProtocolSession: () => import_chunk_RH6TDRML.SpaceProtocolSession,
|
|
40
|
+
TimeframeClock: () => import_chunk_RH6TDRML.TimeframeClock,
|
|
41
|
+
codec: () => import_chunk_RH6TDRML.codec,
|
|
42
|
+
createIdFromSpaceKey: () => import_chunk_RH6TDRML.createIdFromSpaceKey,
|
|
43
|
+
createMappedFeedWriter: () => import_chunk_RH6TDRML.createMappedFeedWriter,
|
|
46
44
|
encodingOptions: () => encodingOptions,
|
|
47
45
|
getSpaceKeyFromDoc: () => getSpaceKeyFromDoc,
|
|
48
|
-
hasInvitationExpired: () =>
|
|
49
|
-
mapFeedIndexesToTimeframe: () =>
|
|
50
|
-
mapTimeframeToFeedIndexes: () =>
|
|
51
|
-
startAfter: () =>
|
|
52
|
-
valueEncoding: () =>
|
|
46
|
+
hasInvitationExpired: () => import_chunk_RH6TDRML.hasInvitationExpired,
|
|
47
|
+
mapFeedIndexesToTimeframe: () => import_chunk_RH6TDRML.mapFeedIndexesToTimeframe,
|
|
48
|
+
mapTimeframeToFeedIndexes: () => import_chunk_RH6TDRML.mapTimeframeToFeedIndexes,
|
|
49
|
+
startAfter: () => import_chunk_RH6TDRML.startAfter,
|
|
50
|
+
valueEncoding: () => import_chunk_RH6TDRML.valueEncoding
|
|
53
51
|
});
|
|
54
52
|
module.exports = __toCommonJS(node_exports);
|
|
55
|
-
var
|
|
53
|
+
var import_chunk_RH6TDRML = require("./chunk-RH6TDRML.cjs");
|
|
56
54
|
var import_async = require("@dxos/async");
|
|
57
55
|
var import_automerge = require("@dxos/automerge/automerge");
|
|
58
56
|
var import_automerge_repo = require("@dxos/automerge/automerge-repo");
|
|
@@ -70,26 +68,14 @@ var import_invariant2 = require("@dxos/invariant");
|
|
|
70
68
|
var import_log2 = require("@dxos/log");
|
|
71
69
|
var import_indexing = require("@dxos/indexing");
|
|
72
70
|
var import_context3 = require("@dxos/context");
|
|
73
|
-
var import_async3 = require("@dxos/async");
|
|
74
|
-
var import_automerge_repo3 = require("@dxos/automerge/automerge-repo");
|
|
75
|
-
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
76
71
|
var import_invariant3 = require("@dxos/invariant");
|
|
77
|
-
var
|
|
78
|
-
var
|
|
72
|
+
var import_keys2 = require("@dxos/keys");
|
|
73
|
+
var import_log3 = require("@dxos/log");
|
|
74
|
+
var import_util2 = require("@dxos/util");
|
|
75
|
+
var import_automerge_repo3 = require("@dxos/automerge/automerge-repo");
|
|
79
76
|
var import_context4 = require("@dxos/context");
|
|
80
|
-
var import_debug = require("@dxos/debug");
|
|
81
|
-
var import_echo_protocol = require("@dxos/echo-protocol");
|
|
82
77
|
var import_invariant4 = require("@dxos/invariant");
|
|
83
|
-
var import_log3 = require("@dxos/log");
|
|
84
|
-
var import_tracing2 = require("@dxos/tracing");
|
|
85
|
-
var import_invariant5 = require("@dxos/invariant");
|
|
86
|
-
var import_keys2 = require("@dxos/keys");
|
|
87
78
|
var import_log4 = require("@dxos/log");
|
|
88
|
-
var import_util2 = require("@dxos/util");
|
|
89
|
-
var import_automerge_repo5 = require("@dxos/automerge/automerge-repo");
|
|
90
|
-
var import_context5 = require("@dxos/context");
|
|
91
|
-
var import_invariant6 = require("@dxos/invariant");
|
|
92
|
-
var import_log5 = require("@dxos/log");
|
|
93
79
|
var import_teleport_extension_automerge_replicator = require("@dxos/teleport-extension-automerge-replicator");
|
|
94
80
|
function _ts_decorate(decorators, target, key, desc) {
|
|
95
81
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -151,7 +137,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
151
137
|
}
|
|
152
138
|
async close() {
|
|
153
139
|
if (this._lifecycleState === import_context2.LifecycleState.CLOSED) {
|
|
154
|
-
return;
|
|
140
|
+
return this;
|
|
155
141
|
}
|
|
156
142
|
for (const replicator of this._replicators) {
|
|
157
143
|
await replicator.disconnect();
|
|
@@ -494,138 +480,6 @@ var encodingOptions = {
|
|
|
494
480
|
valueEncoding: "buffer"
|
|
495
481
|
};
|
|
496
482
|
var isLevelDbNotFoundError = (err) => err.code === "LEVEL_NOT_FOUND";
|
|
497
|
-
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/local-host-network-adapter.ts";
|
|
498
|
-
var LocalHostNetworkAdapter = class extends import_automerge_repo3.NetworkAdapter {
|
|
499
|
-
constructor() {
|
|
500
|
-
super(...arguments);
|
|
501
|
-
this._peers = /* @__PURE__ */ new Map();
|
|
502
|
-
this._connected = new import_async3.Trigger();
|
|
503
|
-
this._isConnected = false;
|
|
504
|
-
}
|
|
505
|
-
/**
|
|
506
|
-
* Emits `ready` event. That signals to `Repo` that it can start using the adapter.
|
|
507
|
-
*/
|
|
508
|
-
ready() {
|
|
509
|
-
this.emit("ready", {
|
|
510
|
-
network: this
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
/**
|
|
514
|
-
* Called by `Repo` to connect to the network.
|
|
515
|
-
*
|
|
516
|
-
* @param peerId Our peer Id.
|
|
517
|
-
*/
|
|
518
|
-
connect(peerId) {
|
|
519
|
-
this.peerId = peerId;
|
|
520
|
-
this._isConnected = true;
|
|
521
|
-
this._connected.wake();
|
|
522
|
-
}
|
|
523
|
-
send(message) {
|
|
524
|
-
const peer = this._peers.get(message.targetId);
|
|
525
|
-
(0, import_invariant3.invariant)(peer, "Peer not found.", {
|
|
526
|
-
F: __dxlog_file2,
|
|
527
|
-
L: 51,
|
|
528
|
-
S: this,
|
|
529
|
-
A: [
|
|
530
|
-
"peer",
|
|
531
|
-
"'Peer not found.'"
|
|
532
|
-
]
|
|
533
|
-
});
|
|
534
|
-
peer.send(message);
|
|
535
|
-
}
|
|
536
|
-
async close() {
|
|
537
|
-
this._peers.forEach((peer) => peer.disconnect());
|
|
538
|
-
this.emit("close");
|
|
539
|
-
}
|
|
540
|
-
disconnect() {
|
|
541
|
-
}
|
|
542
|
-
async whenConnected() {
|
|
543
|
-
await this._connected.wait({
|
|
544
|
-
timeout: 1e4
|
|
545
|
-
});
|
|
546
|
-
}
|
|
547
|
-
syncRepo({ id, syncMessage }) {
|
|
548
|
-
const peerId = this._getPeerId(id);
|
|
549
|
-
return new import_codec_protobuf.Stream(({ next, close }) => {
|
|
550
|
-
(0, import_invariant3.invariant)(!this._peers.has(peerId), "Peer already connected.", {
|
|
551
|
-
F: __dxlog_file2,
|
|
552
|
-
L: 73,
|
|
553
|
-
S: this,
|
|
554
|
-
A: [
|
|
555
|
-
"!this._peers.has(peerId)",
|
|
556
|
-
"'Peer already connected.'"
|
|
557
|
-
]
|
|
558
|
-
});
|
|
559
|
-
this._peers.set(peerId, {
|
|
560
|
-
connected: true,
|
|
561
|
-
send: (message) => {
|
|
562
|
-
next({
|
|
563
|
-
syncMessage: import_automerge_repo3.cbor.encode(message)
|
|
564
|
-
});
|
|
565
|
-
},
|
|
566
|
-
disconnect: () => {
|
|
567
|
-
this._peers.delete(peerId);
|
|
568
|
-
close();
|
|
569
|
-
this.emit("peer-disconnected", {
|
|
570
|
-
peerId
|
|
571
|
-
});
|
|
572
|
-
}
|
|
573
|
-
});
|
|
574
|
-
(0, import_invariant3.invariant)(this._isConnected, void 0, {
|
|
575
|
-
F: __dxlog_file2,
|
|
576
|
-
L: 90,
|
|
577
|
-
S: this,
|
|
578
|
-
A: [
|
|
579
|
-
"this._isConnected",
|
|
580
|
-
""
|
|
581
|
-
]
|
|
582
|
-
});
|
|
583
|
-
this.emit("peer-candidate", {
|
|
584
|
-
peerMetadata: {},
|
|
585
|
-
peerId
|
|
586
|
-
});
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
|
-
async sendSyncMessage({ id, syncMessage }) {
|
|
590
|
-
(0, import_invariant3.invariant)(this._isConnected, void 0, {
|
|
591
|
-
F: __dxlog_file2,
|
|
592
|
-
L: 99,
|
|
593
|
-
S: this,
|
|
594
|
-
A: [
|
|
595
|
-
"this._isConnected",
|
|
596
|
-
""
|
|
597
|
-
]
|
|
598
|
-
});
|
|
599
|
-
const message = import_automerge_repo3.cbor.decode(syncMessage);
|
|
600
|
-
this.emit("message", message);
|
|
601
|
-
}
|
|
602
|
-
async getHostInfo() {
|
|
603
|
-
(0, import_invariant3.invariant)(this._isConnected, void 0, {
|
|
604
|
-
F: __dxlog_file2,
|
|
605
|
-
L: 105,
|
|
606
|
-
S: this,
|
|
607
|
-
A: [
|
|
608
|
-
"this._isConnected",
|
|
609
|
-
""
|
|
610
|
-
]
|
|
611
|
-
});
|
|
612
|
-
(0, import_invariant3.invariant)(this.peerId, "Peer id not set.", {
|
|
613
|
-
F: __dxlog_file2,
|
|
614
|
-
L: 106,
|
|
615
|
-
S: this,
|
|
616
|
-
A: [
|
|
617
|
-
"this.peerId",
|
|
618
|
-
"'Peer id not set.'"
|
|
619
|
-
]
|
|
620
|
-
});
|
|
621
|
-
return {
|
|
622
|
-
peerId: this.peerId
|
|
623
|
-
};
|
|
624
|
-
}
|
|
625
|
-
_getPeerId(id) {
|
|
626
|
-
return id;
|
|
627
|
-
}
|
|
628
|
-
};
|
|
629
483
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
630
484
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
631
485
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -636,7 +490,7 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
636
490
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
637
491
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
638
492
|
}
|
|
639
|
-
var
|
|
493
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
|
|
640
494
|
var AutomergeHost = class extends import_context.Resource {
|
|
641
495
|
constructor({ db, indexMetadataStore }) {
|
|
642
496
|
super();
|
|
@@ -659,26 +513,20 @@ var AutomergeHost = class extends import_context.Resource {
|
|
|
659
513
|
async _open() {
|
|
660
514
|
this._peerId = `host-${import_keys.PublicKey.random().toHex()}`;
|
|
661
515
|
await this._storage.open?.();
|
|
662
|
-
this._clientNetwork = new LocalHostNetworkAdapter();
|
|
663
516
|
this._repo = new import_automerge_repo.Repo({
|
|
664
517
|
peerId: this._peerId,
|
|
665
518
|
sharePolicy: this._sharePolicy.bind(this),
|
|
666
519
|
storage: this._storage,
|
|
667
520
|
network: [
|
|
668
|
-
// Downstream client.
|
|
669
|
-
this._clientNetwork,
|
|
670
521
|
// Upstream swarm.
|
|
671
522
|
this._echoNetworkAdapter
|
|
672
523
|
]
|
|
673
524
|
});
|
|
674
|
-
this._clientNetwork.ready();
|
|
675
525
|
await this._echoNetworkAdapter.open();
|
|
676
|
-
await this._clientNetwork.whenConnected();
|
|
677
526
|
await this._echoNetworkAdapter.whenConnected();
|
|
678
527
|
}
|
|
679
528
|
async _close() {
|
|
680
529
|
await this._storage.close?.();
|
|
681
|
-
await this._clientNetwork.close();
|
|
682
530
|
await this._echoNetworkAdapter.close();
|
|
683
531
|
await this._ctx.dispose();
|
|
684
532
|
}
|
|
@@ -740,8 +588,8 @@ var AutomergeHost = class extends import_context.Resource {
|
|
|
740
588
|
return;
|
|
741
589
|
}
|
|
742
590
|
const handle = await this.loadDoc(import_context.Context.default(void 0, {
|
|
743
|
-
F:
|
|
744
|
-
L:
|
|
591
|
+
F: __dxlog_file2,
|
|
592
|
+
L: 189
|
|
745
593
|
}), documentId);
|
|
746
594
|
await waitForHeads(handle, heads2);
|
|
747
595
|
}) ?? []);
|
|
@@ -752,8 +600,8 @@ var AutomergeHost = class extends import_context.Resource {
|
|
|
752
600
|
import_log.log.info("re-indexing heads for document", {
|
|
753
601
|
documentId
|
|
754
602
|
}, {
|
|
755
|
-
F:
|
|
756
|
-
L:
|
|
603
|
+
F: __dxlog_file2,
|
|
604
|
+
L: 200,
|
|
757
605
|
S: this,
|
|
758
606
|
C: (f, a) => f(...a)
|
|
759
607
|
});
|
|
@@ -768,8 +616,8 @@ var AutomergeHost = class extends import_context.Resource {
|
|
|
768
616
|
import_log.log.warn("document is not available locally, skipping", {
|
|
769
617
|
documentId
|
|
770
618
|
}, {
|
|
771
|
-
F:
|
|
772
|
-
L:
|
|
619
|
+
F: __dxlog_file2,
|
|
620
|
+
L: 204,
|
|
773
621
|
S: this,
|
|
774
622
|
C: (f, a) => f(...a)
|
|
775
623
|
});
|
|
@@ -777,8 +625,8 @@ var AutomergeHost = class extends import_context.Resource {
|
|
|
777
625
|
}
|
|
778
626
|
const doc = handle.docSync();
|
|
779
627
|
(0, import_invariant.invariant)(doc, void 0, {
|
|
780
|
-
F:
|
|
781
|
-
L:
|
|
628
|
+
F: __dxlog_file2,
|
|
629
|
+
L: 209,
|
|
782
630
|
S: this,
|
|
783
631
|
A: [
|
|
784
632
|
"doc",
|
|
@@ -791,8 +639,8 @@ var AutomergeHost = class extends import_context.Resource {
|
|
|
791
639
|
await batch.write();
|
|
792
640
|
}
|
|
793
641
|
import_log.log.info("done re-indexing heads", void 0, {
|
|
794
|
-
F:
|
|
795
|
-
L:
|
|
642
|
+
F: __dxlog_file2,
|
|
643
|
+
L: 216,
|
|
796
644
|
S: this,
|
|
797
645
|
C: (f, a) => f(...a)
|
|
798
646
|
});
|
|
@@ -885,17 +733,8 @@ var AutomergeHost = class extends import_context.Resource {
|
|
|
885
733
|
/**
|
|
886
734
|
* Flush documents to disk.
|
|
887
735
|
*/
|
|
888
|
-
async flush({
|
|
889
|
-
|
|
890
|
-
await Promise.all(states.map(async ({ heads, documentId }) => {
|
|
891
|
-
if (!heads) {
|
|
892
|
-
return;
|
|
893
|
-
}
|
|
894
|
-
const handle = this._repo.handles[documentId] ?? this._repo.find(documentId);
|
|
895
|
-
await waitForHeads(handle, heads);
|
|
896
|
-
}) ?? []);
|
|
897
|
-
}
|
|
898
|
-
await this._repo.flush(states?.map(({ documentId }) => documentId));
|
|
736
|
+
async flush({ documentIds } = {}) {
|
|
737
|
+
await this._repo.flush(documentIds);
|
|
899
738
|
}
|
|
900
739
|
async getHeads(documentId) {
|
|
901
740
|
const handle = this._repo.handles[documentId];
|
|
@@ -909,24 +748,6 @@ var AutomergeHost = class extends import_context.Resource {
|
|
|
909
748
|
return this._headsStore.getHeads(documentId);
|
|
910
749
|
}
|
|
911
750
|
}
|
|
912
|
-
/**
|
|
913
|
-
* Host <-> Client sync.
|
|
914
|
-
*/
|
|
915
|
-
syncRepo(request) {
|
|
916
|
-
return this._clientNetwork.syncRepo(request);
|
|
917
|
-
}
|
|
918
|
-
/**
|
|
919
|
-
* Host <-> Client sync.
|
|
920
|
-
*/
|
|
921
|
-
sendSyncMessage(request) {
|
|
922
|
-
return this._clientNetwork.sendSyncMessage(request);
|
|
923
|
-
}
|
|
924
|
-
/**
|
|
925
|
-
* Host <-> Client sync.
|
|
926
|
-
*/
|
|
927
|
-
async getHostInfo() {
|
|
928
|
-
return this._clientNetwork.getHostInfo();
|
|
929
|
-
}
|
|
930
751
|
};
|
|
931
752
|
_ts_decorate2([
|
|
932
753
|
import_tracing.trace.info()
|
|
@@ -971,331 +792,9 @@ var waitForHeads = async (handle, heads) => {
|
|
|
971
792
|
var changeIsPresentInDoc = (doc, changeHash) => {
|
|
972
793
|
return !!(0, import_automerge.getBackend)(doc).getChangeByHash(changeHash);
|
|
973
794
|
};
|
|
974
|
-
|
|
975
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
976
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
977
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
978
|
-
else
|
|
979
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
980
|
-
if (d = decorators[i])
|
|
981
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
982
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
983
|
-
}
|
|
984
|
-
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-doc-loader.ts";
|
|
985
|
-
var AutomergeDocumentLoaderImpl = class {
|
|
986
|
-
constructor(_spaceId, _repo, _spaceKey) {
|
|
987
|
-
this._spaceId = _spaceId;
|
|
988
|
-
this._repo = _repo;
|
|
989
|
-
this._spaceKey = _spaceKey;
|
|
990
|
-
this._spaceRootDocHandle = null;
|
|
991
|
-
this._objectDocumentHandles = /* @__PURE__ */ new Map();
|
|
992
|
-
this._objectsPendingDocumentLoad = /* @__PURE__ */ new Set();
|
|
993
|
-
this.onObjectDocumentLoaded = new import_async4.Event();
|
|
994
|
-
}
|
|
995
|
-
getAllHandles() {
|
|
996
|
-
return this._spaceRootDocHandle != null ? [
|
|
997
|
-
this._spaceRootDocHandle,
|
|
998
|
-
...new Set(this._objectDocumentHandles.values())
|
|
999
|
-
] : [];
|
|
1000
|
-
}
|
|
1001
|
-
async loadSpaceRootDocHandle(ctx, spaceState) {
|
|
1002
|
-
if (this._spaceRootDocHandle != null) {
|
|
1003
|
-
return;
|
|
1004
|
-
}
|
|
1005
|
-
if (!spaceState.rootUrl) {
|
|
1006
|
-
throw new Error("Database opened with no rootUrl");
|
|
1007
|
-
}
|
|
1008
|
-
const existingDocHandle = await this._initDocHandle(ctx, spaceState.rootUrl);
|
|
1009
|
-
const doc = existingDocHandle.docSync();
|
|
1010
|
-
(0, import_invariant4.invariant)(doc, void 0, {
|
|
1011
|
-
F: __dxlog_file4,
|
|
1012
|
-
L: 84,
|
|
1013
|
-
S: this,
|
|
1014
|
-
A: [
|
|
1015
|
-
"doc",
|
|
1016
|
-
""
|
|
1017
|
-
]
|
|
1018
|
-
});
|
|
1019
|
-
(0, import_invariant4.invariant)(doc.version === import_echo_protocol.SpaceDocVersion.CURRENT, void 0, {
|
|
1020
|
-
F: __dxlog_file4,
|
|
1021
|
-
L: 85,
|
|
1022
|
-
S: this,
|
|
1023
|
-
A: [
|
|
1024
|
-
"doc.version === SpaceDocVersion.CURRENT",
|
|
1025
|
-
""
|
|
1026
|
-
]
|
|
1027
|
-
});
|
|
1028
|
-
if (doc.access == null) {
|
|
1029
|
-
this._initDocAccess(existingDocHandle);
|
|
1030
|
-
}
|
|
1031
|
-
this._spaceRootDocHandle = existingDocHandle;
|
|
1032
|
-
}
|
|
1033
|
-
loadObjectDocument(objectIdOrMany) {
|
|
1034
|
-
const objectIds = Array.isArray(objectIdOrMany) ? objectIdOrMany : [
|
|
1035
|
-
objectIdOrMany
|
|
1036
|
-
];
|
|
1037
|
-
let hasUrlsToLoad = false;
|
|
1038
|
-
const urlsToLoad = {};
|
|
1039
|
-
for (const objectId of objectIds) {
|
|
1040
|
-
(0, import_invariant4.invariant)(this._spaceRootDocHandle, void 0, {
|
|
1041
|
-
F: __dxlog_file4,
|
|
1042
|
-
L: 97,
|
|
1043
|
-
S: this,
|
|
1044
|
-
A: [
|
|
1045
|
-
"this._spaceRootDocHandle",
|
|
1046
|
-
""
|
|
1047
|
-
]
|
|
1048
|
-
});
|
|
1049
|
-
if (this._objectDocumentHandles.has(objectId) || this._objectsPendingDocumentLoad.has(objectId)) {
|
|
1050
|
-
continue;
|
|
1051
|
-
}
|
|
1052
|
-
const spaceRootDoc = this._spaceRootDocHandle.docSync();
|
|
1053
|
-
(0, import_invariant4.invariant)(spaceRootDoc, void 0, {
|
|
1054
|
-
F: __dxlog_file4,
|
|
1055
|
-
L: 102,
|
|
1056
|
-
S: this,
|
|
1057
|
-
A: [
|
|
1058
|
-
"spaceRootDoc",
|
|
1059
|
-
""
|
|
1060
|
-
]
|
|
1061
|
-
});
|
|
1062
|
-
const documentUrl = (spaceRootDoc.links ?? {})[objectId];
|
|
1063
|
-
if (documentUrl == null) {
|
|
1064
|
-
this._objectsPendingDocumentLoad.add(objectId);
|
|
1065
|
-
import_log3.log.info("loading delayed until object links are initialized", {
|
|
1066
|
-
objectId
|
|
1067
|
-
}, {
|
|
1068
|
-
F: __dxlog_file4,
|
|
1069
|
-
L: 106,
|
|
1070
|
-
S: this,
|
|
1071
|
-
C: (f, a) => f(...a)
|
|
1072
|
-
});
|
|
1073
|
-
} else {
|
|
1074
|
-
urlsToLoad[objectId] = documentUrl;
|
|
1075
|
-
hasUrlsToLoad = true;
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1078
|
-
if (hasUrlsToLoad) {
|
|
1079
|
-
this._loadLinkedObjects(urlsToLoad);
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
1082
|
-
getObjectDocumentId(objectId) {
|
|
1083
|
-
(0, import_invariant4.invariant)(this._spaceRootDocHandle, void 0, {
|
|
1084
|
-
F: __dxlog_file4,
|
|
1085
|
-
L: 118,
|
|
1086
|
-
S: this,
|
|
1087
|
-
A: [
|
|
1088
|
-
"this._spaceRootDocHandle",
|
|
1089
|
-
""
|
|
1090
|
-
]
|
|
1091
|
-
});
|
|
1092
|
-
const spaceRootDoc = this._spaceRootDocHandle.docSync();
|
|
1093
|
-
(0, import_invariant4.invariant)(spaceRootDoc, void 0, {
|
|
1094
|
-
F: __dxlog_file4,
|
|
1095
|
-
L: 120,
|
|
1096
|
-
S: this,
|
|
1097
|
-
A: [
|
|
1098
|
-
"spaceRootDoc",
|
|
1099
|
-
""
|
|
1100
|
-
]
|
|
1101
|
-
});
|
|
1102
|
-
if (spaceRootDoc.objects?.[objectId]) {
|
|
1103
|
-
return this._spaceRootDocHandle.documentId;
|
|
1104
|
-
}
|
|
1105
|
-
const documentUrl = (spaceRootDoc.links ?? {})[objectId];
|
|
1106
|
-
return documentUrl && (0, import_automerge_repo4.interpretAsDocumentId)(documentUrl);
|
|
1107
|
-
}
|
|
1108
|
-
onObjectLinksUpdated(links) {
|
|
1109
|
-
if (!links) {
|
|
1110
|
-
return;
|
|
1111
|
-
}
|
|
1112
|
-
const linksAwaitingLoad = Object.entries(links).filter(([objectId]) => this._objectsPendingDocumentLoad.has(objectId));
|
|
1113
|
-
this._loadLinkedObjects(Object.fromEntries(linksAwaitingLoad));
|
|
1114
|
-
linksAwaitingLoad.forEach(([objectId]) => this._objectsPendingDocumentLoad.delete(objectId));
|
|
1115
|
-
}
|
|
1116
|
-
getSpaceRootDocHandle() {
|
|
1117
|
-
(0, import_invariant4.invariant)(this._spaceRootDocHandle, void 0, {
|
|
1118
|
-
F: __dxlog_file4,
|
|
1119
|
-
L: 140,
|
|
1120
|
-
S: this,
|
|
1121
|
-
A: [
|
|
1122
|
-
"this._spaceRootDocHandle",
|
|
1123
|
-
""
|
|
1124
|
-
]
|
|
1125
|
-
});
|
|
1126
|
-
return this._spaceRootDocHandle;
|
|
1127
|
-
}
|
|
1128
|
-
createDocumentForObject(objectId) {
|
|
1129
|
-
(0, import_invariant4.invariant)(this._spaceRootDocHandle, void 0, {
|
|
1130
|
-
F: __dxlog_file4,
|
|
1131
|
-
L: 145,
|
|
1132
|
-
S: this,
|
|
1133
|
-
A: [
|
|
1134
|
-
"this._spaceRootDocHandle",
|
|
1135
|
-
""
|
|
1136
|
-
]
|
|
1137
|
-
});
|
|
1138
|
-
const spaceDocHandle = this._repo.create({
|
|
1139
|
-
version: import_echo_protocol.SpaceDocVersion.CURRENT
|
|
1140
|
-
});
|
|
1141
|
-
this._initDocAccess(spaceDocHandle);
|
|
1142
|
-
this.onObjectBoundToDocument(spaceDocHandle, objectId);
|
|
1143
|
-
this._spaceRootDocHandle.change((newDoc) => {
|
|
1144
|
-
newDoc.links ??= {};
|
|
1145
|
-
newDoc.links[objectId] = spaceDocHandle.url;
|
|
1146
|
-
});
|
|
1147
|
-
return spaceDocHandle;
|
|
1148
|
-
}
|
|
1149
|
-
onObjectBoundToDocument(handle, objectId) {
|
|
1150
|
-
this._objectDocumentHandles.set(objectId, handle);
|
|
1151
|
-
}
|
|
1152
|
-
clearHandleReferences() {
|
|
1153
|
-
const objectsWithHandles = [
|
|
1154
|
-
...this._objectDocumentHandles.keys()
|
|
1155
|
-
];
|
|
1156
|
-
this._objectDocumentHandles.clear();
|
|
1157
|
-
this._spaceRootDocHandle = null;
|
|
1158
|
-
return objectsWithHandles;
|
|
1159
|
-
}
|
|
1160
|
-
_loadLinkedObjects(links) {
|
|
1161
|
-
if (!links) {
|
|
1162
|
-
return;
|
|
1163
|
-
}
|
|
1164
|
-
for (const [objectId, automergeUrl] of Object.entries(links)) {
|
|
1165
|
-
const logMeta = {
|
|
1166
|
-
objectId,
|
|
1167
|
-
automergeUrl
|
|
1168
|
-
};
|
|
1169
|
-
const objectDocumentHandle = this._objectDocumentHandles.get(objectId);
|
|
1170
|
-
if (objectDocumentHandle != null && objectDocumentHandle.url !== automergeUrl) {
|
|
1171
|
-
import_log3.log.warn("object already inlined in a different document, ignoring the link", {
|
|
1172
|
-
...logMeta,
|
|
1173
|
-
actualDocumentUrl: objectDocumentHandle.url
|
|
1174
|
-
}, {
|
|
1175
|
-
F: __dxlog_file4,
|
|
1176
|
-
L: 177,
|
|
1177
|
-
S: this,
|
|
1178
|
-
C: (f, a) => f(...a)
|
|
1179
|
-
});
|
|
1180
|
-
continue;
|
|
1181
|
-
}
|
|
1182
|
-
if (objectDocumentHandle?.url === automergeUrl) {
|
|
1183
|
-
import_log3.log.warn("object document was already loaded", logMeta, {
|
|
1184
|
-
F: __dxlog_file4,
|
|
1185
|
-
L: 184,
|
|
1186
|
-
S: this,
|
|
1187
|
-
C: (f, a) => f(...a)
|
|
1188
|
-
});
|
|
1189
|
-
continue;
|
|
1190
|
-
}
|
|
1191
|
-
const handle = this._repo.find(automergeUrl);
|
|
1192
|
-
import_log3.log.debug("document loading triggered", logMeta, {
|
|
1193
|
-
F: __dxlog_file4,
|
|
1194
|
-
L: 188,
|
|
1195
|
-
S: this,
|
|
1196
|
-
C: (f, a) => f(...a)
|
|
1197
|
-
});
|
|
1198
|
-
this._objectDocumentHandles.set(objectId, handle);
|
|
1199
|
-
void this._createObjectOnDocumentLoad(handle, objectId);
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
|
-
async _initDocHandle(ctx, url) {
|
|
1203
|
-
const docHandle = this._repo.find(url);
|
|
1204
|
-
while (true) {
|
|
1205
|
-
try {
|
|
1206
|
-
await (0, import_debug.warnAfterTimeout)(5e3, "Automerge root doc load timeout (CoreDatabase)", async () => {
|
|
1207
|
-
await (0, import_context4.cancelWithContext)(ctx, docHandle.whenReady());
|
|
1208
|
-
});
|
|
1209
|
-
break;
|
|
1210
|
-
} catch (err) {
|
|
1211
|
-
if (`${err}`.includes("Timeout")) {
|
|
1212
|
-
import_log3.log.info("wraparound", {
|
|
1213
|
-
id: docHandle.documentId,
|
|
1214
|
-
state: docHandle.state
|
|
1215
|
-
}, {
|
|
1216
|
-
F: __dxlog_file4,
|
|
1217
|
-
L: 204,
|
|
1218
|
-
S: this,
|
|
1219
|
-
C: (f, a) => f(...a)
|
|
1220
|
-
});
|
|
1221
|
-
continue;
|
|
1222
|
-
}
|
|
1223
|
-
throw err;
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
if (docHandle.state === "unavailable") {
|
|
1227
|
-
throw new Error("Automerge document is unavailable");
|
|
1228
|
-
}
|
|
1229
|
-
return docHandle;
|
|
1230
|
-
}
|
|
1231
|
-
_initDocAccess(handle) {
|
|
1232
|
-
handle.change((newDoc) => {
|
|
1233
|
-
newDoc.access ??= {
|
|
1234
|
-
spaceKey: this._spaceKey.toHex()
|
|
1235
|
-
};
|
|
1236
|
-
newDoc.access.spaceKey = this._spaceKey.toHex();
|
|
1237
|
-
});
|
|
1238
|
-
}
|
|
1239
|
-
async _createObjectOnDocumentLoad(handle, objectId) {
|
|
1240
|
-
try {
|
|
1241
|
-
await handle.whenReady();
|
|
1242
|
-
const logMeta = {
|
|
1243
|
-
objectId,
|
|
1244
|
-
docUrl: handle.url
|
|
1245
|
-
};
|
|
1246
|
-
if (this.onObjectDocumentLoaded.listenerCount() === 0) {
|
|
1247
|
-
import_log3.log.info("document loaded after all listeners were removed", logMeta, {
|
|
1248
|
-
F: __dxlog_file4,
|
|
1249
|
-
L: 231,
|
|
1250
|
-
S: this,
|
|
1251
|
-
C: (f, a) => f(...a)
|
|
1252
|
-
});
|
|
1253
|
-
return;
|
|
1254
|
-
}
|
|
1255
|
-
const objectDocHandle = this._objectDocumentHandles.get(objectId);
|
|
1256
|
-
if (objectDocHandle?.url !== handle.url) {
|
|
1257
|
-
import_log3.log.warn("object was rebound while a document was loading, discarding handle", logMeta, {
|
|
1258
|
-
F: __dxlog_file4,
|
|
1259
|
-
L: 236,
|
|
1260
|
-
S: this,
|
|
1261
|
-
C: (f, a) => f(...a)
|
|
1262
|
-
});
|
|
1263
|
-
return;
|
|
1264
|
-
}
|
|
1265
|
-
this.onObjectDocumentLoaded.emit({
|
|
1266
|
-
handle,
|
|
1267
|
-
objectId
|
|
1268
|
-
});
|
|
1269
|
-
} catch (err) {
|
|
1270
|
-
const shouldRetryLoading = this.onObjectDocumentLoaded.listenerCount() > 0;
|
|
1271
|
-
import_log3.log.warn("failed to load a document", {
|
|
1272
|
-
objectId,
|
|
1273
|
-
automergeUrl: handle.url,
|
|
1274
|
-
retryLoading: shouldRetryLoading,
|
|
1275
|
-
err
|
|
1276
|
-
}, {
|
|
1277
|
-
F: __dxlog_file4,
|
|
1278
|
-
L: 242,
|
|
1279
|
-
S: this,
|
|
1280
|
-
C: (f, a) => f(...a)
|
|
1281
|
-
});
|
|
1282
|
-
if (shouldRetryLoading) {
|
|
1283
|
-
await this._createObjectOnDocumentLoad(handle, objectId);
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
}
|
|
1287
|
-
};
|
|
1288
|
-
_ts_decorate3([
|
|
1289
|
-
import_tracing2.trace.span({
|
|
1290
|
-
showInBrowserTimeline: true
|
|
1291
|
-
})
|
|
1292
|
-
], AutomergeDocumentLoaderImpl.prototype, "loadSpaceRootDocHandle", null);
|
|
1293
|
-
AutomergeDocumentLoaderImpl = _ts_decorate3([
|
|
1294
|
-
import_tracing2.trace.resource()
|
|
1295
|
-
], AutomergeDocumentLoaderImpl);
|
|
1296
|
-
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/mesh-echo-replicator-connection.ts";
|
|
795
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/mesh-echo-replicator-connection.ts";
|
|
1297
796
|
var DEFAULT_FACTORY = (params) => new import_teleport_extension_automerge_replicator.AutomergeReplicator(...params);
|
|
1298
|
-
var MeshReplicatorConnection = class extends
|
|
797
|
+
var MeshReplicatorConnection = class extends import_context4.Resource {
|
|
1299
798
|
constructor(_params) {
|
|
1300
799
|
super();
|
|
1301
800
|
this._params = _params;
|
|
@@ -1311,8 +810,8 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1311
810
|
});
|
|
1312
811
|
this.writable = new WritableStream({
|
|
1313
812
|
write: async (message, controller) => {
|
|
1314
|
-
(0,
|
|
1315
|
-
F:
|
|
813
|
+
(0, import_invariant4.invariant)(this._isEnabled, "Writing to a disabled connection", {
|
|
814
|
+
F: __dxlog_file3,
|
|
1316
815
|
L: 47,
|
|
1317
816
|
S: this,
|
|
1318
817
|
A: [
|
|
@@ -1322,7 +821,7 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1322
821
|
});
|
|
1323
822
|
try {
|
|
1324
823
|
await this.replicatorExtension.sendSyncMessage({
|
|
1325
|
-
payload:
|
|
824
|
+
payload: import_automerge_repo3.cbor.encode(message)
|
|
1326
825
|
});
|
|
1327
826
|
} catch (err) {
|
|
1328
827
|
controller.error(err);
|
|
@@ -1339,12 +838,12 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1339
838
|
onStartReplication: async (info, remotePeerId) => {
|
|
1340
839
|
this.remoteDeviceKey = remotePeerId;
|
|
1341
840
|
this._remotePeerId = info.id;
|
|
1342
|
-
(0,
|
|
841
|
+
(0, import_log4.log)("onStartReplication", {
|
|
1343
842
|
id: info.id,
|
|
1344
843
|
thisPeerId: this.peerId,
|
|
1345
844
|
remotePeerId: remotePeerId.toHex()
|
|
1346
845
|
}, {
|
|
1347
|
-
F:
|
|
846
|
+
F: __dxlog_file3,
|
|
1348
847
|
L: 81,
|
|
1349
848
|
S: this,
|
|
1350
849
|
C: (f, a) => f(...a)
|
|
@@ -1355,7 +854,7 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1355
854
|
if (!this._isEnabled) {
|
|
1356
855
|
return;
|
|
1357
856
|
}
|
|
1358
|
-
const message =
|
|
857
|
+
const message = import_automerge_repo3.cbor.decode(payload);
|
|
1359
858
|
readableStreamController.enqueue(message);
|
|
1360
859
|
},
|
|
1361
860
|
onClose: async () => {
|
|
@@ -1370,8 +869,8 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1370
869
|
}
|
|
1371
870
|
}
|
|
1372
871
|
get peerId() {
|
|
1373
|
-
(0,
|
|
1374
|
-
F:
|
|
872
|
+
(0, import_invariant4.invariant)(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
873
|
+
F: __dxlog_file3,
|
|
1375
874
|
L: 107,
|
|
1376
875
|
S: this,
|
|
1377
876
|
A: [
|
|
@@ -1389,8 +888,8 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1389
888
|
* Call after the remote peer has connected.
|
|
1390
889
|
*/
|
|
1391
890
|
enable() {
|
|
1392
|
-
(0,
|
|
1393
|
-
F:
|
|
891
|
+
(0, import_invariant4.invariant)(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
892
|
+
F: __dxlog_file3,
|
|
1394
893
|
L: 120,
|
|
1395
894
|
S: this,
|
|
1396
895
|
A: [
|
|
@@ -1407,7 +906,7 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1407
906
|
this._isEnabled = false;
|
|
1408
907
|
}
|
|
1409
908
|
};
|
|
1410
|
-
var
|
|
909
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/mesh-echo-replicator.ts";
|
|
1411
910
|
var MeshEchoReplicator = class {
|
|
1412
911
|
constructor() {
|
|
1413
912
|
this._connections = /* @__PURE__ */ new Set();
|
|
@@ -1419,6 +918,9 @@ var MeshEchoReplicator = class {
|
|
|
1419
918
|
this._context = context;
|
|
1420
919
|
}
|
|
1421
920
|
async disconnect() {
|
|
921
|
+
for (const connection of this._connectionsPerPeer.values()) {
|
|
922
|
+
this._context?.onConnectionClosed(connection);
|
|
923
|
+
}
|
|
1422
924
|
for (const connection of this._connections) {
|
|
1423
925
|
await connection.close();
|
|
1424
926
|
}
|
|
@@ -1427,9 +929,9 @@ var MeshEchoReplicator = class {
|
|
|
1427
929
|
this._context = null;
|
|
1428
930
|
}
|
|
1429
931
|
createExtension(extensionFactory) {
|
|
1430
|
-
(0,
|
|
1431
|
-
F:
|
|
1432
|
-
L:
|
|
932
|
+
(0, import_invariant3.invariant)(this._context, void 0, {
|
|
933
|
+
F: __dxlog_file4,
|
|
934
|
+
L: 54,
|
|
1433
935
|
S: this,
|
|
1434
936
|
A: [
|
|
1435
937
|
"this._context",
|
|
@@ -1440,17 +942,17 @@ var MeshEchoReplicator = class {
|
|
|
1440
942
|
ownPeerId: this._context.peerId,
|
|
1441
943
|
replicatorFactory: extensionFactory,
|
|
1442
944
|
onRemoteConnected: async () => {
|
|
1443
|
-
(0,
|
|
945
|
+
(0, import_log3.log)("onRemoteConnected", {
|
|
1444
946
|
peerId: connection.peerId
|
|
1445
947
|
}, {
|
|
1446
|
-
F:
|
|
1447
|
-
L:
|
|
948
|
+
F: __dxlog_file4,
|
|
949
|
+
L: 60,
|
|
1448
950
|
S: this,
|
|
1449
951
|
C: (f, a) => f(...a)
|
|
1450
952
|
});
|
|
1451
|
-
(0,
|
|
1452
|
-
F:
|
|
1453
|
-
L:
|
|
953
|
+
(0, import_invariant3.invariant)(this._context, void 0, {
|
|
954
|
+
F: __dxlog_file4,
|
|
955
|
+
L: 61,
|
|
1454
956
|
S: this,
|
|
1455
957
|
A: [
|
|
1456
958
|
"this._context",
|
|
@@ -1466,11 +968,11 @@ var MeshEchoReplicator = class {
|
|
|
1466
968
|
}
|
|
1467
969
|
},
|
|
1468
970
|
onRemoteDisconnected: async () => {
|
|
1469
|
-
(0,
|
|
971
|
+
(0, import_log3.log)("onRemoteDisconnected", {
|
|
1470
972
|
peerId: connection.peerId
|
|
1471
973
|
}, {
|
|
1472
|
-
F:
|
|
1473
|
-
L:
|
|
974
|
+
F: __dxlog_file4,
|
|
975
|
+
L: 72,
|
|
1474
976
|
S: this,
|
|
1475
977
|
C: (f, a) => f(...a)
|
|
1476
978
|
});
|
|
@@ -1480,18 +982,18 @@ var MeshEchoReplicator = class {
|
|
|
1480
982
|
this._connections.delete(connection);
|
|
1481
983
|
},
|
|
1482
984
|
shouldAdvertise: async (params) => {
|
|
1483
|
-
(0,
|
|
985
|
+
(0, import_log3.log)("shouldAdvertise", {
|
|
1484
986
|
peerId: connection.peerId,
|
|
1485
987
|
documentId: params.documentId
|
|
1486
988
|
}, {
|
|
1487
|
-
F:
|
|
1488
|
-
L:
|
|
989
|
+
F: __dxlog_file4,
|
|
990
|
+
L: 79,
|
|
1489
991
|
S: this,
|
|
1490
992
|
C: (f, a) => f(...a)
|
|
1491
993
|
});
|
|
1492
|
-
(0,
|
|
1493
|
-
F:
|
|
1494
|
-
L:
|
|
994
|
+
(0, import_invariant3.invariant)(this._context, void 0, {
|
|
995
|
+
F: __dxlog_file4,
|
|
996
|
+
L: 80,
|
|
1495
997
|
S: this,
|
|
1496
998
|
A: [
|
|
1497
999
|
"this._context",
|
|
@@ -1501,12 +1003,12 @@ var MeshEchoReplicator = class {
|
|
|
1501
1003
|
try {
|
|
1502
1004
|
const spaceKey = await this._context.getContainingSpaceForDocument(params.documentId);
|
|
1503
1005
|
if (!spaceKey) {
|
|
1504
|
-
(0,
|
|
1006
|
+
(0, import_log3.log)("space key not found for share policy check", {
|
|
1505
1007
|
peerId: connection.peerId,
|
|
1506
1008
|
documentId: params.documentId
|
|
1507
1009
|
}, {
|
|
1508
|
-
F:
|
|
1509
|
-
L:
|
|
1010
|
+
F: __dxlog_file4,
|
|
1011
|
+
L: 84,
|
|
1510
1012
|
S: this,
|
|
1511
1013
|
C: (f, a) => f(...a)
|
|
1512
1014
|
});
|
|
@@ -1514,19 +1016,19 @@ var MeshEchoReplicator = class {
|
|
|
1514
1016
|
}
|
|
1515
1017
|
const authorizedDevices = this._authorizedDevices.get(spaceKey);
|
|
1516
1018
|
if (!connection.remoteDeviceKey) {
|
|
1517
|
-
(0,
|
|
1019
|
+
(0, import_log3.log)("device key not found for share policy check", {
|
|
1518
1020
|
peerId: connection.peerId,
|
|
1519
1021
|
documentId: params.documentId
|
|
1520
1022
|
}, {
|
|
1521
|
-
F:
|
|
1522
|
-
L:
|
|
1023
|
+
F: __dxlog_file4,
|
|
1024
|
+
L: 94,
|
|
1523
1025
|
S: this,
|
|
1524
1026
|
C: (f, a) => f(...a)
|
|
1525
1027
|
});
|
|
1526
1028
|
return false;
|
|
1527
1029
|
}
|
|
1528
1030
|
const isAuthorized = authorizedDevices?.has(connection.remoteDeviceKey) ?? false;
|
|
1529
|
-
(0,
|
|
1031
|
+
(0, import_log3.log)("share policy check", {
|
|
1530
1032
|
localPeer: this._context.peerId,
|
|
1531
1033
|
remotePeer: connection.peerId,
|
|
1532
1034
|
documentId: params.documentId,
|
|
@@ -1534,16 +1036,16 @@ var MeshEchoReplicator = class {
|
|
|
1534
1036
|
spaceKey,
|
|
1535
1037
|
isAuthorized
|
|
1536
1038
|
}, {
|
|
1537
|
-
F:
|
|
1538
|
-
L:
|
|
1039
|
+
F: __dxlog_file4,
|
|
1040
|
+
L: 102,
|
|
1539
1041
|
S: this,
|
|
1540
1042
|
C: (f, a) => f(...a)
|
|
1541
1043
|
});
|
|
1542
1044
|
return isAuthorized;
|
|
1543
1045
|
} catch (err) {
|
|
1544
|
-
|
|
1545
|
-
F:
|
|
1546
|
-
L:
|
|
1046
|
+
import_log3.log.catch(err, void 0, {
|
|
1047
|
+
F: __dxlog_file4,
|
|
1048
|
+
L: 112,
|
|
1547
1049
|
S: this,
|
|
1548
1050
|
C: (f, a) => f(...a)
|
|
1549
1051
|
});
|
|
@@ -1555,12 +1057,12 @@ var MeshEchoReplicator = class {
|
|
|
1555
1057
|
return connection.replicatorExtension;
|
|
1556
1058
|
}
|
|
1557
1059
|
authorizeDevice(spaceKey, deviceKey) {
|
|
1558
|
-
(0,
|
|
1060
|
+
(0, import_log3.log)("authorizeDevice", {
|
|
1559
1061
|
spaceKey,
|
|
1560
1062
|
deviceKey
|
|
1561
1063
|
}, {
|
|
1562
|
-
F:
|
|
1563
|
-
L:
|
|
1064
|
+
F: __dxlog_file4,
|
|
1065
|
+
L: 123,
|
|
1564
1066
|
S: this,
|
|
1565
1067
|
C: (f, a) => f(...a)
|
|
1566
1068
|
});
|
|
@@ -1578,14 +1080,12 @@ var MeshEchoReplicator = class {
|
|
|
1578
1080
|
0 && (module.exports = {
|
|
1579
1081
|
AuthExtension,
|
|
1580
1082
|
AuthStatus,
|
|
1581
|
-
AutomergeDocumentLoaderImpl,
|
|
1582
1083
|
AutomergeHost,
|
|
1583
1084
|
CredentialRetrieverExtension,
|
|
1584
1085
|
CredentialServerExtension,
|
|
1585
1086
|
DataServiceImpl,
|
|
1586
1087
|
DocumentsSynchronizer,
|
|
1587
1088
|
LevelDBStorageAdapter,
|
|
1588
|
-
LocalHostNetworkAdapter,
|
|
1589
1089
|
MOCK_AUTH_PROVIDER,
|
|
1590
1090
|
MOCK_AUTH_VERIFIER,
|
|
1591
1091
|
MeshEchoReplicator,
|