@dxos/client-services 0.8.2-staging.7ac8446 → 0.8.2

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 (134) hide show
  1. package/dist/lib/browser/{chunk-2TKMQ2UP.mjs → chunk-IFPYIR2N.mjs} +535 -551
  2. package/dist/lib/browser/chunk-IFPYIR2N.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +1 -1
  4. package/dist/lib/browser/index.mjs.map +3 -3
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +1 -1
  7. package/dist/lib/browser/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/{chunk-HUMVSL5Y.cjs → chunk-VC4EAGT6.cjs} +704 -709
  9. package/dist/lib/node/chunk-VC4EAGT6.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +47 -47
  11. package/dist/lib/node/index.cjs.map +3 -3
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/testing/index.cjs +8 -8
  14. package/dist/lib/node/testing/index.cjs.map +3 -3
  15. package/dist/lib/node-esm/{chunk-DQCPFIVI.mjs → chunk-SV2U4CXT.mjs} +535 -540
  16. package/dist/lib/node-esm/chunk-SV2U4CXT.mjs.map +7 -0
  17. package/dist/lib/node-esm/index.mjs +1 -1
  18. package/dist/lib/node-esm/index.mjs.map +3 -3
  19. package/dist/lib/node-esm/meta.json +1 -1
  20. package/dist/lib/node-esm/testing/index.mjs +1 -1
  21. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  22. package/dist/types/src/packlets/agents/edge-agent-manager.d.ts.map +1 -1
  23. package/dist/types/src/packlets/agents/edge-agent-service.d.ts +1 -1
  24. package/dist/types/src/packlets/agents/edge-agent-service.d.ts.map +1 -1
  25. package/dist/types/src/packlets/devices/devices-service.d.ts.map +1 -1
  26. package/dist/types/src/packlets/devtools/feeds.d.ts.map +1 -1
  27. package/dist/types/src/packlets/devtools/keys.d.ts.map +1 -1
  28. package/dist/types/src/packlets/devtools/metadata.d.ts.map +1 -1
  29. package/dist/types/src/packlets/devtools/network.d.ts.map +1 -1
  30. package/dist/types/src/packlets/devtools/spaces.d.ts.map +1 -1
  31. package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts.map +1 -1
  32. package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts.map +1 -1
  33. package/dist/types/src/packlets/diagnostics/diagnostics.d.ts.map +1 -1
  34. package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
  35. package/dist/types/src/packlets/identity/default-space-state-machine.d.ts.map +1 -1
  36. package/dist/types/src/packlets/identity/identity-manager.d.ts +2 -2
  37. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  38. package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +1 -1
  39. package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -1
  40. package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
  41. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  42. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
  43. package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts.map +1 -1
  44. package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts.map +1 -1
  45. package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts.map +1 -1
  46. package/dist/types/src/packlets/invitations/invitation-state.d.ts.map +1 -1
  47. package/dist/types/src/packlets/invitations/invitation-topology.d.ts.map +1 -1
  48. package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -1
  49. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +1 -1
  50. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
  51. package/dist/types/src/packlets/invitations/utils.d.ts.map +1 -1
  52. package/dist/types/src/packlets/locks/browser.d.ts.map +1 -1
  53. package/dist/types/src/packlets/locks/node.d.ts.map +1 -1
  54. package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
  55. package/dist/types/src/packlets/network/network-service.d.ts +3 -1
  56. package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
  57. package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
  58. package/dist/types/src/packlets/services/service-context.d.ts +1 -0
  59. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  60. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  61. package/dist/types/src/packlets/services/service-registry.d.ts.map +1 -1
  62. package/dist/types/src/packlets/services/util.d.ts.map +1 -1
  63. package/dist/types/src/packlets/space-export/space-archive-reader.d.ts +1 -1
  64. package/dist/types/src/packlets/space-export/space-archive-reader.d.ts.map +1 -1
  65. package/dist/types/src/packlets/space-export/space-archive-writer.d.ts.map +1 -1
  66. package/dist/types/src/packlets/spaces/automerge-space-state.d.ts.map +1 -1
  67. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +1 -1
  68. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  69. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  70. package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts.map +1 -1
  71. package/dist/types/src/packlets/spaces/epoch-migrations.d.ts.map +1 -1
  72. package/dist/types/src/packlets/spaces/genesis.d.ts.map +1 -1
  73. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
  74. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  75. package/dist/types/src/packlets/storage/level.d.ts.map +1 -1
  76. package/dist/types/src/packlets/storage/profile-archive.d.ts.map +1 -1
  77. package/dist/types/src/packlets/storage/storage.d.ts.map +1 -1
  78. package/dist/types/src/packlets/storage/util.d.ts.map +1 -1
  79. package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
  80. package/dist/types/src/packlets/testing/credential-utils.d.ts.map +1 -1
  81. package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
  82. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  83. package/dist/types/src/packlets/worker/worker-runtime.d.ts.map +1 -1
  84. package/dist/types/src/packlets/worker/worker-session.d.ts.map +1 -1
  85. package/dist/types/src/version.d.ts +1 -1
  86. package/dist/types/src/version.d.ts.map +1 -1
  87. package/dist/types/tsconfig.tsbuildinfo +1 -1
  88. package/package.json +39 -38
  89. package/src/packlets/agents/edge-agent-manager.ts +6 -6
  90. package/src/packlets/agents/edge-agent-service.ts +8 -11
  91. package/src/packlets/devices/devices-service.ts +5 -3
  92. package/src/packlets/identity/authenticator.ts +2 -2
  93. package/src/packlets/identity/default-space-state-machine.ts +1 -1
  94. package/src/packlets/identity/identity-manager.ts +13 -9
  95. package/src/packlets/identity/identity-recovery-manager.ts +6 -4
  96. package/src/packlets/identity/identity-service.ts +4 -4
  97. package/src/packlets/identity/identity.test.ts +9 -6
  98. package/src/packlets/identity/identity.ts +5 -5
  99. package/src/packlets/invitations/device-invitation-protocol.ts +1 -1
  100. package/src/packlets/invitations/edge-invitation-handler.ts +3 -3
  101. package/src/packlets/invitations/invitation-guest-extenstion.ts +3 -3
  102. package/src/packlets/invitations/invitation-host-extension.ts +5 -5
  103. package/src/packlets/invitations/invitation-topology.ts +1 -1
  104. package/src/packlets/invitations/invitations-handler.ts +2 -2
  105. package/src/packlets/invitations/invitations-manager.ts +15 -4
  106. package/src/packlets/invitations/space-invitation-protocol.ts +1 -1
  107. package/src/packlets/locks/browser.ts +4 -4
  108. package/src/packlets/locks/node.ts +2 -2
  109. package/src/packlets/logging/logging-service.ts +2 -2
  110. package/src/packlets/network/network-service.ts +11 -17
  111. package/src/packlets/services/client-rpc-server.ts +2 -2
  112. package/src/packlets/services/service-context.ts +10 -6
  113. package/src/packlets/services/service-host.ts +13 -5
  114. package/src/packlets/services/service-registry.ts +3 -3
  115. package/src/packlets/space-export/space-archive-reader.ts +2 -1
  116. package/src/packlets/space-export/space-archive-writer.ts +3 -3
  117. package/src/packlets/spaces/automerge-space-state.ts +3 -3
  118. package/src/packlets/spaces/data-space-manager.ts +47 -41
  119. package/src/packlets/spaces/data-space.ts +27 -20
  120. package/src/packlets/spaces/edge-feed-replicator.test.ts +2 -1
  121. package/src/packlets/spaces/edge-feed-replicator.ts +14 -13
  122. package/src/packlets/spaces/epoch-migrations.ts +3 -2
  123. package/src/packlets/spaces/notarization-plugin.test.ts +1 -1
  124. package/src/packlets/spaces/notarization-plugin.ts +18 -18
  125. package/src/packlets/spaces/spaces-service.ts +7 -6
  126. package/src/packlets/storage/profile-archive.ts +2 -1
  127. package/src/packlets/system/system-service.ts +2 -2
  128. package/src/packlets/testing/test-builder.ts +3 -3
  129. package/src/packlets/worker/worker-runtime.ts +4 -4
  130. package/src/packlets/worker/worker-session.ts +3 -3
  131. package/src/version.ts +5 -1
  132. package/dist/lib/browser/chunk-2TKMQ2UP.mjs.map +0 -7
  133. package/dist/lib/node/chunk-HUMVSL5Y.cjs.map +0 -7
  134. package/dist/lib/node-esm/chunk-DQCPFIVI.mjs.map +0 -7
@@ -397,7 +397,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
397
397
  import { TRACE_PROCESSOR } from "@dxos/tracing";
398
398
 
399
399
  // packages/sdk/client-services/src/version.ts
400
- var DXOS_VERSION = "0.8.2-staging.7ac8446";
400
+ var DXOS_VERSION = "0.8.2";
401
401
 
402
402
  // packages/sdk/client-services/src/packlets/services/platform.ts
403
403
  import { Platform } from "@dxos/protocols/proto/dxos/client/services";
@@ -739,6 +739,7 @@ import { log as log3, logInfo } from "@dxos/log";
739
739
  import { EdgeService } from "@dxos/protocols";
740
740
  import { buf } from "@dxos/protocols/buf";
741
741
  import { MessageSchema as RouterMessageSchema } from "@dxos/protocols/buf/dxos/edge/messenger_pb";
742
+ import { EdgeStatus } from "@dxos/protocols/proto/dxos/client/services";
742
743
  import { ComplexMap as ComplexMap2, arrayToBuffer, bufferToArray, defaultMap, rangeFromTo } from "@dxos/util";
743
744
  function _ts_decorate(decorators, target, key, desc) {
744
745
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -746,67 +747,70 @@ function _ts_decorate(decorators, target, key, desc) {
746
747
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
747
748
  return c > 3 && r && Object.defineProperty(target, key, r), r;
748
749
  }
749
- function _using_ctx() {
750
- var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
751
- var err = new Error();
752
- err.name = "SuppressedError";
753
- err.suppressed = suppressed;
754
- err.error = error;
755
- return err;
756
- }, empty = {}, stack = [];
757
- function using(isAwait, value) {
758
- if (value != null) {
759
- if (Object(value) !== value) {
760
- throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
761
- }
762
- if (isAwait) {
763
- var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
764
- }
765
- if (dispose == null) {
766
- dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
767
- }
768
- if (typeof dispose !== "function") {
769
- throw new TypeError(`Property [Symbol.dispose] is not a function.`);
770
- }
771
- stack.push({
772
- v: value,
773
- d: dispose,
774
- a: isAwait
775
- });
776
- } else if (isAwait) {
777
- stack.push({
778
- d: value,
779
- a: isAwait
780
- });
781
- }
782
- return value;
750
+ function _ts_add_disposable_resource(env, value, async) {
751
+ if (value !== null && value !== void 0) {
752
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
753
+ var dispose, inner;
754
+ if (async) {
755
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
756
+ dispose = value[Symbol.asyncDispose];
757
+ }
758
+ if (dispose === void 0) {
759
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
760
+ dispose = value[Symbol.dispose];
761
+ if (async) inner = dispose;
762
+ }
763
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
764
+ if (inner) dispose = function() {
765
+ try {
766
+ inner.call(this);
767
+ } catch (e) {
768
+ return Promise.reject(e);
769
+ }
770
+ };
771
+ env.stack.push({
772
+ value,
773
+ dispose,
774
+ async
775
+ });
776
+ } else if (async) {
777
+ env.stack.push({
778
+ async: true
779
+ });
783
780
  }
784
- return {
785
- e: empty,
786
- u: using.bind(null, false),
787
- a: using.bind(null, true),
788
- d: function() {
789
- var error = this.e;
790
- function next() {
791
- while (resource = stack.pop()) {
792
- try {
793
- var resource, disposalResult = resource.d && resource.d.call(resource.v);
794
- if (resource.a) {
795
- return Promise.resolve(disposalResult).then(next, err);
796
- }
797
- } catch (e) {
798
- return err(e);
799
- }
781
+ return value;
782
+ }
783
+ function _ts_dispose_resources(env) {
784
+ var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
785
+ var e = new Error(message);
786
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
787
+ };
788
+ return (_ts_dispose_resources = function _ts_dispose_resources5(env2) {
789
+ function fail(e) {
790
+ env2.error = env2.hasError ? new _SuppressedError(e, env2.error, "An error was suppressed during disposal.") : e;
791
+ env2.hasError = true;
792
+ }
793
+ var r, s = 0;
794
+ function next() {
795
+ while (r = env2.stack.pop()) {
796
+ try {
797
+ if (!r.async && s === 1) return s = 0, env2.stack.push(r), Promise.resolve().then(next);
798
+ if (r.dispose) {
799
+ var result = r.dispose.call(r.value);
800
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) {
801
+ fail(e);
802
+ return next();
803
+ });
804
+ } else s |= 1;
805
+ } catch (e) {
806
+ fail(e);
800
807
  }
801
- if (error !== empty) throw error;
802
808
  }
803
- function err(e) {
804
- error = error !== empty ? new _disposeSuppressedError(error, e) : e;
805
- return next();
806
- }
807
- return next();
809
+ if (s === 1) return env2.hasError ? Promise.reject(env2.error) : Promise.resolve();
810
+ if (env2.hasError) throw env2.error;
808
811
  }
809
- };
812
+ return next();
813
+ })(env);
810
814
  }
811
815
  var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/edge-feed-replicator.ts";
812
816
  var EdgeFeedReplicator = class extends Resource {
@@ -829,7 +833,7 @@ var EdgeFeedReplicator = class extends Resource {
829
833
  async _open() {
830
834
  log3("open", void 0, {
831
835
  F: __dxlog_file5,
832
- L: 56,
836
+ L: 57,
833
837
  S: this,
834
838
  C: (f, a) => f(...a)
835
839
  });
@@ -848,7 +852,7 @@ var EdgeFeedReplicator = class extends Resource {
848
852
  _spaceId: this._spaceId
849
853
  }, {
850
854
  F: __dxlog_file5,
851
- L: 70,
855
+ L: 71,
852
856
  S: this,
853
857
  C: (f, a) => f(...a)
854
858
  });
@@ -861,7 +865,7 @@ var EdgeFeedReplicator = class extends Resource {
861
865
  type: payload.type
862
866
  }, {
863
867
  F: __dxlog_file5,
864
- L: 75,
868
+ L: 76,
865
869
  S: this,
866
870
  C: (f, a) => f(...a)
867
871
  });
@@ -873,14 +877,14 @@ var EdgeFeedReplicator = class extends Resource {
873
877
  }
874
878
  async _handleReconnect() {
875
879
  await this._resetConnection();
876
- if (this._messenger.isConnected) {
880
+ if (this._messenger.status === EdgeStatus.CONNECTED) {
877
881
  this._startReplication();
878
882
  }
879
883
  }
880
884
  async _close() {
881
885
  log3("close", void 0, {
882
886
  F: __dxlog_file5,
883
- L: 95,
887
+ L: 96,
884
888
  S: this,
885
889
  C: (f, a) => f(...a)
886
890
  });
@@ -892,7 +896,7 @@ var EdgeFeedReplicator = class extends Resource {
892
896
  this._connectionCtx = connectionCtx;
893
897
  log3("connection context created", void 0, {
894
898
  F: __dxlog_file5,
895
- L: 103,
899
+ L: 104,
896
900
  S: this,
897
901
  C: (f, a) => f(...a)
898
902
  });
@@ -905,7 +909,7 @@ var EdgeFeedReplicator = class extends Resource {
905
909
  async _resetConnection() {
906
910
  log3("resetConnection", void 0, {
907
911
  F: __dxlog_file5,
908
- L: 112,
912
+ L: 113,
909
913
  S: this,
910
914
  C: (f, a) => f(...a)
911
915
  });
@@ -921,7 +925,7 @@ var EdgeFeedReplicator = class extends Resource {
921
925
  hasConnectionCtx: !!this._connectionCtx
922
926
  }, {
923
927
  F: __dxlog_file5,
924
- L: 120,
928
+ L: 121,
925
929
  S: this,
926
930
  C: (f, a) => f(...a)
927
931
  });
@@ -938,7 +942,7 @@ var EdgeFeedReplicator = class extends Resource {
938
942
  key: feed.key
939
943
  }, {
940
944
  F: __dxlog_file5,
941
- L: 133,
945
+ L: 134,
942
946
  S: this,
943
947
  C: (f, a) => f(...a)
944
948
  });
@@ -954,7 +958,7 @@ var EdgeFeedReplicator = class extends Resource {
954
958
  if (!this._connectionCtx) {
955
959
  log3("message dropped because connection was disposed", void 0, {
956
960
  F: __dxlog_file5,
957
- L: 146,
961
+ L: 147,
958
962
  S: this,
959
963
  C: (f, a) => f(...a)
960
964
  });
@@ -966,14 +970,14 @@ var EdgeFeedReplicator = class extends Resource {
966
970
  blocks: message.blocks.map((b) => b.index)
967
971
  }, {
968
972
  F: __dxlog_file5,
969
- L: 151,
973
+ L: 152,
970
974
  S: this,
971
975
  C: (f, a) => f(...a)
972
976
  });
973
977
  }
974
978
  invariant2(message.feedKey, void 0, {
975
979
  F: __dxlog_file5,
976
- L: 157,
980
+ L: 158,
977
981
  S: this,
978
982
  A: [
979
983
  "message.feedKey",
@@ -985,7 +989,7 @@ var EdgeFeedReplicator = class extends Resource {
985
989
  type: message.type
986
990
  }, {
987
991
  F: __dxlog_file5,
988
- L: 160,
992
+ L: 161,
989
993
  S: this,
990
994
  C: (f, a) => f(...a)
991
995
  });
@@ -1004,7 +1008,7 @@ var EdgeFeedReplicator = class extends Resource {
1004
1008
  if (!this._connectionCtx) {
1005
1009
  log3.warn("received message after connection context was disposed", void 0, {
1006
1010
  F: __dxlog_file5,
1007
- L: 175,
1011
+ L: 176,
1008
1012
  S: this,
1009
1013
  C: (f, a) => f(...a)
1010
1014
  });
@@ -1013,8 +1017,12 @@ var EdgeFeedReplicator = class extends Resource {
1013
1017
  scheduleMicroTask(this._connectionCtx, async () => {
1014
1018
  switch (message.type) {
1015
1019
  case "metadata": {
1020
+ const env = {
1021
+ stack: [],
1022
+ error: void 0,
1023
+ hasError: false
1024
+ };
1016
1025
  try {
1017
- var _usingCtx = _using_ctx();
1018
1026
  const feedKey = PublicKey3.fromHex(message.feedKey);
1019
1027
  const feed = this._feeds.get(feedKey);
1020
1028
  if (!feed) {
@@ -1022,13 +1030,13 @@ var EdgeFeedReplicator = class extends Resource {
1022
1030
  feedKey
1023
1031
  }, {
1024
1032
  F: __dxlog_file5,
1025
- L: 184,
1033
+ L: 185,
1026
1034
  S: this,
1027
1035
  C: (f, a) => f(...a)
1028
1036
  });
1029
1037
  return;
1030
1038
  }
1031
- const _guard = _usingCtx.u(await this._getPushMutex(feed.key).acquire());
1039
+ const _guard = _ts_add_disposable_resource(env, await this._getPushMutex(feed.key).acquire(), false);
1032
1040
  this._remoteLength.set(feedKey, message.length);
1033
1041
  const logMeta = {
1034
1042
  localLength: feed.length,
@@ -1038,7 +1046,7 @@ var EdgeFeedReplicator = class extends Resource {
1038
1046
  if (message.length > feed.length) {
1039
1047
  log3("requesting missing blocks", logMeta, {
1040
1048
  F: __dxlog_file5,
1041
- L: 194,
1049
+ L: 195,
1042
1050
  S: this,
1043
1051
  C: (f, a) => f(...a)
1044
1052
  });
@@ -1053,17 +1061,18 @@ var EdgeFeedReplicator = class extends Resource {
1053
1061
  } else if (message.length < feed.length) {
1054
1062
  log3("pushing blocks to remote", logMeta, {
1055
1063
  F: __dxlog_file5,
1056
- L: 202,
1064
+ L: 203,
1057
1065
  S: this,
1058
1066
  C: (f, a) => f(...a)
1059
1067
  });
1060
1068
  await this._pushBlocks(feed, message.length, feed.length);
1061
1069
  }
1062
1070
  break;
1063
- } catch (_) {
1064
- _usingCtx.e = _;
1071
+ } catch (e) {
1072
+ env.error = e;
1073
+ env.hasError = true;
1065
1074
  } finally {
1066
- _usingCtx.d();
1075
+ _ts_dispose_resources(env);
1067
1076
  }
1068
1077
  }
1069
1078
  case "data": {
@@ -1072,7 +1081,7 @@ var EdgeFeedReplicator = class extends Resource {
1072
1081
  blocks: message.blocks.map((b) => b.index)
1073
1082
  }, {
1074
1083
  F: __dxlog_file5,
1075
- L: 211,
1084
+ L: 212,
1076
1085
  S: this,
1077
1086
  C: (f, a) => f(...a)
1078
1087
  });
@@ -1083,7 +1092,7 @@ var EdgeFeedReplicator = class extends Resource {
1083
1092
  feedKey
1084
1093
  }, {
1085
1094
  F: __dxlog_file5,
1086
- L: 216,
1095
+ L: 217,
1087
1096
  S: this,
1088
1097
  C: (f, a) => f(...a)
1089
1098
  });
@@ -1097,7 +1106,7 @@ var EdgeFeedReplicator = class extends Resource {
1097
1106
  ...message
1098
1107
  }, {
1099
1108
  F: __dxlog_file5,
1100
- L: 225,
1109
+ L: 226,
1101
1110
  S: this,
1102
1111
  C: (f, a) => f(...a)
1103
1112
  });
@@ -1112,7 +1121,7 @@ var EdgeFeedReplicator = class extends Resource {
1112
1121
  to
1113
1122
  }, {
1114
1123
  F: __dxlog_file5,
1115
- L: 232,
1124
+ L: 233,
1116
1125
  S: this,
1117
1126
  C: (f, a) => f(...a)
1118
1127
  });
@@ -1122,7 +1131,7 @@ var EdgeFeedReplicator = class extends Resource {
1122
1131
  });
1123
1132
  invariant2(data instanceof Uint8Array, void 0, {
1124
1133
  F: __dxlog_file5,
1125
- L: 237,
1134
+ L: 238,
1126
1135
  S: this,
1127
1136
  A: [
1128
1137
  "data instanceof Uint8Array",
@@ -1150,7 +1159,7 @@ var EdgeFeedReplicator = class extends Resource {
1150
1159
  blocks: blocks.length
1151
1160
  }, {
1152
1161
  F: __dxlog_file5,
1153
- L: 258,
1162
+ L: 259,
1154
1163
  S: this,
1155
1164
  C: (f, a) => f(...a)
1156
1165
  });
@@ -1166,13 +1175,17 @@ var EdgeFeedReplicator = class extends Resource {
1166
1175
  }
1167
1176
  }
1168
1177
  async _pushBlocksIfNeeded(feed) {
1178
+ const env = {
1179
+ stack: [],
1180
+ error: void 0,
1181
+ hasError: false
1182
+ };
1169
1183
  try {
1170
- var _usingCtx = _using_ctx();
1171
- const _ = _usingCtx.u(await this._getPushMutex(feed.key).acquire());
1184
+ const _ = _ts_add_disposable_resource(env, await this._getPushMutex(feed.key).acquire(), false);
1172
1185
  if (!this._remoteLength.has(feed.key)) {
1173
1186
  log3("blocks not pushed because remote length is unknown", void 0, {
1174
1187
  F: __dxlog_file5,
1175
- L: 279,
1188
+ L: 280,
1176
1189
  S: this,
1177
1190
  C: (f, a) => f(...a)
1178
1191
  });
@@ -1182,10 +1195,11 @@ var EdgeFeedReplicator = class extends Resource {
1182
1195
  if (remoteLength < feed.length) {
1183
1196
  await this._pushBlocks(feed, remoteLength, feed.length);
1184
1197
  }
1185
- } catch (_) {
1186
- _usingCtx.e = _;
1198
+ } catch (e) {
1199
+ env.error = e;
1200
+ env.hasError = true;
1187
1201
  } finally {
1188
- _usingCtx.d();
1202
+ _ts_dispose_resources(env);
1189
1203
  }
1190
1204
  }
1191
1205
  _createConnectionContext() {
@@ -1197,7 +1211,7 @@ var EdgeFeedReplicator = class extends Resource {
1197
1211
  if (err instanceof EdgeIdentityChangedError || err instanceof EdgeConnectionClosedError) {
1198
1212
  log3("resetting on reconnect", void 0, {
1199
1213
  F: __dxlog_file5,
1200
- L: 296,
1214
+ L: 297,
1201
1215
  S: this,
1202
1216
  C: (f, a) => f(...a)
1203
1217
  });
@@ -1208,7 +1222,7 @@ var EdgeFeedReplicator = class extends Resource {
1208
1222
  }
1209
1223
  }, {
1210
1224
  F: __dxlog_file5,
1211
- L: 290
1225
+ L: 291
1212
1226
  });
1213
1227
  return connectionCtx;
1214
1228
  }
@@ -1228,12 +1242,12 @@ var bufferizeBlock = (block) => ({
1228
1242
  });
1229
1243
 
1230
1244
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
1245
+ import { save } from "@automerge/automerge";
1231
1246
  import { Event as Event7, Mutex as Mutex2, scheduleTask as scheduleTask4, sleep as sleep3, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
1232
- import { save } from "@dxos/automerge/automerge";
1233
1247
  import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
1234
1248
  import { Context as Context6, ContextDisposedError, cancelWithContext as cancelWithContext2 } from "@dxos/context";
1235
1249
  import { timed, warnAfterTimeout } from "@dxos/debug";
1236
- import { createMappedFeedWriter } from "@dxos/echo-pipeline";
1250
+ import { createMappedFeedWriter, FIND_PARAMS as FIND_PARAMS2 } from "@dxos/echo-pipeline";
1237
1251
  import { SpaceDocVersion as SpaceDocVersion2 } from "@dxos/echo-protocol";
1238
1252
  import { failedInvariant as failedInvariant3, invariant as invariant11 } from "@dxos/invariant";
1239
1253
  import { PublicKey as PublicKey8 } from "@dxos/keys";
@@ -1251,12 +1265,7 @@ import { Resource as Resource2 } from "@dxos/context";
1251
1265
  import { checkCredentialType } from "@dxos/credentials";
1252
1266
  var AutomergeSpaceState = class extends Resource2 {
1253
1267
  constructor(_onNewRoot) {
1254
- super();
1255
- this._onNewRoot = _onNewRoot;
1256
- this.rootUrl = void 0;
1257
- this.lastEpoch = void 0;
1258
- this.onNewEpoch = new Event2();
1259
- this._isProcessingRootDocs = false;
1268
+ super(), this._onNewRoot = _onNewRoot, this.rootUrl = void 0, this.lastEpoch = void 0, this.onNewEpoch = new Event2(), this._isProcessingRootDocs = false;
1260
1269
  }
1261
1270
  async _open(ctx) {
1262
1271
  }
@@ -1311,7 +1320,7 @@ var runEpochMigration = async (ctx, context) => {
1311
1320
  const rootHandle = await context.echoHost.loadDoc(ctx, context.currentRoot, {
1312
1321
  timeout: LOAD_DOC_TIMEOUT
1313
1322
  });
1314
- const newRoot = context.echoHost.createDoc(rootHandle.docSync());
1323
+ const newRoot = context.echoHost.createDoc(rootHandle.doc());
1315
1324
  await context.echoHost.flush();
1316
1325
  return {
1317
1326
  newRoot: newRoot.url
@@ -1327,7 +1336,7 @@ var runEpochMigration = async (ctx, context) => {
1327
1336
  case CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT: {
1328
1337
  invariant3(context.newAutomergeRoot, void 0, {
1329
1338
  F: __dxlog_file6,
1330
- L: 62,
1339
+ L: 63,
1331
1340
  S: void 0,
1332
1341
  A: [
1333
1342
  "context.newAutomergeRoot",
@@ -1774,8 +1783,7 @@ var NotarizationTeleportExtension = class extends RpcExtension {
1774
1783
  exposed: {
1775
1784
  NotarizationService: schema2.getService("dxos.mesh.teleport.notarization.NotarizationService")
1776
1785
  }
1777
- });
1778
- this._params = _params;
1786
+ }), this._params = _params;
1779
1787
  }
1780
1788
  async getHandlers() {
1781
1789
  return {
@@ -1856,14 +1864,14 @@ var DefaultSpaceStateMachine = class {
1856
1864
  };
1857
1865
 
1858
1866
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
1867
+ import { interpretAsDocumentId } from "@automerge/automerge-repo";
1859
1868
  import { Event as Event4, synchronized, trackLeaks } from "@dxos/async";
1860
- import { interpretAsDocumentId } from "@dxos/automerge/automerge-repo";
1861
1869
  import { PropertiesType, TYPE_PROPERTIES } from "@dxos/client-protocol";
1862
1870
  import { Context as Context4, LifecycleState, Resource as Resource4, cancelWithContext } from "@dxos/context";
1863
1871
  import { createAdmissionCredentials, getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
1864
- import { DatabaseRoot, findInlineObjectOfType, AuthStatus, CredentialServerExtension } from "@dxos/echo-pipeline";
1872
+ import { DatabaseRoot, findInlineObjectOfType, AuthStatus, CredentialServerExtension, FIND_PARAMS } from "@dxos/echo-pipeline";
1865
1873
  import { SpaceDocVersion, createIdFromSpaceKey, encodeReference } from "@dxos/echo-protocol";
1866
- import { createObjectId, getTypeReference } from "@dxos/echo-schema";
1874
+ import { ObjectId, getTypeReference } from "@dxos/echo-schema";
1867
1875
  import { writeMessages } from "@dxos/feed-store";
1868
1876
  import { assertArgument, assertState, failedInvariant, invariant as invariant5 } from "@dxos/invariant";
1869
1877
  import { PublicKey as PublicKey5 } from "@dxos/keys";
@@ -1986,10 +1994,11 @@ var DataSpaceManager = class extends Resource4 {
1986
1994
  id: "spaces",
1987
1995
  name: "Spaces",
1988
1996
  fetch: async () => {
1989
- return Array.from(this._spaces.values()).map((space) => {
1997
+ return Promise.all(Array.from(this._spaces.values()).map(async (space) => {
1990
1998
  const rootUrl = space.automergeSpaceState.rootUrl;
1991
- const rootHandle = rootUrl ? this._echoHost.automergeRepo.find(rootUrl) : void 0;
1992
- const rootDoc = rootHandle?.docSync();
1999
+ const rootHandle = rootUrl ? await this._echoHost.automergeRepo.find(rootUrl, FIND_PARAMS) : void 0;
2000
+ await rootHandle?.whenReady();
2001
+ const rootDoc = rootHandle?.doc();
1993
2002
  const properties = rootDoc && findInlineObjectOfType(rootDoc, TYPE_PROPERTIES);
1994
2003
  return {
1995
2004
  key: space.key.toHex(),
@@ -2001,7 +2010,7 @@ var DataSpaceManager = class extends Resource4 {
2001
2010
  members: space.inner.spaceState.members.size,
2002
2011
  rootUrl
2003
2012
  };
2004
- });
2013
+ }));
2005
2014
  }
2006
2015
  });
2007
2016
  }
@@ -2017,7 +2026,7 @@ var DataSpaceManager = class extends Resource4 {
2017
2026
  async _open() {
2018
2027
  log6("open", void 0, {
2019
2028
  F: __dxlog_file9,
2020
- L: 213,
2029
+ L: 215,
2021
2030
  S: this,
2022
2031
  C: (f, a) => f(...a)
2023
2032
  });
@@ -2025,7 +2034,7 @@ var DataSpaceManager = class extends Resource4 {
2025
2034
  id: this._instanceId
2026
2035
  }), {
2027
2036
  F: __dxlog_file9,
2028
- L: 214,
2037
+ L: 216,
2029
2038
  S: this,
2030
2039
  C: (f, a) => f(...a)
2031
2040
  });
@@ -2033,7 +2042,7 @@ var DataSpaceManager = class extends Resource4 {
2033
2042
  spaces: this._metadataStore.spaces.length
2034
2043
  }, {
2035
2044
  F: __dxlog_file9,
2036
- L: 215,
2045
+ L: 217,
2037
2046
  S: this,
2038
2047
  C: (f, a) => f(...a)
2039
2048
  });
@@ -2043,7 +2052,7 @@ var DataSpaceManager = class extends Resource4 {
2043
2052
  spaceMetadata
2044
2053
  }, {
2045
2054
  F: __dxlog_file9,
2046
- L: 219,
2055
+ L: 221,
2047
2056
  S: this,
2048
2057
  C: (f, a) => f(...a)
2049
2058
  });
@@ -2054,7 +2063,7 @@ var DataSpaceManager = class extends Resource4 {
2054
2063
  err
2055
2064
  }, {
2056
2065
  F: __dxlog_file9,
2057
- L: 222,
2066
+ L: 224,
2058
2067
  S: this,
2059
2068
  C: (f, a) => f(...a)
2060
2069
  });
@@ -2065,7 +2074,7 @@ var DataSpaceManager = class extends Resource4 {
2065
2074
  id: this._instanceId
2066
2075
  }), {
2067
2076
  F: __dxlog_file9,
2068
- L: 228,
2077
+ L: 230,
2069
2078
  S: this,
2070
2079
  C: (f, a) => f(...a)
2071
2080
  });
@@ -2073,7 +2082,7 @@ var DataSpaceManager = class extends Resource4 {
2073
2082
  async _close() {
2074
2083
  log6("close", void 0, {
2075
2084
  F: __dxlog_file9,
2076
- L: 233,
2085
+ L: 235,
2077
2086
  S: this,
2078
2087
  C: (f, a) => f(...a)
2079
2088
  });
@@ -2104,7 +2113,7 @@ var DataSpaceManager = class extends Resource4 {
2104
2113
  spaceKey
2105
2114
  }, {
2106
2115
  F: __dxlog_file9,
2107
- L: 262,
2116
+ L: 264,
2108
2117
  S: this,
2109
2118
  C: (f, a) => f(...a)
2110
2119
  });
@@ -2112,7 +2121,7 @@ var DataSpaceManager = class extends Resource4 {
2112
2121
  if (options.documents) {
2113
2122
  invariant5(Object.keys(options.documents).every((documentId) => /^[a-zA-Z0-9]+$/.test(documentId)), "Invalid document IDs", {
2114
2123
  F: __dxlog_file9,
2115
- L: 267,
2124
+ L: 269,
2116
2125
  S: this,
2117
2126
  A: [
2118
2127
  "Object.keys(options.documents).every((documentId) => /^[a-zA-Z0-9]+$/.test(documentId))",
@@ -2124,7 +2133,7 @@ var DataSpaceManager = class extends Resource4 {
2124
2133
  documentId
2125
2134
  }, {
2126
2135
  F: __dxlog_file9,
2127
- L: 274,
2136
+ L: 276,
2128
2137
  S: this,
2129
2138
  C: (f, a) => f(...a)
2130
2139
  });
@@ -2138,7 +2147,7 @@ var DataSpaceManager = class extends Resource4 {
2138
2147
  spaceKey
2139
2148
  }, {
2140
2149
  F: __dxlog_file9,
2141
- L: 281,
2150
+ L: 283,
2142
2151
  S: this,
2143
2152
  C: (f, a) => f(...a)
2144
2153
  });
@@ -2147,7 +2156,7 @@ var DataSpaceManager = class extends Resource4 {
2147
2156
  const newRootDocId = documentIdMapping[interpretAsDocumentId(options.rootUrl)] ?? failedInvariant();
2148
2157
  const rootDocHandle = await this._echoHost.loadDoc(Context4.default(void 0, {
2149
2158
  F: __dxlog_file9,
2150
- L: 286
2159
+ L: 288
2151
2160
  }), newRootDocId);
2152
2161
  DatabaseRoot.mapLinks(rootDocHandle, documentIdMapping);
2153
2162
  root = await this._echoHost.openSpaceRoot(spaceId, `automerge:${newRootDocId}`);
@@ -2158,7 +2167,7 @@ var DataSpaceManager = class extends Resource4 {
2158
2167
  spaceKey
2159
2168
  }, {
2160
2169
  F: __dxlog_file9,
2161
- L: 294,
2170
+ L: 296,
2162
2171
  S: this,
2163
2172
  C: (f, a) => f(...a)
2164
2173
  });
@@ -2168,7 +2177,7 @@ var DataSpaceManager = class extends Resource4 {
2168
2177
  spaceKey
2169
2178
  }, {
2170
2179
  F: __dxlog_file9,
2171
- L: 299,
2180
+ L: 301,
2172
2181
  S: this,
2173
2182
  C: (f, a) => f(...a)
2174
2183
  });
@@ -2177,7 +2186,7 @@ var DataSpaceManager = class extends Resource4 {
2177
2186
  const memberCredential = credentials[1];
2178
2187
  invariant5(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2179
2188
  F: __dxlog_file9,
2180
- L: 305,
2189
+ L: 307,
2181
2190
  S: this,
2182
2191
  A: [
2183
2192
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2191,7 +2200,7 @@ var DataSpaceManager = class extends Resource4 {
2191
2200
  spaceKey
2192
2201
  }, {
2193
2202
  F: __dxlog_file9,
2194
- L: 310,
2203
+ L: 312,
2195
2204
  S: this,
2196
2205
  C: (f, a) => f(...a)
2197
2206
  });
@@ -2204,7 +2213,18 @@ var DataSpaceManager = class extends Resource4 {
2204
2213
  }
2205
2214
  switch (space.databaseRoot.getVersion()) {
2206
2215
  case SpaceDocVersion.CURRENT: {
2207
- const [_, properties] = findInlineObjectOfType(space.databaseRoot.docSync(), TYPE_PROPERTIES) ?? [];
2216
+ if (!space.databaseRoot.handle.isReady()) {
2217
+ log6.warn("waiting for space root to be ready", {
2218
+ spaceId: space.id
2219
+ }, {
2220
+ F: __dxlog_file9,
2221
+ L: 325,
2222
+ S: this,
2223
+ C: (f, a) => f(...a)
2224
+ });
2225
+ await space.databaseRoot.handle.whenReady();
2226
+ }
2227
+ const [_, properties] = findInlineObjectOfType(space.databaseRoot.doc(), TYPE_PROPERTIES) ?? [];
2208
2228
  return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
2209
2229
  }
2210
2230
  case SpaceDocVersion.LEGACY: {
@@ -2216,7 +2236,7 @@ var DataSpaceManager = class extends Resource4 {
2216
2236
  spaceId: space.id
2217
2237
  }, {
2218
2238
  F: __dxlog_file9,
2219
- L: 330,
2239
+ L: 336,
2220
2240
  S: this,
2221
2241
  C: (f, a) => f(...a)
2222
2242
  });
@@ -2237,7 +2257,7 @@ var DataSpaceManager = class extends Resource4 {
2237
2257
  keys: []
2238
2258
  }
2239
2259
  };
2240
- const propertiesId = createObjectId();
2260
+ const propertiesId = ObjectId.random();
2241
2261
  document.change((doc) => {
2242
2262
  setDeep(doc, [
2243
2263
  "objects",
@@ -2251,14 +2271,14 @@ var DataSpaceManager = class extends Resource4 {
2251
2271
  const automergeIndex = space.automergeSpaceState.rootUrl;
2252
2272
  invariant5(automergeIndex, void 0, {
2253
2273
  F: __dxlog_file9,
2254
- L: 363,
2274
+ L: 369,
2255
2275
  S: this,
2256
2276
  A: [
2257
2277
  "automergeIndex",
2258
2278
  ""
2259
2279
  ]
2260
2280
  });
2261
- const document = this._echoHost.automergeRepo.find(automergeIndex);
2281
+ const document = await this._echoHost.automergeRepo.find(automergeIndex, FIND_PARAMS);
2262
2282
  await document.whenReady();
2263
2283
  return document;
2264
2284
  }
@@ -2268,13 +2288,13 @@ var DataSpaceManager = class extends Resource4 {
2268
2288
  opts
2269
2289
  }, {
2270
2290
  F: __dxlog_file9,
2271
- L: 372,
2291
+ L: 378,
2272
2292
  S: this,
2273
2293
  C: (f, a) => f(...a)
2274
2294
  });
2275
2295
  invariant5(this._lifecycleState === LifecycleState.OPEN, "Not open.", {
2276
2296
  F: __dxlog_file9,
2277
- L: 373,
2297
+ L: 379,
2278
2298
  S: this,
2279
2299
  A: [
2280
2300
  "this._lifecycleState === LifecycleState.OPEN",
@@ -2283,7 +2303,7 @@ var DataSpaceManager = class extends Resource4 {
2283
2303
  });
2284
2304
  invariant5(!this._spaces.has(opts.spaceKey), "Space already exists.", {
2285
2305
  F: __dxlog_file9,
2286
- L: 374,
2306
+ L: 380,
2287
2307
  S: this,
2288
2308
  A: [
2289
2309
  "!this._spaces.has(opts.spaceKey)",
@@ -2307,7 +2327,7 @@ var DataSpaceManager = class extends Resource4 {
2307
2327
  const space = this._spaceManager.spaces.get(options.spaceKey);
2308
2328
  invariant5(space, void 0, {
2309
2329
  F: __dxlog_file9,
2310
- L: 394,
2330
+ L: 400,
2311
2331
  S: this,
2312
2332
  A: [
2313
2333
  "space",
@@ -2320,7 +2340,7 @@ var DataSpaceManager = class extends Resource4 {
2320
2340
  const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
2321
2341
  invariant5(credentials[0].credential, void 0, {
2322
2342
  F: __dxlog_file9,
2323
- L: 413,
2343
+ L: 419,
2324
2344
  S: this,
2325
2345
  A: [
2326
2346
  "credentials[0].credential",
@@ -2330,7 +2350,7 @@ var DataSpaceManager = class extends Resource4 {
2330
2350
  const spaceMemberCredential = credentials[0].credential.credential;
2331
2351
  invariant5(getCredentialAssertion2(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2332
2352
  F: __dxlog_file9,
2333
- L: 415,
2353
+ L: 421,
2334
2354
  S: this,
2335
2355
  A: [
2336
2356
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2368,7 +2388,7 @@ var DataSpaceManager = class extends Resource4 {
2368
2388
  const space = this._spaces.get(spaceKey);
2369
2389
  invariant5(space, "Space not found.", {
2370
2390
  F: __dxlog_file9,
2371
- L: 452,
2391
+ L: 458,
2372
2392
  S: this,
2373
2393
  A: [
2374
2394
  "space",
@@ -2393,7 +2413,7 @@ var DataSpaceManager = class extends Resource4 {
2393
2413
  metadata
2394
2414
  }, {
2395
2415
  F: __dxlog_file9,
2396
- L: 471,
2416
+ L: 477,
2397
2417
  S: this,
2398
2418
  C: (f, a) => f(...a)
2399
2419
  });
@@ -2437,7 +2457,7 @@ var DataSpaceManager = class extends Resource4 {
2437
2457
  err
2438
2458
  }, {
2439
2459
  F: __dxlog_file9,
2440
- L: 513,
2460
+ L: 519,
2441
2461
  S: this,
2442
2462
  C: (f, a) => f(...a)
2443
2463
  });
@@ -2447,7 +2467,7 @@ var DataSpaceManager = class extends Resource4 {
2447
2467
  onAuthFailure: () => {
2448
2468
  log6.warn("auth failure", void 0, {
2449
2469
  F: __dxlog_file9,
2450
- L: 518,
2470
+ L: 524,
2451
2471
  S: this,
2452
2472
  C: (f, a) => f(...a)
2453
2473
  });
@@ -2480,7 +2500,7 @@ var DataSpaceManager = class extends Resource4 {
2480
2500
  space: space.key
2481
2501
  }, {
2482
2502
  F: __dxlog_file9,
2483
- L: 545,
2503
+ L: 551,
2484
2504
  S: this,
2485
2505
  C: (f, a) => f(...a)
2486
2506
  });
@@ -2491,7 +2511,7 @@ var DataSpaceManager = class extends Resource4 {
2491
2511
  open: this._lifecycleState === LifecycleState.OPEN
2492
2512
  }, {
2493
2513
  F: __dxlog_file9,
2494
- L: 548,
2514
+ L: 554,
2495
2515
  S: this,
2496
2516
  C: (f, a) => f(...a)
2497
2517
  });
@@ -2510,7 +2530,7 @@ var DataSpaceManager = class extends Resource4 {
2510
2530
  space: space.key
2511
2531
  }, {
2512
2532
  F: __dxlog_file9,
2513
- L: 556,
2533
+ L: 562,
2514
2534
  S: this,
2515
2535
  C: (f, a) => f(...a)
2516
2536
  });
@@ -2531,7 +2551,7 @@ var DataSpaceManager = class extends Resource4 {
2531
2551
  spaceId: dataSpace.id
2532
2552
  }, {
2533
2553
  F: __dxlog_file9,
2534
- L: 570,
2554
+ L: 576,
2535
2555
  S: this,
2536
2556
  C: (f, a) => f(...a)
2537
2557
  });
@@ -2561,7 +2581,7 @@ var DataSpaceManager = class extends Resource4 {
2561
2581
  space: space.key
2562
2582
  }, {
2563
2583
  F: __dxlog_file9,
2564
- L: 597,
2584
+ L: 603,
2565
2585
  S: this,
2566
2586
  C: (f, a) => f(...a)
2567
2587
  });
@@ -2594,7 +2614,7 @@ var DataSpaceManager = class extends Resource4 {
2594
2614
  closedSessions
2595
2615
  }, {
2596
2616
  F: __dxlog_file9,
2597
- L: 623,
2617
+ L: 629,
2598
2618
  S: this,
2599
2619
  C: (f, a) => f(...a)
2600
2620
  });
@@ -2609,7 +2629,7 @@ var DataSpaceManager = class extends Resource4 {
2609
2629
  peerId: peerState.peerId
2610
2630
  }, {
2611
2631
  F: __dxlog_file9,
2612
- L: 637,
2632
+ L: 643,
2613
2633
  S: this,
2614
2634
  C: (f, a) => f(...a)
2615
2635
  });
@@ -2754,7 +2774,7 @@ var extractSpaceArchive = async (archive) => {
2754
2774
  const documentId = entry2.fileName.replace(`${SpaceArchiveFileStructure2.documents}/`, "").replace(/\.bin$/, "");
2755
2775
  invariant6(!documentId.includes("/"), void 0, {
2756
2776
  F: __dxlog_file10,
2757
- L: 27,
2777
+ L: 28,
2758
2778
  S: void 0,
2759
2779
  A: [
2760
2780
  "!documentId.includes('/')",
@@ -2768,7 +2788,7 @@ var extractSpaceArchive = async (archive) => {
2768
2788
  documents
2769
2789
  }, {
2770
2790
  F: __dxlog_file10,
2771
- L: 31,
2791
+ L: 32,
2772
2792
  S: void 0,
2773
2793
  C: (f, a) => f(...a)
2774
2794
  });
@@ -2779,67 +2799,70 @@ var extractSpaceArchive = async (archive) => {
2779
2799
  };
2780
2800
 
2781
2801
  // packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
2782
- function _using_ctx2() {
2783
- var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
2784
- var err = new Error();
2785
- err.name = "SuppressedError";
2786
- err.suppressed = suppressed;
2787
- err.error = error;
2788
- return err;
2789
- }, empty = {}, stack = [];
2790
- function using(isAwait, value) {
2791
- if (value != null) {
2792
- if (Object(value) !== value) {
2793
- throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
2794
- }
2795
- if (isAwait) {
2796
- var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
2797
- }
2798
- if (dispose == null) {
2799
- dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
2800
- }
2801
- if (typeof dispose !== "function") {
2802
- throw new TypeError(`Property [Symbol.dispose] is not a function.`);
2803
- }
2804
- stack.push({
2805
- v: value,
2806
- d: dispose,
2807
- a: isAwait
2808
- });
2809
- } else if (isAwait) {
2810
- stack.push({
2811
- d: value,
2812
- a: isAwait
2813
- });
2814
- }
2815
- return value;
2802
+ function _ts_add_disposable_resource2(env, value, async) {
2803
+ if (value !== null && value !== void 0) {
2804
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
2805
+ var dispose, inner;
2806
+ if (async) {
2807
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
2808
+ dispose = value[Symbol.asyncDispose];
2809
+ }
2810
+ if (dispose === void 0) {
2811
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
2812
+ dispose = value[Symbol.dispose];
2813
+ if (async) inner = dispose;
2814
+ }
2815
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
2816
+ if (inner) dispose = function() {
2817
+ try {
2818
+ inner.call(this);
2819
+ } catch (e) {
2820
+ return Promise.reject(e);
2821
+ }
2822
+ };
2823
+ env.stack.push({
2824
+ value,
2825
+ dispose,
2826
+ async
2827
+ });
2828
+ } else if (async) {
2829
+ env.stack.push({
2830
+ async: true
2831
+ });
2816
2832
  }
2817
- return {
2818
- e: empty,
2819
- u: using.bind(null, false),
2820
- a: using.bind(null, true),
2821
- d: function() {
2822
- var error = this.e;
2823
- function next() {
2824
- while (resource = stack.pop()) {
2825
- try {
2826
- var resource, disposalResult = resource.d && resource.d.call(resource.v);
2827
- if (resource.a) {
2828
- return Promise.resolve(disposalResult).then(next, err);
2829
- }
2830
- } catch (e) {
2831
- return err(e);
2832
- }
2833
+ return value;
2834
+ }
2835
+ function _ts_dispose_resources2(env) {
2836
+ var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
2837
+ var e = new Error(message);
2838
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
2839
+ };
2840
+ return (_ts_dispose_resources2 = function _ts_dispose_resources5(env2) {
2841
+ function fail(e) {
2842
+ env2.error = env2.hasError ? new _SuppressedError(e, env2.error, "An error was suppressed during disposal.") : e;
2843
+ env2.hasError = true;
2844
+ }
2845
+ var r, s = 0;
2846
+ function next() {
2847
+ while (r = env2.stack.pop()) {
2848
+ try {
2849
+ if (!r.async && s === 1) return s = 0, env2.stack.push(r), Promise.resolve().then(next);
2850
+ if (r.dispose) {
2851
+ var result = r.dispose.call(r.value);
2852
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) {
2853
+ fail(e);
2854
+ return next();
2855
+ });
2856
+ } else s |= 1;
2857
+ } catch (e) {
2858
+ fail(e);
2833
2859
  }
2834
- if (error !== empty) throw error;
2835
- }
2836
- function err(e) {
2837
- error = error !== empty ? new _disposeSuppressedError(error, e) : e;
2838
- return next();
2839
2860
  }
2840
- return next();
2861
+ if (s === 1) return env2.hasError ? Promise.reject(env2.error) : Promise.resolve();
2862
+ if (env2.hasError) throw env2.error;
2841
2863
  }
2842
- };
2864
+ return next();
2865
+ })(env);
2843
2866
  }
2844
2867
  var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
2845
2868
  var SpacesServiceImpl = class {
@@ -2889,7 +2912,7 @@ var SpacesServiceImpl = class {
2889
2912
  const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
2890
2913
  invariant7(credentials[0].credential, void 0, {
2891
2914
  F: __dxlog_file11,
2892
- L: 118,
2915
+ L: 119,
2893
2916
  S: this,
2894
2917
  A: [
2895
2918
  "credentials[0].credential",
@@ -2899,7 +2922,7 @@ var SpacesServiceImpl = class {
2899
2922
  const spaceMemberCredential = credentials[0].credential.credential;
2900
2923
  invariant7(getCredentialAssertion3(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2901
2924
  F: __dxlog_file11,
2902
- L: 120,
2925
+ L: 121,
2903
2926
  S: this,
2904
2927
  A: [
2905
2928
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2917,7 +2940,7 @@ var SpacesServiceImpl = class {
2917
2940
  ids: spaces.map((space) => space.id)
2918
2941
  }), {
2919
2942
  F: __dxlog_file11,
2920
- L: 133,
2943
+ L: 134,
2921
2944
  S: this,
2922
2945
  C: (f, a) => f(...a)
2923
2946
  });
@@ -3009,7 +3032,7 @@ var SpacesServiceImpl = class {
3009
3032
  } else {
3010
3033
  invariant7(!credential.id, "Id on unsigned credentials is not allowed", {
3011
3034
  F: __dxlog_file11,
3012
- L: 231,
3035
+ L: 232,
3013
3036
  S: this,
3014
3037
  A: [
3015
3038
  "!credential.id",
@@ -3018,7 +3041,7 @@ var SpacesServiceImpl = class {
3018
3041
  });
3019
3042
  invariant7(this._identityManager.identity, "Identity is not available", {
3020
3043
  F: __dxlog_file11,
3021
- L: 232,
3044
+ L: 233,
3022
3045
  S: this,
3023
3046
  A: [
3024
3047
  "this._identityManager.identity",
@@ -3028,7 +3051,7 @@ var SpacesServiceImpl = class {
3028
3051
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
3029
3052
  invariant7(credential.issuer.equals(signer.getIssuer()), void 0, {
3030
3053
  F: __dxlog_file11,
3031
- L: 234,
3054
+ L: 235,
3032
3055
  S: this,
3033
3056
  A: [
3034
3057
  "credential.issuer.equals(signer.getIssuer())",
@@ -3075,9 +3098,13 @@ var SpacesServiceImpl = class {
3075
3098
  });
3076
3099
  }
3077
3100
  async exportSpace(request) {
3101
+ const env = {
3102
+ stack: [],
3103
+ error: void 0,
3104
+ hasError: false
3105
+ };
3078
3106
  try {
3079
- var _usingCtx = _using_ctx2();
3080
- const writer = _usingCtx.a(await new SpaceArchiveWriter().open());
3107
+ const writer = _ts_add_disposable_resource2(env, await new SpaceArchiveWriter().open(), true);
3081
3108
  assertArgument4(SpaceId2.isValid(request.spaceId), "Invalid space ID");
3082
3109
  const dataSpaceManager = await this._getDataSpaceManager();
3083
3110
  const space = dataSpaceManager.getSpaceById(request.spaceId) ?? raise(new Error("Space not found"));
@@ -3094,10 +3121,12 @@ var SpacesServiceImpl = class {
3094
3121
  return {
3095
3122
  archive
3096
3123
  };
3097
- } catch (_) {
3098
- _usingCtx.e = _;
3124
+ } catch (e) {
3125
+ env.error = e;
3126
+ env.hasError = true;
3099
3127
  } finally {
3100
- await _usingCtx.d();
3128
+ const result = _ts_dispose_resources2(env);
3129
+ if (result) await result;
3101
3130
  }
3102
3131
  }
3103
3132
  async importSpace(request) {
@@ -3105,7 +3134,7 @@ var SpacesServiceImpl = class {
3105
3134
  const extracted = await extractSpaceArchive(request.archive);
3106
3135
  invariant7(extracted.metadata.echo?.currentRootUrl, "Space archive does not contain a root URL", {
3107
3136
  F: __dxlog_file11,
3108
- L: 288,
3137
+ L: 289,
3109
3138
  S: this,
3110
3139
  A: [
3111
3140
  "extracted.metadata.echo?.currentRootUrl",
@@ -3125,7 +3154,7 @@ var SpacesServiceImpl = class {
3125
3154
  const assertion = getCredentialAssertion3(credential);
3126
3155
  invariant7(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
3127
3156
  F: __dxlog_file11,
3128
- L: 299,
3157
+ L: 300,
3129
3158
  S: this,
3130
3159
  A: [
3131
3160
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -3135,7 +3164,7 @@ var SpacesServiceImpl = class {
3135
3164
  const myIdentity = this._identityManager.identity;
3136
3165
  invariant7(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
3137
3166
  F: __dxlog_file11,
3138
- L: 301,
3167
+ L: 302,
3139
3168
  S: this,
3140
3169
  A: [
3141
3170
  "myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
@@ -3535,7 +3564,7 @@ var IdentityManager = class {
3535
3564
  L: 135
3536
3565
  }));
3537
3566
  }
3538
- async createIdentity({ displayName, deviceProfile } = {}) {
3567
+ async createIdentity({ profile, deviceProfile } = {}) {
3539
3568
  invariant9(!this._identity, "Identity already exists.", {
3540
3569
  F: __dxlog_file13,
3541
3570
  L: 140,
@@ -3593,10 +3622,8 @@ var IdentityManager = class {
3593
3622
  // Feed admission.
3594
3623
  await generator.createFeedAdmission(identityRecord.haloSpace.key, identityRecord.haloSpace.dataFeedKey, AdmittedFeed3.Designation.DATA)
3595
3624
  ];
3596
- if (displayName) {
3597
- credentials.push(await generator.createProfileCredential({
3598
- displayName
3599
- }));
3625
+ if (profile) {
3626
+ credentials.push(await generator.createProfileCredential(profile));
3600
3627
  }
3601
3628
  credentials.push(await generator.createDeviceAuthorization(identityRecord.deviceKey));
3602
3629
  credentials.push(await generator.createDeviceProfile({
@@ -3713,7 +3740,7 @@ var IdentityManager = class {
3713
3740
  displayName: this._identity.profileDocument?.displayName
3714
3741
  }, {
3715
3742
  F: __dxlog_file13,
3716
- L: 273,
3743
+ L: 277,
3717
3744
  S: this,
3718
3745
  C: (f, a) => f(...a)
3719
3746
  });
@@ -3727,7 +3754,7 @@ var IdentityManager = class {
3727
3754
  deviceKey: identity.deviceKey
3728
3755
  }, {
3729
3756
  F: __dxlog_file13,
3730
- L: 284,
3757
+ L: 288,
3731
3758
  S: this,
3732
3759
  C: (f, a) => f(...a)
3733
3760
  });
@@ -3738,7 +3765,7 @@ var IdentityManager = class {
3738
3765
  async updateProfile(profile) {
3739
3766
  invariant9(this._identity, "Identity not initialized.", {
3740
3767
  F: __dxlog_file13,
3741
- L: 291,
3768
+ L: 295,
3742
3769
  S: this,
3743
3770
  A: [
3744
3771
  "this._identity",
@@ -3769,7 +3796,7 @@ var IdentityManager = class {
3769
3796
  async updateDeviceProfile(profile) {
3770
3797
  invariant9(this._identity, "Identity not initialized.", {
3771
3798
  F: __dxlog_file13,
3772
- L: 308,
3799
+ L: 312,
3773
3800
  S: this,
3774
3801
  A: [
3775
3802
  "this._identity",
@@ -3805,7 +3832,7 @@ var IdentityManager = class {
3805
3832
  async _constructIdentity(identityRecord) {
3806
3833
  invariant9(!this._identity, void 0, {
3807
3834
  F: __dxlog_file13,
3808
- L: 334,
3835
+ L: 338,
3809
3836
  S: this,
3810
3837
  A: [
3811
3838
  "!this._identity",
@@ -3816,7 +3843,7 @@ var IdentityManager = class {
3816
3843
  identityRecord
3817
3844
  }, {
3818
3845
  F: __dxlog_file13,
3819
- L: 335,
3846
+ L: 339,
3820
3847
  S: this,
3821
3848
  C: (f, a) => f(...a)
3822
3849
  });
@@ -3831,7 +3858,7 @@ var IdentityManager = class {
3831
3858
  });
3832
3859
  invariant9(identityRecord.haloSpace.controlFeedKey, void 0, {
3833
3860
  F: __dxlog_file13,
3834
- L: 348,
3861
+ L: 352,
3835
3862
  S: this,
3836
3863
  A: [
3837
3864
  "identityRecord.haloSpace.controlFeedKey",
@@ -3843,7 +3870,7 @@ var IdentityManager = class {
3843
3870
  });
3844
3871
  invariant9(identityRecord.haloSpace.dataFeedKey, void 0, {
3845
3872
  F: __dxlog_file13,
3846
- L: 352,
3873
+ L: 356,
3847
3874
  S: this,
3848
3875
  A: [
3849
3876
  "identityRecord.haloSpace.dataFeedKey",
@@ -3882,7 +3909,7 @@ var IdentityManager = class {
3882
3909
  identityKey: identityRecord.identityKey
3883
3910
  }, {
3884
3911
  F: __dxlog_file13,
3885
- L: 383,
3912
+ L: 387,
3886
3913
  S: this,
3887
3914
  C: (f, a) => f(...a)
3888
3915
  });
@@ -3907,7 +3934,7 @@ var IdentityManager = class {
3907
3934
  onAuthFailure: () => {
3908
3935
  log10.warn("auth failure", void 0, {
3909
3936
  F: __dxlog_file13,
3910
- L: 408,
3937
+ L: 412,
3911
3938
  S: this,
3912
3939
  C: (f, a) => f(...a)
3913
3940
  });
@@ -3942,13 +3969,7 @@ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
3942
3969
  var DEFAULT_SPACE_SEARCH_TIMEOUT = 1e4;
3943
3970
  var IdentityServiceImpl = class extends Resource6 {
3944
3971
  constructor(_identityManager, _recoveryManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
3945
- super();
3946
- this._identityManager = _identityManager;
3947
- this._recoveryManager = _recoveryManager;
3948
- this._keyring = _keyring;
3949
- this._dataSpaceManagerProvider = _dataSpaceManagerProvider;
3950
- this._createIdentity = _createIdentity;
3951
- this._onProfileUpdate = _onProfileUpdate;
3972
+ super(), this._identityManager = _identityManager, this._recoveryManager = _recoveryManager, this._keyring = _keyring, this._dataSpaceManagerProvider = _dataSpaceManagerProvider, this._createIdentity = _createIdentity, this._onProfileUpdate = _onProfileUpdate;
3952
3973
  }
3953
3974
  async _open() {
3954
3975
  const identity = this._identityManager.identity;
@@ -3958,7 +3979,7 @@ var IdentityServiceImpl = class extends Resource6 {
3958
3979
  }
3959
3980
  async createIdentity(request) {
3960
3981
  await this._createIdentity({
3961
- displayName: request.profile?.displayName,
3982
+ profile: request.profile,
3962
3983
  deviceProfile: request.deviceProfile
3963
3984
  });
3964
3985
  const dataSpaceManager = this._dataSpaceManagerProvider();
@@ -4133,74 +4154,77 @@ function _ts_decorate6(decorators, target, key, desc) {
4133
4154
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4134
4155
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4135
4156
  }
4136
- function _using_ctx3() {
4137
- var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
4138
- var err = new Error();
4139
- err.name = "SuppressedError";
4140
- err.suppressed = suppressed;
4141
- err.error = error;
4142
- return err;
4143
- }, empty = {}, stack = [];
4144
- function using(isAwait, value) {
4145
- if (value != null) {
4146
- if (Object(value) !== value) {
4147
- throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
4148
- }
4149
- if (isAwait) {
4150
- var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
4151
- }
4152
- if (dispose == null) {
4153
- dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
4154
- }
4155
- if (typeof dispose !== "function") {
4156
- throw new TypeError(`Property [Symbol.dispose] is not a function.`);
4157
- }
4158
- stack.push({
4159
- v: value,
4160
- d: dispose,
4161
- a: isAwait
4162
- });
4163
- } else if (isAwait) {
4164
- stack.push({
4165
- d: value,
4166
- a: isAwait
4167
- });
4168
- }
4169
- return value;
4157
+ function _ts_add_disposable_resource3(env, value, async) {
4158
+ if (value !== null && value !== void 0) {
4159
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
4160
+ var dispose, inner;
4161
+ if (async) {
4162
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
4163
+ dispose = value[Symbol.asyncDispose];
4164
+ }
4165
+ if (dispose === void 0) {
4166
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
4167
+ dispose = value[Symbol.dispose];
4168
+ if (async) inner = dispose;
4169
+ }
4170
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
4171
+ if (inner) dispose = function() {
4172
+ try {
4173
+ inner.call(this);
4174
+ } catch (e) {
4175
+ return Promise.reject(e);
4176
+ }
4177
+ };
4178
+ env.stack.push({
4179
+ value,
4180
+ dispose,
4181
+ async
4182
+ });
4183
+ } else if (async) {
4184
+ env.stack.push({
4185
+ async: true
4186
+ });
4170
4187
  }
4171
- return {
4172
- e: empty,
4173
- u: using.bind(null, false),
4174
- a: using.bind(null, true),
4175
- d: function() {
4176
- var error = this.e;
4177
- function next() {
4178
- while (resource = stack.pop()) {
4179
- try {
4180
- var resource, disposalResult = resource.d && resource.d.call(resource.v);
4181
- if (resource.a) {
4182
- return Promise.resolve(disposalResult).then(next, err);
4183
- }
4184
- } catch (e) {
4185
- return err(e);
4186
- }
4188
+ return value;
4189
+ }
4190
+ function _ts_dispose_resources3(env) {
4191
+ var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
4192
+ var e = new Error(message);
4193
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
4194
+ };
4195
+ return (_ts_dispose_resources3 = function _ts_dispose_resources5(env2) {
4196
+ function fail(e) {
4197
+ env2.error = env2.hasError ? new _SuppressedError(e, env2.error, "An error was suppressed during disposal.") : e;
4198
+ env2.hasError = true;
4199
+ }
4200
+ var r, s = 0;
4201
+ function next() {
4202
+ while (r = env2.stack.pop()) {
4203
+ try {
4204
+ if (!r.async && s === 1) return s = 0, env2.stack.push(r), Promise.resolve().then(next);
4205
+ if (r.dispose) {
4206
+ var result = r.dispose.call(r.value);
4207
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) {
4208
+ fail(e);
4209
+ return next();
4210
+ });
4211
+ } else s |= 1;
4212
+ } catch (e) {
4213
+ fail(e);
4187
4214
  }
4188
- if (error !== empty) throw error;
4189
- }
4190
- function err(e) {
4191
- error = error !== empty ? new _disposeSuppressedError(error, e) : e;
4192
- return next();
4193
4215
  }
4194
- return next();
4216
+ if (s === 1) return env2.hasError ? Promise.reject(env2.error) : Promise.resolve();
4217
+ if (env2.hasError) throw env2.error;
4195
4218
  }
4196
- };
4219
+ return next();
4220
+ })(env);
4197
4221
  }
4198
4222
  var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
4199
4223
  var DataSpace = class {
4200
4224
  constructor(params) {
4201
4225
  this._ctx = new Context6(void 0, {
4202
4226
  F: __dxlog_file15,
4203
- L: 97
4227
+ L: 100
4204
4228
  });
4205
4229
  this._cache = void 0;
4206
4230
  this._edgeFeedReplicator = void 0;
@@ -4253,7 +4277,7 @@ var DataSpace = class {
4253
4277
  state: SpaceState4[this._state]
4254
4278
  }, {
4255
4279
  F: __dxlog_file15,
4256
- L: 173,
4280
+ L: 176,
4257
4281
  S: this,
4258
4282
  C: (f, a) => f(...a)
4259
4283
  });
@@ -4312,7 +4336,7 @@ var DataSpace = class {
4312
4336
  }
4313
4337
  await this._inner.open(new Context6(void 0, {
4314
4338
  F: __dxlog_file15,
4315
- L: 247
4339
+ L: 250
4316
4340
  }));
4317
4341
  await this._inner.startProtocol();
4318
4342
  await this._edgeFeedReplicator?.open();
@@ -4321,7 +4345,7 @@ var DataSpace = class {
4321
4345
  state: SpaceState4[this._state]
4322
4346
  }, {
4323
4347
  F: __dxlog_file15,
4324
- L: 253,
4348
+ L: 256,
4325
4349
  S: this,
4326
4350
  C: (f, a) => f(...a)
4327
4351
  });
@@ -4341,14 +4365,14 @@ var DataSpace = class {
4341
4365
  state: SpaceState4[this._state]
4342
4366
  }, {
4343
4367
  F: __dxlog_file15,
4344
- L: 272,
4368
+ L: 275,
4345
4369
  S: this,
4346
4370
  C: (f, a) => f(...a)
4347
4371
  });
4348
4372
  await this._ctx.dispose();
4349
4373
  this._ctx = new Context6(void 0, {
4350
4374
  F: __dxlog_file15,
4351
- L: 274
4375
+ L: 277
4352
4376
  });
4353
4377
  if (this._edgeFeedReplicator) {
4354
4378
  this.inner.protocol.feedAdded.remove(this._onFeedAdded);
@@ -4381,7 +4405,7 @@ var DataSpace = class {
4381
4405
  if (err instanceof CancelledError || err instanceof ContextDisposedError) {
4382
4406
  log12("data pipeline initialization cancelled", err, {
4383
4407
  F: __dxlog_file15,
4384
- L: 312,
4408
+ L: 315,
4385
4409
  S: this,
4386
4410
  C: (f, a) => f(...a)
4387
4411
  });
@@ -4389,7 +4413,7 @@ var DataSpace = class {
4389
4413
  }
4390
4414
  log12.error("Error initializing data pipeline", err, {
4391
4415
  F: __dxlog_file15,
4392
- L: 316,
4416
+ L: 319,
4393
4417
  S: this,
4394
4418
  C: (f, a) => f(...a)
4395
4419
  });
@@ -4398,7 +4422,7 @@ var DataSpace = class {
4398
4422
  state: SpaceState4[this._state]
4399
4423
  }, {
4400
4424
  F: __dxlog_file15,
4401
- L: 318,
4425
+ L: 321,
4402
4426
  S: this,
4403
4427
  C: (f, a) => f(...a)
4404
4428
  });
@@ -4418,13 +4442,13 @@ var DataSpace = class {
4418
4442
  state: SpaceState4[this._state]
4419
4443
  }, {
4420
4444
  F: __dxlog_file15,
4421
- L: 334,
4445
+ L: 337,
4422
4446
  S: this,
4423
4447
  C: (f, a) => f(...a)
4424
4448
  });
4425
4449
  log12("initializing control pipeline", void 0, {
4426
4450
  F: __dxlog_file15,
4427
- L: 336,
4451
+ L: 339,
4428
4452
  S: this,
4429
4453
  C: (f, a) => f(...a)
4430
4454
  });
@@ -4433,21 +4457,21 @@ var DataSpace = class {
4433
4457
  const ready = this.stateUpdate.waitForCondition(() => this._state === SpaceState4.SPACE_READY);
4434
4458
  log12("initializing automerge root", void 0, {
4435
4459
  F: __dxlog_file15,
4436
- L: 344,
4460
+ L: 347,
4437
4461
  S: this,
4438
4462
  C: (f, a) => f(...a)
4439
4463
  });
4440
4464
  this._automergeSpaceState.startProcessingRootDocs();
4441
4465
  log12("waiting for space to be ready", void 0, {
4442
4466
  F: __dxlog_file15,
4443
- L: 348,
4467
+ L: 351,
4444
4468
  S: this,
4445
4469
  C: (f, a) => f(...a)
4446
4470
  });
4447
4471
  await ready;
4448
4472
  log12("space is ready", void 0, {
4449
4473
  F: __dxlog_file15,
4450
- L: 350,
4474
+ L: 353,
4451
4475
  S: this,
4452
4476
  C: (f, a) => f(...a)
4453
4477
  });
@@ -4455,14 +4479,14 @@ var DataSpace = class {
4455
4479
  async *getAllDocuments() {
4456
4480
  invariant11(this._databaseRoot, "Space is not ready", {
4457
4481
  F: __dxlog_file15,
4458
- L: 354,
4482
+ L: 357,
4459
4483
  S: this,
4460
4484
  A: [
4461
4485
  "this._databaseRoot",
4462
4486
  "'Space is not ready'"
4463
4487
  ]
4464
4488
  });
4465
- const doc = this._databaseRoot.docSync() ?? failedInvariant3();
4489
+ const doc = this._databaseRoot.doc() ?? failedInvariant3();
4466
4490
  const root = save(doc);
4467
4491
  yield [
4468
4492
  this._databaseRoot.documentId,
@@ -4471,7 +4495,7 @@ var DataSpace = class {
4471
4495
  for (const documentUrl of this._databaseRoot.getAllLinkedDocuments()) {
4472
4496
  const data = await this._echoHost.exportDoc(Context6.default(void 0, {
4473
4497
  F: __dxlog_file15,
4474
- L: 360
4498
+ L: 363
4475
4499
  }), documentUrl);
4476
4500
  yield [
4477
4501
  documentUrl.replace(/^automerge:/, ""),
@@ -4486,7 +4510,7 @@ var DataSpace = class {
4486
4510
  state: SpaceState4[this._state]
4487
4511
  }, {
4488
4512
  F: __dxlog_file15,
4489
- L: 369,
4513
+ L: 372,
4490
4514
  S: this,
4491
4515
  C: (f, a) => f(...a)
4492
4516
  });
@@ -4503,7 +4527,7 @@ var DataSpace = class {
4503
4527
  await this._createWritableFeeds();
4504
4528
  log12("writable feeds created", void 0, {
4505
4529
  F: __dxlog_file15,
4506
- L: 386,
4530
+ L: 389,
4507
4531
  S: this,
4508
4532
  C: (f, a) => f(...a)
4509
4533
  });
@@ -4557,7 +4581,7 @@ var DataSpace = class {
4557
4581
  count: credentials.length
4558
4582
  }, {
4559
4583
  F: __dxlog_file15,
4560
- L: 444,
4584
+ L: 447,
4561
4585
  S: this,
4562
4586
  C: (f, a) => f(...a)
4563
4587
  });
@@ -4568,14 +4592,14 @@ var DataSpace = class {
4568
4592
  });
4569
4593
  log12("credentials notarized", void 0, {
4570
4594
  F: __dxlog_file15,
4571
- L: 448,
4595
+ L: 451,
4572
4596
  S: this,
4573
4597
  C: (f, a) => f(...a)
4574
4598
  });
4575
4599
  } catch (err) {
4576
4600
  log12.error("error notarizing credentials for feed admission", err, {
4577
4601
  F: __dxlog_file15,
4578
- L: 450,
4602
+ L: 453,
4579
4603
  S: this,
4580
4604
  C: (f, a) => f(...a)
4581
4605
  });
@@ -4590,26 +4614,28 @@ var DataSpace = class {
4590
4614
  rootUrl
4591
4615
  }, {
4592
4616
  F: __dxlog_file15,
4593
- L: 460,
4617
+ L: 463,
4594
4618
  S: this,
4595
4619
  C: (f, a) => f(...a)
4596
4620
  });
4597
- const handle = this._echoHost.automergeRepo.find(rootUrl);
4621
+ let handle;
4598
4622
  queueMicrotask(async () => {
4599
4623
  try {
4624
+ const env = {
4625
+ stack: [],
4626
+ error: void 0,
4627
+ hasError: false
4628
+ };
4600
4629
  try {
4601
- var _usingCtx = _using_ctx3();
4602
4630
  await warnAfterTimeout(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
4631
+ handle = await cancelWithContext2(this._ctx, this._echoHost.automergeRepo.find(rootUrl, FIND_PARAMS2));
4603
4632
  await cancelWithContext2(this._ctx, handle.whenReady());
4604
4633
  });
4605
4634
  if (this._ctx.disposed) {
4606
4635
  return;
4607
4636
  }
4608
- const _guard = (
4609
- // Ensure only one root is processed at a time.
4610
- _usingCtx.u(await this._epochProcessingMutex.acquire())
4611
- );
4612
- const doc = handle.docSync() ?? failedInvariant3();
4637
+ const _guard = _ts_add_disposable_resource3(env, await this._epochProcessingMutex.acquire(), false);
4638
+ const doc = handle.doc() ?? failedInvariant3();
4613
4639
  if (!doc.access?.spaceKey) {
4614
4640
  handle.change((doc2) => {
4615
4641
  doc2.access = {
@@ -4627,10 +4653,11 @@ var DataSpace = class {
4627
4653
  } else {
4628
4654
  this.stateUpdate.emit();
4629
4655
  }
4630
- } catch (_) {
4631
- _usingCtx.e = _;
4656
+ } catch (e) {
4657
+ env.error = e;
4658
+ env.hasError = true;
4632
4659
  } finally {
4633
- _usingCtx.d();
4660
+ _ts_dispose_resources3(env);
4634
4661
  }
4635
4662
  } catch (err) {
4636
4663
  if (err instanceof ContextDisposedError) {
@@ -4642,7 +4669,7 @@ var DataSpace = class {
4642
4669
  err
4643
4670
  }, {
4644
4671
  F: __dxlog_file15,
4645
- L: 503,
4672
+ L: 510,
4646
4673
  S: this,
4647
4674
  C: (f, a) => f(...a)
4648
4675
  });
@@ -4732,7 +4759,7 @@ var DataSpace = class {
4732
4759
  state: SpaceState4[this._state]
4733
4760
  }, {
4734
4761
  F: __dxlog_file15,
4735
- L: 585,
4762
+ L: 592,
4736
4763
  S: this,
4737
4764
  C: (f, a) => f(...a)
4738
4765
  });
@@ -5143,15 +5170,10 @@ var InvitationGuestExtension = class extends RpcExtension2 {
5143
5170
  exposed: {
5144
5171
  InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
5145
5172
  }
5146
- });
5147
- this._invitationFlowMutex = _invitationFlowMutex;
5148
- this._callbacks = _callbacks;
5149
- this._ctx = new Context7(void 0, {
5173
+ }), this._invitationFlowMutex = _invitationFlowMutex, this._callbacks = _callbacks, this._ctx = new Context7(void 0, {
5150
5174
  F: __dxlog_file18,
5151
5175
  L: 38
5152
- });
5153
- this._remoteOptionsTrigger = new Trigger4();
5154
- this._invitationFlowLock = null;
5176
+ }), this._remoteOptionsTrigger = new Trigger4(), this._invitationFlowLock = null;
5155
5177
  }
5156
5178
  hasFlowLock() {
5157
5179
  return this._invitationFlowLock != null;
@@ -5280,20 +5302,10 @@ var InvitationHostExtension = class extends RpcExtension3 {
5280
5302
  exposed: {
5281
5303
  InvitationHostService: schema5.getService("dxos.halo.invitations.InvitationHostService")
5282
5304
  }
5283
- });
5284
- this._invitationFlowMutex = _invitationFlowMutex;
5285
- this._callbacks = _callbacks;
5286
- this._ctx = new Context8(void 0, {
5305
+ }), this._invitationFlowMutex = _invitationFlowMutex, this._callbacks = _callbacks, this._ctx = new Context8(void 0, {
5287
5306
  F: __dxlog_file19,
5288
5307
  L: 57
5289
- });
5290
- this._remoteOptionsTrigger = new Trigger5();
5291
- this._challenge = void 0;
5292
- this.guestProfile = void 0;
5293
- this.authenticationPassed = false;
5294
- this.authenticationRetry = 0;
5295
- this.completedTrigger = new Trigger5();
5296
- this._invitationFlowLock = null;
5308
+ }), this._remoteOptionsTrigger = new Trigger5(), this._challenge = void 0, this.guestProfile = void 0, this.authenticationPassed = false, this.authenticationRetry = 0, this.completedTrigger = new Trigger5(), this._invitationFlowLock = null;
5297
5309
  }
5298
5310
  hasFlowLock() {
5299
5311
  return this._invitationFlowLock != null;
@@ -6997,14 +7009,14 @@ var InvitationsManager = class {
6997
7009
  }
6998
7010
  }, {
6999
7011
  F: __dxlog_file24,
7000
- L: 236
7012
+ L: 239
7001
7013
  });
7002
7014
  ctx.onDispose(() => {
7003
7015
  log20("complete", {
7004
7016
  ...handler.toJSON()
7005
7017
  }, {
7006
7018
  F: __dxlog_file24,
7007
- L: 243,
7019
+ L: 246,
7008
7020
  S: this,
7009
7021
  C: (f, a) => f(...a)
7010
7022
  });
@@ -7037,7 +7049,7 @@ var InvitationsManager = class {
7037
7049
  ...handler.toJSON()
7038
7050
  }, {
7039
7051
  F: __dxlog_file24,
7040
- L: 263,
7052
+ L: 274,
7041
7053
  S: this,
7042
7054
  C: (f, a) => f(...a)
7043
7055
  });
@@ -7048,7 +7060,7 @@ var InvitationsManager = class {
7048
7060
  } else {
7049
7061
  log20.warn("auth failed", err, {
7050
7062
  F: __dxlog_file24,
7051
- L: 266,
7063
+ L: 277,
7052
7064
  S: this,
7053
7065
  C: (f, a) => f(...a)
7054
7066
  });
@@ -7061,14 +7073,14 @@ var InvitationsManager = class {
7061
7073
  }
7062
7074
  }, {
7063
7075
  F: __dxlog_file24,
7064
- L: 260
7076
+ L: 271
7065
7077
  });
7066
7078
  ctx.onDispose(() => {
7067
7079
  log20("complete", {
7068
7080
  ...handler.toJSON()
7069
7081
  }, {
7070
7082
  F: __dxlog_file24,
7071
- L: 273,
7083
+ L: 284,
7072
7084
  S: this,
7073
7085
  C: (f, a) => f(...a)
7074
7086
  });
@@ -7113,7 +7125,7 @@ var InvitationsManager = class {
7113
7125
  } catch (err) {
7114
7126
  log20.catch(err, void 0, {
7115
7127
  F: __dxlog_file24,
7116
- L: 309,
7128
+ L: 320,
7117
7129
  S: this,
7118
7130
  C: (f, a) => f(...a)
7119
7131
  });
@@ -7279,13 +7291,7 @@ var AGENT_STATUS_QUERY_RETRY_JITTER = 1e3;
7279
7291
  var AGENT_FEED_ADDED_CHECK_INTERVAL_MS = 3e3;
7280
7292
  var EdgeAgentManager = class extends Resource7 {
7281
7293
  constructor(_edgeFeatures, _edgeHttpClient, _dataSpaceManager, _identity) {
7282
- super();
7283
- this._edgeFeatures = _edgeFeatures;
7284
- this._edgeHttpClient = _edgeHttpClient;
7285
- this._dataSpaceManager = _dataSpaceManager;
7286
- this._identity = _identity;
7287
- this.agentStatusChanged = new Event9();
7288
- this._lastKnownDeviceCount = 0;
7294
+ super(), this._edgeFeatures = _edgeFeatures, this._edgeHttpClient = _edgeHttpClient, this._dataSpaceManager = _dataSpaceManager, this._identity = _identity, this.agentStatusChanged = new Event9(), this._lastKnownDeviceCount = 0;
7289
7295
  }
7290
7296
  get agentStatus() {
7291
7297
  return this._agentStatus;
@@ -7503,28 +7509,22 @@ _ts_decorate9([
7503
7509
  // packages/sdk/client-services/src/packlets/agents/edge-agent-service.ts
7504
7510
  import { Stream as Stream11 } from "@dxos/codec-protobuf/stream";
7505
7511
  import { EdgeAgentStatus as EdgeAgentStatus2 } from "@dxos/protocols";
7506
- import { QueryAgentStatusResponse, QueryEdgeStatusResponse } from "@dxos/protocols/proto/dxos/client/services";
7512
+ import { QueryAgentStatusResponse, EdgeStatus as EdgeStatus2 } from "@dxos/protocols/proto/dxos/client/services";
7507
7513
  var EdgeAgentServiceImpl = class {
7508
7514
  constructor(_agentManagerProvider, _edgeConnection) {
7509
7515
  this._agentManagerProvider = _agentManagerProvider;
7510
7516
  this._edgeConnection = _edgeConnection;
7511
7517
  }
7518
+ // TODO(mykola): Reconcile with NetworkService.queryStatus.
7512
7519
  queryEdgeStatus() {
7513
7520
  return new Stream11(({ ctx, next }) => {
7514
- next({
7515
- status: QueryEdgeStatusResponse.EdgeStatus.NOT_CONNECTED
7516
- });
7517
- if (!this._edgeConnection) {
7518
- return;
7519
- }
7520
- ctx.onDispose(
7521
- // TODO(wittjosiah): EdgeConnection should include a disconnected event as well.
7522
- this._edgeConnection.onReconnected(() => {
7523
- next({
7524
- status: QueryEdgeStatusResponse.EdgeStatus.CONNECTED
7525
- });
7526
- })
7527
- );
7521
+ const update = () => {
7522
+ next({
7523
+ status: this._edgeConnection?.status ?? EdgeStatus2.NOT_CONNECTED
7524
+ });
7525
+ };
7526
+ this._edgeConnection?.statusChanged.on(ctx, update);
7527
+ update();
7528
7528
  });
7529
7529
  }
7530
7530
  async createAgent() {
@@ -7600,7 +7600,7 @@ var EdgeIdentityRecoveryManager = class {
7600
7600
  const identity = this._identityProvider();
7601
7601
  invariant22(identity, void 0, {
7602
7602
  F: __dxlog_file27,
7603
- L: 37,
7603
+ L: 39,
7604
7604
  S: this,
7605
7605
  A: [
7606
7606
  "identity",
@@ -7651,7 +7651,7 @@ var EdgeIdentityRecoveryManager = class {
7651
7651
  async requestRecoveryChallenge() {
7652
7652
  invariant22(this._edgeClient, "Not connected to EDGE.", {
7653
7653
  F: __dxlog_file27,
7654
- L: 74,
7654
+ L: 76,
7655
7655
  S: this,
7656
7656
  A: [
7657
7657
  "this._edgeClient",
@@ -7681,7 +7681,7 @@ var EdgeIdentityRecoveryManager = class {
7681
7681
  async recoverIdentityWithExternalSignature({ lookupKey, deviceKey, controlFeedKey, signature, clientDataJson, authenticatorData }) {
7682
7682
  invariant22(this._edgeClient, "Not connected to EDGE.", {
7683
7683
  F: __dxlog_file27,
7684
- L: 106,
7684
+ L: 108,
7685
7685
  S: this,
7686
7686
  A: [
7687
7687
  "this._edgeClient",
@@ -7715,7 +7715,7 @@ var EdgeIdentityRecoveryManager = class {
7715
7715
  async recoverIdentityWithToken({ token }) {
7716
7716
  invariant22(this._edgeClient, "Not connected to EDGE.", {
7717
7717
  F: __dxlog_file27,
7718
- L: 139,
7718
+ L: 141,
7719
7719
  S: this,
7720
7720
  A: [
7721
7721
  "this._edgeClient",
@@ -7743,7 +7743,7 @@ var EdgeIdentityRecoveryManager = class {
7743
7743
  async recoverIdentity({ recoveryCode }) {
7744
7744
  invariant22(this._edgeClient, "Not connected to EDGE.", {
7745
7745
  F: __dxlog_file27,
7746
- L: 163,
7746
+ L: 165,
7747
7747
  S: this,
7748
7748
  A: [
7749
7749
  "this._edgeClient",
@@ -7774,7 +7774,7 @@ var EdgeIdentityRecoveryManager = class {
7774
7774
  }
7775
7775
  log23.info("recovering identity", response, {
7776
7776
  F: __dxlog_file27,
7777
- L: 189,
7777
+ L: 191,
7778
7778
  S: this,
7779
7779
  C: (f, a) => f(...a)
7780
7780
  });
@@ -7802,86 +7802,75 @@ function _ts_decorate10(decorators, target, key, desc) {
7802
7802
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
7803
7803
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7804
7804
  }
7805
- function _using_ctx4() {
7806
- var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
7807
- var err = new Error();
7808
- err.name = "SuppressedError";
7809
- err.suppressed = suppressed;
7810
- err.error = error;
7811
- return err;
7812
- }, empty = {}, stack = [];
7813
- function using(isAwait, value) {
7814
- if (value != null) {
7815
- if (Object(value) !== value) {
7816
- throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
7817
- }
7818
- if (isAwait) {
7819
- var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
7820
- }
7821
- if (dispose == null) {
7822
- dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
7823
- }
7824
- if (typeof dispose !== "function") {
7825
- throw new TypeError(`Property [Symbol.dispose] is not a function.`);
7826
- }
7827
- stack.push({
7828
- v: value,
7829
- d: dispose,
7830
- a: isAwait
7831
- });
7832
- } else if (isAwait) {
7833
- stack.push({
7834
- d: value,
7835
- a: isAwait
7836
- });
7837
- }
7838
- return value;
7805
+ function _ts_add_disposable_resource4(env, value, async) {
7806
+ if (value !== null && value !== void 0) {
7807
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
7808
+ var dispose, inner;
7809
+ if (async) {
7810
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
7811
+ dispose = value[Symbol.asyncDispose];
7812
+ }
7813
+ if (dispose === void 0) {
7814
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
7815
+ dispose = value[Symbol.dispose];
7816
+ if (async) inner = dispose;
7817
+ }
7818
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
7819
+ if (inner) dispose = function() {
7820
+ try {
7821
+ inner.call(this);
7822
+ } catch (e) {
7823
+ return Promise.reject(e);
7824
+ }
7825
+ };
7826
+ env.stack.push({
7827
+ value,
7828
+ dispose,
7829
+ async
7830
+ });
7831
+ } else if (async) {
7832
+ env.stack.push({
7833
+ async: true
7834
+ });
7839
7835
  }
7840
- return {
7841
- e: empty,
7842
- u: using.bind(null, false),
7843
- a: using.bind(null, true),
7844
- d: function() {
7845
- var error = this.e;
7846
- function next() {
7847
- while (resource = stack.pop()) {
7848
- try {
7849
- var resource, disposalResult = resource.d && resource.d.call(resource.v);
7850
- if (resource.a) {
7851
- return Promise.resolve(disposalResult).then(next, err);
7852
- }
7853
- } catch (e) {
7854
- return err(e);
7855
- }
7836
+ return value;
7837
+ }
7838
+ function _ts_dispose_resources4(env) {
7839
+ var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
7840
+ var e = new Error(message);
7841
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
7842
+ };
7843
+ return (_ts_dispose_resources4 = function _ts_dispose_resources5(env2) {
7844
+ function fail(e) {
7845
+ env2.error = env2.hasError ? new _SuppressedError(e, env2.error, "An error was suppressed during disposal.") : e;
7846
+ env2.hasError = true;
7847
+ }
7848
+ var r, s = 0;
7849
+ function next() {
7850
+ while (r = env2.stack.pop()) {
7851
+ try {
7852
+ if (!r.async && s === 1) return s = 0, env2.stack.push(r), Promise.resolve().then(next);
7853
+ if (r.dispose) {
7854
+ var result = r.dispose.call(r.value);
7855
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) {
7856
+ fail(e);
7857
+ return next();
7858
+ });
7859
+ } else s |= 1;
7860
+ } catch (e) {
7861
+ fail(e);
7856
7862
  }
7857
- if (error !== empty) throw error;
7858
- }
7859
- function err(e) {
7860
- error = error !== empty ? new _disposeSuppressedError(error, e) : e;
7861
- return next();
7862
7863
  }
7863
- return next();
7864
+ if (s === 1) return env2.hasError ? Promise.reject(env2.error) : Promise.resolve();
7865
+ if (env2.hasError) throw env2.error;
7864
7866
  }
7865
- };
7867
+ return next();
7868
+ })(env);
7866
7869
  }
7867
7870
  var __dxlog_file28 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
7868
7871
  var ServiceContext = class extends Resource8 {
7869
7872
  constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtimeParams, _edgeFeatures) {
7870
- super();
7871
- this.storage = storage;
7872
- this.level = level;
7873
- this.networkManager = networkManager;
7874
- this.signalManager = signalManager;
7875
- this._edgeConnection = _edgeConnection;
7876
- this._edgeHttpClient = _edgeHttpClient;
7877
- this._runtimeParams = _runtimeParams;
7878
- this._edgeFeatures = _edgeFeatures;
7879
- this._edgeIdentityUpdateMutex = new Mutex4();
7880
- this.initialized = new Trigger7();
7881
- this._meshReplicator = void 0;
7882
- this._echoEdgeReplicator = void 0;
7883
- this._handlerFactories = /* @__PURE__ */ new Map();
7884
- this._instanceId = PublicKey15.random().toHex();
7873
+ super(), this.storage = storage, this.level = level, this.networkManager = networkManager, this.signalManager = signalManager, this._edgeConnection = _edgeConnection, this._edgeHttpClient = _edgeHttpClient, this._runtimeParams = _runtimeParams, this._edgeFeatures = _edgeFeatures, this._edgeIdentityUpdateMutex = new Mutex4(), this.initialized = new Trigger7(), this._meshReplicator = void 0, this._echoEdgeReplicator = void 0, this._handlerFactories = /* @__PURE__ */ new Map(), this._instanceId = PublicKey15.random().toHex();
7885
7874
  this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
7886
7875
  this.blobStore = new BlobStore(storage.createDirectory("blobs"));
7887
7876
  this.keyring = new Keyring(storage.createDirectory("keyring"));
@@ -7916,7 +7905,10 @@ var ServiceContext = class extends Resource8 {
7916
7905
  this.echoHost = new EchoHost({
7917
7906
  kv: this.level,
7918
7907
  peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
7919
- getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key
7908
+ getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key,
7909
+ indexing: {
7910
+ vector: this._runtimeParams?.enableVectorIndexing
7911
+ }
7920
7912
  });
7921
7913
  this._meshReplicator = new MeshEchoReplicator();
7922
7914
  this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeParams?.invitationConnectionDefaultParams);
@@ -7935,7 +7927,7 @@ var ServiceContext = class extends Resource8 {
7935
7927
  await this._checkStorageVersion();
7936
7928
  log24("opening...", void 0, {
7937
7929
  F: __dxlog_file28,
7938
- L: 199,
7930
+ L: 203,
7939
7931
  S: this,
7940
7932
  C: (f, a) => f(...a)
7941
7933
  });
@@ -7943,7 +7935,7 @@ var ServiceContext = class extends Resource8 {
7943
7935
  id: this._instanceId
7944
7936
  }), {
7945
7937
  F: __dxlog_file28,
7946
- L: 200,
7938
+ L: 204,
7947
7939
  S: this,
7948
7940
  C: (f, a) => f(...a)
7949
7941
  });
@@ -7970,7 +7962,7 @@ var ServiceContext = class extends Resource8 {
7970
7962
  count: loadedInvitations.invitations?.length
7971
7963
  }, {
7972
7964
  F: __dxlog_file28,
7973
- L: 228,
7965
+ L: 232,
7974
7966
  S: this,
7975
7967
  C: (f, a) => f(...a)
7976
7968
  });
@@ -7978,13 +7970,13 @@ var ServiceContext = class extends Resource8 {
7978
7970
  id: this._instanceId
7979
7971
  }), {
7980
7972
  F: __dxlog_file28,
7981
- L: 230,
7973
+ L: 234,
7982
7974
  S: this,
7983
7975
  C: (f, a) => f(...a)
7984
7976
  });
7985
7977
  log24("opened", void 0, {
7986
7978
  F: __dxlog_file28,
7987
- L: 231,
7979
+ L: 235,
7988
7980
  S: this,
7989
7981
  C: (f, a) => f(...a)
7990
7982
  });
@@ -7992,7 +7984,7 @@ var ServiceContext = class extends Resource8 {
7992
7984
  async _close(ctx) {
7993
7985
  log24("closing...", void 0, {
7994
7986
  F: __dxlog_file28,
7995
- L: 235,
7987
+ L: 239,
7996
7988
  S: this,
7997
7989
  C: (f, a) => f(...a)
7998
7990
  });
@@ -8011,7 +8003,7 @@ var ServiceContext = class extends Resource8 {
8011
8003
  await this._edgeConnection?.close();
8012
8004
  log24("closed", void 0, {
8013
8005
  F: __dxlog_file28,
8014
- L: 251,
8006
+ L: 255,
8015
8007
  S: this,
8016
8008
  C: (f, a) => f(...a)
8017
8009
  });
@@ -8022,7 +8014,7 @@ var ServiceContext = class extends Resource8 {
8022
8014
  await identity.joinNetwork();
8023
8015
  await this._initialize(new Context10(void 0, {
8024
8016
  F: __dxlog_file28,
8025
- L: 258
8017
+ L: 262
8026
8018
  }));
8027
8019
  return identity;
8028
8020
  }
@@ -8033,7 +8025,7 @@ var ServiceContext = class extends Resource8 {
8033
8025
  const factory = this._handlerFactories.get(invitation.kind);
8034
8026
  invariant23(factory, `Unknown invitation kind: ${invitation.kind}`, {
8035
8027
  F: __dxlog_file28,
8036
- L: 267,
8028
+ L: 271,
8037
8029
  S: this,
8038
8030
  A: [
8039
8031
  "factory",
@@ -8059,7 +8051,7 @@ var ServiceContext = class extends Resource8 {
8059
8051
  await this.identityManager.acceptIdentity(identity, identityRecord, params.deviceProfile);
8060
8052
  await this._initialize(new Context10(void 0, {
8061
8053
  F: __dxlog_file28,
8062
- L: 286
8054
+ L: 290
8063
8055
  }));
8064
8056
  return identity;
8065
8057
  }
@@ -8073,7 +8065,7 @@ var ServiceContext = class extends Resource8 {
8073
8065
  async _initialize(ctx) {
8074
8066
  log24("initializing spaces...", void 0, {
8075
8067
  F: __dxlog_file28,
8076
- L: 301,
8068
+ L: 305,
8077
8069
  S: this,
8078
8070
  C: (f, a) => f(...a)
8079
8071
  });
@@ -8112,7 +8104,7 @@ var ServiceContext = class extends Resource8 {
8112
8104
  this._handlerFactories.set(Invitation10.Kind.SPACE, (invitation) => {
8113
8105
  invariant23(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
8114
8106
  F: __dxlog_file28,
8115
- L: 339,
8107
+ L: 343,
8116
8108
  S: this,
8117
8109
  A: [
8118
8110
  "this.dataSpaceManager",
@@ -8136,7 +8128,7 @@ var ServiceContext = class extends Resource8 {
8136
8128
  details: assertion
8137
8129
  }, {
8138
8130
  F: __dxlog_file28,
8139
- L: 355,
8131
+ L: 359,
8140
8132
  S: this,
8141
8133
  C: (f, a) => f(...a)
8142
8134
  });
@@ -8147,7 +8139,7 @@ var ServiceContext = class extends Resource8 {
8147
8139
  details: assertion
8148
8140
  }, {
8149
8141
  F: __dxlog_file28,
8150
- L: 359,
8142
+ L: 363,
8151
8143
  S: this,
8152
8144
  C: (f, a) => f(...a)
8153
8145
  });
@@ -8158,7 +8150,7 @@ var ServiceContext = class extends Resource8 {
8158
8150
  details: assertion
8159
8151
  }, {
8160
8152
  F: __dxlog_file28,
8161
- L: 364,
8153
+ L: 368,
8162
8154
  S: this,
8163
8155
  C: (f, a) => f(...a)
8164
8156
  });
@@ -8169,7 +8161,7 @@ var ServiceContext = class extends Resource8 {
8169
8161
  } catch (err) {
8170
8162
  log24.catch(err, void 0, {
8171
8163
  F: __dxlog_file28,
8172
- L: 370,
8164
+ L: 374,
8173
8165
  S: this,
8174
8166
  C: (f, a) => f(...a)
8175
8167
  });
@@ -8179,9 +8171,13 @@ var ServiceContext = class extends Resource8 {
8179
8171
  await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
8180
8172
  }
8181
8173
  async _setNetworkIdentity(params) {
8174
+ const env = {
8175
+ stack: [],
8176
+ error: void 0,
8177
+ hasError: false
8178
+ };
8182
8179
  try {
8183
- var _usingCtx = _using_ctx4();
8184
- const _ = _usingCtx.u(await this._edgeIdentityUpdateMutex.acquire());
8180
+ const _ = _ts_add_disposable_resource4(env, await this._edgeIdentityUpdateMutex.acquire(), false);
8185
8181
  let edgeIdentity;
8186
8182
  const identity = this.identityManager.identity;
8187
8183
  if (identity) {
@@ -8190,7 +8186,7 @@ var ServiceContext = class extends Resource8 {
8190
8186
  swarms: this.networkManager.topics
8191
8187
  }, {
8192
8188
  F: __dxlog_file28,
8193
- L: 384,
8189
+ L: 388,
8194
8190
  S: this,
8195
8191
  C: (f, a) => f(...a)
8196
8192
  });
@@ -8204,7 +8200,7 @@ var ServiceContext = class extends Resource8 {
8204
8200
  });
8205
8201
  invariant23(identity.deviceCredentialChain, void 0, {
8206
8202
  F: __dxlog_file28,
8207
- L: 403,
8203
+ L: 407,
8208
8204
  S: this,
8209
8205
  A: [
8210
8206
  "identity.deviceCredentialChain",
@@ -8222,10 +8218,11 @@ var ServiceContext = class extends Resource8 {
8222
8218
  identityKey: edgeIdentity.identityKey,
8223
8219
  peerKey: edgeIdentity.peerKey
8224
8220
  });
8225
- } catch (_) {
8226
- _usingCtx.e = _;
8221
+ } catch (e) {
8222
+ env.error = e;
8223
+ env.hasError = true;
8227
8224
  } finally {
8228
- _usingCtx.d();
8225
+ _ts_dispose_resources4(env);
8229
8226
  }
8230
8227
  }
8231
8228
  };
@@ -8339,7 +8336,7 @@ var createLevel = async (config) => {
8339
8336
  };
8340
8337
 
8341
8338
  // packages/sdk/client-services/src/packlets/storage/profile-archive.ts
8342
- import { cbor } from "@dxos/automerge/automerge-repo";
8339
+ import { cbor } from "@automerge/automerge-repo";
8343
8340
  import { invariant as invariant24 } from "@dxos/invariant";
8344
8341
  import { log as log25 } from "@dxos/log";
8345
8342
  import { ProfileArchiveEntryType } from "@dxos/protocols";
@@ -8361,7 +8358,7 @@ var exportProfileData = async ({ storage, level }) => {
8361
8358
  count: files.length
8362
8359
  }, {
8363
8360
  F: __dxlog_file29,
8364
- L: 30,
8361
+ L: 31,
8365
8362
  S: void 0,
8366
8363
  C: (f, a) => f(...a)
8367
8364
  });
@@ -8379,7 +8376,7 @@ var exportProfileData = async ({ storage, level }) => {
8379
8376
  count: files.length
8380
8377
  }, {
8381
8378
  F: __dxlog_file29,
8382
- L: 41,
8379
+ L: 42,
8383
8380
  S: void 0,
8384
8381
  C: (f, a) => f(...a)
8385
8382
  });
@@ -8387,7 +8384,7 @@ var exportProfileData = async ({ storage, level }) => {
8387
8384
  {
8388
8385
  log25.info("begin exporting kv pairs", void 0, {
8389
8386
  F: __dxlog_file29,
8390
- L: 45,
8387
+ L: 46,
8391
8388
  S: void 0,
8392
8389
  C: (f, a) => f(...a)
8393
8390
  });
@@ -8408,7 +8405,7 @@ var exportProfileData = async ({ storage, level }) => {
8408
8405
  count
8409
8406
  }, {
8410
8407
  F: __dxlog_file29,
8411
- L: 56,
8408
+ L: 57,
8412
8409
  S: void 0,
8413
8410
  C: (f, a) => f(...a)
8414
8411
  });
@@ -8424,7 +8421,7 @@ var importProfileData = async ({ storage, level }, archive) => {
8424
8421
  const directory = await storage.createDirectory();
8425
8422
  invariant24(typeof entry2.key === "string", "Invalid key type", {
8426
8423
  F: __dxlog_file29,
8427
- L: 79,
8424
+ L: 80,
8428
8425
  S: void 0,
8429
8426
  A: [
8430
8427
  "typeof entry.key === 'string'",
@@ -8434,7 +8431,7 @@ var importProfileData = async ({ storage, level }, archive) => {
8434
8431
  const file = await directory.getOrCreateFile(entry2.key);
8435
8432
  invariant24(entry2.value instanceof Uint8Array, "Invalid value type", {
8436
8433
  F: __dxlog_file29,
8437
- L: 81,
8434
+ L: 82,
8438
8435
  S: void 0,
8439
8436
  A: [
8440
8437
  "entry.value instanceof Uint8Array",
@@ -8448,7 +8445,7 @@ var importProfileData = async ({ storage, level }, archive) => {
8448
8445
  case ProfileArchiveEntryType.KEY_VALUE: {
8449
8446
  invariant24(entry2.key instanceof Uint8Array, "Invalid key type", {
8450
8447
  F: __dxlog_file29,
8451
- L: 87,
8448
+ L: 88,
8452
8449
  S: void 0,
8453
8450
  A: [
8454
8451
  "entry.key instanceof Uint8Array",
@@ -8457,7 +8454,7 @@ var importProfileData = async ({ storage, level }, archive) => {
8457
8454
  });
8458
8455
  invariant24(entry2.value instanceof Uint8Array, "Invalid value type", {
8459
8456
  F: __dxlog_file29,
8460
- L: 88,
8457
+ L: 89,
8461
8458
  S: void 0,
8462
8459
  A: [
8463
8460
  "entry.value instanceof Uint8Array",
@@ -8482,7 +8479,7 @@ var importProfileData = async ({ storage, level }, archive) => {
8482
8479
  progress: `${(count / archive.storage.length * 100).toFixed()}%`
8483
8480
  }, {
8484
8481
  F: __dxlog_file29,
8485
- L: 101,
8482
+ L: 102,
8486
8483
  S: void 0,
8487
8484
  C: (f, a) => f(...a)
8488
8485
  });
@@ -8490,7 +8487,7 @@ var importProfileData = async ({ storage, level }, archive) => {
8490
8487
  }
8491
8488
  log25.info("committing changes..", void 0, {
8492
8489
  F: __dxlog_file29,
8493
- L: 109,
8490
+ L: 110,
8494
8491
  S: void 0,
8495
8492
  C: (f, a) => f(...a)
8496
8493
  });
@@ -8516,7 +8513,7 @@ import { WebsocketRpcClient } from "@dxos/websocket-rpc";
8516
8513
  import { SubscriptionList as SubscriptionList3 } from "@dxos/async";
8517
8514
  import { Stream as Stream12 } from "@dxos/codec-protobuf/stream";
8518
8515
  import { invariant as invariant25 } from "@dxos/invariant";
8519
- import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
8516
+ import { Device as Device2, DeviceKind as DeviceKind2, EdgeStatus as EdgeStatus3 } from "@dxos/protocols/proto/dxos/client/services";
8520
8517
  var __dxlog_file30 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
8521
8518
  var DevicesServiceImpl = class {
8522
8519
  constructor(_identityManager, _edgeConnection) {
@@ -8537,7 +8534,7 @@ var DevicesServiceImpl = class {
8537
8534
  } else {
8538
8535
  invariant25(this._identityManager.identity?.presence, "presence not present", {
8539
8536
  F: __dxlog_file30,
8540
- L: 36,
8537
+ L: 37,
8541
8538
  S: this,
8542
8539
  A: [
8543
8540
  "this._identityManager.identity?.presence",
@@ -8552,7 +8549,7 @@ var DevicesServiceImpl = class {
8552
8549
  if (isMe) {
8553
8550
  presence = Device2.PresenceState.ONLINE;
8554
8551
  } else if (profile.os?.toUpperCase() === "EDGE") {
8555
- presence = this._edgeConnection?.isConnected ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE;
8552
+ presence = this._edgeConnection?.status === EdgeStatus3.CONNECTED ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE;
8556
8553
  } else {
8557
8554
  presence = peers.some((peer) => peer.identityKey.equals(key)) ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE;
8558
8555
  }
@@ -8812,12 +8809,13 @@ var LOG_PROCESSING = 0;
8812
8809
  // packages/sdk/client-services/src/packlets/network/network-service.ts
8813
8810
  import { Stream as Stream15 } from "@dxos/codec-protobuf/stream";
8814
8811
  var NetworkServiceImpl = class {
8815
- constructor(networkManager, signalManager) {
8812
+ constructor(networkManager, signalManager, edgeConnection) {
8816
8813
  this.networkManager = networkManager;
8817
8814
  this.signalManager = signalManager;
8815
+ this.edgeConnection = edgeConnection;
8818
8816
  }
8819
8817
  queryStatus() {
8820
- return new Stream15(({ next }) => {
8818
+ return new Stream15(({ ctx, next }) => {
8821
8819
  const update = () => {
8822
8820
  next({
8823
8821
  swarm: this.networkManager.connectionState,
@@ -8828,13 +8826,9 @@ var NetworkServiceImpl = class {
8828
8826
  }))
8829
8827
  });
8830
8828
  };
8831
- const unsubscribeSwarm = this.networkManager.connectionStateChanged.on(() => update());
8832
- const unsubscribeSignal = this.signalManager.statusChanged?.on(() => update());
8829
+ this.networkManager.connectionStateChanged.on(ctx, () => update());
8830
+ this.signalManager.statusChanged?.on(ctx, () => update());
8833
8831
  update();
8834
- return () => {
8835
- unsubscribeSwarm();
8836
- unsubscribeSignal?.();
8837
- };
8838
8832
  });
8839
8833
  }
8840
8834
  async updateConfig(request) {
@@ -8850,26 +8844,24 @@ var NetworkServiceImpl = class {
8850
8844
  return this.signalManager.query(request);
8851
8845
  }
8852
8846
  subscribeSwarmState(request) {
8853
- return new Stream15(({ next }) => {
8854
- const unsubscribe = this.signalManager.swarmState?.on((state) => {
8847
+ return new Stream15(({ ctx, next }) => {
8848
+ this.signalManager.swarmState?.on(ctx, (state) => {
8855
8849
  if (request.topic.equals(state.swarmKey)) {
8856
8850
  next(state);
8857
8851
  }
8858
8852
  });
8859
- return unsubscribe;
8860
8853
  });
8861
8854
  }
8862
8855
  async sendMessage(message) {
8863
8856
  return this.signalManager.sendMessage(message);
8864
8857
  }
8865
8858
  subscribeMessages(peer) {
8866
- return new Stream15(({ next }) => {
8867
- const unsubscribe = this.signalManager.onMessage.on((message) => {
8859
+ return new Stream15(({ ctx, next }) => {
8860
+ this.signalManager.onMessage.on(ctx, (message) => {
8868
8861
  if (message.recipient.peerKey === peer.peerKey) {
8869
8862
  next(message);
8870
8863
  }
8871
8864
  });
8872
- return unsubscribe;
8873
8865
  });
8874
8866
  }
8875
8867
  };
@@ -8965,6 +8957,9 @@ var ClientServicesHost = class {
8965
8957
  if (this._runtimeParams.disableP2pReplication === void 0) {
8966
8958
  this._runtimeParams.disableP2pReplication = config?.get("runtime.client.disableP2pReplication", false);
8967
8959
  }
8960
+ if (this._runtimeParams.enableVectorIndexing === void 0) {
8961
+ this._runtimeParams.enableVectorIndexing = config?.get("runtime.client.enableVectorIndexing", false);
8962
+ }
8968
8963
  if (config) {
8969
8964
  this.initialize({
8970
8965
  config,
@@ -8979,7 +8974,7 @@ var ClientServicesHost = class {
8979
8974
  if (!this._opening) {
8980
8975
  void this.open(new Context11(void 0, {
8981
8976
  F: __dxlog_file31,
8982
- L: 137
8977
+ L: 141
8983
8978
  }));
8984
8979
  }
8985
8980
  },
@@ -9037,7 +9032,7 @@ var ClientServicesHost = class {
9037
9032
  initialize({ config, ...options }) {
9038
9033
  invariant26(!this._open, "service host is open", {
9039
9034
  F: __dxlog_file31,
9040
- L: 203,
9035
+ L: 207,
9041
9036
  S: this,
9042
9037
  A: [
9043
9038
  "!this._open",
@@ -9046,14 +9041,14 @@ var ClientServicesHost = class {
9046
9041
  });
9047
9042
  log27("initializing...", void 0, {
9048
9043
  F: __dxlog_file31,
9049
- L: 204,
9044
+ L: 208,
9050
9045
  S: this,
9051
9046
  C: (f, a) => f(...a)
9052
9047
  });
9053
9048
  if (config) {
9054
9049
  invariant26(!this._config, "config already set", {
9055
9050
  F: __dxlog_file31,
9056
- L: 207,
9051
+ L: 211,
9057
9052
  S: this,
9058
9053
  A: [
9059
9054
  "!this._config",
@@ -9068,7 +9063,7 @@ var ClientServicesHost = class {
9068
9063
  if (!options.signalManager) {
9069
9064
  log27.warn("running signaling without telemetry metadata.", void 0, {
9070
9065
  F: __dxlog_file31,
9071
- L: 215,
9066
+ L: 219,
9072
9067
  S: this,
9073
9068
  C: (f, a) => f(...a)
9074
9069
  });
@@ -9088,7 +9083,7 @@ var ClientServicesHost = class {
9088
9083
  this._signalManager = signalManager;
9089
9084
  invariant26(!this._networkManager, "network manager already set", {
9090
9085
  F: __dxlog_file31,
9091
- L: 237,
9086
+ L: 241,
9092
9087
  S: this,
9093
9088
  A: [
9094
9089
  "!this._networkManager",
@@ -9106,7 +9101,7 @@ var ClientServicesHost = class {
9106
9101
  });
9107
9102
  log27("initialized", void 0, {
9108
9103
  F: __dxlog_file31,
9109
- L: 250,
9104
+ L: 254,
9110
9105
  S: this,
9111
9106
  C: (f, a) => f(...a)
9112
9107
  });
@@ -9120,13 +9115,13 @@ var ClientServicesHost = class {
9120
9115
  id: traceId
9121
9116
  }), {
9122
9117
  F: __dxlog_file31,
9123
- L: 261,
9118
+ L: 265,
9124
9119
  S: this,
9125
9120
  C: (f, a) => f(...a)
9126
9121
  });
9127
9122
  invariant26(this._config, "config not set", {
9128
9123
  F: __dxlog_file31,
9129
- L: 263,
9124
+ L: 267,
9130
9125
  S: this,
9131
9126
  A: [
9132
9127
  "this._config",
@@ -9135,7 +9130,7 @@ var ClientServicesHost = class {
9135
9130
  });
9136
9131
  invariant26(this._storage, "storage not set", {
9137
9132
  F: __dxlog_file31,
9138
- L: 264,
9133
+ L: 268,
9139
9134
  S: this,
9140
9135
  A: [
9141
9136
  "this._storage",
@@ -9144,7 +9139,7 @@ var ClientServicesHost = class {
9144
9139
  });
9145
9140
  invariant26(this._signalManager, "signal manager not set", {
9146
9141
  F: __dxlog_file31,
9147
- L: 265,
9142
+ L: 269,
9148
9143
  S: this,
9149
9144
  A: [
9150
9145
  "this._signalManager",
@@ -9153,7 +9148,7 @@ var ClientServicesHost = class {
9153
9148
  });
9154
9149
  invariant26(this._networkManager, "network manager not set", {
9155
9150
  F: __dxlog_file31,
9156
- L: 266,
9151
+ L: 270,
9157
9152
  S: this,
9158
9153
  A: [
9159
9154
  "this._networkManager",
@@ -9165,7 +9160,7 @@ var ClientServicesHost = class {
9165
9160
  lockKey: this._resourceLock?.lockKey
9166
9161
  }, {
9167
9162
  F: __dxlog_file31,
9168
- L: 269,
9163
+ L: 273,
9169
9164
  S: this,
9170
9165
  C: (f, a) => f(...a)
9171
9166
  });
@@ -9194,7 +9189,7 @@ var ClientServicesHost = class {
9194
9189
  SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, dataSpaceManagerProvider),
9195
9190
  DataService: this._serviceContext.echoHost.dataService,
9196
9191
  QueryService: this._serviceContext.echoHost.queryService,
9197
- NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
9192
+ NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager, this._edgeConnection),
9198
9193
  LoggingService: this._loggingService,
9199
9194
  TracingService: this._tracingService,
9200
9195
  // TODO(burdon): Move to new protobuf definitions.
@@ -9226,7 +9221,7 @@ var ClientServicesHost = class {
9226
9221
  deviceKey
9227
9222
  }, {
9228
9223
  F: __dxlog_file31,
9229
- L: 366,
9224
+ L: 374,
9230
9225
  S: this,
9231
9226
  C: (f, a) => f(...a)
9232
9227
  });
@@ -9234,7 +9229,7 @@ var ClientServicesHost = class {
9234
9229
  id: traceId
9235
9230
  }), {
9236
9231
  F: __dxlog_file31,
9237
- L: 367,
9232
+ L: 375,
9238
9233
  S: this,
9239
9234
  C: (f, a) => f(...a)
9240
9235
  });
@@ -9248,7 +9243,7 @@ var ClientServicesHost = class {
9248
9243
  deviceKey
9249
9244
  }, {
9250
9245
  F: __dxlog_file31,
9251
- L: 378,
9246
+ L: 386,
9252
9247
  S: this,
9253
9248
  C: (f, a) => f(...a)
9254
9249
  });
@@ -9266,7 +9261,7 @@ var ClientServicesHost = class {
9266
9261
  deviceKey
9267
9262
  }, {
9268
9263
  F: __dxlog_file31,
9269
- L: 387,
9264
+ L: 395,
9270
9265
  S: this,
9271
9266
  C: (f, a) => f(...a)
9272
9267
  });
@@ -9277,13 +9272,13 @@ var ClientServicesHost = class {
9277
9272
  id: traceId
9278
9273
  }), {
9279
9274
  F: __dxlog_file31,
9280
- L: 392,
9275
+ L: 400,
9281
9276
  S: this,
9282
9277
  C: (f, a) => f(...a)
9283
9278
  });
9284
9279
  log27.info("resetting...", void 0, {
9285
9280
  F: __dxlog_file31,
9286
- L: 394,
9281
+ L: 402,
9287
9282
  S: this,
9288
9283
  C: (f, a) => f(...a)
9289
9284
  });
@@ -9293,7 +9288,7 @@ var ClientServicesHost = class {
9293
9288
  await this._storage.reset();
9294
9289
  log27.info("reset", void 0, {
9295
9290
  F: __dxlog_file31,
9296
- L: 401,
9291
+ L: 409,
9297
9292
  S: this,
9298
9293
  C: (f, a) => f(...a)
9299
9294
  });
@@ -9301,7 +9296,7 @@ var ClientServicesHost = class {
9301
9296
  id: traceId
9302
9297
  }), {
9303
9298
  F: __dxlog_file31,
9304
- L: 402,
9299
+ L: 410,
9305
9300
  S: this,
9306
9301
  C: (f, a) => f(...a)
9307
9302
  });
@@ -9379,4 +9374,4 @@ export {
9379
9374
  importProfileData,
9380
9375
  ClientServicesHost
9381
9376
  };
9382
- //# sourceMappingURL=chunk-DQCPFIVI.mjs.map
9377
+ //# sourceMappingURL=chunk-SV2U4CXT.mjs.map