@dxos/client-services 0.1.53-main.972e6e3 → 0.1.53-main.a67c9cf

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.
@@ -2941,7 +2941,7 @@ DataSpaceManager = __decorate2([
2941
2941
  ], DataSpaceManager);
2942
2942
 
2943
2943
  // packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
2944
- import { EventSubscriptions as EventSubscriptions2, scheduleTask as scheduleTask5 } from "@dxos/async";
2944
+ import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as scheduleTask5 } from "@dxos/async";
2945
2945
  import { Stream as Stream9 } from "@dxos/codec-protobuf";
2946
2946
  import { raise, todo as todo2 } from "@dxos/debug";
2947
2947
  import { SpaceNotFoundError } from "@dxos/echo-pipeline";
@@ -2949,7 +2949,6 @@ import { log as log11 } from "@dxos/log";
2949
2949
  import { encodeError } from "@dxos/protocols";
2950
2950
  import { SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/client/services";
2951
2951
  import { humanize } from "@dxos/util";
2952
- var TIMEFRAME_UPDATE_DEBOUNCE_TIME = 500;
2953
2952
  var SpacesServiceImpl = class {
2954
2953
  constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
2955
2954
  this._identityManager = _identityManager;
@@ -2963,16 +2962,16 @@ var SpacesServiceImpl = class {
2963
2962
  }
2964
2963
  const dataSpaceManager = await this._getDataSpaceManager();
2965
2964
  const space = await dataSpaceManager.createSpace();
2966
- return this._transformSpace(space);
2965
+ return this._serializeSpace(space);
2967
2966
  }
2968
2967
  async updateSpace(request) {
2969
2968
  todo2();
2970
2969
  }
2971
2970
  querySpaces() {
2972
2971
  return new Stream9(({ next, ctx }) => {
2973
- const onUpdate = async () => {
2972
+ const scheduler = new UpdateScheduler(ctx, async () => {
2974
2973
  const dataSpaceManager = await this._getDataSpaceManager();
2975
- const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._transformSpace(space));
2974
+ const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
2976
2975
  log11("update", {
2977
2976
  spaces
2978
2977
  }, {
@@ -2984,7 +2983,9 @@ var SpacesServiceImpl = class {
2984
2983
  next({
2985
2984
  spaces
2986
2985
  });
2987
- };
2986
+ }, {
2987
+ maxFrequency: 2
2988
+ });
2988
2989
  scheduleTask5(ctx, async () => {
2989
2990
  const dataSpaceManager = await this._getDataSpaceManager();
2990
2991
  const subscriptions = new EventSubscriptions2();
@@ -2992,21 +2993,21 @@ var SpacesServiceImpl = class {
2992
2993
  const subscribeSpaces = () => {
2993
2994
  subscriptions.clear();
2994
2995
  for (const space of dataSpaceManager.spaces.values()) {
2995
- subscriptions.add(space.stateUpdate.on(ctx, onUpdate));
2996
- subscriptions.add(space.presence.updated.on(ctx, onUpdate));
2997
- subscriptions.add(space.dataPipeline.onNewEpoch.on(ctx, onUpdate));
2998
- space.inner.controlPipeline.state.timeframeUpdate.debounce(TIMEFRAME_UPDATE_DEBOUNCE_TIME).on(ctx, onUpdate);
2996
+ subscriptions.add(space.stateUpdate.on(ctx, () => scheduler.trigger()));
2997
+ subscriptions.add(space.presence.updated.on(ctx, () => scheduler.trigger()));
2998
+ subscriptions.add(space.dataPipeline.onNewEpoch.on(ctx, () => scheduler.trigger()));
2999
+ space.inner.controlPipeline.state.timeframeUpdate.on(ctx, () => scheduler.trigger());
2999
3000
  if (space.dataPipeline.pipelineState) {
3000
- subscriptions.add(space.dataPipeline.pipelineState.timeframeUpdate.debounce(TIMEFRAME_UPDATE_DEBOUNCE_TIME).on(ctx, onUpdate));
3001
+ subscriptions.add(space.dataPipeline.pipelineState.timeframeUpdate.on(ctx, () => scheduler.trigger()));
3001
3002
  }
3002
3003
  }
3003
3004
  };
3004
3005
  dataSpaceManager.updated.on(ctx, () => {
3005
3006
  subscribeSpaces();
3006
- void onUpdate();
3007
+ scheduler.trigger();
3007
3008
  });
3008
3009
  subscribeSpaces();
3009
- void onUpdate();
3010
+ scheduler.trigger();
3010
3011
  });
3011
3012
  if (!this._identityManager.identity) {
3012
3013
  next({
@@ -3064,7 +3065,7 @@ var SpacesServiceImpl = class {
3064
3065
  const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : raise(new SpaceNotFoundError(spaceKey));
3065
3066
  await space.createEpoch();
3066
3067
  }
3067
- _transformSpace(space) {
3068
+ _serializeSpace(space) {
3068
3069
  var _a, _b, _c, _d, _e, _f, _g;
3069
3070
  return {
3070
3071
  spaceKey: space.key,
@@ -4006,4 +4007,4 @@ export {
4006
4007
  ServiceRegistry,
4007
4008
  ClientServicesHost
4008
4009
  };
4009
- //# sourceMappingURL=chunk-CPSUVMSC.mjs.map
4010
+ //# sourceMappingURL=chunk-6ITWCQIT.mjs.map