@open-take/compositor 0.2.7 → 0.2.8

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-take/compositor",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "description": "Polish compositor (D3) — event log + captured frames -> polished mp4 + editable revideo composition.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -22,7 +22,7 @@
22
22
  "@revideo/core": "0.11.0",
23
23
  "@revideo/ui": "0.11.0",
24
24
  "@revideo/vite-plugin": "0.11.0",
25
- "@open-take/revideo-renderer": "0.2.7"
25
+ "@open-take/revideo-renderer": "0.2.8"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/node": "^22.10.1",
package/src/camera.ts CHANGED
@@ -28,7 +28,7 @@ import type { BBox, CameraConfig, Pt, ZoomIntent } from "./types";
28
28
 
29
29
  /** One action, already mapped into video-px, handed to the director. */
30
30
  export type Beat = {
31
- kind: "click" | "type" | "drag" | "scroll" | "hover" | "press";
31
+ kind: "click" | "type" | "drag" | "scroll" | "hover" | "press" | "dropFiles";
32
32
  tMs: number;
33
33
  durationMs: number;
34
34
  /** element bbox (for a drag: the path's bbox), video-px — or undefined for a
package/src/index.ts CHANGED
@@ -12,7 +12,7 @@ export * from "./presets";
12
12
  export { resolveFfmpeg, resolveFfprobe } from "./ffmpeg";
13
13
  export { planComposition, type PlanOpts } from "./plan";
14
14
  export { directCamera, type Beat, type Framing } from "./camera";
15
- export { renderTake, type RenderTakeOpts } from "./render";
15
+ export { renderTake, type RenderTakeOpts, type RenderTakeResult } from "./render";
16
16
  export {
17
17
  validateComposition,
18
18
  formatIssues,
package/src/math.ts CHANGED
@@ -418,14 +418,23 @@ function buildCameraSchedule(comp: TakeComposition): CameraSchedule {
418
418
  * lands. `null` for a beat the camera holds through (no anchor). Derived from
419
419
  * the same schedule the render uses, so a dwell-delayed pull-out (which
420
420
  * departs after the stored inAtMs and can land after its own tMs) is
421
- * reflected instead of approximated from inAtMs. */
421
+ * reflected instead of approximated from inAtMs. `pullOut` says which pace
422
+ * knob the window belongs to (zoomOutMs vs zoomInMs) — the same test the
423
+ * schedule itself makes, so a reader can't drift from it. */
422
424
  export function cameraRampSchedule(
423
425
  comp: TakeComposition,
424
- ): ({ startMs: number; landMs: number } | null)[] {
425
- const { anchors, ramps, landTs } = buildCameraSchedule(comp);
426
- const out: ({ startMs: number; landMs: number } | null)[] = comp.events.map(() => null);
426
+ ): ({ startMs: number; landMs: number; pullOut: boolean } | null)[] {
427
+ const { anchors, targets, restR, ramps, landTs } = buildCameraSchedule(comp);
428
+ const out: ({ startMs: number; landMs: number; pullOut: boolean } | null)[] = comp.events.map(
429
+ () => null,
430
+ );
427
431
  anchors.forEach((a, i) => {
428
- out[a.evIdx] = { startMs: ramps[i]!.start * 1000, landMs: landTs[i]! * 1000 };
432
+ const from = i > 0 ? targets[i - 1]! : restR;
433
+ out[a.evIdx] = {
434
+ startMs: ramps[i]!.start * 1000,
435
+ landMs: landTs[i]! * 1000,
436
+ pullOut: targets[i]!.w > from.w + 1e-6,
437
+ };
429
438
  });
430
439
  return out;
431
440
  }
@@ -589,39 +598,165 @@ type Leg = {
589
598
  drag?: boolean;
590
599
  path?: Pt[];
591
600
  ease?: "linear" | "smooth";
601
+ /** Diagnostics only (never read by the render): which travel clamp, if
602
+ * either, set this leg's duration instead of the speed law. The clamps run
603
+ * AFTER the speed model, so a clamped leg is one where `travelWidthsPerSec`
604
+ * — and therefore the whole `pace` preset — has no say. validate.ts reports
605
+ * it when it stops being the exception and becomes the rule. */
606
+ clamped?: "min" | "max";
607
+ /** Diagnostics only: the duration (s) the clamped speed law asked for. When
608
+ * the delivered `t1 - t0` is shorter, the previous beat's action ran too
609
+ * late to leave room and the move is being rushed — a CAPTURE-side gap no
610
+ * cursor knob can fix. `evIdx` is the event this leg travels to. */
611
+ wantSec?: number;
612
+ evIdx?: number;
592
613
  };
593
614
 
615
+ /** Cumulative ∫ (rest / cameraScale) dt over the take, on a uniform grid.
616
+ *
617
+ * The integrand is how much of the DELIVERED frame one video-px of movement
618
+ * buys, normalised so a camera at rest integrates to 1 — so this converts a
619
+ * video-px path into the distance the VIEWER actually sees it cross, and
620
+ * INVERTING it answers "when must this move depart to hold a constant
621
+ * on-screen speed". Strictly increasing (the integrand is > 0), so the
622
+ * inverse is single-valued and a binary search finds it. Outside the sampled
623
+ * window the end value extrapolates linearly at the end slope.
624
+ *
625
+ * This is a function of the camera schedule alone (which reads comp.events /
626
+ * comp.cursor, never the legs), so pricing a leg with it introduces no cycle. */
627
+ function zoomFracTrack(cam: { T: number; rest: number; at: (t: number) => { scale: number } }) {
628
+ const STEP = 0.005; // 5ms — ~150× finer than the shortest shipped camera ramp
629
+ const n = Math.max(2, Math.min(20000, Math.ceil(cam.T / STEP) + 1));
630
+ const step = cam.T > 0 ? cam.T / (n - 1) : STEP;
631
+ const zf = (t: number) => cam.rest / Math.max(cam.at(t).scale, 1e-6);
632
+ const cum = new Float64Array(n);
633
+ const zf0 = zf(0);
634
+ let prev = zf0;
635
+ for (let i = 1; i < n; i++) {
636
+ const v = zf(i * step);
637
+ cum[i] = cum[i - 1]! + ((prev + v) / 2) * step; // trapezoid
638
+ prev = v;
639
+ }
640
+ const zfT = prev;
641
+ const tEnd = (n - 1) * step;
642
+ const last = cum[n - 1]!;
643
+ return {
644
+ at(t: number): number {
645
+ if (t <= 0) return t * zf0;
646
+ if (t >= tEnd) return last + (t - tEnd) * zfT;
647
+ const i = Math.floor(t / step);
648
+ const f = t / step - i;
649
+ return cum[i]! + (cum[i + 1]! - cum[i]!) * f;
650
+ },
651
+ /** the t at which the cumulative integral equals `y` */
652
+ invert(y: number): number {
653
+ if (y <= 0) return zf0 > 0 ? y / zf0 : 0;
654
+ if (y >= last) return tEnd + (zfT > 0 ? (y - last) / zfT : 0);
655
+ let lo = 0;
656
+ let hi = n - 1;
657
+ while (hi - lo > 1) {
658
+ const mid = (lo + hi) >> 1;
659
+ if (cum[mid]! <= y) lo = mid;
660
+ else hi = mid;
661
+ }
662
+ const span = cum[hi]! - cum[lo]!;
663
+ return (lo + (span > 0 ? (y - cum[lo]!) / span : 0)) * step;
664
+ },
665
+ };
666
+ }
667
+
594
668
  export function buildLegs(comp: TakeComposition): Leg[] {
595
669
  const legs: Leg[] = [];
596
670
  let cur: Pt = comp.start;
671
+ // When the previous beat's ACTION finishes (tMs + durationMs) — not when its
672
+ // travel leg landed. See the prevEnd comment below.
673
+ let freeAt = 0;
597
674
  // Distance-aware travel: hold a roughly constant on-screen speed (premium
598
675
  // feel) instead of a fixed duration (which makes short moves slow + long
599
676
  // moves fast). Falls back to the fixed travelMs when speed is unset/0.
600
677
  const { travelWidthsPerSec, travelMinMs, travelMaxMs, travelMs } = comp.cursor;
601
- const speedPxPerMs = ((travelWidthsPerSec || 0) * comp.source.videoWidth) / 1000;
602
- const travelDur = (a: Pt, b: Pt): number => {
603
- if (speedPxPerMs <= 0) return travelMs / 1000;
678
+ // ON-SCREEN means the DELIVERED frame, not the raw recording. While the
679
+ // camera is zoomed in, a video-px move covers proportionally more of the
680
+ // frame — so a zoom-blind duration makes every zoomed move read that many
681
+ // times too fast, precisely where the viewer is looking closest (a 2x punch
682
+ // -in doubles the apparent speed).
683
+ // The magnification is not constant ACROSS a leg, though: a travel typically
684
+ // departs while the camera is still wide and lands after it has closed in, so
685
+ // pricing the whole leg at the ARRIVAL magnification (the most punched-in
686
+ // instant it ever sees) over-slows the departure by as much as it was
687
+ // previously over-fast. Solve the honest thing instead — depart at the
688
+ // instant from which the INTEGRATED on-screen distance to the target equals
689
+ // one leg's worth of travel at the reference speed — which is exactly what
690
+ // inverting the zoomFrac track does. A camera that never leaves rest
691
+ // integrates to the identity, so a full-view take keeps its measured-by-eye
692
+ // calibration bit-for-bit (short-circuited below to keep that exact).
693
+ // Built lazily: only a composition that actually travels needs the camera,
694
+ // and a zoom-less take must not pay for the track.
695
+ let cam: ReturnType<typeof stageCamera> | undefined;
696
+ let track: ReturnType<typeof zoomFracTrack> | undefined;
697
+ const travelDur = (a: Pt, b: Pt, arriveSec: number): { sec: number; clamped?: "min" | "max" } => {
698
+ if (!travelWidthsPerSec) return { sec: travelMs / 1000 };
699
+ const speedPxPerSec = travelWidthsPerSec * comp.source.videoWidth;
700
+ if (speedPxPerSec <= 0) return { sec: travelMs / 1000 };
604
701
  const dist = Math.hypot(b.x - a.x, b.y - a.y);
605
- return Math.min(travelMaxMs, Math.max(travelMinMs, dist / speedPxPerMs)) / 1000;
702
+ cam ??= stageCamera(comp);
703
+ let ms: number;
704
+ if (cam.peakScale <= cam.rest + 1e-9) {
705
+ ms = (dist / speedPxPerSec) * 1000; // camera never leaves rest — closed form
706
+ } else {
707
+ track ??= zoomFracTrack(cam);
708
+ ms = (arriveSec - track.invert(track.at(arriveSec) - dist / speedPxPerSec)) * 1000;
709
+ }
710
+ if (ms < travelMinMs) return { sec: travelMinMs / 1000, clamped: "min" };
711
+ if (ms > travelMaxMs) return { sec: travelMaxMs / 1000, clamped: "max" };
712
+ return { sec: ms / 1000 };
606
713
  };
607
- for (const e of comp.events) {
714
+ for (const [evIdx, e] of comp.events.entries()) {
608
715
  // scroll/press are not pointer-driven — the cursor holds where it was
609
716
  // (the content pans / the keyboard acts). No travel leg; `cur` is untouched,
610
717
  // so the between-legs parking logic keeps the cursor at its last anchor.
611
- if (e.kind === "scroll" || e.kind === "press") continue;
718
+ // They still OCCUPY the frame for durationMs, though: a scroll's duration IS
719
+ // the pan, and a press's is the reveal animating in. A travel that departs
720
+ // into either puts two motions on screen at once — content sliding under a
721
+ // cursor crossing it — so they push `freeAt` exactly like a pointer beat
722
+ // even though they contribute no leg.
723
+ if (e.kind === "scroll" || e.kind === "press") {
724
+ freeAt = Math.max(freeAt, (e.tMs + (e.durationMs ?? 0)) / 1000);
725
+ continue;
726
+ }
612
727
  const arrive = e.tMs / 1000;
613
728
  // Start travelDur before arrival, but never before the previous leg ended
614
729
  // (a long glide into a quick succession would otherwise overlap it — then
615
- // the move just runs in the available window, a touch faster than target).
616
- const prevEnd = legs.length ? legs[legs.length - 1]!.t1 : 0;
617
- const t0 = Math.max(arrive - travelDur(cur, e.point), prevEnd, 0);
618
- legs.push({ t0, t1: arrive, a: cur, b: e.point }); // travel to anchor
730
+ // the move just runs in the available window, a touch faster than target)
731
+ // and never before the previous beat's ACTION finished. A travel leg ends
732
+ // at its tMs, but a `type` keeps emitting keystrokes for durationMs after
733
+ // that — so the leg end alone would let a long enough glide drag the
734
+ // pointer off the field mid-word.
735
+ // …and never AFTER the arrival: overlapping action windows (only reachable
736
+ // by hand — a capture always leaves a settle gap) would otherwise build an
737
+ // INVERTED leg, which matches no instant at all in cursorPos, so the cursor
738
+ // would silently jump-cut instead of degrading to a hard landing.
739
+ const prevEnd = Math.max(legs.length ? legs[legs.length - 1]!.t1 : 0, freeAt);
740
+ const d = travelDur(cur, e.point, arrive);
741
+ const t0 = Math.min(arrive, Math.max(arrive - d.sec, prevEnd, 0));
742
+ legs.push({
743
+ t0,
744
+ t1: arrive,
745
+ a: cur,
746
+ b: e.point,
747
+ evIdx,
748
+ wantSec: d.sec,
749
+ ...(d.clamped ? { clamped: d.clamped } : {}),
750
+ });
619
751
  cur = e.point;
620
- if (e.kind === "drag" && e.to) {
752
+ freeAt = Math.max(freeAt, (e.tMs + (e.durationMs ?? 0)) / 1000);
753
+ if ((e.kind === "drag" || e.kind === "dropFiles") && e.to) {
621
754
  // Delay the stroke by dragLagMs so the cursor rides the captured ink front
622
755
  // (the ink trails the pen by the capture-pipeline latency). The cursor
623
756
  // holds at the start point during the gap [arrive, arrive+lag], then traces
624
- // — matching when the ink actually appears on screen.
757
+ // — matching when the ink actually appears on screen. A dropFiles carry
758
+ // has no ink, but the page's dragover reaction rode the same capture
759
+ // pipeline, so the same lag keeps cursor and reaction in step.
625
760
  const lag = comp.cursor.dragLagMs / 1000;
626
761
  const start = arrive + lag;
627
762
  const dEnd = (e.tMs + (e.durationMs ?? 0)) / 1000 + lag;
@@ -662,7 +797,11 @@ function alongPath(path: Pt[], u: number): Pt {
662
797
  export function cursorPos(t: number, legs: Leg[], comp: TakeComposition): Pt {
663
798
  for (const lg of legs) {
664
799
  if (lg.t0 <= t && t <= lg.t1) {
665
- const raw = Math.max(0, Math.min(1, (t - lg.t0) / (lg.t1 - lg.t0)));
800
+ // A ZERO-span leg (a departure clamped all the way to its own arrival —
801
+ // see buildLegs) has landed by definition; without the guard the 0/0
802
+ // would put NaN through the ease and blank the cursor for that frame.
803
+ const span = lg.t1 - lg.t0;
804
+ const raw = span > 0 ? Math.max(0, Math.min(1, (t - lg.t0) / span)) : 1;
666
805
  // A drag replays the captured stroke's pacing so the cursor stays locked
667
806
  // to the ink: "smooth" (accel-in / decel-out — a natural hand-draw) or
668
807
  // "linear" (constant speed). The capture bakes the SAME curve into the ink
@@ -691,3 +830,42 @@ export function cursorPos(t: number, legs: Leg[], comp: TakeComposition): Pt {
691
830
  export function isDragging(t: number, legs: Leg[]): boolean {
692
831
  return legs.some((lg) => lg.drag === true && lg.t0 <= t && t <= lg.t1);
693
832
  }
833
+
834
+ // --- file ghost card (dropFiles) ----------------------------------------
835
+
836
+ /** A dropFiles carry's on-screen window [start, end] in SECONDS — when the
837
+ * ghost card rides the cursor. Same dragLagMs shift as the carry leg in
838
+ * buildLegs, so card and cursor cannot drift apart. Shared by the Revideo
839
+ * scene and the editor preview (the no-drift invariant). */
840
+ export function carryWindow(
841
+ e: { tMs: number; durationMs?: number },
842
+ comp: TakeComposition,
843
+ ): { t0: number; t1: number } {
844
+ const lag = comp.cursor.dragLagMs / 1000;
845
+ const t0 = e.tMs / 1000 + lag;
846
+ return { t0, t1: t0 + (e.durationMs ?? 0) / 1000 };
847
+ }
848
+
849
+ /** "1.2 MB" / "412 KB" — the ghost card's size caption (scene + preview). */
850
+ export function fmtBytes(n: number): string {
851
+ return n >= 1024 * 1024
852
+ ? `${(n / 1024 / 1024).toFixed(1)} MB`
853
+ : `${Math.max(1, Math.round(n / 1024))} KB`;
854
+ }
855
+
856
+ /** The ghost card's two text lines for a dropFiles beat: the (first) filename,
857
+ * and a meta caption ("3 files · 1.8 MB" / "1.2 MB"). Shared scene/preview.
858
+ * Long filenames middle-ellipse (extension kept) so the card can't outgrow
859
+ * the frame — neither render surface clamps its width. */
860
+ export function ghostCardLines(files: { name: string; size?: number }[]): {
861
+ title: string;
862
+ meta: string;
863
+ } {
864
+ const raw = files[0]?.name ?? "file";
865
+ const MAX = 34;
866
+ const title = raw.length <= MAX ? raw : `${raw.slice(0, MAX - 12)}…${raw.slice(raw.length - 11)}`;
867
+ const total = files.reduce((s, f) => s + (f.size ?? 0), 0);
868
+ const size = total > 0 ? fmtBytes(total) : "";
869
+ const count = files.length > 1 ? `${files.length} files` : "";
870
+ return { title, meta: [count, size].filter(Boolean).join(" · ") };
871
+ }
package/src/plan.ts CHANGED
@@ -86,17 +86,17 @@ export function planComposition(log: CaptureLog, opts: PlanOpts = {}): TakeCompo
86
86
  const intent = c.zoom ?? "auto";
87
87
  const durationMs = "durationMs" in c ? c.durationMs : 0;
88
88
 
89
- // drag: cursor path + the region we frame is the path's bbox
90
- const to = kind === "drag" ? mapPt((c as { to: Pt }).to) : undefined;
91
- const rawPath =
92
- kind === "drag"
93
- ? ((c as { path?: Pt[] }).path ?? [{ x: c.x, y: c.y }, (c as { to: Pt }).to])
94
- : undefined;
89
+ // drag / dropFiles: cursor path + the region we frame is the path's bbox
90
+ const carries = kind === "drag" || kind === "dropFiles";
91
+ const to = carries ? mapPt((c as { to: Pt }).to) : undefined;
92
+ const rawPath = carries
93
+ ? ((c as { path?: Pt[] }).path ?? [{ x: c.x, y: c.y }, (c as { to: Pt }).to])
94
+ : undefined;
95
95
  const path = rawPath?.map(mapPt);
96
- const ease = kind === "drag" ? (c as { ease?: "linear" | "smooth" }).ease : undefined;
96
+ const ease = carries ? (c as { ease?: "linear" | "smooth" }).ease : undefined;
97
97
 
98
- // the element bbox (ground truth): drag → path bbox, else the captured box
99
- const bbox = kind === "drag" && path ? pathBBox(path) : c.box ? mapBox(c.box) : undefined;
98
+ // the element bbox (ground truth): a carry → path bbox, else the captured box
99
+ const bbox = carries && path ? pathBBox(path) : c.box ? mapBox(c.box) : undefined;
100
100
  const effectBox = c.effectBox ? mapBox(c.effectBox) : undefined;
101
101
  const label = c.sel ?? c.note;
102
102
 
@@ -125,6 +125,9 @@ export function planComposition(log: CaptureLog, opts: PlanOpts = {}): TakeCompo
125
125
  ...(to ? { to } : {}),
126
126
  ...(path ? { path } : {}),
127
127
  ...(ease ? { ease } : {}),
128
+ ...(kind === "dropFiles"
129
+ ? { files: (c as { files: { name: string; size?: number }[] }).files }
130
+ : {}),
128
131
  };
129
132
  return { beat, ev };
130
133
  });
package/src/presets.ts CHANGED
@@ -40,7 +40,13 @@ export function zoomLevelName(scale: number, tol = 0.07): ZoomLevelName | null {
40
40
  // default state speakable.
41
41
  export type MotionPreset = Pick<
42
42
  CursorConfig,
43
- "travelWidthsPerSec" | "holdMs" | "zoomInMs" | "zoomOutMs" | "pullOutDwellMs"
43
+ | "travelWidthsPerSec"
44
+ | "travelMinMs"
45
+ | "travelMaxMs"
46
+ | "holdMs"
47
+ | "zoomInMs"
48
+ | "zoomOutMs"
49
+ | "pullOutDwellMs"
44
50
  > & { zoomEase?: undefined };
45
51
  // zoomIn/zoomOut anchored to the measured reference springs (730/1340 —
46
52
  // see DEFAULT_CURSOR); calm/brisk scale both while keeping out ≈ 1.8× in.
@@ -50,9 +56,19 @@ export type MotionPreset = Pick<
50
56
  // leaves the key undefined; JSON drops it) so applying a pace migrates an old
51
57
  // composition onto the default measured-SS spring curve instead of silently
52
58
  // keeping the old bezier.
59
+ //
60
+ // The TRAVEL CLAMPS ride along too, and they have to. They are applied AFTER
61
+ // travelWidthsPerSec, so a preset that moved only the speed left every clamped
62
+ // leg exactly where it was: below ~202px and above ~571px of a 1920 frame,
63
+ // "calm" and "brisk" rendered IDENTICALLY and nothing said so. Each clamp
64
+ // scales by the pace's own speed ratio against natural (300·0.35/0.28 = 375,
65
+ // 850·0.35/0.45 = 661…), so a leg on a clamp keeps the same relationship to
66
+ // the legs that aren't.
53
67
  export const MOTION: Record<"calm" | "natural" | "brisk", MotionPreset> = {
54
68
  calm: {
55
69
  travelWidthsPerSec: 0.28,
70
+ travelMinMs: 375,
71
+ travelMaxMs: 1060,
56
72
  holdMs: 1500,
57
73
  zoomInMs: 900,
58
74
  zoomOutMs: 1650,
@@ -61,6 +77,8 @@ export const MOTION: Record<"calm" | "natural" | "brisk", MotionPreset> = {
61
77
  },
62
78
  natural: {
63
79
  travelWidthsPerSec: 0.35,
80
+ travelMinMs: 300,
81
+ travelMaxMs: 850,
64
82
  holdMs: 1100,
65
83
  zoomInMs: 730,
66
84
  zoomOutMs: 1340,
@@ -69,6 +87,8 @@ export const MOTION: Record<"calm" | "natural" | "brisk", MotionPreset> = {
69
87
  },
70
88
  brisk: {
71
89
  travelWidthsPerSec: 0.45,
90
+ travelMinMs: 235,
91
+ travelMaxMs: 660,
72
92
  holdMs: 750,
73
93
  zoomInMs: 550,
74
94
  zoomOutMs: 1000,
@@ -78,6 +98,15 @@ export const MOTION: Record<"calm" | "natural" | "brisk", MotionPreset> = {
78
98
  };
79
99
  export type MotionName = keyof typeof MOTION;
80
100
 
101
+ /** A clamp matches its preset — or the LEGACY value every composition carried
102
+ * before the clamps joined the presets. Without that second door, applying
103
+ * "brisk" to an old take and re-reading it would report "custom" purely
104
+ * because the take predates clamp-aware presets. Same escape hatch
105
+ * pullOutDwellMs already has. */
106
+ export const CLAMP_TOL_MS = 20;
107
+ const clampMatches = (v: number | undefined, want: number, legacy: number): boolean =>
108
+ v == null || Math.abs(v - want) < CLAMP_TOL_MS || Math.abs(v - legacy) < 1;
109
+
81
110
  export function motionName(cursor: CursorConfig): MotionName | null {
82
111
  for (const [name, m] of Object.entries(MOTION) as [MotionName, MotionPreset][]) {
83
112
  if (
@@ -85,6 +114,8 @@ export function motionName(cursor: CursorConfig): MotionName | null {
85
114
  Math.abs(cursor.holdMs - m.holdMs) < 60 &&
86
115
  Math.abs(cursor.zoomInMs - m.zoomInMs) < 60 &&
87
116
  Math.abs(cursor.zoomOutMs - m.zoomOutMs) < 60 &&
117
+ clampMatches(cursor.travelMinMs, m.travelMinMs, MOTION.natural.travelMinMs) &&
118
+ clampMatches(cursor.travelMaxMs, m.travelMaxMs, MOTION.natural.travelMaxMs) &&
88
119
  // absent = a pre-dwell composition — still nameable by its four legacy
89
120
  // knobs; only an explicit different value makes the pace "custom".
90
121
  (cursor.pullOutDwellMs == null ||
package/src/render.ts CHANGED
@@ -78,6 +78,16 @@ export type RenderTakeOpts = {
78
78
  writeCompositionSibling?: boolean;
79
79
  };
80
80
 
81
+ export type RenderTakeResult = {
82
+ mp4Path: string;
83
+ compositionPath: string;
84
+ /** non-fatal validator findings for this composition. The render went ahead,
85
+ * but each one is something the author has to look at — a zoom that punches
86
+ * into empty space, a press whose zoom departs before the keypress, a tail
87
+ * that delivers a frozen screen. Empty when `skipValidate` is set. */
88
+ warnings: CompositionIssue[];
89
+ };
90
+
81
91
  function run(cmd: string, args: string[]): Promise<void> {
82
92
  return new Promise((res, rej) => {
83
93
  const c = spawn(cmd, args, { stdio: ["ignore", "ignore", "pipe"] });
@@ -240,9 +250,7 @@ async function prepareScratch(composition: TakeComposition, videoPath: string):
240
250
  // needs the renderer off cwd, or one child process per render.)
241
251
  let renderQueue: Promise<unknown> = Promise.resolve();
242
252
 
243
- export async function renderTake(
244
- opts: RenderTakeOpts,
245
- ): Promise<{ mp4Path: string; compositionPath: string }> {
253
+ export async function renderTake(opts: RenderTakeOpts): Promise<RenderTakeResult> {
246
254
  const run = renderQueue.then(
247
255
  () => renderTakeExclusive(opts),
248
256
  () => renderTakeExclusive(opts),
@@ -251,9 +259,7 @@ export async function renderTake(
251
259
  return run;
252
260
  }
253
261
 
254
- async function renderTakeExclusive(
255
- opts: RenderTakeOpts,
256
- ): Promise<{ mp4Path: string; compositionPath: string }> {
262
+ async function renderTakeExclusive(opts: RenderTakeOpts): Promise<RenderTakeResult> {
257
263
  if (!opts.chromePath) {
258
264
  throw new Error(
259
265
  "renderTake: `chromePath` is required; use @open-take/runtime to resolve managed Chrome automatically",
@@ -272,14 +278,19 @@ async function renderTakeExclusive(
272
278
  // 0. validate BEFORE the expensive render. A hand-edited composition (the
273
279
  // refine loop) can carry a malformed zoom or a capture-locked tMs drift;
274
280
  // catch it in milliseconds rather than after a multi-second render.
281
+ // Warnings are RETURNED as well as printed: this stderr line lands minutes
282
+ // before the render finishes, so on its own it is scrolled past — the
283
+ // caller re-prints them in the end-of-run summary, exactly as it already
284
+ // does for skipped capture steps.
285
+ const warnings: CompositionIssue[] = [];
275
286
  if (!opts.skipValidate) {
276
287
  const issues: CompositionIssue[] = validateComposition(composition, {
277
288
  captureLog: opts.captureLog ?? opts.log,
278
289
  });
279
290
  const errors = issues.filter((i) => i.severity === "error");
280
- const warns = issues.filter((i) => i.severity === "warn");
281
- if (opts.logProgress && warns.length)
282
- process.stderr.write(`composition warnings:\n${formatIssues(warns)}\n`);
291
+ warnings.push(...issues.filter((i) => i.severity === "warn"));
292
+ if (opts.logProgress && warnings.length)
293
+ process.stderr.write(`composition warnings:\n${formatIssues(warnings)}\n`);
283
294
  if (errors.length)
284
295
  throw new Error(
285
296
  `composition has ${errors.length} error(s) — refusing to render:\n${formatIssues(errors)}`,
@@ -375,7 +386,7 @@ async function renderTakeExclusive(
375
386
  await writeFile(compositionPath, JSON.stringify(persisted, null, 2));
376
387
  }
377
388
 
378
- return { mp4Path: resolve(opts.outPath), compositionPath };
389
+ return { mp4Path: resolve(opts.outPath), compositionPath, warnings };
379
390
  } finally {
380
391
  await cleanupScratch(scratch);
381
392
  }
@@ -10,6 +10,8 @@ import {
10
10
  isDragging,
11
11
  gradientEndpoints,
12
12
  smoother,
13
+ carryWindow,
14
+ ghostCardLines,
13
15
  } from "../math";
14
16
  import comp from "./.composition.json";
15
17
 
@@ -112,19 +114,25 @@ export default makeScene2D("take", function* (view) {
112
114
  </Rect>
113
115
 
114
116
  {/* click ripples — pointer-landing beats only (scroll/press have no
115
- spatial click point, so they get no ripple) */}
117
+ spatial click point). A dropFiles ripples at its DROP point on
118
+ RELEASE — not at the off-content carry entry — and stays on even when
119
+ the ghost card is disabled (parity with the editor preview). */}
116
120
  {comp.events
117
121
  .filter((e) => e.kind !== "scroll" && e.kind !== "press")
118
122
  .map((e, index) => {
119
123
  const ms = comp.cursor.rippleMs / 1000;
124
+ const at =
125
+ e.kind === "dropFiles"
126
+ ? { t0: carryWindow(e, comp).t1, p: e.to ?? e.point }
127
+ : { t0: e.tMs / 1000, p: e.point };
120
128
  const prog = () => {
121
- const dt = t() - e.tMs / 1000;
129
+ const dt = t() - at.t0;
122
130
  return dt >= 0 && dt <= ms ? dt / ms : -1;
123
131
  };
124
132
  return (
125
133
  <Circle
126
134
  key={`${e.kind}-${e.tMs}-${index}`}
127
- position={[lx(e.point.x), ly(e.point.y)]}
135
+ position={[lx(at.p.x), ly(at.p.y)]}
128
136
  size={() => {
129
137
  const p = prog();
130
138
  return p < 0 ? 0 : (12 + 60 * smoother(p)) * 2;
@@ -139,6 +147,81 @@ export default makeScene2D("take", function* (view) {
139
147
  );
140
148
  })}
141
149
 
150
+ {/* file ghost card — a macOS-style translucent file card riding the
151
+ cursor through a dropFiles carry, popping/fading on release. Drawn
152
+ UNDER the cursor node so the pointer stays on top. Mirrored in the
153
+ editor preview (preview.ts) — keep cosmetics in step. */}
154
+ {comp.events
155
+ .filter((e) => e.kind === "dropFiles" && e.ghostCard?.enabled !== false)
156
+ .map((e, index) => {
157
+ const gk = vW / 1920; // card is authored for a 1920-wide video
158
+ const gc = e.ghostCard ?? {};
159
+ const off = gc.offset ?? { x: 26 * gk, y: 30 * gk };
160
+ const win = carryWindow(e, comp);
161
+ const releaseS = (gc.releaseMs ?? 280) / 1000;
162
+ const fadeS = 0.15;
163
+ const lines = ghostCardLines(e.files ?? []);
164
+ const vis = () => {
165
+ const tt = t();
166
+ if (tt < win.t0 - fadeS || tt > win.t1 + releaseS) return 0;
167
+ if (tt < win.t0) return (tt - (win.t0 - fadeS)) / fadeS;
168
+ if (tt <= win.t1) return 1;
169
+ return 1 - (tt - win.t1) / releaseS;
170
+ };
171
+ // the release pop: a slight grow as the card lets go of the file
172
+ const pop = () => {
173
+ const tt = t();
174
+ const z =
175
+ tt <= win.t1 ? 1 : 1 + 0.08 * smoother(Math.min(1, (tt - win.t1) / releaseS));
176
+ return [z, z];
177
+ };
178
+ return (
179
+ <Node key={`ghostCard-${e.tMs}-${index}`}>
180
+ <Node
181
+ position={() => {
182
+ const c = cursorPos(t(), legs, comp);
183
+ return [lx(c.x) + off.x, ly(c.y) + off.y];
184
+ }}
185
+ opacity={vis}
186
+ scale={pop}
187
+ >
188
+ <Rect
189
+ layout
190
+ direction={"column"}
191
+ alignItems={"start"}
192
+ padding={[11 * gk, 16 * gk]}
193
+ gap={3 * gk}
194
+ radius={10 * gk}
195
+ offset={[-1, -1]}
196
+ fill={"rgba(24,24,27,0.86)"}
197
+ stroke={"rgba(255,255,255,0.22)"}
198
+ lineWidth={1}
199
+ shadowColor={"rgba(0,0,0,0.45)"}
200
+ shadowBlur={26 * gk}
201
+ shadowOffset={[0, 8 * gk]}
202
+ >
203
+ <Txt
204
+ text={lines.title}
205
+ fontFamily={"ui-monospace, 'SF Mono', Menlo, Consolas, monospace"}
206
+ fontSize={21 * gk}
207
+ fontWeight={600}
208
+ fill={"rgba(255,255,255,0.95)"}
209
+ />
210
+ {lines.meta ? (
211
+ <Txt
212
+ text={lines.meta}
213
+ fontFamily={"system-ui, -apple-system, 'Segoe UI', 'Noto Sans', sans-serif"}
214
+ fontSize={16 * gk}
215
+ fontWeight={500}
216
+ fill={"rgba(255,255,255,0.55)"}
217
+ />
218
+ ) : null}
219
+ </Rect>
220
+ </Node>
221
+ </Node>
222
+ );
223
+ })}
224
+
142
225
  {/* synthetic cursor on ground-truth waypoints */}
143
226
  <Node
144
227
  position={() => {