@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";
@@ -556,13 +556,6 @@ import { Trigger } from "@dxos/async";
556
556
  import { log as log2 } from "@dxos/log";
557
557
  var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/browser-diagnostics-broadcast.ts";
558
558
  var CHANNEL_NAME = "dxos.diagnostics.broadcast";
559
- var MessageType;
560
- (function(MessageType2) {
561
- MessageType2["PROBE"] = "probe";
562
- MessageType2["PROBE_ACK"] = "probe-ack";
563
- MessageType2["REQUEST_DIAGNOSTICS"] = "request-diagnostics";
564
- MessageType2["RECEIVE_DIAGNOSTICS"] = "receive-diagnostics";
565
- })(MessageType || (MessageType = {}));
566
559
  var createCollectDiagnosticsBroadcastSender = () => {
567
560
  return {
568
561
  broadcastDiagnosticsRequest: async () => {
@@ -817,6 +810,7 @@ import { log as log4, logInfo } from "@dxos/log";
817
810
  import { EdgeService } from "@dxos/protocols";
818
811
  import { buf } from "@dxos/protocols/buf";
819
812
  import { MessageSchema as RouterMessageSchema } from "@dxos/protocols/buf/dxos/edge/messenger_pb";
813
+ import { EdgeStatus } from "@dxos/protocols/proto/dxos/client/services";
820
814
  import { ComplexMap as ComplexMap2, arrayToBuffer, bufferToArray, defaultMap, rangeFromTo } from "@dxos/util";
821
815
  function _ts_decorate(decorators, target, key, desc) {
822
816
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -824,67 +818,70 @@ function _ts_decorate(decorators, target, key, desc) {
824
818
  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;
825
819
  return c > 3 && r && Object.defineProperty(target, key, r), r;
826
820
  }
827
- function _using_ctx() {
828
- var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
829
- var err = new Error();
830
- err.name = "SuppressedError";
831
- err.suppressed = suppressed;
832
- err.error = error;
833
- return err;
834
- }, empty = {}, stack = [];
835
- function using(isAwait, value) {
836
- if (value != null) {
837
- if (Object(value) !== value) {
838
- throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
839
- }
840
- if (isAwait) {
841
- var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
842
- }
843
- if (dispose == null) {
844
- dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
845
- }
846
- if (typeof dispose !== "function") {
847
- throw new TypeError(`Property [Symbol.dispose] is not a function.`);
848
- }
849
- stack.push({
850
- v: value,
851
- d: dispose,
852
- a: isAwait
853
- });
854
- } else if (isAwait) {
855
- stack.push({
856
- d: value,
857
- a: isAwait
858
- });
859
- }
860
- return value;
821
+ function _ts_add_disposable_resource(env, value, async) {
822
+ if (value !== null && value !== void 0) {
823
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
824
+ var dispose, inner;
825
+ if (async) {
826
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
827
+ dispose = value[Symbol.asyncDispose];
828
+ }
829
+ if (dispose === void 0) {
830
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
831
+ dispose = value[Symbol.dispose];
832
+ if (async) inner = dispose;
833
+ }
834
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
835
+ if (inner) dispose = function() {
836
+ try {
837
+ inner.call(this);
838
+ } catch (e) {
839
+ return Promise.reject(e);
840
+ }
841
+ };
842
+ env.stack.push({
843
+ value,
844
+ dispose,
845
+ async
846
+ });
847
+ } else if (async) {
848
+ env.stack.push({
849
+ async: true
850
+ });
861
851
  }
862
- return {
863
- e: empty,
864
- u: using.bind(null, false),
865
- a: using.bind(null, true),
866
- d: function() {
867
- var error = this.e;
868
- function next() {
869
- while (resource = stack.pop()) {
870
- try {
871
- var resource, disposalResult = resource.d && resource.d.call(resource.v);
872
- if (resource.a) {
873
- return Promise.resolve(disposalResult).then(next, err);
874
- }
875
- } catch (e) {
876
- return err(e);
877
- }
852
+ return value;
853
+ }
854
+ function _ts_dispose_resources(env) {
855
+ var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
856
+ var e = new Error(message);
857
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
858
+ };
859
+ return (_ts_dispose_resources = function _ts_dispose_resources5(env2) {
860
+ function fail(e) {
861
+ env2.error = env2.hasError ? new _SuppressedError(e, env2.error, "An error was suppressed during disposal.") : e;
862
+ env2.hasError = true;
863
+ }
864
+ var r, s = 0;
865
+ function next() {
866
+ while (r = env2.stack.pop()) {
867
+ try {
868
+ if (!r.async && s === 1) return s = 0, env2.stack.push(r), Promise.resolve().then(next);
869
+ if (r.dispose) {
870
+ var result = r.dispose.call(r.value);
871
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) {
872
+ fail(e);
873
+ return next();
874
+ });
875
+ } else s |= 1;
876
+ } catch (e) {
877
+ fail(e);
878
878
  }
879
- if (error !== empty) throw error;
880
- }
881
- function err(e) {
882
- error = error !== empty ? new _disposeSuppressedError(error, e) : e;
883
- return next();
884
879
  }
885
- return next();
880
+ if (s === 1) return env2.hasError ? Promise.reject(env2.error) : Promise.resolve();
881
+ if (env2.hasError) throw env2.error;
886
882
  }
887
- };
883
+ return next();
884
+ })(env);
888
885
  }
889
886
  var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/edge-feed-replicator.ts";
890
887
  var EdgeFeedReplicator = class extends Resource {
@@ -907,7 +904,7 @@ var EdgeFeedReplicator = class extends Resource {
907
904
  async _open() {
908
905
  log4("open", void 0, {
909
906
  F: __dxlog_file6,
910
- L: 56,
907
+ L: 57,
911
908
  S: this,
912
909
  C: (f, a) => f(...a)
913
910
  });
@@ -926,7 +923,7 @@ var EdgeFeedReplicator = class extends Resource {
926
923
  _spaceId: this._spaceId
927
924
  }, {
928
925
  F: __dxlog_file6,
929
- L: 70,
926
+ L: 71,
930
927
  S: this,
931
928
  C: (f, a) => f(...a)
932
929
  });
@@ -939,7 +936,7 @@ var EdgeFeedReplicator = class extends Resource {
939
936
  type: payload.type
940
937
  }, {
941
938
  F: __dxlog_file6,
942
- L: 75,
939
+ L: 76,
943
940
  S: this,
944
941
  C: (f, a) => f(...a)
945
942
  });
@@ -951,14 +948,14 @@ var EdgeFeedReplicator = class extends Resource {
951
948
  }
952
949
  async _handleReconnect() {
953
950
  await this._resetConnection();
954
- if (this._messenger.isConnected) {
951
+ if (this._messenger.status === EdgeStatus.CONNECTED) {
955
952
  this._startReplication();
956
953
  }
957
954
  }
958
955
  async _close() {
959
956
  log4("close", void 0, {
960
957
  F: __dxlog_file6,
961
- L: 95,
958
+ L: 96,
962
959
  S: this,
963
960
  C: (f, a) => f(...a)
964
961
  });
@@ -970,7 +967,7 @@ var EdgeFeedReplicator = class extends Resource {
970
967
  this._connectionCtx = connectionCtx;
971
968
  log4("connection context created", void 0, {
972
969
  F: __dxlog_file6,
973
- L: 103,
970
+ L: 104,
974
971
  S: this,
975
972
  C: (f, a) => f(...a)
976
973
  });
@@ -983,7 +980,7 @@ var EdgeFeedReplicator = class extends Resource {
983
980
  async _resetConnection() {
984
981
  log4("resetConnection", void 0, {
985
982
  F: __dxlog_file6,
986
- L: 112,
983
+ L: 113,
987
984
  S: this,
988
985
  C: (f, a) => f(...a)
989
986
  });
@@ -999,7 +996,7 @@ var EdgeFeedReplicator = class extends Resource {
999
996
  hasConnectionCtx: !!this._connectionCtx
1000
997
  }, {
1001
998
  F: __dxlog_file6,
1002
- L: 120,
999
+ L: 121,
1003
1000
  S: this,
1004
1001
  C: (f, a) => f(...a)
1005
1002
  });
@@ -1016,7 +1013,7 @@ var EdgeFeedReplicator = class extends Resource {
1016
1013
  key: feed.key
1017
1014
  }, {
1018
1015
  F: __dxlog_file6,
1019
- L: 133,
1016
+ L: 134,
1020
1017
  S: this,
1021
1018
  C: (f, a) => f(...a)
1022
1019
  });
@@ -1032,7 +1029,7 @@ var EdgeFeedReplicator = class extends Resource {
1032
1029
  if (!this._connectionCtx) {
1033
1030
  log4("message dropped because connection was disposed", void 0, {
1034
1031
  F: __dxlog_file6,
1035
- L: 146,
1032
+ L: 147,
1036
1033
  S: this,
1037
1034
  C: (f, a) => f(...a)
1038
1035
  });
@@ -1044,14 +1041,14 @@ var EdgeFeedReplicator = class extends Resource {
1044
1041
  blocks: message.blocks.map((b) => b.index)
1045
1042
  }, {
1046
1043
  F: __dxlog_file6,
1047
- L: 151,
1044
+ L: 152,
1048
1045
  S: this,
1049
1046
  C: (f, a) => f(...a)
1050
1047
  });
1051
1048
  }
1052
1049
  invariant2(message.feedKey, void 0, {
1053
1050
  F: __dxlog_file6,
1054
- L: 157,
1051
+ L: 158,
1055
1052
  S: this,
1056
1053
  A: [
1057
1054
  "message.feedKey",
@@ -1063,7 +1060,7 @@ var EdgeFeedReplicator = class extends Resource {
1063
1060
  type: message.type
1064
1061
  }, {
1065
1062
  F: __dxlog_file6,
1066
- L: 160,
1063
+ L: 161,
1067
1064
  S: this,
1068
1065
  C: (f, a) => f(...a)
1069
1066
  });
@@ -1082,7 +1079,7 @@ var EdgeFeedReplicator = class extends Resource {
1082
1079
  if (!this._connectionCtx) {
1083
1080
  log4.warn("received message after connection context was disposed", void 0, {
1084
1081
  F: __dxlog_file6,
1085
- L: 175,
1082
+ L: 176,
1086
1083
  S: this,
1087
1084
  C: (f, a) => f(...a)
1088
1085
  });
@@ -1091,8 +1088,12 @@ var EdgeFeedReplicator = class extends Resource {
1091
1088
  scheduleMicroTask(this._connectionCtx, async () => {
1092
1089
  switch (message.type) {
1093
1090
  case "metadata": {
1091
+ const env = {
1092
+ stack: [],
1093
+ error: void 0,
1094
+ hasError: false
1095
+ };
1094
1096
  try {
1095
- var _usingCtx = _using_ctx();
1096
1097
  const feedKey = PublicKey3.fromHex(message.feedKey);
1097
1098
  const feed = this._feeds.get(feedKey);
1098
1099
  if (!feed) {
@@ -1100,13 +1101,13 @@ var EdgeFeedReplicator = class extends Resource {
1100
1101
  feedKey
1101
1102
  }, {
1102
1103
  F: __dxlog_file6,
1103
- L: 184,
1104
+ L: 185,
1104
1105
  S: this,
1105
1106
  C: (f, a) => f(...a)
1106
1107
  });
1107
1108
  return;
1108
1109
  }
1109
- const _guard = _usingCtx.u(await this._getPushMutex(feed.key).acquire());
1110
+ const _guard = _ts_add_disposable_resource(env, await this._getPushMutex(feed.key).acquire(), false);
1110
1111
  this._remoteLength.set(feedKey, message.length);
1111
1112
  const logMeta = {
1112
1113
  localLength: feed.length,
@@ -1116,7 +1117,7 @@ var EdgeFeedReplicator = class extends Resource {
1116
1117
  if (message.length > feed.length) {
1117
1118
  log4("requesting missing blocks", logMeta, {
1118
1119
  F: __dxlog_file6,
1119
- L: 194,
1120
+ L: 195,
1120
1121
  S: this,
1121
1122
  C: (f, a) => f(...a)
1122
1123
  });
@@ -1131,17 +1132,18 @@ var EdgeFeedReplicator = class extends Resource {
1131
1132
  } else if (message.length < feed.length) {
1132
1133
  log4("pushing blocks to remote", logMeta, {
1133
1134
  F: __dxlog_file6,
1134
- L: 202,
1135
+ L: 203,
1135
1136
  S: this,
1136
1137
  C: (f, a) => f(...a)
1137
1138
  });
1138
1139
  await this._pushBlocks(feed, message.length, feed.length);
1139
1140
  }
1140
1141
  break;
1141
- } catch (_) {
1142
- _usingCtx.e = _;
1142
+ } catch (e) {
1143
+ env.error = e;
1144
+ env.hasError = true;
1143
1145
  } finally {
1144
- _usingCtx.d();
1146
+ _ts_dispose_resources(env);
1145
1147
  }
1146
1148
  }
1147
1149
  case "data": {
@@ -1150,7 +1152,7 @@ var EdgeFeedReplicator = class extends Resource {
1150
1152
  blocks: message.blocks.map((b) => b.index)
1151
1153
  }, {
1152
1154
  F: __dxlog_file6,
1153
- L: 211,
1155
+ L: 212,
1154
1156
  S: this,
1155
1157
  C: (f, a) => f(...a)
1156
1158
  });
@@ -1161,7 +1163,7 @@ var EdgeFeedReplicator = class extends Resource {
1161
1163
  feedKey
1162
1164
  }, {
1163
1165
  F: __dxlog_file6,
1164
- L: 216,
1166
+ L: 217,
1165
1167
  S: this,
1166
1168
  C: (f, a) => f(...a)
1167
1169
  });
@@ -1175,7 +1177,7 @@ var EdgeFeedReplicator = class extends Resource {
1175
1177
  ...message
1176
1178
  }, {
1177
1179
  F: __dxlog_file6,
1178
- L: 225,
1180
+ L: 226,
1179
1181
  S: this,
1180
1182
  C: (f, a) => f(...a)
1181
1183
  });
@@ -1190,7 +1192,7 @@ var EdgeFeedReplicator = class extends Resource {
1190
1192
  to
1191
1193
  }, {
1192
1194
  F: __dxlog_file6,
1193
- L: 232,
1195
+ L: 233,
1194
1196
  S: this,
1195
1197
  C: (f, a) => f(...a)
1196
1198
  });
@@ -1200,7 +1202,7 @@ var EdgeFeedReplicator = class extends Resource {
1200
1202
  });
1201
1203
  invariant2(data instanceof Uint8Array, void 0, {
1202
1204
  F: __dxlog_file6,
1203
- L: 237,
1205
+ L: 238,
1204
1206
  S: this,
1205
1207
  A: [
1206
1208
  "data instanceof Uint8Array",
@@ -1228,7 +1230,7 @@ var EdgeFeedReplicator = class extends Resource {
1228
1230
  blocks: blocks.length
1229
1231
  }, {
1230
1232
  F: __dxlog_file6,
1231
- L: 258,
1233
+ L: 259,
1232
1234
  S: this,
1233
1235
  C: (f, a) => f(...a)
1234
1236
  });
@@ -1244,13 +1246,17 @@ var EdgeFeedReplicator = class extends Resource {
1244
1246
  }
1245
1247
  }
1246
1248
  async _pushBlocksIfNeeded(feed) {
1249
+ const env = {
1250
+ stack: [],
1251
+ error: void 0,
1252
+ hasError: false
1253
+ };
1247
1254
  try {
1248
- var _usingCtx = _using_ctx();
1249
- const _ = _usingCtx.u(await this._getPushMutex(feed.key).acquire());
1255
+ const _ = _ts_add_disposable_resource(env, await this._getPushMutex(feed.key).acquire(), false);
1250
1256
  if (!this._remoteLength.has(feed.key)) {
1251
1257
  log4("blocks not pushed because remote length is unknown", void 0, {
1252
1258
  F: __dxlog_file6,
1253
- L: 279,
1259
+ L: 280,
1254
1260
  S: this,
1255
1261
  C: (f, a) => f(...a)
1256
1262
  });
@@ -1260,10 +1266,11 @@ var EdgeFeedReplicator = class extends Resource {
1260
1266
  if (remoteLength < feed.length) {
1261
1267
  await this._pushBlocks(feed, remoteLength, feed.length);
1262
1268
  }
1263
- } catch (_) {
1264
- _usingCtx.e = _;
1269
+ } catch (e) {
1270
+ env.error = e;
1271
+ env.hasError = true;
1265
1272
  } finally {
1266
- _usingCtx.d();
1273
+ _ts_dispose_resources(env);
1267
1274
  }
1268
1275
  }
1269
1276
  _createConnectionContext() {
@@ -1275,7 +1282,7 @@ var EdgeFeedReplicator = class extends Resource {
1275
1282
  if (err instanceof EdgeIdentityChangedError || err instanceof EdgeConnectionClosedError) {
1276
1283
  log4("resetting on reconnect", void 0, {
1277
1284
  F: __dxlog_file6,
1278
- L: 296,
1285
+ L: 297,
1279
1286
  S: this,
1280
1287
  C: (f, a) => f(...a)
1281
1288
  });
@@ -1286,7 +1293,7 @@ var EdgeFeedReplicator = class extends Resource {
1286
1293
  }
1287
1294
  }, {
1288
1295
  F: __dxlog_file6,
1289
- L: 290
1296
+ L: 291
1290
1297
  });
1291
1298
  return connectionCtx;
1292
1299
  }
@@ -1306,12 +1313,12 @@ var bufferizeBlock = (block) => ({
1306
1313
  });
1307
1314
 
1308
1315
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
1316
+ import { save } from "@automerge/automerge";
1309
1317
  import { Event as Event7, Mutex as Mutex2, scheduleTask as scheduleTask4, sleep as sleep3, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
1310
- import { save } from "@dxos/automerge/automerge";
1311
1318
  import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
1312
1319
  import { Context as Context6, ContextDisposedError, cancelWithContext as cancelWithContext2 } from "@dxos/context";
1313
1320
  import { timed, warnAfterTimeout } from "@dxos/debug";
1314
- import { createMappedFeedWriter } from "@dxos/echo-pipeline";
1321
+ import { createMappedFeedWriter, FIND_PARAMS as FIND_PARAMS2 } from "@dxos/echo-pipeline";
1315
1322
  import { SpaceDocVersion as SpaceDocVersion2 } from "@dxos/echo-protocol";
1316
1323
  import { failedInvariant as failedInvariant3, invariant as invariant11 } from "@dxos/invariant";
1317
1324
  import { PublicKey as PublicKey8 } from "@dxos/keys";
@@ -1329,12 +1336,7 @@ import { Resource as Resource2 } from "@dxos/context";
1329
1336
  import { checkCredentialType } from "@dxos/credentials";
1330
1337
  var AutomergeSpaceState = class extends Resource2 {
1331
1338
  constructor(_onNewRoot) {
1332
- super();
1333
- this._onNewRoot = _onNewRoot;
1334
- this.rootUrl = void 0;
1335
- this.lastEpoch = void 0;
1336
- this.onNewEpoch = new Event2();
1337
- this._isProcessingRootDocs = false;
1339
+ super(), this._onNewRoot = _onNewRoot, this.rootUrl = void 0, this.lastEpoch = void 0, this.onNewEpoch = new Event2(), this._isProcessingRootDocs = false;
1338
1340
  }
1339
1341
  async _open(ctx) {
1340
1342
  }
@@ -1389,7 +1391,7 @@ var runEpochMigration = async (ctx, context) => {
1389
1391
  const rootHandle = await context.echoHost.loadDoc(ctx, context.currentRoot, {
1390
1392
  timeout: LOAD_DOC_TIMEOUT
1391
1393
  });
1392
- const newRoot = context.echoHost.createDoc(rootHandle.docSync());
1394
+ const newRoot = context.echoHost.createDoc(rootHandle.doc());
1393
1395
  await context.echoHost.flush();
1394
1396
  return {
1395
1397
  newRoot: newRoot.url
@@ -1405,7 +1407,7 @@ var runEpochMigration = async (ctx, context) => {
1405
1407
  case CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT: {
1406
1408
  invariant3(context.newAutomergeRoot, void 0, {
1407
1409
  F: __dxlog_file7,
1408
- L: 62,
1410
+ L: 63,
1409
1411
  S: void 0,
1410
1412
  A: [
1411
1413
  "context.newAutomergeRoot",
@@ -1852,8 +1854,7 @@ var NotarizationTeleportExtension = class extends RpcExtension {
1852
1854
  exposed: {
1853
1855
  NotarizationService: schema2.getService("dxos.mesh.teleport.notarization.NotarizationService")
1854
1856
  }
1855
- });
1856
- this._params = _params;
1857
+ }), this._params = _params;
1857
1858
  }
1858
1859
  async getHandlers() {
1859
1860
  return {
@@ -1934,14 +1935,14 @@ var DefaultSpaceStateMachine = class {
1934
1935
  };
1935
1936
 
1936
1937
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
1938
+ import { interpretAsDocumentId } from "@automerge/automerge-repo";
1937
1939
  import { Event as Event4, synchronized, trackLeaks } from "@dxos/async";
1938
- import { interpretAsDocumentId } from "@dxos/automerge/automerge-repo";
1939
1940
  import { PropertiesType, TYPE_PROPERTIES } from "@dxos/client-protocol";
1940
1941
  import { Context as Context4, LifecycleState, Resource as Resource4, cancelWithContext } from "@dxos/context";
1941
1942
  import { createAdmissionCredentials, getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
1942
- import { DatabaseRoot, findInlineObjectOfType, AuthStatus, CredentialServerExtension } from "@dxos/echo-pipeline";
1943
+ import { DatabaseRoot, findInlineObjectOfType, AuthStatus, CredentialServerExtension, FIND_PARAMS } from "@dxos/echo-pipeline";
1943
1944
  import { SpaceDocVersion, createIdFromSpaceKey, encodeReference } from "@dxos/echo-protocol";
1944
- import { createObjectId, getTypeReference } from "@dxos/echo-schema";
1945
+ import { ObjectId, getTypeReference } from "@dxos/echo-schema";
1945
1946
  import { writeMessages } from "@dxos/feed-store";
1946
1947
  import { assertArgument, assertState, failedInvariant, invariant as invariant5 } from "@dxos/invariant";
1947
1948
  import { PublicKey as PublicKey5 } from "@dxos/keys";
@@ -2064,10 +2065,11 @@ var DataSpaceManager = class extends Resource4 {
2064
2065
  id: "spaces",
2065
2066
  name: "Spaces",
2066
2067
  fetch: async () => {
2067
- return Array.from(this._spaces.values()).map((space) => {
2068
+ return Promise.all(Array.from(this._spaces.values()).map(async (space) => {
2068
2069
  const rootUrl = space.automergeSpaceState.rootUrl;
2069
- const rootHandle = rootUrl ? this._echoHost.automergeRepo.find(rootUrl) : void 0;
2070
- const rootDoc = rootHandle?.docSync();
2070
+ const rootHandle = rootUrl ? await this._echoHost.automergeRepo.find(rootUrl, FIND_PARAMS) : void 0;
2071
+ await rootHandle?.whenReady();
2072
+ const rootDoc = rootHandle?.doc();
2071
2073
  const properties = rootDoc && findInlineObjectOfType(rootDoc, TYPE_PROPERTIES);
2072
2074
  return {
2073
2075
  key: space.key.toHex(),
@@ -2079,7 +2081,7 @@ var DataSpaceManager = class extends Resource4 {
2079
2081
  members: space.inner.spaceState.members.size,
2080
2082
  rootUrl
2081
2083
  };
2082
- });
2084
+ }));
2083
2085
  }
2084
2086
  });
2085
2087
  }
@@ -2095,7 +2097,7 @@ var DataSpaceManager = class extends Resource4 {
2095
2097
  async _open() {
2096
2098
  log7("open", void 0, {
2097
2099
  F: __dxlog_file10,
2098
- L: 213,
2100
+ L: 215,
2099
2101
  S: this,
2100
2102
  C: (f, a) => f(...a)
2101
2103
  });
@@ -2103,7 +2105,7 @@ var DataSpaceManager = class extends Resource4 {
2103
2105
  id: this._instanceId
2104
2106
  }), {
2105
2107
  F: __dxlog_file10,
2106
- L: 214,
2108
+ L: 216,
2107
2109
  S: this,
2108
2110
  C: (f, a) => f(...a)
2109
2111
  });
@@ -2111,7 +2113,7 @@ var DataSpaceManager = class extends Resource4 {
2111
2113
  spaces: this._metadataStore.spaces.length
2112
2114
  }, {
2113
2115
  F: __dxlog_file10,
2114
- L: 215,
2116
+ L: 217,
2115
2117
  S: this,
2116
2118
  C: (f, a) => f(...a)
2117
2119
  });
@@ -2121,7 +2123,7 @@ var DataSpaceManager = class extends Resource4 {
2121
2123
  spaceMetadata
2122
2124
  }, {
2123
2125
  F: __dxlog_file10,
2124
- L: 219,
2126
+ L: 221,
2125
2127
  S: this,
2126
2128
  C: (f, a) => f(...a)
2127
2129
  });
@@ -2132,7 +2134,7 @@ var DataSpaceManager = class extends Resource4 {
2132
2134
  err
2133
2135
  }, {
2134
2136
  F: __dxlog_file10,
2135
- L: 222,
2137
+ L: 224,
2136
2138
  S: this,
2137
2139
  C: (f, a) => f(...a)
2138
2140
  });
@@ -2143,7 +2145,7 @@ var DataSpaceManager = class extends Resource4 {
2143
2145
  id: this._instanceId
2144
2146
  }), {
2145
2147
  F: __dxlog_file10,
2146
- L: 228,
2148
+ L: 230,
2147
2149
  S: this,
2148
2150
  C: (f, a) => f(...a)
2149
2151
  });
@@ -2151,7 +2153,7 @@ var DataSpaceManager = class extends Resource4 {
2151
2153
  async _close() {
2152
2154
  log7("close", void 0, {
2153
2155
  F: __dxlog_file10,
2154
- L: 233,
2156
+ L: 235,
2155
2157
  S: this,
2156
2158
  C: (f, a) => f(...a)
2157
2159
  });
@@ -2182,7 +2184,7 @@ var DataSpaceManager = class extends Resource4 {
2182
2184
  spaceKey
2183
2185
  }, {
2184
2186
  F: __dxlog_file10,
2185
- L: 262,
2187
+ L: 264,
2186
2188
  S: this,
2187
2189
  C: (f, a) => f(...a)
2188
2190
  });
@@ -2190,7 +2192,7 @@ var DataSpaceManager = class extends Resource4 {
2190
2192
  if (options.documents) {
2191
2193
  invariant5(Object.keys(options.documents).every((documentId) => /^[a-zA-Z0-9]+$/.test(documentId)), "Invalid document IDs", {
2192
2194
  F: __dxlog_file10,
2193
- L: 267,
2195
+ L: 269,
2194
2196
  S: this,
2195
2197
  A: [
2196
2198
  "Object.keys(options.documents).every((documentId) => /^[a-zA-Z0-9]+$/.test(documentId))",
@@ -2202,7 +2204,7 @@ var DataSpaceManager = class extends Resource4 {
2202
2204
  documentId
2203
2205
  }, {
2204
2206
  F: __dxlog_file10,
2205
- L: 274,
2207
+ L: 276,
2206
2208
  S: this,
2207
2209
  C: (f, a) => f(...a)
2208
2210
  });
@@ -2216,7 +2218,7 @@ var DataSpaceManager = class extends Resource4 {
2216
2218
  spaceKey
2217
2219
  }, {
2218
2220
  F: __dxlog_file10,
2219
- L: 281,
2221
+ L: 283,
2220
2222
  S: this,
2221
2223
  C: (f, a) => f(...a)
2222
2224
  });
@@ -2225,7 +2227,7 @@ var DataSpaceManager = class extends Resource4 {
2225
2227
  const newRootDocId = documentIdMapping[interpretAsDocumentId(options.rootUrl)] ?? failedInvariant();
2226
2228
  const rootDocHandle = await this._echoHost.loadDoc(Context4.default(void 0, {
2227
2229
  F: __dxlog_file10,
2228
- L: 286
2230
+ L: 288
2229
2231
  }), newRootDocId);
2230
2232
  DatabaseRoot.mapLinks(rootDocHandle, documentIdMapping);
2231
2233
  root = await this._echoHost.openSpaceRoot(spaceId, `automerge:${newRootDocId}`);
@@ -2236,7 +2238,7 @@ var DataSpaceManager = class extends Resource4 {
2236
2238
  spaceKey
2237
2239
  }, {
2238
2240
  F: __dxlog_file10,
2239
- L: 294,
2241
+ L: 296,
2240
2242
  S: this,
2241
2243
  C: (f, a) => f(...a)
2242
2244
  });
@@ -2246,7 +2248,7 @@ var DataSpaceManager = class extends Resource4 {
2246
2248
  spaceKey
2247
2249
  }, {
2248
2250
  F: __dxlog_file10,
2249
- L: 299,
2251
+ L: 301,
2250
2252
  S: this,
2251
2253
  C: (f, a) => f(...a)
2252
2254
  });
@@ -2255,7 +2257,7 @@ var DataSpaceManager = class extends Resource4 {
2255
2257
  const memberCredential = credentials[1];
2256
2258
  invariant5(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2257
2259
  F: __dxlog_file10,
2258
- L: 305,
2260
+ L: 307,
2259
2261
  S: this,
2260
2262
  A: [
2261
2263
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2269,7 +2271,7 @@ var DataSpaceManager = class extends Resource4 {
2269
2271
  spaceKey
2270
2272
  }, {
2271
2273
  F: __dxlog_file10,
2272
- L: 310,
2274
+ L: 312,
2273
2275
  S: this,
2274
2276
  C: (f, a) => f(...a)
2275
2277
  });
@@ -2282,7 +2284,18 @@ var DataSpaceManager = class extends Resource4 {
2282
2284
  }
2283
2285
  switch (space.databaseRoot.getVersion()) {
2284
2286
  case SpaceDocVersion.CURRENT: {
2285
- const [_, properties] = findInlineObjectOfType(space.databaseRoot.docSync(), TYPE_PROPERTIES) ?? [];
2287
+ if (!space.databaseRoot.handle.isReady()) {
2288
+ log7.warn("waiting for space root to be ready", {
2289
+ spaceId: space.id
2290
+ }, {
2291
+ F: __dxlog_file10,
2292
+ L: 325,
2293
+ S: this,
2294
+ C: (f, a) => f(...a)
2295
+ });
2296
+ await space.databaseRoot.handle.whenReady();
2297
+ }
2298
+ const [_, properties] = findInlineObjectOfType(space.databaseRoot.doc(), TYPE_PROPERTIES) ?? [];
2286
2299
  return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
2287
2300
  }
2288
2301
  case SpaceDocVersion.LEGACY: {
@@ -2294,7 +2307,7 @@ var DataSpaceManager = class extends Resource4 {
2294
2307
  spaceId: space.id
2295
2308
  }, {
2296
2309
  F: __dxlog_file10,
2297
- L: 330,
2310
+ L: 336,
2298
2311
  S: this,
2299
2312
  C: (f, a) => f(...a)
2300
2313
  });
@@ -2315,7 +2328,7 @@ var DataSpaceManager = class extends Resource4 {
2315
2328
  keys: []
2316
2329
  }
2317
2330
  };
2318
- const propertiesId = createObjectId();
2331
+ const propertiesId = ObjectId.random();
2319
2332
  document.change((doc) => {
2320
2333
  setDeep(doc, [
2321
2334
  "objects",
@@ -2329,14 +2342,14 @@ var DataSpaceManager = class extends Resource4 {
2329
2342
  const automergeIndex = space.automergeSpaceState.rootUrl;
2330
2343
  invariant5(automergeIndex, void 0, {
2331
2344
  F: __dxlog_file10,
2332
- L: 363,
2345
+ L: 369,
2333
2346
  S: this,
2334
2347
  A: [
2335
2348
  "automergeIndex",
2336
2349
  ""
2337
2350
  ]
2338
2351
  });
2339
- const document = this._echoHost.automergeRepo.find(automergeIndex);
2352
+ const document = await this._echoHost.automergeRepo.find(automergeIndex, FIND_PARAMS);
2340
2353
  await document.whenReady();
2341
2354
  return document;
2342
2355
  }
@@ -2346,13 +2359,13 @@ var DataSpaceManager = class extends Resource4 {
2346
2359
  opts
2347
2360
  }, {
2348
2361
  F: __dxlog_file10,
2349
- L: 372,
2362
+ L: 378,
2350
2363
  S: this,
2351
2364
  C: (f, a) => f(...a)
2352
2365
  });
2353
2366
  invariant5(this._lifecycleState === LifecycleState.OPEN, "Not open.", {
2354
2367
  F: __dxlog_file10,
2355
- L: 373,
2368
+ L: 379,
2356
2369
  S: this,
2357
2370
  A: [
2358
2371
  "this._lifecycleState === LifecycleState.OPEN",
@@ -2361,7 +2374,7 @@ var DataSpaceManager = class extends Resource4 {
2361
2374
  });
2362
2375
  invariant5(!this._spaces.has(opts.spaceKey), "Space already exists.", {
2363
2376
  F: __dxlog_file10,
2364
- L: 374,
2377
+ L: 380,
2365
2378
  S: this,
2366
2379
  A: [
2367
2380
  "!this._spaces.has(opts.spaceKey)",
@@ -2385,7 +2398,7 @@ var DataSpaceManager = class extends Resource4 {
2385
2398
  const space = this._spaceManager.spaces.get(options.spaceKey);
2386
2399
  invariant5(space, void 0, {
2387
2400
  F: __dxlog_file10,
2388
- L: 394,
2401
+ L: 400,
2389
2402
  S: this,
2390
2403
  A: [
2391
2404
  "space",
@@ -2398,7 +2411,7 @@ var DataSpaceManager = class extends Resource4 {
2398
2411
  const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
2399
2412
  invariant5(credentials[0].credential, void 0, {
2400
2413
  F: __dxlog_file10,
2401
- L: 413,
2414
+ L: 419,
2402
2415
  S: this,
2403
2416
  A: [
2404
2417
  "credentials[0].credential",
@@ -2408,7 +2421,7 @@ var DataSpaceManager = class extends Resource4 {
2408
2421
  const spaceMemberCredential = credentials[0].credential.credential;
2409
2422
  invariant5(getCredentialAssertion2(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2410
2423
  F: __dxlog_file10,
2411
- L: 415,
2424
+ L: 421,
2412
2425
  S: this,
2413
2426
  A: [
2414
2427
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2446,7 +2459,7 @@ var DataSpaceManager = class extends Resource4 {
2446
2459
  const space = this._spaces.get(spaceKey);
2447
2460
  invariant5(space, "Space not found.", {
2448
2461
  F: __dxlog_file10,
2449
- L: 452,
2462
+ L: 458,
2450
2463
  S: this,
2451
2464
  A: [
2452
2465
  "space",
@@ -2471,7 +2484,7 @@ var DataSpaceManager = class extends Resource4 {
2471
2484
  metadata
2472
2485
  }, {
2473
2486
  F: __dxlog_file10,
2474
- L: 471,
2487
+ L: 477,
2475
2488
  S: this,
2476
2489
  C: (f, a) => f(...a)
2477
2490
  });
@@ -2515,7 +2528,7 @@ var DataSpaceManager = class extends Resource4 {
2515
2528
  err
2516
2529
  }, {
2517
2530
  F: __dxlog_file10,
2518
- L: 513,
2531
+ L: 519,
2519
2532
  S: this,
2520
2533
  C: (f, a) => f(...a)
2521
2534
  });
@@ -2525,7 +2538,7 @@ var DataSpaceManager = class extends Resource4 {
2525
2538
  onAuthFailure: () => {
2526
2539
  log7.warn("auth failure", void 0, {
2527
2540
  F: __dxlog_file10,
2528
- L: 518,
2541
+ L: 524,
2529
2542
  S: this,
2530
2543
  C: (f, a) => f(...a)
2531
2544
  });
@@ -2558,7 +2571,7 @@ var DataSpaceManager = class extends Resource4 {
2558
2571
  space: space.key
2559
2572
  }, {
2560
2573
  F: __dxlog_file10,
2561
- L: 545,
2574
+ L: 551,
2562
2575
  S: this,
2563
2576
  C: (f, a) => f(...a)
2564
2577
  });
@@ -2569,7 +2582,7 @@ var DataSpaceManager = class extends Resource4 {
2569
2582
  open: this._lifecycleState === LifecycleState.OPEN
2570
2583
  }, {
2571
2584
  F: __dxlog_file10,
2572
- L: 548,
2585
+ L: 554,
2573
2586
  S: this,
2574
2587
  C: (f, a) => f(...a)
2575
2588
  });
@@ -2588,7 +2601,7 @@ var DataSpaceManager = class extends Resource4 {
2588
2601
  space: space.key
2589
2602
  }, {
2590
2603
  F: __dxlog_file10,
2591
- L: 556,
2604
+ L: 562,
2592
2605
  S: this,
2593
2606
  C: (f, a) => f(...a)
2594
2607
  });
@@ -2609,7 +2622,7 @@ var DataSpaceManager = class extends Resource4 {
2609
2622
  spaceId: dataSpace.id
2610
2623
  }, {
2611
2624
  F: __dxlog_file10,
2612
- L: 570,
2625
+ L: 576,
2613
2626
  S: this,
2614
2627
  C: (f, a) => f(...a)
2615
2628
  });
@@ -2639,7 +2652,7 @@ var DataSpaceManager = class extends Resource4 {
2639
2652
  space: space.key
2640
2653
  }, {
2641
2654
  F: __dxlog_file10,
2642
- L: 597,
2655
+ L: 603,
2643
2656
  S: this,
2644
2657
  C: (f, a) => f(...a)
2645
2658
  });
@@ -2672,7 +2685,7 @@ var DataSpaceManager = class extends Resource4 {
2672
2685
  closedSessions
2673
2686
  }, {
2674
2687
  F: __dxlog_file10,
2675
- L: 623,
2688
+ L: 629,
2676
2689
  S: this,
2677
2690
  C: (f, a) => f(...a)
2678
2691
  });
@@ -2687,7 +2700,7 @@ var DataSpaceManager = class extends Resource4 {
2687
2700
  peerId: peerState.peerId
2688
2701
  }, {
2689
2702
  F: __dxlog_file10,
2690
- L: 637,
2703
+ L: 643,
2691
2704
  S: this,
2692
2705
  C: (f, a) => f(...a)
2693
2706
  });
@@ -2832,7 +2845,7 @@ var extractSpaceArchive = async (archive) => {
2832
2845
  const documentId = entry2.fileName.replace(`${SpaceArchiveFileStructure2.documents}/`, "").replace(/\.bin$/, "");
2833
2846
  invariant6(!documentId.includes("/"), void 0, {
2834
2847
  F: __dxlog_file11,
2835
- L: 27,
2848
+ L: 28,
2836
2849
  S: void 0,
2837
2850
  A: [
2838
2851
  "!documentId.includes('/')",
@@ -2846,7 +2859,7 @@ var extractSpaceArchive = async (archive) => {
2846
2859
  documents
2847
2860
  }, {
2848
2861
  F: __dxlog_file11,
2849
- L: 31,
2862
+ L: 32,
2850
2863
  S: void 0,
2851
2864
  C: (f, a) => f(...a)
2852
2865
  });
@@ -2857,67 +2870,70 @@ var extractSpaceArchive = async (archive) => {
2857
2870
  };
2858
2871
 
2859
2872
  // packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
2860
- function _using_ctx2() {
2861
- var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
2862
- var err = new Error();
2863
- err.name = "SuppressedError";
2864
- err.suppressed = suppressed;
2865
- err.error = error;
2866
- return err;
2867
- }, empty = {}, stack = [];
2868
- function using(isAwait, value) {
2869
- if (value != null) {
2870
- if (Object(value) !== value) {
2871
- throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
2872
- }
2873
- if (isAwait) {
2874
- var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
2875
- }
2876
- if (dispose == null) {
2877
- dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
2878
- }
2879
- if (typeof dispose !== "function") {
2880
- throw new TypeError(`Property [Symbol.dispose] is not a function.`);
2881
- }
2882
- stack.push({
2883
- v: value,
2884
- d: dispose,
2885
- a: isAwait
2886
- });
2887
- } else if (isAwait) {
2888
- stack.push({
2889
- d: value,
2890
- a: isAwait
2891
- });
2892
- }
2893
- return value;
2873
+ function _ts_add_disposable_resource2(env, value, async) {
2874
+ if (value !== null && value !== void 0) {
2875
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
2876
+ var dispose, inner;
2877
+ if (async) {
2878
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
2879
+ dispose = value[Symbol.asyncDispose];
2880
+ }
2881
+ if (dispose === void 0) {
2882
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
2883
+ dispose = value[Symbol.dispose];
2884
+ if (async) inner = dispose;
2885
+ }
2886
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
2887
+ if (inner) dispose = function() {
2888
+ try {
2889
+ inner.call(this);
2890
+ } catch (e) {
2891
+ return Promise.reject(e);
2892
+ }
2893
+ };
2894
+ env.stack.push({
2895
+ value,
2896
+ dispose,
2897
+ async
2898
+ });
2899
+ } else if (async) {
2900
+ env.stack.push({
2901
+ async: true
2902
+ });
2894
2903
  }
2895
- return {
2896
- e: empty,
2897
- u: using.bind(null, false),
2898
- a: using.bind(null, true),
2899
- d: function() {
2900
- var error = this.e;
2901
- function next() {
2902
- while (resource = stack.pop()) {
2903
- try {
2904
- var resource, disposalResult = resource.d && resource.d.call(resource.v);
2905
- if (resource.a) {
2906
- return Promise.resolve(disposalResult).then(next, err);
2907
- }
2908
- } catch (e) {
2909
- return err(e);
2910
- }
2904
+ return value;
2905
+ }
2906
+ function _ts_dispose_resources2(env) {
2907
+ var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
2908
+ var e = new Error(message);
2909
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
2910
+ };
2911
+ return (_ts_dispose_resources2 = function _ts_dispose_resources5(env2) {
2912
+ function fail(e) {
2913
+ env2.error = env2.hasError ? new _SuppressedError(e, env2.error, "An error was suppressed during disposal.") : e;
2914
+ env2.hasError = true;
2915
+ }
2916
+ var r, s = 0;
2917
+ function next() {
2918
+ while (r = env2.stack.pop()) {
2919
+ try {
2920
+ if (!r.async && s === 1) return s = 0, env2.stack.push(r), Promise.resolve().then(next);
2921
+ if (r.dispose) {
2922
+ var result = r.dispose.call(r.value);
2923
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) {
2924
+ fail(e);
2925
+ return next();
2926
+ });
2927
+ } else s |= 1;
2928
+ } catch (e) {
2929
+ fail(e);
2911
2930
  }
2912
- if (error !== empty) throw error;
2913
- }
2914
- function err(e) {
2915
- error = error !== empty ? new _disposeSuppressedError(error, e) : e;
2916
- return next();
2917
2931
  }
2918
- return next();
2932
+ if (s === 1) return env2.hasError ? Promise.reject(env2.error) : Promise.resolve();
2933
+ if (env2.hasError) throw env2.error;
2919
2934
  }
2920
- };
2935
+ return next();
2936
+ })(env);
2921
2937
  }
2922
2938
  var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
2923
2939
  var SpacesServiceImpl = class {
@@ -2967,7 +2983,7 @@ var SpacesServiceImpl = class {
2967
2983
  const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
2968
2984
  invariant7(credentials[0].credential, void 0, {
2969
2985
  F: __dxlog_file12,
2970
- L: 118,
2986
+ L: 119,
2971
2987
  S: this,
2972
2988
  A: [
2973
2989
  "credentials[0].credential",
@@ -2977,7 +2993,7 @@ var SpacesServiceImpl = class {
2977
2993
  const spaceMemberCredential = credentials[0].credential.credential;
2978
2994
  invariant7(getCredentialAssertion3(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2979
2995
  F: __dxlog_file12,
2980
- L: 120,
2996
+ L: 121,
2981
2997
  S: this,
2982
2998
  A: [
2983
2999
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2995,7 +3011,7 @@ var SpacesServiceImpl = class {
2995
3011
  ids: spaces.map((space) => space.id)
2996
3012
  }), {
2997
3013
  F: __dxlog_file12,
2998
- L: 133,
3014
+ L: 134,
2999
3015
  S: this,
3000
3016
  C: (f, a) => f(...a)
3001
3017
  });
@@ -3087,7 +3103,7 @@ var SpacesServiceImpl = class {
3087
3103
  } else {
3088
3104
  invariant7(!credential.id, "Id on unsigned credentials is not allowed", {
3089
3105
  F: __dxlog_file12,
3090
- L: 231,
3106
+ L: 232,
3091
3107
  S: this,
3092
3108
  A: [
3093
3109
  "!credential.id",
@@ -3096,7 +3112,7 @@ var SpacesServiceImpl = class {
3096
3112
  });
3097
3113
  invariant7(this._identityManager.identity, "Identity is not available", {
3098
3114
  F: __dxlog_file12,
3099
- L: 232,
3115
+ L: 233,
3100
3116
  S: this,
3101
3117
  A: [
3102
3118
  "this._identityManager.identity",
@@ -3106,7 +3122,7 @@ var SpacesServiceImpl = class {
3106
3122
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
3107
3123
  invariant7(credential.issuer.equals(signer.getIssuer()), void 0, {
3108
3124
  F: __dxlog_file12,
3109
- L: 234,
3125
+ L: 235,
3110
3126
  S: this,
3111
3127
  A: [
3112
3128
  "credential.issuer.equals(signer.getIssuer())",
@@ -3153,9 +3169,13 @@ var SpacesServiceImpl = class {
3153
3169
  });
3154
3170
  }
3155
3171
  async exportSpace(request) {
3172
+ const env = {
3173
+ stack: [],
3174
+ error: void 0,
3175
+ hasError: false
3176
+ };
3156
3177
  try {
3157
- var _usingCtx = _using_ctx2();
3158
- const writer = _usingCtx.a(await new SpaceArchiveWriter().open());
3178
+ const writer = _ts_add_disposable_resource2(env, await new SpaceArchiveWriter().open(), true);
3159
3179
  assertArgument4(SpaceId2.isValid(request.spaceId), "Invalid space ID");
3160
3180
  const dataSpaceManager = await this._getDataSpaceManager();
3161
3181
  const space = dataSpaceManager.getSpaceById(request.spaceId) ?? raise(new Error("Space not found"));
@@ -3172,10 +3192,12 @@ var SpacesServiceImpl = class {
3172
3192
  return {
3173
3193
  archive
3174
3194
  };
3175
- } catch (_) {
3176
- _usingCtx.e = _;
3195
+ } catch (e) {
3196
+ env.error = e;
3197
+ env.hasError = true;
3177
3198
  } finally {
3178
- await _usingCtx.d();
3199
+ const result = _ts_dispose_resources2(env);
3200
+ if (result) await result;
3179
3201
  }
3180
3202
  }
3181
3203
  async importSpace(request) {
@@ -3183,7 +3205,7 @@ var SpacesServiceImpl = class {
3183
3205
  const extracted = await extractSpaceArchive(request.archive);
3184
3206
  invariant7(extracted.metadata.echo?.currentRootUrl, "Space archive does not contain a root URL", {
3185
3207
  F: __dxlog_file12,
3186
- L: 288,
3208
+ L: 289,
3187
3209
  S: this,
3188
3210
  A: [
3189
3211
  "extracted.metadata.echo?.currentRootUrl",
@@ -3203,7 +3225,7 @@ var SpacesServiceImpl = class {
3203
3225
  const assertion = getCredentialAssertion3(credential);
3204
3226
  invariant7(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
3205
3227
  F: __dxlog_file12,
3206
- L: 299,
3228
+ L: 300,
3207
3229
  S: this,
3208
3230
  A: [
3209
3231
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -3213,7 +3235,7 @@ var SpacesServiceImpl = class {
3213
3235
  const myIdentity = this._identityManager.identity;
3214
3236
  invariant7(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
3215
3237
  F: __dxlog_file12,
3216
- L: 301,
3238
+ L: 302,
3217
3239
  S: this,
3218
3240
  A: [
3219
3241
  "myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
@@ -3613,7 +3635,7 @@ var IdentityManager = class {
3613
3635
  L: 135
3614
3636
  }));
3615
3637
  }
3616
- async createIdentity({ displayName, deviceProfile } = {}) {
3638
+ async createIdentity({ profile, deviceProfile } = {}) {
3617
3639
  invariant9(!this._identity, "Identity already exists.", {
3618
3640
  F: __dxlog_file14,
3619
3641
  L: 140,
@@ -3671,10 +3693,8 @@ var IdentityManager = class {
3671
3693
  // Feed admission.
3672
3694
  await generator.createFeedAdmission(identityRecord.haloSpace.key, identityRecord.haloSpace.dataFeedKey, AdmittedFeed3.Designation.DATA)
3673
3695
  ];
3674
- if (displayName) {
3675
- credentials.push(await generator.createProfileCredential({
3676
- displayName
3677
- }));
3696
+ if (profile) {
3697
+ credentials.push(await generator.createProfileCredential(profile));
3678
3698
  }
3679
3699
  credentials.push(await generator.createDeviceAuthorization(identityRecord.deviceKey));
3680
3700
  credentials.push(await generator.createDeviceProfile({
@@ -3791,7 +3811,7 @@ var IdentityManager = class {
3791
3811
  displayName: this._identity.profileDocument?.displayName
3792
3812
  }, {
3793
3813
  F: __dxlog_file14,
3794
- L: 273,
3814
+ L: 277,
3795
3815
  S: this,
3796
3816
  C: (f, a) => f(...a)
3797
3817
  });
@@ -3805,7 +3825,7 @@ var IdentityManager = class {
3805
3825
  deviceKey: identity.deviceKey
3806
3826
  }, {
3807
3827
  F: __dxlog_file14,
3808
- L: 284,
3828
+ L: 288,
3809
3829
  S: this,
3810
3830
  C: (f, a) => f(...a)
3811
3831
  });
@@ -3816,7 +3836,7 @@ var IdentityManager = class {
3816
3836
  async updateProfile(profile) {
3817
3837
  invariant9(this._identity, "Identity not initialized.", {
3818
3838
  F: __dxlog_file14,
3819
- L: 291,
3839
+ L: 295,
3820
3840
  S: this,
3821
3841
  A: [
3822
3842
  "this._identity",
@@ -3847,7 +3867,7 @@ var IdentityManager = class {
3847
3867
  async updateDeviceProfile(profile) {
3848
3868
  invariant9(this._identity, "Identity not initialized.", {
3849
3869
  F: __dxlog_file14,
3850
- L: 308,
3870
+ L: 312,
3851
3871
  S: this,
3852
3872
  A: [
3853
3873
  "this._identity",
@@ -3883,7 +3903,7 @@ var IdentityManager = class {
3883
3903
  async _constructIdentity(identityRecord) {
3884
3904
  invariant9(!this._identity, void 0, {
3885
3905
  F: __dxlog_file14,
3886
- L: 334,
3906
+ L: 338,
3887
3907
  S: this,
3888
3908
  A: [
3889
3909
  "!this._identity",
@@ -3894,7 +3914,7 @@ var IdentityManager = class {
3894
3914
  identityRecord
3895
3915
  }, {
3896
3916
  F: __dxlog_file14,
3897
- L: 335,
3917
+ L: 339,
3898
3918
  S: this,
3899
3919
  C: (f, a) => f(...a)
3900
3920
  });
@@ -3909,7 +3929,7 @@ var IdentityManager = class {
3909
3929
  });
3910
3930
  invariant9(identityRecord.haloSpace.controlFeedKey, void 0, {
3911
3931
  F: __dxlog_file14,
3912
- L: 348,
3932
+ L: 352,
3913
3933
  S: this,
3914
3934
  A: [
3915
3935
  "identityRecord.haloSpace.controlFeedKey",
@@ -3921,7 +3941,7 @@ var IdentityManager = class {
3921
3941
  });
3922
3942
  invariant9(identityRecord.haloSpace.dataFeedKey, void 0, {
3923
3943
  F: __dxlog_file14,
3924
- L: 352,
3944
+ L: 356,
3925
3945
  S: this,
3926
3946
  A: [
3927
3947
  "identityRecord.haloSpace.dataFeedKey",
@@ -3960,7 +3980,7 @@ var IdentityManager = class {
3960
3980
  identityKey: identityRecord.identityKey
3961
3981
  }, {
3962
3982
  F: __dxlog_file14,
3963
- L: 383,
3983
+ L: 387,
3964
3984
  S: this,
3965
3985
  C: (f, a) => f(...a)
3966
3986
  });
@@ -3985,7 +4005,7 @@ var IdentityManager = class {
3985
4005
  onAuthFailure: () => {
3986
4006
  log11.warn("auth failure", void 0, {
3987
4007
  F: __dxlog_file14,
3988
- L: 408,
4008
+ L: 412,
3989
4009
  S: this,
3990
4010
  C: (f, a) => f(...a)
3991
4011
  });
@@ -4020,13 +4040,7 @@ var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
4020
4040
  var DEFAULT_SPACE_SEARCH_TIMEOUT = 1e4;
4021
4041
  var IdentityServiceImpl = class extends Resource6 {
4022
4042
  constructor(_identityManager, _recoveryManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
4023
- super();
4024
- this._identityManager = _identityManager;
4025
- this._recoveryManager = _recoveryManager;
4026
- this._keyring = _keyring;
4027
- this._dataSpaceManagerProvider = _dataSpaceManagerProvider;
4028
- this._createIdentity = _createIdentity;
4029
- this._onProfileUpdate = _onProfileUpdate;
4043
+ super(), this._identityManager = _identityManager, this._recoveryManager = _recoveryManager, this._keyring = _keyring, this._dataSpaceManagerProvider = _dataSpaceManagerProvider, this._createIdentity = _createIdentity, this._onProfileUpdate = _onProfileUpdate;
4030
4044
  }
4031
4045
  async _open() {
4032
4046
  const identity = this._identityManager.identity;
@@ -4036,7 +4050,7 @@ var IdentityServiceImpl = class extends Resource6 {
4036
4050
  }
4037
4051
  async createIdentity(request) {
4038
4052
  await this._createIdentity({
4039
- displayName: request.profile?.displayName,
4053
+ profile: request.profile,
4040
4054
  deviceProfile: request.deviceProfile
4041
4055
  });
4042
4056
  const dataSpaceManager = this._dataSpaceManagerProvider();
@@ -4211,74 +4225,77 @@ function _ts_decorate6(decorators, target, key, desc) {
4211
4225
  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;
4212
4226
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4213
4227
  }
4214
- function _using_ctx3() {
4215
- var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
4216
- var err = new Error();
4217
- err.name = "SuppressedError";
4218
- err.suppressed = suppressed;
4219
- err.error = error;
4220
- return err;
4221
- }, empty = {}, stack = [];
4222
- function using(isAwait, value) {
4223
- if (value != null) {
4224
- if (Object(value) !== value) {
4225
- throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
4226
- }
4227
- if (isAwait) {
4228
- var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
4229
- }
4230
- if (dispose == null) {
4231
- dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
4232
- }
4233
- if (typeof dispose !== "function") {
4234
- throw new TypeError(`Property [Symbol.dispose] is not a function.`);
4235
- }
4236
- stack.push({
4237
- v: value,
4238
- d: dispose,
4239
- a: isAwait
4240
- });
4241
- } else if (isAwait) {
4242
- stack.push({
4243
- d: value,
4244
- a: isAwait
4245
- });
4246
- }
4247
- return value;
4228
+ function _ts_add_disposable_resource3(env, value, async) {
4229
+ if (value !== null && value !== void 0) {
4230
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
4231
+ var dispose, inner;
4232
+ if (async) {
4233
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
4234
+ dispose = value[Symbol.asyncDispose];
4235
+ }
4236
+ if (dispose === void 0) {
4237
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
4238
+ dispose = value[Symbol.dispose];
4239
+ if (async) inner = dispose;
4240
+ }
4241
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
4242
+ if (inner) dispose = function() {
4243
+ try {
4244
+ inner.call(this);
4245
+ } catch (e) {
4246
+ return Promise.reject(e);
4247
+ }
4248
+ };
4249
+ env.stack.push({
4250
+ value,
4251
+ dispose,
4252
+ async
4253
+ });
4254
+ } else if (async) {
4255
+ env.stack.push({
4256
+ async: true
4257
+ });
4248
4258
  }
4249
- return {
4250
- e: empty,
4251
- u: using.bind(null, false),
4252
- a: using.bind(null, true),
4253
- d: function() {
4254
- var error = this.e;
4255
- function next() {
4256
- while (resource = stack.pop()) {
4257
- try {
4258
- var resource, disposalResult = resource.d && resource.d.call(resource.v);
4259
- if (resource.a) {
4260
- return Promise.resolve(disposalResult).then(next, err);
4261
- }
4262
- } catch (e) {
4263
- return err(e);
4264
- }
4259
+ return value;
4260
+ }
4261
+ function _ts_dispose_resources3(env) {
4262
+ var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
4263
+ var e = new Error(message);
4264
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
4265
+ };
4266
+ return (_ts_dispose_resources3 = function _ts_dispose_resources5(env2) {
4267
+ function fail(e) {
4268
+ env2.error = env2.hasError ? new _SuppressedError(e, env2.error, "An error was suppressed during disposal.") : e;
4269
+ env2.hasError = true;
4270
+ }
4271
+ var r, s = 0;
4272
+ function next() {
4273
+ while (r = env2.stack.pop()) {
4274
+ try {
4275
+ if (!r.async && s === 1) return s = 0, env2.stack.push(r), Promise.resolve().then(next);
4276
+ if (r.dispose) {
4277
+ var result = r.dispose.call(r.value);
4278
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) {
4279
+ fail(e);
4280
+ return next();
4281
+ });
4282
+ } else s |= 1;
4283
+ } catch (e) {
4284
+ fail(e);
4265
4285
  }
4266
- if (error !== empty) throw error;
4267
4286
  }
4268
- function err(e) {
4269
- error = error !== empty ? new _disposeSuppressedError(error, e) : e;
4270
- return next();
4271
- }
4272
- return next();
4287
+ if (s === 1) return env2.hasError ? Promise.reject(env2.error) : Promise.resolve();
4288
+ if (env2.hasError) throw env2.error;
4273
4289
  }
4274
- };
4290
+ return next();
4291
+ })(env);
4275
4292
  }
4276
4293
  var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
4277
4294
  var DataSpace = class {
4278
4295
  constructor(params) {
4279
4296
  this._ctx = new Context6(void 0, {
4280
4297
  F: __dxlog_file16,
4281
- L: 97
4298
+ L: 100
4282
4299
  });
4283
4300
  this._cache = void 0;
4284
4301
  this._edgeFeedReplicator = void 0;
@@ -4331,7 +4348,7 @@ var DataSpace = class {
4331
4348
  state: SpaceState4[this._state]
4332
4349
  }, {
4333
4350
  F: __dxlog_file16,
4334
- L: 173,
4351
+ L: 176,
4335
4352
  S: this,
4336
4353
  C: (f, a) => f(...a)
4337
4354
  });
@@ -4390,7 +4407,7 @@ var DataSpace = class {
4390
4407
  }
4391
4408
  await this._inner.open(new Context6(void 0, {
4392
4409
  F: __dxlog_file16,
4393
- L: 247
4410
+ L: 250
4394
4411
  }));
4395
4412
  await this._inner.startProtocol();
4396
4413
  await this._edgeFeedReplicator?.open();
@@ -4399,7 +4416,7 @@ var DataSpace = class {
4399
4416
  state: SpaceState4[this._state]
4400
4417
  }, {
4401
4418
  F: __dxlog_file16,
4402
- L: 253,
4419
+ L: 256,
4403
4420
  S: this,
4404
4421
  C: (f, a) => f(...a)
4405
4422
  });
@@ -4419,14 +4436,14 @@ var DataSpace = class {
4419
4436
  state: SpaceState4[this._state]
4420
4437
  }, {
4421
4438
  F: __dxlog_file16,
4422
- L: 272,
4439
+ L: 275,
4423
4440
  S: this,
4424
4441
  C: (f, a) => f(...a)
4425
4442
  });
4426
4443
  await this._ctx.dispose();
4427
4444
  this._ctx = new Context6(void 0, {
4428
4445
  F: __dxlog_file16,
4429
- L: 274
4446
+ L: 277
4430
4447
  });
4431
4448
  if (this._edgeFeedReplicator) {
4432
4449
  this.inner.protocol.feedAdded.remove(this._onFeedAdded);
@@ -4459,7 +4476,7 @@ var DataSpace = class {
4459
4476
  if (err instanceof CancelledError || err instanceof ContextDisposedError) {
4460
4477
  log13("data pipeline initialization cancelled", err, {
4461
4478
  F: __dxlog_file16,
4462
- L: 312,
4479
+ L: 315,
4463
4480
  S: this,
4464
4481
  C: (f, a) => f(...a)
4465
4482
  });
@@ -4467,7 +4484,7 @@ var DataSpace = class {
4467
4484
  }
4468
4485
  log13.error("Error initializing data pipeline", err, {
4469
4486
  F: __dxlog_file16,
4470
- L: 316,
4487
+ L: 319,
4471
4488
  S: this,
4472
4489
  C: (f, a) => f(...a)
4473
4490
  });
@@ -4476,7 +4493,7 @@ var DataSpace = class {
4476
4493
  state: SpaceState4[this._state]
4477
4494
  }, {
4478
4495
  F: __dxlog_file16,
4479
- L: 318,
4496
+ L: 321,
4480
4497
  S: this,
4481
4498
  C: (f, a) => f(...a)
4482
4499
  });
@@ -4496,13 +4513,13 @@ var DataSpace = class {
4496
4513
  state: SpaceState4[this._state]
4497
4514
  }, {
4498
4515
  F: __dxlog_file16,
4499
- L: 334,
4516
+ L: 337,
4500
4517
  S: this,
4501
4518
  C: (f, a) => f(...a)
4502
4519
  });
4503
4520
  log13("initializing control pipeline", void 0, {
4504
4521
  F: __dxlog_file16,
4505
- L: 336,
4522
+ L: 339,
4506
4523
  S: this,
4507
4524
  C: (f, a) => f(...a)
4508
4525
  });
@@ -4511,21 +4528,21 @@ var DataSpace = class {
4511
4528
  const ready = this.stateUpdate.waitForCondition(() => this._state === SpaceState4.SPACE_READY);
4512
4529
  log13("initializing automerge root", void 0, {
4513
4530
  F: __dxlog_file16,
4514
- L: 344,
4531
+ L: 347,
4515
4532
  S: this,
4516
4533
  C: (f, a) => f(...a)
4517
4534
  });
4518
4535
  this._automergeSpaceState.startProcessingRootDocs();
4519
4536
  log13("waiting for space to be ready", void 0, {
4520
4537
  F: __dxlog_file16,
4521
- L: 348,
4538
+ L: 351,
4522
4539
  S: this,
4523
4540
  C: (f, a) => f(...a)
4524
4541
  });
4525
4542
  await ready;
4526
4543
  log13("space is ready", void 0, {
4527
4544
  F: __dxlog_file16,
4528
- L: 350,
4545
+ L: 353,
4529
4546
  S: this,
4530
4547
  C: (f, a) => f(...a)
4531
4548
  });
@@ -4533,14 +4550,14 @@ var DataSpace = class {
4533
4550
  async *getAllDocuments() {
4534
4551
  invariant11(this._databaseRoot, "Space is not ready", {
4535
4552
  F: __dxlog_file16,
4536
- L: 354,
4553
+ L: 357,
4537
4554
  S: this,
4538
4555
  A: [
4539
4556
  "this._databaseRoot",
4540
4557
  "'Space is not ready'"
4541
4558
  ]
4542
4559
  });
4543
- const doc = this._databaseRoot.docSync() ?? failedInvariant3();
4560
+ const doc = this._databaseRoot.doc() ?? failedInvariant3();
4544
4561
  const root = save(doc);
4545
4562
  yield [
4546
4563
  this._databaseRoot.documentId,
@@ -4549,7 +4566,7 @@ var DataSpace = class {
4549
4566
  for (const documentUrl of this._databaseRoot.getAllLinkedDocuments()) {
4550
4567
  const data = await this._echoHost.exportDoc(Context6.default(void 0, {
4551
4568
  F: __dxlog_file16,
4552
- L: 360
4569
+ L: 363
4553
4570
  }), documentUrl);
4554
4571
  yield [
4555
4572
  documentUrl.replace(/^automerge:/, ""),
@@ -4564,7 +4581,7 @@ var DataSpace = class {
4564
4581
  state: SpaceState4[this._state]
4565
4582
  }, {
4566
4583
  F: __dxlog_file16,
4567
- L: 369,
4584
+ L: 372,
4568
4585
  S: this,
4569
4586
  C: (f, a) => f(...a)
4570
4587
  });
@@ -4581,7 +4598,7 @@ var DataSpace = class {
4581
4598
  await this._createWritableFeeds();
4582
4599
  log13("writable feeds created", void 0, {
4583
4600
  F: __dxlog_file16,
4584
- L: 386,
4601
+ L: 389,
4585
4602
  S: this,
4586
4603
  C: (f, a) => f(...a)
4587
4604
  });
@@ -4635,7 +4652,7 @@ var DataSpace = class {
4635
4652
  count: credentials.length
4636
4653
  }, {
4637
4654
  F: __dxlog_file16,
4638
- L: 444,
4655
+ L: 447,
4639
4656
  S: this,
4640
4657
  C: (f, a) => f(...a)
4641
4658
  });
@@ -4646,14 +4663,14 @@ var DataSpace = class {
4646
4663
  });
4647
4664
  log13("credentials notarized", void 0, {
4648
4665
  F: __dxlog_file16,
4649
- L: 448,
4666
+ L: 451,
4650
4667
  S: this,
4651
4668
  C: (f, a) => f(...a)
4652
4669
  });
4653
4670
  } catch (err) {
4654
4671
  log13.error("error notarizing credentials for feed admission", err, {
4655
4672
  F: __dxlog_file16,
4656
- L: 450,
4673
+ L: 453,
4657
4674
  S: this,
4658
4675
  C: (f, a) => f(...a)
4659
4676
  });
@@ -4668,26 +4685,28 @@ var DataSpace = class {
4668
4685
  rootUrl
4669
4686
  }, {
4670
4687
  F: __dxlog_file16,
4671
- L: 460,
4688
+ L: 463,
4672
4689
  S: this,
4673
4690
  C: (f, a) => f(...a)
4674
4691
  });
4675
- const handle = this._echoHost.automergeRepo.find(rootUrl);
4692
+ let handle;
4676
4693
  queueMicrotask(async () => {
4677
4694
  try {
4695
+ const env = {
4696
+ stack: [],
4697
+ error: void 0,
4698
+ hasError: false
4699
+ };
4678
4700
  try {
4679
- var _usingCtx = _using_ctx3();
4680
4701
  await warnAfterTimeout(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
4702
+ handle = await cancelWithContext2(this._ctx, this._echoHost.automergeRepo.find(rootUrl, FIND_PARAMS2));
4681
4703
  await cancelWithContext2(this._ctx, handle.whenReady());
4682
4704
  });
4683
4705
  if (this._ctx.disposed) {
4684
4706
  return;
4685
4707
  }
4686
- const _guard = (
4687
- // Ensure only one root is processed at a time.
4688
- _usingCtx.u(await this._epochProcessingMutex.acquire())
4689
- );
4690
- const doc = handle.docSync() ?? failedInvariant3();
4708
+ const _guard = _ts_add_disposable_resource3(env, await this._epochProcessingMutex.acquire(), false);
4709
+ const doc = handle.doc() ?? failedInvariant3();
4691
4710
  if (!doc.access?.spaceKey) {
4692
4711
  handle.change((doc2) => {
4693
4712
  doc2.access = {
@@ -4705,10 +4724,11 @@ var DataSpace = class {
4705
4724
  } else {
4706
4725
  this.stateUpdate.emit();
4707
4726
  }
4708
- } catch (_) {
4709
- _usingCtx.e = _;
4727
+ } catch (e) {
4728
+ env.error = e;
4729
+ env.hasError = true;
4710
4730
  } finally {
4711
- _usingCtx.d();
4731
+ _ts_dispose_resources3(env);
4712
4732
  }
4713
4733
  } catch (err) {
4714
4734
  if (err instanceof ContextDisposedError) {
@@ -4720,7 +4740,7 @@ var DataSpace = class {
4720
4740
  err
4721
4741
  }, {
4722
4742
  F: __dxlog_file16,
4723
- L: 503,
4743
+ L: 510,
4724
4744
  S: this,
4725
4745
  C: (f, a) => f(...a)
4726
4746
  });
@@ -4810,7 +4830,7 @@ var DataSpace = class {
4810
4830
  state: SpaceState4[this._state]
4811
4831
  }, {
4812
4832
  F: __dxlog_file16,
4813
- L: 585,
4833
+ L: 592,
4814
4834
  S: this,
4815
4835
  C: (f, a) => f(...a)
4816
4836
  });
@@ -5221,15 +5241,10 @@ var InvitationGuestExtension = class extends RpcExtension2 {
5221
5241
  exposed: {
5222
5242
  InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
5223
5243
  }
5224
- });
5225
- this._invitationFlowMutex = _invitationFlowMutex;
5226
- this._callbacks = _callbacks;
5227
- this._ctx = new Context7(void 0, {
5244
+ }), this._invitationFlowMutex = _invitationFlowMutex, this._callbacks = _callbacks, this._ctx = new Context7(void 0, {
5228
5245
  F: __dxlog_file19,
5229
5246
  L: 38
5230
- });
5231
- this._remoteOptionsTrigger = new Trigger5();
5232
- this._invitationFlowLock = null;
5247
+ }), this._remoteOptionsTrigger = new Trigger5(), this._invitationFlowLock = null;
5233
5248
  }
5234
5249
  hasFlowLock() {
5235
5250
  return this._invitationFlowLock != null;
@@ -5358,20 +5373,10 @@ var InvitationHostExtension = class extends RpcExtension3 {
5358
5373
  exposed: {
5359
5374
  InvitationHostService: schema5.getService("dxos.halo.invitations.InvitationHostService")
5360
5375
  }
5361
- });
5362
- this._invitationFlowMutex = _invitationFlowMutex;
5363
- this._callbacks = _callbacks;
5364
- this._ctx = new Context8(void 0, {
5376
+ }), this._invitationFlowMutex = _invitationFlowMutex, this._callbacks = _callbacks, this._ctx = new Context8(void 0, {
5365
5377
  F: __dxlog_file20,
5366
5378
  L: 57
5367
- });
5368
- this._remoteOptionsTrigger = new Trigger6();
5369
- this._challenge = void 0;
5370
- this.guestProfile = void 0;
5371
- this.authenticationPassed = false;
5372
- this.authenticationRetry = 0;
5373
- this.completedTrigger = new Trigger6();
5374
- this._invitationFlowLock = null;
5379
+ }), this._remoteOptionsTrigger = new Trigger6(), this._challenge = void 0, this.guestProfile = void 0, this.authenticationPassed = false, this.authenticationRetry = 0, this.completedTrigger = new Trigger6(), this._invitationFlowLock = null;
5375
5380
  }
5376
5381
  hasFlowLock() {
5377
5382
  return this._invitationFlowLock != null;
@@ -7075,14 +7080,14 @@ var InvitationsManager = class {
7075
7080
  }
7076
7081
  }, {
7077
7082
  F: __dxlog_file25,
7078
- L: 236
7083
+ L: 239
7079
7084
  });
7080
7085
  ctx.onDispose(() => {
7081
7086
  log21("complete", {
7082
7087
  ...handler.toJSON()
7083
7088
  }, {
7084
7089
  F: __dxlog_file25,
7085
- L: 243,
7090
+ L: 246,
7086
7091
  S: this,
7087
7092
  C: (f, a) => f(...a)
7088
7093
  });
@@ -7115,7 +7120,7 @@ var InvitationsManager = class {
7115
7120
  ...handler.toJSON()
7116
7121
  }, {
7117
7122
  F: __dxlog_file25,
7118
- L: 263,
7123
+ L: 274,
7119
7124
  S: this,
7120
7125
  C: (f, a) => f(...a)
7121
7126
  });
@@ -7126,7 +7131,7 @@ var InvitationsManager = class {
7126
7131
  } else {
7127
7132
  log21.warn("auth failed", err, {
7128
7133
  F: __dxlog_file25,
7129
- L: 266,
7134
+ L: 277,
7130
7135
  S: this,
7131
7136
  C: (f, a) => f(...a)
7132
7137
  });
@@ -7139,14 +7144,14 @@ var InvitationsManager = class {
7139
7144
  }
7140
7145
  }, {
7141
7146
  F: __dxlog_file25,
7142
- L: 260
7147
+ L: 271
7143
7148
  });
7144
7149
  ctx.onDispose(() => {
7145
7150
  log21("complete", {
7146
7151
  ...handler.toJSON()
7147
7152
  }, {
7148
7153
  F: __dxlog_file25,
7149
- L: 273,
7154
+ L: 284,
7150
7155
  S: this,
7151
7156
  C: (f, a) => f(...a)
7152
7157
  });
@@ -7191,7 +7196,7 @@ var InvitationsManager = class {
7191
7196
  } catch (err) {
7192
7197
  log21.catch(err, void 0, {
7193
7198
  F: __dxlog_file25,
7194
- L: 309,
7199
+ L: 320,
7195
7200
  S: this,
7196
7201
  C: (f, a) => f(...a)
7197
7202
  });
@@ -7215,10 +7220,6 @@ function _ts_decorate7(decorators, target, key, desc) {
7215
7220
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7216
7221
  }
7217
7222
  var __dxlog_file26 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
7218
- var Message;
7219
- (function(Message2) {
7220
- Message2["ACQUIRING"] = "acquiring";
7221
- })(Message || (Message = {}));
7222
7223
  var Lock = class {
7223
7224
  constructor({ lockKey, onAcquire, onRelease }) {
7224
7225
  this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
@@ -7422,13 +7423,7 @@ var AGENT_STATUS_QUERY_RETRY_JITTER = 1e3;
7422
7423
  var AGENT_FEED_ADDED_CHECK_INTERVAL_MS = 3e3;
7423
7424
  var EdgeAgentManager = class extends Resource7 {
7424
7425
  constructor(_edgeFeatures, _edgeHttpClient, _dataSpaceManager, _identity) {
7425
- super();
7426
- this._edgeFeatures = _edgeFeatures;
7427
- this._edgeHttpClient = _edgeHttpClient;
7428
- this._dataSpaceManager = _dataSpaceManager;
7429
- this._identity = _identity;
7430
- this.agentStatusChanged = new Event9();
7431
- this._lastKnownDeviceCount = 0;
7426
+ super(), this._edgeFeatures = _edgeFeatures, this._edgeHttpClient = _edgeHttpClient, this._dataSpaceManager = _dataSpaceManager, this._identity = _identity, this.agentStatusChanged = new Event9(), this._lastKnownDeviceCount = 0;
7432
7427
  }
7433
7428
  get agentStatus() {
7434
7429
  return this._agentStatus;
@@ -7646,28 +7641,22 @@ _ts_decorate9([
7646
7641
  // packages/sdk/client-services/src/packlets/agents/edge-agent-service.ts
7647
7642
  import { Stream as Stream11 } from "@dxos/codec-protobuf/stream";
7648
7643
  import { EdgeAgentStatus as EdgeAgentStatus2 } from "@dxos/protocols";
7649
- import { QueryAgentStatusResponse, QueryEdgeStatusResponse } from "@dxos/protocols/proto/dxos/client/services";
7644
+ import { QueryAgentStatusResponse, EdgeStatus as EdgeStatus2 } from "@dxos/protocols/proto/dxos/client/services";
7650
7645
  var EdgeAgentServiceImpl = class {
7651
7646
  constructor(_agentManagerProvider, _edgeConnection) {
7652
7647
  this._agentManagerProvider = _agentManagerProvider;
7653
7648
  this._edgeConnection = _edgeConnection;
7654
7649
  }
7650
+ // TODO(mykola): Reconcile with NetworkService.queryStatus.
7655
7651
  queryEdgeStatus() {
7656
7652
  return new Stream11(({ ctx, next }) => {
7657
- next({
7658
- status: QueryEdgeStatusResponse.EdgeStatus.NOT_CONNECTED
7659
- });
7660
- if (!this._edgeConnection) {
7661
- return;
7662
- }
7663
- ctx.onDispose(
7664
- // TODO(wittjosiah): EdgeConnection should include a disconnected event as well.
7665
- this._edgeConnection.onReconnected(() => {
7666
- next({
7667
- status: QueryEdgeStatusResponse.EdgeStatus.CONNECTED
7668
- });
7669
- })
7670
- );
7653
+ const update = () => {
7654
+ next({
7655
+ status: this._edgeConnection?.status ?? EdgeStatus2.NOT_CONNECTED
7656
+ });
7657
+ };
7658
+ this._edgeConnection?.statusChanged.on(ctx, update);
7659
+ update();
7671
7660
  });
7672
7661
  }
7673
7662
  async createAgent() {
@@ -7743,7 +7732,7 @@ var EdgeIdentityRecoveryManager = class {
7743
7732
  const identity = this._identityProvider();
7744
7733
  invariant21(identity, void 0, {
7745
7734
  F: __dxlog_file28,
7746
- L: 37,
7735
+ L: 39,
7747
7736
  S: this,
7748
7737
  A: [
7749
7738
  "identity",
@@ -7794,7 +7783,7 @@ var EdgeIdentityRecoveryManager = class {
7794
7783
  async requestRecoveryChallenge() {
7795
7784
  invariant21(this._edgeClient, "Not connected to EDGE.", {
7796
7785
  F: __dxlog_file28,
7797
- L: 74,
7786
+ L: 76,
7798
7787
  S: this,
7799
7788
  A: [
7800
7789
  "this._edgeClient",
@@ -7824,7 +7813,7 @@ var EdgeIdentityRecoveryManager = class {
7824
7813
  async recoverIdentityWithExternalSignature({ lookupKey, deviceKey, controlFeedKey, signature, clientDataJson, authenticatorData }) {
7825
7814
  invariant21(this._edgeClient, "Not connected to EDGE.", {
7826
7815
  F: __dxlog_file28,
7827
- L: 106,
7816
+ L: 108,
7828
7817
  S: this,
7829
7818
  A: [
7830
7819
  "this._edgeClient",
@@ -7858,7 +7847,7 @@ var EdgeIdentityRecoveryManager = class {
7858
7847
  async recoverIdentityWithToken({ token }) {
7859
7848
  invariant21(this._edgeClient, "Not connected to EDGE.", {
7860
7849
  F: __dxlog_file28,
7861
- L: 139,
7850
+ L: 141,
7862
7851
  S: this,
7863
7852
  A: [
7864
7853
  "this._edgeClient",
@@ -7886,7 +7875,7 @@ var EdgeIdentityRecoveryManager = class {
7886
7875
  async recoverIdentity({ recoveryCode }) {
7887
7876
  invariant21(this._edgeClient, "Not connected to EDGE.", {
7888
7877
  F: __dxlog_file28,
7889
- L: 163,
7878
+ L: 165,
7890
7879
  S: this,
7891
7880
  A: [
7892
7881
  "this._edgeClient",
@@ -7917,7 +7906,7 @@ var EdgeIdentityRecoveryManager = class {
7917
7906
  }
7918
7907
  log24.info("recovering identity", response, {
7919
7908
  F: __dxlog_file28,
7920
- L: 189,
7909
+ L: 191,
7921
7910
  S: this,
7922
7911
  C: (f, a) => f(...a)
7923
7912
  });
@@ -7945,86 +7934,75 @@ function _ts_decorate10(decorators, target, key, desc) {
7945
7934
  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;
7946
7935
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7947
7936
  }
7948
- function _using_ctx4() {
7949
- var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
7950
- var err = new Error();
7951
- err.name = "SuppressedError";
7952
- err.suppressed = suppressed;
7953
- err.error = error;
7954
- return err;
7955
- }, empty = {}, stack = [];
7956
- function using(isAwait, value) {
7957
- if (value != null) {
7958
- if (Object(value) !== value) {
7959
- throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
7960
- }
7961
- if (isAwait) {
7962
- var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
7963
- }
7964
- if (dispose == null) {
7965
- dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
7966
- }
7967
- if (typeof dispose !== "function") {
7968
- throw new TypeError(`Property [Symbol.dispose] is not a function.`);
7969
- }
7970
- stack.push({
7971
- v: value,
7972
- d: dispose,
7973
- a: isAwait
7974
- });
7975
- } else if (isAwait) {
7976
- stack.push({
7977
- d: value,
7978
- a: isAwait
7979
- });
7980
- }
7981
- return value;
7937
+ function _ts_add_disposable_resource4(env, value, async) {
7938
+ if (value !== null && value !== void 0) {
7939
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
7940
+ var dispose, inner;
7941
+ if (async) {
7942
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
7943
+ dispose = value[Symbol.asyncDispose];
7944
+ }
7945
+ if (dispose === void 0) {
7946
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
7947
+ dispose = value[Symbol.dispose];
7948
+ if (async) inner = dispose;
7949
+ }
7950
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
7951
+ if (inner) dispose = function() {
7952
+ try {
7953
+ inner.call(this);
7954
+ } catch (e) {
7955
+ return Promise.reject(e);
7956
+ }
7957
+ };
7958
+ env.stack.push({
7959
+ value,
7960
+ dispose,
7961
+ async
7962
+ });
7963
+ } else if (async) {
7964
+ env.stack.push({
7965
+ async: true
7966
+ });
7982
7967
  }
7983
- return {
7984
- e: empty,
7985
- u: using.bind(null, false),
7986
- a: using.bind(null, true),
7987
- d: function() {
7988
- var error = this.e;
7989
- function next() {
7990
- while (resource = stack.pop()) {
7991
- try {
7992
- var resource, disposalResult = resource.d && resource.d.call(resource.v);
7993
- if (resource.a) {
7994
- return Promise.resolve(disposalResult).then(next, err);
7995
- }
7996
- } catch (e) {
7997
- return err(e);
7998
- }
7968
+ return value;
7969
+ }
7970
+ function _ts_dispose_resources4(env) {
7971
+ var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
7972
+ var e = new Error(message);
7973
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
7974
+ };
7975
+ return (_ts_dispose_resources4 = function _ts_dispose_resources5(env2) {
7976
+ function fail(e) {
7977
+ env2.error = env2.hasError ? new _SuppressedError(e, env2.error, "An error was suppressed during disposal.") : e;
7978
+ env2.hasError = true;
7979
+ }
7980
+ var r, s = 0;
7981
+ function next() {
7982
+ while (r = env2.stack.pop()) {
7983
+ try {
7984
+ if (!r.async && s === 1) return s = 0, env2.stack.push(r), Promise.resolve().then(next);
7985
+ if (r.dispose) {
7986
+ var result = r.dispose.call(r.value);
7987
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) {
7988
+ fail(e);
7989
+ return next();
7990
+ });
7991
+ } else s |= 1;
7992
+ } catch (e) {
7993
+ fail(e);
7999
7994
  }
8000
- if (error !== empty) throw error;
8001
- }
8002
- function err(e) {
8003
- error = error !== empty ? new _disposeSuppressedError(error, e) : e;
8004
- return next();
8005
7995
  }
8006
- return next();
7996
+ if (s === 1) return env2.hasError ? Promise.reject(env2.error) : Promise.resolve();
7997
+ if (env2.hasError) throw env2.error;
8007
7998
  }
8008
- };
7999
+ return next();
8000
+ })(env);
8009
8001
  }
8010
8002
  var __dxlog_file29 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
8011
8003
  var ServiceContext = class extends Resource8 {
8012
8004
  constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtimeParams, _edgeFeatures) {
8013
- super();
8014
- this.storage = storage;
8015
- this.level = level;
8016
- this.networkManager = networkManager;
8017
- this.signalManager = signalManager;
8018
- this._edgeConnection = _edgeConnection;
8019
- this._edgeHttpClient = _edgeHttpClient;
8020
- this._runtimeParams = _runtimeParams;
8021
- this._edgeFeatures = _edgeFeatures;
8022
- this._edgeIdentityUpdateMutex = new Mutex4();
8023
- this.initialized = new Trigger9();
8024
- this._meshReplicator = void 0;
8025
- this._echoEdgeReplicator = void 0;
8026
- this._handlerFactories = /* @__PURE__ */ new Map();
8027
- this._instanceId = PublicKey15.random().toHex();
8005
+ 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 Trigger9(), this._meshReplicator = void 0, this._echoEdgeReplicator = void 0, this._handlerFactories = /* @__PURE__ */ new Map(), this._instanceId = PublicKey15.random().toHex();
8028
8006
  this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
8029
8007
  this.blobStore = new BlobStore(storage.createDirectory("blobs"));
8030
8008
  this.keyring = new Keyring(storage.createDirectory("keyring"));
@@ -8059,7 +8037,10 @@ var ServiceContext = class extends Resource8 {
8059
8037
  this.echoHost = new EchoHost({
8060
8038
  kv: this.level,
8061
8039
  peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
8062
- getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key
8040
+ getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key,
8041
+ indexing: {
8042
+ vector: this._runtimeParams?.enableVectorIndexing
8043
+ }
8063
8044
  });
8064
8045
  this._meshReplicator = new MeshEchoReplicator();
8065
8046
  this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeParams?.invitationConnectionDefaultParams);
@@ -8078,7 +8059,7 @@ var ServiceContext = class extends Resource8 {
8078
8059
  await this._checkStorageVersion();
8079
8060
  log25("opening...", void 0, {
8080
8061
  F: __dxlog_file29,
8081
- L: 199,
8062
+ L: 203,
8082
8063
  S: this,
8083
8064
  C: (f, a) => f(...a)
8084
8065
  });
@@ -8086,7 +8067,7 @@ var ServiceContext = class extends Resource8 {
8086
8067
  id: this._instanceId
8087
8068
  }), {
8088
8069
  F: __dxlog_file29,
8089
- L: 200,
8070
+ L: 204,
8090
8071
  S: this,
8091
8072
  C: (f, a) => f(...a)
8092
8073
  });
@@ -8113,7 +8094,7 @@ var ServiceContext = class extends Resource8 {
8113
8094
  count: loadedInvitations.invitations?.length
8114
8095
  }, {
8115
8096
  F: __dxlog_file29,
8116
- L: 228,
8097
+ L: 232,
8117
8098
  S: this,
8118
8099
  C: (f, a) => f(...a)
8119
8100
  });
@@ -8121,13 +8102,13 @@ var ServiceContext = class extends Resource8 {
8121
8102
  id: this._instanceId
8122
8103
  }), {
8123
8104
  F: __dxlog_file29,
8124
- L: 230,
8105
+ L: 234,
8125
8106
  S: this,
8126
8107
  C: (f, a) => f(...a)
8127
8108
  });
8128
8109
  log25("opened", void 0, {
8129
8110
  F: __dxlog_file29,
8130
- L: 231,
8111
+ L: 235,
8131
8112
  S: this,
8132
8113
  C: (f, a) => f(...a)
8133
8114
  });
@@ -8135,7 +8116,7 @@ var ServiceContext = class extends Resource8 {
8135
8116
  async _close(ctx) {
8136
8117
  log25("closing...", void 0, {
8137
8118
  F: __dxlog_file29,
8138
- L: 235,
8119
+ L: 239,
8139
8120
  S: this,
8140
8121
  C: (f, a) => f(...a)
8141
8122
  });
@@ -8154,7 +8135,7 @@ var ServiceContext = class extends Resource8 {
8154
8135
  await this._edgeConnection?.close();
8155
8136
  log25("closed", void 0, {
8156
8137
  F: __dxlog_file29,
8157
- L: 251,
8138
+ L: 255,
8158
8139
  S: this,
8159
8140
  C: (f, a) => f(...a)
8160
8141
  });
@@ -8165,7 +8146,7 @@ var ServiceContext = class extends Resource8 {
8165
8146
  await identity.joinNetwork();
8166
8147
  await this._initialize(new Context10(void 0, {
8167
8148
  F: __dxlog_file29,
8168
- L: 258
8149
+ L: 262
8169
8150
  }));
8170
8151
  return identity;
8171
8152
  }
@@ -8176,7 +8157,7 @@ var ServiceContext = class extends Resource8 {
8176
8157
  const factory = this._handlerFactories.get(invitation.kind);
8177
8158
  invariant22(factory, `Unknown invitation kind: ${invitation.kind}`, {
8178
8159
  F: __dxlog_file29,
8179
- L: 267,
8160
+ L: 271,
8180
8161
  S: this,
8181
8162
  A: [
8182
8163
  "factory",
@@ -8202,7 +8183,7 @@ var ServiceContext = class extends Resource8 {
8202
8183
  await this.identityManager.acceptIdentity(identity, identityRecord, params.deviceProfile);
8203
8184
  await this._initialize(new Context10(void 0, {
8204
8185
  F: __dxlog_file29,
8205
- L: 286
8186
+ L: 290
8206
8187
  }));
8207
8188
  return identity;
8208
8189
  }
@@ -8216,7 +8197,7 @@ var ServiceContext = class extends Resource8 {
8216
8197
  async _initialize(ctx) {
8217
8198
  log25("initializing spaces...", void 0, {
8218
8199
  F: __dxlog_file29,
8219
- L: 301,
8200
+ L: 305,
8220
8201
  S: this,
8221
8202
  C: (f, a) => f(...a)
8222
8203
  });
@@ -8255,7 +8236,7 @@ var ServiceContext = class extends Resource8 {
8255
8236
  this._handlerFactories.set(Invitation10.Kind.SPACE, (invitation) => {
8256
8237
  invariant22(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
8257
8238
  F: __dxlog_file29,
8258
- L: 339,
8239
+ L: 343,
8259
8240
  S: this,
8260
8241
  A: [
8261
8242
  "this.dataSpaceManager",
@@ -8279,7 +8260,7 @@ var ServiceContext = class extends Resource8 {
8279
8260
  details: assertion
8280
8261
  }, {
8281
8262
  F: __dxlog_file29,
8282
- L: 355,
8263
+ L: 359,
8283
8264
  S: this,
8284
8265
  C: (f, a) => f(...a)
8285
8266
  });
@@ -8290,7 +8271,7 @@ var ServiceContext = class extends Resource8 {
8290
8271
  details: assertion
8291
8272
  }, {
8292
8273
  F: __dxlog_file29,
8293
- L: 359,
8274
+ L: 363,
8294
8275
  S: this,
8295
8276
  C: (f, a) => f(...a)
8296
8277
  });
@@ -8301,7 +8282,7 @@ var ServiceContext = class extends Resource8 {
8301
8282
  details: assertion
8302
8283
  }, {
8303
8284
  F: __dxlog_file29,
8304
- L: 364,
8285
+ L: 368,
8305
8286
  S: this,
8306
8287
  C: (f, a) => f(...a)
8307
8288
  });
@@ -8312,7 +8293,7 @@ var ServiceContext = class extends Resource8 {
8312
8293
  } catch (err) {
8313
8294
  log25.catch(err, void 0, {
8314
8295
  F: __dxlog_file29,
8315
- L: 370,
8296
+ L: 374,
8316
8297
  S: this,
8317
8298
  C: (f, a) => f(...a)
8318
8299
  });
@@ -8322,9 +8303,13 @@ var ServiceContext = class extends Resource8 {
8322
8303
  await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
8323
8304
  }
8324
8305
  async _setNetworkIdentity(params) {
8306
+ const env = {
8307
+ stack: [],
8308
+ error: void 0,
8309
+ hasError: false
8310
+ };
8325
8311
  try {
8326
- var _usingCtx = _using_ctx4();
8327
- const _ = _usingCtx.u(await this._edgeIdentityUpdateMutex.acquire());
8312
+ const _ = _ts_add_disposable_resource4(env, await this._edgeIdentityUpdateMutex.acquire(), false);
8328
8313
  let edgeIdentity;
8329
8314
  const identity = this.identityManager.identity;
8330
8315
  if (identity) {
@@ -8333,7 +8318,7 @@ var ServiceContext = class extends Resource8 {
8333
8318
  swarms: this.networkManager.topics
8334
8319
  }, {
8335
8320
  F: __dxlog_file29,
8336
- L: 384,
8321
+ L: 388,
8337
8322
  S: this,
8338
8323
  C: (f, a) => f(...a)
8339
8324
  });
@@ -8347,7 +8332,7 @@ var ServiceContext = class extends Resource8 {
8347
8332
  });
8348
8333
  invariant22(identity.deviceCredentialChain, void 0, {
8349
8334
  F: __dxlog_file29,
8350
- L: 403,
8335
+ L: 407,
8351
8336
  S: this,
8352
8337
  A: [
8353
8338
  "identity.deviceCredentialChain",
@@ -8365,10 +8350,11 @@ var ServiceContext = class extends Resource8 {
8365
8350
  identityKey: edgeIdentity.identityKey,
8366
8351
  peerKey: edgeIdentity.peerKey
8367
8352
  });
8368
- } catch (_) {
8369
- _usingCtx.e = _;
8353
+ } catch (e) {
8354
+ env.error = e;
8355
+ env.hasError = true;
8370
8356
  } finally {
8371
- _usingCtx.d();
8357
+ _ts_dispose_resources4(env);
8372
8358
  }
8373
8359
  }
8374
8360
  };
@@ -8482,7 +8468,7 @@ var createLevel = async (config) => {
8482
8468
  };
8483
8469
 
8484
8470
  // packages/sdk/client-services/src/packlets/storage/profile-archive.ts
8485
- import { cbor } from "@dxos/automerge/automerge-repo";
8471
+ import { cbor } from "@automerge/automerge-repo";
8486
8472
  import { invariant as invariant23 } from "@dxos/invariant";
8487
8473
  import { log as log26 } from "@dxos/log";
8488
8474
  import { ProfileArchiveEntryType } from "@dxos/protocols";
@@ -8504,7 +8490,7 @@ var exportProfileData = async ({ storage, level }) => {
8504
8490
  count: files.length
8505
8491
  }, {
8506
8492
  F: __dxlog_file30,
8507
- L: 30,
8493
+ L: 31,
8508
8494
  S: void 0,
8509
8495
  C: (f, a) => f(...a)
8510
8496
  });
@@ -8522,7 +8508,7 @@ var exportProfileData = async ({ storage, level }) => {
8522
8508
  count: files.length
8523
8509
  }, {
8524
8510
  F: __dxlog_file30,
8525
- L: 41,
8511
+ L: 42,
8526
8512
  S: void 0,
8527
8513
  C: (f, a) => f(...a)
8528
8514
  });
@@ -8530,7 +8516,7 @@ var exportProfileData = async ({ storage, level }) => {
8530
8516
  {
8531
8517
  log26.info("begin exporting kv pairs", void 0, {
8532
8518
  F: __dxlog_file30,
8533
- L: 45,
8519
+ L: 46,
8534
8520
  S: void 0,
8535
8521
  C: (f, a) => f(...a)
8536
8522
  });
@@ -8551,7 +8537,7 @@ var exportProfileData = async ({ storage, level }) => {
8551
8537
  count
8552
8538
  }, {
8553
8539
  F: __dxlog_file30,
8554
- L: 56,
8540
+ L: 57,
8555
8541
  S: void 0,
8556
8542
  C: (f, a) => f(...a)
8557
8543
  });
@@ -8567,7 +8553,7 @@ var importProfileData = async ({ storage, level }, archive) => {
8567
8553
  const directory = await storage.createDirectory();
8568
8554
  invariant23(typeof entry2.key === "string", "Invalid key type", {
8569
8555
  F: __dxlog_file30,
8570
- L: 79,
8556
+ L: 80,
8571
8557
  S: void 0,
8572
8558
  A: [
8573
8559
  "typeof entry.key === 'string'",
@@ -8577,7 +8563,7 @@ var importProfileData = async ({ storage, level }, archive) => {
8577
8563
  const file = await directory.getOrCreateFile(entry2.key);
8578
8564
  invariant23(entry2.value instanceof Uint8Array, "Invalid value type", {
8579
8565
  F: __dxlog_file30,
8580
- L: 81,
8566
+ L: 82,
8581
8567
  S: void 0,
8582
8568
  A: [
8583
8569
  "entry.value instanceof Uint8Array",
@@ -8591,7 +8577,7 @@ var importProfileData = async ({ storage, level }, archive) => {
8591
8577
  case ProfileArchiveEntryType.KEY_VALUE: {
8592
8578
  invariant23(entry2.key instanceof Uint8Array, "Invalid key type", {
8593
8579
  F: __dxlog_file30,
8594
- L: 87,
8580
+ L: 88,
8595
8581
  S: void 0,
8596
8582
  A: [
8597
8583
  "entry.key instanceof Uint8Array",
@@ -8600,7 +8586,7 @@ var importProfileData = async ({ storage, level }, archive) => {
8600
8586
  });
8601
8587
  invariant23(entry2.value instanceof Uint8Array, "Invalid value type", {
8602
8588
  F: __dxlog_file30,
8603
- L: 88,
8589
+ L: 89,
8604
8590
  S: void 0,
8605
8591
  A: [
8606
8592
  "entry.value instanceof Uint8Array",
@@ -8625,7 +8611,7 @@ var importProfileData = async ({ storage, level }, archive) => {
8625
8611
  progress: `${(count / archive.storage.length * 100).toFixed()}%`
8626
8612
  }, {
8627
8613
  F: __dxlog_file30,
8628
- L: 101,
8614
+ L: 102,
8629
8615
  S: void 0,
8630
8616
  C: (f, a) => f(...a)
8631
8617
  });
@@ -8633,7 +8619,7 @@ var importProfileData = async ({ storage, level }, archive) => {
8633
8619
  }
8634
8620
  log26.info("committing changes..", void 0, {
8635
8621
  F: __dxlog_file30,
8636
- L: 109,
8622
+ L: 110,
8637
8623
  S: void 0,
8638
8624
  C: (f, a) => f(...a)
8639
8625
  });
@@ -8659,7 +8645,7 @@ import { WebsocketRpcClient } from "@dxos/websocket-rpc";
8659
8645
  import { SubscriptionList as SubscriptionList3 } from "@dxos/async";
8660
8646
  import { Stream as Stream12 } from "@dxos/codec-protobuf/stream";
8661
8647
  import { invariant as invariant24 } from "@dxos/invariant";
8662
- import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
8648
+ import { Device as Device2, DeviceKind as DeviceKind2, EdgeStatus as EdgeStatus3 } from "@dxos/protocols/proto/dxos/client/services";
8663
8649
  var __dxlog_file31 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
8664
8650
  var DevicesServiceImpl = class {
8665
8651
  constructor(_identityManager, _edgeConnection) {
@@ -8680,7 +8666,7 @@ var DevicesServiceImpl = class {
8680
8666
  } else {
8681
8667
  invariant24(this._identityManager.identity?.presence, "presence not present", {
8682
8668
  F: __dxlog_file31,
8683
- L: 36,
8669
+ L: 37,
8684
8670
  S: this,
8685
8671
  A: [
8686
8672
  "this._identityManager.identity?.presence",
@@ -8695,7 +8681,7 @@ var DevicesServiceImpl = class {
8695
8681
  if (isMe) {
8696
8682
  presence = Device2.PresenceState.ONLINE;
8697
8683
  } else if (profile.os?.toUpperCase() === "EDGE") {
8698
- presence = this._edgeConnection?.isConnected ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE;
8684
+ presence = this._edgeConnection?.status === EdgeStatus3.CONNECTED ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE;
8699
8685
  } else {
8700
8686
  presence = peers.some((peer) => peer.identityKey.equals(key)) ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE;
8701
8687
  }
@@ -8955,12 +8941,13 @@ var LOG_PROCESSING = 0;
8955
8941
  // packages/sdk/client-services/src/packlets/network/network-service.ts
8956
8942
  import { Stream as Stream15 } from "@dxos/codec-protobuf/stream";
8957
8943
  var NetworkServiceImpl = class {
8958
- constructor(networkManager, signalManager) {
8944
+ constructor(networkManager, signalManager, edgeConnection) {
8959
8945
  this.networkManager = networkManager;
8960
8946
  this.signalManager = signalManager;
8947
+ this.edgeConnection = edgeConnection;
8961
8948
  }
8962
8949
  queryStatus() {
8963
- return new Stream15(({ next }) => {
8950
+ return new Stream15(({ ctx, next }) => {
8964
8951
  const update = () => {
8965
8952
  next({
8966
8953
  swarm: this.networkManager.connectionState,
@@ -8971,13 +8958,9 @@ var NetworkServiceImpl = class {
8971
8958
  }))
8972
8959
  });
8973
8960
  };
8974
- const unsubscribeSwarm = this.networkManager.connectionStateChanged.on(() => update());
8975
- const unsubscribeSignal = this.signalManager.statusChanged?.on(() => update());
8961
+ this.networkManager.connectionStateChanged.on(ctx, () => update());
8962
+ this.signalManager.statusChanged?.on(ctx, () => update());
8976
8963
  update();
8977
- return () => {
8978
- unsubscribeSwarm();
8979
- unsubscribeSignal?.();
8980
- };
8981
8964
  });
8982
8965
  }
8983
8966
  async updateConfig(request) {
@@ -8993,26 +8976,24 @@ var NetworkServiceImpl = class {
8993
8976
  return this.signalManager.query(request);
8994
8977
  }
8995
8978
  subscribeSwarmState(request) {
8996
- return new Stream15(({ next }) => {
8997
- const unsubscribe = this.signalManager.swarmState?.on((state) => {
8979
+ return new Stream15(({ ctx, next }) => {
8980
+ this.signalManager.swarmState?.on(ctx, (state) => {
8998
8981
  if (request.topic.equals(state.swarmKey)) {
8999
8982
  next(state);
9000
8983
  }
9001
8984
  });
9002
- return unsubscribe;
9003
8985
  });
9004
8986
  }
9005
8987
  async sendMessage(message) {
9006
8988
  return this.signalManager.sendMessage(message);
9007
8989
  }
9008
8990
  subscribeMessages(peer) {
9009
- return new Stream15(({ next }) => {
9010
- const unsubscribe = this.signalManager.onMessage.on((message) => {
8991
+ return new Stream15(({ ctx, next }) => {
8992
+ this.signalManager.onMessage.on(ctx, (message) => {
9011
8993
  if (message.recipient.peerKey === peer.peerKey) {
9012
8994
  next(message);
9013
8995
  }
9014
8996
  });
9015
- return unsubscribe;
9016
8997
  });
9017
8998
  }
9018
8999
  };
@@ -9108,6 +9089,9 @@ var ClientServicesHost = class {
9108
9089
  if (this._runtimeParams.disableP2pReplication === void 0) {
9109
9090
  this._runtimeParams.disableP2pReplication = config?.get("runtime.client.disableP2pReplication", false);
9110
9091
  }
9092
+ if (this._runtimeParams.enableVectorIndexing === void 0) {
9093
+ this._runtimeParams.enableVectorIndexing = config?.get("runtime.client.enableVectorIndexing", false);
9094
+ }
9111
9095
  if (config) {
9112
9096
  this.initialize({
9113
9097
  config,
@@ -9122,7 +9106,7 @@ var ClientServicesHost = class {
9122
9106
  if (!this._opening) {
9123
9107
  void this.open(new Context11(void 0, {
9124
9108
  F: __dxlog_file32,
9125
- L: 137
9109
+ L: 141
9126
9110
  }));
9127
9111
  }
9128
9112
  },
@@ -9180,7 +9164,7 @@ var ClientServicesHost = class {
9180
9164
  initialize({ config, ...options }) {
9181
9165
  invariant25(!this._open, "service host is open", {
9182
9166
  F: __dxlog_file32,
9183
- L: 203,
9167
+ L: 207,
9184
9168
  S: this,
9185
9169
  A: [
9186
9170
  "!this._open",
@@ -9189,14 +9173,14 @@ var ClientServicesHost = class {
9189
9173
  });
9190
9174
  log28("initializing...", void 0, {
9191
9175
  F: __dxlog_file32,
9192
- L: 204,
9176
+ L: 208,
9193
9177
  S: this,
9194
9178
  C: (f, a) => f(...a)
9195
9179
  });
9196
9180
  if (config) {
9197
9181
  invariant25(!this._config, "config already set", {
9198
9182
  F: __dxlog_file32,
9199
- L: 207,
9183
+ L: 211,
9200
9184
  S: this,
9201
9185
  A: [
9202
9186
  "!this._config",
@@ -9211,7 +9195,7 @@ var ClientServicesHost = class {
9211
9195
  if (!options.signalManager) {
9212
9196
  log28.warn("running signaling without telemetry metadata.", void 0, {
9213
9197
  F: __dxlog_file32,
9214
- L: 215,
9198
+ L: 219,
9215
9199
  S: this,
9216
9200
  C: (f, a) => f(...a)
9217
9201
  });
@@ -9231,7 +9215,7 @@ var ClientServicesHost = class {
9231
9215
  this._signalManager = signalManager;
9232
9216
  invariant25(!this._networkManager, "network manager already set", {
9233
9217
  F: __dxlog_file32,
9234
- L: 237,
9218
+ L: 241,
9235
9219
  S: this,
9236
9220
  A: [
9237
9221
  "!this._networkManager",
@@ -9249,7 +9233,7 @@ var ClientServicesHost = class {
9249
9233
  });
9250
9234
  log28("initialized", void 0, {
9251
9235
  F: __dxlog_file32,
9252
- L: 250,
9236
+ L: 254,
9253
9237
  S: this,
9254
9238
  C: (f, a) => f(...a)
9255
9239
  });
@@ -9263,13 +9247,13 @@ var ClientServicesHost = class {
9263
9247
  id: traceId
9264
9248
  }), {
9265
9249
  F: __dxlog_file32,
9266
- L: 261,
9250
+ L: 265,
9267
9251
  S: this,
9268
9252
  C: (f, a) => f(...a)
9269
9253
  });
9270
9254
  invariant25(this._config, "config not set", {
9271
9255
  F: __dxlog_file32,
9272
- L: 263,
9256
+ L: 267,
9273
9257
  S: this,
9274
9258
  A: [
9275
9259
  "this._config",
@@ -9278,7 +9262,7 @@ var ClientServicesHost = class {
9278
9262
  });
9279
9263
  invariant25(this._storage, "storage not set", {
9280
9264
  F: __dxlog_file32,
9281
- L: 264,
9265
+ L: 268,
9282
9266
  S: this,
9283
9267
  A: [
9284
9268
  "this._storage",
@@ -9287,7 +9271,7 @@ var ClientServicesHost = class {
9287
9271
  });
9288
9272
  invariant25(this._signalManager, "signal manager not set", {
9289
9273
  F: __dxlog_file32,
9290
- L: 265,
9274
+ L: 269,
9291
9275
  S: this,
9292
9276
  A: [
9293
9277
  "this._signalManager",
@@ -9296,7 +9280,7 @@ var ClientServicesHost = class {
9296
9280
  });
9297
9281
  invariant25(this._networkManager, "network manager not set", {
9298
9282
  F: __dxlog_file32,
9299
- L: 266,
9283
+ L: 270,
9300
9284
  S: this,
9301
9285
  A: [
9302
9286
  "this._networkManager",
@@ -9308,7 +9292,7 @@ var ClientServicesHost = class {
9308
9292
  lockKey: this._resourceLock?.lockKey
9309
9293
  }, {
9310
9294
  F: __dxlog_file32,
9311
- L: 269,
9295
+ L: 273,
9312
9296
  S: this,
9313
9297
  C: (f, a) => f(...a)
9314
9298
  });
@@ -9337,7 +9321,7 @@ var ClientServicesHost = class {
9337
9321
  SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, dataSpaceManagerProvider),
9338
9322
  DataService: this._serviceContext.echoHost.dataService,
9339
9323
  QueryService: this._serviceContext.echoHost.queryService,
9340
- NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
9324
+ NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager, this._edgeConnection),
9341
9325
  LoggingService: this._loggingService,
9342
9326
  TracingService: this._tracingService,
9343
9327
  // TODO(burdon): Move to new protobuf definitions.
@@ -9369,7 +9353,7 @@ var ClientServicesHost = class {
9369
9353
  deviceKey
9370
9354
  }, {
9371
9355
  F: __dxlog_file32,
9372
- L: 366,
9356
+ L: 374,
9373
9357
  S: this,
9374
9358
  C: (f, a) => f(...a)
9375
9359
  });
@@ -9377,7 +9361,7 @@ var ClientServicesHost = class {
9377
9361
  id: traceId
9378
9362
  }), {
9379
9363
  F: __dxlog_file32,
9380
- L: 367,
9364
+ L: 375,
9381
9365
  S: this,
9382
9366
  C: (f, a) => f(...a)
9383
9367
  });
@@ -9391,7 +9375,7 @@ var ClientServicesHost = class {
9391
9375
  deviceKey
9392
9376
  }, {
9393
9377
  F: __dxlog_file32,
9394
- L: 378,
9378
+ L: 386,
9395
9379
  S: this,
9396
9380
  C: (f, a) => f(...a)
9397
9381
  });
@@ -9409,7 +9393,7 @@ var ClientServicesHost = class {
9409
9393
  deviceKey
9410
9394
  }, {
9411
9395
  F: __dxlog_file32,
9412
- L: 387,
9396
+ L: 395,
9413
9397
  S: this,
9414
9398
  C: (f, a) => f(...a)
9415
9399
  });
@@ -9420,13 +9404,13 @@ var ClientServicesHost = class {
9420
9404
  id: traceId
9421
9405
  }), {
9422
9406
  F: __dxlog_file32,
9423
- L: 392,
9407
+ L: 400,
9424
9408
  S: this,
9425
9409
  C: (f, a) => f(...a)
9426
9410
  });
9427
9411
  log28.info("resetting...", void 0, {
9428
9412
  F: __dxlog_file32,
9429
- L: 394,
9413
+ L: 402,
9430
9414
  S: this,
9431
9415
  C: (f, a) => f(...a)
9432
9416
  });
@@ -9436,7 +9420,7 @@ var ClientServicesHost = class {
9436
9420
  await this._storage.reset();
9437
9421
  log28.info("reset", void 0, {
9438
9422
  F: __dxlog_file32,
9439
- L: 401,
9423
+ L: 409,
9440
9424
  S: this,
9441
9425
  C: (f, a) => f(...a)
9442
9426
  });
@@ -9444,7 +9428,7 @@ var ClientServicesHost = class {
9444
9428
  id: traceId
9445
9429
  }), {
9446
9430
  F: __dxlog_file32,
9447
- L: 402,
9431
+ L: 410,
9448
9432
  S: this,
9449
9433
  C: (f, a) => f(...a)
9450
9434
  });
@@ -9522,4 +9506,4 @@ export {
9522
9506
  importProfileData,
9523
9507
  ClientServicesHost
9524
9508
  };
9525
- //# sourceMappingURL=chunk-2TKMQ2UP.mjs.map
9509
+ //# sourceMappingURL=chunk-IFPYIR2N.mjs.map