@dxos/client-services 0.1.41-next.d517c89 → 0.1.41

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 (39) hide show
  1. package/dist/lib/browser/{chunk-LGMYP2WL.mjs → chunk-T73F4MV4.mjs} +232 -213
  2. package/dist/lib/browser/chunk-T73F4MV4.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +1 -1
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/browser/packlets/testing/index.mjs +1 -1
  6. package/dist/lib/node/index.cjs +271 -252
  7. package/dist/lib/node/index.cjs.map +4 -4
  8. package/dist/lib/node/meta.json +1 -1
  9. package/dist/lib/node/packlets/testing/index.cjs +259 -217
  10. package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
  11. package/dist/types/src/packlets/logging/index.d.ts +2 -0
  12. package/dist/types/src/packlets/logging/index.d.ts.map +1 -0
  13. package/dist/types/src/packlets/logging/logging-service.d.ts +13 -0
  14. package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -0
  15. package/dist/types/src/packlets/logging/logging.test.d.ts +2 -0
  16. package/dist/types/src/packlets/logging/logging.test.d.ts.map +1 -0
  17. package/dist/types/src/packlets/services/service-host.d.ts +1 -0
  18. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  19. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  20. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +6 -5
  21. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
  22. package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts +9 -8
  23. package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts.map +1 -1
  24. package/package.json +30 -30
  25. package/src/packlets/logging/index.ts +5 -0
  26. package/src/packlets/logging/logging-service.ts +78 -0
  27. package/src/packlets/logging/logging.test.ts +50 -0
  28. package/src/packlets/services/service-host.ts +9 -2
  29. package/src/packlets/spaces/data-space-manager.ts +7 -3
  30. package/src/packlets/tests/shared-worker.test.ts +9 -10
  31. package/src/packlets/vault/iframe-host-runtime.ts +13 -16
  32. package/src/packlets/vault/iframe-proxy-runtime.ts +28 -34
  33. package/dist/lib/browser/chunk-LGMYP2WL.mjs.map +0 -7
  34. package/dist/types/src/packlets/deprecated/index.d.ts +0 -2
  35. package/dist/types/src/packlets/deprecated/index.d.ts.map +0 -1
  36. package/dist/types/src/packlets/deprecated/tracing.d.ts +0 -12
  37. package/dist/types/src/packlets/deprecated/tracing.d.ts.map +0 -1
  38. package/src/packlets/deprecated/index.ts +0 -5
  39. package/src/packlets/deprecated/tracing.ts +0 -21
@@ -2060,26 +2060,13 @@ var SpaceInvitationProtocol = class {
2060
2060
 
2061
2061
  // packages/sdk/client-services/src/packlets/services/service-host.ts
2062
2062
  var import_node_assert14 = __toESM(require("node:assert"));
2063
- var import_async20 = require("@dxos/async");
2063
+ var import_async21 = require("@dxos/async");
2064
2064
  var import_client8 = require("@dxos/client");
2065
2065
  var import_echo_pipeline5 = require("@dxos/echo-pipeline");
2066
- var import_log18 = require("@dxos/log");
2066
+ var import_log19 = require("@dxos/log");
2067
2067
  var import_protocols8 = require("@dxos/protocols");
2068
2068
  var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
2069
2069
 
2070
- // packages/sdk/client-services/src/packlets/deprecated/tracing.ts
2071
- var TracingServiceImpl = class {
2072
- constructor(_config) {
2073
- this._config = _config;
2074
- }
2075
- async setTracingOptions() {
2076
- throw new Error("Tracing not available.");
2077
- }
2078
- subscribeToRpcTrace() {
2079
- throw new Error("Tracing not available.");
2080
- }
2081
- };
2082
-
2083
2070
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
2084
2071
  var import_async9 = require("@dxos/async");
2085
2072
  var import_codec_protobuf8 = require("@dxos/codec-protobuf");
@@ -2127,14 +2114,73 @@ var DevicesServiceImpl = class {
2127
2114
  }
2128
2115
  };
2129
2116
 
2130
- // packages/sdk/client-services/src/packlets/network/network-service.ts
2117
+ // packages/sdk/client-services/src/packlets/logging/logging-service.ts
2118
+ var import_async10 = require("@dxos/async");
2131
2119
  var import_codec_protobuf9 = require("@dxos/codec-protobuf");
2120
+ var import_log8 = require("@dxos/log");
2121
+ var LoggingServiceImpl = class {
2122
+ constructor() {
2123
+ this._logs = new import_async10.Event();
2124
+ this._logProcessor = (_config, entry2) => {
2125
+ this._logs.emit(entry2);
2126
+ };
2127
+ }
2128
+ async open() {
2129
+ import_log8.log.runtimeConfig.processors.push(this._logProcessor);
2130
+ }
2131
+ async close() {
2132
+ const index = import_log8.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
2133
+ import_log8.log.runtimeConfig.processors.splice(index, 1);
2134
+ }
2135
+ queryLogs(request) {
2136
+ var _a;
2137
+ const filters = ((_a = request.filters) == null ? void 0 : _a.length) ? request.filters : void 0;
2138
+ return new import_codec_protobuf9.Stream(({ ctx, next }) => {
2139
+ const handler = (entry2) => {
2140
+ var _a2;
2141
+ 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"))) {
2142
+ return;
2143
+ }
2144
+ if ((0, import_log8.shouldLog)(entry2, filters)) {
2145
+ next(jsonify(entry2));
2146
+ }
2147
+ };
2148
+ ctx.onDispose(() => {
2149
+ this._logs.off(handler);
2150
+ });
2151
+ this._logs.on(handler);
2152
+ });
2153
+ }
2154
+ };
2155
+ var jsonify = (value) => {
2156
+ if (typeof value === "function") {
2157
+ return null;
2158
+ } else if (typeof value === "object" && value !== null) {
2159
+ if (Array.isArray(value)) {
2160
+ return value.map(jsonify);
2161
+ } else {
2162
+ if (typeof value.toJSON === "function") {
2163
+ return value.toJSON();
2164
+ }
2165
+ const res = {};
2166
+ for (const key of Object.keys(value)) {
2167
+ res[key] = jsonify(value[key]);
2168
+ }
2169
+ return res;
2170
+ }
2171
+ } else {
2172
+ return value;
2173
+ }
2174
+ };
2175
+
2176
+ // packages/sdk/client-services/src/packlets/network/network-service.ts
2177
+ var import_codec_protobuf10 = require("@dxos/codec-protobuf");
2132
2178
  var NetworkServiceImpl = class {
2133
2179
  constructor(networkManager) {
2134
2180
  this.networkManager = networkManager;
2135
2181
  }
2136
2182
  subscribeToNetworkStatus() {
2137
- return new import_codec_protobuf9.Stream(({ next }) => {
2183
+ return new import_codec_protobuf10.Stream(({ next }) => {
2138
2184
  const unsubscribe = this.networkManager.connectionStateChanged.on((state) => next({
2139
2185
  state
2140
2186
  }));
@@ -2151,35 +2197,35 @@ var NetworkServiceImpl = class {
2151
2197
 
2152
2198
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
2153
2199
  var import_node_assert10 = __toESM(require("node:assert"));
2154
- var import_async12 = require("@dxos/async");
2200
+ var import_async13 = require("@dxos/async");
2155
2201
  var import_client3 = require("@dxos/client");
2156
2202
  var import_context7 = require("@dxos/context");
2157
2203
  var import_credentials10 = require("@dxos/credentials");
2158
2204
  var import_echo_pipeline2 = require("@dxos/echo-pipeline");
2159
2205
  var import_keys9 = require("@dxos/keys");
2160
- var import_log10 = require("@dxos/log");
2206
+ var import_log11 = require("@dxos/log");
2161
2207
  var import_protocols6 = require("@dxos/protocols");
2162
2208
  var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
2163
2209
  var import_util5 = require("@dxos/util");
2164
2210
 
2165
2211
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
2166
- var import_async11 = require("@dxos/async");
2212
+ var import_async12 = require("@dxos/async");
2167
2213
  var import_client2 = require("@dxos/client");
2168
2214
  var import_context6 = require("@dxos/context");
2169
2215
  var import_debug3 = require("@dxos/debug");
2170
2216
  var import_echo_pipeline = require("@dxos/echo-pipeline");
2171
2217
  var import_errors3 = require("@dxos/errors");
2172
2218
  var import_keys8 = require("@dxos/keys");
2173
- var import_log9 = require("@dxos/log");
2219
+ var import_log10 = require("@dxos/log");
2174
2220
  var import_credentials9 = require("@dxos/protocols/proto/dxos/halo/credentials");
2175
2221
  var import_util4 = require("@dxos/util");
2176
2222
 
2177
2223
  // packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
2178
2224
  var import_node_assert9 = __toESM(require("node:assert"));
2179
- var import_async10 = require("@dxos/async");
2225
+ var import_async11 = require("@dxos/async");
2180
2226
  var import_context5 = require("@dxos/context");
2181
2227
  var import_keys7 = require("@dxos/keys");
2182
- var import_log8 = require("@dxos/log");
2228
+ var import_log9 = require("@dxos/log");
2183
2229
  var import_protocols5 = require("@dxos/protocols");
2184
2230
  var import_teleport2 = require("@dxos/teleport");
2185
2231
  var import_util3 = require("@dxos/util");
@@ -2189,7 +2235,7 @@ var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
2189
2235
  var NotarizationPlugin = class {
2190
2236
  constructor() {
2191
2237
  this._ctx = new import_context5.Context();
2192
- this._extensionOpened = new import_async10.Event();
2238
+ this._extensionOpened = new import_async11.Event();
2193
2239
  this._extensions = /* @__PURE__ */ new Set();
2194
2240
  this._processedCredentials = new import_util3.ComplexSet(import_keys7.PublicKey.hash);
2195
2241
  this._processCredentialsTriggers = new import_util3.ComplexMap(import_keys7.PublicKey.hash);
@@ -2203,7 +2249,7 @@ var NotarizationPlugin = class {
2203
2249
  * Request credentials to be notarized.
2204
2250
  */
2205
2251
  async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
2206
- (0, import_log8.log)("notarize", {
2252
+ (0, import_log9.log)("notarize", {
2207
2253
  credentials
2208
2254
  }, {
2209
2255
  file: "notarization-plugin.ts",
@@ -2212,10 +2258,10 @@ var NotarizationPlugin = class {
2212
2258
  callSite: (f, a) => f(...a)
2213
2259
  });
2214
2260
  (0, import_node_assert9.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
2215
- const errors = new import_async10.Trigger();
2261
+ const errors = new import_async11.Trigger();
2216
2262
  const ctx = this._ctx.derive({
2217
2263
  onError: (err) => {
2218
- import_log8.log.warn("Notarization error", {
2264
+ import_log9.log.warn("Notarization error", {
2219
2265
  err
2220
2266
  }, {
2221
2267
  file: "notarization-plugin.ts",
@@ -2229,8 +2275,8 @@ var NotarizationPlugin = class {
2229
2275
  });
2230
2276
  opCtx == null ? void 0 : opCtx.onDispose(() => ctx.dispose());
2231
2277
  if (timeout !== 0) {
2232
- (0, import_async10.scheduleTask)(ctx, () => {
2233
- import_log8.log.warn("Notarization timeout", {
2278
+ (0, import_async11.scheduleTask)(ctx, () => {
2279
+ import_log9.log.warn("Notarization timeout", {
2234
2280
  timeout,
2235
2281
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
2236
2282
  }, {
@@ -2240,12 +2286,12 @@ var NotarizationPlugin = class {
2240
2286
  callSite: (f, a) => f(...a)
2241
2287
  });
2242
2288
  void ctx.dispose();
2243
- errors.throw(new import_async10.TimeoutError(timeout, "Notarization timed out"));
2289
+ errors.throw(new import_async11.TimeoutError(timeout, "Notarization timed out"));
2244
2290
  }, timeout);
2245
2291
  }
2246
2292
  const allNotarized = Promise.all(credentials.map((credential) => this._waitUntilProcessed(credential.id)));
2247
2293
  const peersTried = /* @__PURE__ */ new Set();
2248
- const notarizeTask = new import_async10.DeferredTask(ctx, async () => {
2294
+ const notarizeTask = new import_async11.DeferredTask(ctx, async () => {
2249
2295
  try {
2250
2296
  if (this._extensions.size === 0) {
2251
2297
  return;
@@ -2254,7 +2300,7 @@ var NotarizationPlugin = class {
2254
2300
  ...this._extensions
2255
2301
  ].find((peer2) => !peersTried.has(peer2));
2256
2302
  if (!peer) {
2257
- import_log8.log.warn("Exhausted all peers to notarize with", {
2303
+ import_log9.log.warn("Exhausted all peers to notarize with", {
2258
2304
  retryIn: retryTimeout
2259
2305
  }, {
2260
2306
  file: "notarization-plugin.ts",
@@ -2263,11 +2309,11 @@ var NotarizationPlugin = class {
2263
2309
  callSite: (f, a) => f(...a)
2264
2310
  });
2265
2311
  peersTried.clear();
2266
- (0, import_async10.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
2312
+ (0, import_async11.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
2267
2313
  return;
2268
2314
  }
2269
2315
  peersTried.add(peer);
2270
- (0, import_log8.log)("try notarizing", {
2316
+ (0, import_log9.log)("try notarizing", {
2271
2317
  peer: peer.localPeerId,
2272
2318
  credentialId: credentials.map((credential) => credential.id)
2273
2319
  }, {
@@ -2279,15 +2325,15 @@ var NotarizationPlugin = class {
2279
2325
  await peer.rpc.NotarizationService.notarize({
2280
2326
  credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
2281
2327
  });
2282
- (0, import_log8.log)("success", {}, {
2328
+ (0, import_log9.log)("success", {}, {
2283
2329
  file: "notarization-plugin.ts",
2284
2330
  line: 142,
2285
2331
  scope: this,
2286
2332
  callSite: (f, a) => f(...a)
2287
2333
  });
2288
- await (0, import_async10.sleep)(successDelay);
2334
+ await (0, import_async11.sleep)(successDelay);
2289
2335
  } catch (err) {
2290
- import_log8.log.warn("error notarizing (recoverable)", err, {
2336
+ import_log9.log.warn("error notarizing (recoverable)", err, {
2291
2337
  file: "notarization-plugin.ts",
2292
2338
  line: 145,
2293
2339
  scope: this,
@@ -2304,7 +2350,7 @@ var NotarizationPlugin = class {
2304
2350
  allNotarized,
2305
2351
  errors.wait()
2306
2352
  ]);
2307
- (0, import_log8.log)("done", {}, {
2353
+ (0, import_log9.log)("done", {}, {
2308
2354
  file: "notarization-plugin.ts",
2309
2355
  line: 155,
2310
2356
  scope: this,
@@ -2334,7 +2380,7 @@ var NotarizationPlugin = class {
2334
2380
  if (this._processedCredentials.has(id)) {
2335
2381
  return;
2336
2382
  }
2337
- await (0, import_util3.entry)(this._processCredentialsTriggers, id).orInsert(new import_async10.Trigger()).value.wait();
2383
+ await (0, import_util3.entry)(this._processCredentialsTriggers, id).orInsert(new import_async11.Trigger()).value.wait();
2338
2384
  }
2339
2385
  /**
2340
2386
  * Requests from other peers to notarize credentials.
@@ -2355,7 +2401,7 @@ var NotarizationPlugin = class {
2355
2401
  createExtension() {
2356
2402
  const extension = new NotarizationTeleportExtension({
2357
2403
  onOpen: async () => {
2358
- (0, import_log8.log)("extension opened", {
2404
+ (0, import_log9.log)("extension opened", {
2359
2405
  peer: extension.localPeerId
2360
2406
  }, {
2361
2407
  file: "notarization-plugin.ts",
@@ -2367,7 +2413,7 @@ var NotarizationPlugin = class {
2367
2413
  this._extensionOpened.emit();
2368
2414
  },
2369
2415
  onClose: async () => {
2370
- (0, import_log8.log)("extension closed", {
2416
+ (0, import_log9.log)("extension closed", {
2371
2417
  peer: extension.localPeerId
2372
2418
  }, {
2373
2419
  file: "notarization-plugin.ts",
@@ -2429,7 +2475,7 @@ var DataSpace = class DataSpace2 {
2429
2475
  constructor(params) {
2430
2476
  this._ctx = new import_context6.Context();
2431
2477
  this._state = import_client2.SpaceState.CLOSED;
2432
- this.stateUpdate = new import_async11.Event();
2478
+ this.stateUpdate = new import_async12.Event();
2433
2479
  var _a;
2434
2480
  this._inner = params.inner;
2435
2481
  this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
@@ -2504,12 +2550,12 @@ var DataSpace = class DataSpace2 {
2504
2550
  * Initialize the data pipeline in a separate task.
2505
2551
  */
2506
2552
  initializeDataPipelineAsync() {
2507
- (0, import_async11.scheduleTask)(this._ctx, async () => {
2553
+ (0, import_async12.scheduleTask)(this._ctx, async () => {
2508
2554
  try {
2509
2555
  await this.initializeDataPipeline();
2510
2556
  } catch (err) {
2511
2557
  if (err instanceof import_errors3.CancelledError) {
2512
- (0, import_log9.log)("Data pipeline initialization cancelled", err, {
2558
+ (0, import_log10.log)("Data pipeline initialization cancelled", err, {
2513
2559
  file: "data-space.ts",
2514
2560
  line: 178,
2515
2561
  scope: this,
@@ -2517,7 +2563,7 @@ var DataSpace = class DataSpace2 {
2517
2563
  });
2518
2564
  return;
2519
2565
  }
2520
- import_log9.log.error("Error initializing data pipeline", err, {
2566
+ import_log10.log.error("Error initializing data pipeline", err, {
2521
2567
  file: "data-space.ts",
2522
2568
  line: 182,
2523
2569
  scope: this,
@@ -2537,7 +2583,7 @@ var DataSpace = class DataSpace2 {
2537
2583
  breakOnStall: false
2538
2584
  });
2539
2585
  await this._createWritableFeeds();
2540
- (0, import_log9.log)("Writable feeds created", {}, {
2586
+ (0, import_log10.log)("Writable feeds created", {}, {
2541
2587
  file: "data-space.ts",
2542
2588
  line: 200,
2543
2589
  scope: this,
@@ -2558,7 +2604,7 @@ var DataSpace = class DataSpace2 {
2558
2604
  return pipeline;
2559
2605
  }
2560
2606
  });
2561
- (0, import_log9.log)("waiting for data pipeline to reach target timeframe", {}, {
2607
+ (0, import_log10.log)("waiting for data pipeline to reach target timeframe", {}, {
2562
2608
  file: "data-space.ts",
2563
2609
  line: 220,
2564
2610
  scope: this,
@@ -2568,7 +2614,7 @@ var DataSpace = class DataSpace2 {
2568
2614
  ctx: this._ctx,
2569
2615
  breakOnStall: false
2570
2616
  });
2571
- (0, import_log9.log)("data pipeline ready", {}, {
2617
+ (0, import_log10.log)("data pipeline ready", {}, {
2572
2618
  file: "data-space.ts",
2573
2619
  line: 227,
2574
2620
  scope: this,
@@ -2627,7 +2673,7 @@ __decorate([
2627
2673
  (0, import_debug3.timed)(1e4)
2628
2674
  ], DataSpace.prototype, "_createWritableFeeds", null);
2629
2675
  DataSpace = __decorate([
2630
- (0, import_async11.trackLeaks)("open", "close")
2676
+ (0, import_async12.trackLeaks)("open", "close")
2631
2677
  ], DataSpace);
2632
2678
 
2633
2679
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
@@ -2652,7 +2698,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2652
2698
  this._feedStore = _feedStore;
2653
2699
  this._snapshotStore = _snapshotStore;
2654
2700
  this._ctx = new import_context7.Context();
2655
- this.updated = new import_async12.Event();
2701
+ this.updated = new import_async13.Event();
2656
2702
  this._spaces = new import_util5.ComplexMap(import_keys9.PublicKey.hash);
2657
2703
  this._isOpen = false;
2658
2704
  this._instanceId = import_keys9.PublicKey.random().toHex();
@@ -2662,13 +2708,13 @@ var DataSpaceManager = class DataSpaceManager2 {
2662
2708
  return this._spaces;
2663
2709
  }
2664
2710
  async open() {
2665
- (0, import_log10.log)("open", {}, {
2711
+ (0, import_log11.log)("open", {}, {
2666
2712
  file: "data-space-manager.ts",
2667
2713
  line: 83,
2668
2714
  scope: this,
2669
2715
  callSite: (f, a) => f(...a)
2670
2716
  });
2671
- import_log10.log.trace("dxos.echo.data-space-manager", import_protocols6.trace.begin({
2717
+ import_log11.log.trace("dxos.echo.data-space-manager", import_protocols6.trace.begin({
2672
2718
  id: this._instanceId,
2673
2719
  parentId: this._traceParent
2674
2720
  }), {
@@ -2678,7 +2724,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2678
2724
  callSite: (f, a) => f(...a)
2679
2725
  });
2680
2726
  await this._metadataStore.load();
2681
- (0, import_log10.log)("metadata loaded", {
2727
+ (0, import_log11.log)("metadata loaded", {
2682
2728
  spaces: this._metadataStore.spaces.length
2683
2729
  }, {
2684
2730
  file: "data-space-manager.ts",
@@ -2687,24 +2733,36 @@ var DataSpaceManager = class DataSpaceManager2 {
2687
2733
  callSite: (f, a) => f(...a)
2688
2734
  });
2689
2735
  for (const spaceMetadata of this._metadataStore.spaces) {
2690
- (0, import_log10.log)("load space", {
2691
- spaceMetadata
2692
- }, {
2693
- file: "data-space-manager.ts",
2694
- line: 89,
2695
- scope: this,
2696
- callSite: (f, a) => f(...a)
2697
- });
2698
- const space = await this._constructSpace(spaceMetadata);
2699
- space.initializeDataPipelineAsync();
2736
+ try {
2737
+ (0, import_log11.log)("load space", {
2738
+ spaceMetadata
2739
+ }, {
2740
+ file: "data-space-manager.ts",
2741
+ line: 90,
2742
+ scope: this,
2743
+ callSite: (f, a) => f(...a)
2744
+ });
2745
+ const space = await this._constructSpace(spaceMetadata);
2746
+ space.initializeDataPipelineAsync();
2747
+ } catch (err) {
2748
+ import_log11.log.error("Error loading space", {
2749
+ spaceMetadata,
2750
+ err
2751
+ }, {
2752
+ file: "data-space-manager.ts",
2753
+ line: 94,
2754
+ scope: this,
2755
+ callSite: (f, a) => f(...a)
2756
+ });
2757
+ }
2700
2758
  }
2701
2759
  this._isOpen = true;
2702
2760
  this.updated.emit();
2703
2761
  }
2704
2762
  async close() {
2705
- (0, import_log10.log)("close", {}, {
2763
+ (0, import_log11.log)("close", {}, {
2706
2764
  file: "data-space-manager.ts",
2707
- line: 100,
2765
+ line: 104,
2708
2766
  scope: this,
2709
2767
  callSite: (f, a) => f(...a)
2710
2768
  });
@@ -2713,11 +2771,11 @@ var DataSpaceManager = class DataSpaceManager2 {
2713
2771
  for (const space of this._spaces.values()) {
2714
2772
  await space.close();
2715
2773
  }
2716
- import_log10.log.trace("dxos.echo.data-space-manager", import_protocols6.trace.end({
2774
+ import_log11.log.trace("dxos.echo.data-space-manager", import_protocols6.trace.end({
2717
2775
  id: this._instanceId
2718
2776
  }), {
2719
2777
  file: "data-space-manager.ts",
2720
- line: 106,
2778
+ line: 110,
2721
2779
  scope: this,
2722
2780
  callSite: (f, a) => f(...a)
2723
2781
  });
@@ -2736,11 +2794,11 @@ var DataSpaceManager = class DataSpaceManager2 {
2736
2794
  controlFeedKey,
2737
2795
  dataFeedKey
2738
2796
  };
2739
- (0, import_log10.log)("creating space...", {
2797
+ (0, import_log11.log)("creating space...", {
2740
2798
  spaceKey
2741
2799
  }, {
2742
2800
  file: "data-space-manager.ts",
2743
- line: 125,
2801
+ line: 129,
2744
2802
  scope: this,
2745
2803
  callSite: (f, a) => f(...a)
2746
2804
  });
@@ -2756,11 +2814,11 @@ var DataSpaceManager = class DataSpaceManager2 {
2756
2814
  }
2757
2815
  // TODO(burdon): Rename join space.
2758
2816
  async acceptSpace(opts) {
2759
- (0, import_log10.log)("accept space", {
2817
+ (0, import_log11.log)("accept space", {
2760
2818
  opts
2761
2819
  }, {
2762
2820
  file: "data-space-manager.ts",
2763
- line: 144,
2821
+ line: 148,
2764
2822
  scope: this,
2765
2823
  callSite: (f, a) => f(...a)
2766
2824
  });
@@ -2790,11 +2848,11 @@ var DataSpaceManager = class DataSpaceManager2 {
2790
2848
  }));
2791
2849
  }
2792
2850
  async _constructSpace(metadata) {
2793
- (0, import_log10.log)("construct space", {
2851
+ (0, import_log11.log)("construct space", {
2794
2852
  metadata
2795
2853
  }, {
2796
2854
  file: "data-space-manager.ts",
2797
- line: 180,
2855
+ line: 184,
2798
2856
  scope: this,
2799
2857
  callSite: (f, a) => f(...a)
2800
2858
  });
@@ -2845,23 +2903,23 @@ var DataSpaceManager = class DataSpaceManager2 {
2845
2903
  snapshotId: metadata.snapshot,
2846
2904
  callbacks: {
2847
2905
  beforeReady: async () => {
2848
- (0, import_log10.log)("before space ready", {
2906
+ (0, import_log11.log)("before space ready", {
2849
2907
  space: space.key
2850
2908
  }, {
2851
2909
  file: "data-space-manager.ts",
2852
- line: 229,
2910
+ line: 233,
2853
2911
  scope: this,
2854
2912
  callSite: (f, a) => f(...a)
2855
2913
  });
2856
2914
  this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseBackend.createDataServiceHost());
2857
2915
  },
2858
2916
  afterReady: async () => {
2859
- (0, import_log10.log)("after space ready", {
2917
+ (0, import_log11.log)("after space ready", {
2860
2918
  space: space.key,
2861
2919
  open: this._isOpen
2862
2920
  }, {
2863
2921
  file: "data-space-manager.ts",
2864
- line: 236,
2922
+ line: 240,
2865
2923
  scope: this,
2866
2924
  callSite: (f, a) => f(...a)
2867
2925
  });
@@ -2883,27 +2941,27 @@ var DataSpaceManager = class DataSpaceManager2 {
2883
2941
  }
2884
2942
  };
2885
2943
  __decorate2([
2886
- import_async12.synchronized
2944
+ import_async13.synchronized
2887
2945
  ], DataSpaceManager.prototype, "open", null);
2888
2946
  __decorate2([
2889
- import_async12.synchronized
2947
+ import_async13.synchronized
2890
2948
  ], DataSpaceManager.prototype, "close", null);
2891
2949
  __decorate2([
2892
- import_async12.synchronized
2950
+ import_async13.synchronized
2893
2951
  ], DataSpaceManager.prototype, "createSpace", null);
2894
2952
  __decorate2([
2895
- import_async12.synchronized
2953
+ import_async13.synchronized
2896
2954
  ], DataSpaceManager.prototype, "acceptSpace", null);
2897
2955
  DataSpaceManager = __decorate2([
2898
- (0, import_async12.trackLeaks)("open", "close")
2956
+ (0, import_async13.trackLeaks)("open", "close")
2899
2957
  ], DataSpaceManager);
2900
2958
 
2901
2959
  // packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
2902
- var import_async13 = require("@dxos/async");
2903
- var import_codec_protobuf10 = require("@dxos/codec-protobuf");
2960
+ var import_async14 = require("@dxos/async");
2961
+ var import_codec_protobuf11 = require("@dxos/codec-protobuf");
2904
2962
  var import_debug4 = require("@dxos/debug");
2905
2963
  var import_echo_pipeline3 = require("@dxos/echo-pipeline");
2906
- var import_log11 = require("@dxos/log");
2964
+ var import_log12 = require("@dxos/log");
2907
2965
  var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
2908
2966
  var import_util6 = require("@dxos/util");
2909
2967
  var TIMEFRAME_UPDATE_DEBOUNCE_TIME = 500;
@@ -2926,11 +2984,11 @@ var SpacesServiceImpl = class {
2926
2984
  (0, import_debug4.todo)();
2927
2985
  }
2928
2986
  querySpaces() {
2929
- return new import_codec_protobuf10.Stream(({ next, ctx }) => {
2987
+ return new import_codec_protobuf11.Stream(({ next, ctx }) => {
2930
2988
  const onUpdate = async () => {
2931
2989
  const dataSpaceManager = await this._getDataSpaceManager();
2932
2990
  const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._transformSpace(space));
2933
- (0, import_log11.log)("update", {
2991
+ (0, import_log12.log)("update", {
2934
2992
  spaces
2935
2993
  }, {
2936
2994
  file: "spaces-service.ts",
@@ -2942,9 +3000,9 @@ var SpacesServiceImpl = class {
2942
3000
  spaces
2943
3001
  });
2944
3002
  };
2945
- (0, import_async13.scheduleTask)(ctx, async () => {
3003
+ (0, import_async14.scheduleTask)(ctx, async () => {
2946
3004
  const dataSpaceManager = await this._getDataSpaceManager();
2947
- const subscriptions = new import_async13.EventSubscriptions();
3005
+ const subscriptions = new import_async14.EventSubscriptions();
2948
3006
  ctx.onDispose(() => subscriptions.clear());
2949
3007
  const subscribeSpaces = () => {
2950
3008
  subscriptions.clear();
@@ -2978,8 +3036,8 @@ var SpacesServiceImpl = class {
2978
3036
  await space.postMessage(getChannelId(channel), message);
2979
3037
  }
2980
3038
  subscribeMessages({ spaceKey, channel }) {
2981
- return new import_codec_protobuf10.Stream(({ ctx, next }) => {
2982
- (0, import_async13.scheduleTask)(ctx, async () => {
3039
+ return new import_codec_protobuf11.Stream(({ ctx, next }) => {
3040
+ (0, import_async14.scheduleTask)(ctx, async () => {
2983
3041
  var _a;
2984
3042
  const dataSpaceManager = await this._getDataSpaceManager();
2985
3043
  const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug4.raise)(new import_echo_pipeline3.SpaceNotFoundError(spaceKey));
@@ -2991,7 +3049,7 @@ var SpacesServiceImpl = class {
2991
3049
  });
2992
3050
  }
2993
3051
  queryCredentials({ spaceKey }) {
2994
- return new import_codec_protobuf10.Stream(({ ctx, next }) => {
3052
+ return new import_codec_protobuf11.Stream(({ ctx, next }) => {
2995
3053
  var _a;
2996
3054
  const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug4.raise)(new import_echo_pipeline3.SpaceNotFoundError(spaceKey));
2997
3055
  const processor = space.spaceState.registerProcessor({
@@ -3000,7 +3058,7 @@ var SpacesServiceImpl = class {
3000
3058
  }
3001
3059
  });
3002
3060
  ctx.onDispose(() => processor.close());
3003
- (0, import_async13.scheduleTask)(ctx, () => processor.open());
3061
+ (0, import_async14.scheduleTask)(ctx, () => processor.open());
3004
3062
  });
3005
3063
  }
3006
3064
  async writeCredentials({ spaceKey, credentials }) {
@@ -3094,7 +3152,7 @@ var toStorageType = (type) => {
3094
3152
  };
3095
3153
 
3096
3154
  // packages/sdk/client-services/src/packlets/system/system-service.ts
3097
- var import_codec_protobuf11 = require("@dxos/codec-protobuf");
3155
+ var import_codec_protobuf12 = require("@dxos/codec-protobuf");
3098
3156
  var SystemServiceImpl = class {
3099
3157
  constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
3100
3158
  this._config = config;
@@ -3111,7 +3169,7 @@ var SystemServiceImpl = class {
3111
3169
  await this._onUpdateStatus(status);
3112
3170
  }
3113
3171
  queryStatus() {
3114
- return new import_codec_protobuf11.Stream(({ next }) => {
3172
+ return new import_codec_protobuf12.Stream(({ next }) => {
3115
3173
  const update = () => {
3116
3174
  next({
3117
3175
  status: this._getCurrentStatus()
@@ -3132,14 +3190,14 @@ var SystemServiceImpl = class {
3132
3190
  };
3133
3191
 
3134
3192
  // packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
3135
- var import_async15 = require("@dxos/async");
3136
- var import_log12 = require("@dxos/log");
3193
+ var import_async16 = require("@dxos/async");
3194
+ var import_log13 = require("@dxos/log");
3137
3195
  var import_messaging = require("@dxos/messaging");
3138
3196
  var import_network_manager2 = require("@dxos/network-manager");
3139
3197
  var import_util7 = require("@dxos/util");
3140
3198
 
3141
3199
  // packages/sdk/client-services/src/packlets/services/client-rpc-server.ts
3142
- var import_codec_protobuf12 = require("@dxos/codec-protobuf");
3200
+ var import_codec_protobuf13 = require("@dxos/codec-protobuf");
3143
3201
  var import_debug5 = require("@dxos/debug");
3144
3202
  var import_rpc = require("@dxos/rpc");
3145
3203
  var ClientRpcServer = class {
@@ -3164,7 +3222,7 @@ var ClientRpcServer = class {
3164
3222
  const [serviceName, methodName] = (0, import_rpc.parseMethodName)(method);
3165
3223
  const handler = (method2, params3) => this._getServiceHandler(serviceName).callStream(method2, params3);
3166
3224
  if (this._handleStream) {
3167
- return import_codec_protobuf12.Stream.unwrapPromise(this._handleStream(methodName, params2, handler));
3225
+ return import_codec_protobuf13.Stream.unwrapPromise(this._handleStream(methodName, params2, handler));
3168
3226
  } else {
3169
3227
  return handler(methodName, params2);
3170
3228
  }
@@ -3193,14 +3251,14 @@ var ClientRpcServer = class {
3193
3251
 
3194
3252
  // packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
3195
3253
  var import_node_assert11 = __toESM(require("node:assert"));
3196
- var import_async14 = require("@dxos/async");
3254
+ var import_async15 = require("@dxos/async");
3197
3255
  var import_client4 = require("@dxos/client");
3198
3256
  var import_iframe = require("@dxos/protocols/proto/dxos/iframe");
3199
3257
  var import_rpc2 = require("@dxos/rpc");
3200
3258
  var ShellRuntimeImpl = class {
3201
3259
  constructor(_port) {
3202
3260
  this._port = _port;
3203
- this.layoutUpdate = new import_async14.Event();
3261
+ this.layoutUpdate = new import_async15.Event();
3204
3262
  this._layout = import_iframe.ShellLayout.DEFAULT;
3205
3263
  }
3206
3264
  get layout() {
@@ -3251,8 +3309,8 @@ var ShellRuntimeImpl = class {
3251
3309
  };
3252
3310
  var MemoryShellRuntime = class {
3253
3311
  constructor({ layout, invitationCode, spaceKey } = {}) {
3254
- this.layoutUpdate = new import_async14.Event();
3255
- this.contextUpdate = new import_async14.Event();
3312
+ this.layoutUpdate = new import_async15.Event();
3313
+ this.contextUpdate = new import_async15.Event();
3256
3314
  this._layout = layout != null ? layout : import_iframe.ShellLayout.DEFAULT;
3257
3315
  this._invitationCode = invitationCode;
3258
3316
  this._spaceKey = spaceKey;
@@ -3293,33 +3351,10 @@ var __decorate3 = function(decorators, target, key, desc) {
3293
3351
  };
3294
3352
  var LOCK_KEY = "DXOS_RESOURCE_LOCK";
3295
3353
  var IFrameHostRuntime = class {
3296
- constructor({ configProvider, appPort, shellPort }) {
3297
- this._transportFactory = (0, import_network_manager2.createWebRTCTransportFactory)({
3298
- iceServers: [
3299
- {
3300
- urls: "stun:dev.kube.dxos.org:3478",
3301
- username: "dxos",
3302
- credential: "dxos"
3303
- },
3304
- {
3305
- urls: "turn:dev.kube.dxos.org:3478",
3306
- username: "dxos",
3307
- credential: "dxos"
3308
- },
3309
- {
3310
- urls: "stun:kube.dxos.org:3478",
3311
- username: "dxos",
3312
- credential: "dxos"
3313
- },
3314
- {
3315
- urls: "turn:kube.dxos.org:3478",
3316
- username: "dxos",
3317
- credential: "dxos"
3318
- }
3319
- ]
3320
- });
3321
- this._ready = new import_async15.Trigger();
3322
- this._configProvider = configProvider;
3354
+ constructor({ config, origin, appPort, shellPort }) {
3355
+ this._ready = new import_async16.Trigger();
3356
+ this._configProvider = config;
3357
+ this.origin = origin;
3323
3358
  this._appPort = appPort;
3324
3359
  this._shellPort = shellPort;
3325
3360
  if (this._shellPort) {
@@ -3334,14 +3369,17 @@ var IFrameHostRuntime = class {
3334
3369
  }
3335
3370
  async start() {
3336
3371
  var _a;
3337
- (0, import_log12.log)("starting...", {}, {
3372
+ (0, import_log13.log)("starting...", {}, {
3338
3373
  file: "iframe-host-runtime.ts",
3339
- line: 75,
3374
+ line: 69,
3340
3375
  scope: this,
3341
3376
  callSite: (f, a) => f(...a)
3342
3377
  });
3343
3378
  try {
3344
3379
  this._config = await (0, import_util7.getAsyncValue)(this._configProvider);
3380
+ this._transportFactory = (0, import_network_manager2.createWebRTCTransportFactory)({
3381
+ iceServers: this._config.get("runtime.services.ice")
3382
+ });
3345
3383
  const signals = this._config.get("runtime.services.signaling");
3346
3384
  this._clientServices = new LocalClientServices({
3347
3385
  lockKey: LOCK_KEY,
@@ -3383,17 +3421,17 @@ var IFrameHostRuntime = class {
3383
3421
  (_a = this._shellRuntime) == null ? void 0 : _a.open()
3384
3422
  ]);
3385
3423
  this._ready.wake(void 0);
3386
- (0, import_log12.log)("started", {}, {
3424
+ (0, import_log13.log)("started", {}, {
3387
3425
  file: "iframe-host-runtime.ts",
3388
- line: 118,
3426
+ line: 115,
3389
3427
  scope: this,
3390
3428
  callSite: (f, a) => f(...a)
3391
3429
  });
3392
3430
  } catch (err) {
3393
3431
  this._ready.wake(err);
3394
- import_log12.log.catch(err, {}, {
3432
+ import_log13.log.catch(err, {}, {
3395
3433
  file: "iframe-host-runtime.ts",
3396
- line: 121,
3434
+ line: 118,
3397
3435
  scope: this,
3398
3436
  callSite: (f, a) => f(...a)
3399
3437
  });
@@ -3401,63 +3439,52 @@ var IFrameHostRuntime = class {
3401
3439
  }
3402
3440
  async stop() {
3403
3441
  var _a;
3404
- (0, import_log12.log)("stopping...", {}, {
3442
+ (0, import_log13.log)("stopping...", {}, {
3405
3443
  file: "iframe-host-runtime.ts",
3406
- line: 126,
3444
+ line: 123,
3407
3445
  scope: this,
3408
3446
  callSite: (f, a) => f(...a)
3409
3447
  });
3410
3448
  await this._clientRpc.close();
3411
3449
  await this._clientServices.close();
3412
3450
  await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
3413
- (0, import_log12.log)("stopped", {}, {
3451
+ (0, import_log13.log)("stopped", {}, {
3414
3452
  file: "iframe-host-runtime.ts",
3415
- line: 130,
3453
+ line: 127,
3416
3454
  scope: this,
3417
3455
  callSite: (f, a) => f(...a)
3418
3456
  });
3419
3457
  }
3420
3458
  };
3421
3459
  __decorate3([
3422
- import_log12.logInfo
3460
+ import_log13.logInfo
3423
3461
  ], IFrameHostRuntime.prototype, "origin", void 0);
3424
3462
 
3425
3463
  // packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
3426
3464
  var import_client5 = require("@dxos/client");
3427
3465
  var import_errors5 = require("@dxos/errors");
3428
- var import_log13 = require("@dxos/log");
3466
+ var import_log14 = require("@dxos/log");
3429
3467
  var import_network_manager3 = require("@dxos/network-manager");
3430
3468
  var import_rpc3 = require("@dxos/rpc");
3469
+ var import_util8 = require("@dxos/util");
3431
3470
  var IFrameProxyRuntime = class {
3432
- constructor({ systemPort, workerAppPort, windowAppPort, shellPort }) {
3433
- this._transportService = new import_network_manager3.WebRTCTransportService({
3434
- iceServers: [
3435
- {
3436
- urls: "stun:dev.kube.dxos.org:3478",
3437
- username: "dxos",
3438
- credential: "dxos"
3439
- },
3440
- {
3441
- urls: "turn:dev.kube.dxos.org:3478",
3442
- username: "dxos",
3443
- credential: "dxos"
3444
- },
3445
- {
3446
- urls: "stun:kube.dxos.org:3478",
3447
- username: "dxos",
3448
- credential: "dxos"
3449
- },
3450
- {
3451
- urls: "turn:kube.dxos.org:3478",
3452
- username: "dxos",
3453
- credential: "dxos"
3454
- }
3455
- ]
3456
- });
3471
+ constructor({ config, systemPort, shellPort }) {
3472
+ this._configProvider = config;
3457
3473
  this._systemPort = systemPort;
3458
- this._windowAppPort = windowAppPort;
3459
- this._workerAppPort = workerAppPort;
3460
3474
  this._shellPort = shellPort;
3475
+ if (this._shellPort) {
3476
+ this._shellRuntime = new ShellRuntimeImpl(this._shellPort);
3477
+ }
3478
+ }
3479
+ get shell() {
3480
+ return this._shellRuntime;
3481
+ }
3482
+ async open(origin) {
3483
+ var _a;
3484
+ this._config = await (0, import_util8.getAsyncValue)(this._configProvider);
3485
+ this._transportService = new import_network_manager3.WebRTCTransportService({
3486
+ iceServers: this._config.get("runtime.services.ice")
3487
+ });
3461
3488
  this._systemRpc = (0, import_rpc3.createProtoRpcPeer)({
3462
3489
  requested: import_client5.workerServiceBundle,
3463
3490
  exposed: import_client5.iframeServiceBundle,
@@ -3469,28 +3496,17 @@ var IFrameProxyRuntime = class {
3469
3496
  }
3470
3497
  },
3471
3498
  port: this._systemPort,
3472
- timeout: 1e3
3499
+ timeout: 200
3473
3500
  });
3474
- this._workerAppPort.subscribe((msg) => this._windowAppPort.send(msg));
3475
- this._windowAppPort.subscribe((msg) => this._workerAppPort.send(msg));
3476
- if (this._shellPort) {
3477
- this._shellRuntime = new ShellRuntimeImpl(this._shellPort);
3478
- }
3479
- }
3480
- get shell() {
3481
- return this._shellRuntime;
3482
- }
3483
- async open(origin) {
3484
- var _a;
3485
3501
  try {
3486
3502
  await this._systemRpc.open();
3487
3503
  await this._systemRpc.rpc.WorkerService.start({
3488
3504
  origin
3489
3505
  });
3490
3506
  } catch (err) {
3491
- import_log13.log.catch(err, {}, {
3507
+ import_log14.log.catch(err, {}, {
3492
3508
  file: "iframe-proxy-runtime.ts",
3493
- line: 79,
3509
+ line: 74,
3494
3510
  scope: this,
3495
3511
  callSite: (f, a) => f(...a)
3496
3512
  });
@@ -3507,8 +3523,8 @@ var IFrameProxyRuntime = class {
3507
3523
  };
3508
3524
 
3509
3525
  // packages/sdk/client-services/src/packlets/vault/vault-resource-lock.ts
3510
- var import_async16 = require("@dxos/async");
3511
- var import_log14 = require("@dxos/log");
3526
+ var import_async17 = require("@dxos/async");
3527
+ var import_log15 = require("@dxos/log");
3512
3528
  var __decorate4 = function(decorators, target, key, desc) {
3513
3529
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3514
3530
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -3526,7 +3542,7 @@ var Message;
3526
3542
  var VaultResourceLock = class {
3527
3543
  constructor({ lockKey, onAcquire, onRelease }) {
3528
3544
  this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
3529
- this._releaseTrigger = new import_async16.Trigger();
3545
+ this._releaseTrigger = new import_async17.Trigger();
3530
3546
  this._lockKey = lockKey;
3531
3547
  this._onAcquire = onAcquire;
3532
3548
  this._onRelease = onRelease;
@@ -3540,28 +3556,28 @@ var VaultResourceLock = class {
3540
3556
  message: Message.ACQUIRING
3541
3557
  });
3542
3558
  try {
3543
- (0, import_log14.log)("aquiring lock...", {}, {
3559
+ (0, import_log15.log)("aquiring lock...", {}, {
3544
3560
  file: "vault-resource-lock.ts",
3545
3561
  line: 44,
3546
3562
  scope: this,
3547
3563
  callSite: (f, a) => f(...a)
3548
3564
  });
3549
- await (0, import_async16.asyncTimeout)(this._requestLock(), 3e3);
3550
- (0, import_log14.log)("acquired lock", {}, {
3565
+ await (0, import_async17.asyncTimeout)(this._requestLock(), 3e3);
3566
+ (0, import_log15.log)("acquired lock", {}, {
3551
3567
  file: "vault-resource-lock.ts",
3552
3568
  line: 46,
3553
3569
  scope: this,
3554
3570
  callSite: (f, a) => f(...a)
3555
3571
  });
3556
3572
  } catch (e) {
3557
- (0, import_log14.log)("stealing lock...", {}, {
3573
+ (0, import_log15.log)("stealing lock...", {}, {
3558
3574
  file: "vault-resource-lock.ts",
3559
3575
  line: 48,
3560
3576
  scope: this,
3561
3577
  callSite: (f, a) => f(...a)
3562
3578
  });
3563
3579
  await this._requestLock(true);
3564
- (0, import_log14.log)("stolen lock", {}, {
3580
+ (0, import_log15.log)("stolen lock", {}, {
3565
3581
  file: "vault-resource-lock.ts",
3566
3582
  line: 50,
3567
3583
  scope: this,
@@ -3578,7 +3594,7 @@ var VaultResourceLock = class {
3578
3594
  }
3579
3595
  }
3580
3596
  async _requestLock(steal = false) {
3581
- (0, import_log14.log)("requesting lock...", {
3597
+ (0, import_log15.log)("requesting lock...", {
3582
3598
  steal
3583
3599
  }, {
3584
3600
  file: "vault-resource-lock.ts",
@@ -3586,23 +3602,23 @@ var VaultResourceLock = class {
3586
3602
  scope: this,
3587
3603
  callSite: (f, a) => f(...a)
3588
3604
  });
3589
- const acquired = new import_async16.Trigger();
3605
+ const acquired = new import_async17.Trigger();
3590
3606
  void navigator.locks.request(this._lockKey, {
3591
3607
  steal
3592
3608
  }, async () => {
3593
3609
  var _a, _b;
3594
3610
  await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
3595
3611
  acquired.wake();
3596
- this._releaseTrigger = new import_async16.Trigger();
3612
+ this._releaseTrigger = new import_async17.Trigger();
3597
3613
  await this._releaseTrigger.wait();
3598
- (0, import_log14.log)("releasing lock...", {}, {
3614
+ (0, import_log15.log)("releasing lock...", {}, {
3599
3615
  file: "vault-resource-lock.ts",
3600
3616
  line: 74,
3601
3617
  scope: this,
3602
3618
  callSite: (f, a) => f(...a)
3603
3619
  });
3604
3620
  await ((_b = this._onRelease) == null ? void 0 : _b.call(this));
3605
- (0, import_log14.log)("released lock", {}, {
3621
+ (0, import_log15.log)("released lock", {}, {
3606
3622
  file: "vault-resource-lock.ts",
3607
3623
  line: 76,
3608
3624
  scope: this,
@@ -3613,7 +3629,7 @@ var VaultResourceLock = class {
3613
3629
  await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
3614
3630
  });
3615
3631
  await acquired.wait();
3616
- (0, import_log14.log)("recieved lock", {
3632
+ (0, import_log15.log)("recieved lock", {
3617
3633
  steal
3618
3634
  }, {
3619
3635
  file: "vault-resource-lock.ts",
@@ -3624,22 +3640,22 @@ var VaultResourceLock = class {
3624
3640
  }
3625
3641
  };
3626
3642
  __decorate4([
3627
- import_log14.logInfo
3643
+ import_log15.logInfo
3628
3644
  ], VaultResourceLock.prototype, "lockKey", null);
3629
3645
 
3630
3646
  // packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
3631
- var import_async18 = require("@dxos/async");
3632
- var import_log16 = require("@dxos/log");
3647
+ var import_async19 = require("@dxos/async");
3648
+ var import_log17 = require("@dxos/log");
3633
3649
  var import_messaging2 = require("@dxos/messaging");
3634
3650
  var import_network_manager4 = require("@dxos/network-manager");
3635
3651
 
3636
3652
  // packages/sdk/client-services/src/packlets/vault/worker-session.ts
3637
3653
  var import_node_assert12 = __toESM(require("node:assert"));
3638
- var import_async17 = require("@dxos/async");
3654
+ var import_async18 = require("@dxos/async");
3639
3655
  var import_client6 = require("@dxos/client");
3640
- var import_log15 = require("@dxos/log");
3656
+ var import_log16 = require("@dxos/log");
3641
3657
  var import_rpc4 = require("@dxos/rpc");
3642
- var import_util8 = require("@dxos/util");
3658
+ var import_util9 = require("@dxos/util");
3643
3659
  var __decorate5 = function(decorators, target, key, desc) {
3644
3660
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3645
3661
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -3654,8 +3670,8 @@ var WorkerSession = class {
3654
3670
  constructor({ serviceHost, systemPort, appPort, shellPort, readySignal, options = {
3655
3671
  heartbeatInterval: 1e3
3656
3672
  } }) {
3657
- this._startTrigger = new import_async17.Trigger();
3658
- this.onClose = new import_util8.Callback();
3673
+ this._startTrigger = new import_async18.Trigger();
3674
+ this.onClose = new import_util9.Callback();
3659
3675
  (0, import_node_assert12.default)(options);
3660
3676
  (0, import_node_assert12.default)(serviceHost);
3661
3677
  this._options = options;
@@ -3704,7 +3720,7 @@ var WorkerSession = class {
3704
3720
  try {
3705
3721
  await this.close();
3706
3722
  } catch (err) {
3707
- import_log15.log.catch(err, {}, {
3723
+ import_log16.log.catch(err, {}, {
3708
3724
  file: "worker-session.ts",
3709
3725
  line: 107,
3710
3726
  scope: this,
@@ -3722,7 +3738,7 @@ var WorkerSession = class {
3722
3738
  this.bridgeService = this._iframeRpc.rpc.BridgeService;
3723
3739
  }
3724
3740
  async open() {
3725
- import_log15.log.info("opening..", {}, {
3741
+ import_log16.log.info("opening..", {}, {
3726
3742
  file: "worker-session.ts",
3727
3743
  line: 121,
3728
3744
  scope: this,
@@ -3740,7 +3756,7 @@ var WorkerSession = class {
3740
3756
  try {
3741
3757
  await this._iframeRpc.rpc.IframeService.heartbeat();
3742
3758
  } catch (err1) {
3743
- import_log15.log.warn("Heartbeat failed", {
3759
+ import_log16.log.warn("Heartbeat failed", {
3744
3760
  err: err1
3745
3761
  }, {
3746
3762
  file: "worker-session.ts",
@@ -3751,7 +3767,7 @@ var WorkerSession = class {
3751
3767
  try {
3752
3768
  await this.close();
3753
3769
  } catch (err) {
3754
- import_log15.log.catch(err, {}, {
3770
+ import_log16.log.catch(err, {}, {
3755
3771
  file: "worker-session.ts",
3756
3772
  line: 137,
3757
3773
  scope: this,
@@ -3762,7 +3778,7 @@ var WorkerSession = class {
3762
3778
  }, this._options.heartbeatInterval);
3763
3779
  }
3764
3780
  async close() {
3765
- import_log15.log.info("closing..", {}, {
3781
+ import_log16.log.info("closing..", {}, {
3766
3782
  file: "worker-session.ts",
3767
3783
  line: 144,
3768
3784
  scope: this,
@@ -3771,7 +3787,7 @@ var WorkerSession = class {
3771
3787
  try {
3772
3788
  await this.onClose.callIfSet();
3773
3789
  } catch (err) {
3774
- import_log15.log.catch(err, {}, {
3790
+ import_log16.log.catch(err, {}, {
3775
3791
  file: "worker-session.ts",
3776
3792
  line: 148,
3777
3793
  scope: this,
@@ -3788,9 +3804,9 @@ var WorkerSession = class {
3788
3804
  }
3789
3805
  async _maybeOpenShell() {
3790
3806
  try {
3791
- await (0, import_async17.asyncTimeout)(this._shellClientRpc.open(), 1e3);
3807
+ await (0, import_async18.asyncTimeout)(this._shellClientRpc.open(), 1e3);
3792
3808
  } catch (e) {
3793
- import_log15.log.info("No shell connected.", {}, {
3809
+ import_log16.log.info("No shell connected.", {}, {
3794
3810
  file: "worker-session.ts",
3795
3811
  line: 162,
3796
3812
  scope: this,
@@ -3800,7 +3816,7 @@ var WorkerSession = class {
3800
3816
  }
3801
3817
  };
3802
3818
  __decorate5([
3803
- import_log15.logInfo
3819
+ import_log16.logInfo
3804
3820
  ], WorkerSession.prototype, "origin", void 0);
3805
3821
 
3806
3822
  // packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
@@ -3809,7 +3825,7 @@ var WorkerRuntime = class {
3809
3825
  constructor(_configProvider) {
3810
3826
  this._configProvider = _configProvider;
3811
3827
  this._transportFactory = new import_network_manager4.WebRTCTransportProxyFactory();
3812
- this._ready = new import_async18.Trigger();
3828
+ this._ready = new import_async19.Trigger();
3813
3829
  this.sessions = /* @__PURE__ */ new Set();
3814
3830
  this._clientServices = new ClientServicesHost();
3815
3831
  }
@@ -3817,7 +3833,7 @@ var WorkerRuntime = class {
3817
3833
  return this._clientServices;
3818
3834
  }
3819
3835
  async start() {
3820
- (0, import_log16.log)("starting...", {}, {
3836
+ (0, import_log17.log)("starting...", {}, {
3821
3837
  file: "worker-runtime.ts",
3822
3838
  line: 48,
3823
3839
  scope: this,
@@ -3836,7 +3852,7 @@ var WorkerRuntime = class {
3836
3852
  });
3837
3853
  await this._clientServices.open();
3838
3854
  this._ready.wake(void 0);
3839
- (0, import_log16.log)("started", {}, {
3855
+ (0, import_log17.log)("started", {}, {
3840
3856
  file: "worker-runtime.ts",
3841
3857
  line: 65,
3842
3858
  scope: this,
@@ -3844,7 +3860,7 @@ var WorkerRuntime = class {
3844
3860
  });
3845
3861
  } catch (err) {
3846
3862
  this._ready.wake(err);
3847
- import_log16.log.catch(err, {}, {
3863
+ import_log17.log.catch(err, {}, {
3848
3864
  file: "worker-runtime.ts",
3849
3865
  line: 68,
3850
3866
  scope: this,
@@ -3897,7 +3913,7 @@ var WorkerRuntime = class {
3897
3913
 
3898
3914
  // packages/sdk/client-services/src/packlets/services/service-context.ts
3899
3915
  var import_node_assert13 = __toESM(require("node:assert"));
3900
- var import_async19 = require("@dxos/async");
3916
+ var import_async20 = require("@dxos/async");
3901
3917
  var import_client7 = require("@dxos/client");
3902
3918
  var import_credentials11 = require("@dxos/credentials");
3903
3919
  var import_debug6 = require("@dxos/debug");
@@ -3905,7 +3921,7 @@ var import_echo_pipeline4 = require("@dxos/echo-pipeline");
3905
3921
  var import_feed_store4 = require("@dxos/feed-store");
3906
3922
  var import_keyring = require("@dxos/keyring");
3907
3923
  var import_keys10 = require("@dxos/keys");
3908
- var import_log17 = require("@dxos/log");
3924
+ var import_log18 = require("@dxos/log");
3909
3925
  var import_protocols7 = require("@dxos/protocols");
3910
3926
  var ServiceContext = class {
3911
3927
  // prettier-ignore
@@ -3913,7 +3929,7 @@ var ServiceContext = class {
3913
3929
  this.storage = storage;
3914
3930
  this.networkManager = networkManager;
3915
3931
  this.modelFactory = modelFactory;
3916
- this.initialized = new import_async19.Trigger();
3932
+ this.initialized = new import_async20.Trigger();
3917
3933
  this.dataServiceSubscriptions = new import_echo_pipeline4.DataServiceSubscriptions();
3918
3934
  this._handlerFactories = /* @__PURE__ */ new Map();
3919
3935
  this._instanceId = import_keys10.PublicKey.random().toHex();
@@ -3945,7 +3961,7 @@ var ServiceContext = class {
3945
3961
  }, this._acceptIdentity.bind(this)));
3946
3962
  }
3947
3963
  async open() {
3948
- import_log17.log.trace("dxos.sdk.service-context", import_protocols7.trace.begin({
3964
+ import_log18.log.trace("dxos.sdk.service-context", import_protocols7.trace.begin({
3949
3965
  id: this._instanceId
3950
3966
  }), {
3951
3967
  file: "service-context.ts",
@@ -3953,7 +3969,7 @@ var ServiceContext = class {
3953
3969
  scope: this,
3954
3970
  callSite: (f, a) => f(...a)
3955
3971
  });
3956
- (0, import_log17.log)("opening...", {}, {
3972
+ (0, import_log18.log)("opening...", {}, {
3957
3973
  file: "service-context.ts",
3958
3974
  line: 117,
3959
3975
  scope: this,
@@ -3965,7 +3981,7 @@ var ServiceContext = class {
3965
3981
  if (this.identityManager.identity) {
3966
3982
  await this._initialize();
3967
3983
  }
3968
- (0, import_log17.log)("opened", {}, {
3984
+ (0, import_log18.log)("opened", {}, {
3969
3985
  file: "service-context.ts",
3970
3986
  line: 124,
3971
3987
  scope: this,
@@ -3974,7 +3990,7 @@ var ServiceContext = class {
3974
3990
  }
3975
3991
  async close() {
3976
3992
  var _a, _b;
3977
- (0, import_log17.log)("closing...", {}, {
3993
+ (0, import_log18.log)("closing...", {}, {
3978
3994
  file: "service-context.ts",
3979
3995
  line: 128,
3980
3996
  scope: this,
@@ -3987,13 +4003,13 @@ var ServiceContext = class {
3987
4003
  await this.feedStore.close();
3988
4004
  await this.networkManager.close();
3989
4005
  this.dataServiceSubscriptions.clear();
3990
- (0, import_log17.log)("closed", {}, {
4006
+ (0, import_log18.log)("closed", {}, {
3991
4007
  file: "service-context.ts",
3992
4008
  line: 136,
3993
4009
  scope: this,
3994
4010
  callSite: (f, a) => f(...a)
3995
4011
  });
3996
- import_log17.log.trace("dxos.sdk.service-context", import_protocols7.trace.end({
4012
+ import_log18.log.trace("dxos.sdk.service-context", import_protocols7.trace.end({
3997
4013
  id: this._instanceId
3998
4014
  }), {
3999
4015
  file: "service-context.ts",
@@ -4020,7 +4036,7 @@ var ServiceContext = class {
4020
4036
  // Called when identity is created.
4021
4037
  async _initialize() {
4022
4038
  var _a;
4023
- (0, import_log17.log)("initializing spaces...", {}, {
4039
+ (0, import_log18.log)("initializing spaces...", {}, {
4024
4040
  file: "service-context.ts",
4025
4041
  line: 163,
4026
4042
  scope: this,
@@ -4058,7 +4074,7 @@ var ServiceContext = class {
4058
4074
  return;
4059
4075
  }
4060
4076
  if (!this.dataSpaceManager) {
4061
- (0, import_log17.log)("dataSpaceManager not initialized yet, ignoring space admission", {
4077
+ (0, import_log18.log)("dataSpaceManager not initialized yet, ignoring space admission", {
4062
4078
  details: assertion
4063
4079
  }, {
4064
4080
  file: "service-context.ts",
@@ -4069,7 +4085,7 @@ var ServiceContext = class {
4069
4085
  return;
4070
4086
  }
4071
4087
  if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
4072
- (0, import_log17.log)("space already exists, ignoring space admission", {
4088
+ (0, import_log18.log)("space already exists, ignoring space admission", {
4073
4089
  details: assertion
4074
4090
  }, {
4075
4091
  file: "service-context.ts",
@@ -4080,7 +4096,7 @@ var ServiceContext = class {
4080
4096
  return;
4081
4097
  }
4082
4098
  try {
4083
- (0, import_log17.log)("accepting space recorded in halo", {
4099
+ (0, import_log18.log)("accepting space recorded in halo", {
4084
4100
  details: assertion
4085
4101
  }, {
4086
4102
  file: "service-context.ts",
@@ -4093,7 +4109,7 @@ var ServiceContext = class {
4093
4109
  genesisFeedKey: assertion.genesisFeedKey
4094
4110
  });
4095
4111
  } catch (err) {
4096
- import_log17.log.catch(err, {}, {
4112
+ import_log18.log.catch(err, {}, {
4097
4113
  file: "service-context.ts",
4098
4114
  line: 220,
4099
4115
  scope: this,
@@ -4141,7 +4157,7 @@ var ClientServicesHost = class {
4141
4157
  // TODO(wittjosiah): Turn this on by default.
4142
4158
  lockKey
4143
4159
  } = {}) {
4144
- this._statusUpdate = new import_async20.Event();
4160
+ this._statusUpdate = new import_async21.Event();
4145
4161
  this._opening = false;
4146
4162
  this._open = false;
4147
4163
  this._instanceId = import_client8.PublicKey.random().toHex();
@@ -4176,6 +4192,7 @@ var ClientServicesHost = class {
4176
4192
  await this.reset();
4177
4193
  }
4178
4194
  });
4195
+ this._loggingService = new LoggingServiceImpl();
4179
4196
  this._serviceRegistry = new ServiceRegistry(import_client8.clientServiceBundle, {
4180
4197
  SystemService: this._systemService
4181
4198
  });
@@ -4216,11 +4233,11 @@ var ClientServicesHost = class {
4216
4233
  if (this._open) {
4217
4234
  return;
4218
4235
  }
4219
- import_log18.log.trace("dxos.sdk.client-services-host", import_protocols8.trace.begin({
4236
+ import_log19.log.trace("dxos.sdk.client-services-host", import_protocols8.trace.begin({
4220
4237
  id: this._instanceId
4221
4238
  }), {
4222
4239
  file: "service-host.ts",
4223
- line: 166,
4240
+ line: 169,
4224
4241
  scope: this,
4225
4242
  callSite: (f, a) => f(...a)
4226
4243
  });
@@ -4228,15 +4245,16 @@ var ClientServicesHost = class {
4228
4245
  (0, import_node_assert14.default)(this._storage, "storage not set");
4229
4246
  (0, import_node_assert14.default)(this._networkManager, "network manager not set");
4230
4247
  this._opening = true;
4231
- (0, import_log18.log)("opening...", {
4248
+ (0, import_log19.log)("opening...", {
4232
4249
  lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
4233
4250
  }, {
4234
4251
  file: "service-host.ts",
4235
- line: 173,
4252
+ line: 176,
4236
4253
  scope: this,
4237
4254
  callSite: (f, a) => f(...a)
4238
4255
  });
4239
4256
  await ((_b = this._resourceLock) == null ? void 0 : _b.acquire());
4257
+ await this._loggingService.open();
4240
4258
  this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._modelFactory);
4241
4259
  this._serviceRegistry.setServices({
4242
4260
  SystemService: this._systemService,
@@ -4249,8 +4267,8 @@ var ClientServicesHost = class {
4249
4267
  }),
4250
4268
  DataService: new import_echo_pipeline5.DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
4251
4269
  NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager),
4270
+ LoggingService: this._loggingService,
4252
4271
  // TODO(burdon): Move to new protobuf definitions.
4253
- TracingService: new TracingServiceImpl(this._config),
4254
4272
  DevtoolsHost: new DevtoolsServiceImpl({
4255
4273
  events: new DevtoolsHostEvents(),
4256
4274
  config: this._config,
@@ -4262,11 +4280,11 @@ var ClientServicesHost = class {
4262
4280
  this._open = true;
4263
4281
  this._statusUpdate.emit();
4264
4282
  const deviceKey = (_c = this._serviceContext.identityManager.identity) == null ? void 0 : _c.deviceKey;
4265
- (0, import_log18.log)("opened", {
4283
+ (0, import_log19.log)("opened", {
4266
4284
  deviceKey
4267
4285
  }, {
4268
4286
  file: "service-host.ts",
4269
- line: 220,
4287
+ line: 226,
4270
4288
  scope: this,
4271
4289
  callSite: (f, a) => f(...a)
4272
4290
  });
@@ -4277,50 +4295,51 @@ var ClientServicesHost = class {
4277
4295
  return;
4278
4296
  }
4279
4297
  const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
4280
- (0, import_log18.log)("closing...", {
4298
+ (0, import_log19.log)("closing...", {
4281
4299
  deviceKey
4282
4300
  }, {
4283
4301
  file: "service-host.ts",
4284
- line: 229,
4302
+ line: 235,
4285
4303
  scope: this,
4286
4304
  callSite: (f, a) => f(...a)
4287
4305
  });
4288
4306
  this._serviceRegistry.setServices({
4289
4307
  SystemService: this._systemService
4290
4308
  });
4309
+ await this._loggingService.close();
4291
4310
  await this._serviceContext.close();
4292
4311
  this._open = false;
4293
4312
  this._statusUpdate.emit();
4294
- (0, import_log18.log)("closed", {
4313
+ (0, import_log19.log)("closed", {
4295
4314
  deviceKey
4296
4315
  }, {
4297
4316
  file: "service-host.ts",
4298
- line: 234,
4317
+ line: 241,
4299
4318
  scope: this,
4300
4319
  callSite: (f, a) => f(...a)
4301
4320
  });
4302
- import_log18.log.trace("dxos.sdk.client-services-host", import_protocols8.trace.end({
4321
+ import_log19.log.trace("dxos.sdk.client-services-host", import_protocols8.trace.end({
4303
4322
  id: this._instanceId
4304
4323
  }), {
4305
4324
  file: "service-host.ts",
4306
- line: 236,
4325
+ line: 243,
4307
4326
  scope: this,
4308
4327
  callSite: (f, a) => f(...a)
4309
4328
  });
4310
4329
  }
4311
4330
  async reset() {
4312
4331
  var _a;
4313
- (0, import_log18.log)("resetting...", {}, {
4332
+ (0, import_log19.log)("resetting...", {}, {
4314
4333
  file: "service-host.ts",
4315
- line: 240,
4334
+ line: 247,
4316
4335
  scope: this,
4317
4336
  callSite: (f, a) => f(...a)
4318
4337
  });
4319
4338
  await ((_a = this._serviceContext) == null ? void 0 : _a.close());
4320
4339
  await this._storage.reset();
4321
- (0, import_log18.log)("reset", {}, {
4340
+ (0, import_log19.log)("reset", {}, {
4322
4341
  file: "service-host.ts",
4323
- line: 243,
4342
+ line: 250,
4324
4343
  scope: this,
4325
4344
  callSite: (f, a) => f(...a)
4326
4345
  });
@@ -4351,7 +4370,7 @@ var LocalClientServices = class {
4351
4370
 
4352
4371
  // packages/sdk/client-services/src/packlets/services/utils.ts
4353
4372
  var import_config2 = require("@dxos/config");
4354
- var import_log19 = require("@dxos/log");
4373
+ var import_log20 = require("@dxos/log");
4355
4374
  var import_messaging3 = require("@dxos/messaging");
4356
4375
  var import_network_manager5 = require("@dxos/network-manager");
4357
4376
  var fromHost = (config = new import_config2.Config()) => {
@@ -4372,7 +4391,7 @@ var createNetworkManager = (config, options = {}) => {
4372
4391
  transportFactory
4373
4392
  });
4374
4393
  }
4375
- import_log19.log.warn("P2P network is not configured.", {}, {
4394
+ import_log20.log.warn("P2P network is not configured.", {}, {
4376
4395
  file: "utils.ts",
4377
4396
  line: 48,
4378
4397
  scope: void 0,