@dxos/echo-pipeline 0.6.0 → 0.6.1-main.5f81d7a
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/index.mjs +110 -82
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +105 -79
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/types/src/automerge/automerge-host.d.ts +10 -9
- package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
- package/dist/types/src/automerge/echo-network-adapter.d.ts.map +1 -1
- package/dist/types/src/automerge/heads-store.d.ts +13 -0
- package/dist/types/src/automerge/heads-store.d.ts.map +1 -0
- package/package.json +33 -33
- package/src/automerge/automerge-host.test.ts +34 -17
- package/src/automerge/automerge-host.ts +30 -12
- package/src/automerge/echo-network-adapter.ts +6 -2
- package/src/automerge/heads-store.ts +39 -0
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
import { Event, asyncTimeout } from "@dxos/async";
|
|
32
32
|
import { next as automerge, getBackend, getHeads, isAutomerge, save } from "@dxos/automerge/automerge";
|
|
33
33
|
import { Repo } from "@dxos/automerge/automerge-repo";
|
|
34
|
-
import {
|
|
34
|
+
import { Resource as Resource2, cancelWithContext } from "@dxos/context";
|
|
35
35
|
import { PublicKey } from "@dxos/keys";
|
|
36
36
|
import { objectPointerCodec } from "@dxos/protocols";
|
|
37
37
|
import { trace } from "@dxos/tracing";
|
|
@@ -87,19 +87,13 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
87
87
|
disconnect() {
|
|
88
88
|
}
|
|
89
89
|
async open() {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
S: this,
|
|
94
|
-
A: [
|
|
95
|
-
"this._lifecycleState === LifecycleState.CLOSED",
|
|
96
|
-
""
|
|
97
|
-
]
|
|
98
|
-
});
|
|
90
|
+
if (this._lifecycleState === LifecycleState.OPEN) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
99
93
|
this._lifecycleState = LifecycleState.OPEN;
|
|
100
94
|
log("emit ready", void 0, {
|
|
101
95
|
F: __dxlog_file,
|
|
102
|
-
L:
|
|
96
|
+
L: 65,
|
|
103
97
|
S: this,
|
|
104
98
|
C: (f, a) => f(...a)
|
|
105
99
|
});
|
|
@@ -108,15 +102,9 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
108
102
|
});
|
|
109
103
|
}
|
|
110
104
|
async close() {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
S: this,
|
|
115
|
-
A: [
|
|
116
|
-
"this._lifecycleState === LifecycleState.OPEN",
|
|
117
|
-
""
|
|
118
|
-
]
|
|
119
|
-
});
|
|
105
|
+
if (this._lifecycleState === LifecycleState.CLOSED) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
120
108
|
for (const replicator of this._replicators) {
|
|
121
109
|
await replicator.disconnect();
|
|
122
110
|
}
|
|
@@ -131,7 +119,7 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
131
119
|
async addReplicator(replicator) {
|
|
132
120
|
invariant(this._lifecycleState === LifecycleState.OPEN, void 0, {
|
|
133
121
|
F: __dxlog_file,
|
|
134
|
-
L:
|
|
122
|
+
L: 91,
|
|
135
123
|
S: this,
|
|
136
124
|
A: [
|
|
137
125
|
"this._lifecycleState === LifecycleState.OPEN",
|
|
@@ -140,7 +128,7 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
140
128
|
});
|
|
141
129
|
invariant(this.peerId, void 0, {
|
|
142
130
|
F: __dxlog_file,
|
|
143
|
-
L:
|
|
131
|
+
L: 92,
|
|
144
132
|
S: this,
|
|
145
133
|
A: [
|
|
146
134
|
"this.peerId",
|
|
@@ -149,7 +137,7 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
149
137
|
});
|
|
150
138
|
invariant(!this._replicators.has(replicator), void 0, {
|
|
151
139
|
F: __dxlog_file,
|
|
152
|
-
L:
|
|
140
|
+
L: 93,
|
|
153
141
|
S: this,
|
|
154
142
|
A: [
|
|
155
143
|
"!this._replicators.has(replicator)",
|
|
@@ -168,7 +156,7 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
168
156
|
async removeReplicator(replicator) {
|
|
169
157
|
invariant(this._lifecycleState === LifecycleState.OPEN, void 0, {
|
|
170
158
|
F: __dxlog_file,
|
|
171
|
-
L:
|
|
159
|
+
L: 107,
|
|
172
160
|
S: this,
|
|
173
161
|
A: [
|
|
174
162
|
"this._lifecycleState === LifecycleState.OPEN",
|
|
@@ -177,7 +165,7 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
177
165
|
});
|
|
178
166
|
invariant(this._replicators.has(replicator), void 0, {
|
|
179
167
|
F: __dxlog_file,
|
|
180
|
-
L:
|
|
168
|
+
L: 108,
|
|
181
169
|
S: this,
|
|
182
170
|
A: [
|
|
183
171
|
"this._replicators.has(replicator)",
|
|
@@ -199,13 +187,13 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
199
187
|
peerId: connection.peerId
|
|
200
188
|
}, {
|
|
201
189
|
F: __dxlog_file,
|
|
202
|
-
L:
|
|
190
|
+
L: 123,
|
|
203
191
|
S: this,
|
|
204
192
|
C: (f, a) => f(...a)
|
|
205
193
|
});
|
|
206
194
|
invariant(!this._connections.has(connection.peerId), void 0, {
|
|
207
195
|
F: __dxlog_file,
|
|
208
|
-
L:
|
|
196
|
+
L: 124,
|
|
209
197
|
S: this,
|
|
210
198
|
A: [
|
|
211
199
|
"!this._connections.has(connection.peerId as PeerId)",
|
|
@@ -234,7 +222,7 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
234
222
|
if (connectionEntry.isOpen) {
|
|
235
223
|
log.catch(err, void 0, {
|
|
236
224
|
F: __dxlog_file,
|
|
237
|
-
L:
|
|
225
|
+
L: 143,
|
|
238
226
|
S: this,
|
|
239
227
|
C: (f, a) => f(...a)
|
|
240
228
|
});
|
|
@@ -245,7 +233,7 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
245
233
|
peerId: connection.peerId
|
|
246
234
|
}, {
|
|
247
235
|
F: __dxlog_file,
|
|
248
|
-
L:
|
|
236
|
+
L: 148,
|
|
249
237
|
S: this,
|
|
250
238
|
C: (f, a) => f(...a)
|
|
251
239
|
});
|
|
@@ -260,14 +248,14 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
260
248
|
peerId: connection.peerId
|
|
261
249
|
}, {
|
|
262
250
|
F: __dxlog_file,
|
|
263
|
-
L:
|
|
251
|
+
L: 157,
|
|
264
252
|
S: this,
|
|
265
253
|
C: (f, a) => f(...a)
|
|
266
254
|
});
|
|
267
255
|
const entry = this._connections.get(connection.peerId);
|
|
268
256
|
invariant(entry, void 0, {
|
|
269
257
|
F: __dxlog_file,
|
|
270
|
-
L:
|
|
258
|
+
L: 159,
|
|
271
259
|
S: this,
|
|
272
260
|
A: [
|
|
273
261
|
"entry",
|
|
@@ -284,14 +272,14 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
284
272
|
peerId: connection.peerId
|
|
285
273
|
}, {
|
|
286
274
|
F: __dxlog_file,
|
|
287
|
-
L:
|
|
275
|
+
L: 165,
|
|
288
276
|
S: this,
|
|
289
277
|
C: (f, a) => f(...a)
|
|
290
278
|
});
|
|
291
279
|
const entry = this._connections.get(connection.peerId);
|
|
292
280
|
invariant(entry, void 0, {
|
|
293
281
|
F: __dxlog_file,
|
|
294
|
-
L:
|
|
282
|
+
L: 167,
|
|
295
283
|
S: this,
|
|
296
284
|
A: [
|
|
297
285
|
"entry",
|
|
@@ -304,13 +292,13 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
304
292
|
});
|
|
305
293
|
void entry.reader.cancel().catch((err) => log.catch(err, void 0, {
|
|
306
294
|
F: __dxlog_file,
|
|
307
|
-
L:
|
|
295
|
+
L: 172,
|
|
308
296
|
S: this,
|
|
309
297
|
C: (f, a) => f(...a)
|
|
310
298
|
}));
|
|
311
299
|
void entry.writer.abort().catch((err) => log.catch(err, void 0, {
|
|
312
300
|
F: __dxlog_file,
|
|
313
|
-
L:
|
|
301
|
+
L: 173,
|
|
314
302
|
S: this,
|
|
315
303
|
C: (f, a) => f(...a)
|
|
316
304
|
}));
|
|
@@ -341,6 +329,34 @@ var createEchoPeerMetadata = () => ({
|
|
|
341
329
|
});
|
|
342
330
|
var isEchoPeerMetadata = (metadata) => metadata?.dxos_peerSource === "EchoNetworkAdapter";
|
|
343
331
|
|
|
332
|
+
// packages/core/echo/echo-pipeline/src/automerge/heads-store.ts
|
|
333
|
+
import { headsEncoding } from "@dxos/indexing";
|
|
334
|
+
var HeadsStore = class {
|
|
335
|
+
constructor({ db }) {
|
|
336
|
+
this._db = db;
|
|
337
|
+
}
|
|
338
|
+
setHeads(documentId, heads, batch) {
|
|
339
|
+
batch.put(documentId, heads, {
|
|
340
|
+
sublevel: this._db,
|
|
341
|
+
keyEncoding: "utf8",
|
|
342
|
+
valueEncoding: headsEncoding
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
async getHeads(documentId) {
|
|
346
|
+
try {
|
|
347
|
+
return await this._db.get(documentId, {
|
|
348
|
+
keyEncoding: "utf8",
|
|
349
|
+
valueEncoding: headsEncoding
|
|
350
|
+
});
|
|
351
|
+
} catch (err) {
|
|
352
|
+
if (err.notFound) {
|
|
353
|
+
return void 0;
|
|
354
|
+
}
|
|
355
|
+
throw err;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
|
|
344
360
|
// packages/core/echo/echo-pipeline/src/automerge/leveldb-storage-adapter.ts
|
|
345
361
|
import { LifecycleState as LifecycleState2, Resource } from "@dxos/context";
|
|
346
362
|
var LevelDBStorageAdapter = class extends Resource {
|
|
@@ -586,26 +602,25 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
586
602
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
587
603
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
588
604
|
}
|
|
589
|
-
var
|
|
590
|
-
var AutomergeHost = class {
|
|
605
|
+
var AutomergeHost = class extends Resource2 {
|
|
591
606
|
constructor({ db, indexMetadataStore }) {
|
|
592
|
-
|
|
593
|
-
F: __dxlog_file3,
|
|
594
|
-
L: 71
|
|
595
|
-
});
|
|
607
|
+
super();
|
|
596
608
|
this._echoNetworkAdapter = new EchoNetworkAdapter({
|
|
597
609
|
getContainingSpaceForDocument: this._getContainingSpaceForDocument.bind(this)
|
|
598
610
|
});
|
|
599
611
|
this._storage = new LevelDBStorageAdapter({
|
|
600
|
-
db,
|
|
612
|
+
db: db.sublevel("automerge"),
|
|
601
613
|
callbacks: {
|
|
602
614
|
beforeSave: async (params) => this._beforeSave(params),
|
|
603
615
|
afterSave: async () => this._afterSave()
|
|
604
616
|
}
|
|
605
617
|
});
|
|
618
|
+
this._headsStore = new HeadsStore({
|
|
619
|
+
db: db.sublevel("heads")
|
|
620
|
+
});
|
|
606
621
|
this._indexMetadataStore = indexMetadataStore;
|
|
607
622
|
}
|
|
608
|
-
async
|
|
623
|
+
async _open() {
|
|
609
624
|
this._peerId = `host-${PublicKey.random().toHex()}`;
|
|
610
625
|
await this._storage.open?.();
|
|
611
626
|
this._clientNetwork = new LocalHostNetworkAdapter();
|
|
@@ -625,7 +640,7 @@ var AutomergeHost = class {
|
|
|
625
640
|
await this._clientNetwork.whenConnected();
|
|
626
641
|
await this._echoNetworkAdapter.whenConnected();
|
|
627
642
|
}
|
|
628
|
-
async
|
|
643
|
+
async _close() {
|
|
629
644
|
await this._storage.close?.();
|
|
630
645
|
await this._clientNetwork.close();
|
|
631
646
|
await this._echoNetworkAdapter.close();
|
|
@@ -705,7 +720,8 @@ var AutomergeHost = class {
|
|
|
705
720
|
return;
|
|
706
721
|
}
|
|
707
722
|
const spaceKey = getSpaceKeyFromDoc(doc) ?? void 0;
|
|
708
|
-
const
|
|
723
|
+
const heads = getHeads(doc);
|
|
724
|
+
this._headsStore.setHeads(handle.documentId, heads, batch);
|
|
709
725
|
const objectIds = Object.keys(doc.objects ?? {});
|
|
710
726
|
const encodedIds = objectIds.map((objectId) => objectPointerCodec.encode({
|
|
711
727
|
documentId: handle.documentId,
|
|
@@ -714,7 +730,7 @@ var AutomergeHost = class {
|
|
|
714
730
|
}));
|
|
715
731
|
const idToLastHash = new Map(encodedIds.map((id) => [
|
|
716
732
|
id,
|
|
717
|
-
|
|
733
|
+
heads
|
|
718
734
|
]));
|
|
719
735
|
this._indexMetadataStore.markDirty(idToLastHash, batch);
|
|
720
736
|
}
|
|
@@ -763,18 +779,30 @@ var AutomergeHost = class {
|
|
|
763
779
|
/**
|
|
764
780
|
* Flush documents to disk.
|
|
765
781
|
*/
|
|
766
|
-
async flush({ states }) {
|
|
782
|
+
async flush({ states } = {}) {
|
|
767
783
|
if (states) {
|
|
768
784
|
await Promise.all(states.map(async ({ heads, documentId }) => {
|
|
769
785
|
if (!heads) {
|
|
770
786
|
return;
|
|
771
787
|
}
|
|
772
|
-
const handle = this.
|
|
788
|
+
const handle = this._repo.handles[documentId] ?? this._repo.find(documentId);
|
|
773
789
|
await waitForHeads(handle, heads);
|
|
774
790
|
}) ?? []);
|
|
775
791
|
}
|
|
776
792
|
await this._repo.flush(states?.map(({ documentId }) => documentId));
|
|
777
793
|
}
|
|
794
|
+
async getHeads(documentId) {
|
|
795
|
+
const handle = this._repo.handles[documentId];
|
|
796
|
+
if (handle) {
|
|
797
|
+
const doc = handle.docSync();
|
|
798
|
+
if (!doc) {
|
|
799
|
+
return void 0;
|
|
800
|
+
}
|
|
801
|
+
return getHeads(doc);
|
|
802
|
+
} else {
|
|
803
|
+
return this._headsStore.getHeads(documentId);
|
|
804
|
+
}
|
|
805
|
+
}
|
|
778
806
|
/**
|
|
779
807
|
* Host <-> Client sync.
|
|
780
808
|
*/
|
|
@@ -860,7 +888,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
860
888
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
861
889
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
862
890
|
}
|
|
863
|
-
var
|
|
891
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-doc-loader.ts";
|
|
864
892
|
var AutomergeDocumentLoaderImpl = class {
|
|
865
893
|
constructor(_spaceId, _repo, _spaceKey) {
|
|
866
894
|
this._spaceId = _spaceId;
|
|
@@ -887,7 +915,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
887
915
|
const existingDocHandle = await this._initDocHandle(ctx, spaceState.rootUrl);
|
|
888
916
|
const doc = existingDocHandle.docSync();
|
|
889
917
|
invariant3(doc, void 0, {
|
|
890
|
-
F:
|
|
918
|
+
F: __dxlog_file3,
|
|
891
919
|
L: 84,
|
|
892
920
|
S: this,
|
|
893
921
|
A: [
|
|
@@ -896,7 +924,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
896
924
|
]
|
|
897
925
|
});
|
|
898
926
|
invariant3(doc.version === SpaceDocVersion.CURRENT, void 0, {
|
|
899
|
-
F:
|
|
927
|
+
F: __dxlog_file3,
|
|
900
928
|
L: 85,
|
|
901
929
|
S: this,
|
|
902
930
|
A: [
|
|
@@ -917,7 +945,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
917
945
|
const urlsToLoad = {};
|
|
918
946
|
for (const objectId of objectIds) {
|
|
919
947
|
invariant3(this._spaceRootDocHandle, void 0, {
|
|
920
|
-
F:
|
|
948
|
+
F: __dxlog_file3,
|
|
921
949
|
L: 97,
|
|
922
950
|
S: this,
|
|
923
951
|
A: [
|
|
@@ -930,7 +958,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
930
958
|
}
|
|
931
959
|
const spaceRootDoc = this._spaceRootDocHandle.docSync();
|
|
932
960
|
invariant3(spaceRootDoc, void 0, {
|
|
933
|
-
F:
|
|
961
|
+
F: __dxlog_file3,
|
|
934
962
|
L: 102,
|
|
935
963
|
S: this,
|
|
936
964
|
A: [
|
|
@@ -944,7 +972,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
944
972
|
log2.info("loading delayed until object links are initialized", {
|
|
945
973
|
objectId
|
|
946
974
|
}, {
|
|
947
|
-
F:
|
|
975
|
+
F: __dxlog_file3,
|
|
948
976
|
L: 106,
|
|
949
977
|
S: this,
|
|
950
978
|
C: (f, a) => f(...a)
|
|
@@ -960,7 +988,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
960
988
|
}
|
|
961
989
|
getObjectDocumentId(objectId) {
|
|
962
990
|
invariant3(this._spaceRootDocHandle, void 0, {
|
|
963
|
-
F:
|
|
991
|
+
F: __dxlog_file3,
|
|
964
992
|
L: 118,
|
|
965
993
|
S: this,
|
|
966
994
|
A: [
|
|
@@ -970,7 +998,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
970
998
|
});
|
|
971
999
|
const spaceRootDoc = this._spaceRootDocHandle.docSync();
|
|
972
1000
|
invariant3(spaceRootDoc, void 0, {
|
|
973
|
-
F:
|
|
1001
|
+
F: __dxlog_file3,
|
|
974
1002
|
L: 120,
|
|
975
1003
|
S: this,
|
|
976
1004
|
A: [
|
|
@@ -994,7 +1022,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
994
1022
|
}
|
|
995
1023
|
getSpaceRootDocHandle() {
|
|
996
1024
|
invariant3(this._spaceRootDocHandle, void 0, {
|
|
997
|
-
F:
|
|
1025
|
+
F: __dxlog_file3,
|
|
998
1026
|
L: 140,
|
|
999
1027
|
S: this,
|
|
1000
1028
|
A: [
|
|
@@ -1006,7 +1034,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1006
1034
|
}
|
|
1007
1035
|
createDocumentForObject(objectId) {
|
|
1008
1036
|
invariant3(this._spaceRootDocHandle, void 0, {
|
|
1009
|
-
F:
|
|
1037
|
+
F: __dxlog_file3,
|
|
1010
1038
|
L: 145,
|
|
1011
1039
|
S: this,
|
|
1012
1040
|
A: [
|
|
@@ -1051,7 +1079,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1051
1079
|
...logMeta,
|
|
1052
1080
|
actualDocumentUrl: objectDocumentHandle.url
|
|
1053
1081
|
}, {
|
|
1054
|
-
F:
|
|
1082
|
+
F: __dxlog_file3,
|
|
1055
1083
|
L: 177,
|
|
1056
1084
|
S: this,
|
|
1057
1085
|
C: (f, a) => f(...a)
|
|
@@ -1060,7 +1088,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1060
1088
|
}
|
|
1061
1089
|
if (objectDocumentHandle?.url === automergeUrl) {
|
|
1062
1090
|
log2.warn("object document was already loaded", logMeta, {
|
|
1063
|
-
F:
|
|
1091
|
+
F: __dxlog_file3,
|
|
1064
1092
|
L: 184,
|
|
1065
1093
|
S: this,
|
|
1066
1094
|
C: (f, a) => f(...a)
|
|
@@ -1069,7 +1097,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1069
1097
|
}
|
|
1070
1098
|
const handle = this._repo.find(automergeUrl);
|
|
1071
1099
|
log2.debug("document loading triggered", logMeta, {
|
|
1072
|
-
F:
|
|
1100
|
+
F: __dxlog_file3,
|
|
1073
1101
|
L: 188,
|
|
1074
1102
|
S: this,
|
|
1075
1103
|
C: (f, a) => f(...a)
|
|
@@ -1092,7 +1120,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1092
1120
|
id: docHandle.documentId,
|
|
1093
1121
|
state: docHandle.state
|
|
1094
1122
|
}, {
|
|
1095
|
-
F:
|
|
1123
|
+
F: __dxlog_file3,
|
|
1096
1124
|
L: 204,
|
|
1097
1125
|
S: this,
|
|
1098
1126
|
C: (f, a) => f(...a)
|
|
@@ -1126,7 +1154,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1126
1154
|
};
|
|
1127
1155
|
if (this.onObjectDocumentLoaded.listenerCount() === 0) {
|
|
1128
1156
|
log2.info("document loaded after all listeners were removed", logMeta, {
|
|
1129
|
-
F:
|
|
1157
|
+
F: __dxlog_file3,
|
|
1130
1158
|
L: 231,
|
|
1131
1159
|
S: this,
|
|
1132
1160
|
C: (f, a) => f(...a)
|
|
@@ -1136,7 +1164,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1136
1164
|
const objectDocHandle = this._objectDocumentHandles.get(objectId);
|
|
1137
1165
|
if (objectDocHandle?.url !== handle.url) {
|
|
1138
1166
|
log2.warn("object was rebound while a document was loading, discarding handle", logMeta, {
|
|
1139
|
-
F:
|
|
1167
|
+
F: __dxlog_file3,
|
|
1140
1168
|
L: 236,
|
|
1141
1169
|
S: this,
|
|
1142
1170
|
C: (f, a) => f(...a)
|
|
@@ -1155,7 +1183,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1155
1183
|
retryLoading: shouldRetryLoading,
|
|
1156
1184
|
err
|
|
1157
1185
|
}, {
|
|
1158
|
-
F:
|
|
1186
|
+
F: __dxlog_file3,
|
|
1159
1187
|
L: 242,
|
|
1160
1188
|
S: this,
|
|
1161
1189
|
C: (f, a) => f(...a)
|
|
@@ -1177,13 +1205,13 @@ AutomergeDocumentLoaderImpl = _ts_decorate3([
|
|
|
1177
1205
|
|
|
1178
1206
|
// packages/core/echo/echo-pipeline/src/automerge/mesh-echo-replicator.ts
|
|
1179
1207
|
import { cbor as cbor2 } from "@dxos/automerge/automerge-repo";
|
|
1180
|
-
import { Resource as
|
|
1208
|
+
import { Resource as Resource3 } from "@dxos/context";
|
|
1181
1209
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
1182
1210
|
import { PublicKey as PublicKey2 } from "@dxos/keys";
|
|
1183
1211
|
import { log as log3 } from "@dxos/log";
|
|
1184
1212
|
import { AutomergeReplicator } from "@dxos/teleport-extension-automerge-replicator";
|
|
1185
1213
|
import { ComplexMap, ComplexSet, defaultMap } from "@dxos/util";
|
|
1186
|
-
var
|
|
1214
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/mesh-echo-replicator.ts";
|
|
1187
1215
|
var MeshEchoReplicator = class {
|
|
1188
1216
|
constructor() {
|
|
1189
1217
|
this._connections = /* @__PURE__ */ new Set();
|
|
@@ -1210,7 +1238,7 @@ var MeshEchoReplicator = class {
|
|
|
1210
1238
|
}
|
|
1211
1239
|
createExtension() {
|
|
1212
1240
|
invariant4(this._context, void 0, {
|
|
1213
|
-
F:
|
|
1241
|
+
F: __dxlog_file4,
|
|
1214
1242
|
L: 54,
|
|
1215
1243
|
S: this,
|
|
1216
1244
|
A: [
|
|
@@ -1224,13 +1252,13 @@ var MeshEchoReplicator = class {
|
|
|
1224
1252
|
log3("onRemoteConnected", {
|
|
1225
1253
|
peerId: connection.peerId
|
|
1226
1254
|
}, {
|
|
1227
|
-
F:
|
|
1255
|
+
F: __dxlog_file4,
|
|
1228
1256
|
L: 59,
|
|
1229
1257
|
S: this,
|
|
1230
1258
|
C: (f, a) => f(...a)
|
|
1231
1259
|
});
|
|
1232
1260
|
invariant4(this._context, void 0, {
|
|
1233
|
-
F:
|
|
1261
|
+
F: __dxlog_file4,
|
|
1234
1262
|
L: 60,
|
|
1235
1263
|
S: this,
|
|
1236
1264
|
A: [
|
|
@@ -1250,7 +1278,7 @@ var MeshEchoReplicator = class {
|
|
|
1250
1278
|
log3("onRemoteDisconnected", {
|
|
1251
1279
|
peerId: connection.peerId
|
|
1252
1280
|
}, {
|
|
1253
|
-
F:
|
|
1281
|
+
F: __dxlog_file4,
|
|
1254
1282
|
L: 71,
|
|
1255
1283
|
S: this,
|
|
1256
1284
|
C: (f, a) => f(...a)
|
|
@@ -1265,13 +1293,13 @@ var MeshEchoReplicator = class {
|
|
|
1265
1293
|
peerId: connection.peerId,
|
|
1266
1294
|
documentId: params.documentId
|
|
1267
1295
|
}, {
|
|
1268
|
-
F:
|
|
1296
|
+
F: __dxlog_file4,
|
|
1269
1297
|
L: 78,
|
|
1270
1298
|
S: this,
|
|
1271
1299
|
C: (f, a) => f(...a)
|
|
1272
1300
|
});
|
|
1273
1301
|
invariant4(this._context, void 0, {
|
|
1274
|
-
F:
|
|
1302
|
+
F: __dxlog_file4,
|
|
1275
1303
|
L: 79,
|
|
1276
1304
|
S: this,
|
|
1277
1305
|
A: [
|
|
@@ -1286,7 +1314,7 @@ var MeshEchoReplicator = class {
|
|
|
1286
1314
|
peerId: connection.peerId,
|
|
1287
1315
|
documentId: params.documentId
|
|
1288
1316
|
}, {
|
|
1289
|
-
F:
|
|
1317
|
+
F: __dxlog_file4,
|
|
1290
1318
|
L: 83,
|
|
1291
1319
|
S: this,
|
|
1292
1320
|
C: (f, a) => f(...a)
|
|
@@ -1299,7 +1327,7 @@ var MeshEchoReplicator = class {
|
|
|
1299
1327
|
peerId: connection.peerId,
|
|
1300
1328
|
documentId: params.documentId
|
|
1301
1329
|
}, {
|
|
1302
|
-
F:
|
|
1330
|
+
F: __dxlog_file4,
|
|
1303
1331
|
L: 93,
|
|
1304
1332
|
S: this,
|
|
1305
1333
|
C: (f, a) => f(...a)
|
|
@@ -1315,7 +1343,7 @@ var MeshEchoReplicator = class {
|
|
|
1315
1343
|
spaceKey,
|
|
1316
1344
|
isAuthorized
|
|
1317
1345
|
}, {
|
|
1318
|
-
F:
|
|
1346
|
+
F: __dxlog_file4,
|
|
1319
1347
|
L: 101,
|
|
1320
1348
|
S: this,
|
|
1321
1349
|
C: (f, a) => f(...a)
|
|
@@ -1323,7 +1351,7 @@ var MeshEchoReplicator = class {
|
|
|
1323
1351
|
return isAuthorized;
|
|
1324
1352
|
} catch (err) {
|
|
1325
1353
|
log3.catch(err, void 0, {
|
|
1326
|
-
F:
|
|
1354
|
+
F: __dxlog_file4,
|
|
1327
1355
|
L: 111,
|
|
1328
1356
|
S: this,
|
|
1329
1357
|
C: (f, a) => f(...a)
|
|
@@ -1340,7 +1368,7 @@ var MeshEchoReplicator = class {
|
|
|
1340
1368
|
spaceKey,
|
|
1341
1369
|
deviceKey
|
|
1342
1370
|
}, {
|
|
1343
|
-
F:
|
|
1371
|
+
F: __dxlog_file4,
|
|
1344
1372
|
L: 122,
|
|
1345
1373
|
S: this,
|
|
1346
1374
|
C: (f, a) => f(...a)
|
|
@@ -1353,7 +1381,7 @@ var MeshEchoReplicator = class {
|
|
|
1353
1381
|
}
|
|
1354
1382
|
}
|
|
1355
1383
|
};
|
|
1356
|
-
var MeshReplicatorConnection = class extends
|
|
1384
|
+
var MeshReplicatorConnection = class extends Resource3 {
|
|
1357
1385
|
constructor(_params) {
|
|
1358
1386
|
super();
|
|
1359
1387
|
this._params = _params;
|
|
@@ -1387,7 +1415,7 @@ var MeshReplicatorConnection = class extends Resource2 {
|
|
|
1387
1415
|
thisPeerId: this.peerId,
|
|
1388
1416
|
remotePeerId: remotePeerId.toHex()
|
|
1389
1417
|
}, {
|
|
1390
|
-
F:
|
|
1418
|
+
F: __dxlog_file4,
|
|
1391
1419
|
L: 192,
|
|
1392
1420
|
S: this,
|
|
1393
1421
|
C: (f, a) => f(...a)
|
|
@@ -1411,7 +1439,7 @@ var MeshReplicatorConnection = class extends Resource2 {
|
|
|
1411
1439
|
}
|
|
1412
1440
|
get peerId() {
|
|
1413
1441
|
invariant4(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
1414
|
-
F:
|
|
1442
|
+
F: __dxlog_file4,
|
|
1415
1443
|
L: 215,
|
|
1416
1444
|
S: this,
|
|
1417
1445
|
A: [
|
|
@@ -1430,7 +1458,7 @@ var MeshReplicatorConnection = class extends Resource2 {
|
|
|
1430
1458
|
*/
|
|
1431
1459
|
async enable() {
|
|
1432
1460
|
invariant4(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
1433
|
-
F:
|
|
1461
|
+
F: __dxlog_file4,
|
|
1434
1462
|
L: 228,
|
|
1435
1463
|
S: this,
|
|
1436
1464
|
A: [
|