@dxos/client-services 0.1.49-next.fdd6c88 → 0.1.50-next.1bfebf8

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 (49) hide show
  1. package/dist/lib/browser/{chunk-KMQOZOUZ.mjs → chunk-UL74TKNZ.mjs} +543 -1131
  2. package/dist/lib/browser/chunk-UL74TKNZ.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +601 -9
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/packlets/testing/index.mjs +1 -1
  7. package/dist/lib/node/index.cjs +1164 -1214
  8. package/dist/lib/node/index.cjs.map +4 -4
  9. package/dist/lib/node/meta.json +1 -1
  10. package/dist/lib/node/packlets/testing/index.cjs +302 -780
  11. package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
  12. package/dist/types/src/index.d.ts +1 -0
  13. package/dist/types/src/index.d.ts.map +1 -1
  14. package/dist/types/src/packlets/devtools/devtools.d.ts +2 -1
  15. package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
  16. package/dist/types/src/packlets/devtools/metadata.d.ts +7 -0
  17. package/dist/types/src/packlets/devtools/metadata.d.ts.map +1 -0
  18. package/dist/types/src/packlets/locks/browser.d.ts +16 -0
  19. package/dist/types/src/packlets/locks/browser.d.ts.map +1 -0
  20. package/dist/types/src/packlets/locks/index.d.ts +3 -0
  21. package/dist/types/src/packlets/locks/index.d.ts.map +1 -0
  22. package/dist/types/src/packlets/locks/node.d.ts +13 -0
  23. package/dist/types/src/packlets/locks/node.d.ts.map +1 -0
  24. package/dist/types/src/packlets/locks/resource-lock.d.ts +16 -0
  25. package/dist/types/src/packlets/locks/resource-lock.d.ts.map +1 -0
  26. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  27. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  28. package/dist/types/src/packlets/spaces/data-space.d.ts +1 -1
  29. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
  30. package/dist/types/src/packlets/spaces/spaces-service.d.ts +0 -3
  31. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  32. package/dist/types/src/packlets/vault/index.d.ts +0 -1
  33. package/dist/types/src/packlets/vault/index.d.ts.map +1 -1
  34. package/package.json +33 -30
  35. package/src/index.ts +1 -0
  36. package/src/packlets/devtools/devtools.ts +6 -0
  37. package/src/packlets/devtools/metadata.ts +14 -0
  38. package/src/packlets/{vault/vault-resource-lock.ts → locks/browser.ts} +13 -11
  39. package/src/packlets/locks/index.ts +6 -0
  40. package/src/packlets/locks/node.ts +52 -0
  41. package/src/packlets/locks/resource-lock.ts +24 -0
  42. package/src/packlets/services/service-context.ts +1 -2
  43. package/src/packlets/services/service-host.ts +13 -13
  44. package/src/packlets/spaces/notarization-plugin.ts +7 -3
  45. package/src/packlets/spaces/spaces-service.ts +0 -3
  46. package/src/packlets/vault/index.ts +0 -1
  47. package/dist/lib/browser/chunk-KMQOZOUZ.mjs.map +0 -7
  48. package/dist/types/src/packlets/vault/vault-resource-lock.d.ts +0 -20
  49. package/dist/types/src/packlets/vault/vault-resource-lock.d.ts.map +0 -1
@@ -61,21 +61,21 @@ var createMockCredential = async ({ signer, issuer }) => (0, import_credentials.
61
61
  });
62
62
 
63
63
  // packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
64
- var import_node_assert15 = __toESM(require("node:assert"));
65
- var import_async24 = require("@dxos/async");
66
- var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
64
+ var import_node_assert13 = __toESM(require("node:assert"));
65
+ var import_async19 = require("@dxos/async");
66
+ var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
67
67
 
68
68
  // packages/sdk/client-services/src/packlets/services/service-host.ts
69
- var import_node_assert14 = __toESM(require("node:assert"));
70
- var import_async23 = require("@dxos/async");
71
- var import_client_protocol9 = require("@dxos/client-protocol");
69
+ var import_node_assert12 = __toESM(require("node:assert"));
70
+ var import_async18 = require("@dxos/async");
71
+ var import_client_protocol4 = require("@dxos/client-protocol");
72
72
  var import_echo_pipeline4 = require("@dxos/echo-pipeline");
73
73
  var import_keys12 = require("@dxos/keys");
74
- var import_log19 = require("@dxos/log");
75
- var import_messaging3 = require("@dxos/messaging");
76
- var import_network_manager5 = require("@dxos/network-manager");
74
+ var import_log15 = require("@dxos/log");
75
+ var import_messaging = require("@dxos/messaging");
76
+ var import_network_manager2 = require("@dxos/network-manager");
77
77
  var import_protocols9 = require("@dxos/protocols");
78
- var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
78
+ var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
79
79
 
80
80
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
81
81
  var import_async = require("@dxos/async");
@@ -126,7 +126,7 @@ var DevicesServiceImpl = class {
126
126
 
127
127
  // packages/sdk/client-services/src/packlets/devtools/devtools.ts
128
128
  var import_async4 = require("@dxos/async");
129
- var import_codec_protobuf6 = require("@dxos/codec-protobuf");
129
+ var import_codec_protobuf7 = require("@dxos/codec-protobuf");
130
130
 
131
131
  // packages/sdk/client-services/src/packlets/devtools/feeds.ts
132
132
  var import_async2 = require("@dxos/async");
@@ -214,11 +214,22 @@ var subscribeToKeyringKeys = ({ keyring }) => new import_codec_protobuf3.Stream(
214
214
  (0, import_async3.scheduleTask)(ctx, update);
215
215
  });
216
216
 
217
- // packages/sdk/client-services/src/packlets/devtools/network.ts
217
+ // packages/sdk/client-services/src/packlets/devtools/metadata.ts
218
218
  var import_codec_protobuf4 = require("@dxos/codec-protobuf");
219
+ var subscribeToMetadata = ({ context }) => new import_codec_protobuf4.Stream(({ next, ctx }) => {
220
+ context.metadataStore.update.on(ctx, (data) => next({
221
+ metadata: data
222
+ }));
223
+ next({
224
+ metadata: context.metadataStore.metadata
225
+ });
226
+ });
227
+
228
+ // packages/sdk/client-services/src/packlets/devtools/network.ts
229
+ var import_codec_protobuf5 = require("@dxos/codec-protobuf");
219
230
  var import_context = require("@dxos/context");
220
231
  var import_keys3 = require("@dxos/keys");
221
- var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf4.Stream(({ next, close }) => {
232
+ var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf5.Stream(({ next, close }) => {
222
233
  const update = () => {
223
234
  try {
224
235
  const status = signalManager.getStatus();
@@ -232,7 +243,7 @@ var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf4
232
243
  signalManager.statusChanged.on(() => update());
233
244
  update();
234
245
  });
235
- var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf4.Stream(({ next }) => {
246
+ var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf5.Stream(({ next }) => {
236
247
  const ctx = new import_context.Context();
237
248
  signalManager.onMessage.on(ctx, (message) => {
238
249
  next({
@@ -254,7 +265,7 @@ var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf4.Stream
254
265
  return ctx.dispose();
255
266
  };
256
267
  });
257
- var subscribeToSwarmInfo = ({ networkManager }) => new import_codec_protobuf4.Stream(({ next }) => {
268
+ var subscribeToSwarmInfo = ({ networkManager }) => new import_codec_protobuf5.Stream(({ next }) => {
258
269
  var _a;
259
270
  const update = () => {
260
271
  var _a2;
@@ -270,9 +281,9 @@ var subscribeToSwarmInfo = ({ networkManager }) => new import_codec_protobuf4.St
270
281
  });
271
282
 
272
283
  // packages/sdk/client-services/src/packlets/devtools/spaces.ts
273
- var import_codec_protobuf5 = require("@dxos/codec-protobuf");
284
+ var import_codec_protobuf6 = require("@dxos/codec-protobuf");
274
285
  var subscribeToSpaces = (context, { spaceKeys = [] }) => {
275
- return new import_codec_protobuf5.Stream(({ next }) => {
286
+ return new import_codec_protobuf6.Stream(({ next }) => {
276
287
  let unsubscribe;
277
288
  const update = async () => {
278
289
  const spaces = [
@@ -316,7 +327,7 @@ var DevtoolsServiceImpl = class {
316
327
  this.params = params;
317
328
  }
318
329
  events(request) {
319
- return new import_codec_protobuf6.Stream(({ next }) => {
330
+ return new import_codec_protobuf7.Stream(({ next }) => {
320
331
  this.params.events.ready.on(() => {
321
332
  next({
322
333
  ready: {}
@@ -408,6 +419,11 @@ var DevtoolsServiceImpl = class {
408
419
  networkManager: this.params.context.networkManager
409
420
  });
410
421
  }
422
+ subscribeToMetadata() {
423
+ return subscribeToMetadata({
424
+ context: this.params.context
425
+ });
426
+ }
411
427
  };
412
428
 
413
429
  // packages/sdk/client-services/src/packlets/identity/authenticator.ts
@@ -931,7 +947,7 @@ var IdentityManager = class {
931
947
 
932
948
  // packages/sdk/client-services/src/packlets/identity/identity-service.ts
933
949
  var import_node_assert3 = __toESM(require("node:assert"));
934
- var import_codec_protobuf7 = require("@dxos/codec-protobuf");
950
+ var import_codec_protobuf8 = require("@dxos/codec-protobuf");
935
951
  var import_credentials7 = require("@dxos/credentials");
936
952
  var import_debug2 = require("@dxos/debug");
937
953
  var IdentityServiceImpl = class {
@@ -947,7 +963,7 @@ var IdentityServiceImpl = class {
947
963
  return (0, import_debug2.todo)();
948
964
  }
949
965
  queryIdentity() {
950
- return new import_codec_protobuf7.Stream(({ next }) => {
966
+ return new import_codec_protobuf8.Stream(({ next }) => {
951
967
  const emitNext = () => next({
952
968
  identity: this._getIdentity()
953
969
  });
@@ -1879,7 +1895,7 @@ var InvitationsHandler = class {
1879
1895
  // packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
1880
1896
  var import_node_assert7 = __toESM(require("node:assert"));
1881
1897
  var import_async10 = require("@dxos/async");
1882
- var import_codec_protobuf8 = require("@dxos/codec-protobuf");
1898
+ var import_codec_protobuf9 = require("@dxos/codec-protobuf");
1883
1899
  var import_log6 = require("@dxos/log");
1884
1900
  var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
1885
1901
  var InvitationsServiceImpl = class {
@@ -1908,7 +1924,7 @@ var InvitationsServiceImpl = class {
1908
1924
  this._createInvitations.set(invitation.get().invitationId, invitation);
1909
1925
  this._invitationCreated.emit(invitation.get());
1910
1926
  }
1911
- return new import_codec_protobuf8.Stream(({ next, close }) => {
1927
+ return new import_codec_protobuf9.Stream(({ next, close }) => {
1912
1928
  invitation.subscribe((invitation2) => {
1913
1929
  next(invitation2);
1914
1930
  }, (err) => {
@@ -1930,7 +1946,7 @@ var InvitationsServiceImpl = class {
1930
1946
  this._acceptInvitations.set(invitation.get().invitationId, invitation);
1931
1947
  this._invitationAccepted.emit(invitation.get());
1932
1948
  }
1933
- return new import_codec_protobuf8.Stream(({ next, close }) => {
1949
+ return new import_codec_protobuf9.Stream(({ next, close }) => {
1934
1950
  invitation.subscribe((invitation2) => {
1935
1951
  next(invitation2);
1936
1952
  }, (err) => {
@@ -1993,7 +2009,7 @@ var InvitationsServiceImpl = class {
1993
2009
  }
1994
2010
  }
1995
2011
  queryInvitations() {
1996
- return new import_codec_protobuf8.Stream(({ next, ctx }) => {
2012
+ return new import_codec_protobuf9.Stream(({ next, ctx }) => {
1997
2013
  this._invitationCreated.on(ctx, (invitation) => {
1998
2014
  next({
1999
2015
  action: import_services5.QueryInvitationsResponse.Action.ADDED,
@@ -2134,38 +2150,95 @@ var SpaceInvitationProtocol = class {
2134
2150
  }
2135
2151
  };
2136
2152
 
2137
- // packages/sdk/client-services/src/packlets/logging/logging-service.ts
2153
+ // packages/sdk/client-services/src/packlets/locks/node.ts
2154
+ var import_lockfile = __toESM(require("lockfile"));
2138
2155
  var import_async11 = require("@dxos/async");
2139
- var import_codec_protobuf9 = require("@dxos/codec-protobuf");
2140
2156
  var import_log8 = require("@dxos/log");
2157
+ var __decorate = function(decorators, target, key, desc) {
2158
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2159
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2160
+ r = Reflect.decorate(decorators, target, key, desc);
2161
+ else
2162
+ for (var i = decorators.length - 1; i >= 0; i--)
2163
+ if (d = decorators[i])
2164
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2165
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2166
+ };
2167
+ var Lock = class {
2168
+ constructor({ lockKey: lockPath, onAcquire, onRelease }) {
2169
+ this._releaseTrigger = new import_async11.Trigger();
2170
+ this._lockPath = lockPath;
2171
+ this._onAcquire = onAcquire;
2172
+ this._onRelease = onRelease;
2173
+ }
2174
+ get lockKey() {
2175
+ return this._lockPath;
2176
+ }
2177
+ async acquire() {
2178
+ var _a;
2179
+ (0, import_log8.log)("acquiring lock...", {}, {
2180
+ file: "node.ts",
2181
+ line: 31,
2182
+ scope: this,
2183
+ callSite: (f, a) => f(...a)
2184
+ });
2185
+ if (import_lockfile.default.checkSync(this.lockKey)) {
2186
+ throw new Error(`Lock already acquired: ${this._lockPath}`);
2187
+ }
2188
+ import_lockfile.default.lockSync(this._lockPath);
2189
+ await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
2190
+ (0, import_log8.log)("acquired lock", {}, {
2191
+ file: "node.ts",
2192
+ line: 39,
2193
+ scope: this,
2194
+ callSite: (f, a) => f(...a)
2195
+ });
2196
+ }
2197
+ async release() {
2198
+ var _a;
2199
+ if (!import_lockfile.default.checkSync(this._lockPath)) {
2200
+ throw new Error(`Lock already acquired: ${this._lockPath}`);
2201
+ }
2202
+ await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
2203
+ import_lockfile.default.unlockSync(this._lockPath);
2204
+ }
2205
+ };
2206
+ __decorate([
2207
+ import_log8.logInfo
2208
+ ], Lock.prototype, "lockKey", null);
2209
+
2210
+ // packages/sdk/client-services/src/packlets/logging/logging-service.ts
2211
+ var import_async12 = require("@dxos/async");
2212
+ var import_codec_protobuf10 = require("@dxos/codec-protobuf");
2213
+ var import_log9 = require("@dxos/log");
2141
2214
  var import_util3 = require("@dxos/util");
2142
2215
  var LoggingServiceImpl = class {
2143
2216
  constructor() {
2144
- this._logs = new import_async11.Event();
2217
+ this._logs = new import_async12.Event();
2145
2218
  this._logProcessor = (_config, entry2) => {
2146
2219
  this._logs.emit(entry2);
2147
2220
  };
2148
2221
  }
2149
2222
  async open() {
2150
- import_log8.log.runtimeConfig.processors.push(this._logProcessor);
2223
+ import_log9.log.runtimeConfig.processors.push(this._logProcessor);
2151
2224
  }
2152
2225
  async close() {
2153
- const index = import_log8.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
2154
- import_log8.log.runtimeConfig.processors.splice(index, 1);
2226
+ const index = import_log9.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
2227
+ import_log9.log.runtimeConfig.processors.splice(index, 1);
2155
2228
  }
2156
2229
  queryLogs(request) {
2157
2230
  var _a;
2158
2231
  const filters = ((_a = request.filters) == null ? void 0 : _a.length) ? request.filters : void 0;
2159
- return new import_codec_protobuf9.Stream(({ ctx, next }) => {
2232
+ return new import_codec_protobuf10.Stream(({ ctx, next }) => {
2160
2233
  const handler = (entry2) => {
2161
2234
  var _a2, _b, _c;
2162
2235
  if (((_a2 = entry2.meta) == null ? void 0 : _a2.file.includes("logging-service")) || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
2163
2236
  return;
2164
2237
  }
2165
- if ((0, import_log8.shouldLog)(entry2, filters)) {
2238
+ if ((0, import_log9.shouldLog)(entry2, filters)) {
2166
2239
  const record = {
2167
2240
  ...entry2,
2168
- context: (0, import_util3.jsonify)((0, import_log8.getContextFromEntry)(entry2))
2241
+ context: (0, import_util3.jsonify)((0, import_log9.getContextFromEntry)(entry2))
2169
2242
  };
2170
2243
  (_b = record.meta) == null ? true : delete _b.bugcheck;
2171
2244
  (_c = record.meta) == null ? true : delete _c.scope;
@@ -2181,14 +2254,14 @@ var LoggingServiceImpl = class {
2181
2254
  };
2182
2255
 
2183
2256
  // packages/sdk/client-services/src/packlets/network/network-service.ts
2184
- var import_codec_protobuf10 = require("@dxos/codec-protobuf");
2257
+ var import_codec_protobuf11 = require("@dxos/codec-protobuf");
2185
2258
  var NetworkServiceImpl = class {
2186
2259
  constructor(networkManager, signalManager) {
2187
2260
  this.networkManager = networkManager;
2188
2261
  this.signalManager = signalManager;
2189
2262
  }
2190
2263
  queryStatus() {
2191
- return new import_codec_protobuf10.Stream(({ next }) => {
2264
+ return new import_codec_protobuf11.Stream(({ next }) => {
2192
2265
  const update = () => {
2193
2266
  next({
2194
2267
  swarm: this.networkManager.connectionState,
@@ -2214,45 +2287,46 @@ var NetworkServiceImpl = class {
2214
2287
 
2215
2288
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
2216
2289
  var import_node_assert10 = __toESM(require("node:assert"));
2217
- var import_async14 = require("@dxos/async");
2290
+ var import_async15 = require("@dxos/async");
2218
2291
  var import_context7 = require("@dxos/context");
2219
2292
  var import_credentials13 = require("@dxos/credentials");
2220
2293
  var import_keys10 = require("@dxos/keys");
2221
- var import_log11 = require("@dxos/log");
2294
+ var import_log12 = require("@dxos/log");
2222
2295
  var import_protocols6 = require("@dxos/protocols");
2223
2296
  var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
2224
2297
  var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
2225
2298
  var import_util6 = require("@dxos/util");
2226
2299
 
2227
2300
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
2228
- var import_async13 = require("@dxos/async");
2301
+ var import_async14 = require("@dxos/async");
2229
2302
  var import_client_protocol3 = require("@dxos/client-protocol");
2230
2303
  var import_context6 = require("@dxos/context");
2231
2304
  var import_debug3 = require("@dxos/debug");
2232
2305
  var import_echo_pipeline = require("@dxos/echo-pipeline");
2233
2306
  var import_errors3 = require("@dxos/errors");
2234
2307
  var import_keys9 = require("@dxos/keys");
2235
- var import_log10 = require("@dxos/log");
2308
+ var import_log11 = require("@dxos/log");
2236
2309
  var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
2237
2310
  var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
2238
2311
  var import_util5 = require("@dxos/util");
2239
2312
 
2240
2313
  // packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
2241
2314
  var import_node_assert9 = __toESM(require("node:assert"));
2242
- var import_async12 = require("@dxos/async");
2315
+ var import_async13 = require("@dxos/async");
2243
2316
  var import_context5 = require("@dxos/context");
2244
2317
  var import_keys8 = require("@dxos/keys");
2245
- var import_log9 = require("@dxos/log");
2318
+ var import_log10 = require("@dxos/log");
2246
2319
  var import_protocols5 = require("@dxos/protocols");
2247
2320
  var import_teleport2 = require("@dxos/teleport");
2248
2321
  var import_util4 = require("@dxos/util");
2249
2322
  var DEFAULT_RETRY_TIMEOUT = 1e3;
2250
2323
  var DEFAULT_SUCCESS_DELAY = 1e3;
2251
2324
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
2325
+ var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
2252
2326
  var NotarizationPlugin = class {
2253
2327
  constructor() {
2254
2328
  this._ctx = new import_context5.Context();
2255
- this._extensionOpened = new import_async12.Event();
2329
+ this._extensionOpened = new import_async13.Event();
2256
2330
  this._extensions = /* @__PURE__ */ new Set();
2257
2331
  this._processedCredentials = new import_util4.ComplexSet(import_keys8.PublicKey.hash);
2258
2332
  this._processCredentialsTriggers = new import_util4.ComplexMap(import_keys8.PublicKey.hash);
@@ -2266,23 +2340,23 @@ var NotarizationPlugin = class {
2266
2340
  * Request credentials to be notarized.
2267
2341
  */
2268
2342
  async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
2269
- (0, import_log9.log)("notarize", {
2343
+ (0, import_log10.log)("notarize", {
2270
2344
  credentials
2271
2345
  }, {
2272
2346
  file: "notarization-plugin.ts",
2273
- line: 85,
2347
+ line: 87,
2274
2348
  scope: this,
2275
2349
  callSite: (f, a) => f(...a)
2276
2350
  });
2277
2351
  (0, import_node_assert9.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
2278
- const errors = new import_async12.Trigger();
2352
+ const errors = new import_async13.Trigger();
2279
2353
  const ctx = this._ctx.derive({
2280
2354
  onError: (err) => {
2281
- import_log9.log.warn("Notarization error", {
2355
+ import_log10.log.warn("Notarization error", {
2282
2356
  err
2283
2357
  }, {
2284
2358
  file: "notarization-plugin.ts",
2285
- line: 94,
2359
+ line: 96,
2286
2360
  scope: this,
2287
2361
  callSite: (f, a) => f(...a)
2288
2362
  });
@@ -2292,23 +2366,23 @@ var NotarizationPlugin = class {
2292
2366
  });
2293
2367
  opCtx == null ? void 0 : opCtx.onDispose(() => ctx.dispose());
2294
2368
  if (timeout !== 0) {
2295
- (0, import_async12.scheduleTask)(ctx, () => {
2296
- import_log9.log.warn("Notarization timeout", {
2369
+ (0, import_async13.scheduleTask)(ctx, () => {
2370
+ import_log10.log.warn("Notarization timeout", {
2297
2371
  timeout,
2298
2372
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
2299
2373
  }, {
2300
2374
  file: "notarization-plugin.ts",
2301
- line: 106,
2375
+ line: 108,
2302
2376
  scope: this,
2303
2377
  callSite: (f, a) => f(...a)
2304
2378
  });
2305
2379
  void ctx.dispose();
2306
- errors.throw(new import_async12.TimeoutError(timeout, "Notarization timed out"));
2380
+ errors.throw(new import_async13.TimeoutError(timeout, "Notarization timed out"));
2307
2381
  }, timeout);
2308
2382
  }
2309
2383
  const allNotarized = Promise.all(credentials.map((credential) => this._waitUntilProcessed(credential.id)));
2310
2384
  const peersTried = /* @__PURE__ */ new Set();
2311
- const notarizeTask = new import_async12.DeferredTask(ctx, async () => {
2385
+ const notarizeTask = new import_async13.DeferredTask(ctx, async () => {
2312
2386
  try {
2313
2387
  if (this._extensions.size === 0) {
2314
2388
  return;
@@ -2317,45 +2391,47 @@ var NotarizationPlugin = class {
2317
2391
  ...this._extensions
2318
2392
  ].find((peer2) => !peersTried.has(peer2));
2319
2393
  if (!peer) {
2320
- import_log9.log.warn("Exhausted all peers to notarize with", {
2394
+ import_log10.log.warn("Exhausted all peers to notarize with", {
2321
2395
  retryIn: retryTimeout
2322
2396
  }, {
2323
2397
  file: "notarization-plugin.ts",
2324
- line: 131,
2398
+ line: 133,
2325
2399
  scope: this,
2326
2400
  callSite: (f, a) => f(...a)
2327
2401
  });
2328
2402
  peersTried.clear();
2329
- (0, import_async12.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
2403
+ (0, import_async13.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
2330
2404
  return;
2331
2405
  }
2332
2406
  peersTried.add(peer);
2333
- (0, import_log9.log)("try notarizing", {
2407
+ (0, import_log10.log)("try notarizing", {
2334
2408
  peer: peer.localPeerId,
2335
2409
  credentialId: credentials.map((credential) => credential.id)
2336
2410
  }, {
2337
2411
  file: "notarization-plugin.ts",
2338
- line: 138,
2412
+ line: 140,
2339
2413
  scope: this,
2340
2414
  callSite: (f, a) => f(...a)
2341
2415
  });
2342
2416
  await peer.rpc.NotarizationService.notarize({
2343
2417
  credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
2344
2418
  });
2345
- (0, import_log9.log)("success", {}, {
2419
+ (0, import_log10.log)("success", {}, {
2346
2420
  file: "notarization-plugin.ts",
2347
- line: 142,
2421
+ line: 144,
2348
2422
  scope: this,
2349
2423
  callSite: (f, a) => f(...a)
2350
2424
  });
2351
- await (0, import_async12.sleep)(successDelay);
2425
+ await (0, import_async13.sleep)(successDelay);
2352
2426
  } catch (err) {
2353
- import_log9.log.warn("error notarizing (recoverable)", err, {
2354
- file: "notarization-plugin.ts",
2355
- line: 145,
2356
- scope: this,
2357
- callSite: (f, a) => f(...a)
2358
- });
2427
+ if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
2428
+ import_log10.log.warn("error notarizing (recoverable)", err, {
2429
+ file: "notarization-plugin.ts",
2430
+ line: 148,
2431
+ scope: this,
2432
+ callSite: (f, a) => f(...a)
2433
+ });
2434
+ }
2359
2435
  notarizeTask.schedule();
2360
2436
  }
2361
2437
  });
@@ -2367,9 +2443,9 @@ var NotarizationPlugin = class {
2367
2443
  allNotarized,
2368
2444
  errors.wait()
2369
2445
  ]);
2370
- (0, import_log9.log)("done", {}, {
2446
+ (0, import_log10.log)("done", {}, {
2371
2447
  file: "notarization-plugin.ts",
2372
- line: 155,
2448
+ line: 159,
2373
2449
  scope: this,
2374
2450
  callSite: (f, a) => f(...a)
2375
2451
  });
@@ -2397,7 +2473,7 @@ var NotarizationPlugin = class {
2397
2473
  if (this._processedCredentials.has(id)) {
2398
2474
  return;
2399
2475
  }
2400
- await (0, import_util4.entry)(this._processCredentialsTriggers, id).orInsert(new import_async12.Trigger()).value.wait();
2476
+ await (0, import_util4.entry)(this._processCredentialsTriggers, id).orInsert(new import_async13.Trigger()).value.wait();
2401
2477
  }
2402
2478
  /**
2403
2479
  * Requests from other peers to notarize credentials.
@@ -2405,7 +2481,7 @@ var NotarizationPlugin = class {
2405
2481
  async _onNotarize(request) {
2406
2482
  var _a;
2407
2483
  if (!this._writer) {
2408
- throw new Error("Writer not set");
2484
+ throw new Error(WRITER_NOT_SET_ERROR_CODE);
2409
2485
  }
2410
2486
  for (const credential of (_a = request.credentials) != null ? _a : []) {
2411
2487
  (0, import_node_assert9.default)(credential.id, "Credential must have an id");
@@ -2418,11 +2494,11 @@ var NotarizationPlugin = class {
2418
2494
  createExtension() {
2419
2495
  const extension = new NotarizationTeleportExtension({
2420
2496
  onOpen: async () => {
2421
- (0, import_log9.log)("extension opened", {
2497
+ (0, import_log10.log)("extension opened", {
2422
2498
  peer: extension.localPeerId
2423
2499
  }, {
2424
2500
  file: "notarization-plugin.ts",
2425
- line: 204,
2501
+ line: 208,
2426
2502
  scope: this,
2427
2503
  callSite: (f, a) => f(...a)
2428
2504
  });
@@ -2430,11 +2506,11 @@ var NotarizationPlugin = class {
2430
2506
  this._extensionOpened.emit();
2431
2507
  },
2432
2508
  onClose: async () => {
2433
- (0, import_log9.log)("extension closed", {
2509
+ (0, import_log10.log)("extension closed", {
2434
2510
  peer: extension.localPeerId
2435
2511
  }, {
2436
2512
  file: "notarization-plugin.ts",
2437
- line: 209,
2513
+ line: 213,
2438
2514
  scope: this,
2439
2515
  callSite: (f, a) => f(...a)
2440
2516
  });
@@ -2477,7 +2553,7 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
2477
2553
  };
2478
2554
 
2479
2555
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
2480
- var __decorate = function(decorators, target, key, desc) {
2556
+ var __decorate2 = function(decorators, target, key, desc) {
2481
2557
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2482
2558
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2483
2559
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2495,7 +2571,7 @@ var DataSpace = class DataSpace2 {
2495
2571
  * Error for _state === SpaceState.ERROR.
2496
2572
  */
2497
2573
  this.error = void 0;
2498
- this.stateUpdate = new import_async13.Event();
2574
+ this.stateUpdate = new import_async14.Event();
2499
2575
  this.metrics = {};
2500
2576
  var _a;
2501
2577
  this._inner = params.inner;
@@ -2566,13 +2642,13 @@ var DataSpace = class DataSpace2 {
2566
2642
  * Initialize the data pipeline in a separate task.
2567
2643
  */
2568
2644
  initializeDataPipelineAsync() {
2569
- (0, import_async13.scheduleTask)(this._ctx, async () => {
2645
+ (0, import_async14.scheduleTask)(this._ctx, async () => {
2570
2646
  try {
2571
2647
  this.metrics.pipelineInitBegin = new Date();
2572
2648
  await this.initializeDataPipeline();
2573
2649
  } catch (err) {
2574
2650
  if (err instanceof import_errors3.CancelledError) {
2575
- (0, import_log10.log)("Data pipeline initialization cancelled", err, {
2651
+ (0, import_log11.log)("Data pipeline initialization cancelled", err, {
2576
2652
  file: "data-space.ts",
2577
2653
  line: 172,
2578
2654
  scope: this,
@@ -2580,7 +2656,7 @@ var DataSpace = class DataSpace2 {
2580
2656
  });
2581
2657
  return;
2582
2658
  }
2583
- import_log10.log.error("Error initializing data pipeline", err, {
2659
+ import_log11.log.error("Error initializing data pipeline", err, {
2584
2660
  file: "data-space.ts",
2585
2661
  line: 176,
2586
2662
  scope: this,
@@ -2606,7 +2682,7 @@ var DataSpace = class DataSpace2 {
2606
2682
  });
2607
2683
  this.metrics.controlPipelineReady = new Date();
2608
2684
  await this._createWritableFeeds();
2609
- (0, import_log10.log)("Writable feeds created", {}, {
2685
+ (0, import_log11.log)("Writable feeds created", {}, {
2610
2686
  file: "data-space.ts",
2611
2687
  line: 201,
2612
2688
  scope: this,
@@ -2621,7 +2697,7 @@ var DataSpace = class DataSpace2 {
2621
2697
  await this._inner.initializeDataPipeline();
2622
2698
  this.metrics.dataPipelineOpen = new Date();
2623
2699
  await (0, import_context6.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
2624
- (0, import_log10.log)("waiting for data pipeline to reach target timeframe", {}, {
2700
+ (0, import_log11.log)("waiting for data pipeline to reach target timeframe", {}, {
2625
2701
  file: "data-space.ts",
2626
2702
  line: 220,
2627
2703
  scope: this,
@@ -2632,7 +2708,7 @@ var DataSpace = class DataSpace2 {
2632
2708
  breakOnStall: false
2633
2709
  });
2634
2710
  this.metrics.dataPipelineReady = new Date();
2635
- (0, import_log10.log)("data pipeline ready", {}, {
2711
+ (0, import_log11.log)("data pipeline ready", {}, {
2636
2712
  file: "data-space.ts",
2637
2713
  line: 229,
2638
2714
  scope: this,
@@ -2708,11 +2784,11 @@ var DataSpace = class DataSpace2 {
2708
2784
  }
2709
2785
  }
2710
2786
  };
2711
- __decorate([
2787
+ __decorate2([
2712
2788
  (0, import_debug3.timed)(1e4)
2713
2789
  ], DataSpace.prototype, "_createWritableFeeds", null);
2714
- DataSpace = __decorate([
2715
- (0, import_async13.trackLeaks)("open", "close")
2790
+ DataSpace = __decorate2([
2791
+ (0, import_async14.trackLeaks)("open", "close")
2716
2792
  ], DataSpace);
2717
2793
 
2718
2794
  // packages/sdk/client-services/src/packlets/spaces/genesis.ts
@@ -2786,7 +2862,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
2786
2862
  };
2787
2863
 
2788
2864
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
2789
- var __decorate2 = function(decorators, target, key, desc) {
2865
+ var __decorate3 = function(decorators, target, key, desc) {
2790
2866
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2791
2867
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2792
2868
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2805,7 +2881,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2805
2881
  this._signingContext = _signingContext;
2806
2882
  this._feedStore = _feedStore;
2807
2883
  this._ctx = new import_context7.Context();
2808
- this.updated = new import_async14.Event();
2884
+ this.updated = new import_async15.Event();
2809
2885
  this._spaces = new import_util6.ComplexMap(import_keys10.PublicKey.hash);
2810
2886
  this._isOpen = false;
2811
2887
  this._instanceId = import_keys10.PublicKey.random().toHex();
@@ -2815,13 +2891,13 @@ var DataSpaceManager = class DataSpaceManager2 {
2815
2891
  return this._spaces;
2816
2892
  }
2817
2893
  async open() {
2818
- (0, import_log11.log)("open", {}, {
2894
+ (0, import_log12.log)("open", {}, {
2819
2895
  file: "data-space-manager.ts",
2820
2896
  line: 80,
2821
2897
  scope: this,
2822
2898
  callSite: (f, a) => f(...a)
2823
2899
  });
2824
- import_log11.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.begin({
2900
+ import_log12.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.begin({
2825
2901
  id: this._instanceId
2826
2902
  }), {
2827
2903
  file: "data-space-manager.ts",
@@ -2830,7 +2906,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2830
2906
  callSite: (f, a) => f(...a)
2831
2907
  });
2832
2908
  await this._metadataStore.load();
2833
- (0, import_log11.log)("metadata loaded", {
2909
+ (0, import_log12.log)("metadata loaded", {
2834
2910
  spaces: this._metadataStore.spaces.length
2835
2911
  }, {
2836
2912
  file: "data-space-manager.ts",
@@ -2840,7 +2916,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2840
2916
  });
2841
2917
  for (const spaceMetadata of this._metadataStore.spaces) {
2842
2918
  try {
2843
- (0, import_log11.log)("load space", {
2919
+ (0, import_log12.log)("load space", {
2844
2920
  spaceMetadata
2845
2921
  }, {
2846
2922
  file: "data-space-manager.ts",
@@ -2851,7 +2927,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2851
2927
  const space = await this._constructSpace(spaceMetadata);
2852
2928
  space.initializeDataPipelineAsync();
2853
2929
  } catch (err) {
2854
- import_log11.log.error("Error loading space", {
2930
+ import_log12.log.error("Error loading space", {
2855
2931
  spaceMetadata,
2856
2932
  err
2857
2933
  }, {
@@ -2864,7 +2940,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2864
2940
  }
2865
2941
  this._isOpen = true;
2866
2942
  this.updated.emit();
2867
- import_log11.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.end({
2943
+ import_log12.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.end({
2868
2944
  id: this._instanceId
2869
2945
  }), {
2870
2946
  file: "data-space-manager.ts",
@@ -2874,7 +2950,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2874
2950
  });
2875
2951
  }
2876
2952
  async close() {
2877
- (0, import_log11.log)("close", {}, {
2953
+ (0, import_log12.log)("close", {}, {
2878
2954
  file: "data-space-manager.ts",
2879
2955
  line: 102,
2880
2956
  scope: this,
@@ -2900,7 +2976,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2900
2976
  controlFeedKey,
2901
2977
  dataFeedKey
2902
2978
  };
2903
- (0, import_log11.log)("creating space...", {
2979
+ (0, import_log12.log)("creating space...", {
2904
2980
  spaceKey
2905
2981
  }, {
2906
2982
  file: "data-space-manager.ts",
@@ -2920,7 +2996,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2920
2996
  }
2921
2997
  // TODO(burdon): Rename join space.
2922
2998
  async acceptSpace(opts) {
2923
- (0, import_log11.log)("accept space", {
2999
+ (0, import_log12.log)("accept space", {
2924
3000
  opts
2925
3001
  }, {
2926
3002
  file: "data-space-manager.ts",
@@ -2954,7 +3030,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2954
3030
  }));
2955
3031
  }
2956
3032
  async _constructSpace(metadata) {
2957
- (0, import_log11.log)("construct space", {
3033
+ (0, import_log12.log)("construct space", {
2958
3034
  metadata
2959
3035
  }, {
2960
3036
  file: "data-space-manager.ts",
@@ -2992,7 +3068,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2992
3068
  session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
2993
3069
  },
2994
3070
  onAuthFailure: () => {
2995
- import_log11.log.warn("auth failure", {}, {
3071
+ import_log12.log.warn("auth failure", {}, {
2996
3072
  file: "data-space-manager.ts",
2997
3073
  line: 212,
2998
3074
  scope: this,
@@ -3013,7 +3089,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3013
3089
  signingContext: this._signingContext,
3014
3090
  callbacks: {
3015
3091
  beforeReady: async () => {
3016
- (0, import_log11.log)("before space ready", {
3092
+ (0, import_log12.log)("before space ready", {
3017
3093
  space: space.key
3018
3094
  }, {
3019
3095
  file: "data-space-manager.ts",
@@ -3024,7 +3100,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3024
3100
  this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
3025
3101
  },
3026
3102
  afterReady: async () => {
3027
- (0, import_log11.log)("after space ready", {
3103
+ (0, import_log12.log)("after space ready", {
3028
3104
  space: space.key,
3029
3105
  open: this._isOpen
3030
3106
  }, {
@@ -3051,28 +3127,28 @@ var DataSpaceManager = class DataSpaceManager2 {
3051
3127
  return dataSpace;
3052
3128
  }
3053
3129
  };
3054
- __decorate2([
3055
- import_async14.synchronized
3130
+ __decorate3([
3131
+ import_async15.synchronized
3056
3132
  ], DataSpaceManager.prototype, "open", null);
3057
- __decorate2([
3058
- import_async14.synchronized
3133
+ __decorate3([
3134
+ import_async15.synchronized
3059
3135
  ], DataSpaceManager.prototype, "close", null);
3060
- __decorate2([
3061
- import_async14.synchronized
3136
+ __decorate3([
3137
+ import_async15.synchronized
3062
3138
  ], DataSpaceManager.prototype, "createSpace", null);
3063
- __decorate2([
3064
- import_async14.synchronized
3139
+ __decorate3([
3140
+ import_async15.synchronized
3065
3141
  ], DataSpaceManager.prototype, "acceptSpace", null);
3066
- DataSpaceManager = __decorate2([
3067
- (0, import_async14.trackLeaks)("open", "close")
3142
+ DataSpaceManager = __decorate3([
3143
+ (0, import_async15.trackLeaks)("open", "close")
3068
3144
  ], DataSpaceManager);
3069
3145
 
3070
3146
  // packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
3071
- var import_async15 = require("@dxos/async");
3072
- var import_codec_protobuf11 = require("@dxos/codec-protobuf");
3147
+ var import_async16 = require("@dxos/async");
3148
+ var import_codec_protobuf12 = require("@dxos/codec-protobuf");
3073
3149
  var import_debug5 = require("@dxos/debug");
3074
3150
  var import_echo_pipeline2 = require("@dxos/echo-pipeline");
3075
- var import_log12 = require("@dxos/log");
3151
+ var import_log13 = require("@dxos/log");
3076
3152
  var import_protocols7 = require("@dxos/protocols");
3077
3153
  var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
3078
3154
  var import_util7 = require("@dxos/util");
@@ -3096,15 +3172,15 @@ var SpacesServiceImpl = class {
3096
3172
  (0, import_debug5.todo)();
3097
3173
  }
3098
3174
  querySpaces() {
3099
- return new import_codec_protobuf11.Stream(({ next, ctx }) => {
3175
+ return new import_codec_protobuf12.Stream(({ next, ctx }) => {
3100
3176
  const onUpdate = async () => {
3101
3177
  const dataSpaceManager = await this._getDataSpaceManager();
3102
3178
  const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._transformSpace(space));
3103
- (0, import_log12.log)("update", {
3179
+ (0, import_log13.log)("update", {
3104
3180
  spaces
3105
3181
  }, {
3106
3182
  file: "spaces-service.ts",
3107
- line: 62,
3183
+ line: 59,
3108
3184
  scope: this,
3109
3185
  callSite: (f, a) => f(...a)
3110
3186
  });
@@ -3112,9 +3188,9 @@ var SpacesServiceImpl = class {
3112
3188
  spaces
3113
3189
  });
3114
3190
  };
3115
- (0, import_async15.scheduleTask)(ctx, async () => {
3191
+ (0, import_async16.scheduleTask)(ctx, async () => {
3116
3192
  const dataSpaceManager = await this._getDataSpaceManager();
3117
- const subscriptions = new import_async15.EventSubscriptions();
3193
+ const subscriptions = new import_async16.EventSubscriptions();
3118
3194
  ctx.onDispose(() => subscriptions.clear());
3119
3195
  const subscribeSpaces = () => {
3120
3196
  subscriptions.clear();
@@ -3148,8 +3224,8 @@ var SpacesServiceImpl = class {
3148
3224
  await space.postMessage(getChannelId(channel), message);
3149
3225
  }
3150
3226
  subscribeMessages({ spaceKey, channel }) {
3151
- return new import_codec_protobuf11.Stream(({ ctx, next }) => {
3152
- (0, import_async15.scheduleTask)(ctx, async () => {
3227
+ return new import_codec_protobuf12.Stream(({ ctx, next }) => {
3228
+ (0, import_async16.scheduleTask)(ctx, async () => {
3153
3229
  var _a;
3154
3230
  const dataSpaceManager = await this._getDataSpaceManager();
3155
3231
  const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
@@ -3161,7 +3237,7 @@ var SpacesServiceImpl = class {
3161
3237
  });
3162
3238
  }
3163
3239
  queryCredentials({ spaceKey }) {
3164
- return new import_codec_protobuf11.Stream(({ ctx, next }) => {
3240
+ return new import_codec_protobuf12.Stream(({ ctx, next }) => {
3165
3241
  var _a;
3166
3242
  const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3167
3243
  const processor = space.spaceState.registerProcessor({
@@ -3170,7 +3246,7 @@ var SpacesServiceImpl = class {
3170
3246
  }
3171
3247
  });
3172
3248
  ctx.onDispose(() => processor.close());
3173
- (0, import_async15.scheduleTask)(ctx, () => processor.open());
3249
+ (0, import_async16.scheduleTask)(ctx, () => processor.open());
3174
3250
  });
3175
3251
  }
3176
3252
  async writeCredentials({ spaceKey, credentials }) {
@@ -3273,7 +3349,7 @@ var toStorageType = (type) => {
3273
3349
  };
3274
3350
 
3275
3351
  // packages/sdk/client-services/src/packlets/system/system-service.ts
3276
- var import_codec_protobuf12 = require("@dxos/codec-protobuf");
3352
+ var import_codec_protobuf13 = require("@dxos/codec-protobuf");
3277
3353
  var SystemServiceImpl = class {
3278
3354
  constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
3279
3355
  this._config = config;
@@ -3290,7 +3366,7 @@ var SystemServiceImpl = class {
3290
3366
  await this._onUpdateStatus(status);
3291
3367
  }
3292
3368
  queryStatus() {
3293
- return new import_codec_protobuf12.Stream(({ next }) => {
3369
+ return new import_codec_protobuf13.Stream(({ next }) => {
3294
3370
  const update = () => {
3295
3371
  next({
3296
3372
  status: this._getCurrentStatus()
@@ -3310,543 +3386,18 @@ var SystemServiceImpl = class {
3310
3386
  }
3311
3387
  };
3312
3388
 
3313
- // packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
3314
- var import_async17 = require("@dxos/async");
3315
- var import_client_protocol5 = require("@dxos/client-protocol");
3316
- var import_log13 = require("@dxos/log");
3317
- var import_messaging = require("@dxos/messaging");
3318
- var import_network_manager2 = require("@dxos/network-manager");
3319
- var import_util8 = require("@dxos/util");
3320
-
3321
- // packages/sdk/client-services/src/packlets/services/client-rpc-server.ts
3322
- var import_codec_protobuf13 = require("@dxos/codec-protobuf");
3323
- var import_debug6 = require("@dxos/debug");
3324
- var import_rpc = require("@dxos/rpc");
3325
- var ClientRpcServer = class {
3326
- constructor(params) {
3327
- this._handlerCache = /* @__PURE__ */ new Map();
3328
- const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
3329
- this._handleCall = handleCall;
3330
- this._handleStream = handleStream;
3331
- this._serviceRegistry = serviceRegistry;
3332
- this._rpcPeer = new import_rpc.RpcPeer({
3333
- ...rpcOptions,
3334
- callHandler: (method, params2) => {
3335
- const [serviceName, methodName] = (0, import_rpc.parseMethodName)(method);
3336
- const handler = (method2, params3) => this._getServiceHandler(serviceName).call(method2, params3);
3337
- if (this._handleCall) {
3338
- return this._handleCall(methodName, params2, handler);
3339
- } else {
3340
- return handler(methodName, params2);
3341
- }
3342
- },
3343
- streamHandler: (method, params2) => {
3344
- const [serviceName, methodName] = (0, import_rpc.parseMethodName)(method);
3345
- const handler = (method2, params3) => this._getServiceHandler(serviceName).callStream(method2, params3);
3346
- if (this._handleStream) {
3347
- return import_codec_protobuf13.Stream.unwrapPromise(this._handleStream(methodName, params2, handler));
3348
- } else {
3349
- return handler(methodName, params2);
3350
- }
3351
- }
3352
- });
3353
- }
3354
- async open() {
3355
- await this._rpcPeer.open();
3356
- }
3357
- async close() {
3358
- await this._rpcPeer.close();
3359
- }
3360
- _getServiceHandler(serviceName) {
3361
- var _a;
3362
- if (!this._handlerCache.has(serviceName)) {
3363
- const [key, descriptor] = (_a = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName)) != null ? _a : (0, import_debug6.raise)(new Error(`Service not available: ${serviceName}`));
3364
- const service = this._serviceRegistry.services[key];
3365
- if (!service) {
3366
- throw new Error(`Service not available: ${serviceName}`);
3367
- }
3368
- this._handlerCache.set(serviceName, descriptor.createServer(service));
3369
- }
3370
- return this._handlerCache.get(serviceName);
3371
- }
3372
- };
3373
-
3374
- // packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
3375
- var import_node_assert11 = __toESM(require("node:assert"));
3376
- var import_async16 = require("@dxos/async");
3377
- var import_client_protocol4 = require("@dxos/client-protocol");
3378
- var import_iframe = require("@dxos/protocols/proto/dxos/iframe");
3379
- var import_rpc2 = require("@dxos/rpc");
3380
- var ShellRuntimeImpl = class {
3381
- constructor(_port) {
3382
- this._port = _port;
3383
- this.layoutUpdate = new import_async16.Event();
3384
- this._layout = import_iframe.ShellLayout.DEFAULT;
3385
- }
3386
- get layout() {
3387
- return this._layout;
3388
- }
3389
- get invitationCode() {
3390
- return this._invitationCode;
3391
- }
3392
- get spaceKey() {
3393
- return this._spaceKey;
3394
- }
3395
- setLayout(layout, options = {}) {
3396
- this._layout = layout;
3397
- this._invitationCode = options.invitationCode;
3398
- this._spaceKey = options.spaceKey;
3399
- this.layoutUpdate.emit({
3400
- layout,
3401
- ...options
3402
- });
3403
- }
3404
- async setAppContext(context) {
3405
- (0, import_node_assert11.default)(this._appRpc, "runtime not open");
3406
- await this._appRpc.rpc.AppService.setContext(context);
3407
- }
3408
- async open() {
3409
- this._appRpc = (0, import_rpc2.createProtoRpcPeer)({
3410
- requested: import_client_protocol4.appServiceBundle,
3411
- exposed: import_client_protocol4.shellServiceBundle,
3412
- handlers: {
3413
- ShellService: {
3414
- setLayout: async (request) => {
3415
- this._layout = request.layout;
3416
- this._invitationCode = request.invitationCode;
3417
- this._spaceKey = request.spaceKey;
3418
- this.layoutUpdate.emit(request);
3419
- }
3420
- }
3421
- },
3422
- port: this._port
3423
- });
3424
- await this._appRpc.open();
3425
- }
3426
- async close() {
3427
- var _a;
3428
- await ((_a = this._appRpc) == null ? void 0 : _a.close());
3429
- this._appRpc = void 0;
3430
- }
3431
- };
3432
-
3433
- // packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
3434
- var __decorate3 = function(decorators, target, key, desc) {
3435
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3436
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3437
- r = Reflect.decorate(decorators, target, key, desc);
3438
- else
3439
- for (var i = decorators.length - 1; i >= 0; i--)
3440
- if (d = decorators[i])
3441
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3442
- return c > 3 && r && Object.defineProperty(target, key, r), r;
3443
- };
3444
- var LOCK_KEY = "DXOS_RESOURCE_LOCK";
3445
- var IFrameHostRuntime = class {
3446
- constructor({ config, origin, appPort, shellPort }) {
3447
- this._ready = new import_async17.Trigger();
3448
- this._configProvider = config;
3449
- this.origin = origin;
3450
- this._appPort = appPort;
3451
- this._shellPort = shellPort;
3452
- if (this._shellPort) {
3453
- this._shellRuntime = new ShellRuntimeImpl(this._shellPort);
3454
- }
3455
- }
3456
- get services() {
3457
- return this._clientServices;
3458
- }
3459
- get shell() {
3460
- return this._shellRuntime;
3461
- }
3462
- async start() {
3463
- var _a;
3464
- (0, import_log13.log)("starting...", {}, {
3465
- file: "iframe-host-runtime.ts",
3466
- line: 70,
3467
- scope: this,
3468
- callSite: (f, a) => f(...a)
3469
- });
3470
- try {
3471
- this._config = await (0, import_util8.getAsyncValue)(this._configProvider);
3472
- this._transportFactory = (0, import_network_manager2.createWebRTCTransportFactory)({
3473
- iceServers: this._config.get("runtime.services.ice")
3474
- });
3475
- const signals = this._config.get("runtime.services.signaling");
3476
- this._clientServices = new LocalClientServices({
3477
- lockKey: LOCK_KEY,
3478
- config: this._config,
3479
- signalManager: signals ? new import_messaging.WebsocketSignalManager(signals) : new import_messaging.MemorySignalManager(new import_messaging.MemorySignalManagerContext()),
3480
- transportFactory: this._transportFactory
3481
- });
3482
- const middleware = {
3483
- handleCall: async (method, params, handler) => {
3484
- const error = await this._ready.wait({
3485
- timeout: import_client_protocol5.PROXY_CONNECTION_TIMEOUT
3486
- });
3487
- if (error) {
3488
- throw error;
3489
- }
3490
- return handler(method, params);
3491
- },
3492
- handleStream: async (method, params, handler) => {
3493
- const error = await this._ready.wait({
3494
- timeout: import_client_protocol5.PROXY_CONNECTION_TIMEOUT
3495
- });
3496
- if (error) {
3497
- throw error;
3498
- }
3499
- return handler(method, params);
3500
- }
3501
- };
3502
- this._clientRpc = new ClientRpcServer({
3503
- serviceRegistry: this._clientServices.host.serviceRegistry,
3504
- port: this._appPort,
3505
- ...middleware
3506
- });
3507
- await Promise.all([
3508
- this._clientServices.open(),
3509
- this._clientRpc.open(),
3510
- (_a = this._shellRuntime) == null ? void 0 : _a.open()
3511
- ]);
3512
- this._ready.wake(void 0);
3513
- (0, import_log13.log)("started", {}, {
3514
- file: "iframe-host-runtime.ts",
3515
- line: 113,
3516
- scope: this,
3517
- callSite: (f, a) => f(...a)
3518
- });
3519
- } catch (err) {
3520
- this._ready.wake(err);
3521
- import_log13.log.catch(err, {}, {
3522
- file: "iframe-host-runtime.ts",
3523
- line: 116,
3524
- scope: this,
3525
- callSite: (f, a) => f(...a)
3526
- });
3527
- }
3528
- }
3529
- async stop() {
3530
- var _a;
3531
- (0, import_log13.log)("stopping...", {}, {
3532
- file: "iframe-host-runtime.ts",
3533
- line: 121,
3534
- scope: this,
3535
- callSite: (f, a) => f(...a)
3536
- });
3537
- await this._clientRpc.close();
3538
- await this._clientServices.close();
3539
- await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
3540
- (0, import_log13.log)("stopped", {}, {
3541
- file: "iframe-host-runtime.ts",
3542
- line: 125,
3543
- scope: this,
3544
- callSite: (f, a) => f(...a)
3545
- });
3546
- }
3547
- };
3548
- __decorate3([
3549
- import_log13.logInfo
3550
- ], IFrameHostRuntime.prototype, "origin", void 0);
3551
-
3552
- // packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
3553
- var import_async18 = require("@dxos/async");
3554
- var import_client_protocol6 = require("@dxos/client-protocol");
3555
- var import_errors5 = require("@dxos/errors");
3556
- var import_log14 = require("@dxos/log");
3557
- var import_network_manager3 = require("@dxos/network-manager");
3558
- var import_rpc3 = require("@dxos/rpc");
3559
- var import_util9 = require("@dxos/util");
3560
-
3561
- // packages/sdk/client-services/src/packlets/vault/vault-resource-lock.ts
3562
- var import_async19 = require("@dxos/async");
3563
- var import_client_protocol7 = require("@dxos/client-protocol");
3564
- var import_log15 = require("@dxos/log");
3565
- var __decorate4 = function(decorators, target, key, desc) {
3566
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3567
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3568
- r = Reflect.decorate(decorators, target, key, desc);
3569
- else
3570
- for (var i = decorators.length - 1; i >= 0; i--)
3571
- if (d = decorators[i])
3572
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3573
- return c > 3 && r && Object.defineProperty(target, key, r), r;
3574
- };
3575
- var Message;
3576
- (function(Message2) {
3577
- Message2["ACQUIRING"] = "acquiring";
3578
- })(Message || (Message = {}));
3579
- var VaultResourceLock = class {
3580
- constructor({ lockKey, onAcquire, onRelease }) {
3581
- this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
3582
- this._releaseTrigger = new import_async19.Trigger();
3583
- this._lockKey = lockKey;
3584
- this._onAcquire = onAcquire;
3585
- this._onRelease = onRelease;
3586
- this._broadcastChannel.onmessage = this._onMessage.bind(this);
3587
- }
3588
- get lockKey() {
3589
- return this._lockKey;
3590
- }
3591
- async acquire() {
3592
- this._broadcastChannel.postMessage({
3593
- message: Message.ACQUIRING
3594
- });
3595
- try {
3596
- (0, import_log15.log)("aquiring lock...", {}, {
3597
- file: "vault-resource-lock.ts",
3598
- line: 45,
3599
- scope: this,
3600
- callSite: (f, a) => f(...a)
3601
- });
3602
- await (0, import_async19.asyncTimeout)(this._requestLock(), import_client_protocol7.RESOURCE_LOCK_TIMEOUT);
3603
- (0, import_log15.log)("acquired lock", {}, {
3604
- file: "vault-resource-lock.ts",
3605
- line: 47,
3606
- scope: this,
3607
- callSite: (f, a) => f(...a)
3608
- });
3609
- } catch (e) {
3610
- (0, import_log15.log)("stealing lock...", {}, {
3611
- file: "vault-resource-lock.ts",
3612
- line: 49,
3613
- scope: this,
3614
- callSite: (f, a) => f(...a)
3615
- });
3616
- await this._requestLock(true);
3617
- (0, import_log15.log)("stolen lock", {}, {
3618
- file: "vault-resource-lock.ts",
3619
- line: 51,
3620
- scope: this,
3621
- callSite: (f, a) => f(...a)
3622
- });
3623
- }
3624
- }
3625
- async release() {
3626
- this._releaseTrigger.wake();
3627
- }
3628
- _onMessage(event) {
3629
- if (event.data.message === Message.ACQUIRING) {
3630
- this._releaseTrigger.wake();
3631
- }
3632
- }
3633
- async _requestLock(steal = false) {
3634
- (0, import_log15.log)("requesting lock...", {
3635
- steal
3636
- }, {
3637
- file: "vault-resource-lock.ts",
3638
- line: 66,
3639
- scope: this,
3640
- callSite: (f, a) => f(...a)
3641
- });
3642
- const acquired = new import_async19.Trigger();
3643
- void navigator.locks.request(this._lockKey, {
3644
- steal
3645
- }, async () => {
3646
- var _a, _b;
3647
- await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
3648
- acquired.wake();
3649
- this._releaseTrigger = new import_async19.Trigger();
3650
- await this._releaseTrigger.wait();
3651
- (0, import_log15.log)("releasing lock...", {}, {
3652
- file: "vault-resource-lock.ts",
3653
- line: 75,
3654
- scope: this,
3655
- callSite: (f, a) => f(...a)
3656
- });
3657
- await ((_b = this._onRelease) == null ? void 0 : _b.call(this));
3658
- (0, import_log15.log)("released lock", {}, {
3659
- file: "vault-resource-lock.ts",
3660
- line: 77,
3661
- scope: this,
3662
- callSite: (f, a) => f(...a)
3663
- });
3664
- }).catch(async () => {
3665
- var _a;
3666
- await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
3667
- });
3668
- await acquired.wait();
3669
- (0, import_log15.log)("recieved lock", {
3670
- steal
3671
- }, {
3672
- file: "vault-resource-lock.ts",
3673
- line: 84,
3674
- scope: this,
3675
- callSite: (f, a) => f(...a)
3676
- });
3677
- }
3678
- };
3679
- __decorate4([
3680
- import_log15.logInfo
3681
- ], VaultResourceLock.prototype, "lockKey", null);
3682
-
3683
- // packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
3684
- var import_async21 = require("@dxos/async");
3685
- var import_log17 = require("@dxos/log");
3686
- var import_messaging2 = require("@dxos/messaging");
3687
- var import_network_manager4 = require("@dxos/network-manager");
3688
-
3689
- // packages/sdk/client-services/src/packlets/vault/worker-session.ts
3690
- var import_node_assert12 = __toESM(require("node:assert"));
3691
- var import_async20 = require("@dxos/async");
3692
- var import_client_protocol8 = require("@dxos/client-protocol");
3693
- var import_log16 = require("@dxos/log");
3694
- var import_rpc4 = require("@dxos/rpc");
3695
- var import_util10 = require("@dxos/util");
3696
- var __decorate5 = function(decorators, target, key, desc) {
3697
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3698
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3699
- r = Reflect.decorate(decorators, target, key, desc);
3700
- else
3701
- for (var i = decorators.length - 1; i >= 0; i--)
3702
- if (d = decorators[i])
3703
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3704
- return c > 3 && r && Object.defineProperty(target, key, r), r;
3705
- };
3706
- var WorkerSession = class {
3707
- constructor({ serviceHost, systemPort, appPort, shellPort, readySignal }) {
3708
- this._startTrigger = new import_async20.Trigger();
3709
- this.onClose = new import_util10.Callback();
3710
- (0, import_node_assert12.default)(serviceHost);
3711
- this._serviceHost = serviceHost;
3712
- const middleware = {
3713
- handleCall: async (method, params, handler) => {
3714
- const error = await readySignal.wait({
3715
- timeout: import_client_protocol8.PROXY_CONNECTION_TIMEOUT
3716
- });
3717
- if (error) {
3718
- throw error;
3719
- }
3720
- return handler(method, params);
3721
- },
3722
- handleStream: async (method, params, handler) => {
3723
- const error = await readySignal.wait({
3724
- timeout: import_client_protocol8.PROXY_CONNECTION_TIMEOUT
3725
- });
3726
- if (error) {
3727
- throw error;
3728
- }
3729
- return handler(method, params);
3730
- }
3731
- };
3732
- this._clientRpc = new ClientRpcServer({
3733
- serviceRegistry: this._serviceHost.serviceRegistry,
3734
- port: appPort,
3735
- ...middleware
3736
- });
3737
- this._shellClientRpc = new ClientRpcServer({
3738
- serviceRegistry: this._serviceHost.serviceRegistry,
3739
- port: shellPort,
3740
- ...middleware
3741
- });
3742
- this._iframeRpc = (0, import_rpc4.createProtoRpcPeer)({
3743
- requested: import_client_protocol8.iframeServiceBundle,
3744
- exposed: import_client_protocol8.workerServiceBundle,
3745
- handlers: {
3746
- WorkerService: {
3747
- start: async (request) => {
3748
- this.origin = request.origin;
3749
- this.lockKey = request.lockKey;
3750
- this._startTrigger.wake();
3751
- },
3752
- stop: async () => {
3753
- setTimeout(async () => {
3754
- try {
3755
- await this.close();
3756
- } catch (err) {
3757
- import_log16.log.catch(err, {}, {
3758
- file: "worker-session.ts",
3759
- line: 100,
3760
- scope: this,
3761
- callSite: (f, a) => f(...a)
3762
- });
3763
- }
3764
- });
3765
- }
3766
- }
3767
- },
3768
- port: systemPort,
3769
- timeout: 1e3
3770
- });
3771
- this.bridgeService = this._iframeRpc.rpc.BridgeService;
3772
- }
3773
- async open() {
3774
- import_log16.log.info("opening..", {}, {
3775
- file: "worker-session.ts",
3776
- line: 114,
3777
- scope: this,
3778
- callSite: (f, a) => f(...a)
3779
- });
3780
- await Promise.all([
3781
- this._clientRpc.open(),
3782
- this._iframeRpc.open(),
3783
- this._maybeOpenShell()
3784
- ]);
3785
- await this._startTrigger.wait({
3786
- timeout: import_client_protocol8.PROXY_CONNECTION_TIMEOUT
3787
- });
3788
- if (this.lockKey) {
3789
- void this._afterLockReleases(this.lockKey, () => this.close());
3790
- }
3791
- }
3792
- async close() {
3793
- import_log16.log.info("closing..", {}, {
3794
- file: "worker-session.ts",
3795
- line: 124,
3796
- scope: this,
3797
- callSite: (f, a) => f(...a)
3798
- });
3799
- try {
3800
- await this.onClose.callIfSet();
3801
- } catch (err) {
3802
- import_log16.log.catch(err, {}, {
3803
- file: "worker-session.ts",
3804
- line: 128,
3805
- scope: this,
3806
- callSite: (f, a) => f(...a)
3807
- });
3808
- }
3809
- await Promise.all([
3810
- this._clientRpc.close(),
3811
- this._iframeRpc.close()
3812
- ]);
3813
- }
3814
- async _maybeOpenShell() {
3815
- try {
3816
- await (0, import_async20.asyncTimeout)(this._shellClientRpc.open(), 1e3);
3817
- } catch (e) {
3818
- import_log16.log.info("No shell connected.", {}, {
3819
- file: "worker-session.ts",
3820
- line: 138,
3821
- scope: this,
3822
- callSite: (f, a) => f(...a)
3823
- });
3824
- }
3825
- }
3826
- _afterLockReleases(lockKey, callback) {
3827
- return navigator.locks.request(lockKey, () => {
3828
- }).then(callback);
3829
- }
3830
- };
3831
- __decorate5([
3832
- import_log16.logInfo
3833
- ], WorkerSession.prototype, "origin", void 0);
3834
- __decorate5([
3835
- import_log16.logInfo
3836
- ], WorkerSession.prototype, "lockKey", void 0);
3837
-
3838
3389
  // packages/sdk/client-services/src/packlets/services/service-context.ts
3839
- var import_node_assert13 = __toESM(require("node:assert"));
3840
- var import_async22 = require("@dxos/async");
3390
+ var import_node_assert11 = __toESM(require("node:assert"));
3391
+ var import_async17 = require("@dxos/async");
3841
3392
  var import_credentials14 = require("@dxos/credentials");
3842
- var import_debug7 = require("@dxos/debug");
3393
+ var import_debug6 = require("@dxos/debug");
3843
3394
  var import_echo_pipeline3 = require("@dxos/echo-pipeline");
3844
3395
  var import_feed_store4 = require("@dxos/feed-store");
3845
3396
  var import_keyring = require("@dxos/keyring");
3846
3397
  var import_keys11 = require("@dxos/keys");
3847
- var import_log18 = require("@dxos/log");
3398
+ var import_log14 = require("@dxos/log");
3848
3399
  var import_protocols8 = require("@dxos/protocols");
3849
- var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
3400
+ var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
3850
3401
  var ServiceContext = class {
3851
3402
  // prettier-ignore
3852
3403
  constructor(storage, networkManager, signalManager, modelFactory) {
@@ -3854,7 +3405,7 @@ var ServiceContext = class {
3854
3405
  this.networkManager = networkManager;
3855
3406
  this.signalManager = signalManager;
3856
3407
  this.modelFactory = modelFactory;
3857
- this.initialized = new import_async22.Trigger();
3408
+ this.initialized = new import_async17.Trigger();
3858
3409
  this.dataServiceSubscriptions = new import_echo_pipeline3.DataServiceSubscriptions();
3859
3410
  this._handlerFactories = /* @__PURE__ */ new Map();
3860
3411
  this._instanceId = import_keys11.PublicKey.random().toHex();
@@ -3879,13 +3430,13 @@ var ServiceContext = class {
3879
3430
  });
3880
3431
  this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
3881
3432
  this.invitations = new InvitationsHandler(this.networkManager);
3882
- this._handlerFactories.set(import_services12.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
3433
+ this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
3883
3434
  var _a;
3884
- return (_a = this.identityManager.identity) != null ? _a : (0, import_debug7.failUndefined)();
3435
+ return (_a = this.identityManager.identity) != null ? _a : (0, import_debug6.failUndefined)();
3885
3436
  }, this._acceptIdentity.bind(this)));
3886
3437
  }
3887
3438
  async open() {
3888
- import_log18.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.begin({
3439
+ import_log14.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.begin({
3889
3440
  id: this._instanceId
3890
3441
  }), {
3891
3442
  file: "service-context.ts",
@@ -3894,7 +3445,7 @@ var ServiceContext = class {
3894
3445
  callSite: (f, a) => f(...a)
3895
3446
  });
3896
3447
  await this._checkStorageVersion();
3897
- (0, import_log18.log)("opening...", {}, {
3448
+ (0, import_log14.log)("opening...", {}, {
3898
3449
  file: "service-context.ts",
3899
3450
  line: 123,
3900
3451
  scope: this,
@@ -3907,13 +3458,13 @@ var ServiceContext = class {
3907
3458
  if (this.identityManager.identity) {
3908
3459
  await this._initialize();
3909
3460
  }
3910
- (0, import_log18.log)("opened", {}, {
3461
+ (0, import_log14.log)("opened", {}, {
3911
3462
  file: "service-context.ts",
3912
3463
  line: 131,
3913
3464
  scope: this,
3914
3465
  callSite: (f, a) => f(...a)
3915
3466
  });
3916
- import_log18.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.end({
3467
+ import_log14.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.end({
3917
3468
  id: this._instanceId
3918
3469
  }), {
3919
3470
  file: "service-context.ts",
@@ -3924,7 +3475,7 @@ var ServiceContext = class {
3924
3475
  }
3925
3476
  async close() {
3926
3477
  var _a, _b;
3927
- (0, import_log18.log)("closing...", {}, {
3478
+ (0, import_log14.log)("closing...", {}, {
3928
3479
  file: "service-context.ts",
3929
3480
  line: 136,
3930
3481
  scope: this,
@@ -3938,7 +3489,7 @@ var ServiceContext = class {
3938
3489
  await this.networkManager.close();
3939
3490
  await this.signalManager.close();
3940
3491
  this.dataServiceSubscriptions.clear();
3941
- (0, import_log18.log)("closed", {}, {
3492
+ (0, import_log14.log)("closed", {}, {
3942
3493
  file: "service-context.ts",
3943
3494
  line: 145,
3944
3495
  scope: this,
@@ -3952,7 +3503,7 @@ var ServiceContext = class {
3952
3503
  }
3953
3504
  getInvitationHandler(invitation) {
3954
3505
  const factory = this._handlerFactories.get(invitation.kind);
3955
- (0, import_node_assert13.default)(factory, `Unknown invitation kind: ${invitation.kind}`);
3506
+ (0, import_node_assert11.default)(factory, `Unknown invitation kind: ${invitation.kind}`);
3956
3507
  return factory(invitation);
3957
3508
  }
3958
3509
  async _acceptIdentity(params) {
@@ -3963,28 +3514,19 @@ var ServiceContext = class {
3963
3514
  async _checkStorageVersion() {
3964
3515
  await this.metadataStore.load();
3965
3516
  if (this.metadataStore.version !== import_protocols8.STORAGE_VERSION) {
3966
- import_log18.log.error("Invalid storage version", {
3967
- current: this.metadataStore.version,
3968
- expected: import_protocols8.STORAGE_VERSION
3969
- }, {
3970
- file: "service-context.ts",
3971
- line: 171,
3972
- scope: this,
3973
- callSite: (f, a) => f(...a)
3974
- });
3975
- await this.metadataStore.clear();
3517
+ throw new Error(`Invalid storage version: current=${this.metadataStore.version}, expected=${import_protocols8.STORAGE_VERSION}`);
3976
3518
  }
3977
3519
  }
3978
3520
  // Called when identity is created.
3979
3521
  async _initialize() {
3980
3522
  var _a;
3981
- (0, import_log18.log)("initializing spaces...", {}, {
3523
+ (0, import_log14.log)("initializing spaces...", {}, {
3982
3524
  file: "service-context.ts",
3983
- line: 179,
3525
+ line: 178,
3984
3526
  scope: this,
3985
3527
  callSite: (f, a) => f(...a)
3986
3528
  });
3987
- const identity = (_a = this.identityManager.identity) != null ? _a : (0, import_debug7.failUndefined)();
3529
+ const identity = (_a = this.identityManager.identity) != null ? _a : (0, import_debug6.failUndefined)();
3988
3530
  const signingContext = {
3989
3531
  credentialSigner: identity.getIdentityCredentialSigner(),
3990
3532
  identityKey: identity.identityKey,
@@ -4000,8 +3542,8 @@ var ServiceContext = class {
4000
3542
  };
4001
3543
  this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
4002
3544
  await this.dataSpaceManager.open();
4003
- this._handlerFactories.set(import_services12.Invitation.Kind.SPACE, (invitation) => {
4004
- (0, import_node_assert13.default)(this.dataSpaceManager, "dataSpaceManager not initialized yet");
3545
+ this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
3546
+ (0, import_node_assert11.default)(this.dataSpaceManager, "dataSpaceManager not initialized yet");
4005
3547
  return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
4006
3548
  });
4007
3549
  this.initialized.wake();
@@ -4015,33 +3557,33 @@ var ServiceContext = class {
4015
3557
  return;
4016
3558
  }
4017
3559
  if (!this.dataSpaceManager) {
4018
- (0, import_log18.log)("dataSpaceManager not initialized yet, ignoring space admission", {
3560
+ (0, import_log14.log)("dataSpaceManager not initialized yet, ignoring space admission", {
4019
3561
  details: assertion
4020
3562
  }, {
4021
3563
  file: "service-context.ts",
4022
- line: 218,
3564
+ line: 217,
4023
3565
  scope: this,
4024
3566
  callSite: (f, a) => f(...a)
4025
3567
  });
4026
3568
  return;
4027
3569
  }
4028
3570
  if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
4029
- (0, import_log18.log)("space already exists, ignoring space admission", {
3571
+ (0, import_log14.log)("space already exists, ignoring space admission", {
4030
3572
  details: assertion
4031
3573
  }, {
4032
3574
  file: "service-context.ts",
4033
- line: 222,
3575
+ line: 221,
4034
3576
  scope: this,
4035
3577
  callSite: (f, a) => f(...a)
4036
3578
  });
4037
3579
  return;
4038
3580
  }
4039
3581
  try {
4040
- (0, import_log18.log)("accepting space recorded in halo", {
3582
+ (0, import_log14.log)("accepting space recorded in halo", {
4041
3583
  details: assertion
4042
3584
  }, {
4043
3585
  file: "service-context.ts",
4044
- line: 227,
3586
+ line: 226,
4045
3587
  scope: this,
4046
3588
  callSite: (f, a) => f(...a)
4047
3589
  });
@@ -4050,9 +3592,9 @@ var ServiceContext = class {
4050
3592
  genesisFeedKey: assertion.genesisFeedKey
4051
3593
  });
4052
3594
  } catch (err) {
4053
- import_log18.log.catch(err, {}, {
3595
+ import_log14.log.catch(err, {}, {
4054
3596
  file: "service-context.ts",
4055
- line: 233,
3597
+ line: 232,
4056
3598
  scope: this,
4057
3599
  callSite: (f, a) => f(...a)
4058
3600
  });
@@ -4091,7 +3633,7 @@ var ServiceRegistry = class {
4091
3633
  var ClientServicesHost = class {
4092
3634
  constructor({
4093
3635
  config,
4094
- modelFactory = (0, import_client_protocol9.createDefaultModelFactory)(),
3636
+ modelFactory = (0, import_client_protocol4.createDefaultModelFactory)(),
4095
3637
  // TODO(burdon): Create ApolloLink abstraction (see Client).
4096
3638
  transportFactory,
4097
3639
  signalManager,
@@ -4100,7 +3642,7 @@ var ClientServicesHost = class {
4100
3642
  // TODO(wittjosiah): Turn this on by default.
4101
3643
  lockKey
4102
3644
  } = {}) {
4103
- this._statusUpdate = new import_async23.Event();
3645
+ this._statusUpdate = new import_async18.Event();
4104
3646
  this._opening = false;
4105
3647
  this._open = false;
4106
3648
  this._storage = storage;
@@ -4112,24 +3654,26 @@ var ClientServicesHost = class {
4112
3654
  signalManager
4113
3655
  });
4114
3656
  }
4115
- this._resourceLock = lockKey ? new VaultResourceLock({
4116
- lockKey,
4117
- onAcquire: () => {
4118
- if (!this._opening) {
4119
- void this.open();
4120
- }
4121
- },
4122
- onRelease: () => this.close()
4123
- }) : void 0;
3657
+ if (lockKey) {
3658
+ this._resourceLock = new Lock({
3659
+ lockKey,
3660
+ onAcquire: () => {
3661
+ if (!this._opening) {
3662
+ void this.open();
3663
+ }
3664
+ },
3665
+ onRelease: () => this.close()
3666
+ });
3667
+ }
4124
3668
  this._systemService = new SystemServiceImpl({
4125
3669
  config: this._config,
4126
3670
  statusUpdate: this._statusUpdate,
4127
- getCurrentStatus: () => this.isOpen ? import_services13.SystemStatus.ACTIVE : import_services13.SystemStatus.INACTIVE,
3671
+ getCurrentStatus: () => this.isOpen ? import_services11.SystemStatus.ACTIVE : import_services11.SystemStatus.INACTIVE,
4128
3672
  onUpdateStatus: async (status) => {
4129
3673
  var _a, _b;
4130
- if (!this.isOpen && status === import_services13.SystemStatus.ACTIVE) {
3674
+ if (!this.isOpen && status === import_services11.SystemStatus.ACTIVE) {
4131
3675
  await ((_a = this._resourceLock) == null ? void 0 : _a.acquire());
4132
- } else if (this.isOpen && status === import_services13.SystemStatus.INACTIVE) {
3676
+ } else if (this.isOpen && status === import_services11.SystemStatus.INACTIVE) {
4133
3677
  await ((_b = this._resourceLock) == null ? void 0 : _b.release());
4134
3678
  }
4135
3679
  },
@@ -4138,7 +3682,7 @@ var ClientServicesHost = class {
4138
3682
  }
4139
3683
  });
4140
3684
  this._loggingService = new LoggingServiceImpl();
4141
- this._serviceRegistry = new ServiceRegistry(import_client_protocol9.clientServiceBundle, {
3685
+ this._serviceRegistry = new ServiceRegistry(import_client_protocol4.clientServiceBundle, {
4142
3686
  SystemService: this._systemService
4143
3687
  });
4144
3688
  }
@@ -4161,20 +3705,20 @@ var ClientServicesHost = class {
4161
3705
  */
4162
3706
  initialize({ config, ...options }) {
4163
3707
  var _a, _b, _c;
4164
- (0, import_node_assert14.default)(!this._open, "service host is open");
3708
+ (0, import_node_assert12.default)(!this._open, "service host is open");
4165
3709
  if (config) {
4166
- (0, import_node_assert14.default)(!this._config, "config already set");
3710
+ (0, import_node_assert12.default)(!this._config, "config already set");
4167
3711
  this._config = config;
4168
3712
  if (!this._storage) {
4169
3713
  this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
4170
3714
  }
4171
3715
  }
4172
- const { connectionLog = true, transportFactory = (0, import_network_manager5.createWebRTCTransportFactory)({
3716
+ const { connectionLog = true, transportFactory = (0, import_network_manager2.createWebRTCTransportFactory)({
4173
3717
  iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
4174
- }), signalManager = new import_messaging3.WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
3718
+ }), signalManager = new import_messaging.WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
4175
3719
  this._signalManager = signalManager;
4176
- (0, import_node_assert14.default)(!this._networkManager, "network manager already set");
4177
- this._networkManager = new import_network_manager5.NetworkManager({
3720
+ (0, import_node_assert12.default)(!this._networkManager, "network manager already set");
3721
+ this._networkManager = new import_network_manager2.NetworkManager({
4178
3722
  log: connectionLog,
4179
3723
  transportFactory,
4180
3724
  signalManager
@@ -4186,7 +3730,7 @@ var ClientServicesHost = class {
4186
3730
  return;
4187
3731
  }
4188
3732
  const traceId = import_keys12.PublicKey.random().toHex();
4189
- import_log19.log.trace("dxos.sdk.client-services-host.open", import_protocols9.trace.begin({
3733
+ import_log15.log.trace("dxos.sdk.client-services-host.open", import_protocols9.trace.begin({
4190
3734
  id: traceId
4191
3735
  }), {
4192
3736
  file: "service-host.ts",
@@ -4194,12 +3738,12 @@ var ClientServicesHost = class {
4194
3738
  scope: this,
4195
3739
  callSite: (f, a) => f(...a)
4196
3740
  });
4197
- (0, import_node_assert14.default)(this._config, "config not set");
4198
- (0, import_node_assert14.default)(this._storage, "storage not set");
4199
- (0, import_node_assert14.default)(this._signalManager, "signal manager not set");
4200
- (0, import_node_assert14.default)(this._networkManager, "network manager not set");
3741
+ (0, import_node_assert12.default)(this._config, "config not set");
3742
+ (0, import_node_assert12.default)(this._storage, "storage not set");
3743
+ (0, import_node_assert12.default)(this._signalManager, "signal manager not set");
3744
+ (0, import_node_assert12.default)(this._networkManager, "network manager not set");
4201
3745
  this._opening = true;
4202
- (0, import_log19.log)("opening...", {
3746
+ (0, import_log15.log)("opening...", {
4203
3747
  lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
4204
3748
  }, {
4205
3749
  file: "service-host.ts",
@@ -4234,7 +3778,7 @@ var ClientServicesHost = class {
4234
3778
  this._open = true;
4235
3779
  this._statusUpdate.emit();
4236
3780
  const deviceKey = (_c = this._serviceContext.identityManager.identity) == null ? void 0 : _c.deviceKey;
4237
- (0, import_log19.log)("opened", {
3781
+ (0, import_log15.log)("opened", {
4238
3782
  deviceKey
4239
3783
  }, {
4240
3784
  file: "service-host.ts",
@@ -4242,7 +3786,7 @@ var ClientServicesHost = class {
4242
3786
  scope: this,
4243
3787
  callSite: (f, a) => f(...a)
4244
3788
  });
4245
- import_log19.log.trace("dxos.sdk.client-services-host.open", import_protocols9.trace.end({
3789
+ import_log15.log.trace("dxos.sdk.client-services-host.open", import_protocols9.trace.end({
4246
3790
  id: traceId
4247
3791
  }), {
4248
3792
  file: "service-host.ts",
@@ -4257,7 +3801,7 @@ var ClientServicesHost = class {
4257
3801
  return;
4258
3802
  }
4259
3803
  const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
4260
- (0, import_log19.log)("closing...", {
3804
+ (0, import_log15.log)("closing...", {
4261
3805
  deviceKey
4262
3806
  }, {
4263
3807
  file: "service-host.ts",
@@ -4272,7 +3816,7 @@ var ClientServicesHost = class {
4272
3816
  await this._serviceContext.close();
4273
3817
  this._open = false;
4274
3818
  this._statusUpdate.emit();
4275
- (0, import_log19.log)("closed", {
3819
+ (0, import_log15.log)("closed", {
4276
3820
  deviceKey
4277
3821
  }, {
4278
3822
  file: "service-host.ts",
@@ -4284,7 +3828,7 @@ var ClientServicesHost = class {
4284
3828
  async reset() {
4285
3829
  var _a;
4286
3830
  const traceId = import_keys12.PublicKey.random().toHex();
4287
- import_log19.log.trace("dxos.sdk.client-services-host.reset", import_protocols9.trace.begin({
3831
+ import_log15.log.trace("dxos.sdk.client-services-host.reset", import_protocols9.trace.begin({
4288
3832
  id: traceId
4289
3833
  }), {
4290
3834
  file: "service-host.ts",
@@ -4292,7 +3836,7 @@ var ClientServicesHost = class {
4292
3836
  scope: this,
4293
3837
  callSite: (f, a) => f(...a)
4294
3838
  });
4295
- (0, import_log19.log)("resetting...", {}, {
3839
+ (0, import_log15.log)("resetting...", {}, {
4296
3840
  file: "service-host.ts",
4297
3841
  line: 273,
4298
3842
  scope: this,
@@ -4300,13 +3844,13 @@ var ClientServicesHost = class {
4300
3844
  });
4301
3845
  await ((_a = this._serviceContext) == null ? void 0 : _a.close());
4302
3846
  await this._storage.reset();
4303
- (0, import_log19.log)("reset", {}, {
3847
+ (0, import_log15.log)("reset", {}, {
4304
3848
  file: "service-host.ts",
4305
3849
  line: 276,
4306
3850
  scope: this,
4307
3851
  callSite: (f, a) => f(...a)
4308
3852
  });
4309
- import_log19.log.trace("dxos.sdk.client-services-host.reset", import_protocols9.trace.end({
3853
+ import_log15.log.trace("dxos.sdk.client-services-host.reset", import_protocols9.trace.end({
4310
3854
  id: traceId
4311
3855
  }), {
4312
3856
  file: "service-host.ts",
@@ -4317,28 +3861,6 @@ var ClientServicesHost = class {
4317
3861
  }
4318
3862
  };
4319
3863
 
4320
- // packages/sdk/client-services/src/packlets/services/local-client-services.ts
4321
- var LocalClientServices = class {
4322
- constructor(params) {
4323
- this._host = new ClientServicesHost(params);
4324
- }
4325
- get descriptors() {
4326
- return this._host.descriptors;
4327
- }
4328
- get services() {
4329
- return this._host.services;
4330
- }
4331
- get host() {
4332
- return this._host;
4333
- }
4334
- async open() {
4335
- await this._host.open();
4336
- }
4337
- async close() {
4338
- await this._host.close();
4339
- }
4340
- };
4341
-
4342
3864
  // packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
4343
3865
  var sanitizeInvitation = (invitation) => {
4344
3866
  return {
@@ -4352,14 +3874,14 @@ var sanitizeInvitation = (invitation) => {
4352
3874
  };
4353
3875
  };
4354
3876
  var performInvitation = ({ host, guest, options, hooks }) => {
4355
- const hostComplete = new import_async24.Trigger();
4356
- const guestComplete = new import_async24.Trigger();
4357
- const authCode = new import_async24.Trigger();
3877
+ const hostComplete = new import_async19.Trigger();
3878
+ const guestComplete = new import_async19.Trigger();
3879
+ const authCode = new import_async19.Trigger();
4358
3880
  const hostObservable = createInvitation(host, options);
4359
3881
  hostObservable.subscribe(async (hostInvitation) => {
4360
3882
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
4361
3883
  switch (hostInvitation.state) {
4362
- case import_services14.Invitation.State.CONNECTING: {
3884
+ case import_services12.Invitation.State.CONNECTING: {
4363
3885
  if ((_b = (_a = hooks == null ? void 0 : hooks.host) == null ? void 0 : _a.onConnecting) == null ? void 0 : _b.call(_a, hostObservable)) {
4364
3886
  break;
4365
3887
  }
@@ -4367,29 +3889,29 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4367
3889
  guestObservable.subscribe(async (guestInvitation) => {
4368
3890
  var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2;
4369
3891
  switch (guestInvitation.state) {
4370
- case import_services14.Invitation.State.CONNECTING: {
3892
+ case import_services12.Invitation.State.CONNECTING: {
4371
3893
  if ((_b2 = (_a2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _a2.onConnecting) == null ? void 0 : _b2.call(_a2, guestObservable)) {
4372
3894
  break;
4373
3895
  }
4374
- (0, import_node_assert15.default)(hostInvitation.swarmKey.equals(guestInvitation.swarmKey));
3896
+ (0, import_node_assert13.default)(hostInvitation.swarmKey.equals(guestInvitation.swarmKey));
4375
3897
  break;
4376
3898
  }
4377
- case import_services14.Invitation.State.CONNECTED: {
3899
+ case import_services12.Invitation.State.CONNECTED: {
4378
3900
  (_d2 = (_c2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _c2.onConnected) == null ? void 0 : _d2.call(_c2, guestObservable);
4379
3901
  break;
4380
3902
  }
4381
- case import_services14.Invitation.State.READY_FOR_AUTHENTICATION: {
3903
+ case import_services12.Invitation.State.READY_FOR_AUTHENTICATION: {
4382
3904
  if ((_f2 = (_e2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _e2.onReady) == null ? void 0 : _f2.call(_e2, guestObservable)) {
4383
3905
  break;
4384
3906
  }
4385
3907
  await guestObservable.authenticate(await authCode.wait());
4386
3908
  break;
4387
3909
  }
4388
- case import_services14.Invitation.State.AUTHENTICATING: {
3910
+ case import_services12.Invitation.State.AUTHENTICATING: {
4389
3911
  (_h2 = (_g2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _g2.onAuthenticating) == null ? void 0 : _h2.call(_g2, guestObservable);
4390
3912
  break;
4391
3913
  }
4392
- case import_services14.Invitation.State.SUCCESS: {
3914
+ case import_services12.Invitation.State.SUCCESS: {
4393
3915
  if ((_j2 = (_i2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _i2.onSuccess) == null ? void 0 : _j2.call(_i2, guestObservable)) {
4394
3916
  break;
4395
3917
  }
@@ -4398,7 +3920,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4398
3920
  });
4399
3921
  break;
4400
3922
  }
4401
- case import_services14.Invitation.State.CANCELLED: {
3923
+ case import_services12.Invitation.State.CANCELLED: {
4402
3924
  if ((_l2 = (_k2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _k2.onCancelled) == null ? void 0 : _l2.call(_k2, guestObservable)) {
4403
3925
  break;
4404
3926
  }
@@ -4407,7 +3929,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4407
3929
  });
4408
3930
  break;
4409
3931
  }
4410
- case import_services14.Invitation.State.TIMEOUT: {
3932
+ case import_services12.Invitation.State.TIMEOUT: {
4411
3933
  if ((_n2 = (_m2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _m2.onTimeout) == null ? void 0 : _n2.call(_m2, guestObservable)) {
4412
3934
  return;
4413
3935
  }
@@ -4427,11 +3949,11 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4427
3949
  });
4428
3950
  break;
4429
3951
  }
4430
- case import_services14.Invitation.State.CONNECTED: {
3952
+ case import_services12.Invitation.State.CONNECTED: {
4431
3953
  (_d = (_c = hooks == null ? void 0 : hooks.host) == null ? void 0 : _c.onConnected) == null ? void 0 : _d.call(_c, hostObservable);
4432
3954
  break;
4433
3955
  }
4434
- case import_services14.Invitation.State.READY_FOR_AUTHENTICATION: {
3956
+ case import_services12.Invitation.State.READY_FOR_AUTHENTICATION: {
4435
3957
  if ((_f = (_e = hooks == null ? void 0 : hooks.host) == null ? void 0 : _e.onReady) == null ? void 0 : _f.call(_e, hostObservable)) {
4436
3958
  break;
4437
3959
  }
@@ -4440,11 +3962,11 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4440
3962
  }
4441
3963
  break;
4442
3964
  }
4443
- case import_services14.Invitation.State.AUTHENTICATING: {
3965
+ case import_services12.Invitation.State.AUTHENTICATING: {
4444
3966
  (_h = (_g = hooks == null ? void 0 : hooks.host) == null ? void 0 : _g.onAuthenticating) == null ? void 0 : _h.call(_g, hostObservable);
4445
3967
  break;
4446
3968
  }
4447
- case import_services14.Invitation.State.SUCCESS: {
3969
+ case import_services12.Invitation.State.SUCCESS: {
4448
3970
  if ((_j = (_i = hooks == null ? void 0 : hooks.host) == null ? void 0 : _i.onSuccess) == null ? void 0 : _j.call(_i, hostObservable)) {
4449
3971
  break;
4450
3972
  }
@@ -4453,7 +3975,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4453
3975
  });
4454
3976
  break;
4455
3977
  }
4456
- case import_services14.Invitation.State.CANCELLED: {
3978
+ case import_services12.Invitation.State.CANCELLED: {
4457
3979
  if ((_l = (_k = hooks == null ? void 0 : hooks.host) == null ? void 0 : _k.onCancelled) == null ? void 0 : _l.call(_k, hostObservable)) {
4458
3980
  break;
4459
3981
  }
@@ -4462,7 +3984,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4462
3984
  });
4463
3985
  break;
4464
3986
  }
4465
- case import_services14.Invitation.State.TIMEOUT: {
3987
+ case import_services12.Invitation.State.TIMEOUT: {
4466
3988
  if ((_n = (_m = hooks == null ? void 0 : hooks.host) == null ? void 0 : _m.onTimeout) == null ? void 0 : _n.call(_m, hostObservable)) {
4467
3989
  break;
4468
3990
  }
@@ -4488,12 +4010,12 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4488
4010
  };
4489
4011
  var createInvitation = (host, options) => {
4490
4012
  options != null ? options : options = {
4491
- authMethod: import_services14.Invitation.AuthMethod.NONE,
4013
+ authMethod: import_services12.Invitation.AuthMethod.NONE,
4492
4014
  ...options != null ? options : {}
4493
4015
  };
4494
4016
  if (host instanceof ServiceContext) {
4495
4017
  const hostHandler = host.getInvitationHandler({
4496
- kind: import_services14.Invitation.Kind.SPACE,
4018
+ kind: import_services12.Invitation.Kind.SPACE,
4497
4019
  ...options
4498
4020
  });
4499
4021
  return host.invitations.createInvitation(hostHandler, options);
@@ -4512,36 +4034,36 @@ var acceptInvitation = (guest, invitation) => {
4512
4034
  };
4513
4035
 
4514
4036
  // packages/sdk/client-services/src/packlets/testing/test-builder.ts
4515
- var import_client_protocol10 = require("@dxos/client-protocol");
4037
+ var import_client_protocol5 = require("@dxos/client-protocol");
4516
4038
  var import_context8 = require("@dxos/context");
4517
4039
  var import_credentials15 = require("@dxos/credentials");
4518
4040
  var import_echo_pipeline5 = require("@dxos/echo-pipeline");
4519
4041
  var import_testing = require("@dxos/echo-pipeline/testing");
4520
4042
  var import_feed_store5 = require("@dxos/feed-store");
4521
4043
  var import_keyring2 = require("@dxos/keyring");
4522
- var import_messaging4 = require("@dxos/messaging");
4523
- var import_network_manager6 = require("@dxos/network-manager");
4044
+ var import_messaging2 = require("@dxos/messaging");
4045
+ var import_network_manager3 = require("@dxos/network-manager");
4524
4046
  var import_random_access_storage2 = require("@dxos/random-access-storage");
4525
4047
  var createServiceHost = (config, signalManagerContext) => {
4526
4048
  return new ClientServicesHost({
4527
4049
  config,
4528
- signalManager: new import_messaging4.MemorySignalManager(signalManagerContext),
4529
- transportFactory: import_network_manager6.MemoryTransportFactory
4050
+ signalManager: new import_messaging2.MemorySignalManager(signalManagerContext),
4051
+ transportFactory: import_network_manager3.MemoryTransportFactory
4530
4052
  });
4531
4053
  };
4532
- var createServiceContext = ({ signalContext = new import_messaging4.MemorySignalManagerContext(), storage = (0, import_random_access_storage2.createStorage)({
4054
+ var createServiceContext = ({ signalContext = new import_messaging2.MemorySignalManagerContext(), storage = (0, import_random_access_storage2.createStorage)({
4533
4055
  type: import_random_access_storage2.StorageType.RAM
4534
4056
  }) } = {}) => {
4535
- const signalManager = new import_messaging4.MemorySignalManager(signalContext);
4536
- const networkManager = new import_network_manager6.NetworkManager({
4057
+ const signalManager = new import_messaging2.MemorySignalManager(signalContext);
4058
+ const networkManager = new import_network_manager3.NetworkManager({
4537
4059
  signalManager,
4538
- transportFactory: import_network_manager6.MemoryTransportFactory
4060
+ transportFactory: import_network_manager3.MemoryTransportFactory
4539
4061
  });
4540
- const modelFactory = (0, import_client_protocol10.createDefaultModelFactory)();
4062
+ const modelFactory = (0, import_client_protocol5.createDefaultModelFactory)();
4541
4063
  return new ServiceContext(storage, networkManager, signalManager, modelFactory);
4542
4064
  };
4543
4065
  var createPeers = async (numPeers) => {
4544
- const signalContext = new import_messaging4.MemorySignalManagerContext();
4066
+ const signalContext = new import_messaging2.MemorySignalManagerContext();
4545
4067
  return await Promise.all(Array.from(Array(numPeers)).map(async () => {
4546
4068
  const peer = createServiceContext({
4547
4069
  signalContext
@@ -4560,7 +4082,7 @@ var syncItemsLocal = async (db1, db2) => {
4560
4082
  };
4561
4083
  var TestBuilder = class {
4562
4084
  constructor() {
4563
- this.signalContext = new import_messaging4.MemorySignalManagerContext();
4085
+ this.signalContext = new import_messaging2.MemorySignalManagerContext();
4564
4086
  this._ctx = new import_context8.Context();
4565
4087
  }
4566
4088
  createPeer(peerOptions) {
@@ -4612,9 +4134,9 @@ var TestPeer = class {
4612
4134
  }
4613
4135
  get networkManager() {
4614
4136
  var _a, _b;
4615
- return (_b = (_a = this._props).networkManager) != null ? _b : _a.networkManager = new import_network_manager6.NetworkManager({
4616
- signalManager: new import_messaging4.MemorySignalManager(this.signalContext),
4617
- transportFactory: import_network_manager6.MemoryTransportFactory
4137
+ return (_b = (_a = this._props).networkManager) != null ? _b : _a.networkManager = new import_network_manager3.NetworkManager({
4138
+ signalManager: new import_messaging2.MemorySignalManager(this.signalContext),
4139
+ transportFactory: import_network_manager3.MemoryTransportFactory
4618
4140
  });
4619
4141
  }
4620
4142
  get spaceManager() {
@@ -4623,7 +4145,7 @@ var TestPeer = class {
4623
4145
  feedStore: this.feedStore,
4624
4146
  networkManager: this.networkManager,
4625
4147
  metadataStore: this.metadataStore,
4626
- modelFactory: (0, import_client_protocol10.createDefaultModelFactory)(),
4148
+ modelFactory: (0, import_client_protocol5.createDefaultModelFactory)(),
4627
4149
  snapshotStore: this.snapshotStore
4628
4150
  });
4629
4151
  }