@dxos/echo-pipeline 0.5.9-main.b8d8fee → 0.5.9-main.bd9c8b3

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 (27) 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.ts +4 -2
  15. package/src/automerge/automerge-host.ts +8 -35
  16. package/src/automerge/index.ts +0 -1
  17. package/src/automerge/mesh-echo-replicator.ts +5 -0
  18. package/src/automerge/storage-adapter.test.ts +103 -139
  19. package/dist/types/src/automerge/automerge-storage-adapter.d.ts +0 -16
  20. package/dist/types/src/automerge/automerge-storage-adapter.d.ts.map +0 -1
  21. package/dist/types/src/automerge/automerge-storage/342/200/223wrapper.d.ts +0 -25
  22. package/dist/types/src/automerge/automerge-storage/342/200/223wrapper.d.ts.map +0 -1
  23. package/dist/types/src/automerge/migrations.d.ts +0 -7
  24. package/dist/types/src/automerge/migrations.d.ts.map +0 -1
  25. package/src/automerge/automerge-storage-adapter.ts +0 -103
  26. package/src/automerge/automerge-storage/342/200/223wrapper.ts +0 -59
  27. package/src/automerge/migrations.ts +0 -42
@@ -32,7 +32,6 @@ import { Repo } from "@dxos/automerge/automerge-repo";
32
32
  import { Context } from "@dxos/context";
33
33
  import { invariant as invariant3 } from "@dxos/invariant";
34
34
  import { PublicKey } from "@dxos/keys";
35
- import { log as log3 } from "@dxos/log";
36
35
  import { objectPointerCodec } from "@dxos/protocols";
37
36
  import { trace } from "@dxos/tracing";
38
37
  import { mapValues } from "@dxos/util";
@@ -573,118 +572,6 @@ var LocalHostNetworkAdapter = class extends NetworkAdapter2 {
573
572
  }
574
573
  };
575
574
 
576
- // packages/core/echo/echo-pipeline/src/automerge/migrations.ts
577
- import { IndexedDBStorageAdapter } from "@dxos/automerge/automerge-repo-storage-indexeddb";
578
- import { log as log2 } from "@dxos/log";
579
- import { StorageType } from "@dxos/random-access-storage";
580
-
581
- // packages/core/echo/echo-pipeline/src/automerge/automerge-storage-adapter.ts
582
- import { arrayToBuffer, bufferToArray } from "@dxos/util";
583
- var AutomergeStorageAdapter = class {
584
- constructor(_directory) {
585
- this._directory = _directory;
586
- this._state = "opened";
587
- }
588
- async load(key) {
589
- if (this._state !== "opened") {
590
- return void 0;
591
- }
592
- const filename = this._getFilename(key);
593
- const file = this._directory.getOrCreateFile(filename);
594
- const { size } = await file.stat();
595
- if (!size || size === 0) {
596
- return void 0;
597
- }
598
- const buffer = await file.read(0, size);
599
- return bufferToArray(buffer);
600
- }
601
- async save(key, data) {
602
- if (this._state !== "opened") {
603
- return void 0;
604
- }
605
- const filename = this._getFilename(key);
606
- const file = this._directory.getOrCreateFile(filename);
607
- await file.write(0, arrayToBuffer(data));
608
- await file.truncate?.(data.length);
609
- await file.flush?.();
610
- }
611
- async remove(key) {
612
- if (this._state !== "opened") {
613
- return void 0;
614
- }
615
- const filename = this._getFilename(key);
616
- const file = this._directory.getOrCreateFile(filename);
617
- await file.destroy();
618
- }
619
- async loadRange(keyPrefix) {
620
- if (this._state !== "opened") {
621
- return [];
622
- }
623
- const filename = this._getFilename(keyPrefix);
624
- const entries = await this._directory.list();
625
- return Promise.all(entries.filter((entry) => entry.startsWith(filename)).map(async (entry) => {
626
- const file = this._directory.getOrCreateFile(entry);
627
- const { size } = await file.stat();
628
- const buffer = await file.read(0, size);
629
- return {
630
- key: this._getKeyFromFilename(entry),
631
- data: bufferToArray(buffer)
632
- };
633
- }));
634
- }
635
- async removeRange(keyPrefix) {
636
- if (this._state !== "opened") {
637
- return void 0;
638
- }
639
- const filename = this._getFilename(keyPrefix);
640
- const entries = await this._directory.list();
641
- await Promise.all(entries.filter((entry) => entry.startsWith(filename)).map(async (entry) => {
642
- const file = this._directory.getOrCreateFile(entry);
643
- await file.destroy();
644
- }));
645
- }
646
- async close() {
647
- this._state = "closed";
648
- }
649
- _getFilename(key) {
650
- return key.map((k) => k.replaceAll("%", "%25").replaceAll("-", "%2D")).join("-");
651
- }
652
- _getKeyFromFilename(filename) {
653
- return filename.split("-").map((k) => k.replaceAll("%2D", "-").replaceAll("%25", "%"));
654
- }
655
- };
656
-
657
- // packages/core/echo/echo-pipeline/src/automerge/migrations.ts
658
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/migrations.ts";
659
- var levelMigration = async ({ db, directory }) => {
660
- const isNewLevel = !await db.iterator({
661
- ...encodingOptions
662
- }).next();
663
- if (!isNewLevel) {
664
- return;
665
- }
666
- const oldStorageAdapter = directory.type === StorageType.IDB ? new IndexedDBStorageAdapter(directory.path, "data") : new AutomergeStorageAdapter(directory);
667
- const chunks = await oldStorageAdapter.loadRange([]);
668
- if (chunks.length === 0) {
669
- return;
670
- }
671
- const batch = db.batch();
672
- log2.info("found chunks on old storage adapter", {
673
- chunks: chunks.length
674
- }, {
675
- F: __dxlog_file3,
676
- L: 37,
677
- S: void 0,
678
- C: (f, a) => f(...a)
679
- });
680
- for (const { key, data } of await oldStorageAdapter.loadRange([])) {
681
- data && batch.put(key, data, {
682
- ...encodingOptions
683
- });
684
- }
685
- await batch.write();
686
- };
687
-
688
575
  // packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts
689
576
  function _ts_decorate2(decorators, target, key, desc) {
690
577
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -696,31 +583,24 @@ function _ts_decorate2(decorators, target, key, desc) {
696
583
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
697
584
  return c > 3 && r && Object.defineProperty(target, key, r), r;
698
585
  }
699
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
586
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
700
587
  var AutomergeHost = class {
701
- constructor({ directory, db, indexMetadataStore }) {
588
+ constructor({ db, indexMetadataStore }) {
702
589
  this._ctx = new Context();
703
590
  this._echoNetworkAdapter = new EchoNetworkAdapter({
704
591
  getContainingSpaceForDocument: this._getContainingSpaceForDocument.bind(this)
705
592
  });
706
- this._requestedDocs = /* @__PURE__ */ new Set();
707
- this._directory = directory;
708
- this._db = db;
709
- this._indexMetadataStore = indexMetadataStore;
710
- }
711
- async open() {
712
- this._peerId = `host-${PublicKey.random().toHex()}`;
713
- this._directory && await levelMigration({
714
- db: this._db,
715
- directory: this._directory
716
- });
717
593
  this._storage = new LevelDBStorageAdapter({
718
- db: this._db,
594
+ db,
719
595
  callbacks: {
720
596
  beforeSave: async (params) => this._beforeSave(params),
721
597
  afterSave: async () => this._afterSave()
722
598
  }
723
599
  });
600
+ this._indexMetadataStore = indexMetadataStore;
601
+ }
602
+ async open() {
603
+ this._peerId = `host-${PublicKey.random().toHex()}`;
724
604
  await this._storage.open?.();
725
605
  this._clientNetwork = new LocalHostNetworkAdapter();
726
606
  this._repo = new Repo({
@@ -765,21 +645,6 @@ var AutomergeHost = class {
765
645
  if (!documentId) {
766
646
  return false;
767
647
  }
768
- const doc = this._repo.handles[documentId]?.docSync();
769
- if (!doc) {
770
- const isRequested = this._requestedDocs.has(`automerge:${documentId}`);
771
- log3("doc share policy check", {
772
- peerId,
773
- documentId,
774
- isRequested
775
- }, {
776
- F: __dxlog_file4,
777
- L: 156,
778
- S: this,
779
- C: (f, a) => f(...a)
780
- });
781
- return isRequested;
782
- }
783
648
  const peerMetadata = this.repo.peerMetadataByPeerId[peerId];
784
649
  if (peerMetadata?.dxos_peerSource === "EchoNetworkAdapter") {
785
650
  return this._echoNetworkAdapter.shouldAdvertize(peerId, {
@@ -859,8 +724,8 @@ var AutomergeHost = class {
859
724
  async flush({ states }) {
860
725
  await Promise.all(states?.map(async ({ heads, documentId }) => {
861
726
  invariant3(heads, "heads are required for flush", {
862
- F: __dxlog_file4,
863
- L: 250,
727
+ F: __dxlog_file3,
728
+ L: 223,
864
729
  S: this,
865
730
  A: [
866
731
  "heads",
@@ -933,8 +798,9 @@ var changeIsPresentInDoc = (doc, changeHash) => {
933
798
  import { Event as Event2 } from "@dxos/async";
934
799
  import { cancelWithContext } from "@dxos/context";
935
800
  import { warnAfterTimeout } from "@dxos/debug";
801
+ import { SpaceDocVersion } from "@dxos/echo-protocol";
936
802
  import { invariant as invariant4 } from "@dxos/invariant";
937
- import { log as log4 } from "@dxos/log";
803
+ import { log as log2 } from "@dxos/log";
938
804
  import { trace as trace2 } from "@dxos/tracing";
939
805
  function _ts_decorate3(decorators, target, key, desc) {
940
806
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -946,7 +812,7 @@ function _ts_decorate3(decorators, target, key, desc) {
946
812
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
947
813
  return c > 3 && r && Object.defineProperty(target, key, r), r;
948
814
  }
949
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-doc-loader.ts";
815
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-doc-loader.ts";
950
816
  var AutomergeDocumentLoaderImpl = class {
951
817
  constructor(_spaceId, _repo, _spaceKey) {
952
818
  this._spaceId = _spaceId;
@@ -968,10 +834,10 @@ var AutomergeDocumentLoaderImpl = class {
968
834
  return;
969
835
  }
970
836
  if (!spaceState.rootUrl) {
971
- log4.error("Database opened with no rootUrl", {
837
+ log2.error("Database opened with no rootUrl", {
972
838
  spaceId: this._spaceId
973
839
  }, {
974
- F: __dxlog_file5,
840
+ F: __dxlog_file4,
975
841
  L: 72,
976
842
  S: this,
977
843
  C: (f, a) => f(...a)
@@ -981,7 +847,7 @@ var AutomergeDocumentLoaderImpl = class {
981
847
  const existingDocHandle = await this._initDocHandle(ctx, spaceState.rootUrl);
982
848
  const doc = existingDocHandle.docSync();
983
849
  invariant4(doc, void 0, {
984
- F: __dxlog_file5,
850
+ F: __dxlog_file4,
985
851
  L: 77,
986
852
  S: this,
987
853
  A: [
@@ -1003,7 +869,7 @@ var AutomergeDocumentLoaderImpl = class {
1003
869
  const urlsToLoad = {};
1004
870
  for (const objectId of objectIds) {
1005
871
  invariant4(this._spaceRootDocHandle, void 0, {
1006
- F: __dxlog_file5,
872
+ F: __dxlog_file4,
1007
873
  L: 90,
1008
874
  S: this,
1009
875
  A: [
@@ -1016,7 +882,7 @@ var AutomergeDocumentLoaderImpl = class {
1016
882
  }
1017
883
  const spaceRootDoc = this._spaceRootDocHandle.docSync();
1018
884
  invariant4(spaceRootDoc, void 0, {
1019
- F: __dxlog_file5,
885
+ F: __dxlog_file4,
1020
886
  L: 95,
1021
887
  S: this,
1022
888
  A: [
@@ -1027,10 +893,10 @@ var AutomergeDocumentLoaderImpl = class {
1027
893
  const documentUrl = (spaceRootDoc.links ?? {})[objectId];
1028
894
  if (documentUrl == null) {
1029
895
  this._objectsPendingDocumentLoad.add(objectId);
1030
- log4.info("loading delayed until object links are initialized", {
896
+ log2.info("loading delayed until object links are initialized", {
1031
897
  objectId
1032
898
  }, {
1033
- F: __dxlog_file5,
899
+ F: __dxlog_file4,
1034
900
  L: 99,
1035
901
  S: this,
1036
902
  C: (f, a) => f(...a)
@@ -1054,7 +920,7 @@ var AutomergeDocumentLoaderImpl = class {
1054
920
  }
1055
921
  getSpaceRootDocHandle() {
1056
922
  invariant4(this._spaceRootDocHandle, void 0, {
1057
- F: __dxlog_file5,
923
+ F: __dxlog_file4,
1058
924
  L: 122,
1059
925
  S: this,
1060
926
  A: [
@@ -1066,7 +932,7 @@ var AutomergeDocumentLoaderImpl = class {
1066
932
  }
1067
933
  createDocumentForObject(objectId) {
1068
934
  invariant4(this._spaceRootDocHandle, void 0, {
1069
- F: __dxlog_file5,
935
+ F: __dxlog_file4,
1070
936
  L: 127,
1071
937
  S: this,
1072
938
  A: [
@@ -1074,7 +940,9 @@ var AutomergeDocumentLoaderImpl = class {
1074
940
  ""
1075
941
  ]
1076
942
  });
1077
- const spaceDocHandle = this._repo.create();
943
+ const spaceDocHandle = this._repo.create({
944
+ version: SpaceDocVersion.CURRENT
945
+ });
1078
946
  this._initDocAccess(spaceDocHandle);
1079
947
  this.onObjectBoundToDocument(spaceDocHandle, objectId);
1080
948
  this._spaceRootDocHandle.change((newDoc) => {
@@ -1105,30 +973,30 @@ var AutomergeDocumentLoaderImpl = class {
1105
973
  };
1106
974
  const objectDocumentHandle = this._objectDocumentHandles.get(objectId);
1107
975
  if (objectDocumentHandle != null && objectDocumentHandle.url !== automergeUrl) {
1108
- log4.warn("object already inlined in a different document, ignoring the link", {
976
+ log2.warn("object already inlined in a different document, ignoring the link", {
1109
977
  ...logMeta,
1110
978
  actualDocumentUrl: objectDocumentHandle.url
1111
979
  }, {
1112
- F: __dxlog_file5,
1113
- L: 157,
980
+ F: __dxlog_file4,
981
+ L: 159,
1114
982
  S: this,
1115
983
  C: (f, a) => f(...a)
1116
984
  });
1117
985
  continue;
1118
986
  }
1119
987
  if (objectDocumentHandle?.url === automergeUrl) {
1120
- log4.warn("object document was already loaded", logMeta, {
1121
- F: __dxlog_file5,
1122
- L: 164,
988
+ log2.warn("object document was already loaded", logMeta, {
989
+ F: __dxlog_file4,
990
+ L: 166,
1123
991
  S: this,
1124
992
  C: (f, a) => f(...a)
1125
993
  });
1126
994
  continue;
1127
995
  }
1128
996
  const handle = this._repo.find(automergeUrl);
1129
- log4.debug("document loading triggered", logMeta, {
1130
- F: __dxlog_file5,
1131
- L: 168,
997
+ log2.debug("document loading triggered", logMeta, {
998
+ F: __dxlog_file4,
999
+ L: 170,
1132
1000
  S: this,
1133
1001
  C: (f, a) => f(...a)
1134
1002
  });
@@ -1146,12 +1014,12 @@ var AutomergeDocumentLoaderImpl = class {
1146
1014
  break;
1147
1015
  } catch (err) {
1148
1016
  if (`${err}`.includes("Timeout")) {
1149
- log4.info("wraparound", {
1017
+ log2.info("wraparound", {
1150
1018
  id: docHandle.documentId,
1151
1019
  state: docHandle.state
1152
1020
  }, {
1153
- F: __dxlog_file5,
1154
- L: 184,
1021
+ F: __dxlog_file4,
1022
+ L: 186,
1155
1023
  S: this,
1156
1024
  C: (f, a) => f(...a)
1157
1025
  });
@@ -1191,9 +1059,9 @@ var AutomergeDocumentLoaderImpl = class {
1191
1059
  docUrl: handle.url
1192
1060
  };
1193
1061
  if (this.onObjectDocumentLoaded.listenerCount() === 0) {
1194
- log4.info("document loaded after all listeners were removed", logMeta, {
1195
- F: __dxlog_file5,
1196
- L: 220,
1062
+ log2.info("document loaded after all listeners were removed", logMeta, {
1063
+ F: __dxlog_file4,
1064
+ L: 222,
1197
1065
  S: this,
1198
1066
  C: (f, a) => f(...a)
1199
1067
  });
@@ -1201,9 +1069,9 @@ var AutomergeDocumentLoaderImpl = class {
1201
1069
  }
1202
1070
  const objectDocHandle = this._objectDocumentHandles.get(objectId);
1203
1071
  if (objectDocHandle?.url !== handle.url) {
1204
- log4.warn("object was rebound while a document was loading, discarding handle", logMeta, {
1205
- F: __dxlog_file5,
1206
- L: 225,
1072
+ log2.warn("object was rebound while a document was loading, discarding handle", logMeta, {
1073
+ F: __dxlog_file4,
1074
+ L: 227,
1207
1075
  S: this,
1208
1076
  C: (f, a) => f(...a)
1209
1077
  });
@@ -1215,14 +1083,14 @@ var AutomergeDocumentLoaderImpl = class {
1215
1083
  });
1216
1084
  } catch (err) {
1217
1085
  const shouldRetryLoading = this.onObjectDocumentLoaded.listenerCount() > 0;
1218
- log4.warn("failed to load a document", {
1086
+ log2.warn("failed to load a document", {
1219
1087
  objectId,
1220
1088
  automergeUrl: handle.url,
1221
1089
  retryLoading: shouldRetryLoading,
1222
1090
  err
1223
1091
  }, {
1224
- F: __dxlog_file5,
1225
- L: 231,
1092
+ F: __dxlog_file4,
1093
+ L: 233,
1226
1094
  S: this,
1227
1095
  C: (f, a) => f(...a)
1228
1096
  });
@@ -1246,10 +1114,10 @@ import { cbor as cbor2 } from "@dxos/automerge/automerge-repo";
1246
1114
  import { Resource as Resource2 } from "@dxos/context";
1247
1115
  import { invariant as invariant5 } from "@dxos/invariant";
1248
1116
  import { PublicKey as PublicKey2 } from "@dxos/keys";
1249
- import { log as log5 } from "@dxos/log";
1117
+ import { log as log3 } from "@dxos/log";
1250
1118
  import { AutomergeReplicator } from "@dxos/teleport-extension-automerge-replicator";
1251
1119
  import { ComplexMap, ComplexSet, defaultMap } from "@dxos/util";
1252
- var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/mesh-echo-replicator.ts";
1120
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/mesh-echo-replicator.ts";
1253
1121
  var MeshEchoReplicator = class {
1254
1122
  constructor() {
1255
1123
  this._connections = /* @__PURE__ */ new Set();
@@ -1276,7 +1144,7 @@ var MeshEchoReplicator = class {
1276
1144
  }
1277
1145
  createExtension() {
1278
1146
  invariant5(this._context, void 0, {
1279
- F: __dxlog_file6,
1147
+ F: __dxlog_file5,
1280
1148
  L: 54,
1281
1149
  S: this,
1282
1150
  A: [
@@ -1287,16 +1155,16 @@ var MeshEchoReplicator = class {
1287
1155
  const connection = new MeshReplicatorConnection({
1288
1156
  ownPeerId: this._context.peerId,
1289
1157
  onRemoteConnected: async () => {
1290
- log5("onRemoteConnected", {
1158
+ log3("onRemoteConnected", {
1291
1159
  peerId: connection.peerId
1292
1160
  }, {
1293
- F: __dxlog_file6,
1161
+ F: __dxlog_file5,
1294
1162
  L: 59,
1295
1163
  S: this,
1296
1164
  C: (f, a) => f(...a)
1297
1165
  });
1298
1166
  invariant5(this._context, void 0, {
1299
- F: __dxlog_file6,
1167
+ F: __dxlog_file5,
1300
1168
  L: 60,
1301
1169
  S: this,
1302
1170
  A: [
@@ -1313,10 +1181,10 @@ var MeshEchoReplicator = class {
1313
1181
  }
1314
1182
  },
1315
1183
  onRemoteDisconnected: async () => {
1316
- log5("onRemoteDisconnected", {
1184
+ log3("onRemoteDisconnected", {
1317
1185
  peerId: connection.peerId
1318
1186
  }, {
1319
- F: __dxlog_file6,
1187
+ F: __dxlog_file5,
1320
1188
  L: 71,
1321
1189
  S: this,
1322
1190
  C: (f, a) => f(...a)
@@ -1327,17 +1195,17 @@ var MeshEchoReplicator = class {
1327
1195
  this._connections.delete(connection);
1328
1196
  },
1329
1197
  shouldAdvertize: async (params) => {
1330
- log5("shouldAdvertize", {
1198
+ log3("shouldAdvertize", {
1331
1199
  peerId: connection.peerId,
1332
1200
  documentId: params.documentId
1333
1201
  }, {
1334
- F: __dxlog_file6,
1202
+ F: __dxlog_file5,
1335
1203
  L: 78,
1336
1204
  S: this,
1337
1205
  C: (f, a) => f(...a)
1338
1206
  });
1339
1207
  invariant5(this._context, void 0, {
1340
- F: __dxlog_file6,
1208
+ F: __dxlog_file5,
1341
1209
  L: 79,
1342
1210
  S: this,
1343
1211
  A: [
@@ -1348,11 +1216,11 @@ var MeshEchoReplicator = class {
1348
1216
  try {
1349
1217
  const spaceKey = await this._context.getContainingSpaceForDocument(params.documentId);
1350
1218
  if (!spaceKey) {
1351
- log5("space key not found for share policy check", {
1219
+ log3("space key not found for share policy check", {
1352
1220
  peerId: connection.peerId,
1353
1221
  documentId: params.documentId
1354
1222
  }, {
1355
- F: __dxlog_file6,
1223
+ F: __dxlog_file5,
1356
1224
  L: 83,
1357
1225
  S: this,
1358
1226
  C: (f, a) => f(...a)
@@ -1361,11 +1229,11 @@ var MeshEchoReplicator = class {
1361
1229
  }
1362
1230
  const authorizedDevices = this._authorizedDevices.get(spaceKey);
1363
1231
  if (!connection.remoteDeviceKey) {
1364
- log5("device key not found for share policy check", {
1232
+ log3("device key not found for share policy check", {
1365
1233
  peerId: connection.peerId,
1366
1234
  documentId: params.documentId
1367
1235
  }, {
1368
- F: __dxlog_file6,
1236
+ F: __dxlog_file5,
1369
1237
  L: 93,
1370
1238
  S: this,
1371
1239
  C: (f, a) => f(...a)
@@ -1373,7 +1241,7 @@ var MeshEchoReplicator = class {
1373
1241
  return false;
1374
1242
  }
1375
1243
  const isAuthorized = authorizedDevices?.has(connection.remoteDeviceKey) ?? false;
1376
- log5("share policy check", {
1244
+ log3("share policy check", {
1377
1245
  localPeer: this._context.peerId,
1378
1246
  remotePeer: connection.peerId,
1379
1247
  documentId: params.documentId,
@@ -1381,15 +1249,15 @@ var MeshEchoReplicator = class {
1381
1249
  spaceKey,
1382
1250
  isAuthorized
1383
1251
  }, {
1384
- F: __dxlog_file6,
1252
+ F: __dxlog_file5,
1385
1253
  L: 101,
1386
1254
  S: this,
1387
1255
  C: (f, a) => f(...a)
1388
1256
  });
1389
1257
  return isAuthorized;
1390
1258
  } catch (err) {
1391
- log5.catch(err, void 0, {
1392
- F: __dxlog_file6,
1259
+ log3.catch(err, void 0, {
1260
+ F: __dxlog_file5,
1393
1261
  L: 111,
1394
1262
  S: this,
1395
1263
  C: (f, a) => f(...a)
@@ -1402,16 +1270,21 @@ var MeshEchoReplicator = class {
1402
1270
  return connection.replicatorExtension;
1403
1271
  }
1404
1272
  authorizeDevice(spaceKey, deviceKey) {
1405
- log5("authorizeDevice", {
1273
+ log3("authorizeDevice", {
1406
1274
  spaceKey,
1407
1275
  deviceKey
1408
1276
  }, {
1409
- F: __dxlog_file6,
1277
+ F: __dxlog_file5,
1410
1278
  L: 122,
1411
1279
  S: this,
1412
1280
  C: (f, a) => f(...a)
1413
1281
  });
1414
1282
  defaultMap(this._authorizedDevices, spaceKey, () => new ComplexSet(PublicKey2.hash)).add(deviceKey);
1283
+ for (const connection of this._connections) {
1284
+ if (connection.remoteDeviceKey && connection.remoteDeviceKey.equals(deviceKey)) {
1285
+ this._context?.onConnectionAuthScopeChanged(connection);
1286
+ }
1287
+ }
1415
1288
  }
1416
1289
  };
1417
1290
  var MeshReplicatorConnection = class extends Resource2 {
@@ -1443,13 +1316,13 @@ var MeshReplicatorConnection = class extends Resource2 {
1443
1316
  onStartReplication: async (info, remotePeerId) => {
1444
1317
  this.remoteDeviceKey = remotePeerId;
1445
1318
  this._remotePeerId = info.id;
1446
- log5("onStartReplication", {
1319
+ log3("onStartReplication", {
1447
1320
  id: info.id,
1448
1321
  thisPeerId: this.peerId,
1449
1322
  remotePeerId: remotePeerId.toHex()
1450
1323
  }, {
1451
- F: __dxlog_file6,
1452
- L: 187,
1324
+ F: __dxlog_file5,
1325
+ L: 192,
1453
1326
  S: this,
1454
1327
  C: (f, a) => f(...a)
1455
1328
  });
@@ -1472,8 +1345,8 @@ var MeshReplicatorConnection = class extends Resource2 {
1472
1345
  }
1473
1346
  get peerId() {
1474
1347
  invariant5(this._remotePeerId != null, "Remote peer has not connected yet.", {
1475
- F: __dxlog_file6,
1476
- L: 210,
1348
+ F: __dxlog_file5,
1349
+ L: 215,
1477
1350
  S: this,
1478
1351
  A: [
1479
1352
  "this._remotePeerId != null",
@@ -1491,8 +1364,8 @@ var MeshReplicatorConnection = class extends Resource2 {
1491
1364
  */
1492
1365
  async enable() {
1493
1366
  invariant5(this._remotePeerId != null, "Remote peer has not connected yet.", {
1494
- F: __dxlog_file6,
1495
- L: 223,
1367
+ F: __dxlog_file5,
1368
+ L: 228,
1496
1369
  S: this,
1497
1370
  A: [
1498
1371
  "this._remotePeerId != null",
@@ -1513,7 +1386,6 @@ export {
1513
1386
  AuthStatus,
1514
1387
  AutomergeDocumentLoaderImpl,
1515
1388
  AutomergeHost,
1516
- AutomergeStorageAdapter,
1517
1389
  DataServiceImpl,
1518
1390
  LevelDBStorageAdapter,
1519
1391
  LocalHostNetworkAdapter,