@dxos/client-services 0.1.51-main.e7215ae → 0.1.51-next.5787f10

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 (37) hide show
  1. package/dist/lib/browser/{chunk-5W2L64HI.mjs → chunk-2GQ7337P.mjs} +105 -49
  2. package/dist/lib/browser/chunk-2GQ7337P.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 +8 -2
  6. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  7. package/dist/lib/node/index.cjs +122 -66
  8. package/dist/lib/node/index.cjs.map +3 -3
  9. package/dist/lib/node/meta.json +1 -1
  10. package/dist/lib/node/packlets/testing/index.cjs +146 -84
  11. package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
  12. package/dist/types/src/packlets/devtools/devtools.d.ts +2 -1
  13. package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
  14. package/dist/types/src/packlets/devtools/feeds.d.ts.map +1 -1
  15. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  16. package/dist/types/src/packlets/logging/logging-service.d.ts +1 -1
  17. package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
  18. package/dist/types/src/packlets/services/service-context.d.ts +5 -0
  19. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  20. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  21. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  22. package/dist/types/src/packlets/testing/test-builder.d.ts +3 -0
  23. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  24. package/package.json +31 -30
  25. package/src/packlets/devtools/devtools.ts +7 -0
  26. package/src/packlets/devtools/feeds.ts +1 -0
  27. package/src/packlets/identity/identity-manager.test.ts +4 -1
  28. package/src/packlets/identity/identity-manager.ts +4 -1
  29. package/src/packlets/identity/identity.test.ts +40 -15
  30. package/src/packlets/logging/logging-service.ts +58 -15
  31. package/src/packlets/services/service-context.ts +7 -0
  32. package/src/packlets/spaces/data-space-manager.test.ts +64 -1
  33. package/src/packlets/spaces/data-space-manager.ts +2 -2
  34. package/src/packlets/spaces/data-space.ts +8 -3
  35. package/src/packlets/spaces/spaces-service.ts +7 -0
  36. package/src/packlets/testing/test-builder.ts +7 -0
  37. package/dist/lib/browser/chunk-5W2L64HI.mjs.map +0 -7
@@ -63,7 +63,7 @@ var createMockCredential = async ({ signer, issuer }) => (0, import_credentials.
63
63
  // packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
64
64
  var import_node_assert13 = __toESM(require("node:assert"));
65
65
  var import_async19 = require("@dxos/async");
66
- var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
66
+ var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
67
67
 
68
68
  // packages/sdk/client-services/src/packlets/services/service-host.ts
69
69
  var import_node_assert12 = __toESM(require("node:assert"));
@@ -75,7 +75,7 @@ var import_log15 = require("@dxos/log");
75
75
  var import_messaging = require("@dxos/messaging");
76
76
  var import_network_manager2 = require("@dxos/network-manager");
77
77
  var import_protocols9 = require("@dxos/protocols");
78
- var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
78
+ var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
79
79
 
80
80
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
81
81
  var import_async = require("@dxos/async");
@@ -148,11 +148,15 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
148
148
  }
149
149
  });
150
150
  next({
151
- feeds: Array.from(feedMap.values()).map((feed) => ({
152
- feedKey: feed.key,
153
- length: feed.properties.length,
154
- bytes: feed.core.byteLength
155
- }))
151
+ feeds: Array.from(feedMap.values()).map((feed) => {
152
+ var _a, _b;
153
+ return {
154
+ feedKey: feed.key,
155
+ length: feed.properties.length,
156
+ bytes: feed.core.byteLength,
157
+ downloaded: (_b = (_a = feed.core.bitfield) == null ? void 0 : _a.data.toBuffer()) != null ? _b : new Uint8Array()
158
+ };
159
+ })
156
160
  });
157
161
  };
158
162
  subscriptions.add(feedStore.feedOpened.on(update));
@@ -351,6 +355,11 @@ var DevtoolsServiceImpl = class {
351
355
  usageQuota: (_e = navigatorInfo == null ? void 0 : navigatorInfo.quota) != null ? _e : 0
352
356
  };
353
357
  }
358
+ async getBlobs() {
359
+ return {
360
+ blobs: await this.params.context.blobStore.list()
361
+ };
362
+ }
354
363
  async getSnapshots() {
355
364
  return {
356
365
  snapshots: await this.params.context.snapshotStore.listSnapshots()
@@ -891,7 +900,8 @@ var IdentityManager = class {
891
900
  });
892
901
  (0, import_node_assert2.default)(identityRecord.haloSpace.dataFeedKey);
893
902
  const dataFeed = await this._feedStore.openFeed(identityRecord.haloSpace.dataFeedKey, {
894
- writable: true
903
+ writable: true,
904
+ sparse: true
895
905
  });
896
906
  const space = await this._constructSpace({
897
907
  spaceRecord: identityRecord.haloSpace,
@@ -914,7 +924,7 @@ var IdentityManager = class {
914
924
  identityKey: identityRecord.identityKey
915
925
  }, {
916
926
  file: "identity-manager.ts",
917
- line: 223,
927
+ line: 226,
918
928
  scope: this,
919
929
  callSite: (f, a) => f(...a)
920
930
  });
@@ -935,7 +945,7 @@ var IdentityManager = class {
935
945
  onAuthFailure: () => {
936
946
  import_log3.log.warn("auth failure", {}, {
937
947
  file: "identity-manager.ts",
938
- line: 242,
948
+ line: 245,
939
949
  scope: this,
940
950
  callSite: (f, a) => f(...a)
941
951
  });
@@ -2214,6 +2224,7 @@ __decorate([
2214
2224
  var import_async12 = require("@dxos/async");
2215
2225
  var import_codec_protobuf10 = require("@dxos/codec-protobuf");
2216
2226
  var import_log9 = require("@dxos/log");
2227
+ var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
2217
2228
  var import_util3 = require("@dxos/util");
2218
2229
  var LoggingServiceImpl = class {
2219
2230
  constructor() {
@@ -2230,31 +2241,60 @@ var LoggingServiceImpl = class {
2230
2241
  import_log9.log.runtimeConfig.processors.splice(index, 1);
2231
2242
  }
2232
2243
  queryLogs(request) {
2233
- var _a;
2234
- const filters = ((_a = request.filters) == null ? void 0 : _a.length) ? request.filters : void 0;
2235
2244
  return new import_codec_protobuf10.Stream(({ ctx, next }) => {
2236
2245
  const handler = (entry2) => {
2237
- var _a2, _b, _c;
2238
- 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"))) {
2246
+ var _a, _b, _c, _d, _e;
2247
+ if (LOG_PROCESSING > 0) {
2239
2248
  return;
2240
2249
  }
2241
- if ((0, import_log9.shouldLog)(entry2, filters)) {
2242
- const record = {
2243
- ...entry2,
2244
- context: (0, import_util3.jsonify)((0, import_log9.getContextFromEntry)(entry2))
2245
- };
2246
- (_b = record.meta) == null ? true : delete _b.bugcheck;
2247
- (_c = record.meta) == null ? true : delete _c.scope;
2250
+ if (((_a = entry2.meta) == null ? void 0 : _a.file.includes("logging-service")) || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
2251
+ return;
2252
+ }
2253
+ if (!shouldLog(entry2, request)) {
2254
+ return;
2255
+ }
2256
+ const record = {
2257
+ ...entry2,
2258
+ context: (0, import_util3.jsonify)((0, import_log9.getContextFromEntry)(entry2)),
2259
+ timestamp: new Date(),
2260
+ meta: {
2261
+ // TODO(dmaretskyi): Fix proto.
2262
+ file: (_c = (_b = entry2.meta) == null ? void 0 : _b.file) != null ? _c : "",
2263
+ line: (_e = (_d = entry2.meta) == null ? void 0 : _d.line) != null ? _e : 0
2264
+ }
2265
+ };
2266
+ try {
2267
+ LOG_PROCESSING++;
2248
2268
  next(record);
2269
+ } finally {
2270
+ LOG_PROCESSING--;
2249
2271
  }
2250
2272
  };
2251
- ctx.onDispose(() => {
2252
- this._logs.off(handler);
2253
- });
2254
- this._logs.on(handler);
2273
+ this._logs.on(ctx, handler);
2274
+ });
2275
+ }
2276
+ };
2277
+ var matchFilter = (filter, level, path, options) => {
2278
+ switch (options) {
2279
+ case import_services7.QueryLogsRequest.MatchingOptions.INCLUSIVE:
2280
+ return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));
2281
+ case import_services7.QueryLogsRequest.MatchingOptions.EXPLICIT:
2282
+ return level === filter.level && (!filter.pattern || path.includes(filter.pattern));
2283
+ }
2284
+ };
2285
+ var shouldLog = (entry2, request) => {
2286
+ var _a;
2287
+ const options = (_a = request.options) != null ? _a : import_services7.QueryLogsRequest.MatchingOptions.INCLUSIVE;
2288
+ if (request.filters === void 0) {
2289
+ return options === import_services7.QueryLogsRequest.MatchingOptions.INCLUSIVE;
2290
+ } else {
2291
+ return request.filters.some((filter) => {
2292
+ var _a2, _b;
2293
+ return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.file) != null ? _b : "", options);
2255
2294
  });
2256
2295
  }
2257
2296
  };
2297
+ var LOG_PROCESSING = 0;
2258
2298
 
2259
2299
  // packages/sdk/client-services/src/packlets/network/network-service.ts
2260
2300
  var import_codec_protobuf11 = require("@dxos/codec-protobuf");
@@ -2296,7 +2336,7 @@ var import_credentials13 = require("@dxos/credentials");
2296
2336
  var import_keys10 = require("@dxos/keys");
2297
2337
  var import_log12 = require("@dxos/log");
2298
2338
  var import_protocols6 = require("@dxos/protocols");
2299
- var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
2339
+ var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
2300
2340
  var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
2301
2341
  var import_util6 = require("@dxos/util");
2302
2342
 
@@ -2309,8 +2349,9 @@ var import_echo_pipeline = require("@dxos/echo-pipeline");
2309
2349
  var import_errors3 = require("@dxos/errors");
2310
2350
  var import_keys9 = require("@dxos/keys");
2311
2351
  var import_log11 = require("@dxos/log");
2312
- var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
2352
+ var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
2313
2353
  var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
2354
+ var import_timeframe = require("@dxos/timeframe");
2314
2355
  var import_util5 = require("@dxos/util");
2315
2356
 
2316
2357
  // packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
@@ -2569,7 +2610,7 @@ var __decorate2 = function(decorators, target, key, desc) {
2569
2610
  var DataSpace = class DataSpace2 {
2570
2611
  constructor(params) {
2571
2612
  this._ctx = new import_context6.Context();
2572
- this._state = import_services7.SpaceState.CLOSED;
2613
+ this._state = import_services8.SpaceState.CLOSED;
2573
2614
  /**
2574
2615
  * Error for _state === SpaceState.ERROR.
2575
2616
  */
@@ -2623,11 +2664,11 @@ var DataSpace = class DataSpace2 {
2623
2664
  await this.notarizationPlugin.open();
2624
2665
  await this._notarizationPluginConsumer.open();
2625
2666
  await this._inner.open();
2626
- this._state = import_services7.SpaceState.INACTIVE;
2667
+ this._state = import_services8.SpaceState.INACTIVE;
2627
2668
  this.metrics.open = new Date();
2628
2669
  }
2629
2670
  async close() {
2630
- this._state = import_services7.SpaceState.CLOSED;
2671
+ this._state = import_services8.SpaceState.CLOSED;
2631
2672
  await this._ctx.dispose();
2632
2673
  await this.authVerifier.close();
2633
2674
  await this._inner.close();
@@ -2653,7 +2694,7 @@ var DataSpace = class DataSpace2 {
2653
2694
  if (err instanceof import_errors3.CancelledError) {
2654
2695
  (0, import_log11.log)("Data pipeline initialization cancelled", err, {
2655
2696
  file: "data-space.ts",
2656
- line: 172,
2697
+ line: 173,
2657
2698
  scope: this,
2658
2699
  callSite: (f, a) => f(...a)
2659
2700
  });
@@ -2661,11 +2702,11 @@ var DataSpace = class DataSpace2 {
2661
2702
  }
2662
2703
  import_log11.log.error("Error initializing data pipeline", err, {
2663
2704
  file: "data-space.ts",
2664
- line: 176,
2705
+ line: 177,
2665
2706
  scope: this,
2666
2707
  callSite: (f, a) => f(...a)
2667
2708
  });
2668
- this._state = import_services7.SpaceState.ERROR;
2709
+ this._state = import_services8.SpaceState.ERROR;
2669
2710
  this.error = err;
2670
2711
  this.stateUpdate.emit();
2671
2712
  } finally {
@@ -2675,10 +2716,10 @@ var DataSpace = class DataSpace2 {
2675
2716
  }
2676
2717
  async initializeDataPipeline() {
2677
2718
  var _a, _b, _c, _d;
2678
- if (this._state !== import_services7.SpaceState.INACTIVE) {
2719
+ if (this._state !== import_services8.SpaceState.INACTIVE) {
2679
2720
  throw new import_errors3.SystemError("Invalid operation");
2680
2721
  }
2681
- this._state = import_services7.SpaceState.INITIALIZING;
2722
+ this._state = import_services8.SpaceState.INITIALIZING;
2682
2723
  await this._inner.controlPipeline.state.waitUntilReachedTargetTimeframe({
2683
2724
  ctx: this._ctx,
2684
2725
  breakOnStall: false
@@ -2718,7 +2759,7 @@ var DataSpace = class DataSpace2 {
2718
2759
  callSite: (f, a) => f(...a)
2719
2760
  });
2720
2761
  await ((_b = (_a = this._callbacks).beforeReady) == null ? void 0 : _b.call(_a));
2721
- this._state = import_services7.SpaceState.READY;
2762
+ this._state = import_services8.SpaceState.READY;
2722
2763
  this.stateUpdate.emit();
2723
2764
  await ((_d = (_c = this._callbacks).afterReady) == null ? void 0 : _d.call(_c));
2724
2765
  }
@@ -2742,7 +2783,8 @@ var DataSpace = class DataSpace2 {
2742
2783
  }
2743
2784
  if (!this.inner.dataFeedKey) {
2744
2785
  const dataFeed = await this._feedStore.openFeed(await this._keyring.createKey(), {
2745
- writable: true
2786
+ writable: true,
2787
+ sparse: true
2746
2788
  });
2747
2789
  this.inner.setDataFeed(dataFeed);
2748
2790
  credentials.push(await this._signingContext.credentialSigner.createCredential({
@@ -2768,7 +2810,7 @@ var DataSpace = class DataSpace2 {
2768
2810
  async createEpoch() {
2769
2811
  var _a, _b;
2770
2812
  const epoch = await this.dataPipeline.createEpoch();
2771
- await this.inner.controlPipeline.writer.write({
2813
+ const receipt = await this.inner.controlPipeline.writer.write({
2772
2814
  credential: {
2773
2815
  credential: await this._signingContext.credentialSigner.createCredential({
2774
2816
  subject: this.key,
@@ -2779,6 +2821,12 @@ var DataSpace = class DataSpace2 {
2779
2821
  })
2780
2822
  }
2781
2823
  });
2824
+ await this.inner.controlPipeline.state.waitUntilTimeframe(new import_timeframe.Timeframe([
2825
+ [
2826
+ receipt.feedKey,
2827
+ receipt.seq
2828
+ ]
2829
+ ]));
2782
2830
  for (const feed of (_b = (_a = this.inner.dataPipeline.pipelineState) == null ? void 0 : _a.feeds) != null ? _b : []) {
2783
2831
  const indexBeforeEpoch = epoch.timeframe.get(feed.key);
2784
2832
  if (indexBeforeEpoch) {
@@ -2798,7 +2846,7 @@ DataSpace = __decorate2([
2798
2846
  var import_credentials11 = require("@dxos/credentials");
2799
2847
  var import_debug4 = require("@dxos/debug");
2800
2848
  var import_credentials12 = require("@dxos/protocols/proto/dxos/halo/credentials");
2801
- var import_timeframe = require("@dxos/timeframe");
2849
+ var import_timeframe2 = require("@dxos/timeframe");
2802
2850
  var spaceGenesis = async (keyring, signingContext, space) => {
2803
2851
  var _a, _b, _c, _d;
2804
2852
  const credentials = [
@@ -2849,7 +2897,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
2849
2897
  "@type": "dxos.halo.credentials.Epoch",
2850
2898
  number: 0,
2851
2899
  previousId: void 0,
2852
- timeframe: new import_timeframe.Timeframe(),
2900
+ timeframe: new import_timeframe2.Timeframe(),
2853
2901
  snapshotCid: void 0
2854
2902
  }
2855
2903
  })
@@ -3029,7 +3077,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3029
3077
  async waitUntilSpaceReady(spaceKey) {
3030
3078
  await (0, import_context7.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
3031
3079
  const space = this._spaces.get(spaceKey);
3032
- return !!space && space.state === import_services8.SpaceState.READY;
3080
+ return !!space && space.state === import_services9.SpaceState.READY;
3033
3081
  }));
3034
3082
  }
3035
3083
  async _constructSpace(metadata) {
@@ -3054,7 +3102,8 @@ var DataSpaceManager = class DataSpaceManager2 {
3054
3102
  writable: true
3055
3103
  });
3056
3104
  const dataFeed = metadata.dataFeedKey && await this._feedStore.openFeed(metadata.dataFeedKey, {
3057
- writable: true
3105
+ writable: true,
3106
+ sparse: true
3058
3107
  });
3059
3108
  const space = await this._spaceManager.constructSpace({
3060
3109
  metadata,
@@ -3067,7 +3116,6 @@ var DataSpaceManager = class DataSpaceManager2 {
3067
3116
  session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
3068
3117
  remotePeerId: session.remotePeerId
3069
3118
  }));
3070
- session.addExtension("dxos.mesh.teleport.objectsync", space.snapshotManager.objectSync.createExtension());
3071
3119
  session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
3072
3120
  },
3073
3121
  onAuthFailure: () => {
@@ -3153,7 +3201,7 @@ var import_debug5 = require("@dxos/debug");
3153
3201
  var import_echo_pipeline2 = require("@dxos/echo-pipeline");
3154
3202
  var import_log13 = require("@dxos/log");
3155
3203
  var import_protocols7 = require("@dxos/protocols");
3156
- var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
3204
+ var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
3157
3205
  var import_util7 = require("@dxos/util");
3158
3206
  var TIMEFRAME_UPDATE_DEBOUNCE_TIME = 500;
3159
3207
  var SpacesServiceImpl = class {
@@ -3183,7 +3231,7 @@ var SpacesServiceImpl = class {
3183
3231
  spaces
3184
3232
  }, {
3185
3233
  file: "spaces-service.ts",
3186
- line: 59,
3234
+ line: 60,
3187
3235
  scope: this,
3188
3236
  callSite: (f, a) => f(...a)
3189
3237
  });
@@ -3200,6 +3248,7 @@ var SpacesServiceImpl = class {
3200
3248
  for (const space of dataSpaceManager.spaces.values()) {
3201
3249
  subscriptions.add(space.stateUpdate.on(ctx, onUpdate));
3202
3250
  subscriptions.add(space.presence.updated.on(ctx, onUpdate));
3251
+ subscriptions.add(space.dataPipeline.onNewEpoch.on(ctx, onUpdate));
3203
3252
  space.inner.controlPipeline.state.timeframeUpdate.debounce(TIMEFRAME_UPDATE_DEBOUNCE_TIME).on(ctx, onUpdate);
3204
3253
  if (space.dataPipeline.pipelineState) {
3205
3254
  subscriptions.add(space.dataPipeline.pipelineState.timeframeUpdate.debounce(TIMEFRAME_UPDATE_DEBOUNCE_TIME).on(ctx, onUpdate));
@@ -3270,20 +3319,23 @@ var SpacesServiceImpl = class {
3270
3319
  await space.createEpoch();
3271
3320
  }
3272
3321
  _transformSpace(space) {
3273
- var _a, _b, _c, _d, _e;
3322
+ var _a, _b, _c, _d, _e, _f, _g;
3274
3323
  return {
3275
3324
  spaceKey: space.key,
3276
3325
  state: space.state,
3277
3326
  error: space.error ? (0, import_protocols7.encodeError)(space.error) : void 0,
3278
3327
  pipeline: {
3328
+ currentEpoch: space.dataPipeline.currentEpoch,
3329
+ appliedEpoch: space.dataPipeline.appliedEpoch,
3279
3330
  controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
3280
3331
  currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
3281
3332
  targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
3282
3333
  totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
3283
3334
  dataFeeds: (_b = (_a = space.dataPipeline.pipelineState) == null ? void 0 : _a.feeds.map((feed) => feed.key)) != null ? _b : [],
3284
- currentDataTimeframe: (_c = space.dataPipeline.pipelineState) == null ? void 0 : _c.timeframe,
3285
- targetDataTimeframe: (_d = space.dataPipeline.pipelineState) == null ? void 0 : _d.targetTimeframe,
3286
- totalDataTimeframe: (_e = space.dataPipeline.pipelineState) == null ? void 0 : _e.endTimeframe
3335
+ startDataTimeframe: (_c = space.dataPipeline.pipelineState) == null ? void 0 : _c.startTimeframe,
3336
+ currentDataTimeframe: (_d = space.dataPipeline.pipelineState) == null ? void 0 : _d.timeframe,
3337
+ targetDataTimeframe: (_e = space.dataPipeline.pipelineState) == null ? void 0 : _e.targetTimeframe,
3338
+ totalDataTimeframe: (_f = space.dataPipeline.pipelineState) == null ? void 0 : _f.endTimeframe
3287
3339
  },
3288
3340
  members: Array.from(space.inner.spaceState.members.values()).map((member) => {
3289
3341
  var _a2, _b2, _c2;
@@ -3294,9 +3346,10 @@ var SpacesServiceImpl = class {
3294
3346
  displayName: (_b2 = (_a2 = member.assertion.profile) == null ? void 0 : _a2.displayName) != null ? _b2 : (0, import_util7.humanize)(member.key)
3295
3347
  }
3296
3348
  },
3297
- presence: ((_c2 = this._identityManager.identity) == null ? void 0 : _c2.identityKey.equals(member.key)) || space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services9.SpaceMember.PresenceState.ONLINE : import_services9.SpaceMember.PresenceState.OFFLINE
3349
+ presence: ((_c2 = this._identityManager.identity) == null ? void 0 : _c2.identityKey.equals(member.key)) || space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services10.SpaceMember.PresenceState.ONLINE : import_services10.SpaceMember.PresenceState.OFFLINE
3298
3350
  };
3299
3351
  }),
3352
+ creator: (_g = space.inner.spaceState.creator) == null ? void 0 : _g.key,
3300
3353
  cache: space.cache,
3301
3354
  metrics: space.metrics
3302
3355
  };
@@ -3402,7 +3455,8 @@ var import_keyring = require("@dxos/keyring");
3402
3455
  var import_keys11 = require("@dxos/keys");
3403
3456
  var import_log14 = require("@dxos/log");
3404
3457
  var import_protocols8 = require("@dxos/protocols");
3405
- var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
3458
+ var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
3459
+ var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
3406
3460
  var ServiceContext = class {
3407
3461
  // prettier-ignore
3408
3462
  constructor(storage, networkManager, signalManager, modelFactory) {
@@ -3416,6 +3470,7 @@ var ServiceContext = class {
3416
3470
  this._instanceId = import_keys11.PublicKey.random().toHex();
3417
3471
  this.metadataStore = new import_echo_pipeline3.MetadataStore(storage.createDirectory("metadata"));
3418
3472
  this.snapshotStore = new import_echo_pipeline3.SnapshotStore(storage.createDirectory("snapshots"));
3473
+ this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
3419
3474
  this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
3420
3475
  this.feedStore = new import_feed_store4.FeedStore({
3421
3476
  factory: new import_feed_store4.FeedFactory({
@@ -3429,13 +3484,14 @@ var ServiceContext = class {
3429
3484
  this.spaceManager = new import_echo_pipeline3.SpaceManager({
3430
3485
  feedStore: this.feedStore,
3431
3486
  networkManager: this.networkManager,
3487
+ blobStore: this.blobStore,
3432
3488
  metadataStore: this.metadataStore,
3433
3489
  modelFactory: this.modelFactory,
3434
3490
  snapshotStore: this.snapshotStore
3435
3491
  });
3436
3492
  this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
3437
3493
  this.invitations = new InvitationsHandler(this.networkManager);
3438
- this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
3494
+ this._handlerFactories.set(import_services11.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
3439
3495
  var _a;
3440
3496
  return (_a = this.identityManager.identity) != null ? _a : (0, import_debug6.failUndefined)();
3441
3497
  }, this._acceptIdentity.bind(this)));
@@ -3445,14 +3501,14 @@ var ServiceContext = class {
3445
3501
  id: this._instanceId
3446
3502
  }), {
3447
3503
  file: "service-context.ts",
3448
- line: 119,
3504
+ line: 126,
3449
3505
  scope: this,
3450
3506
  callSite: (f, a) => f(...a)
3451
3507
  });
3452
3508
  await this._checkStorageVersion();
3453
3509
  (0, import_log14.log)("opening...", {}, {
3454
3510
  file: "service-context.ts",
3455
- line: 123,
3511
+ line: 130,
3456
3512
  scope: this,
3457
3513
  callSite: (f, a) => f(...a)
3458
3514
  });
@@ -3465,7 +3521,7 @@ var ServiceContext = class {
3465
3521
  }
3466
3522
  (0, import_log14.log)("opened", {}, {
3467
3523
  file: "service-context.ts",
3468
- line: 131,
3524
+ line: 138,
3469
3525
  scope: this,
3470
3526
  callSite: (f, a) => f(...a)
3471
3527
  });
@@ -3473,7 +3529,7 @@ var ServiceContext = class {
3473
3529
  id: this._instanceId
3474
3530
  }), {
3475
3531
  file: "service-context.ts",
3476
- line: 132,
3532
+ line: 139,
3477
3533
  scope: this,
3478
3534
  callSite: (f, a) => f(...a)
3479
3535
  });
@@ -3482,7 +3538,7 @@ var ServiceContext = class {
3482
3538
  var _a, _b;
3483
3539
  (0, import_log14.log)("closing...", {}, {
3484
3540
  file: "service-context.ts",
3485
- line: 136,
3541
+ line: 143,
3486
3542
  scope: this,
3487
3543
  callSite: (f, a) => f(...a)
3488
3544
  });
@@ -3496,7 +3552,7 @@ var ServiceContext = class {
3496
3552
  this.dataServiceSubscriptions.clear();
3497
3553
  (0, import_log14.log)("closed", {}, {
3498
3554
  file: "service-context.ts",
3499
- line: 145,
3555
+ line: 152,
3500
3556
  scope: this,
3501
3557
  callSite: (f, a) => f(...a)
3502
3558
  });
@@ -3527,7 +3583,7 @@ var ServiceContext = class {
3527
3583
  var _a;
3528
3584
  (0, import_log14.log)("initializing spaces...", {}, {
3529
3585
  file: "service-context.ts",
3530
- line: 178,
3586
+ line: 185,
3531
3587
  scope: this,
3532
3588
  callSite: (f, a) => f(...a)
3533
3589
  });
@@ -3547,7 +3603,7 @@ var ServiceContext = class {
3547
3603
  };
3548
3604
  this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
3549
3605
  await this.dataSpaceManager.open();
3550
- this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
3606
+ this._handlerFactories.set(import_services11.Invitation.Kind.SPACE, (invitation) => {
3551
3607
  (0, import_node_assert11.default)(this.dataSpaceManager, "dataSpaceManager not initialized yet");
3552
3608
  return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
3553
3609
  });
@@ -3566,7 +3622,7 @@ var ServiceContext = class {
3566
3622
  details: assertion
3567
3623
  }, {
3568
3624
  file: "service-context.ts",
3569
- line: 217,
3625
+ line: 224,
3570
3626
  scope: this,
3571
3627
  callSite: (f, a) => f(...a)
3572
3628
  });
@@ -3577,7 +3633,7 @@ var ServiceContext = class {
3577
3633
  details: assertion
3578
3634
  }, {
3579
3635
  file: "service-context.ts",
3580
- line: 221,
3636
+ line: 228,
3581
3637
  scope: this,
3582
3638
  callSite: (f, a) => f(...a)
3583
3639
  });
@@ -3588,7 +3644,7 @@ var ServiceContext = class {
3588
3644
  details: assertion
3589
3645
  }, {
3590
3646
  file: "service-context.ts",
3591
- line: 226,
3647
+ line: 233,
3592
3648
  scope: this,
3593
3649
  callSite: (f, a) => f(...a)
3594
3650
  });
@@ -3599,7 +3655,7 @@ var ServiceContext = class {
3599
3655
  } catch (err) {
3600
3656
  import_log14.log.catch(err, {}, {
3601
3657
  file: "service-context.ts",
3602
- line: 232,
3658
+ line: 239,
3603
3659
  scope: this,
3604
3660
  callSite: (f, a) => f(...a)
3605
3661
  });
@@ -3673,12 +3729,12 @@ var ClientServicesHost = class {
3673
3729
  this._systemService = new SystemServiceImpl({
3674
3730
  config: this._config,
3675
3731
  statusUpdate: this._statusUpdate,
3676
- getCurrentStatus: () => this.isOpen ? import_services11.SystemStatus.ACTIVE : import_services11.SystemStatus.INACTIVE,
3732
+ getCurrentStatus: () => this.isOpen ? import_services12.SystemStatus.ACTIVE : import_services12.SystemStatus.INACTIVE,
3677
3733
  onUpdateStatus: async (status) => {
3678
3734
  var _a, _b;
3679
- if (!this.isOpen && status === import_services11.SystemStatus.ACTIVE) {
3735
+ if (!this.isOpen && status === import_services12.SystemStatus.ACTIVE) {
3680
3736
  await ((_a = this._resourceLock) == null ? void 0 : _a.acquire());
3681
- } else if (this.isOpen && status === import_services11.SystemStatus.INACTIVE) {
3737
+ } else if (this.isOpen && status === import_services12.SystemStatus.INACTIVE) {
3682
3738
  await ((_b = this._resourceLock) == null ? void 0 : _b.release());
3683
3739
  }
3684
3740
  },
@@ -3886,7 +3942,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
3886
3942
  hostObservable.subscribe(async (hostInvitation) => {
3887
3943
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
3888
3944
  switch (hostInvitation.state) {
3889
- case import_services12.Invitation.State.CONNECTING: {
3945
+ case import_services13.Invitation.State.CONNECTING: {
3890
3946
  if ((_b = (_a = hooks == null ? void 0 : hooks.host) == null ? void 0 : _a.onConnecting) == null ? void 0 : _b.call(_a, hostObservable)) {
3891
3947
  break;
3892
3948
  }
@@ -3894,29 +3950,29 @@ var performInvitation = ({ host, guest, options, hooks }) => {
3894
3950
  guestObservable.subscribe(async (guestInvitation) => {
3895
3951
  var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2;
3896
3952
  switch (guestInvitation.state) {
3897
- case import_services12.Invitation.State.CONNECTING: {
3953
+ case import_services13.Invitation.State.CONNECTING: {
3898
3954
  if ((_b2 = (_a2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _a2.onConnecting) == null ? void 0 : _b2.call(_a2, guestObservable)) {
3899
3955
  break;
3900
3956
  }
3901
3957
  (0, import_node_assert13.default)(hostInvitation.swarmKey.equals(guestInvitation.swarmKey));
3902
3958
  break;
3903
3959
  }
3904
- case import_services12.Invitation.State.CONNECTED: {
3960
+ case import_services13.Invitation.State.CONNECTED: {
3905
3961
  (_d2 = (_c2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _c2.onConnected) == null ? void 0 : _d2.call(_c2, guestObservable);
3906
3962
  break;
3907
3963
  }
3908
- case import_services12.Invitation.State.READY_FOR_AUTHENTICATION: {
3964
+ case import_services13.Invitation.State.READY_FOR_AUTHENTICATION: {
3909
3965
  if ((_f2 = (_e2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _e2.onReady) == null ? void 0 : _f2.call(_e2, guestObservable)) {
3910
3966
  break;
3911
3967
  }
3912
3968
  await guestObservable.authenticate(await authCode.wait());
3913
3969
  break;
3914
3970
  }
3915
- case import_services12.Invitation.State.AUTHENTICATING: {
3971
+ case import_services13.Invitation.State.AUTHENTICATING: {
3916
3972
  (_h2 = (_g2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _g2.onAuthenticating) == null ? void 0 : _h2.call(_g2, guestObservable);
3917
3973
  break;
3918
3974
  }
3919
- case import_services12.Invitation.State.SUCCESS: {
3975
+ case import_services13.Invitation.State.SUCCESS: {
3920
3976
  if ((_j2 = (_i2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _i2.onSuccess) == null ? void 0 : _j2.call(_i2, guestObservable)) {
3921
3977
  break;
3922
3978
  }
@@ -3925,7 +3981,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
3925
3981
  });
3926
3982
  break;
3927
3983
  }
3928
- case import_services12.Invitation.State.CANCELLED: {
3984
+ case import_services13.Invitation.State.CANCELLED: {
3929
3985
  if ((_l2 = (_k2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _k2.onCancelled) == null ? void 0 : _l2.call(_k2, guestObservable)) {
3930
3986
  break;
3931
3987
  }
@@ -3934,7 +3990,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
3934
3990
  });
3935
3991
  break;
3936
3992
  }
3937
- case import_services12.Invitation.State.TIMEOUT: {
3993
+ case import_services13.Invitation.State.TIMEOUT: {
3938
3994
  if ((_n2 = (_m2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _m2.onTimeout) == null ? void 0 : _n2.call(_m2, guestObservable)) {
3939
3995
  return;
3940
3996
  }
@@ -3954,11 +4010,11 @@ var performInvitation = ({ host, guest, options, hooks }) => {
3954
4010
  });
3955
4011
  break;
3956
4012
  }
3957
- case import_services12.Invitation.State.CONNECTED: {
4013
+ case import_services13.Invitation.State.CONNECTED: {
3958
4014
  (_d = (_c = hooks == null ? void 0 : hooks.host) == null ? void 0 : _c.onConnected) == null ? void 0 : _d.call(_c, hostObservable);
3959
4015
  break;
3960
4016
  }
3961
- case import_services12.Invitation.State.READY_FOR_AUTHENTICATION: {
4017
+ case import_services13.Invitation.State.READY_FOR_AUTHENTICATION: {
3962
4018
  if ((_f = (_e = hooks == null ? void 0 : hooks.host) == null ? void 0 : _e.onReady) == null ? void 0 : _f.call(_e, hostObservable)) {
3963
4019
  break;
3964
4020
  }
@@ -3967,11 +4023,11 @@ var performInvitation = ({ host, guest, options, hooks }) => {
3967
4023
  }
3968
4024
  break;
3969
4025
  }
3970
- case import_services12.Invitation.State.AUTHENTICATING: {
4026
+ case import_services13.Invitation.State.AUTHENTICATING: {
3971
4027
  (_h = (_g = hooks == null ? void 0 : hooks.host) == null ? void 0 : _g.onAuthenticating) == null ? void 0 : _h.call(_g, hostObservable);
3972
4028
  break;
3973
4029
  }
3974
- case import_services12.Invitation.State.SUCCESS: {
4030
+ case import_services13.Invitation.State.SUCCESS: {
3975
4031
  if ((_j = (_i = hooks == null ? void 0 : hooks.host) == null ? void 0 : _i.onSuccess) == null ? void 0 : _j.call(_i, hostObservable)) {
3976
4032
  break;
3977
4033
  }
@@ -3980,7 +4036,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
3980
4036
  });
3981
4037
  break;
3982
4038
  }
3983
- case import_services12.Invitation.State.CANCELLED: {
4039
+ case import_services13.Invitation.State.CANCELLED: {
3984
4040
  if ((_l = (_k = hooks == null ? void 0 : hooks.host) == null ? void 0 : _k.onCancelled) == null ? void 0 : _l.call(_k, hostObservable)) {
3985
4041
  break;
3986
4042
  }
@@ -3989,7 +4045,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
3989
4045
  });
3990
4046
  break;
3991
4047
  }
3992
- case import_services12.Invitation.State.TIMEOUT: {
4048
+ case import_services13.Invitation.State.TIMEOUT: {
3993
4049
  if ((_n = (_m = hooks == null ? void 0 : hooks.host) == null ? void 0 : _m.onTimeout) == null ? void 0 : _n.call(_m, hostObservable)) {
3994
4050
  break;
3995
4051
  }
@@ -4015,12 +4071,12 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4015
4071
  };
4016
4072
  var createInvitation = (host, options) => {
4017
4073
  options != null ? options : options = {
4018
- authMethod: import_services12.Invitation.AuthMethod.NONE,
4074
+ authMethod: import_services13.Invitation.AuthMethod.NONE,
4019
4075
  ...options != null ? options : {}
4020
4076
  };
4021
4077
  if (host instanceof ServiceContext) {
4022
4078
  const hostHandler = host.getInvitationHandler({
4023
- kind: import_services12.Invitation.Kind.SPACE,
4079
+ kind: import_services13.Invitation.Kind.SPACE,
4024
4080
  ...options
4025
4081
  });
4026
4082
  return host.invitations.createInvitation(hostHandler, options);
@@ -4049,6 +4105,7 @@ var import_keyring2 = require("@dxos/keyring");
4049
4105
  var import_messaging2 = require("@dxos/messaging");
4050
4106
  var import_network_manager3 = require("@dxos/network-manager");
4051
4107
  var import_random_access_storage2 = require("@dxos/random-access-storage");
4108
+ var import_teleport_extension_object_sync2 = require("@dxos/teleport-extension-object-sync");
4052
4109
  var createServiceHost = (config, signalManagerContext) => {
4053
4110
  return new ClientServicesHost({
4054
4111
  config,
@@ -4133,6 +4190,10 @@ var TestPeer = class {
4133
4190
  var _a, _b;
4134
4191
  return (_b = (_a = this._props).metadataStore) != null ? _b : _a.metadataStore = new import_echo_pipeline5.MetadataStore(this.storage.createDirectory("metadata"));
4135
4192
  }
4193
+ get blobStore() {
4194
+ var _a, _b;
4195
+ return (_b = (_a = this._props).blobStore) != null ? _b : _a.blobStore = new import_teleport_extension_object_sync2.BlobStore(this.storage.createDirectory("blobs"));
4196
+ }
4136
4197
  get snapshotStore() {
4137
4198
  var _a, _b;
4138
4199
  return (_b = (_a = this._props).snapshotStore) != null ? _b : _a.snapshotStore = new import_echo_pipeline5.SnapshotStore(this.storage.createDirectory("snapshots"));
@@ -4151,7 +4212,8 @@ var TestPeer = class {
4151
4212
  networkManager: this.networkManager,
4152
4213
  metadataStore: this.metadataStore,
4153
4214
  modelFactory: (0, import_client_protocol6.createDefaultModelFactory)(),
4154
- snapshotStore: this.snapshotStore
4215
+ snapshotStore: this.snapshotStore,
4216
+ blobStore: this.blobStore
4155
4217
  });
4156
4218
  }
4157
4219
  async destroy() {