demoman 0.9.4 → 0.9.6

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.
@@ -15416,6 +15416,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15416
15416
  pressMs: external_exports.number().nonnegative(),
15417
15417
  releaseMs: external_exports.number().nonnegative()
15418
15418
  });
15419
+ var PageScreenSchema = external_exports.object({
15420
+ after: external_exports.number().int().min(0),
15421
+ sourceTimeMs: external_exports.number(),
15422
+ ref: external_exports.string(),
15423
+ width: external_exports.number().int().positive(),
15424
+ height: external_exports.number().int().positive(),
15425
+ heldAnimations: external_exports.number().int().min(0),
15426
+ waitedMs: external_exports.number().min(0),
15427
+ unsettled: external_exports.string().optional()
15428
+ }).refine((s) => s.ref !== "" || s.unsettled !== void 0, {
15429
+ message: 'a page screen with no bytes (ref "") must say why in `unsettled`',
15430
+ path: ["unsettled"]
15431
+ });
15419
15432
  var ViewportTransformSchema = external_exports.object({
15420
15433
  sourceTimeMs: external_exports.number().nonnegative(),
15421
15434
  scale: external_exports.number().positive(),
@@ -15440,7 +15453,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15440
15453
  /** The longest single hold within `roomMs` (a settle or the camera's
15441
15454
  * room, not a wait for the page to go quiet): what the film check may
15442
15455
  * take for Demoman's pacing inside one still stretch. */
15443
- 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()
15444
15462
  }).superRefine((marker, ctx) => {
15445
15463
  if (marker.actEndSourceTimeMs !== void 0 && marker.actEndSourceTimeMs < marker.sourceTimeMs) {
15446
15464
  ctx.addIssue({
@@ -15541,7 +15559,27 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15541
15559
  // A native drag's picture could not be drawn in the page (the element
15542
15560
  // the page named for it was gone, or copying it threw). The drag still
15543
15561
  // ran; the film shows the card jump to its drop instead of travelling.
15544
- "dragPictureMissing"
15562
+ "dragPictureMissing",
15563
+ // A step's page had not settled when the cap ran out (requests in
15564
+ // flight, an animation running, the DOM still changing) or showed a
15565
+ // caret it would not hide: the page's own doing. The video is
15566
+ // unaffected; refresh cannot compare that screen. The note names the
15567
+ // step and the conditions.
15568
+ "stepUnsettled",
15569
+ // As `stepUnsettled`, but at least one condition was this machine's:
15570
+ // the first paint never came, the settle probe or the page screen
15571
+ // failed, requests could not be watched. Recording again may change
15572
+ // it, so refresh does (DEM-55); the note names the step and the
15573
+ // conditions, the page's beside the machine's.
15574
+ "stepSettleFailed",
15575
+ // A step's settle left out a request open since more than a request cap
15576
+ // before the step began (a long poll): its own step waited for it. The
15577
+ // screen counts as settled; the note names the step and how many.
15578
+ "requestNotWaited",
15579
+ // A page screen's hold (caret hidden, endless animations held) could not
15580
+ // be undone after the capture: the video after that step may show no
15581
+ // caret and frozen spinners. About the video, so not forgiven.
15582
+ "pageHoldNotReleased"
15545
15583
  ]),
15546
15584
  note: external_exports.string()
15547
15585
  });
@@ -15603,6 +15641,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15603
15641
  // 2026-10-11 carries none, and identity is what they were drawn as.
15604
15642
  // See `ViewportTransformSchema`.
15605
15643
  viewportTransforms: external_exports.array(ViewportTransformSchema).optional(),
15644
+ // Optional, and absent is none: a sampled replay, a capture, and every
15645
+ // bundle written before 2026-11-10 carry none.
15646
+ pageScreens: external_exports.array(PageScreenSchema).optional(),
15606
15647
  markers: external_exports.array(MarkerSchema),
15607
15648
  degradations: external_exports.array(DegradationSchema),
15608
15649
  /**
@@ -16203,7 +16244,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16203
16244
  * own edit. The record that write-back reads, never inferred from the
16204
16245
  * scale's value. Absent when the scale was the default.
16205
16246
  */
16206
- scaleSetBy: external_exports.enum(["script", "author"]).optional()
16247
+ scaleSetBy: external_exports.enum(["script", "author"]).optional(),
16248
+ /**
16249
+ * How the camera reaches this zoom, decided once at record time from the
16250
+ * beat plan: `pan` slides from the zoom before it, `return` pulls back to
16251
+ * full frame first. Absent: the renderer's own clock (every earlier take).
16252
+ */
16253
+ arrives: external_exports.enum(["pan", "return"]).optional()
16207
16254
  });
16208
16255
  var ZoomSkipped = external_exports.union([
16209
16256
  external_exports.object({
@@ -16490,6 +16537,24 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16490
16537
  anchors: external_exports.array(Anchor),
16491
16538
  actions: external_exports.array(Action),
16492
16539
  camera: external_exports.array(CameraEvent),
16540
+ /**
16541
+ * The take's pauses, planned rather than measured: one beat per action,
16542
+ * in order. Absent on every take recorded before the plan existed.
16543
+ */
16544
+ pacing: external_exports.object({
16545
+ beats: external_exports.array(external_exports.object({
16546
+ beforeActionId: external_exports.string().min(1),
16547
+ /** Dead air before the action. */
16548
+ restMs: external_exports.number().min(0),
16549
+ /** How long the walk to the action takes. */
16550
+ arriveMs: external_exports.number().min(0),
16551
+ /** Dead air from the approach scroll's end to the journey's
16552
+ * start. Only on a step whose approach scrolled. */
16553
+ afterScrollMs: external_exports.number().min(0).optional()
16554
+ })),
16555
+ /** Dead air after the last action's motion. */
16556
+ tailMs: external_exports.number().min(0)
16557
+ }).optional(),
16493
16558
  /** See `ZoomSkipped`. */
16494
16559
  zoomsSkipped: external_exports.array(ZoomSkipped).optional(),
16495
16560
  edits: external_exports.object({
@@ -17555,6 +17620,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17555
17620
  const instants = [];
17556
17621
  let unplacedPaces = 0;
17557
17622
  for (const pace of plan.paces) {
17623
+ if (pace.origin === "planned")
17624
+ continue;
17558
17625
  const from = markerAt.get(pace.afterActionId);
17559
17626
  const to = markerAt.get(pace.beforeActionId);
17560
17627
  if (from === void 0 || to === void 0) {
@@ -17575,7 +17642,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17575
17642
  unplacedPaces
17576
17643
  };
17577
17644
  }
17578
- function rawSegmentsOf(plan, bundle, motion, sourceDurationMs, cuts) {
17645
+ function rawSegmentsOf(bundle, motion, sourceDurationMs, cuts, regions) {
17579
17646
  const cutSet = /* @__PURE__ */ new Set([0, sourceDurationMs]);
17580
17647
  for (const marker of bundle.markers)
17581
17648
  cutSet.add(marker.sourceTimeMs);
@@ -17587,6 +17654,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17587
17654
  cutSet.add(cut.srcStartMs);
17588
17655
  cutSet.add(cut.srcEndMs);
17589
17656
  }
17657
+ for (const region of regions) {
17658
+ cutSet.add(region.srcStartMs);
17659
+ cutSet.add(region.srcEndMs);
17660
+ }
17590
17661
  const ordered = [...cutSet].filter((t) => t >= 0 && t <= sourceDurationMs).sort((a, b) => a - b);
17591
17662
  const isMotion = (start, end) => motion.some((s) => s.startMs <= start && s.endMs >= end && end > start);
17592
17663
  const raw = [];
@@ -17601,50 +17672,112 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17601
17672
  if (insideCutClosed(cuts, (srcStartMs + srcEndMs) / 2))
17602
17673
  continue;
17603
17674
  const kind = isMotion(srcStartMs, srcEndMs) ? "motion" : "idle";
17604
- const outDurationMs = kind === "motion" ? srcDuration : idleOutputFor(plan, bundle, motion, cuts, srcStartMs, srcEndMs, srcDuration);
17675
+ const outDurationMs = kind === "motion" ? srcDuration : idleOutputFor(regions, srcStartMs, srcEndMs, srcDuration);
17605
17676
  raw.push({ srcStartMs, srcEndMs, kind, outDurationMs });
17606
17677
  }
17607
17678
  return raw;
17608
17679
  }
17609
- function authoredPaceCovering(plan, bundle, srcStartMs, srcEndMs) {
17680
+ function authoredRegions(plan, bundle, idleIn) {
17610
17681
  if (!isRealTime(bundle))
17611
- return void 0;
17612
- if (!plan.paces)
17613
- return void 0;
17682
+ return [];
17614
17683
  const markerAt = new Map(bundle.markers.map((m) => [m.actionId, m.sourceTimeMs]));
17615
- return plan.paces.find((pace) => {
17684
+ return (plan.paces ?? []).flatMap((pace) => {
17616
17685
  if (pace.origin !== "authored")
17617
- return false;
17686
+ return [];
17618
17687
  if (gapPacedLive(bundle, pace.afterActionId, pace.idleTargetMs)) {
17619
- return false;
17688
+ return [];
17620
17689
  }
17621
17690
  const after = markerAt.get(pace.afterActionId);
17622
17691
  const before = markerAt.get(pace.beforeActionId);
17623
17692
  if (after === void 0 || before === void 0)
17624
- return false;
17625
- return after <= srcStartMs && srcEndMs <= before;
17693
+ return [];
17694
+ return [
17695
+ {
17696
+ srcStartMs: after,
17697
+ srcEndMs: before,
17698
+ targetMs: pace.idleTargetMs,
17699
+ idleMs: idleIn(after, before)
17700
+ }
17701
+ ];
17626
17702
  });
17627
17703
  }
17628
- function idleMsBetweenMarkers(bundle, motion, removed, pace) {
17629
- const markerAt = new Map(bundle.markers.map((m) => [m.actionId, m.sourceTimeMs]));
17630
- const after = markerAt.get(pace.afterActionId);
17631
- const before = markerAt.get(pace.beforeActionId);
17632
- if (after === void 0 || before === void 0)
17633
- return 0;
17704
+ function plannedIdleOf(plan, bundle, idleIn, cuts, interruptions, sourceDurationMs) {
17705
+ const regions = [];
17706
+ const freezes = [];
17707
+ const unplacedBeatSteps = [];
17708
+ if (!isRealTime(bundle)) {
17709
+ return { regions, freezes, unplacedPaces: 0, unplacedBeatSteps };
17710
+ }
17711
+ const markerOf = new Map(bundle.markers.map((m) => [m.actionId, m]));
17712
+ const share = (srcStartMs, srcEndMs, targetMs) => {
17713
+ const idleMs = idleIn(srcStartMs, srcEndMs);
17714
+ if (idleMs > 0) {
17715
+ regions.push({ srcStartMs, srcEndMs, targetMs, idleMs });
17716
+ return true;
17717
+ }
17718
+ if (targetMs <= 0 || insideCutClosed(cuts, srcEndMs))
17719
+ return true;
17720
+ const gone = interruptions.find((s) => s.startMs <= srcEndMs && srcEndMs < s.endMs);
17721
+ const at = gone ? gone.startMs : srcEndMs;
17722
+ if (gone && (at <= srcStartMs || insideCutClosed(cuts, at)))
17723
+ return false;
17724
+ freezes.push({ sourceTimeMs: at, durationMs: targetMs });
17725
+ return true;
17726
+ };
17727
+ const afterAct = (prev, endMs) => {
17728
+ const end = prev.actEndSourceTimeMs;
17729
+ if (end === void 0 || end < prev.sourceTimeMs || end > endMs) {
17730
+ return prev.sourceTimeMs;
17731
+ }
17732
+ share(prev.sourceTimeMs, end, 0);
17733
+ return end;
17734
+ };
17735
+ for (const pace of plan.paces ?? []) {
17736
+ if (pace.origin !== "planned")
17737
+ continue;
17738
+ const prev = pace.afterActionId === null ? { sourceTimeMs: 0 } : markerOf.get(pace.afterActionId);
17739
+ const step = markerOf.get(pace.beforeActionId);
17740
+ const approach = step?.approachSourceTimeMs;
17741
+ const scrollEnd = step?.scrollEndSourceTimeMs;
17742
+ 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
17743
+ // what to play after it. One without the other is not guessed at.
17744
+ scrollEnd === void 0 !== (pace.afterScrollMs === void 0) || scrollEnd !== void 0 && (scrollEnd < prev.sourceTimeMs || scrollEnd > approach)) {
17745
+ unplacedBeatSteps.push(pace.beforeActionId);
17746
+ continue;
17747
+ }
17748
+ const restEnd = scrollEnd ?? approach;
17749
+ const rest = share(afterAct(prev, restEnd), restEnd, pace.restMs);
17750
+ const scroll = scrollEnd === void 0 || pace.afterScrollMs === void 0 ? true : share(scrollEnd, approach, pace.afterScrollMs);
17751
+ const arrive = share(approach, step.sourceTimeMs, pace.arriveMs);
17752
+ if (!rest || !scroll || !arrive)
17753
+ unplacedBeatSteps.push(pace.beforeActionId);
17754
+ }
17755
+ if (plan.tailMs != null) {
17756
+ const lastStep = plan.paces?.at(-1)?.beforeActionId;
17757
+ const last2 = lastStep === void 0 ? void 0 : markerOf.get(lastStep);
17758
+ if (last2 === void 0 || !share(afterAct(last2, sourceDurationMs), sourceDurationMs, plan.tailMs)) {
17759
+ unplacedBeatSteps.push(null);
17760
+ }
17761
+ }
17762
+ return {
17763
+ regions,
17764
+ freezes,
17765
+ unplacedPaces: unplacedBeatSteps.length,
17766
+ unplacedBeatSteps
17767
+ };
17768
+ }
17769
+ function idleMsIn(motion, removed, fromMs, toMs) {
17634
17770
  const notIdle = merge2([
17635
17771
  ...motion,
17636
17772
  ...removed.map((cut) => ({ startMs: cut.srcStartMs, endMs: cut.srcEndMs }))
17637
17773
  ]);
17638
- return Math.max(0, before - after - motionMsBetween(notIdle, after, before));
17774
+ return Math.max(0, toMs - fromMs - motionMsBetween(notIdle, fromMs, toMs));
17639
17775
  }
17640
- function idleOutputFor(plan, bundle, motion, removed, srcStartMs, srcEndMs, srcDuration) {
17641
- const pace = authoredPaceCovering(plan, bundle, srcStartMs, srcEndMs);
17642
- if (!pace)
17643
- return srcDuration;
17644
- const idleTotal = idleMsBetweenMarkers(bundle, motion, removed, pace);
17645
- if (idleTotal <= 0)
17776
+ function idleOutputFor(regions, srcStartMs, srcEndMs, srcDuration) {
17777
+ const region = regions.find((r) => r.srcStartMs <= srcStartMs && srcEndMs <= r.srcEndMs);
17778
+ if (!region || region.idleMs <= 0)
17646
17779
  return srcDuration;
17647
- return pace.idleTargetMs * (srcDuration / idleTotal);
17780
+ return region.targetMs * (srcDuration / region.idleMs);
17648
17781
  }
17649
17782
  function splitAtHold(raw, sourceTimeMs) {
17650
17783
  const idx = raw.findIndex((s) => s.srcStartMs + HOLD_EPSILON_MS < sourceTimeMs && sourceTimeMs < s.srcEndMs - HOLD_EPSILON_MS);
@@ -17715,8 +17848,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17715
17848
  const settleMs = bundle.source === "capture" ? springSettleMs(CURSOR_SPRING_TAU_MS) : 0;
17716
17849
  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);
17717
17850
  }
17718
- function buildTimeline(plan, bundle, hints = []) {
17719
- const motion = motionSpansOf(bundle, hints);
17851
+ function buildTimeline(plan, bundle, hints = [], keyframeHints = []) {
17852
+ const isPlanned = plan.tailMs !== null || (plan.paces ?? []).some((pace) => pace.origin === "planned");
17853
+ const motion = motionSpansOf(bundle, isPlanned ? hints : [...hints, ...keyframeHints]);
17720
17854
  const sourceDurationMs = sourceDurationOf(bundle);
17721
17855
  const { cuts, unplacedCuts } = cutRanges(plan, bundle, sourceDurationMs);
17722
17856
  const interruptions = interruptionsOf(bundle, cuts);
@@ -17730,9 +17864,17 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17730
17864
  }))
17731
17865
  ].sort((a, b) => a.srcStartMs - b.srcStartMs);
17732
17866
  const holds = holdInstants(plan, bundle, sourceDurationMs, cuts);
17733
- const { instants: paces, unplacedPaces } = paceInstants(plan, bundle, motion, cuts);
17867
+ const recorded = paceInstants(plan, bundle, motion, cuts);
17868
+ const idleIn = (fromMs, toMs) => idleMsIn(motion, removed, fromMs, toMs);
17869
+ const planned = plannedIdleOf(plan, bundle, idleIn, cuts, interruptions, sourceDurationMs);
17870
+ const regions = [
17871
+ ...authoredRegions(plan, bundle, idleIn),
17872
+ ...planned.regions
17873
+ ];
17874
+ const paces = [...recorded.instants, ...planned.freezes].sort((a, b) => a.sourceTimeMs - b.sourceTimeMs);
17875
+ const unplacedPaces = recorded.unplacedPaces + planned.unplacedPaces;
17734
17876
  const nonMonotonicPaces = (plan.paces ?? []).filter((pace) => pace.origin === "recorded" && pace.recordedSpanMs < 0).length;
17735
- let raw = rawSegmentsOf(plan, bundle, motion, sourceDurationMs, removed);
17877
+ let raw = rawSegmentsOf(bundle, motion, sourceDurationMs, removed, regions);
17736
17878
  for (const hold of holds)
17737
17879
  raw = splitAtHold(raw, hold.sourceTimeMs);
17738
17880
  for (const pace of paces)
@@ -17768,6 +17910,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17768
17910
  }
17769
17911
  };
17770
17912
  const isSeam = (sourceTimeMs) => cuts.some((cut) => Math.abs(cut.srcStartMs - sourceTimeMs) <= HOLD_EPSILON_MS);
17913
+ const opensInterruption = (sourceTimeMs) => interruptions.some((span) => Math.abs(span.startMs - sourceTimeMs) <= HOLD_EPSILON_MS);
17771
17914
  for (const seg of raw) {
17772
17915
  emitHoldsAt(seg.srcStartMs);
17773
17916
  emitPacesAt(seg.srcStartMs);
@@ -17779,13 +17922,26 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17779
17922
  kind: seg.kind
17780
17923
  });
17781
17924
  outCursor += seg.outDurationMs;
17782
- if (isSeam(seg.srcEndMs)) {
17925
+ if (isSeam(seg.srcEndMs))
17783
17926
  emitHoldsAt(seg.srcEndMs);
17927
+ if (isSeam(seg.srcEndMs) || opensInterruption(seg.srcEndMs)) {
17784
17928
  emitPacesAt(seg.srcEndMs);
17785
17929
  }
17786
17930
  }
17787
17931
  emitHoldsAt(sourceDurationMs);
17788
17932
  emitPacesAt(sourceDurationMs);
17933
+ const placedIdle = [];
17934
+ for (const seg of segments) {
17935
+ 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);
17936
+ if (!isPlaced || seg.outEndMs <= seg.outStartMs)
17937
+ continue;
17938
+ const last2 = placedIdle.at(-1);
17939
+ if (last2 && seg.outStartMs - last2.endMs <= HOLD_EPSILON_MS) {
17940
+ last2.endMs = seg.outEndMs;
17941
+ } else {
17942
+ placedIdle.push({ startMs: seg.outStartMs, endMs: seg.outEndMs });
17943
+ }
17944
+ }
17789
17945
  return {
17790
17946
  segments,
17791
17947
  outputDurationMs: outCursor,
@@ -17794,6 +17950,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17794
17950
  unplacedCuts,
17795
17951
  interruptions,
17796
17952
  unplacedPaces,
17953
+ // Present only when a beat was unplaced, so a take with no plan builds
17954
+ // the timeline it always did.
17955
+ ...planned.unplacedBeatSteps.length > 0 ? { unplacedBeatSteps: planned.unplacedBeatSteps } : {},
17956
+ ...placedIdle.length > 0 ? { placedIdle } : {},
17797
17957
  nonMonotonicPaces
17798
17958
  };
17799
17959
  }
@@ -18052,14 +18212,20 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18052
18212
  offsetMs: event.marker.offsetMs,
18053
18213
  scale: clamp(event.scale ?? 1, 1, CAMERA_DEFAULTS.maxScale),
18054
18214
  end: event.end ?? null,
18215
+ ...event.arrives === void 0 ? {} : { arrives: event.arrives },
18055
18216
  ...fitOf(event)
18056
18217
  })).filter((intent) => intent.scale > 1).sort((a, b) => {
18057
18218
  const byAction = (order.get(a.actionId) ?? 0) - (order.get(b.actionId) ?? 0);
18058
18219
  return byAction !== 0 ? byAction : a.offsetMs - b.offsetMs;
18059
18220
  });
18060
18221
  }
18061
- function solveCamera(intents, rectOf, timeline, markerSourceMs, viewport, fitWindow = null, motion = MOTION_DEFAULTS, actEnds = /* @__PURE__ */ new Map(), holds = []) {
18222
+ function solveCamera(intents, rectOf, timeline, markerSourceMs, viewport, fitWindow = null, motion = MOTION_DEFAULTS, actEnds = /* @__PURE__ */ new Map(), holds = [], gapAfterActionIds = []) {
18062
18223
  const timings = motionTimings(motion.smoothness);
18224
+ const gaps = gapAfterActionIds.flatMap((id) => {
18225
+ const at = markerSourceMs.get(id);
18226
+ return at === void 0 ? [] : [toOutputMs(timeline, at)];
18227
+ });
18228
+ 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);
18063
18229
  const neutral = { x: viewport.width / 2, y: viewport.height / 2 };
18064
18230
  const seeds = [];
18065
18231
  const actEndOf = /* @__PURE__ */ new Map();
@@ -18093,6 +18259,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18093
18259
  stiffness: timings.stiffness,
18094
18260
  zoom: true,
18095
18261
  authoredEndMs: resolvedEndMs,
18262
+ arrives: intent.arrives ?? null,
18096
18263
  endUnplaced: intent.end !== null && resolvedEndMs === null,
18097
18264
  fitted: scale < requested ? {
18098
18265
  from: requested,
@@ -18100,6 +18267,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18100
18267
  cap: asked < requested ? asked : null
18101
18268
  } : null,
18102
18269
  actionMs,
18270
+ sourceMs,
18103
18271
  plannedTransitionMs: timings.zoomInMs
18104
18272
  };
18105
18273
  seeds.push(seed);
@@ -18108,7 +18276,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18108
18276
  seeds.sort((a, b) => a.outputTimeMs - b.outputTimeMs);
18109
18277
  for (const [i, seed] of seeds.entries()) {
18110
18278
  const before = seeds[i - 1];
18111
- const pans = before !== void 0 && !returnsBetween(heldUntilOf(before, seed.actionMs, holds), seed.outputTimeMs, timings);
18279
+ const pans = before !== void 0 && arrivesOf(seed, before, holds, edited, timings) === "pan";
18112
18280
  const notBeforeMs = (actEndOf.get(seed) ?? Number.NEGATIVE_INFINITY) + (pans ? 0 : CAMERA_DEFAULTS.actSettleMs);
18113
18281
  if (seed.outputTimeMs - timings.zoomInMs < notBeforeMs) {
18114
18282
  seed.transitionMs = Math.max(MIN_PAN_MS, Math.min(timings.zoomInMs, seed.outputTimeMs - notBeforeMs));
@@ -18126,13 +18294,15 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18126
18294
  stiffness: timings.stiffness,
18127
18295
  zoom: false,
18128
18296
  authoredEndMs: null,
18297
+ arrives: null,
18129
18298
  endUnplaced: false,
18130
18299
  fitted: null,
18131
18300
  actionMs: 0,
18301
+ sourceMs: 0,
18132
18302
  plannedTransitionMs: 0
18133
18303
  },
18134
18304
  ...seeds
18135
- ].sort((a, b) => a.outputTimeMs - b.outputTimeMs), timeline.outputDurationMs, timings, holds);
18305
+ ].sort((a, b) => a.outputTimeMs - b.outputTimeMs), timeline.outputDurationMs, timings, holds, edited);
18136
18306
  }
18137
18307
  function fitScaleFor(rect2, window2) {
18138
18308
  const margin = 2 * CAMERA_DEFAULTS.fitMarginPx;
@@ -18148,10 +18318,17 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18148
18318
  const { minPlateauMs } = CAMERA_DEFAULTS.neutral;
18149
18319
  return nextArrivalMs - timings.zoomInMs - minPlateauMs >= heldUntilMs + minPlateauMs + timings.zoomOutMs;
18150
18320
  }
18321
+ function arrivesOf(seed, before, holds, edited, timings) {
18322
+ const fits = returnsBetween(heldUntilOf(before, seed.actionMs, holds), seed.outputTimeMs, { zoomInMs: seed.plannedTransitionMs, zoomOutMs: timings.zoomOutMs });
18323
+ if (seed.arrives !== null && !edited(before, seed)) {
18324
+ return seed.arrives === "return" && !fits ? "pan" : seed.arrives;
18325
+ }
18326
+ return fits ? "return" : "pan";
18327
+ }
18151
18328
  function pullOutLandsAt(heldUntilMs, timings) {
18152
18329
  return heldUntilMs + CAMERA_DEFAULTS.neutral.zoomHoldMs + timings.zoomOutMs;
18153
18330
  }
18154
- function insertNeutralKeys(seeds, outputDurationMs, timings, holds = []) {
18331
+ function insertNeutralKeys(seeds, outputDurationMs, timings, holds = [], edited = () => false) {
18155
18332
  const { neutral } = CAMERA_DEFAULTS;
18156
18333
  const { zoomOutMs } = timings;
18157
18334
  const keys = [];
@@ -18213,10 +18390,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18213
18390
  continue;
18214
18391
  }
18215
18392
  const latestMs = next.outputTimeMs - next.plannedTransitionMs - neutral.minPlateauMs;
18216
- if (!returnsBetween(heldUntil, next.outputTimeMs, {
18217
- zoomInMs: next.plannedTransitionMs,
18218
- zoomOutMs
18219
- })) {
18393
+ if (arrivesOf(next, seed, holds, edited, timings) === "pan") {
18220
18394
  const settledMs = Math.max(seed.outputTimeMs, seed.actionMs, heldUntil) + neutral.minPlateauMs;
18221
18395
  seeds[i + 1] = {
18222
18396
  ...next,
@@ -18859,7 +19033,23 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18859
19033
  const cutSteps = stepsInsideRemoved(scene);
18860
19034
  const attachedToCuts = [];
18861
19035
  const gapAfter = new Map((scene.edits.gaps ?? []).map((gap) => [gap.afterActionId, gap]));
19036
+ const beatBefore = new Map((scene.pacing?.beats ?? []).map((beat) => [beat.beforeActionId, beat]));
19037
+ const planned = (afterActionId, beforeActionId) => {
19038
+ const beat = beatBefore.get(beforeActionId);
19039
+ return beat ? {
19040
+ afterActionId,
19041
+ beforeActionId,
19042
+ origin: "planned",
19043
+ restMs: beat.restMs,
19044
+ arriveMs: beat.arriveMs,
19045
+ ...beat.afterScrollMs === void 0 ? {} : { afterScrollMs: beat.afterScrollMs }
19046
+ } : void 0;
19047
+ };
18862
19048
  const paces = [];
19049
+ const first = scene.actions[0];
19050
+ const opening = first && planned(null, first.id);
19051
+ if (opening)
19052
+ paces.push(opening);
18863
19053
  for (let i = 0; i + 1 < scene.actions.length; i++) {
18864
19054
  const from = scene.actions[i];
18865
19055
  const to = scene.actions[i + 1];
@@ -18867,7 +19057,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18867
19057
  continue;
18868
19058
  const authored = gapAfter.get(from.id);
18869
19059
  const anchors = { afterActionId: from.id, beforeActionId: to.id };
18870
- paces.push(authored ? { ...anchors, origin: "authored", idleTargetMs: authored.durationMs } : {
19060
+ paces.push(authored ? { ...anchors, origin: "authored", idleTargetMs: authored.durationMs } : planned(from.id, to.id) ?? {
18871
19061
  ...anchors,
18872
19062
  origin: "recorded",
18873
19063
  // Raw, and negative when the log does not ascend. This carried a
@@ -18927,6 +19117,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18927
19117
  ];
18928
19118
  }),
18929
19119
  paces,
19120
+ tailMs: scene.pacing?.tailMs ?? null,
18930
19121
  removed,
18931
19122
  removedSteps: [...cutSteps],
18932
19123
  attachedToCuts,
@@ -19184,13 +19375,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19184
19375
  const settleMs = bundle.source === "capture" ? springSettleMs(CURSOR_SPRING_TAU_MS) : 0;
19185
19376
  const leadMs = bundle.source === "capture" ? springLeadMs(CURSOR_SPRING_TAU_MS) : 0;
19186
19377
  const motionHints = [
19187
- ...hints,
19188
19378
  ...cursorMotionSpans(travelled).map((span) => ({
19189
19379
  startMs: Math.max(0, span.startMs - leadMs),
19190
19380
  endMs: span.endMs + settleMs
19191
19381
  }))
19192
19382
  ];
19193
- let timeline = buildTimeline(plan, bundle, motionHints);
19383
+ let timeline = buildTimeline(plan, bundle, motionHints, hints);
19194
19384
  const unplacedIds = new Set(timeline.unplacedCuts.flatMap((u) => u.ids));
19195
19385
  if (unplacedIds.size > 0 && givenScene !== void 0) {
19196
19386
  const kept = planScene({
@@ -19208,7 +19398,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19208
19398
  removedSteps: kept.removedSteps,
19209
19399
  attachedToCuts: kept.attachedToCuts
19210
19400
  };
19211
- timeline = buildTimeline(plan, bundle, motionHints);
19401
+ timeline = buildTimeline(plan, bundle, motionHints, hints);
19212
19402
  }
19213
19403
  const bridged = bridgeCutSeams(cursor, timeline, CUT_BRIDGE_MS);
19214
19404
  const trim = resolveRange({
@@ -19227,7 +19417,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19227
19417
  startMs: toOutputMs(timeline, h.pressMs),
19228
19418
  endMs: toOutputMs(timeline, h.releaseMs)
19229
19419
  }));
19230
- const camera = solveCamera(plan.cameraIntents, rectOf, timeline, markerSourceMs, plan.viewport, cameraFitWindow, motion, actEnds, holdOutputMs);
19420
+ const camera = solveCamera(plan.cameraIntents, rectOf, timeline, markerSourceMs, plan.viewport, cameraFitWindow, motion, actEnds, holdOutputMs, (scene?.edits.gaps ?? []).map((gap) => gap.afterActionId));
19231
19421
  const intentAction = new Map(plan.cameraIntents.map((intent) => [intent.id, intent.actionId]));
19232
19422
  const loweredZooms = [];
19233
19423
  for (const segment of camera.segments) {
@@ -48150,55 +48340,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
48150
48340
  })
48151
48341
  };
48152
48342
  }
48153
- async function renderScreens(args) {
48154
- const { plan, bundle, scene, target, ports } = args;
48155
- const { logo = null, wallpaper = null } = args;
48156
- const sink = ports.images;
48157
- if (!sink)
48158
- throw new Error("renderScreens needs an image sink");
48159
- const { resolved, presentation, violations } = await composeLikeRender({
48160
- plan,
48161
- bundle,
48162
- scene,
48163
- target,
48164
- ports,
48165
- logo,
48166
- wallpaper
48167
- });
48168
- const { startMs } = resolved.range;
48169
- const screens = screensWithWindows(resolved, presentation, target, scene, bundle, startMs);
48170
- const canvas = ports.surface.create(target.width, target.height);
48171
- const ctx = canvas.getContext("2d");
48172
- for (const [i, m] of screens.moments.entries()) {
48173
- const outputTimeMs = startMs + m.ms;
48174
- const image = await ports.frames.at(toSourceMs(resolved.timeline, outputTimeMs));
48175
- await renderFrame({
48176
- resolved,
48177
- target,
48178
- presentation,
48179
- frames: {
48180
- at: async () => image,
48181
- describe: () => ports.frames.describe()
48182
- },
48183
- ctx,
48184
- outputTimeMs
48185
- });
48186
- await sink.add(canvas, `screen-${i}.png`);
48187
- }
48188
- const files = await sink.finish();
48189
- if (files.length !== screens.moments.length) {
48190
- throw new Error(`${screens.moments.length} screens drawn but the image sink returned ${files.length} files`);
48191
- }
48192
- return {
48193
- screens,
48194
- images: screens.moments.map((m, i) => ({
48195
- step: m.step,
48196
- bytes: files[i].bytes
48197
- })),
48198
- detailViolations: violations,
48199
- unavailableSpans: ports.frames.unavailable?.() ?? []
48200
- };
48201
- }
48202
48343
  function stillSourceMs(bundle, marker) {
48203
48344
  const keyframe = bundle.keyframes.find((k) => k.actionId === marker.actionId);
48204
48345
  return keyframe ? keyframe.sourceTimeMs : marker.sourceTimeMs;
@@ -48585,25 +48726,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
48585
48726
  return true;
48586
48727
  });
48587
48728
  }
48588
- function screenImageName(step) {
48589
- return step === null ? "final.png" : `step-${step}.png`;
48590
- }
48591
- async function scaledPng(bytes2, width) {
48592
- const bitmap = await createImageBitmap(new Blob([bytes2]));
48593
- try {
48594
- const canvas = new OffscreenCanvas(width, Math.round(bitmap.height * width / bitmap.width));
48595
- canvas.getContext("2d").drawImage(bitmap, 0, 0, canvas.width, canvas.height);
48596
- const blob = await canvas.convertToBlob({ type: "image/png" });
48597
- return new Uint8Array(await blob.arrayBuffer());
48598
- } finally {
48599
- bitmap.close();
48600
- }
48601
- }
48602
48729
  async function renderOutput(input) {
48603
48730
  const { fileType, target, scene, bundle, frames, onFrame } = input;
48604
- if (input.screensOnly !== void 0 && fileType === "stills") {
48605
- throw new Error("screensOnly applies to an mp4 or gif output, not stills");
48606
- }
48607
48731
  const logoAt = async (at2) => {
48608
48732
  if (input.logo === null)
48609
48733
  return { logo: null, logoWarning: null };
@@ -48767,57 +48891,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
48767
48891
  }
48768
48892
  };
48769
48893
  }
48770
- if (input.screensOnly !== void 0) {
48771
- const { width } = input.screensOnly;
48772
- const { logo, logoWarning: logoWarning2 } = await logoAt(target);
48773
- const wallpaper = await wallpaperAt(target);
48774
- let result2;
48775
- try {
48776
- result2 = await renderScreens({
48777
- plan,
48778
- bundle,
48779
- scene,
48780
- target,
48781
- ports: { frames, surface, images: createPngSink() },
48782
- logo,
48783
- wallpaper: wallpaper.image
48784
- });
48785
- } finally {
48786
- release(wallpaper.image, wallpaper.held ?? null);
48787
- }
48788
- const deepest = input.wallpaper?.ok !== true ? 1 : composeForTarget({
48789
- plan,
48790
- bundle,
48791
- scene,
48792
- target
48793
- }).resolved.cameraKeys.reduce((m, k) => Math.max(m, k.scale), 1);
48794
- const files = [];
48795
- for (const image of result2.images) {
48796
- files.push({
48797
- name: screenImageName(image.step),
48798
- bytes: await scaledPng(image.bytes, width)
48799
- });
48800
- }
48801
- return {
48802
- files,
48803
- facts: {
48804
- detailViolations: result2.detailViolations,
48805
- unavailableSpans: [...result2.unavailableSpans, ...reclaimed],
48806
- unplacedStills: [],
48807
- loweredZooms: [],
48808
- logoWarning: logoWarning2,
48809
- wallpaperWarning: wallpaperWarning(target, deepest, wallpaper.failed),
48810
- clampedRanges: [],
48811
- // The target's own size: the screens' windows are measured in it.
48812
- rendered: {
48813
- width: target.width,
48814
- height: target.height,
48815
- fps: target.fps
48816
- },
48817
- screens: result2.screens
48818
- }
48819
- };
48820
- }
48821
48894
  const renderAt = async (at2, maxBytes, saysWidth = false, pass) => {
48822
48895
  const { logo, logoWarning: logoWarning2 } = await logoAt(at2);
48823
48896
  const wallpaper = await wallpaperAt(at2);
@@ -49213,7 +49286,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
49213
49286
  },
49214
49287
  ...manifest.stills === void 0 ? {} : { stills: manifest.stills },
49215
49288
  ...manifest.outputTimesMs === void 0 ? {} : { outputTimesMs: manifest.outputTimesMs },
49216
- ...manifest.screensOnly === void 0 ? {} : { screensOnly: manifest.screensOnly },
49217
49289
  onFrame: wholePercent((done, total, width, pass) => width === void 0 ? report?.(done, total) : pass === void 0 ? report?.(done, total, width) : report?.(done, total, width, pass))
49218
49290
  // The decoded image is freed once every output is rendered: the GIF
49219
49291
  // ladder and the MP4 cap re-render inside this call.