demoman 0.9.5 → 0.9.7

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.
@@ -15453,7 +15453,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15453
15453
  /** The longest single hold within `roomMs` (a settle or the camera's
15454
15454
  * room, not a wait for the page to go quiet): what the film check may
15455
15455
  * take for Demoman's pacing inside one still stretch. */
15456
- roomHeldMs: external_exports.number().nonnegative().optional()
15456
+ roomHeldMs: external_exports.number().nonnegative().optional(),
15457
+ /** Where the walk set off for this step, in source time. */
15458
+ approachSourceTimeMs: external_exports.number().min(0).optional(),
15459
+ /** When this step's approach scroll ended, in source time: continuous
15460
+ * recording, and only when the approach scrolled. */
15461
+ scrollEndSourceTimeMs: external_exports.number().min(0).optional()
15457
15462
  }).superRefine((marker, ctx) => {
15458
15463
  if (marker.actEndSourceTimeMs !== void 0 && marker.actEndSourceTimeMs < marker.sourceTimeMs) {
15459
15464
  ctx.addIssue({
@@ -15555,6 +15560,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15555
15560
  // the page named for it was gone, or copying it threw). The drag still
15556
15561
  // ran; the film shows the card jump to its drop instead of travelling.
15557
15562
  "dragPictureMissing",
15563
+ // A pointer move reached the page more than `POINTER_LATE_MS` after its
15564
+ // plan (a slow machine). The drawn cursor follows the plan, so it
15565
+ // arrives before the page's hover shows; the note counts the moves and
15566
+ // names the worst. One per run.
15567
+ "pointerLate",
15558
15568
  // A step's page had not settled when the cap ran out (requests in
15559
15569
  // flight, an animation running, the DOM still changing) or showed a
15560
15570
  // caret it would not hide: the page's own doing. The video is
@@ -15574,7 +15584,22 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15574
15584
  // A page screen's hold (caret hidden, endless animations held) could not
15575
15585
  // be undone after the capture: the video after that step may show no
15576
15586
  // caret and frozen spinners. About the video, so not forgiven.
15577
- "pageHoldNotReleased"
15587
+ "pageHoldNotReleased",
15588
+ // A held take only: a connection with no data for IDLE_CONNECTION_MS
15589
+ // stopped counting as waiting on the server. One per connection; the
15590
+ // note is its label ("GET /poll"). The video is right, so refresh
15591
+ // forgives it.
15592
+ "connectionIgnored",
15593
+ // A held take only: a page animation the held clock could not pin (one
15594
+ // in a cross-origin frame, say) ran on real time. One per animation, at
15595
+ // the held time first seen; the note names it. The video is right, so
15596
+ // refresh forgives it.
15597
+ "animationUnpinned",
15598
+ // A held take only: data arrived, outside a wait of the script's (in a
15599
+ // pause or a rest), on a connection the recording had followed, so it
15600
+ // landed where the machine put it. Once a take, at the held time first
15601
+ // seen. The page's own, so refresh forgives it.
15602
+ "answerUnpaced"
15578
15603
  ]),
15579
15604
  note: external_exports.string()
15580
15605
  });
@@ -15606,6 +15631,23 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15606
15631
  * reader of what it means.
15607
15632
  */
15608
15633
  timing: external_exports.literal("real").optional(),
15634
+ /**
15635
+ * Present only on a replay recorded on a held page clock: page time
15636
+ * advanced one video frame per capture, so source time is the designed
15637
+ * clock, not elapsed wall time. `isHeld` is the one reader.
15638
+ */
15639
+ clock: external_exports.literal("held").optional(),
15640
+ /**
15641
+ * A held replay only: the stretches of source time spent waiting on the
15642
+ * network, `label` the connections that made each ("POST /api/chat").
15643
+ */
15644
+ networkSpans: external_exports.array(external_exports.object({
15645
+ startMs: external_exports.number().nonnegative(),
15646
+ endMs: external_exports.number().nonnegative(),
15647
+ label: external_exports.string()
15648
+ }).refine((s) => s.endMs >= s.startMs, {
15649
+ message: "a network stretch cannot end before it starts"
15650
+ })).optional(),
15609
15651
  /**
15610
15652
  * A real-time replay only: the gaps the author edited that the engine
15611
15653
  * waited out live, each at the duration it waited. The pause is then
@@ -15661,6 +15703,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15661
15703
  path: ["timing"]
15662
15704
  });
15663
15705
  }
15706
+ if (bundle.clock === "held" && (bundle.source === "capture" || bundle.timing !== "real")) {
15707
+ ctx.addIssue({
15708
+ code: "custom",
15709
+ message: "a held clock is a real-time replay's; a capture or a sampled replay cannot be held",
15710
+ path: ["clock"]
15711
+ });
15712
+ }
15664
15713
  if (bundle.pacedGaps !== void 0 && bundle.timing !== "real") {
15665
15714
  ctx.addIssue({
15666
15715
  code: "custom",
@@ -15750,6 +15799,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15750
15799
  }
15751
15800
  return bundle.keyframes[0] ?? null;
15752
15801
  }
15802
+ function isHeld(bundle) {
15803
+ return bundle.clock === "held";
15804
+ }
15753
15805
 
15754
15806
  // ../../packages/compositor/dist/geometry.js
15755
15807
  function rectCenter(r) {
@@ -16239,7 +16291,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16239
16291
  * own edit. The record that write-back reads, never inferred from the
16240
16292
  * scale's value. Absent when the scale was the default.
16241
16293
  */
16242
- scaleSetBy: external_exports.enum(["script", "author"]).optional()
16294
+ scaleSetBy: external_exports.enum(["script", "author"]).optional(),
16295
+ /**
16296
+ * How the camera reaches this zoom, decided once at record time from the
16297
+ * beat plan: `pan` slides from the zoom before it, `return` pulls back to
16298
+ * full frame first. Absent: the renderer's own clock (every earlier take).
16299
+ */
16300
+ arrives: external_exports.enum(["pan", "return"]).optional()
16243
16301
  });
16244
16302
  var ZoomSkipped = external_exports.union([
16245
16303
  external_exports.object({
@@ -16526,6 +16584,24 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16526
16584
  anchors: external_exports.array(Anchor),
16527
16585
  actions: external_exports.array(Action),
16528
16586
  camera: external_exports.array(CameraEvent),
16587
+ /**
16588
+ * The take's pauses, planned rather than measured: one beat per action,
16589
+ * in order. Absent on every take recorded before the plan existed.
16590
+ */
16591
+ pacing: external_exports.object({
16592
+ beats: external_exports.array(external_exports.object({
16593
+ beforeActionId: external_exports.string().min(1),
16594
+ /** Dead air before the action. */
16595
+ restMs: external_exports.number().min(0),
16596
+ /** How long the walk to the action takes. */
16597
+ arriveMs: external_exports.number().min(0),
16598
+ /** Dead air from the approach scroll's end to the journey's
16599
+ * start. Only on a step whose approach scrolled. */
16600
+ afterScrollMs: external_exports.number().min(0).optional()
16601
+ })),
16602
+ /** Dead air after the last action's motion. */
16603
+ tailMs: external_exports.number().min(0)
16604
+ }).optional(),
16529
16605
  /** See `ZoomSkipped`. */
16530
16606
  zoomsSkipped: external_exports.array(ZoomSkipped).optional(),
16531
16607
  edits: external_exports.object({
@@ -17591,6 +17667,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17591
17667
  const instants = [];
17592
17668
  let unplacedPaces = 0;
17593
17669
  for (const pace of plan.paces) {
17670
+ if (pace.origin === "planned")
17671
+ continue;
17594
17672
  const from = markerAt.get(pace.afterActionId);
17595
17673
  const to = markerAt.get(pace.beforeActionId);
17596
17674
  if (from === void 0 || to === void 0) {
@@ -17611,7 +17689,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17611
17689
  unplacedPaces
17612
17690
  };
17613
17691
  }
17614
- function rawSegmentsOf(plan, bundle, motion, sourceDurationMs, cuts) {
17692
+ function rawSegmentsOf(bundle, motion, sourceDurationMs, cuts, regions) {
17615
17693
  const cutSet = /* @__PURE__ */ new Set([0, sourceDurationMs]);
17616
17694
  for (const marker of bundle.markers)
17617
17695
  cutSet.add(marker.sourceTimeMs);
@@ -17623,6 +17701,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17623
17701
  cutSet.add(cut.srcStartMs);
17624
17702
  cutSet.add(cut.srcEndMs);
17625
17703
  }
17704
+ for (const region of regions) {
17705
+ cutSet.add(region.srcStartMs);
17706
+ cutSet.add(region.srcEndMs);
17707
+ }
17626
17708
  const ordered = [...cutSet].filter((t) => t >= 0 && t <= sourceDurationMs).sort((a, b) => a - b);
17627
17709
  const isMotion = (start, end) => motion.some((s) => s.startMs <= start && s.endMs >= end && end > start);
17628
17710
  const raw = [];
@@ -17637,50 +17719,112 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17637
17719
  if (insideCutClosed(cuts, (srcStartMs + srcEndMs) / 2))
17638
17720
  continue;
17639
17721
  const kind = isMotion(srcStartMs, srcEndMs) ? "motion" : "idle";
17640
- const outDurationMs = kind === "motion" ? srcDuration : idleOutputFor(plan, bundle, motion, cuts, srcStartMs, srcEndMs, srcDuration);
17722
+ const outDurationMs = kind === "motion" ? srcDuration : idleOutputFor(regions, srcStartMs, srcEndMs, srcDuration);
17641
17723
  raw.push({ srcStartMs, srcEndMs, kind, outDurationMs });
17642
17724
  }
17643
17725
  return raw;
17644
17726
  }
17645
- function authoredPaceCovering(plan, bundle, srcStartMs, srcEndMs) {
17727
+ function authoredRegions(plan, bundle, idleIn) {
17646
17728
  if (!isRealTime(bundle))
17647
- return void 0;
17648
- if (!plan.paces)
17649
- return void 0;
17729
+ return [];
17650
17730
  const markerAt = new Map(bundle.markers.map((m) => [m.actionId, m.sourceTimeMs]));
17651
- return plan.paces.find((pace) => {
17731
+ return (plan.paces ?? []).flatMap((pace) => {
17652
17732
  if (pace.origin !== "authored")
17653
- return false;
17733
+ return [];
17654
17734
  if (gapPacedLive(bundle, pace.afterActionId, pace.idleTargetMs)) {
17655
- return false;
17735
+ return [];
17656
17736
  }
17657
17737
  const after = markerAt.get(pace.afterActionId);
17658
17738
  const before = markerAt.get(pace.beforeActionId);
17659
17739
  if (after === void 0 || before === void 0)
17660
- return false;
17661
- return after <= srcStartMs && srcEndMs <= before;
17740
+ return [];
17741
+ return [
17742
+ {
17743
+ srcStartMs: after,
17744
+ srcEndMs: before,
17745
+ targetMs: pace.idleTargetMs,
17746
+ idleMs: idleIn(after, before)
17747
+ }
17748
+ ];
17662
17749
  });
17663
17750
  }
17664
- function idleMsBetweenMarkers(bundle, motion, removed, pace) {
17665
- const markerAt = new Map(bundle.markers.map((m) => [m.actionId, m.sourceTimeMs]));
17666
- const after = markerAt.get(pace.afterActionId);
17667
- const before = markerAt.get(pace.beforeActionId);
17668
- if (after === void 0 || before === void 0)
17669
- return 0;
17751
+ function plannedIdleOf(plan, bundle, idleIn, cuts, interruptions, sourceDurationMs) {
17752
+ const regions = [];
17753
+ const freezes = [];
17754
+ const unplacedBeatSteps = [];
17755
+ if (!isRealTime(bundle)) {
17756
+ return { regions, freezes, unplacedPaces: 0, unplacedBeatSteps };
17757
+ }
17758
+ const markerOf = new Map(bundle.markers.map((m) => [m.actionId, m]));
17759
+ const share = (srcStartMs, srcEndMs, targetMs) => {
17760
+ const idleMs = idleIn(srcStartMs, srcEndMs);
17761
+ if (idleMs > 0) {
17762
+ regions.push({ srcStartMs, srcEndMs, targetMs, idleMs });
17763
+ return true;
17764
+ }
17765
+ if (targetMs <= 0 || insideCutClosed(cuts, srcEndMs))
17766
+ return true;
17767
+ const gone = interruptions.find((s) => s.startMs <= srcEndMs && srcEndMs < s.endMs);
17768
+ const at = gone ? gone.startMs : srcEndMs;
17769
+ if (gone && (at <= srcStartMs || insideCutClosed(cuts, at)))
17770
+ return false;
17771
+ freezes.push({ sourceTimeMs: at, durationMs: targetMs });
17772
+ return true;
17773
+ };
17774
+ const afterAct = (prev, endMs) => {
17775
+ const end = prev.actEndSourceTimeMs;
17776
+ if (end === void 0 || end < prev.sourceTimeMs || end > endMs) {
17777
+ return prev.sourceTimeMs;
17778
+ }
17779
+ share(prev.sourceTimeMs, end, 0);
17780
+ return end;
17781
+ };
17782
+ for (const pace of plan.paces ?? []) {
17783
+ if (pace.origin !== "planned")
17784
+ continue;
17785
+ const prev = pace.afterActionId === null ? { sourceTimeMs: 0 } : markerOf.get(pace.afterActionId);
17786
+ const step = markerOf.get(pace.beforeActionId);
17787
+ const approach = step?.approachSourceTimeMs;
17788
+ const scrollEnd = step?.scrollEndSourceTimeMs;
17789
+ if (prev === void 0 || step === void 0 || approach === void 0 || approach < prev.sourceTimeMs || approach > step.sourceTimeMs || // The scroll's stretch needs both halves: where the scroll ended and
17790
+ // what to play after it. One without the other is not guessed at.
17791
+ scrollEnd === void 0 !== (pace.afterScrollMs === void 0) || scrollEnd !== void 0 && (scrollEnd < prev.sourceTimeMs || scrollEnd > approach)) {
17792
+ unplacedBeatSteps.push(pace.beforeActionId);
17793
+ continue;
17794
+ }
17795
+ const restEnd = scrollEnd ?? approach;
17796
+ const rest = share(afterAct(prev, restEnd), restEnd, pace.restMs);
17797
+ const scroll = scrollEnd === void 0 || pace.afterScrollMs === void 0 ? true : share(scrollEnd, approach, pace.afterScrollMs);
17798
+ const arrive = share(approach, step.sourceTimeMs, pace.arriveMs);
17799
+ if (!rest || !scroll || !arrive)
17800
+ unplacedBeatSteps.push(pace.beforeActionId);
17801
+ }
17802
+ if (plan.tailMs != null) {
17803
+ const lastStep = plan.paces?.at(-1)?.beforeActionId;
17804
+ const last2 = lastStep === void 0 ? void 0 : markerOf.get(lastStep);
17805
+ if (last2 === void 0 || !share(afterAct(last2, sourceDurationMs), sourceDurationMs, plan.tailMs)) {
17806
+ unplacedBeatSteps.push(null);
17807
+ }
17808
+ }
17809
+ return {
17810
+ regions,
17811
+ freezes,
17812
+ unplacedPaces: unplacedBeatSteps.length,
17813
+ unplacedBeatSteps
17814
+ };
17815
+ }
17816
+ function idleMsIn(motion, removed, fromMs, toMs) {
17670
17817
  const notIdle = merge2([
17671
17818
  ...motion,
17672
17819
  ...removed.map((cut) => ({ startMs: cut.srcStartMs, endMs: cut.srcEndMs }))
17673
17820
  ]);
17674
- return Math.max(0, before - after - motionMsBetween(notIdle, after, before));
17821
+ return Math.max(0, toMs - fromMs - motionMsBetween(notIdle, fromMs, toMs));
17675
17822
  }
17676
- function idleOutputFor(plan, bundle, motion, removed, srcStartMs, srcEndMs, srcDuration) {
17677
- const pace = authoredPaceCovering(plan, bundle, srcStartMs, srcEndMs);
17678
- if (!pace)
17823
+ function idleOutputFor(regions, srcStartMs, srcEndMs, srcDuration) {
17824
+ const region = regions.find((r) => r.srcStartMs <= srcStartMs && srcEndMs <= r.srcEndMs);
17825
+ if (!region || region.idleMs <= 0)
17679
17826
  return srcDuration;
17680
- const idleTotal = idleMsBetweenMarkers(bundle, motion, removed, pace);
17681
- if (idleTotal <= 0)
17682
- return srcDuration;
17683
- return pace.idleTargetMs * (srcDuration / idleTotal);
17827
+ return region.targetMs * (srcDuration / region.idleMs);
17684
17828
  }
17685
17829
  function splitAtHold(raw, sourceTimeMs) {
17686
17830
  const idx = raw.findIndex((s) => s.srcStartMs + HOLD_EPSILON_MS < sourceTimeMs && sourceTimeMs < s.srcEndMs - HOLD_EPSILON_MS);
@@ -17751,8 +17895,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17751
17895
  const settleMs = bundle.source === "capture" ? springSettleMs(CURSOR_SPRING_TAU_MS) : 0;
17752
17896
  return Math.max(lastKeyframe?.sourceTimeMs ?? 0, ...bundle.markers.map((m) => m.sourceTimeMs), ...motionSpansOf(bundle).map((m) => m.endMs), travel === void 0 ? 0 : travel.endMs + settleMs);
17753
17897
  }
17754
- function buildTimeline(plan, bundle, hints = []) {
17755
- const motion = motionSpansOf(bundle, hints);
17898
+ function buildTimeline(plan, bundle, hints = [], keyframeHints = []) {
17899
+ const isPlanned = plan.tailMs !== null || (plan.paces ?? []).some((pace) => pace.origin === "planned");
17900
+ const motion = motionSpansOf(bundle, isPlanned || isHeld(bundle) ? hints : [...hints, ...keyframeHints]);
17756
17901
  const sourceDurationMs = sourceDurationOf(bundle);
17757
17902
  const { cuts, unplacedCuts } = cutRanges(plan, bundle, sourceDurationMs);
17758
17903
  const interruptions = interruptionsOf(bundle, cuts);
@@ -17766,9 +17911,17 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17766
17911
  }))
17767
17912
  ].sort((a, b) => a.srcStartMs - b.srcStartMs);
17768
17913
  const holds = holdInstants(plan, bundle, sourceDurationMs, cuts);
17769
- const { instants: paces, unplacedPaces } = paceInstants(plan, bundle, motion, cuts);
17914
+ const recorded = paceInstants(plan, bundle, motion, cuts);
17915
+ const idleIn = (fromMs, toMs) => idleMsIn(motion, removed, fromMs, toMs);
17916
+ const planned = plannedIdleOf(plan, bundle, idleIn, cuts, interruptions, sourceDurationMs);
17917
+ const regions = [
17918
+ ...authoredRegions(plan, bundle, idleIn),
17919
+ ...planned.regions
17920
+ ];
17921
+ const paces = [...recorded.instants, ...planned.freezes].sort((a, b) => a.sourceTimeMs - b.sourceTimeMs);
17922
+ const unplacedPaces = recorded.unplacedPaces + planned.unplacedPaces;
17770
17923
  const nonMonotonicPaces = (plan.paces ?? []).filter((pace) => pace.origin === "recorded" && pace.recordedSpanMs < 0).length;
17771
- let raw = rawSegmentsOf(plan, bundle, motion, sourceDurationMs, removed);
17924
+ let raw = rawSegmentsOf(bundle, motion, sourceDurationMs, removed, regions);
17772
17925
  for (const hold of holds)
17773
17926
  raw = splitAtHold(raw, hold.sourceTimeMs);
17774
17927
  for (const pace of paces)
@@ -17804,6 +17957,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17804
17957
  }
17805
17958
  };
17806
17959
  const isSeam = (sourceTimeMs) => cuts.some((cut) => Math.abs(cut.srcStartMs - sourceTimeMs) <= HOLD_EPSILON_MS);
17960
+ const opensInterruption = (sourceTimeMs) => interruptions.some((span) => Math.abs(span.startMs - sourceTimeMs) <= HOLD_EPSILON_MS);
17807
17961
  for (const seg of raw) {
17808
17962
  emitHoldsAt(seg.srcStartMs);
17809
17963
  emitPacesAt(seg.srcStartMs);
@@ -17815,13 +17969,26 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17815
17969
  kind: seg.kind
17816
17970
  });
17817
17971
  outCursor += seg.outDurationMs;
17818
- if (isSeam(seg.srcEndMs)) {
17972
+ if (isSeam(seg.srcEndMs))
17819
17973
  emitHoldsAt(seg.srcEndMs);
17974
+ if (isSeam(seg.srcEndMs) || opensInterruption(seg.srcEndMs)) {
17820
17975
  emitPacesAt(seg.srcEndMs);
17821
17976
  }
17822
17977
  }
17823
17978
  emitHoldsAt(sourceDurationMs);
17824
17979
  emitPacesAt(sourceDurationMs);
17980
+ const placedIdle = [];
17981
+ for (const seg of segments) {
17982
+ const isPlaced = seg.kind === "idle" ? planned.regions.some((r) => seg.srcStartMs >= r.srcStartMs && seg.srcEndMs <= r.srcEndMs) : seg.kind === "pace" && planned.freezes.some((f) => Math.abs(f.sourceTimeMs - seg.srcStartMs) <= HOLD_EPSILON_MS);
17983
+ if (!isPlaced || seg.outEndMs <= seg.outStartMs)
17984
+ continue;
17985
+ const last2 = placedIdle.at(-1);
17986
+ if (last2 && seg.outStartMs - last2.endMs <= HOLD_EPSILON_MS) {
17987
+ last2.endMs = seg.outEndMs;
17988
+ } else {
17989
+ placedIdle.push({ startMs: seg.outStartMs, endMs: seg.outEndMs });
17990
+ }
17991
+ }
17825
17992
  return {
17826
17993
  segments,
17827
17994
  outputDurationMs: outCursor,
@@ -17830,6 +17997,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17830
17997
  unplacedCuts,
17831
17998
  interruptions,
17832
17999
  unplacedPaces,
18000
+ // Present only when a beat was unplaced, so a take with no plan builds
18001
+ // the timeline it always did.
18002
+ ...planned.unplacedBeatSteps.length > 0 ? { unplacedBeatSteps: planned.unplacedBeatSteps } : {},
18003
+ ...placedIdle.length > 0 ? { placedIdle } : {},
17833
18004
  nonMonotonicPaces
17834
18005
  };
17835
18006
  }
@@ -18088,14 +18259,20 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18088
18259
  offsetMs: event.marker.offsetMs,
18089
18260
  scale: clamp(event.scale ?? 1, 1, CAMERA_DEFAULTS.maxScale),
18090
18261
  end: event.end ?? null,
18262
+ ...event.arrives === void 0 ? {} : { arrives: event.arrives },
18091
18263
  ...fitOf(event)
18092
18264
  })).filter((intent) => intent.scale > 1).sort((a, b) => {
18093
18265
  const byAction = (order.get(a.actionId) ?? 0) - (order.get(b.actionId) ?? 0);
18094
18266
  return byAction !== 0 ? byAction : a.offsetMs - b.offsetMs;
18095
18267
  });
18096
18268
  }
18097
- function solveCamera(intents, rectOf, timeline, markerSourceMs, viewport, fitWindow = null, motion = MOTION_DEFAULTS, actEnds = /* @__PURE__ */ new Map(), holds = []) {
18269
+ function solveCamera(intents, rectOf, timeline, markerSourceMs, viewport, fitWindow = null, motion = MOTION_DEFAULTS, actEnds = /* @__PURE__ */ new Map(), holds = [], gapAfterActionIds = []) {
18098
18270
  const timings = motionTimings(motion.smoothness);
18271
+ const gaps = gapAfterActionIds.flatMap((id) => {
18272
+ const at = markerSourceMs.get(id);
18273
+ return at === void 0 ? [] : [toOutputMs(timeline, at)];
18274
+ });
18275
+ const edited = (before, seed) => gaps.some((ms) => ms >= before.actionMs && ms < seed.actionMs) || timeline.cuts.some((cut) => cut.srcEndMs > before.sourceMs && cut.srcStartMs < seed.sourceMs);
18099
18276
  const neutral = { x: viewport.width / 2, y: viewport.height / 2 };
18100
18277
  const seeds = [];
18101
18278
  const actEndOf = /* @__PURE__ */ new Map();
@@ -18129,6 +18306,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18129
18306
  stiffness: timings.stiffness,
18130
18307
  zoom: true,
18131
18308
  authoredEndMs: resolvedEndMs,
18309
+ arrives: intent.arrives ?? null,
18132
18310
  endUnplaced: intent.end !== null && resolvedEndMs === null,
18133
18311
  fitted: scale < requested ? {
18134
18312
  from: requested,
@@ -18136,6 +18314,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18136
18314
  cap: asked < requested ? asked : null
18137
18315
  } : null,
18138
18316
  actionMs,
18317
+ sourceMs,
18139
18318
  plannedTransitionMs: timings.zoomInMs
18140
18319
  };
18141
18320
  seeds.push(seed);
@@ -18144,7 +18323,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18144
18323
  seeds.sort((a, b) => a.outputTimeMs - b.outputTimeMs);
18145
18324
  for (const [i, seed] of seeds.entries()) {
18146
18325
  const before = seeds[i - 1];
18147
- const pans = before !== void 0 && !returnsBetween(heldUntilOf(before, seed.actionMs, holds), seed.outputTimeMs, timings);
18326
+ const pans = before !== void 0 && arrivesOf(seed, before, holds, edited, timings) === "pan";
18148
18327
  const notBeforeMs = (actEndOf.get(seed) ?? Number.NEGATIVE_INFINITY) + (pans ? 0 : CAMERA_DEFAULTS.actSettleMs);
18149
18328
  if (seed.outputTimeMs - timings.zoomInMs < notBeforeMs) {
18150
18329
  seed.transitionMs = Math.max(MIN_PAN_MS, Math.min(timings.zoomInMs, seed.outputTimeMs - notBeforeMs));
@@ -18162,13 +18341,15 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18162
18341
  stiffness: timings.stiffness,
18163
18342
  zoom: false,
18164
18343
  authoredEndMs: null,
18344
+ arrives: null,
18165
18345
  endUnplaced: false,
18166
18346
  fitted: null,
18167
18347
  actionMs: 0,
18348
+ sourceMs: 0,
18168
18349
  plannedTransitionMs: 0
18169
18350
  },
18170
18351
  ...seeds
18171
- ].sort((a, b) => a.outputTimeMs - b.outputTimeMs), timeline.outputDurationMs, timings, holds);
18352
+ ].sort((a, b) => a.outputTimeMs - b.outputTimeMs), timeline.outputDurationMs, timings, holds, edited);
18172
18353
  }
18173
18354
  function fitScaleFor(rect2, window2) {
18174
18355
  const margin = 2 * CAMERA_DEFAULTS.fitMarginPx;
@@ -18184,10 +18365,17 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18184
18365
  const { minPlateauMs } = CAMERA_DEFAULTS.neutral;
18185
18366
  return nextArrivalMs - timings.zoomInMs - minPlateauMs >= heldUntilMs + minPlateauMs + timings.zoomOutMs;
18186
18367
  }
18368
+ function arrivesOf(seed, before, holds, edited, timings) {
18369
+ const fits = returnsBetween(heldUntilOf(before, seed.actionMs, holds), seed.outputTimeMs, { zoomInMs: seed.plannedTransitionMs, zoomOutMs: timings.zoomOutMs });
18370
+ if (seed.arrives !== null && !edited(before, seed)) {
18371
+ return seed.arrives === "return" && !fits ? "pan" : seed.arrives;
18372
+ }
18373
+ return fits ? "return" : "pan";
18374
+ }
18187
18375
  function pullOutLandsAt(heldUntilMs, timings) {
18188
18376
  return heldUntilMs + CAMERA_DEFAULTS.neutral.zoomHoldMs + timings.zoomOutMs;
18189
18377
  }
18190
- function insertNeutralKeys(seeds, outputDurationMs, timings, holds = []) {
18378
+ function insertNeutralKeys(seeds, outputDurationMs, timings, holds = [], edited = () => false) {
18191
18379
  const { neutral } = CAMERA_DEFAULTS;
18192
18380
  const { zoomOutMs } = timings;
18193
18381
  const keys = [];
@@ -18249,10 +18437,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18249
18437
  continue;
18250
18438
  }
18251
18439
  const latestMs = next.outputTimeMs - next.plannedTransitionMs - neutral.minPlateauMs;
18252
- if (!returnsBetween(heldUntil, next.outputTimeMs, {
18253
- zoomInMs: next.plannedTransitionMs,
18254
- zoomOutMs
18255
- })) {
18440
+ if (arrivesOf(next, seed, holds, edited, timings) === "pan") {
18256
18441
  const settledMs = Math.max(seed.outputTimeMs, seed.actionMs, heldUntil) + neutral.minPlateauMs;
18257
18442
  seeds[i + 1] = {
18258
18443
  ...next,
@@ -18364,6 +18549,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18364
18549
  }
18365
18550
  function solveFollow(args) {
18366
18551
  const { keys, cursorAt, holds, outputDurationMs } = args;
18552
+ const legal = args.legal ?? ((center) => center);
18367
18553
  const omega = args.rate / 1e3;
18368
18554
  const held = (t) => holds.some((h) => h.startMs <= t && t < h.endMs);
18369
18555
  const stretches = [];
@@ -18387,9 +18573,22 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18387
18573
  };
18388
18574
  let holding = false;
18389
18575
  let rest = null;
18390
- const targetAt = (t) => {
18576
+ let lead = null;
18577
+ const nextMove = (t, from) => {
18578
+ for (let s = t + FOLLOW_STEP_MS; s < endMs; s += FOLLOW_STEP_MS) {
18579
+ const h = cursorAt?.(s) ?? null;
18580
+ if (h === null)
18581
+ return null;
18582
+ const d = { x: h.x - from.x, y: h.y - from.y };
18583
+ if (Math.hypot(d.x, d.y) >= CURSOR_MOTION_EPSILON_PX)
18584
+ return d;
18585
+ }
18586
+ return null;
18587
+ };
18588
+ const targetAt = (t, dt) => {
18391
18589
  if (held(t)) {
18392
18590
  holding = true;
18591
+ lead = null;
18393
18592
  return aimAt(t);
18394
18593
  }
18395
18594
  const hand = cursorAt?.(t) ?? null;
@@ -18400,15 +18599,47 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18400
18599
  if (hand !== null && rest !== null && Math.hypot(hand.x - rest.x, hand.y - rest.y) < CURSOR_MOTION_EPSILON_PX) {
18401
18600
  return aimAt(t);
18402
18601
  }
18602
+ if (rest !== null && hand !== null)
18603
+ lead = { at: aimAt(t), hand: rest };
18403
18604
  rest = null;
18404
- return hand ?? aimAt(t);
18605
+ if (hand === null) {
18606
+ lead = null;
18607
+ return aimAt(t);
18608
+ }
18609
+ if (lead === null)
18610
+ return hand;
18611
+ const step = { x: hand.x - lead.hand.x, y: hand.y - lead.hand.y };
18612
+ const moved = Math.hypot(step.x, step.y);
18613
+ const carried = { x: lead.at.x + step.x, y: lead.at.y + step.y };
18614
+ const gap = { x: hand.x - carried.x, y: hand.y - carried.y };
18615
+ const left = Math.hypot(gap.x, gap.y);
18616
+ if (moved === 0) {
18617
+ if (lead.next === void 0)
18618
+ lead.next = nextMove(t, hand);
18619
+ const next = lead.next;
18620
+ if (next !== null && gap.x * next.x + gap.y * next.y < 0) {
18621
+ lead = { ...lead, hand };
18622
+ return lead.at;
18623
+ }
18624
+ }
18625
+ const reach = moved > 0 ? moved : left * (1 - Math.exp(-omega * dt));
18626
+ if (left <= reach) {
18627
+ lead = null;
18628
+ return hand;
18629
+ }
18630
+ const k = reach / left;
18631
+ lead = {
18632
+ at: { x: carried.x + gap.x * k, y: carried.y + gap.y * k },
18633
+ hand
18634
+ };
18635
+ return lead.at;
18405
18636
  };
18406
18637
  let x = landing.center;
18407
18638
  let v = { x: 0, y: 0 };
18408
18639
  const centers = [x];
18409
18640
  for (let t = landing.outputTimeMs; t < endMs; t += FOLLOW_STEP_MS) {
18410
- const target = targetAt(t);
18411
18641
  const dt = Math.min(FOLLOW_STEP_MS, endMs - t);
18642
+ const target = legal(targetAt(t, dt), sampleCamera(keys, t).scale);
18412
18643
  const e = Math.exp(-omega * dt);
18413
18644
  const step = (y, vel) => {
18414
18645
  const k = vel + omega * y;
@@ -18460,9 +18691,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18460
18691
  scale: base.scale
18461
18692
  };
18462
18693
  }
18694
+ function legalFor(base, frameRect, viewport, canvas) {
18695
+ return (center, scale) => frameCamera({ center, scale }, base, frameRect, viewport, canvas).center;
18696
+ }
18463
18697
  function frameTrack(track, outputTimeMs, base, frameRect, viewport, canvas) {
18464
- const legal = (center, scale) => frameCamera({ center, scale }, base, frameRect, viewport, canvas).center;
18465
- return frameCamera(sampleTrack(track, outputTimeMs, legal), base, frameRect, viewport, canvas);
18698
+ return frameCamera(sampleTrack(track, outputTimeMs, legalFor(base, frameRect, viewport, canvas)), base, frameRect, viewport, canvas);
18466
18699
  }
18467
18700
 
18468
18701
  // ../../packages/compositor/dist/plan/cursor.js
@@ -18895,7 +19128,23 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18895
19128
  const cutSteps = stepsInsideRemoved(scene);
18896
19129
  const attachedToCuts = [];
18897
19130
  const gapAfter = new Map((scene.edits.gaps ?? []).map((gap) => [gap.afterActionId, gap]));
19131
+ const beatBefore = new Map((scene.pacing?.beats ?? []).map((beat) => [beat.beforeActionId, beat]));
19132
+ const planned = (afterActionId, beforeActionId) => {
19133
+ const beat = beatBefore.get(beforeActionId);
19134
+ return beat ? {
19135
+ afterActionId,
19136
+ beforeActionId,
19137
+ origin: "planned",
19138
+ restMs: beat.restMs,
19139
+ arriveMs: beat.arriveMs,
19140
+ ...beat.afterScrollMs === void 0 ? {} : { afterScrollMs: beat.afterScrollMs }
19141
+ } : void 0;
19142
+ };
18898
19143
  const paces = [];
19144
+ const first = scene.actions[0];
19145
+ const opening = first && planned(null, first.id);
19146
+ if (opening)
19147
+ paces.push(opening);
18899
19148
  for (let i = 0; i + 1 < scene.actions.length; i++) {
18900
19149
  const from = scene.actions[i];
18901
19150
  const to = scene.actions[i + 1];
@@ -18903,7 +19152,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18903
19152
  continue;
18904
19153
  const authored = gapAfter.get(from.id);
18905
19154
  const anchors = { afterActionId: from.id, beforeActionId: to.id };
18906
- paces.push(authored ? { ...anchors, origin: "authored", idleTargetMs: authored.durationMs } : {
19155
+ paces.push(authored ? { ...anchors, origin: "authored", idleTargetMs: authored.durationMs } : planned(from.id, to.id) ?? {
18907
19156
  ...anchors,
18908
19157
  origin: "recorded",
18909
19158
  // Raw, and negative when the log does not ascend. This carried a
@@ -18963,6 +19212,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18963
19212
  ];
18964
19213
  }),
18965
19214
  paces,
19215
+ tailMs: scene.pacing?.tailMs ?? null,
18966
19216
  removed,
18967
19217
  removedSteps: [...cutSteps],
18968
19218
  attachedToCuts,
@@ -19182,7 +19432,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19182
19432
  endMs: toOutputMs(timeline, h.releaseMs)
19183
19433
  })),
19184
19434
  outputDurationMs: timeline.outputDurationMs,
19185
- rate: motionTimings(motion.smoothness).followRatePerS
19435
+ rate: motionTimings(motion.smoothness).followRatePerS,
19436
+ ...args.legal === void 0 ? {} : { legal: args.legal }
19186
19437
  });
19187
19438
  }
19188
19439
  function resolvePlan(givenPlan, given, givenScene, hints = [], cameraFitWindow = null) {
@@ -19220,13 +19471,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19220
19471
  const settleMs = bundle.source === "capture" ? springSettleMs(CURSOR_SPRING_TAU_MS) : 0;
19221
19472
  const leadMs = bundle.source === "capture" ? springLeadMs(CURSOR_SPRING_TAU_MS) : 0;
19222
19473
  const motionHints = [
19223
- ...hints,
19224
19474
  ...cursorMotionSpans(travelled).map((span) => ({
19225
19475
  startMs: Math.max(0, span.startMs - leadMs),
19226
19476
  endMs: span.endMs + settleMs
19227
19477
  }))
19228
19478
  ];
19229
- let timeline = buildTimeline(plan, bundle, motionHints);
19479
+ let timeline = buildTimeline(plan, bundle, motionHints, hints);
19230
19480
  const unplacedIds = new Set(timeline.unplacedCuts.flatMap((u) => u.ids));
19231
19481
  if (unplacedIds.size > 0 && givenScene !== void 0) {
19232
19482
  const kept = planScene({
@@ -19244,7 +19494,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19244
19494
  removedSteps: kept.removedSteps,
19245
19495
  attachedToCuts: kept.attachedToCuts
19246
19496
  };
19247
- timeline = buildTimeline(plan, bundle, motionHints);
19497
+ timeline = buildTimeline(plan, bundle, motionHints, hints);
19248
19498
  }
19249
19499
  const bridged = bridgeCutSeams(cursor, timeline, CUT_BRIDGE_MS);
19250
19500
  const trim = resolveRange({
@@ -19263,7 +19513,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19263
19513
  startMs: toOutputMs(timeline, h.pressMs),
19264
19514
  endMs: toOutputMs(timeline, h.releaseMs)
19265
19515
  }));
19266
- const camera = solveCamera(plan.cameraIntents, rectOf, timeline, markerSourceMs, plan.viewport, cameraFitWindow, motion, actEnds, holdOutputMs);
19516
+ const camera = solveCamera(plan.cameraIntents, rectOf, timeline, markerSourceMs, plan.viewport, cameraFitWindow, motion, actEnds, holdOutputMs, (scene?.edits.gaps ?? []).map((gap) => gap.afterActionId));
19267
19517
  const intentAction = new Map(plan.cameraIntents.map((intent) => [intent.id, intent.actionId]));
19268
19518
  const loweredZooms = [];
19269
19519
  for (const segment of camera.segments) {
@@ -47998,6 +48248,18 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
47998
48248
  const k = contentScale(frameRect, viewport);
47999
48249
  return { width: frameRect.width / k, height: frameRect.height / k };
48000
48250
  }
48251
+ function followInReach(resolved, bundle, keys, frameRect, viewport, canvas) {
48252
+ return resolveCameraFollow({
48253
+ keys,
48254
+ plan: resolved.plan,
48255
+ bundle,
48256
+ timeline: resolved.timeline,
48257
+ cursor: resolved.cursor,
48258
+ motion: resolved.motion,
48259
+ drawsPointer: !resolved.touch && !resolved.cursorLook.hidden,
48260
+ legal: legalFor(contentScale(frameRect, viewport), frameRect, viewport, canvas)
48261
+ });
48262
+ }
48001
48263
  function composeForTarget(args) {
48002
48264
  const { plan, bundle, scene, target, hints, logo = null, wallpaper = null } = args;
48003
48265
  const detailTarget = args.detailTarget ?? target;
@@ -48015,15 +48277,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
48015
48277
  resolved: {
48016
48278
  ...resolved,
48017
48279
  cameraKeys: detail.keys,
48018
- cameraFollow: resolveCameraFollow({
48019
- keys: detail.keys,
48020
- plan: resolved.plan,
48021
- bundle,
48022
- timeline: resolved.timeline,
48023
- cursor: resolved.cursor,
48024
- motion: resolved.motion,
48025
- drawsPointer: !resolved.touch && !resolved.cursorLook.hidden
48026
- })
48280
+ cameraFollow: followInReach(resolved, bundle, detail.keys, presentation.frameRect, resolved.plan.viewport, target)
48027
48281
  },
48028
48282
  presentation,
48029
48283
  violations: detail.violations