@dxos/echo-pipeline 0.6.1-main.fac53f5 → 0.6.1-main.ff751ec

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.
@@ -18,40 +18,40 @@ 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: () => import_chunk_Y5U7UXEL.AuthExtension,
22
- AuthStatus: () => import_chunk_Y5U7UXEL.AuthStatus,
21
+ AuthExtension: () => import_chunk_QATBVT6S.AuthExtension,
22
+ AuthStatus: () => import_chunk_QATBVT6S.AuthStatus,
23
23
  AutomergeDocumentLoaderImpl: () => AutomergeDocumentLoaderImpl,
24
24
  AutomergeHost: () => AutomergeHost,
25
- CredentialRetrieverExtension: () => import_chunk_Y5U7UXEL.CredentialRetrieverExtension,
26
- CredentialServerExtension: () => import_chunk_Y5U7UXEL.CredentialServerExtension,
27
- DataServiceImpl: () => import_chunk_Y5U7UXEL.DataServiceImpl,
25
+ CredentialRetrieverExtension: () => import_chunk_QATBVT6S.CredentialRetrieverExtension,
26
+ CredentialServerExtension: () => import_chunk_QATBVT6S.CredentialServerExtension,
27
+ DataServiceImpl: () => import_chunk_QATBVT6S.DataServiceImpl,
28
28
  LevelDBStorageAdapter: () => LevelDBStorageAdapter,
29
29
  LocalHostNetworkAdapter: () => LocalHostNetworkAdapter,
30
- MOCK_AUTH_PROVIDER: () => import_chunk_Y5U7UXEL.MOCK_AUTH_PROVIDER,
31
- MOCK_AUTH_VERIFIER: () => import_chunk_Y5U7UXEL.MOCK_AUTH_VERIFIER,
30
+ MOCK_AUTH_PROVIDER: () => import_chunk_QATBVT6S.MOCK_AUTH_PROVIDER,
31
+ MOCK_AUTH_VERIFIER: () => import_chunk_QATBVT6S.MOCK_AUTH_VERIFIER,
32
32
  MeshEchoReplicator: () => MeshEchoReplicator,
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,
33
+ MetadataStore: () => import_chunk_QATBVT6S.MetadataStore,
34
+ Pipeline: () => import_chunk_QATBVT6S.Pipeline,
35
+ SnapshotManager: () => import_chunk_QATBVT6S.SnapshotManager,
36
+ SnapshotStore: () => import_chunk_QATBVT6S.SnapshotStore,
37
+ Space: () => import_chunk_QATBVT6S.Space,
38
+ SpaceManager: () => import_chunk_QATBVT6S.SpaceManager,
39
+ SpaceProtocol: () => import_chunk_QATBVT6S.SpaceProtocol,
40
+ SpaceProtocolSession: () => import_chunk_QATBVT6S.SpaceProtocolSession,
41
+ TimeframeClock: () => import_chunk_QATBVT6S.TimeframeClock,
42
+ codec: () => import_chunk_QATBVT6S.codec,
43
+ createIdFromSpaceKey: () => import_chunk_QATBVT6S.createIdFromSpaceKey,
44
+ createMappedFeedWriter: () => import_chunk_QATBVT6S.createMappedFeedWriter,
45
45
  encodingOptions: () => encodingOptions,
46
46
  getSpaceKeyFromDoc: () => getSpaceKeyFromDoc,
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
47
+ hasInvitationExpired: () => import_chunk_QATBVT6S.hasInvitationExpired,
48
+ mapFeedIndexesToTimeframe: () => import_chunk_QATBVT6S.mapFeedIndexesToTimeframe,
49
+ mapTimeframeToFeedIndexes: () => import_chunk_QATBVT6S.mapTimeframeToFeedIndexes,
50
+ startAfter: () => import_chunk_QATBVT6S.startAfter,
51
+ valueEncoding: () => import_chunk_QATBVT6S.valueEncoding
52
52
  });
53
53
  module.exports = __toCommonJS(node_exports);
54
- var import_chunk_Y5U7UXEL = require("./chunk-Y5U7UXEL.cjs");
54
+ var import_chunk_QATBVT6S = require("./chunk-QATBVT6S.cjs");
55
55
  var import_async = require("@dxos/async");
56
56
  var import_automerge = require("@dxos/automerge/automerge");
57
57
  var import_automerge_repo = require("@dxos/automerge/automerge-repo");
@@ -65,6 +65,7 @@ var import_automerge_repo2 = require("@dxos/automerge/automerge-repo");
65
65
  var import_context2 = require("@dxos/context");
66
66
  var import_invariant = require("@dxos/invariant");
67
67
  var import_log = require("@dxos/log");
68
+ var import_indexing = require("@dxos/indexing");
68
69
  var import_context3 = require("@dxos/context");
69
70
  var import_async3 = require("@dxos/async");
70
71
  var import_automerge_repo3 = require("@dxos/automerge/automerge-repo");
@@ -129,19 +130,13 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
129
130
  disconnect() {
130
131
  }
131
132
  async open() {
132
- (0, import_invariant.invariant)(this._lifecycleState === import_context2.LifecycleState.CLOSED, void 0, {
133
- F: __dxlog_file,
134
- L: 60,
135
- S: this,
136
- A: [
137
- "this._lifecycleState === LifecycleState.CLOSED",
138
- ""
139
- ]
140
- });
133
+ if (this._lifecycleState === import_context2.LifecycleState.OPEN) {
134
+ return;
135
+ }
141
136
  this._lifecycleState = import_context2.LifecycleState.OPEN;
142
137
  (0, import_log.log)("emit ready", void 0, {
143
138
  F: __dxlog_file,
144
- L: 63,
139
+ L: 65,
145
140
  S: this,
146
141
  C: (f, a) => f(...a)
147
142
  });
@@ -150,15 +145,9 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
150
145
  });
151
146
  }
152
147
  async close() {
153
- (0, import_invariant.invariant)(this._lifecycleState === import_context2.LifecycleState.OPEN, void 0, {
154
- F: __dxlog_file,
155
- L: 71,
156
- S: this,
157
- A: [
158
- "this._lifecycleState === LifecycleState.OPEN",
159
- ""
160
- ]
161
- });
148
+ if (this._lifecycleState === import_context2.LifecycleState.CLOSED) {
149
+ return;
150
+ }
162
151
  for (const replicator of this._replicators) {
163
152
  await replicator.disconnect();
164
153
  }
@@ -173,7 +162,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
173
162
  async addReplicator(replicator) {
174
163
  (0, import_invariant.invariant)(this._lifecycleState === import_context2.LifecycleState.OPEN, void 0, {
175
164
  F: __dxlog_file,
176
- L: 87,
165
+ L: 91,
177
166
  S: this,
178
167
  A: [
179
168
  "this._lifecycleState === LifecycleState.OPEN",
@@ -182,7 +171,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
182
171
  });
183
172
  (0, import_invariant.invariant)(this.peerId, void 0, {
184
173
  F: __dxlog_file,
185
- L: 88,
174
+ L: 92,
186
175
  S: this,
187
176
  A: [
188
177
  "this.peerId",
@@ -191,7 +180,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
191
180
  });
192
181
  (0, import_invariant.invariant)(!this._replicators.has(replicator), void 0, {
193
182
  F: __dxlog_file,
194
- L: 89,
183
+ L: 93,
195
184
  S: this,
196
185
  A: [
197
186
  "!this._replicators.has(replicator)",
@@ -210,7 +199,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
210
199
  async removeReplicator(replicator) {
211
200
  (0, import_invariant.invariant)(this._lifecycleState === import_context2.LifecycleState.OPEN, void 0, {
212
201
  F: __dxlog_file,
213
- L: 103,
202
+ L: 107,
214
203
  S: this,
215
204
  A: [
216
205
  "this._lifecycleState === LifecycleState.OPEN",
@@ -219,7 +208,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
219
208
  });
220
209
  (0, import_invariant.invariant)(this._replicators.has(replicator), void 0, {
221
210
  F: __dxlog_file,
222
- L: 104,
211
+ L: 108,
223
212
  S: this,
224
213
  A: [
225
214
  "this._replicators.has(replicator)",
@@ -241,13 +230,13 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
241
230
  peerId: connection.peerId
242
231
  }, {
243
232
  F: __dxlog_file,
244
- L: 119,
233
+ L: 123,
245
234
  S: this,
246
235
  C: (f, a) => f(...a)
247
236
  });
248
237
  (0, import_invariant.invariant)(!this._connections.has(connection.peerId), void 0, {
249
238
  F: __dxlog_file,
250
- L: 120,
239
+ L: 124,
251
240
  S: this,
252
241
  A: [
253
242
  "!this._connections.has(connection.peerId as PeerId)",
@@ -276,7 +265,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
276
265
  if (connectionEntry.isOpen) {
277
266
  import_log.log.catch(err, void 0, {
278
267
  F: __dxlog_file,
279
- L: 139,
268
+ L: 143,
280
269
  S: this,
281
270
  C: (f, a) => f(...a)
282
271
  });
@@ -287,7 +276,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
287
276
  peerId: connection.peerId
288
277
  }, {
289
278
  F: __dxlog_file,
290
- L: 144,
279
+ L: 148,
291
280
  S: this,
292
281
  C: (f, a) => f(...a)
293
282
  });
@@ -302,14 +291,14 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
302
291
  peerId: connection.peerId
303
292
  }, {
304
293
  F: __dxlog_file,
305
- L: 153,
294
+ L: 157,
306
295
  S: this,
307
296
  C: (f, a) => f(...a)
308
297
  });
309
298
  const entry = this._connections.get(connection.peerId);
310
299
  (0, import_invariant.invariant)(entry, void 0, {
311
300
  F: __dxlog_file,
312
- L: 155,
301
+ L: 159,
313
302
  S: this,
314
303
  A: [
315
304
  "entry",
@@ -326,14 +315,14 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
326
315
  peerId: connection.peerId
327
316
  }, {
328
317
  F: __dxlog_file,
329
- L: 161,
318
+ L: 165,
330
319
  S: this,
331
320
  C: (f, a) => f(...a)
332
321
  });
333
322
  const entry = this._connections.get(connection.peerId);
334
323
  (0, import_invariant.invariant)(entry, void 0, {
335
324
  F: __dxlog_file,
336
- L: 163,
325
+ L: 167,
337
326
  S: this,
338
327
  A: [
339
328
  "entry",
@@ -346,13 +335,13 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
346
335
  });
347
336
  void entry.reader.cancel().catch((err) => import_log.log.catch(err, void 0, {
348
337
  F: __dxlog_file,
349
- L: 168,
338
+ L: 172,
350
339
  S: this,
351
340
  C: (f, a) => f(...a)
352
341
  }));
353
342
  void entry.writer.abort().catch((err) => import_log.log.catch(err, void 0, {
354
343
  F: __dxlog_file,
355
- L: 169,
344
+ L: 173,
356
345
  S: this,
357
346
  C: (f, a) => f(...a)
358
347
  }));
@@ -382,6 +371,31 @@ var createEchoPeerMetadata = () => ({
382
371
  dxos_peerSource: "EchoNetworkAdapter"
383
372
  });
384
373
  var isEchoPeerMetadata = (metadata) => metadata?.dxos_peerSource === "EchoNetworkAdapter";
374
+ var HeadsStore = class {
375
+ constructor({ db }) {
376
+ this._db = db;
377
+ }
378
+ setHeads(documentId, heads, batch) {
379
+ batch.put(documentId, heads, {
380
+ sublevel: this._db,
381
+ keyEncoding: "utf8",
382
+ valueEncoding: import_indexing.headsEncoding
383
+ });
384
+ }
385
+ async getHeads(documentId) {
386
+ try {
387
+ return await this._db.get(documentId, {
388
+ keyEncoding: "utf8",
389
+ valueEncoding: import_indexing.headsEncoding
390
+ });
391
+ } catch (err) {
392
+ if (err.notFound) {
393
+ return void 0;
394
+ }
395
+ throw err;
396
+ }
397
+ }
398
+ };
385
399
  var LevelDBStorageAdapter = class extends import_context3.Resource {
386
400
  constructor(_params) {
387
401
  super();
@@ -617,26 +631,25 @@ function _ts_decorate2(decorators, target, key, desc) {
617
631
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
618
632
  return c > 3 && r && Object.defineProperty(target, key, r), r;
619
633
  }
620
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
621
- var AutomergeHost = class {
634
+ var AutomergeHost = class extends import_context.Resource {
622
635
  constructor({ db, indexMetadataStore }) {
623
- this._ctx = new import_context.Context(void 0, {
624
- F: __dxlog_file3,
625
- L: 71
626
- });
636
+ super();
627
637
  this._echoNetworkAdapter = new EchoNetworkAdapter({
628
638
  getContainingSpaceForDocument: this._getContainingSpaceForDocument.bind(this)
629
639
  });
630
640
  this._storage = new LevelDBStorageAdapter({
631
- db,
641
+ db: db.sublevel("automerge"),
632
642
  callbacks: {
633
643
  beforeSave: async (params) => this._beforeSave(params),
634
644
  afterSave: async () => this._afterSave()
635
645
  }
636
646
  });
647
+ this._headsStore = new HeadsStore({
648
+ db: db.sublevel("heads")
649
+ });
637
650
  this._indexMetadataStore = indexMetadataStore;
638
651
  }
639
- async open() {
652
+ async _open() {
640
653
  this._peerId = `host-${import_keys.PublicKey.random().toHex()}`;
641
654
  await this._storage.open?.();
642
655
  this._clientNetwork = new LocalHostNetworkAdapter();
@@ -656,7 +669,7 @@ var AutomergeHost = class {
656
669
  await this._clientNetwork.whenConnected();
657
670
  await this._echoNetworkAdapter.whenConnected();
658
671
  }
659
- async close() {
672
+ async _close() {
660
673
  await this._storage.close?.();
661
674
  await this._clientNetwork.close();
662
675
  await this._echoNetworkAdapter.close();
@@ -736,7 +749,8 @@ var AutomergeHost = class {
736
749
  return;
737
750
  }
738
751
  const spaceKey = getSpaceKeyFromDoc(doc) ?? void 0;
739
- const lastAvailableHash = (0, import_automerge.getHeads)(doc);
752
+ const heads = (0, import_automerge.getHeads)(doc);
753
+ this._headsStore.setHeads(handle.documentId, heads, batch);
740
754
  const objectIds = Object.keys(doc.objects ?? {});
741
755
  const encodedIds = objectIds.map((objectId) => import_protocols.objectPointerCodec.encode({
742
756
  documentId: handle.documentId,
@@ -745,7 +759,7 @@ var AutomergeHost = class {
745
759
  }));
746
760
  const idToLastHash = new Map(encodedIds.map((id) => [
747
761
  id,
748
- lastAvailableHash
762
+ heads
749
763
  ]));
750
764
  this._indexMetadataStore.markDirty(idToLastHash, batch);
751
765
  }
@@ -794,18 +808,30 @@ var AutomergeHost = class {
794
808
  /**
795
809
  * Flush documents to disk.
796
810
  */
797
- async flush({ states }) {
811
+ async flush({ states } = {}) {
798
812
  if (states) {
799
813
  await Promise.all(states.map(async ({ heads, documentId }) => {
800
814
  if (!heads) {
801
815
  return;
802
816
  }
803
- const handle = this.repo.handles[documentId] ?? this._repo.find(documentId);
817
+ const handle = this._repo.handles[documentId] ?? this._repo.find(documentId);
804
818
  await waitForHeads(handle, heads);
805
819
  }) ?? []);
806
820
  }
807
821
  await this._repo.flush(states?.map(({ documentId }) => documentId));
808
822
  }
823
+ async getHeads(documentId) {
824
+ const handle = this._repo.handles[documentId];
825
+ if (handle) {
826
+ const doc = handle.docSync();
827
+ if (!doc) {
828
+ return void 0;
829
+ }
830
+ return (0, import_automerge.getHeads)(doc);
831
+ } else {
832
+ return this._headsStore.getHeads(documentId);
833
+ }
834
+ }
809
835
  /**
810
836
  * Host <-> Client sync.
811
837
  */
@@ -881,7 +907,7 @@ function _ts_decorate3(decorators, target, key, desc) {
881
907
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
882
908
  return c > 3 && r && Object.defineProperty(target, key, r), r;
883
909
  }
884
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-doc-loader.ts";
910
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-doc-loader.ts";
885
911
  var AutomergeDocumentLoaderImpl = class {
886
912
  constructor(_spaceId, _repo, _spaceKey) {
887
913
  this._spaceId = _spaceId;
@@ -908,7 +934,7 @@ var AutomergeDocumentLoaderImpl = class {
908
934
  const existingDocHandle = await this._initDocHandle(ctx, spaceState.rootUrl);
909
935
  const doc = existingDocHandle.docSync();
910
936
  (0, import_invariant3.invariant)(doc, void 0, {
911
- F: __dxlog_file4,
937
+ F: __dxlog_file3,
912
938
  L: 84,
913
939
  S: this,
914
940
  A: [
@@ -917,7 +943,7 @@ var AutomergeDocumentLoaderImpl = class {
917
943
  ]
918
944
  });
919
945
  (0, import_invariant3.invariant)(doc.version === import_echo_protocol.SpaceDocVersion.CURRENT, void 0, {
920
- F: __dxlog_file4,
946
+ F: __dxlog_file3,
921
947
  L: 85,
922
948
  S: this,
923
949
  A: [
@@ -938,7 +964,7 @@ var AutomergeDocumentLoaderImpl = class {
938
964
  const urlsToLoad = {};
939
965
  for (const objectId of objectIds) {
940
966
  (0, import_invariant3.invariant)(this._spaceRootDocHandle, void 0, {
941
- F: __dxlog_file4,
967
+ F: __dxlog_file3,
942
968
  L: 97,
943
969
  S: this,
944
970
  A: [
@@ -951,7 +977,7 @@ var AutomergeDocumentLoaderImpl = class {
951
977
  }
952
978
  const spaceRootDoc = this._spaceRootDocHandle.docSync();
953
979
  (0, import_invariant3.invariant)(spaceRootDoc, void 0, {
954
- F: __dxlog_file4,
980
+ F: __dxlog_file3,
955
981
  L: 102,
956
982
  S: this,
957
983
  A: [
@@ -965,7 +991,7 @@ var AutomergeDocumentLoaderImpl = class {
965
991
  import_log2.log.info("loading delayed until object links are initialized", {
966
992
  objectId
967
993
  }, {
968
- F: __dxlog_file4,
994
+ F: __dxlog_file3,
969
995
  L: 106,
970
996
  S: this,
971
997
  C: (f, a) => f(...a)
@@ -981,7 +1007,7 @@ var AutomergeDocumentLoaderImpl = class {
981
1007
  }
982
1008
  getObjectDocumentId(objectId) {
983
1009
  (0, import_invariant3.invariant)(this._spaceRootDocHandle, void 0, {
984
- F: __dxlog_file4,
1010
+ F: __dxlog_file3,
985
1011
  L: 118,
986
1012
  S: this,
987
1013
  A: [
@@ -991,7 +1017,7 @@ var AutomergeDocumentLoaderImpl = class {
991
1017
  });
992
1018
  const spaceRootDoc = this._spaceRootDocHandle.docSync();
993
1019
  (0, import_invariant3.invariant)(spaceRootDoc, void 0, {
994
- F: __dxlog_file4,
1020
+ F: __dxlog_file3,
995
1021
  L: 120,
996
1022
  S: this,
997
1023
  A: [
@@ -1015,7 +1041,7 @@ var AutomergeDocumentLoaderImpl = class {
1015
1041
  }
1016
1042
  getSpaceRootDocHandle() {
1017
1043
  (0, import_invariant3.invariant)(this._spaceRootDocHandle, void 0, {
1018
- F: __dxlog_file4,
1044
+ F: __dxlog_file3,
1019
1045
  L: 140,
1020
1046
  S: this,
1021
1047
  A: [
@@ -1027,7 +1053,7 @@ var AutomergeDocumentLoaderImpl = class {
1027
1053
  }
1028
1054
  createDocumentForObject(objectId) {
1029
1055
  (0, import_invariant3.invariant)(this._spaceRootDocHandle, void 0, {
1030
- F: __dxlog_file4,
1056
+ F: __dxlog_file3,
1031
1057
  L: 145,
1032
1058
  S: this,
1033
1059
  A: [
@@ -1072,7 +1098,7 @@ var AutomergeDocumentLoaderImpl = class {
1072
1098
  ...logMeta,
1073
1099
  actualDocumentUrl: objectDocumentHandle.url
1074
1100
  }, {
1075
- F: __dxlog_file4,
1101
+ F: __dxlog_file3,
1076
1102
  L: 177,
1077
1103
  S: this,
1078
1104
  C: (f, a) => f(...a)
@@ -1081,7 +1107,7 @@ var AutomergeDocumentLoaderImpl = class {
1081
1107
  }
1082
1108
  if (objectDocumentHandle?.url === automergeUrl) {
1083
1109
  import_log2.log.warn("object document was already loaded", logMeta, {
1084
- F: __dxlog_file4,
1110
+ F: __dxlog_file3,
1085
1111
  L: 184,
1086
1112
  S: this,
1087
1113
  C: (f, a) => f(...a)
@@ -1090,7 +1116,7 @@ var AutomergeDocumentLoaderImpl = class {
1090
1116
  }
1091
1117
  const handle = this._repo.find(automergeUrl);
1092
1118
  import_log2.log.debug("document loading triggered", logMeta, {
1093
- F: __dxlog_file4,
1119
+ F: __dxlog_file3,
1094
1120
  L: 188,
1095
1121
  S: this,
1096
1122
  C: (f, a) => f(...a)
@@ -1113,7 +1139,7 @@ var AutomergeDocumentLoaderImpl = class {
1113
1139
  id: docHandle.documentId,
1114
1140
  state: docHandle.state
1115
1141
  }, {
1116
- F: __dxlog_file4,
1142
+ F: __dxlog_file3,
1117
1143
  L: 204,
1118
1144
  S: this,
1119
1145
  C: (f, a) => f(...a)
@@ -1138,16 +1164,14 @@ var AutomergeDocumentLoaderImpl = class {
1138
1164
  }
1139
1165
  async _createObjectOnDocumentLoad(handle, objectId) {
1140
1166
  try {
1141
- await handle.doc([
1142
- "ready"
1143
- ]);
1167
+ await handle.whenReady();
1144
1168
  const logMeta = {
1145
1169
  objectId,
1146
1170
  docUrl: handle.url
1147
1171
  };
1148
1172
  if (this.onObjectDocumentLoaded.listenerCount() === 0) {
1149
1173
  import_log2.log.info("document loaded after all listeners were removed", logMeta, {
1150
- F: __dxlog_file4,
1174
+ F: __dxlog_file3,
1151
1175
  L: 231,
1152
1176
  S: this,
1153
1177
  C: (f, a) => f(...a)
@@ -1157,7 +1181,7 @@ var AutomergeDocumentLoaderImpl = class {
1157
1181
  const objectDocHandle = this._objectDocumentHandles.get(objectId);
1158
1182
  if (objectDocHandle?.url !== handle.url) {
1159
1183
  import_log2.log.warn("object was rebound while a document was loading, discarding handle", logMeta, {
1160
- F: __dxlog_file4,
1184
+ F: __dxlog_file3,
1161
1185
  L: 236,
1162
1186
  S: this,
1163
1187
  C: (f, a) => f(...a)
@@ -1176,7 +1200,7 @@ var AutomergeDocumentLoaderImpl = class {
1176
1200
  retryLoading: shouldRetryLoading,
1177
1201
  err
1178
1202
  }, {
1179
- F: __dxlog_file4,
1203
+ F: __dxlog_file3,
1180
1204
  L: 242,
1181
1205
  S: this,
1182
1206
  C: (f, a) => f(...a)
@@ -1195,7 +1219,7 @@ _ts_decorate3([
1195
1219
  AutomergeDocumentLoaderImpl = _ts_decorate3([
1196
1220
  import_tracing2.trace.resource()
1197
1221
  ], AutomergeDocumentLoaderImpl);
1198
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/mesh-echo-replicator.ts";
1222
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/mesh-echo-replicator.ts";
1199
1223
  var MeshEchoReplicator = class {
1200
1224
  constructor() {
1201
1225
  this._connections = /* @__PURE__ */ new Set();
@@ -1216,7 +1240,7 @@ var MeshEchoReplicator = class {
1216
1240
  }
1217
1241
  createExtension() {
1218
1242
  (0, import_invariant4.invariant)(this._context, void 0, {
1219
- F: __dxlog_file5,
1243
+ F: __dxlog_file4,
1220
1244
  L: 54,
1221
1245
  S: this,
1222
1246
  A: [
@@ -1230,13 +1254,13 @@ var MeshEchoReplicator = class {
1230
1254
  (0, import_log3.log)("onRemoteConnected", {
1231
1255
  peerId: connection.peerId
1232
1256
  }, {
1233
- F: __dxlog_file5,
1257
+ F: __dxlog_file4,
1234
1258
  L: 59,
1235
1259
  S: this,
1236
1260
  C: (f, a) => f(...a)
1237
1261
  });
1238
1262
  (0, import_invariant4.invariant)(this._context, void 0, {
1239
- F: __dxlog_file5,
1263
+ F: __dxlog_file4,
1240
1264
  L: 60,
1241
1265
  S: this,
1242
1266
  A: [
@@ -1256,7 +1280,7 @@ var MeshEchoReplicator = class {
1256
1280
  (0, import_log3.log)("onRemoteDisconnected", {
1257
1281
  peerId: connection.peerId
1258
1282
  }, {
1259
- F: __dxlog_file5,
1283
+ F: __dxlog_file4,
1260
1284
  L: 71,
1261
1285
  S: this,
1262
1286
  C: (f, a) => f(...a)
@@ -1271,13 +1295,13 @@ var MeshEchoReplicator = class {
1271
1295
  peerId: connection.peerId,
1272
1296
  documentId: params.documentId
1273
1297
  }, {
1274
- F: __dxlog_file5,
1298
+ F: __dxlog_file4,
1275
1299
  L: 78,
1276
1300
  S: this,
1277
1301
  C: (f, a) => f(...a)
1278
1302
  });
1279
1303
  (0, import_invariant4.invariant)(this._context, void 0, {
1280
- F: __dxlog_file5,
1304
+ F: __dxlog_file4,
1281
1305
  L: 79,
1282
1306
  S: this,
1283
1307
  A: [
@@ -1292,7 +1316,7 @@ var MeshEchoReplicator = class {
1292
1316
  peerId: connection.peerId,
1293
1317
  documentId: params.documentId
1294
1318
  }, {
1295
- F: __dxlog_file5,
1319
+ F: __dxlog_file4,
1296
1320
  L: 83,
1297
1321
  S: this,
1298
1322
  C: (f, a) => f(...a)
@@ -1305,7 +1329,7 @@ var MeshEchoReplicator = class {
1305
1329
  peerId: connection.peerId,
1306
1330
  documentId: params.documentId
1307
1331
  }, {
1308
- F: __dxlog_file5,
1332
+ F: __dxlog_file4,
1309
1333
  L: 93,
1310
1334
  S: this,
1311
1335
  C: (f, a) => f(...a)
@@ -1321,7 +1345,7 @@ var MeshEchoReplicator = class {
1321
1345
  spaceKey,
1322
1346
  isAuthorized
1323
1347
  }, {
1324
- F: __dxlog_file5,
1348
+ F: __dxlog_file4,
1325
1349
  L: 101,
1326
1350
  S: this,
1327
1351
  C: (f, a) => f(...a)
@@ -1329,7 +1353,7 @@ var MeshEchoReplicator = class {
1329
1353
  return isAuthorized;
1330
1354
  } catch (err) {
1331
1355
  import_log3.log.catch(err, void 0, {
1332
- F: __dxlog_file5,
1356
+ F: __dxlog_file4,
1333
1357
  L: 111,
1334
1358
  S: this,
1335
1359
  C: (f, a) => f(...a)
@@ -1346,7 +1370,7 @@ var MeshEchoReplicator = class {
1346
1370
  spaceKey,
1347
1371
  deviceKey
1348
1372
  }, {
1349
- F: __dxlog_file5,
1373
+ F: __dxlog_file4,
1350
1374
  L: 122,
1351
1375
  S: this,
1352
1376
  C: (f, a) => f(...a)
@@ -1393,7 +1417,7 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
1393
1417
  thisPeerId: this.peerId,
1394
1418
  remotePeerId: remotePeerId.toHex()
1395
1419
  }, {
1396
- F: __dxlog_file5,
1420
+ F: __dxlog_file4,
1397
1421
  L: 192,
1398
1422
  S: this,
1399
1423
  C: (f, a) => f(...a)
@@ -1417,7 +1441,7 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
1417
1441
  }
1418
1442
  get peerId() {
1419
1443
  (0, import_invariant4.invariant)(this._remotePeerId != null, "Remote peer has not connected yet.", {
1420
- F: __dxlog_file5,
1444
+ F: __dxlog_file4,
1421
1445
  L: 215,
1422
1446
  S: this,
1423
1447
  A: [
@@ -1436,7 +1460,7 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
1436
1460
  */
1437
1461
  async enable() {
1438
1462
  (0, import_invariant4.invariant)(this._remotePeerId != null, "Remote peer has not connected yet.", {
1439
- F: __dxlog_file5,
1463
+ F: __dxlog_file4,
1440
1464
  L: 228,
1441
1465
  S: this,
1442
1466
  A: [