@dxos/client-services 0.8.2-main.fbd8ed0 → 0.8.2-staging.4d6ad0f

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 (100) hide show
  1. package/dist/lib/browser/{chunk-I3QLQXQD.mjs → chunk-AA2G5WEV.mjs} +375 -394
  2. package/dist/lib/browser/chunk-AA2G5WEV.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-Y747YVDI.cjs → chunk-JC3EZ3VA.cjs} +378 -386
  9. package/dist/lib/node/chunk-JC3EZ3VA.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-XNCWQTDB.mjs → chunk-ZCHUTUNU.mjs} +375 -383
  16. package/dist/lib/node-esm/chunk-ZCHUTUNU.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/identity/authenticator.d.ts.map +1 -1
  24. package/dist/types/src/packlets/identity/default-space-state-machine.d.ts.map +1 -1
  25. package/dist/types/src/packlets/identity/identity-manager.d.ts +2 -2
  26. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  27. package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +1 -1
  28. package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -1
  29. package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
  30. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  31. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
  32. package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts.map +1 -1
  33. package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts.map +1 -1
  34. package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts.map +1 -1
  35. package/dist/types/src/packlets/invitations/invitation-topology.d.ts.map +1 -1
  36. package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -1
  37. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +1 -1
  38. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
  39. package/dist/types/src/packlets/locks/browser.d.ts.map +1 -1
  40. package/dist/types/src/packlets/locks/node.d.ts.map +1 -1
  41. package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
  42. package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
  43. package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
  44. package/dist/types/src/packlets/services/service-context.d.ts +1 -0
  45. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  46. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  47. package/dist/types/src/packlets/services/service-registry.d.ts.map +1 -1
  48. package/dist/types/src/packlets/space-export/space-archive-writer.d.ts.map +1 -1
  49. package/dist/types/src/packlets/spaces/automerge-space-state.d.ts.map +1 -1
  50. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  51. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  52. package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts.map +1 -1
  53. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
  54. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  55. package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
  56. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  57. package/dist/types/src/packlets/worker/worker-runtime.d.ts.map +1 -1
  58. package/dist/types/src/packlets/worker/worker-session.d.ts.map +1 -1
  59. package/dist/types/src/version.d.ts +1 -1
  60. package/dist/types/src/version.d.ts.map +1 -1
  61. package/package.json +39 -39
  62. package/src/packlets/agents/edge-agent-manager.ts +6 -6
  63. package/src/packlets/identity/authenticator.ts +2 -2
  64. package/src/packlets/identity/default-space-state-machine.ts +1 -1
  65. package/src/packlets/identity/identity-manager.ts +13 -9
  66. package/src/packlets/identity/identity-recovery-manager.ts +6 -4
  67. package/src/packlets/identity/identity-service.ts +4 -4
  68. package/src/packlets/identity/identity.ts +5 -5
  69. package/src/packlets/invitations/device-invitation-protocol.ts +1 -1
  70. package/src/packlets/invitations/edge-invitation-handler.ts +3 -3
  71. package/src/packlets/invitations/invitation-guest-extenstion.ts +3 -3
  72. package/src/packlets/invitations/invitation-host-extension.ts +5 -5
  73. package/src/packlets/invitations/invitation-topology.ts +1 -1
  74. package/src/packlets/invitations/invitations-handler.ts +2 -2
  75. package/src/packlets/invitations/invitations-manager.ts +15 -4
  76. package/src/packlets/invitations/space-invitation-protocol.ts +1 -1
  77. package/src/packlets/locks/browser.ts +4 -4
  78. package/src/packlets/locks/node.ts +2 -2
  79. package/src/packlets/logging/logging-service.ts +2 -2
  80. package/src/packlets/network/network-service.ts +2 -2
  81. package/src/packlets/services/client-rpc-server.ts +2 -2
  82. package/src/packlets/services/service-context.ts +10 -6
  83. package/src/packlets/services/service-host.ts +8 -4
  84. package/src/packlets/services/service-registry.ts +3 -3
  85. package/src/packlets/space-export/space-archive-writer.ts +3 -3
  86. package/src/packlets/spaces/automerge-space-state.ts +3 -3
  87. package/src/packlets/spaces/data-space-manager.ts +14 -14
  88. package/src/packlets/spaces/data-space.ts +18 -18
  89. package/src/packlets/spaces/edge-feed-replicator.ts +12 -12
  90. package/src/packlets/spaces/notarization-plugin.test.ts +1 -1
  91. package/src/packlets/spaces/notarization-plugin.ts +18 -18
  92. package/src/packlets/spaces/spaces-service.ts +5 -5
  93. package/src/packlets/system/system-service.ts +2 -2
  94. package/src/packlets/testing/test-builder.ts +3 -3
  95. package/src/packlets/worker/worker-runtime.ts +4 -4
  96. package/src/packlets/worker/worker-session.ts +3 -3
  97. package/src/version.ts +1 -1
  98. package/dist/lib/browser/chunk-I3QLQXQD.mjs.map +0 -7
  99. package/dist/lib/node/chunk-Y747YVDI.cjs.map +0 -7
  100. package/dist/lib/node-esm/chunk-XNCWQTDB.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-main.fbd8ed0";
400
+ var DXOS_VERSION = "0.8.2-staging.4d6ad0f";
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 () => {
@@ -825,67 +818,70 @@ function _ts_decorate(decorators, target, key, desc) {
825
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;
826
819
  return c > 3 && r && Object.defineProperty(target, key, r), r;
827
820
  }
828
- function _using_ctx() {
829
- var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
830
- var err = new Error();
831
- err.name = "SuppressedError";
832
- err.suppressed = suppressed;
833
- err.error = error;
834
- return err;
835
- }, empty = {}, stack = [];
836
- function using(isAwait, value) {
837
- if (value != null) {
838
- if (Object(value) !== value) {
839
- throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
840
- }
841
- if (isAwait) {
842
- var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
843
- }
844
- if (dispose == null) {
845
- dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
846
- }
847
- if (typeof dispose !== "function") {
848
- throw new TypeError(`Property [Symbol.dispose] is not a function.`);
849
- }
850
- stack.push({
851
- v: value,
852
- d: dispose,
853
- a: isAwait
854
- });
855
- } else if (isAwait) {
856
- stack.push({
857
- d: value,
858
- a: isAwait
859
- });
860
- }
861
- 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
+ });
862
851
  }
863
- return {
864
- e: empty,
865
- u: using.bind(null, false),
866
- a: using.bind(null, true),
867
- d: function() {
868
- var error = this.e;
869
- function next() {
870
- while (resource = stack.pop()) {
871
- try {
872
- var resource, disposalResult = resource.d && resource.d.call(resource.v);
873
- if (resource.a) {
874
- return Promise.resolve(disposalResult).then(next, err);
875
- }
876
- } catch (e) {
877
- return err(e);
878
- }
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);
879
878
  }
880
- if (error !== empty) throw error;
881
879
  }
882
- function err(e) {
883
- error = error !== empty ? new _disposeSuppressedError(error, e) : e;
884
- return next();
885
- }
886
- return next();
880
+ if (s === 1) return env2.hasError ? Promise.reject(env2.error) : Promise.resolve();
881
+ if (env2.hasError) throw env2.error;
887
882
  }
888
- };
883
+ return next();
884
+ })(env);
889
885
  }
890
886
  var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/edge-feed-replicator.ts";
891
887
  var EdgeFeedReplicator = class extends Resource {
@@ -1092,8 +1088,12 @@ var EdgeFeedReplicator = class extends Resource {
1092
1088
  scheduleMicroTask(this._connectionCtx, async () => {
1093
1089
  switch (message.type) {
1094
1090
  case "metadata": {
1091
+ const env = {
1092
+ stack: [],
1093
+ error: void 0,
1094
+ hasError: false
1095
+ };
1095
1096
  try {
1096
- var _usingCtx = _using_ctx();
1097
1097
  const feedKey = PublicKey3.fromHex(message.feedKey);
1098
1098
  const feed = this._feeds.get(feedKey);
1099
1099
  if (!feed) {
@@ -1107,7 +1107,7 @@ var EdgeFeedReplicator = class extends Resource {
1107
1107
  });
1108
1108
  return;
1109
1109
  }
1110
- 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);
1111
1111
  this._remoteLength.set(feedKey, message.length);
1112
1112
  const logMeta = {
1113
1113
  localLength: feed.length,
@@ -1139,10 +1139,11 @@ var EdgeFeedReplicator = class extends Resource {
1139
1139
  await this._pushBlocks(feed, message.length, feed.length);
1140
1140
  }
1141
1141
  break;
1142
- } catch (_) {
1143
- _usingCtx.e = _;
1142
+ } catch (e) {
1143
+ env.error = e;
1144
+ env.hasError = true;
1144
1145
  } finally {
1145
- _usingCtx.d();
1146
+ _ts_dispose_resources(env);
1146
1147
  }
1147
1148
  }
1148
1149
  case "data": {
@@ -1245,9 +1246,13 @@ var EdgeFeedReplicator = class extends Resource {
1245
1246
  }
1246
1247
  }
1247
1248
  async _pushBlocksIfNeeded(feed) {
1249
+ const env = {
1250
+ stack: [],
1251
+ error: void 0,
1252
+ hasError: false
1253
+ };
1248
1254
  try {
1249
- var _usingCtx = _using_ctx();
1250
- const _ = _usingCtx.u(await this._getPushMutex(feed.key).acquire());
1255
+ const _ = _ts_add_disposable_resource(env, await this._getPushMutex(feed.key).acquire(), false);
1251
1256
  if (!this._remoteLength.has(feed.key)) {
1252
1257
  log4("blocks not pushed because remote length is unknown", void 0, {
1253
1258
  F: __dxlog_file6,
@@ -1261,10 +1266,11 @@ var EdgeFeedReplicator = class extends Resource {
1261
1266
  if (remoteLength < feed.length) {
1262
1267
  await this._pushBlocks(feed, remoteLength, feed.length);
1263
1268
  }
1264
- } catch (_) {
1265
- _usingCtx.e = _;
1269
+ } catch (e) {
1270
+ env.error = e;
1271
+ env.hasError = true;
1266
1272
  } finally {
1267
- _usingCtx.d();
1273
+ _ts_dispose_resources(env);
1268
1274
  }
1269
1275
  }
1270
1276
  _createConnectionContext() {
@@ -1330,12 +1336,7 @@ import { Resource as Resource2 } from "@dxos/context";
1330
1336
  import { checkCredentialType } from "@dxos/credentials";
1331
1337
  var AutomergeSpaceState = class extends Resource2 {
1332
1338
  constructor(_onNewRoot) {
1333
- super();
1334
- this._onNewRoot = _onNewRoot;
1335
- this.rootUrl = void 0;
1336
- this.lastEpoch = void 0;
1337
- this.onNewEpoch = new Event2();
1338
- this._isProcessingRootDocs = false;
1339
+ super(), this._onNewRoot = _onNewRoot, this.rootUrl = void 0, this.lastEpoch = void 0, this.onNewEpoch = new Event2(), this._isProcessingRootDocs = false;
1339
1340
  }
1340
1341
  async _open(ctx) {
1341
1342
  }
@@ -1853,8 +1854,7 @@ var NotarizationTeleportExtension = class extends RpcExtension {
1853
1854
  exposed: {
1854
1855
  NotarizationService: schema2.getService("dxos.mesh.teleport.notarization.NotarizationService")
1855
1856
  }
1856
- });
1857
- this._params = _params;
1857
+ }), this._params = _params;
1858
1858
  }
1859
1859
  async getHandlers() {
1860
1860
  return {
@@ -2870,67 +2870,70 @@ var extractSpaceArchive = async (archive) => {
2870
2870
  };
2871
2871
 
2872
2872
  // packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
2873
- function _using_ctx2() {
2874
- var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
2875
- var err = new Error();
2876
- err.name = "SuppressedError";
2877
- err.suppressed = suppressed;
2878
- err.error = error;
2879
- return err;
2880
- }, empty = {}, stack = [];
2881
- function using(isAwait, value) {
2882
- if (value != null) {
2883
- if (Object(value) !== value) {
2884
- throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
2885
- }
2886
- if (isAwait) {
2887
- var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
2888
- }
2889
- if (dispose == null) {
2890
- dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
2891
- }
2892
- if (typeof dispose !== "function") {
2893
- throw new TypeError(`Property [Symbol.dispose] is not a function.`);
2894
- }
2895
- stack.push({
2896
- v: value,
2897
- d: dispose,
2898
- a: isAwait
2899
- });
2900
- } else if (isAwait) {
2901
- stack.push({
2902
- d: value,
2903
- a: isAwait
2904
- });
2905
- }
2906
- 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
+ });
2907
2903
  }
2908
- return {
2909
- e: empty,
2910
- u: using.bind(null, false),
2911
- a: using.bind(null, true),
2912
- d: function() {
2913
- var error = this.e;
2914
- function next() {
2915
- while (resource = stack.pop()) {
2916
- try {
2917
- var resource, disposalResult = resource.d && resource.d.call(resource.v);
2918
- if (resource.a) {
2919
- return Promise.resolve(disposalResult).then(next, err);
2920
- }
2921
- } catch (e) {
2922
- return err(e);
2923
- }
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);
2924
2930
  }
2925
- if (error !== empty) throw error;
2926
2931
  }
2927
- function err(e) {
2928
- error = error !== empty ? new _disposeSuppressedError(error, e) : e;
2929
- return next();
2930
- }
2931
- return next();
2932
+ if (s === 1) return env2.hasError ? Promise.reject(env2.error) : Promise.resolve();
2933
+ if (env2.hasError) throw env2.error;
2932
2934
  }
2933
- };
2935
+ return next();
2936
+ })(env);
2934
2937
  }
2935
2938
  var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
2936
2939
  var SpacesServiceImpl = class {
@@ -3166,9 +3169,13 @@ var SpacesServiceImpl = class {
3166
3169
  });
3167
3170
  }
3168
3171
  async exportSpace(request) {
3172
+ const env = {
3173
+ stack: [],
3174
+ error: void 0,
3175
+ hasError: false
3176
+ };
3169
3177
  try {
3170
- var _usingCtx = _using_ctx2();
3171
- const writer = _usingCtx.a(await new SpaceArchiveWriter().open());
3178
+ const writer = _ts_add_disposable_resource2(env, await new SpaceArchiveWriter().open(), true);
3172
3179
  assertArgument4(SpaceId2.isValid(request.spaceId), "Invalid space ID");
3173
3180
  const dataSpaceManager = await this._getDataSpaceManager();
3174
3181
  const space = dataSpaceManager.getSpaceById(request.spaceId) ?? raise(new Error("Space not found"));
@@ -3185,10 +3192,12 @@ var SpacesServiceImpl = class {
3185
3192
  return {
3186
3193
  archive
3187
3194
  };
3188
- } catch (_) {
3189
- _usingCtx.e = _;
3195
+ } catch (e) {
3196
+ env.error = e;
3197
+ env.hasError = true;
3190
3198
  } finally {
3191
- await _usingCtx.d();
3199
+ const result = _ts_dispose_resources2(env);
3200
+ if (result) await result;
3192
3201
  }
3193
3202
  }
3194
3203
  async importSpace(request) {
@@ -3626,7 +3635,7 @@ var IdentityManager = class {
3626
3635
  L: 135
3627
3636
  }));
3628
3637
  }
3629
- async createIdentity({ displayName, deviceProfile } = {}) {
3638
+ async createIdentity({ profile, deviceProfile } = {}) {
3630
3639
  invariant9(!this._identity, "Identity already exists.", {
3631
3640
  F: __dxlog_file14,
3632
3641
  L: 140,
@@ -3684,10 +3693,8 @@ var IdentityManager = class {
3684
3693
  // Feed admission.
3685
3694
  await generator.createFeedAdmission(identityRecord.haloSpace.key, identityRecord.haloSpace.dataFeedKey, AdmittedFeed3.Designation.DATA)
3686
3695
  ];
3687
- if (displayName) {
3688
- credentials.push(await generator.createProfileCredential({
3689
- displayName
3690
- }));
3696
+ if (profile) {
3697
+ credentials.push(await generator.createProfileCredential(profile));
3691
3698
  }
3692
3699
  credentials.push(await generator.createDeviceAuthorization(identityRecord.deviceKey));
3693
3700
  credentials.push(await generator.createDeviceProfile({
@@ -3804,7 +3811,7 @@ var IdentityManager = class {
3804
3811
  displayName: this._identity.profileDocument?.displayName
3805
3812
  }, {
3806
3813
  F: __dxlog_file14,
3807
- L: 273,
3814
+ L: 277,
3808
3815
  S: this,
3809
3816
  C: (f, a) => f(...a)
3810
3817
  });
@@ -3818,7 +3825,7 @@ var IdentityManager = class {
3818
3825
  deviceKey: identity.deviceKey
3819
3826
  }, {
3820
3827
  F: __dxlog_file14,
3821
- L: 284,
3828
+ L: 288,
3822
3829
  S: this,
3823
3830
  C: (f, a) => f(...a)
3824
3831
  });
@@ -3829,7 +3836,7 @@ var IdentityManager = class {
3829
3836
  async updateProfile(profile) {
3830
3837
  invariant9(this._identity, "Identity not initialized.", {
3831
3838
  F: __dxlog_file14,
3832
- L: 291,
3839
+ L: 295,
3833
3840
  S: this,
3834
3841
  A: [
3835
3842
  "this._identity",
@@ -3860,7 +3867,7 @@ var IdentityManager = class {
3860
3867
  async updateDeviceProfile(profile) {
3861
3868
  invariant9(this._identity, "Identity not initialized.", {
3862
3869
  F: __dxlog_file14,
3863
- L: 308,
3870
+ L: 312,
3864
3871
  S: this,
3865
3872
  A: [
3866
3873
  "this._identity",
@@ -3896,7 +3903,7 @@ var IdentityManager = class {
3896
3903
  async _constructIdentity(identityRecord) {
3897
3904
  invariant9(!this._identity, void 0, {
3898
3905
  F: __dxlog_file14,
3899
- L: 334,
3906
+ L: 338,
3900
3907
  S: this,
3901
3908
  A: [
3902
3909
  "!this._identity",
@@ -3907,7 +3914,7 @@ var IdentityManager = class {
3907
3914
  identityRecord
3908
3915
  }, {
3909
3916
  F: __dxlog_file14,
3910
- L: 335,
3917
+ L: 339,
3911
3918
  S: this,
3912
3919
  C: (f, a) => f(...a)
3913
3920
  });
@@ -3922,7 +3929,7 @@ var IdentityManager = class {
3922
3929
  });
3923
3930
  invariant9(identityRecord.haloSpace.controlFeedKey, void 0, {
3924
3931
  F: __dxlog_file14,
3925
- L: 348,
3932
+ L: 352,
3926
3933
  S: this,
3927
3934
  A: [
3928
3935
  "identityRecord.haloSpace.controlFeedKey",
@@ -3934,7 +3941,7 @@ var IdentityManager = class {
3934
3941
  });
3935
3942
  invariant9(identityRecord.haloSpace.dataFeedKey, void 0, {
3936
3943
  F: __dxlog_file14,
3937
- L: 352,
3944
+ L: 356,
3938
3945
  S: this,
3939
3946
  A: [
3940
3947
  "identityRecord.haloSpace.dataFeedKey",
@@ -3973,7 +3980,7 @@ var IdentityManager = class {
3973
3980
  identityKey: identityRecord.identityKey
3974
3981
  }, {
3975
3982
  F: __dxlog_file14,
3976
- L: 383,
3983
+ L: 387,
3977
3984
  S: this,
3978
3985
  C: (f, a) => f(...a)
3979
3986
  });
@@ -3998,7 +4005,7 @@ var IdentityManager = class {
3998
4005
  onAuthFailure: () => {
3999
4006
  log11.warn("auth failure", void 0, {
4000
4007
  F: __dxlog_file14,
4001
- L: 408,
4008
+ L: 412,
4002
4009
  S: this,
4003
4010
  C: (f, a) => f(...a)
4004
4011
  });
@@ -4033,13 +4040,7 @@ var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
4033
4040
  var DEFAULT_SPACE_SEARCH_TIMEOUT = 1e4;
4034
4041
  var IdentityServiceImpl = class extends Resource6 {
4035
4042
  constructor(_identityManager, _recoveryManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
4036
- super();
4037
- this._identityManager = _identityManager;
4038
- this._recoveryManager = _recoveryManager;
4039
- this._keyring = _keyring;
4040
- this._dataSpaceManagerProvider = _dataSpaceManagerProvider;
4041
- this._createIdentity = _createIdentity;
4042
- this._onProfileUpdate = _onProfileUpdate;
4043
+ super(), this._identityManager = _identityManager, this._recoveryManager = _recoveryManager, this._keyring = _keyring, this._dataSpaceManagerProvider = _dataSpaceManagerProvider, this._createIdentity = _createIdentity, this._onProfileUpdate = _onProfileUpdate;
4043
4044
  }
4044
4045
  async _open() {
4045
4046
  const identity = this._identityManager.identity;
@@ -4049,7 +4050,7 @@ var IdentityServiceImpl = class extends Resource6 {
4049
4050
  }
4050
4051
  async createIdentity(request) {
4051
4052
  await this._createIdentity({
4052
- displayName: request.profile?.displayName,
4053
+ profile: request.profile,
4053
4054
  deviceProfile: request.deviceProfile
4054
4055
  });
4055
4056
  const dataSpaceManager = this._dataSpaceManagerProvider();
@@ -4224,67 +4225,70 @@ function _ts_decorate6(decorators, target, key, desc) {
4224
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;
4225
4226
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4226
4227
  }
4227
- function _using_ctx3() {
4228
- var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
4229
- var err = new Error();
4230
- err.name = "SuppressedError";
4231
- err.suppressed = suppressed;
4232
- err.error = error;
4233
- return err;
4234
- }, empty = {}, stack = [];
4235
- function using(isAwait, value) {
4236
- if (value != null) {
4237
- if (Object(value) !== value) {
4238
- throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
4239
- }
4240
- if (isAwait) {
4241
- var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
4242
- }
4243
- if (dispose == null) {
4244
- dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
4245
- }
4246
- if (typeof dispose !== "function") {
4247
- throw new TypeError(`Property [Symbol.dispose] is not a function.`);
4248
- }
4249
- stack.push({
4250
- v: value,
4251
- d: dispose,
4252
- a: isAwait
4253
- });
4254
- } else if (isAwait) {
4255
- stack.push({
4256
- d: value,
4257
- a: isAwait
4258
- });
4259
- }
4260
- 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
+ });
4261
4258
  }
4262
- return {
4263
- e: empty,
4264
- u: using.bind(null, false),
4265
- a: using.bind(null, true),
4266
- d: function() {
4267
- var error = this.e;
4268
- function next() {
4269
- while (resource = stack.pop()) {
4270
- try {
4271
- var resource, disposalResult = resource.d && resource.d.call(resource.v);
4272
- if (resource.a) {
4273
- return Promise.resolve(disposalResult).then(next, err);
4274
- }
4275
- } catch (e) {
4276
- return err(e);
4277
- }
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);
4278
4285
  }
4279
- if (error !== empty) throw error;
4280
4286
  }
4281
- function err(e) {
4282
- error = error !== empty ? new _disposeSuppressedError(error, e) : e;
4283
- return next();
4284
- }
4285
- return next();
4287
+ if (s === 1) return env2.hasError ? Promise.reject(env2.error) : Promise.resolve();
4288
+ if (env2.hasError) throw env2.error;
4286
4289
  }
4287
- };
4290
+ return next();
4291
+ })(env);
4288
4292
  }
4289
4293
  var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
4290
4294
  var DataSpace = class {
@@ -4688,8 +4692,12 @@ var DataSpace = class {
4688
4692
  let handle;
4689
4693
  queueMicrotask(async () => {
4690
4694
  try {
4695
+ const env = {
4696
+ stack: [],
4697
+ error: void 0,
4698
+ hasError: false
4699
+ };
4691
4700
  try {
4692
- var _usingCtx = _using_ctx3();
4693
4701
  await warnAfterTimeout(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
4694
4702
  handle = await cancelWithContext2(this._ctx, this._echoHost.automergeRepo.find(rootUrl, FIND_PARAMS2));
4695
4703
  await cancelWithContext2(this._ctx, handle.whenReady());
@@ -4697,10 +4705,7 @@ var DataSpace = class {
4697
4705
  if (this._ctx.disposed) {
4698
4706
  return;
4699
4707
  }
4700
- const _guard = (
4701
- // Ensure only one root is processed at a time.
4702
- _usingCtx.u(await this._epochProcessingMutex.acquire())
4703
- );
4708
+ const _guard = _ts_add_disposable_resource3(env, await this._epochProcessingMutex.acquire(), false);
4704
4709
  const doc = handle.doc() ?? failedInvariant3();
4705
4710
  if (!doc.access?.spaceKey) {
4706
4711
  handle.change((doc2) => {
@@ -4719,10 +4724,11 @@ var DataSpace = class {
4719
4724
  } else {
4720
4725
  this.stateUpdate.emit();
4721
4726
  }
4722
- } catch (_) {
4723
- _usingCtx.e = _;
4727
+ } catch (e) {
4728
+ env.error = e;
4729
+ env.hasError = true;
4724
4730
  } finally {
4725
- _usingCtx.d();
4731
+ _ts_dispose_resources3(env);
4726
4732
  }
4727
4733
  } catch (err) {
4728
4734
  if (err instanceof ContextDisposedError) {
@@ -5235,15 +5241,10 @@ var InvitationGuestExtension = class extends RpcExtension2 {
5235
5241
  exposed: {
5236
5242
  InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
5237
5243
  }
5238
- });
5239
- this._invitationFlowMutex = _invitationFlowMutex;
5240
- this._callbacks = _callbacks;
5241
- this._ctx = new Context7(void 0, {
5244
+ }), this._invitationFlowMutex = _invitationFlowMutex, this._callbacks = _callbacks, this._ctx = new Context7(void 0, {
5242
5245
  F: __dxlog_file19,
5243
5246
  L: 38
5244
- });
5245
- this._remoteOptionsTrigger = new Trigger5();
5246
- this._invitationFlowLock = null;
5247
+ }), this._remoteOptionsTrigger = new Trigger5(), this._invitationFlowLock = null;
5247
5248
  }
5248
5249
  hasFlowLock() {
5249
5250
  return this._invitationFlowLock != null;
@@ -5372,20 +5373,10 @@ var InvitationHostExtension = class extends RpcExtension3 {
5372
5373
  exposed: {
5373
5374
  InvitationHostService: schema5.getService("dxos.halo.invitations.InvitationHostService")
5374
5375
  }
5375
- });
5376
- this._invitationFlowMutex = _invitationFlowMutex;
5377
- this._callbacks = _callbacks;
5378
- this._ctx = new Context8(void 0, {
5376
+ }), this._invitationFlowMutex = _invitationFlowMutex, this._callbacks = _callbacks, this._ctx = new Context8(void 0, {
5379
5377
  F: __dxlog_file20,
5380
5378
  L: 57
5381
- });
5382
- this._remoteOptionsTrigger = new Trigger6();
5383
- this._challenge = void 0;
5384
- this.guestProfile = void 0;
5385
- this.authenticationPassed = false;
5386
- this.authenticationRetry = 0;
5387
- this.completedTrigger = new Trigger6();
5388
- 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;
5389
5380
  }
5390
5381
  hasFlowLock() {
5391
5382
  return this._invitationFlowLock != null;
@@ -7089,14 +7080,14 @@ var InvitationsManager = class {
7089
7080
  }
7090
7081
  }, {
7091
7082
  F: __dxlog_file25,
7092
- L: 236
7083
+ L: 239
7093
7084
  });
7094
7085
  ctx.onDispose(() => {
7095
7086
  log21("complete", {
7096
7087
  ...handler.toJSON()
7097
7088
  }, {
7098
7089
  F: __dxlog_file25,
7099
- L: 243,
7090
+ L: 246,
7100
7091
  S: this,
7101
7092
  C: (f, a) => f(...a)
7102
7093
  });
@@ -7129,7 +7120,7 @@ var InvitationsManager = class {
7129
7120
  ...handler.toJSON()
7130
7121
  }, {
7131
7122
  F: __dxlog_file25,
7132
- L: 263,
7123
+ L: 274,
7133
7124
  S: this,
7134
7125
  C: (f, a) => f(...a)
7135
7126
  });
@@ -7140,7 +7131,7 @@ var InvitationsManager = class {
7140
7131
  } else {
7141
7132
  log21.warn("auth failed", err, {
7142
7133
  F: __dxlog_file25,
7143
- L: 266,
7134
+ L: 277,
7144
7135
  S: this,
7145
7136
  C: (f, a) => f(...a)
7146
7137
  });
@@ -7153,14 +7144,14 @@ var InvitationsManager = class {
7153
7144
  }
7154
7145
  }, {
7155
7146
  F: __dxlog_file25,
7156
- L: 260
7147
+ L: 271
7157
7148
  });
7158
7149
  ctx.onDispose(() => {
7159
7150
  log21("complete", {
7160
7151
  ...handler.toJSON()
7161
7152
  }, {
7162
7153
  F: __dxlog_file25,
7163
- L: 273,
7154
+ L: 284,
7164
7155
  S: this,
7165
7156
  C: (f, a) => f(...a)
7166
7157
  });
@@ -7205,7 +7196,7 @@ var InvitationsManager = class {
7205
7196
  } catch (err) {
7206
7197
  log21.catch(err, void 0, {
7207
7198
  F: __dxlog_file25,
7208
- L: 309,
7199
+ L: 320,
7209
7200
  S: this,
7210
7201
  C: (f, a) => f(...a)
7211
7202
  });
@@ -7229,10 +7220,6 @@ function _ts_decorate7(decorators, target, key, desc) {
7229
7220
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7230
7221
  }
7231
7222
  var __dxlog_file26 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
7232
- var Message;
7233
- (function(Message2) {
7234
- Message2["ACQUIRING"] = "acquiring";
7235
- })(Message || (Message = {}));
7236
7223
  var Lock = class {
7237
7224
  constructor({ lockKey, onAcquire, onRelease }) {
7238
7225
  this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
@@ -7436,13 +7423,7 @@ var AGENT_STATUS_QUERY_RETRY_JITTER = 1e3;
7436
7423
  var AGENT_FEED_ADDED_CHECK_INTERVAL_MS = 3e3;
7437
7424
  var EdgeAgentManager = class extends Resource7 {
7438
7425
  constructor(_edgeFeatures, _edgeHttpClient, _dataSpaceManager, _identity) {
7439
- super();
7440
- this._edgeFeatures = _edgeFeatures;
7441
- this._edgeHttpClient = _edgeHttpClient;
7442
- this._dataSpaceManager = _dataSpaceManager;
7443
- this._identity = _identity;
7444
- this.agentStatusChanged = new Event9();
7445
- this._lastKnownDeviceCount = 0;
7426
+ super(), this._edgeFeatures = _edgeFeatures, this._edgeHttpClient = _edgeHttpClient, this._dataSpaceManager = _dataSpaceManager, this._identity = _identity, this.agentStatusChanged = new Event9(), this._lastKnownDeviceCount = 0;
7446
7427
  }
7447
7428
  get agentStatus() {
7448
7429
  return this._agentStatus;
@@ -7751,7 +7732,7 @@ var EdgeIdentityRecoveryManager = class {
7751
7732
  const identity = this._identityProvider();
7752
7733
  invariant21(identity, void 0, {
7753
7734
  F: __dxlog_file28,
7754
- L: 37,
7735
+ L: 39,
7755
7736
  S: this,
7756
7737
  A: [
7757
7738
  "identity",
@@ -7802,7 +7783,7 @@ var EdgeIdentityRecoveryManager = class {
7802
7783
  async requestRecoveryChallenge() {
7803
7784
  invariant21(this._edgeClient, "Not connected to EDGE.", {
7804
7785
  F: __dxlog_file28,
7805
- L: 74,
7786
+ L: 76,
7806
7787
  S: this,
7807
7788
  A: [
7808
7789
  "this._edgeClient",
@@ -7832,7 +7813,7 @@ var EdgeIdentityRecoveryManager = class {
7832
7813
  async recoverIdentityWithExternalSignature({ lookupKey, deviceKey, controlFeedKey, signature, clientDataJson, authenticatorData }) {
7833
7814
  invariant21(this._edgeClient, "Not connected to EDGE.", {
7834
7815
  F: __dxlog_file28,
7835
- L: 106,
7816
+ L: 108,
7836
7817
  S: this,
7837
7818
  A: [
7838
7819
  "this._edgeClient",
@@ -7866,7 +7847,7 @@ var EdgeIdentityRecoveryManager = class {
7866
7847
  async recoverIdentityWithToken({ token }) {
7867
7848
  invariant21(this._edgeClient, "Not connected to EDGE.", {
7868
7849
  F: __dxlog_file28,
7869
- L: 139,
7850
+ L: 141,
7870
7851
  S: this,
7871
7852
  A: [
7872
7853
  "this._edgeClient",
@@ -7894,7 +7875,7 @@ var EdgeIdentityRecoveryManager = class {
7894
7875
  async recoverIdentity({ recoveryCode }) {
7895
7876
  invariant21(this._edgeClient, "Not connected to EDGE.", {
7896
7877
  F: __dxlog_file28,
7897
- L: 163,
7878
+ L: 165,
7898
7879
  S: this,
7899
7880
  A: [
7900
7881
  "this._edgeClient",
@@ -7925,7 +7906,7 @@ var EdgeIdentityRecoveryManager = class {
7925
7906
  }
7926
7907
  log24.info("recovering identity", response, {
7927
7908
  F: __dxlog_file28,
7928
- L: 189,
7909
+ L: 191,
7929
7910
  S: this,
7930
7911
  C: (f, a) => f(...a)
7931
7912
  });
@@ -7953,86 +7934,75 @@ function _ts_decorate10(decorators, target, key, desc) {
7953
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;
7954
7935
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7955
7936
  }
7956
- function _using_ctx4() {
7957
- var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
7958
- var err = new Error();
7959
- err.name = "SuppressedError";
7960
- err.suppressed = suppressed;
7961
- err.error = error;
7962
- return err;
7963
- }, empty = {}, stack = [];
7964
- function using(isAwait, value) {
7965
- if (value != null) {
7966
- if (Object(value) !== value) {
7967
- throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
7968
- }
7969
- if (isAwait) {
7970
- var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
7971
- }
7972
- if (dispose == null) {
7973
- dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
7974
- }
7975
- if (typeof dispose !== "function") {
7976
- throw new TypeError(`Property [Symbol.dispose] is not a function.`);
7977
- }
7978
- stack.push({
7979
- v: value,
7980
- d: dispose,
7981
- a: isAwait
7982
- });
7983
- } else if (isAwait) {
7984
- stack.push({
7985
- d: value,
7986
- a: isAwait
7987
- });
7988
- }
7989
- 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
+ });
7990
7967
  }
7991
- return {
7992
- e: empty,
7993
- u: using.bind(null, false),
7994
- a: using.bind(null, true),
7995
- d: function() {
7996
- var error = this.e;
7997
- function next() {
7998
- while (resource = stack.pop()) {
7999
- try {
8000
- var resource, disposalResult = resource.d && resource.d.call(resource.v);
8001
- if (resource.a) {
8002
- return Promise.resolve(disposalResult).then(next, err);
8003
- }
8004
- } catch (e) {
8005
- return err(e);
8006
- }
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);
8007
7994
  }
8008
- if (error !== empty) throw error;
8009
- }
8010
- function err(e) {
8011
- error = error !== empty ? new _disposeSuppressedError(error, e) : e;
8012
- return next();
8013
7995
  }
8014
- return next();
7996
+ if (s === 1) return env2.hasError ? Promise.reject(env2.error) : Promise.resolve();
7997
+ if (env2.hasError) throw env2.error;
8015
7998
  }
8016
- };
7999
+ return next();
8000
+ })(env);
8017
8001
  }
8018
8002
  var __dxlog_file29 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
8019
8003
  var ServiceContext = class extends Resource8 {
8020
8004
  constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtimeParams, _edgeFeatures) {
8021
- super();
8022
- this.storage = storage;
8023
- this.level = level;
8024
- this.networkManager = networkManager;
8025
- this.signalManager = signalManager;
8026
- this._edgeConnection = _edgeConnection;
8027
- this._edgeHttpClient = _edgeHttpClient;
8028
- this._runtimeParams = _runtimeParams;
8029
- this._edgeFeatures = _edgeFeatures;
8030
- this._edgeIdentityUpdateMutex = new Mutex4();
8031
- this.initialized = new Trigger9();
8032
- this._meshReplicator = void 0;
8033
- this._echoEdgeReplicator = void 0;
8034
- this._handlerFactories = /* @__PURE__ */ new Map();
8035
- 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();
8036
8006
  this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
8037
8007
  this.blobStore = new BlobStore(storage.createDirectory("blobs"));
8038
8008
  this.keyring = new Keyring(storage.createDirectory("keyring"));
@@ -8067,7 +8037,10 @@ var ServiceContext = class extends Resource8 {
8067
8037
  this.echoHost = new EchoHost({
8068
8038
  kv: this.level,
8069
8039
  peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
8070
- getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key
8040
+ getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key,
8041
+ indexing: {
8042
+ vector: this._runtimeParams?.enableVectorIndexing
8043
+ }
8071
8044
  });
8072
8045
  this._meshReplicator = new MeshEchoReplicator();
8073
8046
  this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeParams?.invitationConnectionDefaultParams);
@@ -8086,7 +8059,7 @@ var ServiceContext = class extends Resource8 {
8086
8059
  await this._checkStorageVersion();
8087
8060
  log25("opening...", void 0, {
8088
8061
  F: __dxlog_file29,
8089
- L: 199,
8062
+ L: 203,
8090
8063
  S: this,
8091
8064
  C: (f, a) => f(...a)
8092
8065
  });
@@ -8094,7 +8067,7 @@ var ServiceContext = class extends Resource8 {
8094
8067
  id: this._instanceId
8095
8068
  }), {
8096
8069
  F: __dxlog_file29,
8097
- L: 200,
8070
+ L: 204,
8098
8071
  S: this,
8099
8072
  C: (f, a) => f(...a)
8100
8073
  });
@@ -8121,7 +8094,7 @@ var ServiceContext = class extends Resource8 {
8121
8094
  count: loadedInvitations.invitations?.length
8122
8095
  }, {
8123
8096
  F: __dxlog_file29,
8124
- L: 228,
8097
+ L: 232,
8125
8098
  S: this,
8126
8099
  C: (f, a) => f(...a)
8127
8100
  });
@@ -8129,13 +8102,13 @@ var ServiceContext = class extends Resource8 {
8129
8102
  id: this._instanceId
8130
8103
  }), {
8131
8104
  F: __dxlog_file29,
8132
- L: 230,
8105
+ L: 234,
8133
8106
  S: this,
8134
8107
  C: (f, a) => f(...a)
8135
8108
  });
8136
8109
  log25("opened", void 0, {
8137
8110
  F: __dxlog_file29,
8138
- L: 231,
8111
+ L: 235,
8139
8112
  S: this,
8140
8113
  C: (f, a) => f(...a)
8141
8114
  });
@@ -8143,7 +8116,7 @@ var ServiceContext = class extends Resource8 {
8143
8116
  async _close(ctx) {
8144
8117
  log25("closing...", void 0, {
8145
8118
  F: __dxlog_file29,
8146
- L: 235,
8119
+ L: 239,
8147
8120
  S: this,
8148
8121
  C: (f, a) => f(...a)
8149
8122
  });
@@ -8162,7 +8135,7 @@ var ServiceContext = class extends Resource8 {
8162
8135
  await this._edgeConnection?.close();
8163
8136
  log25("closed", void 0, {
8164
8137
  F: __dxlog_file29,
8165
- L: 251,
8138
+ L: 255,
8166
8139
  S: this,
8167
8140
  C: (f, a) => f(...a)
8168
8141
  });
@@ -8173,7 +8146,7 @@ var ServiceContext = class extends Resource8 {
8173
8146
  await identity.joinNetwork();
8174
8147
  await this._initialize(new Context10(void 0, {
8175
8148
  F: __dxlog_file29,
8176
- L: 258
8149
+ L: 262
8177
8150
  }));
8178
8151
  return identity;
8179
8152
  }
@@ -8184,7 +8157,7 @@ var ServiceContext = class extends Resource8 {
8184
8157
  const factory = this._handlerFactories.get(invitation.kind);
8185
8158
  invariant22(factory, `Unknown invitation kind: ${invitation.kind}`, {
8186
8159
  F: __dxlog_file29,
8187
- L: 267,
8160
+ L: 271,
8188
8161
  S: this,
8189
8162
  A: [
8190
8163
  "factory",
@@ -8210,7 +8183,7 @@ var ServiceContext = class extends Resource8 {
8210
8183
  await this.identityManager.acceptIdentity(identity, identityRecord, params.deviceProfile);
8211
8184
  await this._initialize(new Context10(void 0, {
8212
8185
  F: __dxlog_file29,
8213
- L: 286
8186
+ L: 290
8214
8187
  }));
8215
8188
  return identity;
8216
8189
  }
@@ -8224,7 +8197,7 @@ var ServiceContext = class extends Resource8 {
8224
8197
  async _initialize(ctx) {
8225
8198
  log25("initializing spaces...", void 0, {
8226
8199
  F: __dxlog_file29,
8227
- L: 301,
8200
+ L: 305,
8228
8201
  S: this,
8229
8202
  C: (f, a) => f(...a)
8230
8203
  });
@@ -8263,7 +8236,7 @@ var ServiceContext = class extends Resource8 {
8263
8236
  this._handlerFactories.set(Invitation10.Kind.SPACE, (invitation) => {
8264
8237
  invariant22(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
8265
8238
  F: __dxlog_file29,
8266
- L: 339,
8239
+ L: 343,
8267
8240
  S: this,
8268
8241
  A: [
8269
8242
  "this.dataSpaceManager",
@@ -8287,7 +8260,7 @@ var ServiceContext = class extends Resource8 {
8287
8260
  details: assertion
8288
8261
  }, {
8289
8262
  F: __dxlog_file29,
8290
- L: 355,
8263
+ L: 359,
8291
8264
  S: this,
8292
8265
  C: (f, a) => f(...a)
8293
8266
  });
@@ -8298,7 +8271,7 @@ var ServiceContext = class extends Resource8 {
8298
8271
  details: assertion
8299
8272
  }, {
8300
8273
  F: __dxlog_file29,
8301
- L: 359,
8274
+ L: 363,
8302
8275
  S: this,
8303
8276
  C: (f, a) => f(...a)
8304
8277
  });
@@ -8309,7 +8282,7 @@ var ServiceContext = class extends Resource8 {
8309
8282
  details: assertion
8310
8283
  }, {
8311
8284
  F: __dxlog_file29,
8312
- L: 364,
8285
+ L: 368,
8313
8286
  S: this,
8314
8287
  C: (f, a) => f(...a)
8315
8288
  });
@@ -8320,7 +8293,7 @@ var ServiceContext = class extends Resource8 {
8320
8293
  } catch (err) {
8321
8294
  log25.catch(err, void 0, {
8322
8295
  F: __dxlog_file29,
8323
- L: 370,
8296
+ L: 374,
8324
8297
  S: this,
8325
8298
  C: (f, a) => f(...a)
8326
8299
  });
@@ -8330,9 +8303,13 @@ var ServiceContext = class extends Resource8 {
8330
8303
  await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
8331
8304
  }
8332
8305
  async _setNetworkIdentity(params) {
8306
+ const env = {
8307
+ stack: [],
8308
+ error: void 0,
8309
+ hasError: false
8310
+ };
8333
8311
  try {
8334
- var _usingCtx = _using_ctx4();
8335
- const _ = _usingCtx.u(await this._edgeIdentityUpdateMutex.acquire());
8312
+ const _ = _ts_add_disposable_resource4(env, await this._edgeIdentityUpdateMutex.acquire(), false);
8336
8313
  let edgeIdentity;
8337
8314
  const identity = this.identityManager.identity;
8338
8315
  if (identity) {
@@ -8341,7 +8318,7 @@ var ServiceContext = class extends Resource8 {
8341
8318
  swarms: this.networkManager.topics
8342
8319
  }, {
8343
8320
  F: __dxlog_file29,
8344
- L: 384,
8321
+ L: 388,
8345
8322
  S: this,
8346
8323
  C: (f, a) => f(...a)
8347
8324
  });
@@ -8355,7 +8332,7 @@ var ServiceContext = class extends Resource8 {
8355
8332
  });
8356
8333
  invariant22(identity.deviceCredentialChain, void 0, {
8357
8334
  F: __dxlog_file29,
8358
- L: 403,
8335
+ L: 407,
8359
8336
  S: this,
8360
8337
  A: [
8361
8338
  "identity.deviceCredentialChain",
@@ -8373,10 +8350,11 @@ var ServiceContext = class extends Resource8 {
8373
8350
  identityKey: edgeIdentity.identityKey,
8374
8351
  peerKey: edgeIdentity.peerKey
8375
8352
  });
8376
- } catch (_) {
8377
- _usingCtx.e = _;
8353
+ } catch (e) {
8354
+ env.error = e;
8355
+ env.hasError = true;
8378
8356
  } finally {
8379
- _usingCtx.d();
8357
+ _ts_dispose_resources4(env);
8380
8358
  }
8381
8359
  }
8382
8360
  };
@@ -9111,6 +9089,9 @@ var ClientServicesHost = class {
9111
9089
  if (this._runtimeParams.disableP2pReplication === void 0) {
9112
9090
  this._runtimeParams.disableP2pReplication = config?.get("runtime.client.disableP2pReplication", false);
9113
9091
  }
9092
+ if (this._runtimeParams.enableVectorIndexing === void 0) {
9093
+ this._runtimeParams.enableVectorIndexing = config?.get("runtime.client.enableVectorIndexing", false);
9094
+ }
9114
9095
  if (config) {
9115
9096
  this.initialize({
9116
9097
  config,
@@ -9125,7 +9106,7 @@ var ClientServicesHost = class {
9125
9106
  if (!this._opening) {
9126
9107
  void this.open(new Context11(void 0, {
9127
9108
  F: __dxlog_file32,
9128
- L: 137
9109
+ L: 141
9129
9110
  }));
9130
9111
  }
9131
9112
  },
@@ -9183,7 +9164,7 @@ var ClientServicesHost = class {
9183
9164
  initialize({ config, ...options }) {
9184
9165
  invariant25(!this._open, "service host is open", {
9185
9166
  F: __dxlog_file32,
9186
- L: 203,
9167
+ L: 207,
9187
9168
  S: this,
9188
9169
  A: [
9189
9170
  "!this._open",
@@ -9192,14 +9173,14 @@ var ClientServicesHost = class {
9192
9173
  });
9193
9174
  log28("initializing...", void 0, {
9194
9175
  F: __dxlog_file32,
9195
- L: 204,
9176
+ L: 208,
9196
9177
  S: this,
9197
9178
  C: (f, a) => f(...a)
9198
9179
  });
9199
9180
  if (config) {
9200
9181
  invariant25(!this._config, "config already set", {
9201
9182
  F: __dxlog_file32,
9202
- L: 207,
9183
+ L: 211,
9203
9184
  S: this,
9204
9185
  A: [
9205
9186
  "!this._config",
@@ -9214,7 +9195,7 @@ var ClientServicesHost = class {
9214
9195
  if (!options.signalManager) {
9215
9196
  log28.warn("running signaling without telemetry metadata.", void 0, {
9216
9197
  F: __dxlog_file32,
9217
- L: 215,
9198
+ L: 219,
9218
9199
  S: this,
9219
9200
  C: (f, a) => f(...a)
9220
9201
  });
@@ -9234,7 +9215,7 @@ var ClientServicesHost = class {
9234
9215
  this._signalManager = signalManager;
9235
9216
  invariant25(!this._networkManager, "network manager already set", {
9236
9217
  F: __dxlog_file32,
9237
- L: 237,
9218
+ L: 241,
9238
9219
  S: this,
9239
9220
  A: [
9240
9221
  "!this._networkManager",
@@ -9252,7 +9233,7 @@ var ClientServicesHost = class {
9252
9233
  });
9253
9234
  log28("initialized", void 0, {
9254
9235
  F: __dxlog_file32,
9255
- L: 250,
9236
+ L: 254,
9256
9237
  S: this,
9257
9238
  C: (f, a) => f(...a)
9258
9239
  });
@@ -9266,13 +9247,13 @@ var ClientServicesHost = class {
9266
9247
  id: traceId
9267
9248
  }), {
9268
9249
  F: __dxlog_file32,
9269
- L: 261,
9250
+ L: 265,
9270
9251
  S: this,
9271
9252
  C: (f, a) => f(...a)
9272
9253
  });
9273
9254
  invariant25(this._config, "config not set", {
9274
9255
  F: __dxlog_file32,
9275
- L: 263,
9256
+ L: 267,
9276
9257
  S: this,
9277
9258
  A: [
9278
9259
  "this._config",
@@ -9281,7 +9262,7 @@ var ClientServicesHost = class {
9281
9262
  });
9282
9263
  invariant25(this._storage, "storage not set", {
9283
9264
  F: __dxlog_file32,
9284
- L: 264,
9265
+ L: 268,
9285
9266
  S: this,
9286
9267
  A: [
9287
9268
  "this._storage",
@@ -9290,7 +9271,7 @@ var ClientServicesHost = class {
9290
9271
  });
9291
9272
  invariant25(this._signalManager, "signal manager not set", {
9292
9273
  F: __dxlog_file32,
9293
- L: 265,
9274
+ L: 269,
9294
9275
  S: this,
9295
9276
  A: [
9296
9277
  "this._signalManager",
@@ -9299,7 +9280,7 @@ var ClientServicesHost = class {
9299
9280
  });
9300
9281
  invariant25(this._networkManager, "network manager not set", {
9301
9282
  F: __dxlog_file32,
9302
- L: 266,
9283
+ L: 270,
9303
9284
  S: this,
9304
9285
  A: [
9305
9286
  "this._networkManager",
@@ -9311,7 +9292,7 @@ var ClientServicesHost = class {
9311
9292
  lockKey: this._resourceLock?.lockKey
9312
9293
  }, {
9313
9294
  F: __dxlog_file32,
9314
- L: 269,
9295
+ L: 273,
9315
9296
  S: this,
9316
9297
  C: (f, a) => f(...a)
9317
9298
  });
@@ -9372,7 +9353,7 @@ var ClientServicesHost = class {
9372
9353
  deviceKey
9373
9354
  }, {
9374
9355
  F: __dxlog_file32,
9375
- L: 370,
9356
+ L: 374,
9376
9357
  S: this,
9377
9358
  C: (f, a) => f(...a)
9378
9359
  });
@@ -9380,7 +9361,7 @@ var ClientServicesHost = class {
9380
9361
  id: traceId
9381
9362
  }), {
9382
9363
  F: __dxlog_file32,
9383
- L: 371,
9364
+ L: 375,
9384
9365
  S: this,
9385
9366
  C: (f, a) => f(...a)
9386
9367
  });
@@ -9394,7 +9375,7 @@ var ClientServicesHost = class {
9394
9375
  deviceKey
9395
9376
  }, {
9396
9377
  F: __dxlog_file32,
9397
- L: 382,
9378
+ L: 386,
9398
9379
  S: this,
9399
9380
  C: (f, a) => f(...a)
9400
9381
  });
@@ -9412,7 +9393,7 @@ var ClientServicesHost = class {
9412
9393
  deviceKey
9413
9394
  }, {
9414
9395
  F: __dxlog_file32,
9415
- L: 391,
9396
+ L: 395,
9416
9397
  S: this,
9417
9398
  C: (f, a) => f(...a)
9418
9399
  });
@@ -9423,13 +9404,13 @@ var ClientServicesHost = class {
9423
9404
  id: traceId
9424
9405
  }), {
9425
9406
  F: __dxlog_file32,
9426
- L: 396,
9407
+ L: 400,
9427
9408
  S: this,
9428
9409
  C: (f, a) => f(...a)
9429
9410
  });
9430
9411
  log28.info("resetting...", void 0, {
9431
9412
  F: __dxlog_file32,
9432
- L: 398,
9413
+ L: 402,
9433
9414
  S: this,
9434
9415
  C: (f, a) => f(...a)
9435
9416
  });
@@ -9439,7 +9420,7 @@ var ClientServicesHost = class {
9439
9420
  await this._storage.reset();
9440
9421
  log28.info("reset", void 0, {
9441
9422
  F: __dxlog_file32,
9442
- L: 405,
9423
+ L: 409,
9443
9424
  S: this,
9444
9425
  C: (f, a) => f(...a)
9445
9426
  });
@@ -9447,7 +9428,7 @@ var ClientServicesHost = class {
9447
9428
  id: traceId
9448
9429
  }), {
9449
9430
  F: __dxlog_file32,
9450
- L: 406,
9431
+ L: 410,
9451
9432
  S: this,
9452
9433
  C: (f, a) => f(...a)
9453
9434
  });
@@ -9525,4 +9506,4 @@ export {
9525
9506
  importProfileData,
9526
9507
  ClientServicesHost
9527
9508
  };
9528
- //# sourceMappingURL=chunk-I3QLQXQD.mjs.map
9509
+ //# sourceMappingURL=chunk-AA2G5WEV.mjs.map