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