@dxos/echo-pipeline 0.5.9-main.a2de4fa → 0.5.9-main.a75fa71
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-I2J5TTHJ.mjs → chunk-HS77A4I4.mjs} +174 -23
- package/dist/lib/browser/{chunk-I2J5TTHJ.mjs.map → chunk-HS77A4I4.mjs.map} +4 -4
- package/dist/lib/browser/index.mjs +91 -42
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +11 -7
- package/dist/lib/browser/testing/index.mjs.map +1 -1
- package/dist/lib/node/{chunk-QPCNQ4ZK.cjs → chunk-Y5U7UXEL.cjs} +185 -34
- package/dist/lib/node/{chunk-QPCNQ4ZK.cjs.map → chunk-Y5U7UXEL.cjs.map} +4 -4
- package/dist/lib/node/index.cjs +126 -77
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +21 -17
- package/dist/lib/node/testing/index.cjs.map +1 -1
- package/dist/types/src/automerge/automerge-host.d.ts +40 -2
- package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
- package/dist/types/src/automerge/echo-network-adapter.d.ts +2 -0
- package/dist/types/src/automerge/echo-network-adapter.d.ts.map +1 -1
- package/dist/types/src/space/admission-discovery-extension.d.ts +30 -0
- package/dist/types/src/space/admission-discovery-extension.d.ts.map +1 -0
- package/dist/types/src/space/index.d.ts +1 -0
- package/dist/types/src/space/index.d.ts.map +1 -1
- package/dist/types/src/space/space-manager.d.ts +8 -0
- package/dist/types/src/space/space-manager.d.ts.map +1 -1
- package/package.json +33 -33
- package/src/automerge/automerge-host.ts +96 -18
- package/src/automerge/echo-network-adapter.ts +10 -4
- package/src/automerge/mesh-echo-replicator.ts +1 -1
- package/src/space/admission-discovery-extension.ts +90 -0
- package/src/space/index.ts +1 -0
- package/src/space/space-manager.ts +46 -1
package/dist/lib/node/index.cjs
CHANGED
|
@@ -18,43 +18,44 @@ 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_Y5U7UXEL.AuthExtension,
|
|
22
|
+
AuthStatus: () => import_chunk_Y5U7UXEL.AuthStatus,
|
|
23
23
|
AutomergeDocumentLoaderImpl: () => AutomergeDocumentLoaderImpl,
|
|
24
24
|
AutomergeHost: () => AutomergeHost,
|
|
25
|
-
|
|
25
|
+
CredentialRetrieverExtension: () => import_chunk_Y5U7UXEL.CredentialRetrieverExtension,
|
|
26
|
+
CredentialServerExtension: () => import_chunk_Y5U7UXEL.CredentialServerExtension,
|
|
27
|
+
DataServiceImpl: () => import_chunk_Y5U7UXEL.DataServiceImpl,
|
|
26
28
|
LevelDBStorageAdapter: () => LevelDBStorageAdapter,
|
|
27
29
|
LocalHostNetworkAdapter: () => LocalHostNetworkAdapter,
|
|
28
|
-
MOCK_AUTH_PROVIDER: () =>
|
|
29
|
-
MOCK_AUTH_VERIFIER: () =>
|
|
30
|
+
MOCK_AUTH_PROVIDER: () => import_chunk_Y5U7UXEL.MOCK_AUTH_PROVIDER,
|
|
31
|
+
MOCK_AUTH_VERIFIER: () => import_chunk_Y5U7UXEL.MOCK_AUTH_VERIFIER,
|
|
30
32
|
MeshEchoReplicator: () => MeshEchoReplicator,
|
|
31
|
-
MetadataStore: () =>
|
|
32
|
-
Pipeline: () =>
|
|
33
|
-
SnapshotManager: () =>
|
|
34
|
-
SnapshotStore: () =>
|
|
35
|
-
Space: () =>
|
|
36
|
-
SpaceManager: () =>
|
|
37
|
-
SpaceProtocol: () =>
|
|
38
|
-
SpaceProtocolSession: () =>
|
|
39
|
-
TimeframeClock: () =>
|
|
40
|
-
codec: () =>
|
|
41
|
-
createIdFromSpaceKey: () =>
|
|
42
|
-
createMappedFeedWriter: () =>
|
|
33
|
+
MetadataStore: () => import_chunk_Y5U7UXEL.MetadataStore,
|
|
34
|
+
Pipeline: () => import_chunk_Y5U7UXEL.Pipeline,
|
|
35
|
+
SnapshotManager: () => import_chunk_Y5U7UXEL.SnapshotManager,
|
|
36
|
+
SnapshotStore: () => import_chunk_Y5U7UXEL.SnapshotStore,
|
|
37
|
+
Space: () => import_chunk_Y5U7UXEL.Space,
|
|
38
|
+
SpaceManager: () => import_chunk_Y5U7UXEL.SpaceManager,
|
|
39
|
+
SpaceProtocol: () => import_chunk_Y5U7UXEL.SpaceProtocol,
|
|
40
|
+
SpaceProtocolSession: () => import_chunk_Y5U7UXEL.SpaceProtocolSession,
|
|
41
|
+
TimeframeClock: () => import_chunk_Y5U7UXEL.TimeframeClock,
|
|
42
|
+
codec: () => import_chunk_Y5U7UXEL.codec,
|
|
43
|
+
createIdFromSpaceKey: () => import_chunk_Y5U7UXEL.createIdFromSpaceKey,
|
|
44
|
+
createMappedFeedWriter: () => import_chunk_Y5U7UXEL.createMappedFeedWriter,
|
|
43
45
|
encodingOptions: () => encodingOptions,
|
|
44
46
|
getSpaceKeyFromDoc: () => getSpaceKeyFromDoc,
|
|
45
|
-
hasInvitationExpired: () =>
|
|
46
|
-
mapFeedIndexesToTimeframe: () =>
|
|
47
|
-
mapTimeframeToFeedIndexes: () =>
|
|
48
|
-
startAfter: () =>
|
|
49
|
-
valueEncoding: () =>
|
|
47
|
+
hasInvitationExpired: () => import_chunk_Y5U7UXEL.hasInvitationExpired,
|
|
48
|
+
mapFeedIndexesToTimeframe: () => import_chunk_Y5U7UXEL.mapFeedIndexesToTimeframe,
|
|
49
|
+
mapTimeframeToFeedIndexes: () => import_chunk_Y5U7UXEL.mapTimeframeToFeedIndexes,
|
|
50
|
+
startAfter: () => import_chunk_Y5U7UXEL.startAfter,
|
|
51
|
+
valueEncoding: () => import_chunk_Y5U7UXEL.valueEncoding
|
|
50
52
|
});
|
|
51
53
|
module.exports = __toCommonJS(node_exports);
|
|
52
|
-
var
|
|
54
|
+
var import_chunk_Y5U7UXEL = require("./chunk-Y5U7UXEL.cjs");
|
|
53
55
|
var import_async = require("@dxos/async");
|
|
54
56
|
var import_automerge = require("@dxos/automerge/automerge");
|
|
55
57
|
var import_automerge_repo = require("@dxos/automerge/automerge-repo");
|
|
56
58
|
var import_context = require("@dxos/context");
|
|
57
|
-
var import_invariant = require("@dxos/invariant");
|
|
58
59
|
var import_keys = require("@dxos/keys");
|
|
59
60
|
var import_protocols = require("@dxos/protocols");
|
|
60
61
|
var import_tracing = require("@dxos/tracing");
|
|
@@ -62,23 +63,23 @@ var import_util = require("@dxos/util");
|
|
|
62
63
|
var import_async2 = require("@dxos/async");
|
|
63
64
|
var import_automerge_repo2 = require("@dxos/automerge/automerge-repo");
|
|
64
65
|
var import_context2 = require("@dxos/context");
|
|
65
|
-
var
|
|
66
|
+
var import_invariant = require("@dxos/invariant");
|
|
66
67
|
var import_log = require("@dxos/log");
|
|
67
68
|
var import_context3 = require("@dxos/context");
|
|
68
69
|
var import_async3 = require("@dxos/async");
|
|
69
70
|
var import_automerge_repo3 = require("@dxos/automerge/automerge-repo");
|
|
70
71
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
71
|
-
var
|
|
72
|
+
var import_invariant2 = require("@dxos/invariant");
|
|
72
73
|
var import_async4 = require("@dxos/async");
|
|
73
74
|
var import_context4 = require("@dxos/context");
|
|
74
75
|
var import_debug = require("@dxos/debug");
|
|
75
76
|
var import_echo_protocol = require("@dxos/echo-protocol");
|
|
76
|
-
var
|
|
77
|
+
var import_invariant3 = require("@dxos/invariant");
|
|
77
78
|
var import_log2 = require("@dxos/log");
|
|
78
79
|
var import_tracing2 = require("@dxos/tracing");
|
|
79
80
|
var import_automerge_repo4 = require("@dxos/automerge/automerge-repo");
|
|
80
81
|
var import_context5 = require("@dxos/context");
|
|
81
|
-
var
|
|
82
|
+
var import_invariant4 = require("@dxos/invariant");
|
|
82
83
|
var import_keys2 = require("@dxos/keys");
|
|
83
84
|
var import_log3 = require("@dxos/log");
|
|
84
85
|
var import_teleport_extension_automerge_replicator = require("@dxos/teleport-extension-automerge-replicator");
|
|
@@ -127,7 +128,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
127
128
|
disconnect() {
|
|
128
129
|
}
|
|
129
130
|
async open() {
|
|
130
|
-
(0,
|
|
131
|
+
(0, import_invariant.invariant)(this._lifecycleState === import_context2.LifecycleState.CLOSED, void 0, {
|
|
131
132
|
F: __dxlog_file,
|
|
132
133
|
L: 60,
|
|
133
134
|
S: this,
|
|
@@ -148,7 +149,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
148
149
|
});
|
|
149
150
|
}
|
|
150
151
|
async close() {
|
|
151
|
-
(0,
|
|
152
|
+
(0, import_invariant.invariant)(this._lifecycleState === import_context2.LifecycleState.OPEN, void 0, {
|
|
152
153
|
F: __dxlog_file,
|
|
153
154
|
L: 71,
|
|
154
155
|
S: this,
|
|
@@ -169,7 +170,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
169
170
|
});
|
|
170
171
|
}
|
|
171
172
|
async addReplicator(replicator) {
|
|
172
|
-
(0,
|
|
173
|
+
(0, import_invariant.invariant)(this._lifecycleState === import_context2.LifecycleState.OPEN, void 0, {
|
|
173
174
|
F: __dxlog_file,
|
|
174
175
|
L: 87,
|
|
175
176
|
S: this,
|
|
@@ -178,7 +179,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
178
179
|
""
|
|
179
180
|
]
|
|
180
181
|
});
|
|
181
|
-
(0,
|
|
182
|
+
(0, import_invariant.invariant)(this.peerId, void 0, {
|
|
182
183
|
F: __dxlog_file,
|
|
183
184
|
L: 88,
|
|
184
185
|
S: this,
|
|
@@ -187,7 +188,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
187
188
|
""
|
|
188
189
|
]
|
|
189
190
|
});
|
|
190
|
-
(0,
|
|
191
|
+
(0, import_invariant.invariant)(!this._replicators.has(replicator), void 0, {
|
|
191
192
|
F: __dxlog_file,
|
|
192
193
|
L: 89,
|
|
193
194
|
S: this,
|
|
@@ -206,7 +207,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
206
207
|
});
|
|
207
208
|
}
|
|
208
209
|
async removeReplicator(replicator) {
|
|
209
|
-
(0,
|
|
210
|
+
(0, import_invariant.invariant)(this._lifecycleState === import_context2.LifecycleState.OPEN, void 0, {
|
|
210
211
|
F: __dxlog_file,
|
|
211
212
|
L: 103,
|
|
212
213
|
S: this,
|
|
@@ -215,7 +216,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
215
216
|
""
|
|
216
217
|
]
|
|
217
218
|
});
|
|
218
|
-
(0,
|
|
219
|
+
(0, import_invariant.invariant)(this._replicators.has(replicator), void 0, {
|
|
219
220
|
F: __dxlog_file,
|
|
220
221
|
L: 104,
|
|
221
222
|
S: this,
|
|
@@ -243,7 +244,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
243
244
|
S: this,
|
|
244
245
|
C: (f, a) => f(...a)
|
|
245
246
|
});
|
|
246
|
-
(0,
|
|
247
|
+
(0, import_invariant.invariant)(!this._connections.has(connection.peerId), void 0, {
|
|
247
248
|
F: __dxlog_file,
|
|
248
249
|
L: 120,
|
|
249
250
|
S: this,
|
|
@@ -305,7 +306,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
305
306
|
C: (f, a) => f(...a)
|
|
306
307
|
});
|
|
307
308
|
const entry = this._connections.get(connection.peerId);
|
|
308
|
-
(0,
|
|
309
|
+
(0, import_invariant.invariant)(entry, void 0, {
|
|
309
310
|
F: __dxlog_file,
|
|
310
311
|
L: 155,
|
|
311
312
|
S: this,
|
|
@@ -329,7 +330,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
329
330
|
C: (f, a) => f(...a)
|
|
330
331
|
});
|
|
331
332
|
const entry = this._connections.get(connection.peerId);
|
|
332
|
-
(0,
|
|
333
|
+
(0, import_invariant.invariant)(entry, void 0, {
|
|
333
334
|
F: __dxlog_file,
|
|
334
335
|
L: 163,
|
|
335
336
|
S: this,
|
|
@@ -359,10 +360,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
359
360
|
_emitPeerCandidate(connection) {
|
|
360
361
|
this.emit("peer-candidate", {
|
|
361
362
|
peerId: connection.peerId,
|
|
362
|
-
peerMetadata:
|
|
363
|
-
// TODO(dmaretskyi): Refactor this.
|
|
364
|
-
dxos_peerSource: "EchoNetworkAdapter"
|
|
365
|
-
}
|
|
363
|
+
peerMetadata: createEchoPeerMetadata()
|
|
366
364
|
});
|
|
367
365
|
}
|
|
368
366
|
};
|
|
@@ -378,6 +376,11 @@ _ts_decorate([
|
|
|
378
376
|
_ts_decorate([
|
|
379
377
|
import_async2.synchronized
|
|
380
378
|
], EchoNetworkAdapter.prototype, "removeReplicator", null);
|
|
379
|
+
var createEchoPeerMetadata = () => ({
|
|
380
|
+
// TODO(dmaretskyi): Refactor this.
|
|
381
|
+
dxos_peerSource: "EchoNetworkAdapter"
|
|
382
|
+
});
|
|
383
|
+
var isEchoPeerMetadata = (metadata) => metadata?.dxos_peerSource === "EchoNetworkAdapter";
|
|
381
384
|
var LevelDBStorageAdapter = class extends import_context3.Resource {
|
|
382
385
|
constructor(_params) {
|
|
383
386
|
super();
|
|
@@ -499,7 +502,7 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo3.NetworkAdapte
|
|
|
499
502
|
}
|
|
500
503
|
send(message) {
|
|
501
504
|
const peer = this._peers.get(message.targetId);
|
|
502
|
-
(0,
|
|
505
|
+
(0, import_invariant2.invariant)(peer, "Peer not found.", {
|
|
503
506
|
F: __dxlog_file2,
|
|
504
507
|
L: 51,
|
|
505
508
|
S: this,
|
|
@@ -524,7 +527,7 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo3.NetworkAdapte
|
|
|
524
527
|
syncRepo({ id, syncMessage }) {
|
|
525
528
|
const peerId = this._getPeerId(id);
|
|
526
529
|
return new import_codec_protobuf.Stream(({ next, close }) => {
|
|
527
|
-
(0,
|
|
530
|
+
(0, import_invariant2.invariant)(!this._peers.has(peerId), "Peer already connected.", {
|
|
528
531
|
F: __dxlog_file2,
|
|
529
532
|
L: 73,
|
|
530
533
|
S: this,
|
|
@@ -548,7 +551,7 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo3.NetworkAdapte
|
|
|
548
551
|
});
|
|
549
552
|
}
|
|
550
553
|
});
|
|
551
|
-
(0,
|
|
554
|
+
(0, import_invariant2.invariant)(this._isConnected, void 0, {
|
|
552
555
|
F: __dxlog_file2,
|
|
553
556
|
L: 90,
|
|
554
557
|
S: this,
|
|
@@ -564,7 +567,7 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo3.NetworkAdapte
|
|
|
564
567
|
});
|
|
565
568
|
}
|
|
566
569
|
async sendSyncMessage({ id, syncMessage }) {
|
|
567
|
-
(0,
|
|
570
|
+
(0, import_invariant2.invariant)(this._isConnected, void 0, {
|
|
568
571
|
F: __dxlog_file2,
|
|
569
572
|
L: 99,
|
|
570
573
|
S: this,
|
|
@@ -577,7 +580,7 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo3.NetworkAdapte
|
|
|
577
580
|
this.emit("message", message);
|
|
578
581
|
}
|
|
579
582
|
async getHostInfo() {
|
|
580
|
-
(0,
|
|
583
|
+
(0, import_invariant2.invariant)(this._isConnected, void 0, {
|
|
581
584
|
F: __dxlog_file2,
|
|
582
585
|
L: 105,
|
|
583
586
|
S: this,
|
|
@@ -586,7 +589,7 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo3.NetworkAdapte
|
|
|
586
589
|
""
|
|
587
590
|
]
|
|
588
591
|
});
|
|
589
|
-
(0,
|
|
592
|
+
(0, import_invariant2.invariant)(this.peerId, "Peer id not set.", {
|
|
590
593
|
F: __dxlog_file2,
|
|
591
594
|
L: 106,
|
|
592
595
|
S: this,
|
|
@@ -616,7 +619,10 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
616
619
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
|
|
617
620
|
var AutomergeHost = class {
|
|
618
621
|
constructor({ db, indexMetadataStore }) {
|
|
619
|
-
this._ctx = new import_context.Context(
|
|
622
|
+
this._ctx = new import_context.Context(void 0, {
|
|
623
|
+
F: __dxlog_file3,
|
|
624
|
+
L: 71
|
|
625
|
+
});
|
|
620
626
|
this._echoNetworkAdapter = new EchoNetworkAdapter({
|
|
621
627
|
getContainingSpaceForDocument: this._getContainingSpaceForDocument.bind(this)
|
|
622
628
|
});
|
|
@@ -655,6 +661,9 @@ var AutomergeHost = class {
|
|
|
655
661
|
await this._echoNetworkAdapter.close();
|
|
656
662
|
await this._ctx.dispose();
|
|
657
663
|
}
|
|
664
|
+
/**
|
|
665
|
+
* @deprecated To be abstracted away.
|
|
666
|
+
*/
|
|
658
667
|
get repo() {
|
|
659
668
|
return this._repo;
|
|
660
669
|
}
|
|
@@ -664,6 +673,39 @@ var AutomergeHost = class {
|
|
|
664
673
|
async removeReplicator(replicator) {
|
|
665
674
|
await this._echoNetworkAdapter.removeReplicator(replicator);
|
|
666
675
|
}
|
|
676
|
+
/**
|
|
677
|
+
* Loads the document handle from the repo and waits for it to be ready.
|
|
678
|
+
*/
|
|
679
|
+
async loadDoc(ctx, documentId, opts) {
|
|
680
|
+
let handle;
|
|
681
|
+
if (typeof documentId === "string") {
|
|
682
|
+
handle = this._repo.handles[documentId];
|
|
683
|
+
}
|
|
684
|
+
if (!handle) {
|
|
685
|
+
handle = this._repo.find(documentId);
|
|
686
|
+
}
|
|
687
|
+
if (!handle.isReady()) {
|
|
688
|
+
if (!opts?.timeout) {
|
|
689
|
+
await (0, import_context.cancelWithContext)(ctx, handle.whenReady());
|
|
690
|
+
} else {
|
|
691
|
+
await (0, import_context.cancelWithContext)(ctx, (0, import_async.asyncTimeout)(handle.whenReady(), opts.timeout));
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
return handle;
|
|
695
|
+
}
|
|
696
|
+
/**
|
|
697
|
+
* Create new persisted document.
|
|
698
|
+
*/
|
|
699
|
+
createDoc(initialValue, opts) {
|
|
700
|
+
if (opts?.preserveHistory) {
|
|
701
|
+
if (!(0, import_automerge.isAutomerge)(initialValue)) {
|
|
702
|
+
throw new TypeError("Initial value must be an Automerge document");
|
|
703
|
+
}
|
|
704
|
+
return this._repo.import((0, import_automerge.save)(initialValue));
|
|
705
|
+
} else {
|
|
706
|
+
return this._repo.create(initialValue);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
667
709
|
// TODO(dmaretskyi): Share based on HALO permissions and space affinity.
|
|
668
710
|
// Hosts, running in the worker, don't share documents unless requested by other peers.
|
|
669
711
|
// NOTE: If both peers return sharePolicy=false the replication will not happen
|
|
@@ -676,7 +718,7 @@ var AutomergeHost = class {
|
|
|
676
718
|
return false;
|
|
677
719
|
}
|
|
678
720
|
const peerMetadata = this.repo.peerMetadataByPeerId[peerId];
|
|
679
|
-
if (peerMetadata
|
|
721
|
+
if (isEchoPeerMetadata(peerMetadata)) {
|
|
680
722
|
return this._echoNetworkAdapter.shouldAdvertize(peerId, {
|
|
681
723
|
documentId
|
|
682
724
|
});
|
|
@@ -748,31 +790,36 @@ var AutomergeHost = class {
|
|
|
748
790
|
}
|
|
749
791
|
return import_keys.PublicKey.from(spaceKeyHex);
|
|
750
792
|
}
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
793
|
+
/**
|
|
794
|
+
* Flush documents to disk.
|
|
795
|
+
*/
|
|
754
796
|
async flush({ states }) {
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
});
|
|
765
|
-
const handle = this.repo.handles[documentId] ?? this._repo.find(documentId);
|
|
766
|
-
await waitForHeads(handle, heads);
|
|
767
|
-
}) ?? []);
|
|
797
|
+
if (states) {
|
|
798
|
+
await Promise.all(states.map(async ({ heads, documentId }) => {
|
|
799
|
+
if (!heads) {
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
const handle = this.repo.handles[documentId] ?? this._repo.find(documentId);
|
|
803
|
+
await waitForHeads(handle, heads);
|
|
804
|
+
}) ?? []);
|
|
805
|
+
}
|
|
768
806
|
await this._repo.flush(states?.map(({ documentId }) => documentId));
|
|
769
807
|
}
|
|
808
|
+
/**
|
|
809
|
+
* Host <-> Client sync.
|
|
810
|
+
*/
|
|
770
811
|
syncRepo(request) {
|
|
771
812
|
return this._clientNetwork.syncRepo(request);
|
|
772
813
|
}
|
|
814
|
+
/**
|
|
815
|
+
* Host <-> Client sync.
|
|
816
|
+
*/
|
|
773
817
|
sendSyncMessage(request) {
|
|
774
818
|
return this._clientNetwork.sendSyncMessage(request);
|
|
775
819
|
}
|
|
820
|
+
/**
|
|
821
|
+
* Host <-> Client sync.
|
|
822
|
+
*/
|
|
776
823
|
async getHostInfo() {
|
|
777
824
|
return this._clientNetwork.getHostInfo();
|
|
778
825
|
}
|
|
@@ -867,7 +914,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
867
914
|
} else {
|
|
868
915
|
const existingDocHandle = await this._initDocHandle(ctx, spaceState.rootUrl);
|
|
869
916
|
const doc = existingDocHandle.docSync();
|
|
870
|
-
(0,
|
|
917
|
+
(0, import_invariant3.invariant)(doc, void 0, {
|
|
871
918
|
F: __dxlog_file4,
|
|
872
919
|
L: 77,
|
|
873
920
|
S: this,
|
|
@@ -889,7 +936,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
889
936
|
let hasUrlsToLoad = false;
|
|
890
937
|
const urlsToLoad = {};
|
|
891
938
|
for (const objectId of objectIds) {
|
|
892
|
-
(0,
|
|
939
|
+
(0, import_invariant3.invariant)(this._spaceRootDocHandle, void 0, {
|
|
893
940
|
F: __dxlog_file4,
|
|
894
941
|
L: 90,
|
|
895
942
|
S: this,
|
|
@@ -902,7 +949,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
902
949
|
continue;
|
|
903
950
|
}
|
|
904
951
|
const spaceRootDoc = this._spaceRootDocHandle.docSync();
|
|
905
|
-
(0,
|
|
952
|
+
(0, import_invariant3.invariant)(spaceRootDoc, void 0, {
|
|
906
953
|
F: __dxlog_file4,
|
|
907
954
|
L: 95,
|
|
908
955
|
S: this,
|
|
@@ -940,7 +987,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
940
987
|
linksAwaitingLoad.forEach(([objectId]) => this._objectsPendingDocumentLoad.delete(objectId));
|
|
941
988
|
}
|
|
942
989
|
getSpaceRootDocHandle() {
|
|
943
|
-
(0,
|
|
990
|
+
(0, import_invariant3.invariant)(this._spaceRootDocHandle, void 0, {
|
|
944
991
|
F: __dxlog_file4,
|
|
945
992
|
L: 122,
|
|
946
993
|
S: this,
|
|
@@ -952,7 +999,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
952
999
|
return this._spaceRootDocHandle;
|
|
953
1000
|
}
|
|
954
1001
|
createDocumentForObject(objectId) {
|
|
955
|
-
(0,
|
|
1002
|
+
(0, import_invariant3.invariant)(this._spaceRootDocHandle, void 0, {
|
|
956
1003
|
F: __dxlog_file4,
|
|
957
1004
|
L: 127,
|
|
958
1005
|
S: this,
|
|
@@ -1149,7 +1196,7 @@ var MeshEchoReplicator = class {
|
|
|
1149
1196
|
this._context = null;
|
|
1150
1197
|
}
|
|
1151
1198
|
createExtension() {
|
|
1152
|
-
(0,
|
|
1199
|
+
(0, import_invariant4.invariant)(this._context, void 0, {
|
|
1153
1200
|
F: __dxlog_file5,
|
|
1154
1201
|
L: 54,
|
|
1155
1202
|
S: this,
|
|
@@ -1169,7 +1216,7 @@ var MeshEchoReplicator = class {
|
|
|
1169
1216
|
S: this,
|
|
1170
1217
|
C: (f, a) => f(...a)
|
|
1171
1218
|
});
|
|
1172
|
-
(0,
|
|
1219
|
+
(0, import_invariant4.invariant)(this._context, void 0, {
|
|
1173
1220
|
F: __dxlog_file5,
|
|
1174
1221
|
L: 60,
|
|
1175
1222
|
S: this,
|
|
@@ -1196,8 +1243,8 @@ var MeshEchoReplicator = class {
|
|
|
1196
1243
|
C: (f, a) => f(...a)
|
|
1197
1244
|
});
|
|
1198
1245
|
this._context?.onConnectionClosed(connection);
|
|
1199
|
-
await connection.disable();
|
|
1200
1246
|
this._connectionsPerPeer.delete(connection.peerId);
|
|
1247
|
+
await connection.disable();
|
|
1201
1248
|
this._connections.delete(connection);
|
|
1202
1249
|
},
|
|
1203
1250
|
shouldAdvertize: async (params) => {
|
|
@@ -1210,7 +1257,7 @@ var MeshEchoReplicator = class {
|
|
|
1210
1257
|
S: this,
|
|
1211
1258
|
C: (f, a) => f(...a)
|
|
1212
1259
|
});
|
|
1213
|
-
(0,
|
|
1260
|
+
(0, import_invariant4.invariant)(this._context, void 0, {
|
|
1214
1261
|
F: __dxlog_file5,
|
|
1215
1262
|
L: 79,
|
|
1216
1263
|
S: this,
|
|
@@ -1350,7 +1397,7 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1350
1397
|
});
|
|
1351
1398
|
}
|
|
1352
1399
|
get peerId() {
|
|
1353
|
-
(0,
|
|
1400
|
+
(0, import_invariant4.invariant)(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
1354
1401
|
F: __dxlog_file5,
|
|
1355
1402
|
L: 215,
|
|
1356
1403
|
S: this,
|
|
@@ -1369,7 +1416,7 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1369
1416
|
* Call after the remote peer has connected.
|
|
1370
1417
|
*/
|
|
1371
1418
|
async enable() {
|
|
1372
|
-
(0,
|
|
1419
|
+
(0, import_invariant4.invariant)(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
1373
1420
|
F: __dxlog_file5,
|
|
1374
1421
|
L: 228,
|
|
1375
1422
|
S: this,
|
|
@@ -1393,6 +1440,8 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1393
1440
|
AuthStatus,
|
|
1394
1441
|
AutomergeDocumentLoaderImpl,
|
|
1395
1442
|
AutomergeHost,
|
|
1443
|
+
CredentialRetrieverExtension,
|
|
1444
|
+
CredentialServerExtension,
|
|
1396
1445
|
DataServiceImpl,
|
|
1397
1446
|
LevelDBStorageAdapter,
|
|
1398
1447
|
LocalHostNetworkAdapter,
|