@dxos/client-services 0.1.41-next.adfd7c6 → 0.1.42-next.6e229fb

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-6DELP6G3.mjs} +231 -213
  2. package/dist/lib/browser/chunk-6DELP6G3.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 +270 -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 +258 -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 +4 -4
  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 +10 -15
  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,9 @@ 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, appPort, shellPort }) {
3355
+ this._ready = new import_async16.Trigger();
3356
+ this._configProvider = config;
3323
3357
  this._appPort = appPort;
3324
3358
  this._shellPort = shellPort;
3325
3359
  if (this._shellPort) {
@@ -3334,14 +3368,17 @@ var IFrameHostRuntime = class {
3334
3368
  }
3335
3369
  async start() {
3336
3370
  var _a;
3337
- (0, import_log12.log)("starting...", {}, {
3371
+ (0, import_log13.log)("starting...", {}, {
3338
3372
  file: "iframe-host-runtime.ts",
3339
- line: 75,
3373
+ line: 67,
3340
3374
  scope: this,
3341
3375
  callSite: (f, a) => f(...a)
3342
3376
  });
3343
3377
  try {
3344
3378
  this._config = await (0, import_util7.getAsyncValue)(this._configProvider);
3379
+ this._transportFactory = (0, import_network_manager2.createWebRTCTransportFactory)({
3380
+ iceServers: this._config.get("runtime.services.ice")
3381
+ });
3345
3382
  const signals = this._config.get("runtime.services.signaling");
3346
3383
  this._clientServices = new LocalClientServices({
3347
3384
  lockKey: LOCK_KEY,
@@ -3383,17 +3420,17 @@ var IFrameHostRuntime = class {
3383
3420
  (_a = this._shellRuntime) == null ? void 0 : _a.open()
3384
3421
  ]);
3385
3422
  this._ready.wake(void 0);
3386
- (0, import_log12.log)("started", {}, {
3423
+ (0, import_log13.log)("started", {}, {
3387
3424
  file: "iframe-host-runtime.ts",
3388
- line: 118,
3425
+ line: 113,
3389
3426
  scope: this,
3390
3427
  callSite: (f, a) => f(...a)
3391
3428
  });
3392
3429
  } catch (err) {
3393
3430
  this._ready.wake(err);
3394
- import_log12.log.catch(err, {}, {
3431
+ import_log13.log.catch(err, {}, {
3395
3432
  file: "iframe-host-runtime.ts",
3396
- line: 121,
3433
+ line: 116,
3397
3434
  scope: this,
3398
3435
  callSite: (f, a) => f(...a)
3399
3436
  });
@@ -3401,63 +3438,52 @@ var IFrameHostRuntime = class {
3401
3438
  }
3402
3439
  async stop() {
3403
3440
  var _a;
3404
- (0, import_log12.log)("stopping...", {}, {
3441
+ (0, import_log13.log)("stopping...", {}, {
3405
3442
  file: "iframe-host-runtime.ts",
3406
- line: 126,
3443
+ line: 121,
3407
3444
  scope: this,
3408
3445
  callSite: (f, a) => f(...a)
3409
3446
  });
3410
3447
  await this._clientRpc.close();
3411
3448
  await this._clientServices.close();
3412
3449
  await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
3413
- (0, import_log12.log)("stopped", {}, {
3450
+ (0, import_log13.log)("stopped", {}, {
3414
3451
  file: "iframe-host-runtime.ts",
3415
- line: 130,
3452
+ line: 125,
3416
3453
  scope: this,
3417
3454
  callSite: (f, a) => f(...a)
3418
3455
  });
3419
3456
  }
3420
3457
  };
3421
3458
  __decorate3([
3422
- import_log12.logInfo
3459
+ import_log13.logInfo
3423
3460
  ], IFrameHostRuntime.prototype, "origin", void 0);
3424
3461
 
3425
3462
  // packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
3426
3463
  var import_client5 = require("@dxos/client");
3427
3464
  var import_errors5 = require("@dxos/errors");
3428
- var import_log13 = require("@dxos/log");
3465
+ var import_log14 = require("@dxos/log");
3429
3466
  var import_network_manager3 = require("@dxos/network-manager");
3430
3467
  var import_rpc3 = require("@dxos/rpc");
3468
+ var import_util8 = require("@dxos/util");
3431
3469
  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
- });
3470
+ constructor({ config, systemPort, shellPort }) {
3471
+ this._configProvider = config;
3457
3472
  this._systemPort = systemPort;
3458
- this._windowAppPort = windowAppPort;
3459
- this._workerAppPort = workerAppPort;
3460
3473
  this._shellPort = shellPort;
3474
+ if (this._shellPort) {
3475
+ this._shellRuntime = new ShellRuntimeImpl(this._shellPort);
3476
+ }
3477
+ }
3478
+ get shell() {
3479
+ return this._shellRuntime;
3480
+ }
3481
+ async open(origin) {
3482
+ var _a;
3483
+ this._config = await (0, import_util8.getAsyncValue)(this._configProvider);
3484
+ this._transportService = new import_network_manager3.WebRTCTransportService({
3485
+ iceServers: this._config.get("runtime.services.ice")
3486
+ });
3461
3487
  this._systemRpc = (0, import_rpc3.createProtoRpcPeer)({
3462
3488
  requested: import_client5.workerServiceBundle,
3463
3489
  exposed: import_client5.iframeServiceBundle,
@@ -3469,28 +3495,17 @@ var IFrameProxyRuntime = class {
3469
3495
  }
3470
3496
  },
3471
3497
  port: this._systemPort,
3472
- timeout: 1e3
3498
+ timeout: 200
3473
3499
  });
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
3500
  try {
3486
3501
  await this._systemRpc.open();
3487
3502
  await this._systemRpc.rpc.WorkerService.start({
3488
3503
  origin
3489
3504
  });
3490
3505
  } catch (err) {
3491
- import_log13.log.catch(err, {}, {
3506
+ import_log14.log.catch(err, {}, {
3492
3507
  file: "iframe-proxy-runtime.ts",
3493
- line: 79,
3508
+ line: 74,
3494
3509
  scope: this,
3495
3510
  callSite: (f, a) => f(...a)
3496
3511
  });
@@ -3507,8 +3522,8 @@ var IFrameProxyRuntime = class {
3507
3522
  };
3508
3523
 
3509
3524
  // 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");
3525
+ var import_async17 = require("@dxos/async");
3526
+ var import_log15 = require("@dxos/log");
3512
3527
  var __decorate4 = function(decorators, target, key, desc) {
3513
3528
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3514
3529
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -3526,7 +3541,7 @@ var Message;
3526
3541
  var VaultResourceLock = class {
3527
3542
  constructor({ lockKey, onAcquire, onRelease }) {
3528
3543
  this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
3529
- this._releaseTrigger = new import_async16.Trigger();
3544
+ this._releaseTrigger = new import_async17.Trigger();
3530
3545
  this._lockKey = lockKey;
3531
3546
  this._onAcquire = onAcquire;
3532
3547
  this._onRelease = onRelease;
@@ -3540,28 +3555,28 @@ var VaultResourceLock = class {
3540
3555
  message: Message.ACQUIRING
3541
3556
  });
3542
3557
  try {
3543
- (0, import_log14.log)("aquiring lock...", {}, {
3558
+ (0, import_log15.log)("aquiring lock...", {}, {
3544
3559
  file: "vault-resource-lock.ts",
3545
3560
  line: 44,
3546
3561
  scope: this,
3547
3562
  callSite: (f, a) => f(...a)
3548
3563
  });
3549
- await (0, import_async16.asyncTimeout)(this._requestLock(), 3e3);
3550
- (0, import_log14.log)("acquired lock", {}, {
3564
+ await (0, import_async17.asyncTimeout)(this._requestLock(), 3e3);
3565
+ (0, import_log15.log)("acquired lock", {}, {
3551
3566
  file: "vault-resource-lock.ts",
3552
3567
  line: 46,
3553
3568
  scope: this,
3554
3569
  callSite: (f, a) => f(...a)
3555
3570
  });
3556
3571
  } catch (e) {
3557
- (0, import_log14.log)("stealing lock...", {}, {
3572
+ (0, import_log15.log)("stealing lock...", {}, {
3558
3573
  file: "vault-resource-lock.ts",
3559
3574
  line: 48,
3560
3575
  scope: this,
3561
3576
  callSite: (f, a) => f(...a)
3562
3577
  });
3563
3578
  await this._requestLock(true);
3564
- (0, import_log14.log)("stolen lock", {}, {
3579
+ (0, import_log15.log)("stolen lock", {}, {
3565
3580
  file: "vault-resource-lock.ts",
3566
3581
  line: 50,
3567
3582
  scope: this,
@@ -3578,7 +3593,7 @@ var VaultResourceLock = class {
3578
3593
  }
3579
3594
  }
3580
3595
  async _requestLock(steal = false) {
3581
- (0, import_log14.log)("requesting lock...", {
3596
+ (0, import_log15.log)("requesting lock...", {
3582
3597
  steal
3583
3598
  }, {
3584
3599
  file: "vault-resource-lock.ts",
@@ -3586,23 +3601,23 @@ var VaultResourceLock = class {
3586
3601
  scope: this,
3587
3602
  callSite: (f, a) => f(...a)
3588
3603
  });
3589
- const acquired = new import_async16.Trigger();
3604
+ const acquired = new import_async17.Trigger();
3590
3605
  void navigator.locks.request(this._lockKey, {
3591
3606
  steal
3592
3607
  }, async () => {
3593
3608
  var _a, _b;
3594
3609
  await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
3595
3610
  acquired.wake();
3596
- this._releaseTrigger = new import_async16.Trigger();
3611
+ this._releaseTrigger = new import_async17.Trigger();
3597
3612
  await this._releaseTrigger.wait();
3598
- (0, import_log14.log)("releasing lock...", {}, {
3613
+ (0, import_log15.log)("releasing lock...", {}, {
3599
3614
  file: "vault-resource-lock.ts",
3600
3615
  line: 74,
3601
3616
  scope: this,
3602
3617
  callSite: (f, a) => f(...a)
3603
3618
  });
3604
3619
  await ((_b = this._onRelease) == null ? void 0 : _b.call(this));
3605
- (0, import_log14.log)("released lock", {}, {
3620
+ (0, import_log15.log)("released lock", {}, {
3606
3621
  file: "vault-resource-lock.ts",
3607
3622
  line: 76,
3608
3623
  scope: this,
@@ -3613,7 +3628,7 @@ var VaultResourceLock = class {
3613
3628
  await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
3614
3629
  });
3615
3630
  await acquired.wait();
3616
- (0, import_log14.log)("recieved lock", {
3631
+ (0, import_log15.log)("recieved lock", {
3617
3632
  steal
3618
3633
  }, {
3619
3634
  file: "vault-resource-lock.ts",
@@ -3624,22 +3639,22 @@ var VaultResourceLock = class {
3624
3639
  }
3625
3640
  };
3626
3641
  __decorate4([
3627
- import_log14.logInfo
3642
+ import_log15.logInfo
3628
3643
  ], VaultResourceLock.prototype, "lockKey", null);
3629
3644
 
3630
3645
  // packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
3631
- var import_async18 = require("@dxos/async");
3632
- var import_log16 = require("@dxos/log");
3646
+ var import_async19 = require("@dxos/async");
3647
+ var import_log17 = require("@dxos/log");
3633
3648
  var import_messaging2 = require("@dxos/messaging");
3634
3649
  var import_network_manager4 = require("@dxos/network-manager");
3635
3650
 
3636
3651
  // packages/sdk/client-services/src/packlets/vault/worker-session.ts
3637
3652
  var import_node_assert12 = __toESM(require("node:assert"));
3638
- var import_async17 = require("@dxos/async");
3653
+ var import_async18 = require("@dxos/async");
3639
3654
  var import_client6 = require("@dxos/client");
3640
- var import_log15 = require("@dxos/log");
3655
+ var import_log16 = require("@dxos/log");
3641
3656
  var import_rpc4 = require("@dxos/rpc");
3642
- var import_util8 = require("@dxos/util");
3657
+ var import_util9 = require("@dxos/util");
3643
3658
  var __decorate5 = function(decorators, target, key, desc) {
3644
3659
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3645
3660
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -3654,8 +3669,8 @@ var WorkerSession = class {
3654
3669
  constructor({ serviceHost, systemPort, appPort, shellPort, readySignal, options = {
3655
3670
  heartbeatInterval: 1e3
3656
3671
  } }) {
3657
- this._startTrigger = new import_async17.Trigger();
3658
- this.onClose = new import_util8.Callback();
3672
+ this._startTrigger = new import_async18.Trigger();
3673
+ this.onClose = new import_util9.Callback();
3659
3674
  (0, import_node_assert12.default)(options);
3660
3675
  (0, import_node_assert12.default)(serviceHost);
3661
3676
  this._options = options;
@@ -3704,7 +3719,7 @@ var WorkerSession = class {
3704
3719
  try {
3705
3720
  await this.close();
3706
3721
  } catch (err) {
3707
- import_log15.log.catch(err, {}, {
3722
+ import_log16.log.catch(err, {}, {
3708
3723
  file: "worker-session.ts",
3709
3724
  line: 107,
3710
3725
  scope: this,
@@ -3722,7 +3737,7 @@ var WorkerSession = class {
3722
3737
  this.bridgeService = this._iframeRpc.rpc.BridgeService;
3723
3738
  }
3724
3739
  async open() {
3725
- import_log15.log.info("opening..", {}, {
3740
+ import_log16.log.info("opening..", {}, {
3726
3741
  file: "worker-session.ts",
3727
3742
  line: 121,
3728
3743
  scope: this,
@@ -3740,7 +3755,7 @@ var WorkerSession = class {
3740
3755
  try {
3741
3756
  await this._iframeRpc.rpc.IframeService.heartbeat();
3742
3757
  } catch (err1) {
3743
- import_log15.log.warn("Heartbeat failed", {
3758
+ import_log16.log.warn("Heartbeat failed", {
3744
3759
  err: err1
3745
3760
  }, {
3746
3761
  file: "worker-session.ts",
@@ -3751,7 +3766,7 @@ var WorkerSession = class {
3751
3766
  try {
3752
3767
  await this.close();
3753
3768
  } catch (err) {
3754
- import_log15.log.catch(err, {}, {
3769
+ import_log16.log.catch(err, {}, {
3755
3770
  file: "worker-session.ts",
3756
3771
  line: 137,
3757
3772
  scope: this,
@@ -3762,7 +3777,7 @@ var WorkerSession = class {
3762
3777
  }, this._options.heartbeatInterval);
3763
3778
  }
3764
3779
  async close() {
3765
- import_log15.log.info("closing..", {}, {
3780
+ import_log16.log.info("closing..", {}, {
3766
3781
  file: "worker-session.ts",
3767
3782
  line: 144,
3768
3783
  scope: this,
@@ -3771,7 +3786,7 @@ var WorkerSession = class {
3771
3786
  try {
3772
3787
  await this.onClose.callIfSet();
3773
3788
  } catch (err) {
3774
- import_log15.log.catch(err, {}, {
3789
+ import_log16.log.catch(err, {}, {
3775
3790
  file: "worker-session.ts",
3776
3791
  line: 148,
3777
3792
  scope: this,
@@ -3788,9 +3803,9 @@ var WorkerSession = class {
3788
3803
  }
3789
3804
  async _maybeOpenShell() {
3790
3805
  try {
3791
- await (0, import_async17.asyncTimeout)(this._shellClientRpc.open(), 1e3);
3806
+ await (0, import_async18.asyncTimeout)(this._shellClientRpc.open(), 1e3);
3792
3807
  } catch (e) {
3793
- import_log15.log.info("No shell connected.", {}, {
3808
+ import_log16.log.info("No shell connected.", {}, {
3794
3809
  file: "worker-session.ts",
3795
3810
  line: 162,
3796
3811
  scope: this,
@@ -3800,7 +3815,7 @@ var WorkerSession = class {
3800
3815
  }
3801
3816
  };
3802
3817
  __decorate5([
3803
- import_log15.logInfo
3818
+ import_log16.logInfo
3804
3819
  ], WorkerSession.prototype, "origin", void 0);
3805
3820
 
3806
3821
  // packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
@@ -3809,7 +3824,7 @@ var WorkerRuntime = class {
3809
3824
  constructor(_configProvider) {
3810
3825
  this._configProvider = _configProvider;
3811
3826
  this._transportFactory = new import_network_manager4.WebRTCTransportProxyFactory();
3812
- this._ready = new import_async18.Trigger();
3827
+ this._ready = new import_async19.Trigger();
3813
3828
  this.sessions = /* @__PURE__ */ new Set();
3814
3829
  this._clientServices = new ClientServicesHost();
3815
3830
  }
@@ -3817,7 +3832,7 @@ var WorkerRuntime = class {
3817
3832
  return this._clientServices;
3818
3833
  }
3819
3834
  async start() {
3820
- (0, import_log16.log)("starting...", {}, {
3835
+ (0, import_log17.log)("starting...", {}, {
3821
3836
  file: "worker-runtime.ts",
3822
3837
  line: 48,
3823
3838
  scope: this,
@@ -3836,7 +3851,7 @@ var WorkerRuntime = class {
3836
3851
  });
3837
3852
  await this._clientServices.open();
3838
3853
  this._ready.wake(void 0);
3839
- (0, import_log16.log)("started", {}, {
3854
+ (0, import_log17.log)("started", {}, {
3840
3855
  file: "worker-runtime.ts",
3841
3856
  line: 65,
3842
3857
  scope: this,
@@ -3844,7 +3859,7 @@ var WorkerRuntime = class {
3844
3859
  });
3845
3860
  } catch (err) {
3846
3861
  this._ready.wake(err);
3847
- import_log16.log.catch(err, {}, {
3862
+ import_log17.log.catch(err, {}, {
3848
3863
  file: "worker-runtime.ts",
3849
3864
  line: 68,
3850
3865
  scope: this,
@@ -3897,7 +3912,7 @@ var WorkerRuntime = class {
3897
3912
 
3898
3913
  // packages/sdk/client-services/src/packlets/services/service-context.ts
3899
3914
  var import_node_assert13 = __toESM(require("node:assert"));
3900
- var import_async19 = require("@dxos/async");
3915
+ var import_async20 = require("@dxos/async");
3901
3916
  var import_client7 = require("@dxos/client");
3902
3917
  var import_credentials11 = require("@dxos/credentials");
3903
3918
  var import_debug6 = require("@dxos/debug");
@@ -3905,7 +3920,7 @@ var import_echo_pipeline4 = require("@dxos/echo-pipeline");
3905
3920
  var import_feed_store4 = require("@dxos/feed-store");
3906
3921
  var import_keyring = require("@dxos/keyring");
3907
3922
  var import_keys10 = require("@dxos/keys");
3908
- var import_log17 = require("@dxos/log");
3923
+ var import_log18 = require("@dxos/log");
3909
3924
  var import_protocols7 = require("@dxos/protocols");
3910
3925
  var ServiceContext = class {
3911
3926
  // prettier-ignore
@@ -3913,7 +3928,7 @@ var ServiceContext = class {
3913
3928
  this.storage = storage;
3914
3929
  this.networkManager = networkManager;
3915
3930
  this.modelFactory = modelFactory;
3916
- this.initialized = new import_async19.Trigger();
3931
+ this.initialized = new import_async20.Trigger();
3917
3932
  this.dataServiceSubscriptions = new import_echo_pipeline4.DataServiceSubscriptions();
3918
3933
  this._handlerFactories = /* @__PURE__ */ new Map();
3919
3934
  this._instanceId = import_keys10.PublicKey.random().toHex();
@@ -3945,7 +3960,7 @@ var ServiceContext = class {
3945
3960
  }, this._acceptIdentity.bind(this)));
3946
3961
  }
3947
3962
  async open() {
3948
- import_log17.log.trace("dxos.sdk.service-context", import_protocols7.trace.begin({
3963
+ import_log18.log.trace("dxos.sdk.service-context", import_protocols7.trace.begin({
3949
3964
  id: this._instanceId
3950
3965
  }), {
3951
3966
  file: "service-context.ts",
@@ -3953,7 +3968,7 @@ var ServiceContext = class {
3953
3968
  scope: this,
3954
3969
  callSite: (f, a) => f(...a)
3955
3970
  });
3956
- (0, import_log17.log)("opening...", {}, {
3971
+ (0, import_log18.log)("opening...", {}, {
3957
3972
  file: "service-context.ts",
3958
3973
  line: 117,
3959
3974
  scope: this,
@@ -3965,7 +3980,7 @@ var ServiceContext = class {
3965
3980
  if (this.identityManager.identity) {
3966
3981
  await this._initialize();
3967
3982
  }
3968
- (0, import_log17.log)("opened", {}, {
3983
+ (0, import_log18.log)("opened", {}, {
3969
3984
  file: "service-context.ts",
3970
3985
  line: 124,
3971
3986
  scope: this,
@@ -3974,7 +3989,7 @@ var ServiceContext = class {
3974
3989
  }
3975
3990
  async close() {
3976
3991
  var _a, _b;
3977
- (0, import_log17.log)("closing...", {}, {
3992
+ (0, import_log18.log)("closing...", {}, {
3978
3993
  file: "service-context.ts",
3979
3994
  line: 128,
3980
3995
  scope: this,
@@ -3987,13 +4002,13 @@ var ServiceContext = class {
3987
4002
  await this.feedStore.close();
3988
4003
  await this.networkManager.close();
3989
4004
  this.dataServiceSubscriptions.clear();
3990
- (0, import_log17.log)("closed", {}, {
4005
+ (0, import_log18.log)("closed", {}, {
3991
4006
  file: "service-context.ts",
3992
4007
  line: 136,
3993
4008
  scope: this,
3994
4009
  callSite: (f, a) => f(...a)
3995
4010
  });
3996
- import_log17.log.trace("dxos.sdk.service-context", import_protocols7.trace.end({
4011
+ import_log18.log.trace("dxos.sdk.service-context", import_protocols7.trace.end({
3997
4012
  id: this._instanceId
3998
4013
  }), {
3999
4014
  file: "service-context.ts",
@@ -4020,7 +4035,7 @@ var ServiceContext = class {
4020
4035
  // Called when identity is created.
4021
4036
  async _initialize() {
4022
4037
  var _a;
4023
- (0, import_log17.log)("initializing spaces...", {}, {
4038
+ (0, import_log18.log)("initializing spaces...", {}, {
4024
4039
  file: "service-context.ts",
4025
4040
  line: 163,
4026
4041
  scope: this,
@@ -4058,7 +4073,7 @@ var ServiceContext = class {
4058
4073
  return;
4059
4074
  }
4060
4075
  if (!this.dataSpaceManager) {
4061
- (0, import_log17.log)("dataSpaceManager not initialized yet, ignoring space admission", {
4076
+ (0, import_log18.log)("dataSpaceManager not initialized yet, ignoring space admission", {
4062
4077
  details: assertion
4063
4078
  }, {
4064
4079
  file: "service-context.ts",
@@ -4069,7 +4084,7 @@ var ServiceContext = class {
4069
4084
  return;
4070
4085
  }
4071
4086
  if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
4072
- (0, import_log17.log)("space already exists, ignoring space admission", {
4087
+ (0, import_log18.log)("space already exists, ignoring space admission", {
4073
4088
  details: assertion
4074
4089
  }, {
4075
4090
  file: "service-context.ts",
@@ -4080,7 +4095,7 @@ var ServiceContext = class {
4080
4095
  return;
4081
4096
  }
4082
4097
  try {
4083
- (0, import_log17.log)("accepting space recorded in halo", {
4098
+ (0, import_log18.log)("accepting space recorded in halo", {
4084
4099
  details: assertion
4085
4100
  }, {
4086
4101
  file: "service-context.ts",
@@ -4093,7 +4108,7 @@ var ServiceContext = class {
4093
4108
  genesisFeedKey: assertion.genesisFeedKey
4094
4109
  });
4095
4110
  } catch (err) {
4096
- import_log17.log.catch(err, {}, {
4111
+ import_log18.log.catch(err, {}, {
4097
4112
  file: "service-context.ts",
4098
4113
  line: 220,
4099
4114
  scope: this,
@@ -4141,7 +4156,7 @@ var ClientServicesHost = class {
4141
4156
  // TODO(wittjosiah): Turn this on by default.
4142
4157
  lockKey
4143
4158
  } = {}) {
4144
- this._statusUpdate = new import_async20.Event();
4159
+ this._statusUpdate = new import_async21.Event();
4145
4160
  this._opening = false;
4146
4161
  this._open = false;
4147
4162
  this._instanceId = import_client8.PublicKey.random().toHex();
@@ -4176,6 +4191,7 @@ var ClientServicesHost = class {
4176
4191
  await this.reset();
4177
4192
  }
4178
4193
  });
4194
+ this._loggingService = new LoggingServiceImpl();
4179
4195
  this._serviceRegistry = new ServiceRegistry(import_client8.clientServiceBundle, {
4180
4196
  SystemService: this._systemService
4181
4197
  });
@@ -4216,11 +4232,11 @@ var ClientServicesHost = class {
4216
4232
  if (this._open) {
4217
4233
  return;
4218
4234
  }
4219
- import_log18.log.trace("dxos.sdk.client-services-host", import_protocols8.trace.begin({
4235
+ import_log19.log.trace("dxos.sdk.client-services-host", import_protocols8.trace.begin({
4220
4236
  id: this._instanceId
4221
4237
  }), {
4222
4238
  file: "service-host.ts",
4223
- line: 166,
4239
+ line: 169,
4224
4240
  scope: this,
4225
4241
  callSite: (f, a) => f(...a)
4226
4242
  });
@@ -4228,15 +4244,16 @@ var ClientServicesHost = class {
4228
4244
  (0, import_node_assert14.default)(this._storage, "storage not set");
4229
4245
  (0, import_node_assert14.default)(this._networkManager, "network manager not set");
4230
4246
  this._opening = true;
4231
- (0, import_log18.log)("opening...", {
4247
+ (0, import_log19.log)("opening...", {
4232
4248
  lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
4233
4249
  }, {
4234
4250
  file: "service-host.ts",
4235
- line: 173,
4251
+ line: 176,
4236
4252
  scope: this,
4237
4253
  callSite: (f, a) => f(...a)
4238
4254
  });
4239
4255
  await ((_b = this._resourceLock) == null ? void 0 : _b.acquire());
4256
+ await this._loggingService.open();
4240
4257
  this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._modelFactory);
4241
4258
  this._serviceRegistry.setServices({
4242
4259
  SystemService: this._systemService,
@@ -4249,8 +4266,8 @@ var ClientServicesHost = class {
4249
4266
  }),
4250
4267
  DataService: new import_echo_pipeline5.DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
4251
4268
  NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager),
4269
+ LoggingService: this._loggingService,
4252
4270
  // TODO(burdon): Move to new protobuf definitions.
4253
- TracingService: new TracingServiceImpl(this._config),
4254
4271
  DevtoolsHost: new DevtoolsServiceImpl({
4255
4272
  events: new DevtoolsHostEvents(),
4256
4273
  config: this._config,
@@ -4262,11 +4279,11 @@ var ClientServicesHost = class {
4262
4279
  this._open = true;
4263
4280
  this._statusUpdate.emit();
4264
4281
  const deviceKey = (_c = this._serviceContext.identityManager.identity) == null ? void 0 : _c.deviceKey;
4265
- (0, import_log18.log)("opened", {
4282
+ (0, import_log19.log)("opened", {
4266
4283
  deviceKey
4267
4284
  }, {
4268
4285
  file: "service-host.ts",
4269
- line: 220,
4286
+ line: 226,
4270
4287
  scope: this,
4271
4288
  callSite: (f, a) => f(...a)
4272
4289
  });
@@ -4277,50 +4294,51 @@ var ClientServicesHost = class {
4277
4294
  return;
4278
4295
  }
4279
4296
  const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
4280
- (0, import_log18.log)("closing...", {
4297
+ (0, import_log19.log)("closing...", {
4281
4298
  deviceKey
4282
4299
  }, {
4283
4300
  file: "service-host.ts",
4284
- line: 229,
4301
+ line: 235,
4285
4302
  scope: this,
4286
4303
  callSite: (f, a) => f(...a)
4287
4304
  });
4288
4305
  this._serviceRegistry.setServices({
4289
4306
  SystemService: this._systemService
4290
4307
  });
4308
+ await this._loggingService.close();
4291
4309
  await this._serviceContext.close();
4292
4310
  this._open = false;
4293
4311
  this._statusUpdate.emit();
4294
- (0, import_log18.log)("closed", {
4312
+ (0, import_log19.log)("closed", {
4295
4313
  deviceKey
4296
4314
  }, {
4297
4315
  file: "service-host.ts",
4298
- line: 234,
4316
+ line: 241,
4299
4317
  scope: this,
4300
4318
  callSite: (f, a) => f(...a)
4301
4319
  });
4302
- import_log18.log.trace("dxos.sdk.client-services-host", import_protocols8.trace.end({
4320
+ import_log19.log.trace("dxos.sdk.client-services-host", import_protocols8.trace.end({
4303
4321
  id: this._instanceId
4304
4322
  }), {
4305
4323
  file: "service-host.ts",
4306
- line: 236,
4324
+ line: 243,
4307
4325
  scope: this,
4308
4326
  callSite: (f, a) => f(...a)
4309
4327
  });
4310
4328
  }
4311
4329
  async reset() {
4312
4330
  var _a;
4313
- (0, import_log18.log)("resetting...", {}, {
4331
+ (0, import_log19.log)("resetting...", {}, {
4314
4332
  file: "service-host.ts",
4315
- line: 240,
4333
+ line: 247,
4316
4334
  scope: this,
4317
4335
  callSite: (f, a) => f(...a)
4318
4336
  });
4319
4337
  await ((_a = this._serviceContext) == null ? void 0 : _a.close());
4320
4338
  await this._storage.reset();
4321
- (0, import_log18.log)("reset", {}, {
4339
+ (0, import_log19.log)("reset", {}, {
4322
4340
  file: "service-host.ts",
4323
- line: 243,
4341
+ line: 250,
4324
4342
  scope: this,
4325
4343
  callSite: (f, a) => f(...a)
4326
4344
  });
@@ -4351,7 +4369,7 @@ var LocalClientServices = class {
4351
4369
 
4352
4370
  // packages/sdk/client-services/src/packlets/services/utils.ts
4353
4371
  var import_config2 = require("@dxos/config");
4354
- var import_log19 = require("@dxos/log");
4372
+ var import_log20 = require("@dxos/log");
4355
4373
  var import_messaging3 = require("@dxos/messaging");
4356
4374
  var import_network_manager5 = require("@dxos/network-manager");
4357
4375
  var fromHost = (config = new import_config2.Config()) => {
@@ -4372,7 +4390,7 @@ var createNetworkManager = (config, options = {}) => {
4372
4390
  transportFactory
4373
4391
  });
4374
4392
  }
4375
- import_log19.log.warn("P2P network is not configured.", {}, {
4393
+ import_log20.log.warn("P2P network is not configured.", {}, {
4376
4394
  file: "utils.ts",
4377
4395
  line: 48,
4378
4396
  scope: void 0,