tempo-sdk 0.0.33 → 0.0.34

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.
@@ -3930,11 +3930,12 @@ function createProjectionOutbox(options) {
3930
3930
  const dirty = /* @__PURE__ */ new Set();
3931
3931
  const full = /* @__PURE__ */ new Set();
3932
3932
  let dirtyHead = false;
3933
+ const dirtyHeadRoots = /* @__PURE__ */ new Set();
3933
3934
  let sessionId;
3934
3935
  let sequence = 0;
3935
3936
  let stopped = false;
3936
3937
  let fixedWindow;
3937
- const hasWork = () => dirtyHead || dirty.size > 0;
3938
+ const hasWork = () => dirtyHead || dirtyHeadRoots.size > 0 || dirty.size > 0;
3938
3939
  const report = (error) => {
3939
3940
  try {
3940
3941
  options.onError?.(error);
@@ -3944,14 +3945,19 @@ function createProjectionOutbox(options) {
3944
3945
  const assertActive = () => {
3945
3946
  if (stopped) throw new Error("Projection producer has been stopped");
3946
3947
  };
3947
- const restore = (failedSession, rootIds, includeHead) => {
3948
+ const restore = (failedSession, rootIds, includeHeadForAllRoots, headRootIds) => {
3948
3949
  if (stopped || sessionId !== failedSession) return;
3949
3950
  for (const rootId of rootIds) {
3950
3951
  if (!roots.has(rootId)) continue;
3951
3952
  dirty.add(rootId);
3952
3953
  full.add(rootId);
3953
3954
  }
3954
- dirtyHead || (dirtyHead = includeHead);
3955
+ dirtyHead || (dirtyHead = includeHeadForAllRoots);
3956
+ if (!dirtyHead) {
3957
+ for (const rootId of headRootIds) {
3958
+ if (roots.has(rootId)) dirtyHeadRoots.add(rootId);
3959
+ }
3960
+ }
3955
3961
  fixedWindow.schedule();
3956
3962
  };
3957
3963
  const flushOnce = (timing) => {
@@ -3959,7 +3965,9 @@ function createProjectionOutbox(options) {
3959
3965
  if (stopped || !activeSession || !hasWork()) return;
3960
3966
  const rootIds = [...dirty];
3961
3967
  const fullRootIds = new Set(full);
3962
- const includeHead = dirtyHead;
3968
+ const includeHeadForAllRoots = dirtyHead;
3969
+ const headRootIds = includeHeadForAllRoots ? [] : [...dirtyHeadRoots];
3970
+ const includeHead = includeHeadForAllRoots || headRootIds.length > 0;
3963
3971
  const context = {
3964
3972
  ...timing,
3965
3973
  candidateRootCount: rootIds.length,
@@ -3969,6 +3977,7 @@ function createProjectionOutbox(options) {
3969
3977
  dirty.clear();
3970
3978
  full.clear();
3971
3979
  dirtyHead = false;
3980
+ dirtyHeadRoots.clear();
3972
3981
  try {
3973
3982
  const changes = [];
3974
3983
  for (const rootId of rootIds) {
@@ -3981,7 +3990,9 @@ function createProjectionOutbox(options) {
3981
3990
  changes.push({ rootId, ...captured });
3982
3991
  }
3983
3992
  if (stopped || sessionId !== activeSession) return;
3984
- const head = includeHead ? options.captureHead(context) : void 0;
3993
+ const emittedHeadRootIds = includeHeadForAllRoots ? [] : headRootIds;
3994
+ const shouldCaptureHead = includeHead;
3995
+ const head = shouldCaptureHead ? options.captureHead(context) : void 0;
3985
3996
  if (stopped || sessionId !== activeSession) return;
3986
3997
  if (changes.length === 0 && head === void 0) return;
3987
3998
  const emittedSequence = sequence;
@@ -3989,6 +4000,7 @@ function createProjectionOutbox(options) {
3989
4000
  sessionId: activeSession,
3990
4001
  sequence: emittedSequence,
3991
4002
  ...head === void 0 ? {} : { head },
4003
+ ...head !== void 0 && emittedHeadRootIds.length > 0 ? { headRootIds: emittedHeadRootIds } : {},
3992
4004
  roots: changes
3993
4005
  });
3994
4006
  if (sessionId === activeSession && sequence === emittedSequence) {
@@ -3996,7 +4008,12 @@ function createProjectionOutbox(options) {
3996
4008
  }
3997
4009
  } catch (error) {
3998
4010
  report(error);
3999
- restore(activeSession, rootIds, includeHead);
4011
+ restore(
4012
+ activeSession,
4013
+ rootIds,
4014
+ includeHeadForAllRoots,
4015
+ headRootIds
4016
+ );
4000
4017
  }
4001
4018
  };
4002
4019
  fixedWindow = createProjectionFixedWindow({
@@ -4014,6 +4031,7 @@ function createProjectionOutbox(options) {
4014
4031
  fixedWindow.reset();
4015
4032
  dirty.clear();
4016
4033
  full.clear();
4034
+ dirtyHeadRoots.clear();
4017
4035
  dirtyHead = true;
4018
4036
  sessionId = nextSessionId;
4019
4037
  sequence = 0;
@@ -4031,7 +4049,7 @@ function createProjectionOutbox(options) {
4031
4049
  if (!sessionId) return;
4032
4050
  dirty.add(rootId);
4033
4051
  full.add(rootId);
4034
- dirtyHead = true;
4052
+ if (!dirtyHead) dirtyHeadRoots.add(rootId);
4035
4053
  if (sequence === 0) fixedWindow.schedule();
4036
4054
  else fixedWindow.flushNow();
4037
4055
  },
@@ -4039,6 +4057,7 @@ function createProjectionOutbox(options) {
4039
4057
  if (stopped || !roots.delete(rootId)) return;
4040
4058
  dirty.delete(rootId);
4041
4059
  full.delete(rootId);
4060
+ dirtyHeadRoots.delete(rootId);
4042
4061
  if (!hasWork()) fixedWindow.cancel();
4043
4062
  },
4044
4063
  record(activity) {
@@ -4049,11 +4068,12 @@ function createProjectionOutbox(options) {
4049
4068
  }
4050
4069
  fixedWindow.schedule();
4051
4070
  },
4052
- requestFull(rootId) {
4071
+ requestFull(rootId, options2) {
4053
4072
  assertActive();
4054
4073
  if (!sessionId || !roots.has(rootId)) return;
4055
4074
  dirty.add(rootId);
4056
4075
  full.add(rootId);
4076
+ if (options2?.includeHead && !dirtyHead) dirtyHeadRoots.add(rootId);
4057
4077
  fixedWindow.flushNow();
4058
4078
  },
4059
4079
  stop() {
@@ -4063,6 +4083,7 @@ function createProjectionOutbox(options) {
4063
4083
  roots.clear();
4064
4084
  dirty.clear();
4065
4085
  full.clear();
4086
+ dirtyHeadRoots.clear();
4066
4087
  dirtyHead = false;
4067
4088
  sessionId = void 0;
4068
4089
  }
@@ -4485,6 +4506,7 @@ function createCombinedDocumentProducer(options) {
4485
4506
  sessionId: batch.sessionId,
4486
4507
  sequence: batch.sequence,
4487
4508
  ...batch.head === void 0 ? {} : { head: batch.head },
4509
+ ...batch.headRootIds === void 0 ? {} : { headRootIds: batch.headRootIds },
4488
4510
  ...perf ? { perf } : {},
4489
4511
  roots: batch.roots
4490
4512
  };
@@ -4957,7 +4979,7 @@ function createCombinedDocumentProducer(options) {
4957
4979
  }));
4958
4980
  syncRootLifecycleObserver();
4959
4981
  },
4960
- requestFull: (rootId) => core.requestFull(rootId),
4982
+ requestFull: (rootId, requestOptions) => core.requestFull(rootId, requestOptions),
4961
4983
  captureSemanticSubtree(rootId, targetFiberId) {
4962
4984
  if (stopped) throw new Error("Projection producer has been stopped");
4963
4985
  const runtime = roots.get(rootId);
@@ -6221,7 +6243,11 @@ function createProjectionSourceController(options) {
6221
6243
  }
6222
6244
  return true;
6223
6245
  }
6224
- producer?.requestFull(registration.rootId);
6246
+ if (payload.includeHead === true) {
6247
+ producer?.requestFull(registration.rootId, { includeHead: true });
6248
+ } else {
6249
+ producer?.requestFull(registration.rootId);
6250
+ }
6225
6251
  return true;
6226
6252
  }
6227
6253
  if (payload.type === "capture-projection-semantic-subtree") {