@dxos/echo-pipeline 0.5.9-main.4ed8273 → 0.5.9-main.4fc2821

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.
Files changed (28) hide show
  1. package/dist/lib/browser/index.mjs +78 -206
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node/index.cjs +91 -214
  5. package/dist/lib/node/index.cjs.map +4 -4
  6. package/dist/lib/node/meta.json +1 -1
  7. package/dist/types/src/automerge/automerge-doc-loader.d.ts.map +1 -1
  8. package/dist/types/src/automerge/automerge-host.d.ts +1 -9
  9. package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
  10. package/dist/types/src/automerge/index.d.ts +0 -1
  11. package/dist/types/src/automerge/index.d.ts.map +1 -1
  12. package/dist/types/src/automerge/mesh-echo-replicator.d.ts.map +1 -1
  13. package/package.json +33 -33
  14. package/src/automerge/automerge-doc-loader.test.ts +2 -3
  15. package/src/automerge/automerge-doc-loader.ts +4 -2
  16. package/src/automerge/automerge-host.ts +8 -35
  17. package/src/automerge/index.ts +0 -1
  18. package/src/automerge/mesh-echo-replicator.ts +5 -0
  19. package/src/automerge/storage-adapter.test.ts +103 -139
  20. package/dist/types/src/automerge/automerge-storage-adapter.d.ts +0 -16
  21. package/dist/types/src/automerge/automerge-storage-adapter.d.ts.map +0 -1
  22. package/dist/types/src/automerge/automerge-storage/342/200/223wrapper.d.ts +0 -25
  23. package/dist/types/src/automerge/automerge-storage/342/200/223wrapper.d.ts.map +0 -1
  24. package/dist/types/src/automerge/migrations.d.ts +0 -7
  25. package/dist/types/src/automerge/migrations.d.ts.map +0 -1
  26. package/src/automerge/automerge-storage-adapter.ts +0 -103
  27. package/src/automerge/automerge-storage/342/200/223wrapper.ts +0 -59
  28. package/src/automerge/migrations.ts +0 -42
@@ -22,7 +22,6 @@ __export(node_exports, {
22
22
  AuthStatus: () => import_chunk_QPCNQ4ZK.AuthStatus,
23
23
  AutomergeDocumentLoaderImpl: () => AutomergeDocumentLoaderImpl,
24
24
  AutomergeHost: () => AutomergeHost,
25
- AutomergeStorageAdapter: () => AutomergeStorageAdapter,
26
25
  DataServiceImpl: () => import_chunk_QPCNQ4ZK.DataServiceImpl,
27
26
  LevelDBStorageAdapter: () => LevelDBStorageAdapter,
28
27
  LocalHostNetworkAdapter: () => LocalHostNetworkAdapter,
@@ -57,7 +56,6 @@ var import_automerge_repo = require("@dxos/automerge/automerge-repo");
57
56
  var import_context = require("@dxos/context");
58
57
  var import_invariant = require("@dxos/invariant");
59
58
  var import_keys = require("@dxos/keys");
60
- var import_log = require("@dxos/log");
61
59
  var import_protocols = require("@dxos/protocols");
62
60
  var import_tracing = require("@dxos/tracing");
63
61
  var import_util = require("@dxos/util");
@@ -65,29 +63,26 @@ var import_async2 = require("@dxos/async");
65
63
  var import_automerge_repo2 = require("@dxos/automerge/automerge-repo");
66
64
  var import_context2 = require("@dxos/context");
67
65
  var import_invariant2 = require("@dxos/invariant");
68
- var import_log2 = require("@dxos/log");
66
+ var import_log = require("@dxos/log");
69
67
  var import_context3 = require("@dxos/context");
70
68
  var import_async3 = require("@dxos/async");
71
69
  var import_automerge_repo3 = require("@dxos/automerge/automerge-repo");
72
70
  var import_codec_protobuf = require("@dxos/codec-protobuf");
73
71
  var import_invariant3 = require("@dxos/invariant");
74
- var import_automerge_repo_storage_indexeddb = require("@dxos/automerge/automerge-repo-storage-indexeddb");
75
- var import_log3 = require("@dxos/log");
76
- var import_random_access_storage = require("@dxos/random-access-storage");
77
- var import_util2 = require("@dxos/util");
78
72
  var import_async4 = require("@dxos/async");
79
73
  var import_context4 = require("@dxos/context");
80
74
  var import_debug = require("@dxos/debug");
75
+ var import_echo_protocol = require("@dxos/echo-protocol");
81
76
  var import_invariant4 = require("@dxos/invariant");
82
- var import_log4 = require("@dxos/log");
77
+ var import_log2 = require("@dxos/log");
83
78
  var import_tracing2 = require("@dxos/tracing");
84
79
  var import_automerge_repo4 = require("@dxos/automerge/automerge-repo");
85
80
  var import_context5 = require("@dxos/context");
86
81
  var import_invariant5 = require("@dxos/invariant");
87
82
  var import_keys2 = require("@dxos/keys");
88
- var import_log5 = require("@dxos/log");
83
+ var import_log3 = require("@dxos/log");
89
84
  var import_teleport_extension_automerge_replicator = require("@dxos/teleport-extension-automerge-replicator");
90
- var import_util3 = require("@dxos/util");
85
+ var import_util2 = require("@dxos/util");
91
86
  function _ts_decorate(decorators, target, key, desc) {
92
87
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
93
88
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -120,7 +115,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
120
115
  }
121
116
  connectionEntry.writer.write(message).catch((err) => {
122
117
  if (connectionEntry.isOpen) {
123
- import_log2.log.catch(err, void 0, {
118
+ import_log.log.catch(err, void 0, {
124
119
  F: __dxlog_file,
125
120
  L: 49,
126
121
  S: this,
@@ -142,7 +137,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
142
137
  ]
143
138
  });
144
139
  this._lifecycleState = import_context2.LifecycleState.OPEN;
145
- (0, import_log2.log)("emit ready", void 0, {
140
+ (0, import_log.log)("emit ready", void 0, {
146
141
  F: __dxlog_file,
147
142
  L: 63,
148
143
  S: this,
@@ -240,7 +235,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
240
235
  return connection.connection.shouldAdvertize(params);
241
236
  }
242
237
  _onConnectionOpen(connection) {
243
- (0, import_log2.log)("Connection opened", {
238
+ (0, import_log.log)("Connection opened", {
244
239
  peerId: connection.peerId
245
240
  }, {
246
241
  F: __dxlog_file,
@@ -277,7 +272,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
277
272
  }
278
273
  } catch (err) {
279
274
  if (connectionEntry.isOpen) {
280
- import_log2.log.catch(err, void 0, {
275
+ import_log.log.catch(err, void 0, {
281
276
  F: __dxlog_file,
282
277
  L: 139,
283
278
  S: this,
@@ -286,7 +281,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
286
281
  }
287
282
  }
288
283
  });
289
- (0, import_log2.log)("emit peer-candidate", {
284
+ (0, import_log.log)("emit peer-candidate", {
290
285
  peerId: connection.peerId
291
286
  }, {
292
287
  F: __dxlog_file,
@@ -301,7 +296,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
301
296
  * TODO(y): replace with a proper API call when sharePolicy update becomes supported by automerge-repo
302
297
  */
303
298
  _onConnectionAuthScopeChanged(connection) {
304
- (0, import_log2.log)("Connection auth scope changed", {
299
+ (0, import_log.log)("Connection auth scope changed", {
305
300
  peerId: connection.peerId
306
301
  }, {
307
302
  F: __dxlog_file,
@@ -325,7 +320,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
325
320
  this._emitPeerCandidate(connection);
326
321
  }
327
322
  _onConnectionClosed(connection) {
328
- (0, import_log2.log)("Connection closed", {
323
+ (0, import_log.log)("Connection closed", {
329
324
  peerId: connection.peerId
330
325
  }, {
331
326
  F: __dxlog_file,
@@ -347,13 +342,13 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
347
342
  this.emit("peer-disconnected", {
348
343
  peerId: connection.peerId
349
344
  });
350
- void entry.reader.cancel().catch((err) => import_log2.log.catch(err, void 0, {
345
+ void entry.reader.cancel().catch((err) => import_log.log.catch(err, void 0, {
351
346
  F: __dxlog_file,
352
347
  L: 168,
353
348
  S: this,
354
349
  C: (f, a) => f(...a)
355
350
  }));
356
- void entry.writer.abort().catch((err) => import_log2.log.catch(err, void 0, {
351
+ void entry.writer.abort().catch((err) => import_log.log.catch(err, void 0, {
357
352
  F: __dxlog_file,
358
353
  L: 169,
359
354
  S: this,
@@ -608,108 +603,6 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo3.NetworkAdapte
608
603
  return id;
609
604
  }
610
605
  };
611
- var AutomergeStorageAdapter = class {
612
- constructor(_directory) {
613
- this._directory = _directory;
614
- this._state = "opened";
615
- }
616
- async load(key) {
617
- if (this._state !== "opened") {
618
- return void 0;
619
- }
620
- const filename = this._getFilename(key);
621
- const file = this._directory.getOrCreateFile(filename);
622
- const { size } = await file.stat();
623
- if (!size || size === 0) {
624
- return void 0;
625
- }
626
- const buffer = await file.read(0, size);
627
- return (0, import_util2.bufferToArray)(buffer);
628
- }
629
- async save(key, data) {
630
- if (this._state !== "opened") {
631
- return void 0;
632
- }
633
- const filename = this._getFilename(key);
634
- const file = this._directory.getOrCreateFile(filename);
635
- await file.write(0, (0, import_util2.arrayToBuffer)(data));
636
- await file.truncate?.(data.length);
637
- await file.flush?.();
638
- }
639
- async remove(key) {
640
- if (this._state !== "opened") {
641
- return void 0;
642
- }
643
- const filename = this._getFilename(key);
644
- const file = this._directory.getOrCreateFile(filename);
645
- await file.destroy();
646
- }
647
- async loadRange(keyPrefix) {
648
- if (this._state !== "opened") {
649
- return [];
650
- }
651
- const filename = this._getFilename(keyPrefix);
652
- const entries = await this._directory.list();
653
- return Promise.all(entries.filter((entry) => entry.startsWith(filename)).map(async (entry) => {
654
- const file = this._directory.getOrCreateFile(entry);
655
- const { size } = await file.stat();
656
- const buffer = await file.read(0, size);
657
- return {
658
- key: this._getKeyFromFilename(entry),
659
- data: (0, import_util2.bufferToArray)(buffer)
660
- };
661
- }));
662
- }
663
- async removeRange(keyPrefix) {
664
- if (this._state !== "opened") {
665
- return void 0;
666
- }
667
- const filename = this._getFilename(keyPrefix);
668
- const entries = await this._directory.list();
669
- await Promise.all(entries.filter((entry) => entry.startsWith(filename)).map(async (entry) => {
670
- const file = this._directory.getOrCreateFile(entry);
671
- await file.destroy();
672
- }));
673
- }
674
- async close() {
675
- this._state = "closed";
676
- }
677
- _getFilename(key) {
678
- return key.map((k) => k.replaceAll("%", "%25").replaceAll("-", "%2D")).join("-");
679
- }
680
- _getKeyFromFilename(filename) {
681
- return filename.split("-").map((k) => k.replaceAll("%2D", "-").replaceAll("%25", "%"));
682
- }
683
- };
684
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/migrations.ts";
685
- var levelMigration = async ({ db, directory }) => {
686
- const isNewLevel = !await db.iterator({
687
- ...encodingOptions
688
- }).next();
689
- if (!isNewLevel) {
690
- return;
691
- }
692
- const oldStorageAdapter = directory.type === import_random_access_storage.StorageType.IDB ? new import_automerge_repo_storage_indexeddb.IndexedDBStorageAdapter(directory.path, "data") : new AutomergeStorageAdapter(directory);
693
- const chunks = await oldStorageAdapter.loadRange([]);
694
- if (chunks.length === 0) {
695
- return;
696
- }
697
- const batch = db.batch();
698
- import_log3.log.info("found chunks on old storage adapter", {
699
- chunks: chunks.length
700
- }, {
701
- F: __dxlog_file3,
702
- L: 37,
703
- S: void 0,
704
- C: (f, a) => f(...a)
705
- });
706
- for (const { key, data } of await oldStorageAdapter.loadRange([])) {
707
- data && batch.put(key, data, {
708
- ...encodingOptions
709
- });
710
- }
711
- await batch.write();
712
- };
713
606
  function _ts_decorate2(decorators, target, key, desc) {
714
607
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
715
608
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -720,31 +613,24 @@ function _ts_decorate2(decorators, target, key, desc) {
720
613
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
721
614
  return c > 3 && r && Object.defineProperty(target, key, r), r;
722
615
  }
723
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
616
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
724
617
  var AutomergeHost = class {
725
- constructor({ directory, db, indexMetadataStore }) {
618
+ constructor({ db, indexMetadataStore }) {
726
619
  this._ctx = new import_context.Context();
727
620
  this._echoNetworkAdapter = new EchoNetworkAdapter({
728
621
  getContainingSpaceForDocument: this._getContainingSpaceForDocument.bind(this)
729
622
  });
730
- this._requestedDocs = /* @__PURE__ */ new Set();
731
- this._directory = directory;
732
- this._db = db;
733
- this._indexMetadataStore = indexMetadataStore;
734
- }
735
- async open() {
736
- this._peerId = `host-${import_keys.PublicKey.random().toHex()}`;
737
- this._directory && await levelMigration({
738
- db: this._db,
739
- directory: this._directory
740
- });
741
623
  this._storage = new LevelDBStorageAdapter({
742
- db: this._db,
624
+ db,
743
625
  callbacks: {
744
626
  beforeSave: async (params) => this._beforeSave(params),
745
627
  afterSave: async () => this._afterSave()
746
628
  }
747
629
  });
630
+ this._indexMetadataStore = indexMetadataStore;
631
+ }
632
+ async open() {
633
+ this._peerId = `host-${import_keys.PublicKey.random().toHex()}`;
748
634
  await this._storage.open?.();
749
635
  this._clientNetwork = new LocalHostNetworkAdapter();
750
636
  this._repo = new import_automerge_repo.Repo({
@@ -789,21 +675,6 @@ var AutomergeHost = class {
789
675
  if (!documentId) {
790
676
  return false;
791
677
  }
792
- const doc = this._repo.handles[documentId]?.docSync();
793
- if (!doc) {
794
- const isRequested = this._requestedDocs.has(`automerge:${documentId}`);
795
- (0, import_log.log)("doc share policy check", {
796
- peerId,
797
- documentId,
798
- isRequested
799
- }, {
800
- F: __dxlog_file4,
801
- L: 156,
802
- S: this,
803
- C: (f, a) => f(...a)
804
- });
805
- return isRequested;
806
- }
807
678
  const peerMetadata = this.repo.peerMetadataByPeerId[peerId];
808
679
  if (peerMetadata?.dxos_peerSource === "EchoNetworkAdapter") {
809
680
  return this._echoNetworkAdapter.shouldAdvertize(peerId, {
@@ -883,8 +754,8 @@ var AutomergeHost = class {
883
754
  async flush({ states }) {
884
755
  await Promise.all(states?.map(async ({ heads, documentId }) => {
885
756
  (0, import_invariant.invariant)(heads, "heads are required for flush", {
886
- F: __dxlog_file4,
887
- L: 250,
757
+ F: __dxlog_file3,
758
+ L: 223,
888
759
  S: this,
889
760
  A: [
890
761
  "heads",
@@ -962,7 +833,7 @@ function _ts_decorate3(decorators, target, key, desc) {
962
833
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
963
834
  return c > 3 && r && Object.defineProperty(target, key, r), r;
964
835
  }
965
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-doc-loader.ts";
836
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-doc-loader.ts";
966
837
  var AutomergeDocumentLoaderImpl = class {
967
838
  constructor(_spaceId, _repo, _spaceKey) {
968
839
  this._spaceId = _spaceId;
@@ -984,10 +855,10 @@ var AutomergeDocumentLoaderImpl = class {
984
855
  return;
985
856
  }
986
857
  if (!spaceState.rootUrl) {
987
- import_log4.log.error("Database opened with no rootUrl", {
858
+ import_log2.log.error("Database opened with no rootUrl", {
988
859
  spaceId: this._spaceId
989
860
  }, {
990
- F: __dxlog_file5,
861
+ F: __dxlog_file4,
991
862
  L: 72,
992
863
  S: this,
993
864
  C: (f, a) => f(...a)
@@ -997,7 +868,7 @@ var AutomergeDocumentLoaderImpl = class {
997
868
  const existingDocHandle = await this._initDocHandle(ctx, spaceState.rootUrl);
998
869
  const doc = existingDocHandle.docSync();
999
870
  (0, import_invariant4.invariant)(doc, void 0, {
1000
- F: __dxlog_file5,
871
+ F: __dxlog_file4,
1001
872
  L: 77,
1002
873
  S: this,
1003
874
  A: [
@@ -1019,7 +890,7 @@ var AutomergeDocumentLoaderImpl = class {
1019
890
  const urlsToLoad = {};
1020
891
  for (const objectId of objectIds) {
1021
892
  (0, import_invariant4.invariant)(this._spaceRootDocHandle, void 0, {
1022
- F: __dxlog_file5,
893
+ F: __dxlog_file4,
1023
894
  L: 90,
1024
895
  S: this,
1025
896
  A: [
@@ -1032,7 +903,7 @@ var AutomergeDocumentLoaderImpl = class {
1032
903
  }
1033
904
  const spaceRootDoc = this._spaceRootDocHandle.docSync();
1034
905
  (0, import_invariant4.invariant)(spaceRootDoc, void 0, {
1035
- F: __dxlog_file5,
906
+ F: __dxlog_file4,
1036
907
  L: 95,
1037
908
  S: this,
1038
909
  A: [
@@ -1043,10 +914,10 @@ var AutomergeDocumentLoaderImpl = class {
1043
914
  const documentUrl = (spaceRootDoc.links ?? {})[objectId];
1044
915
  if (documentUrl == null) {
1045
916
  this._objectsPendingDocumentLoad.add(objectId);
1046
- import_log4.log.info("loading delayed until object links are initialized", {
917
+ import_log2.log.info("loading delayed until object links are initialized", {
1047
918
  objectId
1048
919
  }, {
1049
- F: __dxlog_file5,
920
+ F: __dxlog_file4,
1050
921
  L: 99,
1051
922
  S: this,
1052
923
  C: (f, a) => f(...a)
@@ -1070,7 +941,7 @@ var AutomergeDocumentLoaderImpl = class {
1070
941
  }
1071
942
  getSpaceRootDocHandle() {
1072
943
  (0, import_invariant4.invariant)(this._spaceRootDocHandle, void 0, {
1073
- F: __dxlog_file5,
944
+ F: __dxlog_file4,
1074
945
  L: 122,
1075
946
  S: this,
1076
947
  A: [
@@ -1082,7 +953,7 @@ var AutomergeDocumentLoaderImpl = class {
1082
953
  }
1083
954
  createDocumentForObject(objectId) {
1084
955
  (0, import_invariant4.invariant)(this._spaceRootDocHandle, void 0, {
1085
- F: __dxlog_file5,
956
+ F: __dxlog_file4,
1086
957
  L: 127,
1087
958
  S: this,
1088
959
  A: [
@@ -1090,7 +961,9 @@ var AutomergeDocumentLoaderImpl = class {
1090
961
  ""
1091
962
  ]
1092
963
  });
1093
- const spaceDocHandle = this._repo.create();
964
+ const spaceDocHandle = this._repo.create({
965
+ version: import_echo_protocol.SpaceDocVersion.CURRENT
966
+ });
1094
967
  this._initDocAccess(spaceDocHandle);
1095
968
  this.onObjectBoundToDocument(spaceDocHandle, objectId);
1096
969
  this._spaceRootDocHandle.change((newDoc) => {
@@ -1121,30 +994,30 @@ var AutomergeDocumentLoaderImpl = class {
1121
994
  };
1122
995
  const objectDocumentHandle = this._objectDocumentHandles.get(objectId);
1123
996
  if (objectDocumentHandle != null && objectDocumentHandle.url !== automergeUrl) {
1124
- import_log4.log.warn("object already inlined in a different document, ignoring the link", {
997
+ import_log2.log.warn("object already inlined in a different document, ignoring the link", {
1125
998
  ...logMeta,
1126
999
  actualDocumentUrl: objectDocumentHandle.url
1127
1000
  }, {
1128
- F: __dxlog_file5,
1129
- L: 157,
1001
+ F: __dxlog_file4,
1002
+ L: 159,
1130
1003
  S: this,
1131
1004
  C: (f, a) => f(...a)
1132
1005
  });
1133
1006
  continue;
1134
1007
  }
1135
1008
  if (objectDocumentHandle?.url === automergeUrl) {
1136
- import_log4.log.warn("object document was already loaded", logMeta, {
1137
- F: __dxlog_file5,
1138
- L: 164,
1009
+ import_log2.log.warn("object document was already loaded", logMeta, {
1010
+ F: __dxlog_file4,
1011
+ L: 166,
1139
1012
  S: this,
1140
1013
  C: (f, a) => f(...a)
1141
1014
  });
1142
1015
  continue;
1143
1016
  }
1144
1017
  const handle = this._repo.find(automergeUrl);
1145
- import_log4.log.debug("document loading triggered", logMeta, {
1146
- F: __dxlog_file5,
1147
- L: 168,
1018
+ import_log2.log.debug("document loading triggered", logMeta, {
1019
+ F: __dxlog_file4,
1020
+ L: 170,
1148
1021
  S: this,
1149
1022
  C: (f, a) => f(...a)
1150
1023
  });
@@ -1162,12 +1035,12 @@ var AutomergeDocumentLoaderImpl = class {
1162
1035
  break;
1163
1036
  } catch (err) {
1164
1037
  if (`${err}`.includes("Timeout")) {
1165
- import_log4.log.info("wraparound", {
1038
+ import_log2.log.info("wraparound", {
1166
1039
  id: docHandle.documentId,
1167
1040
  state: docHandle.state
1168
1041
  }, {
1169
- F: __dxlog_file5,
1170
- L: 184,
1042
+ F: __dxlog_file4,
1043
+ L: 186,
1171
1044
  S: this,
1172
1045
  C: (f, a) => f(...a)
1173
1046
  });
@@ -1207,9 +1080,9 @@ var AutomergeDocumentLoaderImpl = class {
1207
1080
  docUrl: handle.url
1208
1081
  };
1209
1082
  if (this.onObjectDocumentLoaded.listenerCount() === 0) {
1210
- import_log4.log.info("document loaded after all listeners were removed", logMeta, {
1211
- F: __dxlog_file5,
1212
- L: 220,
1083
+ import_log2.log.info("document loaded after all listeners were removed", logMeta, {
1084
+ F: __dxlog_file4,
1085
+ L: 222,
1213
1086
  S: this,
1214
1087
  C: (f, a) => f(...a)
1215
1088
  });
@@ -1217,9 +1090,9 @@ var AutomergeDocumentLoaderImpl = class {
1217
1090
  }
1218
1091
  const objectDocHandle = this._objectDocumentHandles.get(objectId);
1219
1092
  if (objectDocHandle?.url !== handle.url) {
1220
- import_log4.log.warn("object was rebound while a document was loading, discarding handle", logMeta, {
1221
- F: __dxlog_file5,
1222
- L: 225,
1093
+ import_log2.log.warn("object was rebound while a document was loading, discarding handle", logMeta, {
1094
+ F: __dxlog_file4,
1095
+ L: 227,
1223
1096
  S: this,
1224
1097
  C: (f, a) => f(...a)
1225
1098
  });
@@ -1231,14 +1104,14 @@ var AutomergeDocumentLoaderImpl = class {
1231
1104
  });
1232
1105
  } catch (err) {
1233
1106
  const shouldRetryLoading = this.onObjectDocumentLoaded.listenerCount() > 0;
1234
- import_log4.log.warn("failed to load a document", {
1107
+ import_log2.log.warn("failed to load a document", {
1235
1108
  objectId,
1236
1109
  automergeUrl: handle.url,
1237
1110
  retryLoading: shouldRetryLoading,
1238
1111
  err
1239
1112
  }, {
1240
- F: __dxlog_file5,
1241
- L: 231,
1113
+ F: __dxlog_file4,
1114
+ L: 233,
1242
1115
  S: this,
1243
1116
  C: (f, a) => f(...a)
1244
1117
  });
@@ -1256,12 +1129,12 @@ _ts_decorate3([
1256
1129
  AutomergeDocumentLoaderImpl = _ts_decorate3([
1257
1130
  import_tracing2.trace.resource()
1258
1131
  ], AutomergeDocumentLoaderImpl);
1259
- var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/mesh-echo-replicator.ts";
1132
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/mesh-echo-replicator.ts";
1260
1133
  var MeshEchoReplicator = class {
1261
1134
  constructor() {
1262
1135
  this._connections = /* @__PURE__ */ new Set();
1263
1136
  this._connectionsPerPeer = /* @__PURE__ */ new Map();
1264
- this._authorizedDevices = new import_util3.ComplexMap(import_keys2.PublicKey.hash);
1137
+ this._authorizedDevices = new import_util2.ComplexMap(import_keys2.PublicKey.hash);
1265
1138
  this._context = null;
1266
1139
  }
1267
1140
  async connect(context) {
@@ -1277,7 +1150,7 @@ var MeshEchoReplicator = class {
1277
1150
  }
1278
1151
  createExtension() {
1279
1152
  (0, import_invariant5.invariant)(this._context, void 0, {
1280
- F: __dxlog_file6,
1153
+ F: __dxlog_file5,
1281
1154
  L: 54,
1282
1155
  S: this,
1283
1156
  A: [
@@ -1288,16 +1161,16 @@ var MeshEchoReplicator = class {
1288
1161
  const connection = new MeshReplicatorConnection({
1289
1162
  ownPeerId: this._context.peerId,
1290
1163
  onRemoteConnected: async () => {
1291
- (0, import_log5.log)("onRemoteConnected", {
1164
+ (0, import_log3.log)("onRemoteConnected", {
1292
1165
  peerId: connection.peerId
1293
1166
  }, {
1294
- F: __dxlog_file6,
1167
+ F: __dxlog_file5,
1295
1168
  L: 59,
1296
1169
  S: this,
1297
1170
  C: (f, a) => f(...a)
1298
1171
  });
1299
1172
  (0, import_invariant5.invariant)(this._context, void 0, {
1300
- F: __dxlog_file6,
1173
+ F: __dxlog_file5,
1301
1174
  L: 60,
1302
1175
  S: this,
1303
1176
  A: [
@@ -1314,10 +1187,10 @@ var MeshEchoReplicator = class {
1314
1187
  }
1315
1188
  },
1316
1189
  onRemoteDisconnected: async () => {
1317
- (0, import_log5.log)("onRemoteDisconnected", {
1190
+ (0, import_log3.log)("onRemoteDisconnected", {
1318
1191
  peerId: connection.peerId
1319
1192
  }, {
1320
- F: __dxlog_file6,
1193
+ F: __dxlog_file5,
1321
1194
  L: 71,
1322
1195
  S: this,
1323
1196
  C: (f, a) => f(...a)
@@ -1328,17 +1201,17 @@ var MeshEchoReplicator = class {
1328
1201
  this._connections.delete(connection);
1329
1202
  },
1330
1203
  shouldAdvertize: async (params) => {
1331
- (0, import_log5.log)("shouldAdvertize", {
1204
+ (0, import_log3.log)("shouldAdvertize", {
1332
1205
  peerId: connection.peerId,
1333
1206
  documentId: params.documentId
1334
1207
  }, {
1335
- F: __dxlog_file6,
1208
+ F: __dxlog_file5,
1336
1209
  L: 78,
1337
1210
  S: this,
1338
1211
  C: (f, a) => f(...a)
1339
1212
  });
1340
1213
  (0, import_invariant5.invariant)(this._context, void 0, {
1341
- F: __dxlog_file6,
1214
+ F: __dxlog_file5,
1342
1215
  L: 79,
1343
1216
  S: this,
1344
1217
  A: [
@@ -1349,11 +1222,11 @@ var MeshEchoReplicator = class {
1349
1222
  try {
1350
1223
  const spaceKey = await this._context.getContainingSpaceForDocument(params.documentId);
1351
1224
  if (!spaceKey) {
1352
- (0, import_log5.log)("space key not found for share policy check", {
1225
+ (0, import_log3.log)("space key not found for share policy check", {
1353
1226
  peerId: connection.peerId,
1354
1227
  documentId: params.documentId
1355
1228
  }, {
1356
- F: __dxlog_file6,
1229
+ F: __dxlog_file5,
1357
1230
  L: 83,
1358
1231
  S: this,
1359
1232
  C: (f, a) => f(...a)
@@ -1362,11 +1235,11 @@ var MeshEchoReplicator = class {
1362
1235
  }
1363
1236
  const authorizedDevices = this._authorizedDevices.get(spaceKey);
1364
1237
  if (!connection.remoteDeviceKey) {
1365
- (0, import_log5.log)("device key not found for share policy check", {
1238
+ (0, import_log3.log)("device key not found for share policy check", {
1366
1239
  peerId: connection.peerId,
1367
1240
  documentId: params.documentId
1368
1241
  }, {
1369
- F: __dxlog_file6,
1242
+ F: __dxlog_file5,
1370
1243
  L: 93,
1371
1244
  S: this,
1372
1245
  C: (f, a) => f(...a)
@@ -1374,7 +1247,7 @@ var MeshEchoReplicator = class {
1374
1247
  return false;
1375
1248
  }
1376
1249
  const isAuthorized = authorizedDevices?.has(connection.remoteDeviceKey) ?? false;
1377
- (0, import_log5.log)("share policy check", {
1250
+ (0, import_log3.log)("share policy check", {
1378
1251
  localPeer: this._context.peerId,
1379
1252
  remotePeer: connection.peerId,
1380
1253
  documentId: params.documentId,
@@ -1382,15 +1255,15 @@ var MeshEchoReplicator = class {
1382
1255
  spaceKey,
1383
1256
  isAuthorized
1384
1257
  }, {
1385
- F: __dxlog_file6,
1258
+ F: __dxlog_file5,
1386
1259
  L: 101,
1387
1260
  S: this,
1388
1261
  C: (f, a) => f(...a)
1389
1262
  });
1390
1263
  return isAuthorized;
1391
1264
  } catch (err) {
1392
- import_log5.log.catch(err, void 0, {
1393
- F: __dxlog_file6,
1265
+ import_log3.log.catch(err, void 0, {
1266
+ F: __dxlog_file5,
1394
1267
  L: 111,
1395
1268
  S: this,
1396
1269
  C: (f, a) => f(...a)
@@ -1403,16 +1276,21 @@ var MeshEchoReplicator = class {
1403
1276
  return connection.replicatorExtension;
1404
1277
  }
1405
1278
  authorizeDevice(spaceKey, deviceKey) {
1406
- (0, import_log5.log)("authorizeDevice", {
1279
+ (0, import_log3.log)("authorizeDevice", {
1407
1280
  spaceKey,
1408
1281
  deviceKey
1409
1282
  }, {
1410
- F: __dxlog_file6,
1283
+ F: __dxlog_file5,
1411
1284
  L: 122,
1412
1285
  S: this,
1413
1286
  C: (f, a) => f(...a)
1414
1287
  });
1415
- (0, import_util3.defaultMap)(this._authorizedDevices, spaceKey, () => new import_util3.ComplexSet(import_keys2.PublicKey.hash)).add(deviceKey);
1288
+ (0, import_util2.defaultMap)(this._authorizedDevices, spaceKey, () => new import_util2.ComplexSet(import_keys2.PublicKey.hash)).add(deviceKey);
1289
+ for (const connection of this._connections) {
1290
+ if (connection.remoteDeviceKey && connection.remoteDeviceKey.equals(deviceKey)) {
1291
+ this._context?.onConnectionAuthScopeChanged(connection);
1292
+ }
1293
+ }
1416
1294
  }
1417
1295
  };
1418
1296
  var MeshReplicatorConnection = class extends import_context5.Resource {
@@ -1444,13 +1322,13 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
1444
1322
  onStartReplication: async (info, remotePeerId) => {
1445
1323
  this.remoteDeviceKey = remotePeerId;
1446
1324
  this._remotePeerId = info.id;
1447
- (0, import_log5.log)("onStartReplication", {
1325
+ (0, import_log3.log)("onStartReplication", {
1448
1326
  id: info.id,
1449
1327
  thisPeerId: this.peerId,
1450
1328
  remotePeerId: remotePeerId.toHex()
1451
1329
  }, {
1452
- F: __dxlog_file6,
1453
- L: 187,
1330
+ F: __dxlog_file5,
1331
+ L: 192,
1454
1332
  S: this,
1455
1333
  C: (f, a) => f(...a)
1456
1334
  });
@@ -1473,8 +1351,8 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
1473
1351
  }
1474
1352
  get peerId() {
1475
1353
  (0, import_invariant5.invariant)(this._remotePeerId != null, "Remote peer has not connected yet.", {
1476
- F: __dxlog_file6,
1477
- L: 210,
1354
+ F: __dxlog_file5,
1355
+ L: 215,
1478
1356
  S: this,
1479
1357
  A: [
1480
1358
  "this._remotePeerId != null",
@@ -1492,8 +1370,8 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
1492
1370
  */
1493
1371
  async enable() {
1494
1372
  (0, import_invariant5.invariant)(this._remotePeerId != null, "Remote peer has not connected yet.", {
1495
- F: __dxlog_file6,
1496
- L: 223,
1373
+ F: __dxlog_file5,
1374
+ L: 228,
1497
1375
  S: this,
1498
1376
  A: [
1499
1377
  "this._remotePeerId != null",
@@ -1515,7 +1393,6 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
1515
1393
  AuthStatus,
1516
1394
  AutomergeDocumentLoaderImpl,
1517
1395
  AutomergeHost,
1518
- AutomergeStorageAdapter,
1519
1396
  DataServiceImpl,
1520
1397
  LevelDBStorageAdapter,
1521
1398
  LocalHostNetworkAdapter,