@dxos/client-services 0.8.2-main.f11618f → 0.8.2-staging.42af850

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 (126) hide show
  1. package/dist/lib/browser/{chunk-R24OWGT7.mjs → chunk-YSJIZAYP.mjs} +484 -490
  2. package/dist/lib/browser/chunk-YSJIZAYP.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-ZIKA2DAN.cjs → chunk-XIZXFDK7.cjs} +485 -480
  9. package/dist/lib/node/chunk-XIZXFDK7.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-QLUXYSIC.mjs → chunk-LE5QCJLR.mjs} +484 -479
  16. package/dist/lib/node-esm/chunk-LE5QCJLR.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/devtools/feeds.d.ts.map +1 -1
  24. package/dist/types/src/packlets/devtools/keys.d.ts.map +1 -1
  25. package/dist/types/src/packlets/devtools/metadata.d.ts.map +1 -1
  26. package/dist/types/src/packlets/devtools/network.d.ts.map +1 -1
  27. package/dist/types/src/packlets/devtools/spaces.d.ts.map +1 -1
  28. package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts.map +1 -1
  29. package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts.map +1 -1
  30. package/dist/types/src/packlets/diagnostics/diagnostics.d.ts.map +1 -1
  31. package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
  32. package/dist/types/src/packlets/identity/default-space-state-machine.d.ts.map +1 -1
  33. package/dist/types/src/packlets/identity/identity-manager.d.ts +2 -2
  34. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  35. package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +1 -1
  36. package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -1
  37. package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
  38. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  39. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
  40. package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts.map +1 -1
  41. package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts.map +1 -1
  42. package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts.map +1 -1
  43. package/dist/types/src/packlets/invitations/invitation-state.d.ts.map +1 -1
  44. package/dist/types/src/packlets/invitations/invitation-topology.d.ts.map +1 -1
  45. package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -1
  46. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +1 -1
  47. package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
  48. package/dist/types/src/packlets/invitations/utils.d.ts.map +1 -1
  49. package/dist/types/src/packlets/locks/browser.d.ts.map +1 -1
  50. package/dist/types/src/packlets/locks/node.d.ts.map +1 -1
  51. package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
  52. package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
  53. package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
  54. package/dist/types/src/packlets/services/service-context.d.ts +1 -0
  55. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  56. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  57. package/dist/types/src/packlets/services/service-registry.d.ts.map +1 -1
  58. package/dist/types/src/packlets/services/util.d.ts.map +1 -1
  59. package/dist/types/src/packlets/space-export/space-archive-reader.d.ts +1 -1
  60. package/dist/types/src/packlets/space-export/space-archive-reader.d.ts.map +1 -1
  61. package/dist/types/src/packlets/space-export/space-archive-writer.d.ts.map +1 -1
  62. package/dist/types/src/packlets/spaces/automerge-space-state.d.ts.map +1 -1
  63. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +1 -1
  64. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  65. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  66. package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts.map +1 -1
  67. package/dist/types/src/packlets/spaces/epoch-migrations.d.ts.map +1 -1
  68. package/dist/types/src/packlets/spaces/genesis.d.ts.map +1 -1
  69. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
  70. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  71. package/dist/types/src/packlets/storage/level.d.ts.map +1 -1
  72. package/dist/types/src/packlets/storage/profile-archive.d.ts.map +1 -1
  73. package/dist/types/src/packlets/storage/storage.d.ts.map +1 -1
  74. package/dist/types/src/packlets/storage/util.d.ts.map +1 -1
  75. package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
  76. package/dist/types/src/packlets/testing/credential-utils.d.ts.map +1 -1
  77. package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
  78. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  79. package/dist/types/src/packlets/worker/worker-runtime.d.ts.map +1 -1
  80. package/dist/types/src/packlets/worker/worker-session.d.ts.map +1 -1
  81. package/dist/types/src/version.d.ts +1 -1
  82. package/dist/types/src/version.d.ts.map +1 -1
  83. package/dist/types/tsconfig.tsbuildinfo +1 -1
  84. package/package.json +39 -38
  85. package/src/packlets/agents/edge-agent-manager.ts +6 -6
  86. package/src/packlets/identity/authenticator.ts +2 -2
  87. package/src/packlets/identity/default-space-state-machine.ts +1 -1
  88. package/src/packlets/identity/identity-manager.ts +13 -9
  89. package/src/packlets/identity/identity-recovery-manager.ts +6 -4
  90. package/src/packlets/identity/identity-service.ts +4 -4
  91. package/src/packlets/identity/identity.ts +5 -5
  92. package/src/packlets/invitations/device-invitation-protocol.ts +1 -1
  93. package/src/packlets/invitations/edge-invitation-handler.ts +3 -3
  94. package/src/packlets/invitations/invitation-guest-extenstion.ts +3 -3
  95. package/src/packlets/invitations/invitation-host-extension.ts +5 -5
  96. package/src/packlets/invitations/invitation-topology.ts +1 -1
  97. package/src/packlets/invitations/invitations-handler.ts +2 -2
  98. package/src/packlets/invitations/invitations-manager.ts +15 -4
  99. package/src/packlets/invitations/space-invitation-protocol.ts +1 -1
  100. package/src/packlets/locks/browser.ts +4 -4
  101. package/src/packlets/locks/node.ts +2 -2
  102. package/src/packlets/logging/logging-service.ts +2 -2
  103. package/src/packlets/network/network-service.ts +2 -2
  104. package/src/packlets/services/client-rpc-server.ts +2 -2
  105. package/src/packlets/services/service-context.ts +10 -6
  106. package/src/packlets/services/service-host.ts +8 -4
  107. package/src/packlets/services/service-registry.ts +3 -3
  108. package/src/packlets/space-export/space-archive-reader.ts +2 -1
  109. package/src/packlets/space-export/space-archive-writer.ts +3 -3
  110. package/src/packlets/spaces/automerge-space-state.ts +3 -3
  111. package/src/packlets/spaces/data-space-manager.ts +45 -39
  112. package/src/packlets/spaces/data-space.ts +27 -20
  113. package/src/packlets/spaces/edge-feed-replicator.ts +12 -12
  114. package/src/packlets/spaces/epoch-migrations.ts +3 -2
  115. package/src/packlets/spaces/notarization-plugin.test.ts +1 -1
  116. package/src/packlets/spaces/notarization-plugin.ts +18 -18
  117. package/src/packlets/spaces/spaces-service.ts +7 -6
  118. package/src/packlets/storage/profile-archive.ts +2 -1
  119. package/src/packlets/system/system-service.ts +2 -2
  120. package/src/packlets/testing/test-builder.ts +3 -3
  121. package/src/packlets/worker/worker-runtime.ts +4 -4
  122. package/src/packlets/worker/worker-session.ts +3 -3
  123. package/src/version.ts +1 -1
  124. package/dist/lib/browser/chunk-R24OWGT7.mjs.map +0 -7
  125. package/dist/lib/node/chunk-ZIKA2DAN.cjs.map +0 -7
  126. package/dist/lib/node-esm/chunk-QLUXYSIC.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.f11618f";
400
+ var DXOS_VERSION = "0.8.2-staging.42af850";
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() {
@@ -1307,12 +1313,12 @@ var bufferizeBlock = (block) => ({
1307
1313
  });
1308
1314
 
1309
1315
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
1316
+ import { save } from "@automerge/automerge";
1310
1317
  import { Event as Event7, Mutex as Mutex2, scheduleTask as scheduleTask4, sleep as sleep3, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
1311
- import { save } from "@dxos/automerge/automerge";
1312
1318
  import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
1313
1319
  import { Context as Context6, ContextDisposedError, cancelWithContext as cancelWithContext2 } from "@dxos/context";
1314
1320
  import { timed, warnAfterTimeout } from "@dxos/debug";
1315
- import { createMappedFeedWriter } from "@dxos/echo-pipeline";
1321
+ import { createMappedFeedWriter, FIND_PARAMS as FIND_PARAMS2 } from "@dxos/echo-pipeline";
1316
1322
  import { SpaceDocVersion as SpaceDocVersion2 } from "@dxos/echo-protocol";
1317
1323
  import { failedInvariant as failedInvariant3, invariant as invariant11 } from "@dxos/invariant";
1318
1324
  import { PublicKey as PublicKey8 } from "@dxos/keys";
@@ -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
  }
@@ -1390,7 +1391,7 @@ var runEpochMigration = async (ctx, context) => {
1390
1391
  const rootHandle = await context.echoHost.loadDoc(ctx, context.currentRoot, {
1391
1392
  timeout: LOAD_DOC_TIMEOUT
1392
1393
  });
1393
- const newRoot = context.echoHost.createDoc(rootHandle.docSync());
1394
+ const newRoot = context.echoHost.createDoc(rootHandle.doc());
1394
1395
  await context.echoHost.flush();
1395
1396
  return {
1396
1397
  newRoot: newRoot.url
@@ -1406,7 +1407,7 @@ var runEpochMigration = async (ctx, context) => {
1406
1407
  case CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT: {
1407
1408
  invariant3(context.newAutomergeRoot, void 0, {
1408
1409
  F: __dxlog_file7,
1409
- L: 62,
1410
+ L: 63,
1410
1411
  S: void 0,
1411
1412
  A: [
1412
1413
  "context.newAutomergeRoot",
@@ -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 {
@@ -1935,12 +1935,12 @@ var DefaultSpaceStateMachine = class {
1935
1935
  };
1936
1936
 
1937
1937
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
1938
+ import { interpretAsDocumentId } from "@automerge/automerge-repo";
1938
1939
  import { Event as Event4, synchronized, trackLeaks } from "@dxos/async";
1939
- import { interpretAsDocumentId } from "@dxos/automerge/automerge-repo";
1940
1940
  import { PropertiesType, TYPE_PROPERTIES } from "@dxos/client-protocol";
1941
1941
  import { Context as Context4, LifecycleState, Resource as Resource4, cancelWithContext } from "@dxos/context";
1942
1942
  import { createAdmissionCredentials, getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
1943
- import { DatabaseRoot, findInlineObjectOfType, AuthStatus, CredentialServerExtension } from "@dxos/echo-pipeline";
1943
+ import { DatabaseRoot, findInlineObjectOfType, AuthStatus, CredentialServerExtension, FIND_PARAMS } from "@dxos/echo-pipeline";
1944
1944
  import { SpaceDocVersion, createIdFromSpaceKey, encodeReference } from "@dxos/echo-protocol";
1945
1945
  import { ObjectId, getTypeReference } from "@dxos/echo-schema";
1946
1946
  import { writeMessages } from "@dxos/feed-store";
@@ -2065,10 +2065,11 @@ var DataSpaceManager = class extends Resource4 {
2065
2065
  id: "spaces",
2066
2066
  name: "Spaces",
2067
2067
  fetch: async () => {
2068
- return Array.from(this._spaces.values()).map((space) => {
2068
+ return Promise.all(Array.from(this._spaces.values()).map(async (space) => {
2069
2069
  const rootUrl = space.automergeSpaceState.rootUrl;
2070
- const rootHandle = rootUrl ? this._echoHost.automergeRepo.find(rootUrl) : void 0;
2071
- 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();
2072
2073
  const properties = rootDoc && findInlineObjectOfType(rootDoc, TYPE_PROPERTIES);
2073
2074
  return {
2074
2075
  key: space.key.toHex(),
@@ -2080,7 +2081,7 @@ var DataSpaceManager = class extends Resource4 {
2080
2081
  members: space.inner.spaceState.members.size,
2081
2082
  rootUrl
2082
2083
  };
2083
- });
2084
+ }));
2084
2085
  }
2085
2086
  });
2086
2087
  }
@@ -2096,7 +2097,7 @@ var DataSpaceManager = class extends Resource4 {
2096
2097
  async _open() {
2097
2098
  log7("open", void 0, {
2098
2099
  F: __dxlog_file10,
2099
- L: 213,
2100
+ L: 215,
2100
2101
  S: this,
2101
2102
  C: (f, a) => f(...a)
2102
2103
  });
@@ -2104,7 +2105,7 @@ var DataSpaceManager = class extends Resource4 {
2104
2105
  id: this._instanceId
2105
2106
  }), {
2106
2107
  F: __dxlog_file10,
2107
- L: 214,
2108
+ L: 216,
2108
2109
  S: this,
2109
2110
  C: (f, a) => f(...a)
2110
2111
  });
@@ -2112,7 +2113,7 @@ var DataSpaceManager = class extends Resource4 {
2112
2113
  spaces: this._metadataStore.spaces.length
2113
2114
  }, {
2114
2115
  F: __dxlog_file10,
2115
- L: 215,
2116
+ L: 217,
2116
2117
  S: this,
2117
2118
  C: (f, a) => f(...a)
2118
2119
  });
@@ -2122,7 +2123,7 @@ var DataSpaceManager = class extends Resource4 {
2122
2123
  spaceMetadata
2123
2124
  }, {
2124
2125
  F: __dxlog_file10,
2125
- L: 219,
2126
+ L: 221,
2126
2127
  S: this,
2127
2128
  C: (f, a) => f(...a)
2128
2129
  });
@@ -2133,7 +2134,7 @@ var DataSpaceManager = class extends Resource4 {
2133
2134
  err
2134
2135
  }, {
2135
2136
  F: __dxlog_file10,
2136
- L: 222,
2137
+ L: 224,
2137
2138
  S: this,
2138
2139
  C: (f, a) => f(...a)
2139
2140
  });
@@ -2144,7 +2145,7 @@ var DataSpaceManager = class extends Resource4 {
2144
2145
  id: this._instanceId
2145
2146
  }), {
2146
2147
  F: __dxlog_file10,
2147
- L: 228,
2148
+ L: 230,
2148
2149
  S: this,
2149
2150
  C: (f, a) => f(...a)
2150
2151
  });
@@ -2152,7 +2153,7 @@ var DataSpaceManager = class extends Resource4 {
2152
2153
  async _close() {
2153
2154
  log7("close", void 0, {
2154
2155
  F: __dxlog_file10,
2155
- L: 233,
2156
+ L: 235,
2156
2157
  S: this,
2157
2158
  C: (f, a) => f(...a)
2158
2159
  });
@@ -2183,7 +2184,7 @@ var DataSpaceManager = class extends Resource4 {
2183
2184
  spaceKey
2184
2185
  }, {
2185
2186
  F: __dxlog_file10,
2186
- L: 262,
2187
+ L: 264,
2187
2188
  S: this,
2188
2189
  C: (f, a) => f(...a)
2189
2190
  });
@@ -2191,7 +2192,7 @@ var DataSpaceManager = class extends Resource4 {
2191
2192
  if (options.documents) {
2192
2193
  invariant5(Object.keys(options.documents).every((documentId) => /^[a-zA-Z0-9]+$/.test(documentId)), "Invalid document IDs", {
2193
2194
  F: __dxlog_file10,
2194
- L: 267,
2195
+ L: 269,
2195
2196
  S: this,
2196
2197
  A: [
2197
2198
  "Object.keys(options.documents).every((documentId) => /^[a-zA-Z0-9]+$/.test(documentId))",
@@ -2203,7 +2204,7 @@ var DataSpaceManager = class extends Resource4 {
2203
2204
  documentId
2204
2205
  }, {
2205
2206
  F: __dxlog_file10,
2206
- L: 274,
2207
+ L: 276,
2207
2208
  S: this,
2208
2209
  C: (f, a) => f(...a)
2209
2210
  });
@@ -2217,7 +2218,7 @@ var DataSpaceManager = class extends Resource4 {
2217
2218
  spaceKey
2218
2219
  }, {
2219
2220
  F: __dxlog_file10,
2220
- L: 281,
2221
+ L: 283,
2221
2222
  S: this,
2222
2223
  C: (f, a) => f(...a)
2223
2224
  });
@@ -2226,7 +2227,7 @@ var DataSpaceManager = class extends Resource4 {
2226
2227
  const newRootDocId = documentIdMapping[interpretAsDocumentId(options.rootUrl)] ?? failedInvariant();
2227
2228
  const rootDocHandle = await this._echoHost.loadDoc(Context4.default(void 0, {
2228
2229
  F: __dxlog_file10,
2229
- L: 286
2230
+ L: 288
2230
2231
  }), newRootDocId);
2231
2232
  DatabaseRoot.mapLinks(rootDocHandle, documentIdMapping);
2232
2233
  root = await this._echoHost.openSpaceRoot(spaceId, `automerge:${newRootDocId}`);
@@ -2237,7 +2238,7 @@ var DataSpaceManager = class extends Resource4 {
2237
2238
  spaceKey
2238
2239
  }, {
2239
2240
  F: __dxlog_file10,
2240
- L: 294,
2241
+ L: 296,
2241
2242
  S: this,
2242
2243
  C: (f, a) => f(...a)
2243
2244
  });
@@ -2247,7 +2248,7 @@ var DataSpaceManager = class extends Resource4 {
2247
2248
  spaceKey
2248
2249
  }, {
2249
2250
  F: __dxlog_file10,
2250
- L: 299,
2251
+ L: 301,
2251
2252
  S: this,
2252
2253
  C: (f, a) => f(...a)
2253
2254
  });
@@ -2256,7 +2257,7 @@ var DataSpaceManager = class extends Resource4 {
2256
2257
  const memberCredential = credentials[1];
2257
2258
  invariant5(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2258
2259
  F: __dxlog_file10,
2259
- L: 305,
2260
+ L: 307,
2260
2261
  S: this,
2261
2262
  A: [
2262
2263
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2270,7 +2271,7 @@ var DataSpaceManager = class extends Resource4 {
2270
2271
  spaceKey
2271
2272
  }, {
2272
2273
  F: __dxlog_file10,
2273
- L: 310,
2274
+ L: 312,
2274
2275
  S: this,
2275
2276
  C: (f, a) => f(...a)
2276
2277
  });
@@ -2283,7 +2284,18 @@ var DataSpaceManager = class extends Resource4 {
2283
2284
  }
2284
2285
  switch (space.databaseRoot.getVersion()) {
2285
2286
  case SpaceDocVersion.CURRENT: {
2286
- 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) ?? [];
2287
2299
  return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
2288
2300
  }
2289
2301
  case SpaceDocVersion.LEGACY: {
@@ -2295,7 +2307,7 @@ var DataSpaceManager = class extends Resource4 {
2295
2307
  spaceId: space.id
2296
2308
  }, {
2297
2309
  F: __dxlog_file10,
2298
- L: 330,
2310
+ L: 336,
2299
2311
  S: this,
2300
2312
  C: (f, a) => f(...a)
2301
2313
  });
@@ -2330,14 +2342,14 @@ var DataSpaceManager = class extends Resource4 {
2330
2342
  const automergeIndex = space.automergeSpaceState.rootUrl;
2331
2343
  invariant5(automergeIndex, void 0, {
2332
2344
  F: __dxlog_file10,
2333
- L: 363,
2345
+ L: 369,
2334
2346
  S: this,
2335
2347
  A: [
2336
2348
  "automergeIndex",
2337
2349
  ""
2338
2350
  ]
2339
2351
  });
2340
- const document = this._echoHost.automergeRepo.find(automergeIndex);
2352
+ const document = await this._echoHost.automergeRepo.find(automergeIndex, FIND_PARAMS);
2341
2353
  await document.whenReady();
2342
2354
  return document;
2343
2355
  }
@@ -2347,13 +2359,13 @@ var DataSpaceManager = class extends Resource4 {
2347
2359
  opts
2348
2360
  }, {
2349
2361
  F: __dxlog_file10,
2350
- L: 372,
2362
+ L: 378,
2351
2363
  S: this,
2352
2364
  C: (f, a) => f(...a)
2353
2365
  });
2354
2366
  invariant5(this._lifecycleState === LifecycleState.OPEN, "Not open.", {
2355
2367
  F: __dxlog_file10,
2356
- L: 373,
2368
+ L: 379,
2357
2369
  S: this,
2358
2370
  A: [
2359
2371
  "this._lifecycleState === LifecycleState.OPEN",
@@ -2362,7 +2374,7 @@ var DataSpaceManager = class extends Resource4 {
2362
2374
  });
2363
2375
  invariant5(!this._spaces.has(opts.spaceKey), "Space already exists.", {
2364
2376
  F: __dxlog_file10,
2365
- L: 374,
2377
+ L: 380,
2366
2378
  S: this,
2367
2379
  A: [
2368
2380
  "!this._spaces.has(opts.spaceKey)",
@@ -2386,7 +2398,7 @@ var DataSpaceManager = class extends Resource4 {
2386
2398
  const space = this._spaceManager.spaces.get(options.spaceKey);
2387
2399
  invariant5(space, void 0, {
2388
2400
  F: __dxlog_file10,
2389
- L: 394,
2401
+ L: 400,
2390
2402
  S: this,
2391
2403
  A: [
2392
2404
  "space",
@@ -2399,7 +2411,7 @@ var DataSpaceManager = class extends Resource4 {
2399
2411
  const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
2400
2412
  invariant5(credentials[0].credential, void 0, {
2401
2413
  F: __dxlog_file10,
2402
- L: 413,
2414
+ L: 419,
2403
2415
  S: this,
2404
2416
  A: [
2405
2417
  "credentials[0].credential",
@@ -2409,7 +2421,7 @@ var DataSpaceManager = class extends Resource4 {
2409
2421
  const spaceMemberCredential = credentials[0].credential.credential;
2410
2422
  invariant5(getCredentialAssertion2(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2411
2423
  F: __dxlog_file10,
2412
- L: 415,
2424
+ L: 421,
2413
2425
  S: this,
2414
2426
  A: [
2415
2427
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2447,7 +2459,7 @@ var DataSpaceManager = class extends Resource4 {
2447
2459
  const space = this._spaces.get(spaceKey);
2448
2460
  invariant5(space, "Space not found.", {
2449
2461
  F: __dxlog_file10,
2450
- L: 452,
2462
+ L: 458,
2451
2463
  S: this,
2452
2464
  A: [
2453
2465
  "space",
@@ -2472,7 +2484,7 @@ var DataSpaceManager = class extends Resource4 {
2472
2484
  metadata
2473
2485
  }, {
2474
2486
  F: __dxlog_file10,
2475
- L: 471,
2487
+ L: 477,
2476
2488
  S: this,
2477
2489
  C: (f, a) => f(...a)
2478
2490
  });
@@ -2516,7 +2528,7 @@ var DataSpaceManager = class extends Resource4 {
2516
2528
  err
2517
2529
  }, {
2518
2530
  F: __dxlog_file10,
2519
- L: 513,
2531
+ L: 519,
2520
2532
  S: this,
2521
2533
  C: (f, a) => f(...a)
2522
2534
  });
@@ -2526,7 +2538,7 @@ var DataSpaceManager = class extends Resource4 {
2526
2538
  onAuthFailure: () => {
2527
2539
  log7.warn("auth failure", void 0, {
2528
2540
  F: __dxlog_file10,
2529
- L: 518,
2541
+ L: 524,
2530
2542
  S: this,
2531
2543
  C: (f, a) => f(...a)
2532
2544
  });
@@ -2559,7 +2571,7 @@ var DataSpaceManager = class extends Resource4 {
2559
2571
  space: space.key
2560
2572
  }, {
2561
2573
  F: __dxlog_file10,
2562
- L: 545,
2574
+ L: 551,
2563
2575
  S: this,
2564
2576
  C: (f, a) => f(...a)
2565
2577
  });
@@ -2570,7 +2582,7 @@ var DataSpaceManager = class extends Resource4 {
2570
2582
  open: this._lifecycleState === LifecycleState.OPEN
2571
2583
  }, {
2572
2584
  F: __dxlog_file10,
2573
- L: 548,
2585
+ L: 554,
2574
2586
  S: this,
2575
2587
  C: (f, a) => f(...a)
2576
2588
  });
@@ -2589,7 +2601,7 @@ var DataSpaceManager = class extends Resource4 {
2589
2601
  space: space.key
2590
2602
  }, {
2591
2603
  F: __dxlog_file10,
2592
- L: 556,
2604
+ L: 562,
2593
2605
  S: this,
2594
2606
  C: (f, a) => f(...a)
2595
2607
  });
@@ -2610,7 +2622,7 @@ var DataSpaceManager = class extends Resource4 {
2610
2622
  spaceId: dataSpace.id
2611
2623
  }, {
2612
2624
  F: __dxlog_file10,
2613
- L: 570,
2625
+ L: 576,
2614
2626
  S: this,
2615
2627
  C: (f, a) => f(...a)
2616
2628
  });
@@ -2640,7 +2652,7 @@ var DataSpaceManager = class extends Resource4 {
2640
2652
  space: space.key
2641
2653
  }, {
2642
2654
  F: __dxlog_file10,
2643
- L: 597,
2655
+ L: 603,
2644
2656
  S: this,
2645
2657
  C: (f, a) => f(...a)
2646
2658
  });
@@ -2673,7 +2685,7 @@ var DataSpaceManager = class extends Resource4 {
2673
2685
  closedSessions
2674
2686
  }, {
2675
2687
  F: __dxlog_file10,
2676
- L: 623,
2688
+ L: 629,
2677
2689
  S: this,
2678
2690
  C: (f, a) => f(...a)
2679
2691
  });
@@ -2688,7 +2700,7 @@ var DataSpaceManager = class extends Resource4 {
2688
2700
  peerId: peerState.peerId
2689
2701
  }, {
2690
2702
  F: __dxlog_file10,
2691
- L: 637,
2703
+ L: 643,
2692
2704
  S: this,
2693
2705
  C: (f, a) => f(...a)
2694
2706
  });
@@ -2833,7 +2845,7 @@ var extractSpaceArchive = async (archive) => {
2833
2845
  const documentId = entry2.fileName.replace(`${SpaceArchiveFileStructure2.documents}/`, "").replace(/\.bin$/, "");
2834
2846
  invariant6(!documentId.includes("/"), void 0, {
2835
2847
  F: __dxlog_file11,
2836
- L: 27,
2848
+ L: 28,
2837
2849
  S: void 0,
2838
2850
  A: [
2839
2851
  "!documentId.includes('/')",
@@ -2847,7 +2859,7 @@ var extractSpaceArchive = async (archive) => {
2847
2859
  documents
2848
2860
  }, {
2849
2861
  F: __dxlog_file11,
2850
- L: 31,
2862
+ L: 32,
2851
2863
  S: void 0,
2852
2864
  C: (f, a) => f(...a)
2853
2865
  });
@@ -2858,67 +2870,70 @@ var extractSpaceArchive = async (archive) => {
2858
2870
  };
2859
2871
 
2860
2872
  // packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
2861
- function _using_ctx2() {
2862
- var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
2863
- var err = new Error();
2864
- err.name = "SuppressedError";
2865
- err.suppressed = suppressed;
2866
- err.error = error;
2867
- return err;
2868
- }, empty = {}, stack = [];
2869
- function using(isAwait, value) {
2870
- if (value != null) {
2871
- if (Object(value) !== value) {
2872
- throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
2873
- }
2874
- if (isAwait) {
2875
- var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
2876
- }
2877
- if (dispose == null) {
2878
- dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
2879
- }
2880
- if (typeof dispose !== "function") {
2881
- throw new TypeError(`Property [Symbol.dispose] is not a function.`);
2882
- }
2883
- stack.push({
2884
- v: value,
2885
- d: dispose,
2886
- a: isAwait
2887
- });
2888
- } else if (isAwait) {
2889
- stack.push({
2890
- d: value,
2891
- a: isAwait
2892
- });
2893
- }
2894
- 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
+ });
2895
2903
  }
2896
- return {
2897
- e: empty,
2898
- u: using.bind(null, false),
2899
- a: using.bind(null, true),
2900
- d: function() {
2901
- var error = this.e;
2902
- function next() {
2903
- while (resource = stack.pop()) {
2904
- try {
2905
- var resource, disposalResult = resource.d && resource.d.call(resource.v);
2906
- if (resource.a) {
2907
- return Promise.resolve(disposalResult).then(next, err);
2908
- }
2909
- } catch (e) {
2910
- return err(e);
2911
- }
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);
2912
2930
  }
2913
- if (error !== empty) throw error;
2914
2931
  }
2915
- function err(e) {
2916
- error = error !== empty ? new _disposeSuppressedError(error, e) : e;
2917
- return next();
2918
- }
2919
- return next();
2932
+ if (s === 1) return env2.hasError ? Promise.reject(env2.error) : Promise.resolve();
2933
+ if (env2.hasError) throw env2.error;
2920
2934
  }
2921
- };
2935
+ return next();
2936
+ })(env);
2922
2937
  }
2923
2938
  var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
2924
2939
  var SpacesServiceImpl = class {
@@ -2968,7 +2983,7 @@ var SpacesServiceImpl = class {
2968
2983
  const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
2969
2984
  invariant7(credentials[0].credential, void 0, {
2970
2985
  F: __dxlog_file12,
2971
- L: 118,
2986
+ L: 119,
2972
2987
  S: this,
2973
2988
  A: [
2974
2989
  "credentials[0].credential",
@@ -2978,7 +2993,7 @@ var SpacesServiceImpl = class {
2978
2993
  const spaceMemberCredential = credentials[0].credential.credential;
2979
2994
  invariant7(getCredentialAssertion3(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2980
2995
  F: __dxlog_file12,
2981
- L: 120,
2996
+ L: 121,
2982
2997
  S: this,
2983
2998
  A: [
2984
2999
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2996,7 +3011,7 @@ var SpacesServiceImpl = class {
2996
3011
  ids: spaces.map((space) => space.id)
2997
3012
  }), {
2998
3013
  F: __dxlog_file12,
2999
- L: 133,
3014
+ L: 134,
3000
3015
  S: this,
3001
3016
  C: (f, a) => f(...a)
3002
3017
  });
@@ -3088,7 +3103,7 @@ var SpacesServiceImpl = class {
3088
3103
  } else {
3089
3104
  invariant7(!credential.id, "Id on unsigned credentials is not allowed", {
3090
3105
  F: __dxlog_file12,
3091
- L: 231,
3106
+ L: 232,
3092
3107
  S: this,
3093
3108
  A: [
3094
3109
  "!credential.id",
@@ -3097,7 +3112,7 @@ var SpacesServiceImpl = class {
3097
3112
  });
3098
3113
  invariant7(this._identityManager.identity, "Identity is not available", {
3099
3114
  F: __dxlog_file12,
3100
- L: 232,
3115
+ L: 233,
3101
3116
  S: this,
3102
3117
  A: [
3103
3118
  "this._identityManager.identity",
@@ -3107,7 +3122,7 @@ var SpacesServiceImpl = class {
3107
3122
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
3108
3123
  invariant7(credential.issuer.equals(signer.getIssuer()), void 0, {
3109
3124
  F: __dxlog_file12,
3110
- L: 234,
3125
+ L: 235,
3111
3126
  S: this,
3112
3127
  A: [
3113
3128
  "credential.issuer.equals(signer.getIssuer())",
@@ -3154,9 +3169,13 @@ var SpacesServiceImpl = class {
3154
3169
  });
3155
3170
  }
3156
3171
  async exportSpace(request) {
3172
+ const env = {
3173
+ stack: [],
3174
+ error: void 0,
3175
+ hasError: false
3176
+ };
3157
3177
  try {
3158
- var _usingCtx = _using_ctx2();
3159
- const writer = _usingCtx.a(await new SpaceArchiveWriter().open());
3178
+ const writer = _ts_add_disposable_resource2(env, await new SpaceArchiveWriter().open(), true);
3160
3179
  assertArgument4(SpaceId2.isValid(request.spaceId), "Invalid space ID");
3161
3180
  const dataSpaceManager = await this._getDataSpaceManager();
3162
3181
  const space = dataSpaceManager.getSpaceById(request.spaceId) ?? raise(new Error("Space not found"));
@@ -3173,10 +3192,12 @@ var SpacesServiceImpl = class {
3173
3192
  return {
3174
3193
  archive
3175
3194
  };
3176
- } catch (_) {
3177
- _usingCtx.e = _;
3195
+ } catch (e) {
3196
+ env.error = e;
3197
+ env.hasError = true;
3178
3198
  } finally {
3179
- await _usingCtx.d();
3199
+ const result = _ts_dispose_resources2(env);
3200
+ if (result) await result;
3180
3201
  }
3181
3202
  }
3182
3203
  async importSpace(request) {
@@ -3184,7 +3205,7 @@ var SpacesServiceImpl = class {
3184
3205
  const extracted = await extractSpaceArchive(request.archive);
3185
3206
  invariant7(extracted.metadata.echo?.currentRootUrl, "Space archive does not contain a root URL", {
3186
3207
  F: __dxlog_file12,
3187
- L: 288,
3208
+ L: 289,
3188
3209
  S: this,
3189
3210
  A: [
3190
3211
  "extracted.metadata.echo?.currentRootUrl",
@@ -3204,7 +3225,7 @@ var SpacesServiceImpl = class {
3204
3225
  const assertion = getCredentialAssertion3(credential);
3205
3226
  invariant7(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
3206
3227
  F: __dxlog_file12,
3207
- L: 299,
3228
+ L: 300,
3208
3229
  S: this,
3209
3230
  A: [
3210
3231
  "assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -3214,7 +3235,7 @@ var SpacesServiceImpl = class {
3214
3235
  const myIdentity = this._identityManager.identity;
3215
3236
  invariant7(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
3216
3237
  F: __dxlog_file12,
3217
- L: 301,
3238
+ L: 302,
3218
3239
  S: this,
3219
3240
  A: [
3220
3241
  "myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
@@ -3614,7 +3635,7 @@ var IdentityManager = class {
3614
3635
  L: 135
3615
3636
  }));
3616
3637
  }
3617
- async createIdentity({ displayName, deviceProfile } = {}) {
3638
+ async createIdentity({ profile, deviceProfile } = {}) {
3618
3639
  invariant9(!this._identity, "Identity already exists.", {
3619
3640
  F: __dxlog_file14,
3620
3641
  L: 140,
@@ -3672,10 +3693,8 @@ var IdentityManager = class {
3672
3693
  // Feed admission.
3673
3694
  await generator.createFeedAdmission(identityRecord.haloSpace.key, identityRecord.haloSpace.dataFeedKey, AdmittedFeed3.Designation.DATA)
3674
3695
  ];
3675
- if (displayName) {
3676
- credentials.push(await generator.createProfileCredential({
3677
- displayName
3678
- }));
3696
+ if (profile) {
3697
+ credentials.push(await generator.createProfileCredential(profile));
3679
3698
  }
3680
3699
  credentials.push(await generator.createDeviceAuthorization(identityRecord.deviceKey));
3681
3700
  credentials.push(await generator.createDeviceProfile({
@@ -3792,7 +3811,7 @@ var IdentityManager = class {
3792
3811
  displayName: this._identity.profileDocument?.displayName
3793
3812
  }, {
3794
3813
  F: __dxlog_file14,
3795
- L: 273,
3814
+ L: 277,
3796
3815
  S: this,
3797
3816
  C: (f, a) => f(...a)
3798
3817
  });
@@ -3806,7 +3825,7 @@ var IdentityManager = class {
3806
3825
  deviceKey: identity.deviceKey
3807
3826
  }, {
3808
3827
  F: __dxlog_file14,
3809
- L: 284,
3828
+ L: 288,
3810
3829
  S: this,
3811
3830
  C: (f, a) => f(...a)
3812
3831
  });
@@ -3817,7 +3836,7 @@ var IdentityManager = class {
3817
3836
  async updateProfile(profile) {
3818
3837
  invariant9(this._identity, "Identity not initialized.", {
3819
3838
  F: __dxlog_file14,
3820
- L: 291,
3839
+ L: 295,
3821
3840
  S: this,
3822
3841
  A: [
3823
3842
  "this._identity",
@@ -3848,7 +3867,7 @@ var IdentityManager = class {
3848
3867
  async updateDeviceProfile(profile) {
3849
3868
  invariant9(this._identity, "Identity not initialized.", {
3850
3869
  F: __dxlog_file14,
3851
- L: 308,
3870
+ L: 312,
3852
3871
  S: this,
3853
3872
  A: [
3854
3873
  "this._identity",
@@ -3884,7 +3903,7 @@ var IdentityManager = class {
3884
3903
  async _constructIdentity(identityRecord) {
3885
3904
  invariant9(!this._identity, void 0, {
3886
3905
  F: __dxlog_file14,
3887
- L: 334,
3906
+ L: 338,
3888
3907
  S: this,
3889
3908
  A: [
3890
3909
  "!this._identity",
@@ -3895,7 +3914,7 @@ var IdentityManager = class {
3895
3914
  identityRecord
3896
3915
  }, {
3897
3916
  F: __dxlog_file14,
3898
- L: 335,
3917
+ L: 339,
3899
3918
  S: this,
3900
3919
  C: (f, a) => f(...a)
3901
3920
  });
@@ -3910,7 +3929,7 @@ var IdentityManager = class {
3910
3929
  });
3911
3930
  invariant9(identityRecord.haloSpace.controlFeedKey, void 0, {
3912
3931
  F: __dxlog_file14,
3913
- L: 348,
3932
+ L: 352,
3914
3933
  S: this,
3915
3934
  A: [
3916
3935
  "identityRecord.haloSpace.controlFeedKey",
@@ -3922,7 +3941,7 @@ var IdentityManager = class {
3922
3941
  });
3923
3942
  invariant9(identityRecord.haloSpace.dataFeedKey, void 0, {
3924
3943
  F: __dxlog_file14,
3925
- L: 352,
3944
+ L: 356,
3926
3945
  S: this,
3927
3946
  A: [
3928
3947
  "identityRecord.haloSpace.dataFeedKey",
@@ -3961,7 +3980,7 @@ var IdentityManager = class {
3961
3980
  identityKey: identityRecord.identityKey
3962
3981
  }, {
3963
3982
  F: __dxlog_file14,
3964
- L: 383,
3983
+ L: 387,
3965
3984
  S: this,
3966
3985
  C: (f, a) => f(...a)
3967
3986
  });
@@ -3986,7 +4005,7 @@ var IdentityManager = class {
3986
4005
  onAuthFailure: () => {
3987
4006
  log11.warn("auth failure", void 0, {
3988
4007
  F: __dxlog_file14,
3989
- L: 408,
4008
+ L: 412,
3990
4009
  S: this,
3991
4010
  C: (f, a) => f(...a)
3992
4011
  });
@@ -4021,13 +4040,7 @@ var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
4021
4040
  var DEFAULT_SPACE_SEARCH_TIMEOUT = 1e4;
4022
4041
  var IdentityServiceImpl = class extends Resource6 {
4023
4042
  constructor(_identityManager, _recoveryManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
4024
- super();
4025
- this._identityManager = _identityManager;
4026
- this._recoveryManager = _recoveryManager;
4027
- this._keyring = _keyring;
4028
- this._dataSpaceManagerProvider = _dataSpaceManagerProvider;
4029
- this._createIdentity = _createIdentity;
4030
- this._onProfileUpdate = _onProfileUpdate;
4043
+ super(), this._identityManager = _identityManager, this._recoveryManager = _recoveryManager, this._keyring = _keyring, this._dataSpaceManagerProvider = _dataSpaceManagerProvider, this._createIdentity = _createIdentity, this._onProfileUpdate = _onProfileUpdate;
4031
4044
  }
4032
4045
  async _open() {
4033
4046
  const identity = this._identityManager.identity;
@@ -4037,7 +4050,7 @@ var IdentityServiceImpl = class extends Resource6 {
4037
4050
  }
4038
4051
  async createIdentity(request) {
4039
4052
  await this._createIdentity({
4040
- displayName: request.profile?.displayName,
4053
+ profile: request.profile,
4041
4054
  deviceProfile: request.deviceProfile
4042
4055
  });
4043
4056
  const dataSpaceManager = this._dataSpaceManagerProvider();
@@ -4212,74 +4225,77 @@ function _ts_decorate6(decorators, target, key, desc) {
4212
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;
4213
4226
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4214
4227
  }
4215
- function _using_ctx3() {
4216
- var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
4217
- var err = new Error();
4218
- err.name = "SuppressedError";
4219
- err.suppressed = suppressed;
4220
- err.error = error;
4221
- return err;
4222
- }, empty = {}, stack = [];
4223
- function using(isAwait, value) {
4224
- if (value != null) {
4225
- if (Object(value) !== value) {
4226
- throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
4227
- }
4228
- if (isAwait) {
4229
- var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
4230
- }
4231
- if (dispose == null) {
4232
- dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
4233
- }
4234
- if (typeof dispose !== "function") {
4235
- throw new TypeError(`Property [Symbol.dispose] is not a function.`);
4236
- }
4237
- stack.push({
4238
- v: value,
4239
- d: dispose,
4240
- a: isAwait
4241
- });
4242
- } else if (isAwait) {
4243
- stack.push({
4244
- d: value,
4245
- a: isAwait
4246
- });
4247
- }
4248
- 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
+ });
4249
4258
  }
4250
- return {
4251
- e: empty,
4252
- u: using.bind(null, false),
4253
- a: using.bind(null, true),
4254
- d: function() {
4255
- var error = this.e;
4256
- function next() {
4257
- while (resource = stack.pop()) {
4258
- try {
4259
- var resource, disposalResult = resource.d && resource.d.call(resource.v);
4260
- if (resource.a) {
4261
- return Promise.resolve(disposalResult).then(next, err);
4262
- }
4263
- } catch (e) {
4264
- return err(e);
4265
- }
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);
4266
4285
  }
4267
- if (error !== empty) throw error;
4268
- }
4269
- function err(e) {
4270
- error = error !== empty ? new _disposeSuppressedError(error, e) : e;
4271
- return next();
4272
4286
  }
4273
- return next();
4287
+ if (s === 1) return env2.hasError ? Promise.reject(env2.error) : Promise.resolve();
4288
+ if (env2.hasError) throw env2.error;
4274
4289
  }
4275
- };
4290
+ return next();
4291
+ })(env);
4276
4292
  }
4277
4293
  var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
4278
4294
  var DataSpace = class {
4279
4295
  constructor(params) {
4280
4296
  this._ctx = new Context6(void 0, {
4281
4297
  F: __dxlog_file16,
4282
- L: 97
4298
+ L: 100
4283
4299
  });
4284
4300
  this._cache = void 0;
4285
4301
  this._edgeFeedReplicator = void 0;
@@ -4332,7 +4348,7 @@ var DataSpace = class {
4332
4348
  state: SpaceState4[this._state]
4333
4349
  }, {
4334
4350
  F: __dxlog_file16,
4335
- L: 173,
4351
+ L: 176,
4336
4352
  S: this,
4337
4353
  C: (f, a) => f(...a)
4338
4354
  });
@@ -4391,7 +4407,7 @@ var DataSpace = class {
4391
4407
  }
4392
4408
  await this._inner.open(new Context6(void 0, {
4393
4409
  F: __dxlog_file16,
4394
- L: 247
4410
+ L: 250
4395
4411
  }));
4396
4412
  await this._inner.startProtocol();
4397
4413
  await this._edgeFeedReplicator?.open();
@@ -4400,7 +4416,7 @@ var DataSpace = class {
4400
4416
  state: SpaceState4[this._state]
4401
4417
  }, {
4402
4418
  F: __dxlog_file16,
4403
- L: 253,
4419
+ L: 256,
4404
4420
  S: this,
4405
4421
  C: (f, a) => f(...a)
4406
4422
  });
@@ -4420,14 +4436,14 @@ var DataSpace = class {
4420
4436
  state: SpaceState4[this._state]
4421
4437
  }, {
4422
4438
  F: __dxlog_file16,
4423
- L: 272,
4439
+ L: 275,
4424
4440
  S: this,
4425
4441
  C: (f, a) => f(...a)
4426
4442
  });
4427
4443
  await this._ctx.dispose();
4428
4444
  this._ctx = new Context6(void 0, {
4429
4445
  F: __dxlog_file16,
4430
- L: 274
4446
+ L: 277
4431
4447
  });
4432
4448
  if (this._edgeFeedReplicator) {
4433
4449
  this.inner.protocol.feedAdded.remove(this._onFeedAdded);
@@ -4460,7 +4476,7 @@ var DataSpace = class {
4460
4476
  if (err instanceof CancelledError || err instanceof ContextDisposedError) {
4461
4477
  log13("data pipeline initialization cancelled", err, {
4462
4478
  F: __dxlog_file16,
4463
- L: 312,
4479
+ L: 315,
4464
4480
  S: this,
4465
4481
  C: (f, a) => f(...a)
4466
4482
  });
@@ -4468,7 +4484,7 @@ var DataSpace = class {
4468
4484
  }
4469
4485
  log13.error("Error initializing data pipeline", err, {
4470
4486
  F: __dxlog_file16,
4471
- L: 316,
4487
+ L: 319,
4472
4488
  S: this,
4473
4489
  C: (f, a) => f(...a)
4474
4490
  });
@@ -4477,7 +4493,7 @@ var DataSpace = class {
4477
4493
  state: SpaceState4[this._state]
4478
4494
  }, {
4479
4495
  F: __dxlog_file16,
4480
- L: 318,
4496
+ L: 321,
4481
4497
  S: this,
4482
4498
  C: (f, a) => f(...a)
4483
4499
  });
@@ -4497,13 +4513,13 @@ var DataSpace = class {
4497
4513
  state: SpaceState4[this._state]
4498
4514
  }, {
4499
4515
  F: __dxlog_file16,
4500
- L: 334,
4516
+ L: 337,
4501
4517
  S: this,
4502
4518
  C: (f, a) => f(...a)
4503
4519
  });
4504
4520
  log13("initializing control pipeline", void 0, {
4505
4521
  F: __dxlog_file16,
4506
- L: 336,
4522
+ L: 339,
4507
4523
  S: this,
4508
4524
  C: (f, a) => f(...a)
4509
4525
  });
@@ -4512,21 +4528,21 @@ var DataSpace = class {
4512
4528
  const ready = this.stateUpdate.waitForCondition(() => this._state === SpaceState4.SPACE_READY);
4513
4529
  log13("initializing automerge root", void 0, {
4514
4530
  F: __dxlog_file16,
4515
- L: 344,
4531
+ L: 347,
4516
4532
  S: this,
4517
4533
  C: (f, a) => f(...a)
4518
4534
  });
4519
4535
  this._automergeSpaceState.startProcessingRootDocs();
4520
4536
  log13("waiting for space to be ready", void 0, {
4521
4537
  F: __dxlog_file16,
4522
- L: 348,
4538
+ L: 351,
4523
4539
  S: this,
4524
4540
  C: (f, a) => f(...a)
4525
4541
  });
4526
4542
  await ready;
4527
4543
  log13("space is ready", void 0, {
4528
4544
  F: __dxlog_file16,
4529
- L: 350,
4545
+ L: 353,
4530
4546
  S: this,
4531
4547
  C: (f, a) => f(...a)
4532
4548
  });
@@ -4534,14 +4550,14 @@ var DataSpace = class {
4534
4550
  async *getAllDocuments() {
4535
4551
  invariant11(this._databaseRoot, "Space is not ready", {
4536
4552
  F: __dxlog_file16,
4537
- L: 354,
4553
+ L: 357,
4538
4554
  S: this,
4539
4555
  A: [
4540
4556
  "this._databaseRoot",
4541
4557
  "'Space is not ready'"
4542
4558
  ]
4543
4559
  });
4544
- const doc = this._databaseRoot.docSync() ?? failedInvariant3();
4560
+ const doc = this._databaseRoot.doc() ?? failedInvariant3();
4545
4561
  const root = save(doc);
4546
4562
  yield [
4547
4563
  this._databaseRoot.documentId,
@@ -4550,7 +4566,7 @@ var DataSpace = class {
4550
4566
  for (const documentUrl of this._databaseRoot.getAllLinkedDocuments()) {
4551
4567
  const data = await this._echoHost.exportDoc(Context6.default(void 0, {
4552
4568
  F: __dxlog_file16,
4553
- L: 360
4569
+ L: 363
4554
4570
  }), documentUrl);
4555
4571
  yield [
4556
4572
  documentUrl.replace(/^automerge:/, ""),
@@ -4565,7 +4581,7 @@ var DataSpace = class {
4565
4581
  state: SpaceState4[this._state]
4566
4582
  }, {
4567
4583
  F: __dxlog_file16,
4568
- L: 369,
4584
+ L: 372,
4569
4585
  S: this,
4570
4586
  C: (f, a) => f(...a)
4571
4587
  });
@@ -4582,7 +4598,7 @@ var DataSpace = class {
4582
4598
  await this._createWritableFeeds();
4583
4599
  log13("writable feeds created", void 0, {
4584
4600
  F: __dxlog_file16,
4585
- L: 386,
4601
+ L: 389,
4586
4602
  S: this,
4587
4603
  C: (f, a) => f(...a)
4588
4604
  });
@@ -4636,7 +4652,7 @@ var DataSpace = class {
4636
4652
  count: credentials.length
4637
4653
  }, {
4638
4654
  F: __dxlog_file16,
4639
- L: 444,
4655
+ L: 447,
4640
4656
  S: this,
4641
4657
  C: (f, a) => f(...a)
4642
4658
  });
@@ -4647,14 +4663,14 @@ var DataSpace = class {
4647
4663
  });
4648
4664
  log13("credentials notarized", void 0, {
4649
4665
  F: __dxlog_file16,
4650
- L: 448,
4666
+ L: 451,
4651
4667
  S: this,
4652
4668
  C: (f, a) => f(...a)
4653
4669
  });
4654
4670
  } catch (err) {
4655
4671
  log13.error("error notarizing credentials for feed admission", err, {
4656
4672
  F: __dxlog_file16,
4657
- L: 450,
4673
+ L: 453,
4658
4674
  S: this,
4659
4675
  C: (f, a) => f(...a)
4660
4676
  });
@@ -4669,26 +4685,28 @@ var DataSpace = class {
4669
4685
  rootUrl
4670
4686
  }, {
4671
4687
  F: __dxlog_file16,
4672
- L: 460,
4688
+ L: 463,
4673
4689
  S: this,
4674
4690
  C: (f, a) => f(...a)
4675
4691
  });
4676
- const handle = this._echoHost.automergeRepo.find(rootUrl);
4692
+ let handle;
4677
4693
  queueMicrotask(async () => {
4678
4694
  try {
4695
+ const env = {
4696
+ stack: [],
4697
+ error: void 0,
4698
+ hasError: false
4699
+ };
4679
4700
  try {
4680
- var _usingCtx = _using_ctx3();
4681
4701
  await warnAfterTimeout(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
4702
+ handle = await cancelWithContext2(this._ctx, this._echoHost.automergeRepo.find(rootUrl, FIND_PARAMS2));
4682
4703
  await cancelWithContext2(this._ctx, handle.whenReady());
4683
4704
  });
4684
4705
  if (this._ctx.disposed) {
4685
4706
  return;
4686
4707
  }
4687
- const _guard = (
4688
- // Ensure only one root is processed at a time.
4689
- _usingCtx.u(await this._epochProcessingMutex.acquire())
4690
- );
4691
- const doc = handle.docSync() ?? failedInvariant3();
4708
+ const _guard = _ts_add_disposable_resource3(env, await this._epochProcessingMutex.acquire(), false);
4709
+ const doc = handle.doc() ?? failedInvariant3();
4692
4710
  if (!doc.access?.spaceKey) {
4693
4711
  handle.change((doc2) => {
4694
4712
  doc2.access = {
@@ -4706,10 +4724,11 @@ var DataSpace = class {
4706
4724
  } else {
4707
4725
  this.stateUpdate.emit();
4708
4726
  }
4709
- } catch (_) {
4710
- _usingCtx.e = _;
4727
+ } catch (e) {
4728
+ env.error = e;
4729
+ env.hasError = true;
4711
4730
  } finally {
4712
- _usingCtx.d();
4731
+ _ts_dispose_resources3(env);
4713
4732
  }
4714
4733
  } catch (err) {
4715
4734
  if (err instanceof ContextDisposedError) {
@@ -4721,7 +4740,7 @@ var DataSpace = class {
4721
4740
  err
4722
4741
  }, {
4723
4742
  F: __dxlog_file16,
4724
- L: 503,
4743
+ L: 510,
4725
4744
  S: this,
4726
4745
  C: (f, a) => f(...a)
4727
4746
  });
@@ -4811,7 +4830,7 @@ var DataSpace = class {
4811
4830
  state: SpaceState4[this._state]
4812
4831
  }, {
4813
4832
  F: __dxlog_file16,
4814
- L: 585,
4833
+ L: 592,
4815
4834
  S: this,
4816
4835
  C: (f, a) => f(...a)
4817
4836
  });
@@ -5222,15 +5241,10 @@ var InvitationGuestExtension = class extends RpcExtension2 {
5222
5241
  exposed: {
5223
5242
  InvitationHostService: schema4.getService("dxos.halo.invitations.InvitationHostService")
5224
5243
  }
5225
- });
5226
- this._invitationFlowMutex = _invitationFlowMutex;
5227
- this._callbacks = _callbacks;
5228
- this._ctx = new Context7(void 0, {
5244
+ }), this._invitationFlowMutex = _invitationFlowMutex, this._callbacks = _callbacks, this._ctx = new Context7(void 0, {
5229
5245
  F: __dxlog_file19,
5230
5246
  L: 38
5231
- });
5232
- this._remoteOptionsTrigger = new Trigger5();
5233
- this._invitationFlowLock = null;
5247
+ }), this._remoteOptionsTrigger = new Trigger5(), this._invitationFlowLock = null;
5234
5248
  }
5235
5249
  hasFlowLock() {
5236
5250
  return this._invitationFlowLock != null;
@@ -5359,20 +5373,10 @@ var InvitationHostExtension = class extends RpcExtension3 {
5359
5373
  exposed: {
5360
5374
  InvitationHostService: schema5.getService("dxos.halo.invitations.InvitationHostService")
5361
5375
  }
5362
- });
5363
- this._invitationFlowMutex = _invitationFlowMutex;
5364
- this._callbacks = _callbacks;
5365
- this._ctx = new Context8(void 0, {
5376
+ }), this._invitationFlowMutex = _invitationFlowMutex, this._callbacks = _callbacks, this._ctx = new Context8(void 0, {
5366
5377
  F: __dxlog_file20,
5367
5378
  L: 57
5368
- });
5369
- this._remoteOptionsTrigger = new Trigger6();
5370
- this._challenge = void 0;
5371
- this.guestProfile = void 0;
5372
- this.authenticationPassed = false;
5373
- this.authenticationRetry = 0;
5374
- this.completedTrigger = new Trigger6();
5375
- 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;
5376
5380
  }
5377
5381
  hasFlowLock() {
5378
5382
  return this._invitationFlowLock != null;
@@ -7076,14 +7080,14 @@ var InvitationsManager = class {
7076
7080
  }
7077
7081
  }, {
7078
7082
  F: __dxlog_file25,
7079
- L: 236
7083
+ L: 239
7080
7084
  });
7081
7085
  ctx.onDispose(() => {
7082
7086
  log21("complete", {
7083
7087
  ...handler.toJSON()
7084
7088
  }, {
7085
7089
  F: __dxlog_file25,
7086
- L: 243,
7090
+ L: 246,
7087
7091
  S: this,
7088
7092
  C: (f, a) => f(...a)
7089
7093
  });
@@ -7116,7 +7120,7 @@ var InvitationsManager = class {
7116
7120
  ...handler.toJSON()
7117
7121
  }, {
7118
7122
  F: __dxlog_file25,
7119
- L: 263,
7123
+ L: 274,
7120
7124
  S: this,
7121
7125
  C: (f, a) => f(...a)
7122
7126
  });
@@ -7127,7 +7131,7 @@ var InvitationsManager = class {
7127
7131
  } else {
7128
7132
  log21.warn("auth failed", err, {
7129
7133
  F: __dxlog_file25,
7130
- L: 266,
7134
+ L: 277,
7131
7135
  S: this,
7132
7136
  C: (f, a) => f(...a)
7133
7137
  });
@@ -7140,14 +7144,14 @@ var InvitationsManager = class {
7140
7144
  }
7141
7145
  }, {
7142
7146
  F: __dxlog_file25,
7143
- L: 260
7147
+ L: 271
7144
7148
  });
7145
7149
  ctx.onDispose(() => {
7146
7150
  log21("complete", {
7147
7151
  ...handler.toJSON()
7148
7152
  }, {
7149
7153
  F: __dxlog_file25,
7150
- L: 273,
7154
+ L: 284,
7151
7155
  S: this,
7152
7156
  C: (f, a) => f(...a)
7153
7157
  });
@@ -7192,7 +7196,7 @@ var InvitationsManager = class {
7192
7196
  } catch (err) {
7193
7197
  log21.catch(err, void 0, {
7194
7198
  F: __dxlog_file25,
7195
- L: 309,
7199
+ L: 320,
7196
7200
  S: this,
7197
7201
  C: (f, a) => f(...a)
7198
7202
  });
@@ -7216,10 +7220,6 @@ function _ts_decorate7(decorators, target, key, desc) {
7216
7220
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7217
7221
  }
7218
7222
  var __dxlog_file26 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
7219
- var Message;
7220
- (function(Message2) {
7221
- Message2["ACQUIRING"] = "acquiring";
7222
- })(Message || (Message = {}));
7223
7223
  var Lock = class {
7224
7224
  constructor({ lockKey, onAcquire, onRelease }) {
7225
7225
  this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
@@ -7423,13 +7423,7 @@ var AGENT_STATUS_QUERY_RETRY_JITTER = 1e3;
7423
7423
  var AGENT_FEED_ADDED_CHECK_INTERVAL_MS = 3e3;
7424
7424
  var EdgeAgentManager = class extends Resource7 {
7425
7425
  constructor(_edgeFeatures, _edgeHttpClient, _dataSpaceManager, _identity) {
7426
- super();
7427
- this._edgeFeatures = _edgeFeatures;
7428
- this._edgeHttpClient = _edgeHttpClient;
7429
- this._dataSpaceManager = _dataSpaceManager;
7430
- this._identity = _identity;
7431
- this.agentStatusChanged = new Event9();
7432
- this._lastKnownDeviceCount = 0;
7426
+ super(), this._edgeFeatures = _edgeFeatures, this._edgeHttpClient = _edgeHttpClient, this._dataSpaceManager = _dataSpaceManager, this._identity = _identity, this.agentStatusChanged = new Event9(), this._lastKnownDeviceCount = 0;
7433
7427
  }
7434
7428
  get agentStatus() {
7435
7429
  return this._agentStatus;
@@ -7738,7 +7732,7 @@ var EdgeIdentityRecoveryManager = class {
7738
7732
  const identity = this._identityProvider();
7739
7733
  invariant21(identity, void 0, {
7740
7734
  F: __dxlog_file28,
7741
- L: 37,
7735
+ L: 39,
7742
7736
  S: this,
7743
7737
  A: [
7744
7738
  "identity",
@@ -7789,7 +7783,7 @@ var EdgeIdentityRecoveryManager = class {
7789
7783
  async requestRecoveryChallenge() {
7790
7784
  invariant21(this._edgeClient, "Not connected to EDGE.", {
7791
7785
  F: __dxlog_file28,
7792
- L: 74,
7786
+ L: 76,
7793
7787
  S: this,
7794
7788
  A: [
7795
7789
  "this._edgeClient",
@@ -7819,7 +7813,7 @@ var EdgeIdentityRecoveryManager = class {
7819
7813
  async recoverIdentityWithExternalSignature({ lookupKey, deviceKey, controlFeedKey, signature, clientDataJson, authenticatorData }) {
7820
7814
  invariant21(this._edgeClient, "Not connected to EDGE.", {
7821
7815
  F: __dxlog_file28,
7822
- L: 106,
7816
+ L: 108,
7823
7817
  S: this,
7824
7818
  A: [
7825
7819
  "this._edgeClient",
@@ -7853,7 +7847,7 @@ var EdgeIdentityRecoveryManager = class {
7853
7847
  async recoverIdentityWithToken({ token }) {
7854
7848
  invariant21(this._edgeClient, "Not connected to EDGE.", {
7855
7849
  F: __dxlog_file28,
7856
- L: 139,
7850
+ L: 141,
7857
7851
  S: this,
7858
7852
  A: [
7859
7853
  "this._edgeClient",
@@ -7881,7 +7875,7 @@ var EdgeIdentityRecoveryManager = class {
7881
7875
  async recoverIdentity({ recoveryCode }) {
7882
7876
  invariant21(this._edgeClient, "Not connected to EDGE.", {
7883
7877
  F: __dxlog_file28,
7884
- L: 163,
7878
+ L: 165,
7885
7879
  S: this,
7886
7880
  A: [
7887
7881
  "this._edgeClient",
@@ -7912,7 +7906,7 @@ var EdgeIdentityRecoveryManager = class {
7912
7906
  }
7913
7907
  log24.info("recovering identity", response, {
7914
7908
  F: __dxlog_file28,
7915
- L: 189,
7909
+ L: 191,
7916
7910
  S: this,
7917
7911
  C: (f, a) => f(...a)
7918
7912
  });
@@ -7940,86 +7934,75 @@ function _ts_decorate10(decorators, target, key, desc) {
7940
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;
7941
7935
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7942
7936
  }
7943
- function _using_ctx4() {
7944
- var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
7945
- var err = new Error();
7946
- err.name = "SuppressedError";
7947
- err.suppressed = suppressed;
7948
- err.error = error;
7949
- return err;
7950
- }, empty = {}, stack = [];
7951
- function using(isAwait, value) {
7952
- if (value != null) {
7953
- if (Object(value) !== value) {
7954
- throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
7955
- }
7956
- if (isAwait) {
7957
- var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
7958
- }
7959
- if (dispose == null) {
7960
- dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
7961
- }
7962
- if (typeof dispose !== "function") {
7963
- throw new TypeError(`Property [Symbol.dispose] is not a function.`);
7964
- }
7965
- stack.push({
7966
- v: value,
7967
- d: dispose,
7968
- a: isAwait
7969
- });
7970
- } else if (isAwait) {
7971
- stack.push({
7972
- d: value,
7973
- a: isAwait
7974
- });
7975
- }
7976
- 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
+ });
7977
7967
  }
7978
- return {
7979
- e: empty,
7980
- u: using.bind(null, false),
7981
- a: using.bind(null, true),
7982
- d: function() {
7983
- var error = this.e;
7984
- function next() {
7985
- while (resource = stack.pop()) {
7986
- try {
7987
- var resource, disposalResult = resource.d && resource.d.call(resource.v);
7988
- if (resource.a) {
7989
- return Promise.resolve(disposalResult).then(next, err);
7990
- }
7991
- } catch (e) {
7992
- return err(e);
7993
- }
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);
7994
7994
  }
7995
- if (error !== empty) throw error;
7996
- }
7997
- function err(e) {
7998
- error = error !== empty ? new _disposeSuppressedError(error, e) : e;
7999
- return next();
8000
7995
  }
8001
- return next();
7996
+ if (s === 1) return env2.hasError ? Promise.reject(env2.error) : Promise.resolve();
7997
+ if (env2.hasError) throw env2.error;
8002
7998
  }
8003
- };
7999
+ return next();
8000
+ })(env);
8004
8001
  }
8005
8002
  var __dxlog_file29 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
8006
8003
  var ServiceContext = class extends Resource8 {
8007
8004
  constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtimeParams, _edgeFeatures) {
8008
- super();
8009
- this.storage = storage;
8010
- this.level = level;
8011
- this.networkManager = networkManager;
8012
- this.signalManager = signalManager;
8013
- this._edgeConnection = _edgeConnection;
8014
- this._edgeHttpClient = _edgeHttpClient;
8015
- this._runtimeParams = _runtimeParams;
8016
- this._edgeFeatures = _edgeFeatures;
8017
- this._edgeIdentityUpdateMutex = new Mutex4();
8018
- this.initialized = new Trigger9();
8019
- this._meshReplicator = void 0;
8020
- this._echoEdgeReplicator = void 0;
8021
- this._handlerFactories = /* @__PURE__ */ new Map();
8022
- 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();
8023
8006
  this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
8024
8007
  this.blobStore = new BlobStore(storage.createDirectory("blobs"));
8025
8008
  this.keyring = new Keyring(storage.createDirectory("keyring"));
@@ -8054,7 +8037,10 @@ var ServiceContext = class extends Resource8 {
8054
8037
  this.echoHost = new EchoHost({
8055
8038
  kv: this.level,
8056
8039
  peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
8057
- getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key
8040
+ getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key,
8041
+ indexing: {
8042
+ vector: this._runtimeParams?.enableVectorIndexing
8043
+ }
8058
8044
  });
8059
8045
  this._meshReplicator = new MeshEchoReplicator();
8060
8046
  this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeParams?.invitationConnectionDefaultParams);
@@ -8073,7 +8059,7 @@ var ServiceContext = class extends Resource8 {
8073
8059
  await this._checkStorageVersion();
8074
8060
  log25("opening...", void 0, {
8075
8061
  F: __dxlog_file29,
8076
- L: 199,
8062
+ L: 203,
8077
8063
  S: this,
8078
8064
  C: (f, a) => f(...a)
8079
8065
  });
@@ -8081,7 +8067,7 @@ var ServiceContext = class extends Resource8 {
8081
8067
  id: this._instanceId
8082
8068
  }), {
8083
8069
  F: __dxlog_file29,
8084
- L: 200,
8070
+ L: 204,
8085
8071
  S: this,
8086
8072
  C: (f, a) => f(...a)
8087
8073
  });
@@ -8108,7 +8094,7 @@ var ServiceContext = class extends Resource8 {
8108
8094
  count: loadedInvitations.invitations?.length
8109
8095
  }, {
8110
8096
  F: __dxlog_file29,
8111
- L: 228,
8097
+ L: 232,
8112
8098
  S: this,
8113
8099
  C: (f, a) => f(...a)
8114
8100
  });
@@ -8116,13 +8102,13 @@ var ServiceContext = class extends Resource8 {
8116
8102
  id: this._instanceId
8117
8103
  }), {
8118
8104
  F: __dxlog_file29,
8119
- L: 230,
8105
+ L: 234,
8120
8106
  S: this,
8121
8107
  C: (f, a) => f(...a)
8122
8108
  });
8123
8109
  log25("opened", void 0, {
8124
8110
  F: __dxlog_file29,
8125
- L: 231,
8111
+ L: 235,
8126
8112
  S: this,
8127
8113
  C: (f, a) => f(...a)
8128
8114
  });
@@ -8130,7 +8116,7 @@ var ServiceContext = class extends Resource8 {
8130
8116
  async _close(ctx) {
8131
8117
  log25("closing...", void 0, {
8132
8118
  F: __dxlog_file29,
8133
- L: 235,
8119
+ L: 239,
8134
8120
  S: this,
8135
8121
  C: (f, a) => f(...a)
8136
8122
  });
@@ -8149,7 +8135,7 @@ var ServiceContext = class extends Resource8 {
8149
8135
  await this._edgeConnection?.close();
8150
8136
  log25("closed", void 0, {
8151
8137
  F: __dxlog_file29,
8152
- L: 251,
8138
+ L: 255,
8153
8139
  S: this,
8154
8140
  C: (f, a) => f(...a)
8155
8141
  });
@@ -8160,7 +8146,7 @@ var ServiceContext = class extends Resource8 {
8160
8146
  await identity.joinNetwork();
8161
8147
  await this._initialize(new Context10(void 0, {
8162
8148
  F: __dxlog_file29,
8163
- L: 258
8149
+ L: 262
8164
8150
  }));
8165
8151
  return identity;
8166
8152
  }
@@ -8171,7 +8157,7 @@ var ServiceContext = class extends Resource8 {
8171
8157
  const factory = this._handlerFactories.get(invitation.kind);
8172
8158
  invariant22(factory, `Unknown invitation kind: ${invitation.kind}`, {
8173
8159
  F: __dxlog_file29,
8174
- L: 267,
8160
+ L: 271,
8175
8161
  S: this,
8176
8162
  A: [
8177
8163
  "factory",
@@ -8197,7 +8183,7 @@ var ServiceContext = class extends Resource8 {
8197
8183
  await this.identityManager.acceptIdentity(identity, identityRecord, params.deviceProfile);
8198
8184
  await this._initialize(new Context10(void 0, {
8199
8185
  F: __dxlog_file29,
8200
- L: 286
8186
+ L: 290
8201
8187
  }));
8202
8188
  return identity;
8203
8189
  }
@@ -8211,7 +8197,7 @@ var ServiceContext = class extends Resource8 {
8211
8197
  async _initialize(ctx) {
8212
8198
  log25("initializing spaces...", void 0, {
8213
8199
  F: __dxlog_file29,
8214
- L: 301,
8200
+ L: 305,
8215
8201
  S: this,
8216
8202
  C: (f, a) => f(...a)
8217
8203
  });
@@ -8250,7 +8236,7 @@ var ServiceContext = class extends Resource8 {
8250
8236
  this._handlerFactories.set(Invitation10.Kind.SPACE, (invitation) => {
8251
8237
  invariant22(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
8252
8238
  F: __dxlog_file29,
8253
- L: 339,
8239
+ L: 343,
8254
8240
  S: this,
8255
8241
  A: [
8256
8242
  "this.dataSpaceManager",
@@ -8274,7 +8260,7 @@ var ServiceContext = class extends Resource8 {
8274
8260
  details: assertion
8275
8261
  }, {
8276
8262
  F: __dxlog_file29,
8277
- L: 355,
8263
+ L: 359,
8278
8264
  S: this,
8279
8265
  C: (f, a) => f(...a)
8280
8266
  });
@@ -8285,7 +8271,7 @@ var ServiceContext = class extends Resource8 {
8285
8271
  details: assertion
8286
8272
  }, {
8287
8273
  F: __dxlog_file29,
8288
- L: 359,
8274
+ L: 363,
8289
8275
  S: this,
8290
8276
  C: (f, a) => f(...a)
8291
8277
  });
@@ -8296,7 +8282,7 @@ var ServiceContext = class extends Resource8 {
8296
8282
  details: assertion
8297
8283
  }, {
8298
8284
  F: __dxlog_file29,
8299
- L: 364,
8285
+ L: 368,
8300
8286
  S: this,
8301
8287
  C: (f, a) => f(...a)
8302
8288
  });
@@ -8307,7 +8293,7 @@ var ServiceContext = class extends Resource8 {
8307
8293
  } catch (err) {
8308
8294
  log25.catch(err, void 0, {
8309
8295
  F: __dxlog_file29,
8310
- L: 370,
8296
+ L: 374,
8311
8297
  S: this,
8312
8298
  C: (f, a) => f(...a)
8313
8299
  });
@@ -8317,9 +8303,13 @@ var ServiceContext = class extends Resource8 {
8317
8303
  await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
8318
8304
  }
8319
8305
  async _setNetworkIdentity(params) {
8306
+ const env = {
8307
+ stack: [],
8308
+ error: void 0,
8309
+ hasError: false
8310
+ };
8320
8311
  try {
8321
- var _usingCtx = _using_ctx4();
8322
- const _ = _usingCtx.u(await this._edgeIdentityUpdateMutex.acquire());
8312
+ const _ = _ts_add_disposable_resource4(env, await this._edgeIdentityUpdateMutex.acquire(), false);
8323
8313
  let edgeIdentity;
8324
8314
  const identity = this.identityManager.identity;
8325
8315
  if (identity) {
@@ -8328,7 +8318,7 @@ var ServiceContext = class extends Resource8 {
8328
8318
  swarms: this.networkManager.topics
8329
8319
  }, {
8330
8320
  F: __dxlog_file29,
8331
- L: 384,
8321
+ L: 388,
8332
8322
  S: this,
8333
8323
  C: (f, a) => f(...a)
8334
8324
  });
@@ -8342,7 +8332,7 @@ var ServiceContext = class extends Resource8 {
8342
8332
  });
8343
8333
  invariant22(identity.deviceCredentialChain, void 0, {
8344
8334
  F: __dxlog_file29,
8345
- L: 403,
8335
+ L: 407,
8346
8336
  S: this,
8347
8337
  A: [
8348
8338
  "identity.deviceCredentialChain",
@@ -8360,10 +8350,11 @@ var ServiceContext = class extends Resource8 {
8360
8350
  identityKey: edgeIdentity.identityKey,
8361
8351
  peerKey: edgeIdentity.peerKey
8362
8352
  });
8363
- } catch (_) {
8364
- _usingCtx.e = _;
8353
+ } catch (e) {
8354
+ env.error = e;
8355
+ env.hasError = true;
8365
8356
  } finally {
8366
- _usingCtx.d();
8357
+ _ts_dispose_resources4(env);
8367
8358
  }
8368
8359
  }
8369
8360
  };
@@ -8477,7 +8468,7 @@ var createLevel = async (config) => {
8477
8468
  };
8478
8469
 
8479
8470
  // packages/sdk/client-services/src/packlets/storage/profile-archive.ts
8480
- import { cbor } from "@dxos/automerge/automerge-repo";
8471
+ import { cbor } from "@automerge/automerge-repo";
8481
8472
  import { invariant as invariant23 } from "@dxos/invariant";
8482
8473
  import { log as log26 } from "@dxos/log";
8483
8474
  import { ProfileArchiveEntryType } from "@dxos/protocols";
@@ -8499,7 +8490,7 @@ var exportProfileData = async ({ storage, level }) => {
8499
8490
  count: files.length
8500
8491
  }, {
8501
8492
  F: __dxlog_file30,
8502
- L: 30,
8493
+ L: 31,
8503
8494
  S: void 0,
8504
8495
  C: (f, a) => f(...a)
8505
8496
  });
@@ -8517,7 +8508,7 @@ var exportProfileData = async ({ storage, level }) => {
8517
8508
  count: files.length
8518
8509
  }, {
8519
8510
  F: __dxlog_file30,
8520
- L: 41,
8511
+ L: 42,
8521
8512
  S: void 0,
8522
8513
  C: (f, a) => f(...a)
8523
8514
  });
@@ -8525,7 +8516,7 @@ var exportProfileData = async ({ storage, level }) => {
8525
8516
  {
8526
8517
  log26.info("begin exporting kv pairs", void 0, {
8527
8518
  F: __dxlog_file30,
8528
- L: 45,
8519
+ L: 46,
8529
8520
  S: void 0,
8530
8521
  C: (f, a) => f(...a)
8531
8522
  });
@@ -8546,7 +8537,7 @@ var exportProfileData = async ({ storage, level }) => {
8546
8537
  count
8547
8538
  }, {
8548
8539
  F: __dxlog_file30,
8549
- L: 56,
8540
+ L: 57,
8550
8541
  S: void 0,
8551
8542
  C: (f, a) => f(...a)
8552
8543
  });
@@ -8562,7 +8553,7 @@ var importProfileData = async ({ storage, level }, archive) => {
8562
8553
  const directory = await storage.createDirectory();
8563
8554
  invariant23(typeof entry2.key === "string", "Invalid key type", {
8564
8555
  F: __dxlog_file30,
8565
- L: 79,
8556
+ L: 80,
8566
8557
  S: void 0,
8567
8558
  A: [
8568
8559
  "typeof entry.key === 'string'",
@@ -8572,7 +8563,7 @@ var importProfileData = async ({ storage, level }, archive) => {
8572
8563
  const file = await directory.getOrCreateFile(entry2.key);
8573
8564
  invariant23(entry2.value instanceof Uint8Array, "Invalid value type", {
8574
8565
  F: __dxlog_file30,
8575
- L: 81,
8566
+ L: 82,
8576
8567
  S: void 0,
8577
8568
  A: [
8578
8569
  "entry.value instanceof Uint8Array",
@@ -8586,7 +8577,7 @@ var importProfileData = async ({ storage, level }, archive) => {
8586
8577
  case ProfileArchiveEntryType.KEY_VALUE: {
8587
8578
  invariant23(entry2.key instanceof Uint8Array, "Invalid key type", {
8588
8579
  F: __dxlog_file30,
8589
- L: 87,
8580
+ L: 88,
8590
8581
  S: void 0,
8591
8582
  A: [
8592
8583
  "entry.key instanceof Uint8Array",
@@ -8595,7 +8586,7 @@ var importProfileData = async ({ storage, level }, archive) => {
8595
8586
  });
8596
8587
  invariant23(entry2.value instanceof Uint8Array, "Invalid value type", {
8597
8588
  F: __dxlog_file30,
8598
- L: 88,
8589
+ L: 89,
8599
8590
  S: void 0,
8600
8591
  A: [
8601
8592
  "entry.value instanceof Uint8Array",
@@ -8620,7 +8611,7 @@ var importProfileData = async ({ storage, level }, archive) => {
8620
8611
  progress: `${(count / archive.storage.length * 100).toFixed()}%`
8621
8612
  }, {
8622
8613
  F: __dxlog_file30,
8623
- L: 101,
8614
+ L: 102,
8624
8615
  S: void 0,
8625
8616
  C: (f, a) => f(...a)
8626
8617
  });
@@ -8628,7 +8619,7 @@ var importProfileData = async ({ storage, level }, archive) => {
8628
8619
  }
8629
8620
  log26.info("committing changes..", void 0, {
8630
8621
  F: __dxlog_file30,
8631
- L: 109,
8622
+ L: 110,
8632
8623
  S: void 0,
8633
8624
  C: (f, a) => f(...a)
8634
8625
  });
@@ -9098,6 +9089,9 @@ var ClientServicesHost = class {
9098
9089
  if (this._runtimeParams.disableP2pReplication === void 0) {
9099
9090
  this._runtimeParams.disableP2pReplication = config?.get("runtime.client.disableP2pReplication", false);
9100
9091
  }
9092
+ if (this._runtimeParams.enableVectorIndexing === void 0) {
9093
+ this._runtimeParams.enableVectorIndexing = config?.get("runtime.client.enableVectorIndexing", false);
9094
+ }
9101
9095
  if (config) {
9102
9096
  this.initialize({
9103
9097
  config,
@@ -9112,7 +9106,7 @@ var ClientServicesHost = class {
9112
9106
  if (!this._opening) {
9113
9107
  void this.open(new Context11(void 0, {
9114
9108
  F: __dxlog_file32,
9115
- L: 137
9109
+ L: 141
9116
9110
  }));
9117
9111
  }
9118
9112
  },
@@ -9170,7 +9164,7 @@ var ClientServicesHost = class {
9170
9164
  initialize({ config, ...options }) {
9171
9165
  invariant25(!this._open, "service host is open", {
9172
9166
  F: __dxlog_file32,
9173
- L: 203,
9167
+ L: 207,
9174
9168
  S: this,
9175
9169
  A: [
9176
9170
  "!this._open",
@@ -9179,14 +9173,14 @@ var ClientServicesHost = class {
9179
9173
  });
9180
9174
  log28("initializing...", void 0, {
9181
9175
  F: __dxlog_file32,
9182
- L: 204,
9176
+ L: 208,
9183
9177
  S: this,
9184
9178
  C: (f, a) => f(...a)
9185
9179
  });
9186
9180
  if (config) {
9187
9181
  invariant25(!this._config, "config already set", {
9188
9182
  F: __dxlog_file32,
9189
- L: 207,
9183
+ L: 211,
9190
9184
  S: this,
9191
9185
  A: [
9192
9186
  "!this._config",
@@ -9201,7 +9195,7 @@ var ClientServicesHost = class {
9201
9195
  if (!options.signalManager) {
9202
9196
  log28.warn("running signaling without telemetry metadata.", void 0, {
9203
9197
  F: __dxlog_file32,
9204
- L: 215,
9198
+ L: 219,
9205
9199
  S: this,
9206
9200
  C: (f, a) => f(...a)
9207
9201
  });
@@ -9221,7 +9215,7 @@ var ClientServicesHost = class {
9221
9215
  this._signalManager = signalManager;
9222
9216
  invariant25(!this._networkManager, "network manager already set", {
9223
9217
  F: __dxlog_file32,
9224
- L: 237,
9218
+ L: 241,
9225
9219
  S: this,
9226
9220
  A: [
9227
9221
  "!this._networkManager",
@@ -9239,7 +9233,7 @@ var ClientServicesHost = class {
9239
9233
  });
9240
9234
  log28("initialized", void 0, {
9241
9235
  F: __dxlog_file32,
9242
- L: 250,
9236
+ L: 254,
9243
9237
  S: this,
9244
9238
  C: (f, a) => f(...a)
9245
9239
  });
@@ -9253,13 +9247,13 @@ var ClientServicesHost = class {
9253
9247
  id: traceId
9254
9248
  }), {
9255
9249
  F: __dxlog_file32,
9256
- L: 261,
9250
+ L: 265,
9257
9251
  S: this,
9258
9252
  C: (f, a) => f(...a)
9259
9253
  });
9260
9254
  invariant25(this._config, "config not set", {
9261
9255
  F: __dxlog_file32,
9262
- L: 263,
9256
+ L: 267,
9263
9257
  S: this,
9264
9258
  A: [
9265
9259
  "this._config",
@@ -9268,7 +9262,7 @@ var ClientServicesHost = class {
9268
9262
  });
9269
9263
  invariant25(this._storage, "storage not set", {
9270
9264
  F: __dxlog_file32,
9271
- L: 264,
9265
+ L: 268,
9272
9266
  S: this,
9273
9267
  A: [
9274
9268
  "this._storage",
@@ -9277,7 +9271,7 @@ var ClientServicesHost = class {
9277
9271
  });
9278
9272
  invariant25(this._signalManager, "signal manager not set", {
9279
9273
  F: __dxlog_file32,
9280
- L: 265,
9274
+ L: 269,
9281
9275
  S: this,
9282
9276
  A: [
9283
9277
  "this._signalManager",
@@ -9286,7 +9280,7 @@ var ClientServicesHost = class {
9286
9280
  });
9287
9281
  invariant25(this._networkManager, "network manager not set", {
9288
9282
  F: __dxlog_file32,
9289
- L: 266,
9283
+ L: 270,
9290
9284
  S: this,
9291
9285
  A: [
9292
9286
  "this._networkManager",
@@ -9298,7 +9292,7 @@ var ClientServicesHost = class {
9298
9292
  lockKey: this._resourceLock?.lockKey
9299
9293
  }, {
9300
9294
  F: __dxlog_file32,
9301
- L: 269,
9295
+ L: 273,
9302
9296
  S: this,
9303
9297
  C: (f, a) => f(...a)
9304
9298
  });
@@ -9359,7 +9353,7 @@ var ClientServicesHost = class {
9359
9353
  deviceKey
9360
9354
  }, {
9361
9355
  F: __dxlog_file32,
9362
- L: 370,
9356
+ L: 374,
9363
9357
  S: this,
9364
9358
  C: (f, a) => f(...a)
9365
9359
  });
@@ -9367,7 +9361,7 @@ var ClientServicesHost = class {
9367
9361
  id: traceId
9368
9362
  }), {
9369
9363
  F: __dxlog_file32,
9370
- L: 371,
9364
+ L: 375,
9371
9365
  S: this,
9372
9366
  C: (f, a) => f(...a)
9373
9367
  });
@@ -9381,7 +9375,7 @@ var ClientServicesHost = class {
9381
9375
  deviceKey
9382
9376
  }, {
9383
9377
  F: __dxlog_file32,
9384
- L: 382,
9378
+ L: 386,
9385
9379
  S: this,
9386
9380
  C: (f, a) => f(...a)
9387
9381
  });
@@ -9399,7 +9393,7 @@ var ClientServicesHost = class {
9399
9393
  deviceKey
9400
9394
  }, {
9401
9395
  F: __dxlog_file32,
9402
- L: 391,
9396
+ L: 395,
9403
9397
  S: this,
9404
9398
  C: (f, a) => f(...a)
9405
9399
  });
@@ -9410,13 +9404,13 @@ var ClientServicesHost = class {
9410
9404
  id: traceId
9411
9405
  }), {
9412
9406
  F: __dxlog_file32,
9413
- L: 396,
9407
+ L: 400,
9414
9408
  S: this,
9415
9409
  C: (f, a) => f(...a)
9416
9410
  });
9417
9411
  log28.info("resetting...", void 0, {
9418
9412
  F: __dxlog_file32,
9419
- L: 398,
9413
+ L: 402,
9420
9414
  S: this,
9421
9415
  C: (f, a) => f(...a)
9422
9416
  });
@@ -9426,7 +9420,7 @@ var ClientServicesHost = class {
9426
9420
  await this._storage.reset();
9427
9421
  log28.info("reset", void 0, {
9428
9422
  F: __dxlog_file32,
9429
- L: 405,
9423
+ L: 409,
9430
9424
  S: this,
9431
9425
  C: (f, a) => f(...a)
9432
9426
  });
@@ -9434,7 +9428,7 @@ var ClientServicesHost = class {
9434
9428
  id: traceId
9435
9429
  }), {
9436
9430
  F: __dxlog_file32,
9437
- L: 406,
9431
+ L: 410,
9438
9432
  S: this,
9439
9433
  C: (f, a) => f(...a)
9440
9434
  });
@@ -9512,4 +9506,4 @@ export {
9512
9506
  importProfileData,
9513
9507
  ClientServicesHost
9514
9508
  };
9515
- //# sourceMappingURL=chunk-R24OWGT7.mjs.map
9509
+ //# sourceMappingURL=chunk-YSJIZAYP.mjs.map