@open-take/compositor 0.2.0 → 0.2.2

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/dist/index.d.ts CHANGED
@@ -123,6 +123,16 @@ type CaptureLog = {
123
123
  /** the ordered ground-truth actions (click / type / drag) */
124
124
  events: CaptureEvent[];
125
125
  tEndMs?: number;
126
+ /** Steps the capture DROPPED (target not found / endpoint unresolved) — the
127
+ * take still completes, but a missing beat must reach the end-of-run
128
+ * summary and (with --strict) the exit code, not just an early stderr line
129
+ * buried under render progress. `step` is the plan's 0-based step index. */
130
+ skipped?: {
131
+ step: number;
132
+ action: string;
133
+ target?: string;
134
+ reason: string;
135
+ }[];
126
136
  };
127
137
  type ZoomDecision = {
128
138
  /** selective: not every action zooms. Edit this to tune/remove. */
@@ -232,6 +242,28 @@ type CursorConfig = {
232
242
  * shapes the curve. Bounce > 0 overshoots the RECT (a touch past the target
233
243
  * frame, then settle) — keep it small. */
234
244
  zoomSpring?: number;
245
+ /** Fraction of a camera ramp still UNfinished at its keyframe end (the action
246
+ * instant), left to settle as an asymptotic overdamped tail that continues
247
+ * INTO the hold — so a move tapers out like a physical camera instead of
248
+ * stopping on a velocity cliff at the keyframe. Frame-tracked on the
249
+ * reference export: its moves keep sub-threshold motion ~0.5s past the
250
+ * visible end (tail τ ≈ 220ms in / ≈ 370ms out), while the cut spring's
251
+ * τ = duration/6.9 ends 2-3× harder. ~0.04 (the shipped default) reproduces
252
+ * the reference tails over the default zoomInMs/zoomOutMs. 0 = legacy
253
+ * cut+normalized spring (absent falls back to the default on NEW plans; an
254
+ * old composition without the field renders as it always did). Ignored when
255
+ * zoomSpring or zoomEase is set (those keep their exact legacy curves). */
256
+ zoomSettleFrac?: number;
257
+ /** Minimum stay (ms) after the previous action's visible end before a
258
+ * PULL-OUT ramp may begin. When the beat gap is too tight the pull-out now
259
+ * departs late and LANDS late (after its own action instant) instead of
260
+ * fleeing a frame the viewer is still reading — the reference recorder's
261
+ * reactive pattern (payoff plays while the camera is still arriving).
262
+ * ~800 (the shipped default) reads as a natural beat; pace presets scale it.
263
+ * 0/absent = legacy (a squeezed pull-out departs the instant the previous
264
+ * action ends and lands exactly on its action). Named pullOut- because
265
+ * holdMs already covers the ordinary post-action dwell. */
266
+ pullOutDwellMs?: number;
235
267
  /** ms to delay the synthetic cursor along a DRAG stroke, compensating for the
236
268
  * capture pipeline latency: the captured ink appears ~this long after the pen
237
269
  * actually moved, so without the delay the (exact-time) cursor leads the ink.
@@ -322,6 +354,10 @@ type TakeComposition = {
322
354
  };
323
355
  source: {
324
356
  videoUrl: string;
357
+ /** stage size the source video is DRAWN at (capture viewport CSS px) —
358
+ * the coordinate space of every event/bbox below. A Retina capture's
359
+ * file is denser (viewport × captureScale); the scene stretches it to
360
+ * this size, so the extra pixels only sharpen sampling under zoom. */
325
361
  videoWidth: number;
326
362
  videoHeight: number;
327
363
  viewport: {
@@ -337,6 +373,14 @@ type TakeComposition = {
337
373
  start: Pt;
338
374
  events: CompEvent[];
339
375
  durationMs: number;
376
+ /** Head trim (ms of the composition timeline cut from the delivered mp4).
377
+ * Capture starts at navigation, so the first frames show the app before it
378
+ * painted (plus any cold-cache font swap) — trim them here instead of
379
+ * post-processing with ffmpeg, so the refine loop keeps applying to the file
380
+ * actually shipped. Event tMs values stay on the untrimmed timeline (the
381
+ * capture is the ground truth); only the delivered head moves. 0/absent =
382
+ * no trim. */
383
+ startMs?: number;
340
384
  /** render-time review decoration (badges/watermark/label); never persisted */
341
385
  review?: ReviewDecor;
342
386
  };
@@ -358,7 +402,7 @@ declare const ZOOM_LEVELS: {
358
402
  type ZoomLevelName = keyof typeof ZOOM_LEVELS;
359
403
  /** Name a scale if it sits within tolerance of a preset; else null (custom). */
360
404
  declare function zoomLevelName(scale: number, tol?: number): ZoomLevelName | null;
361
- type MotionPreset = Pick<CursorConfig, "travelWidthsPerSec" | "holdMs" | "zoomInMs" | "zoomOutMs"> & {
405
+ type MotionPreset = Pick<CursorConfig, "travelWidthsPerSec" | "holdMs" | "zoomInMs" | "zoomOutMs" | "pullOutDwellMs"> & {
362
406
  zoomEase?: undefined;
363
407
  };
364
408
  declare const MOTION: Record<"calm" | "natural" | "brisk", MotionPreset>;
@@ -515,7 +559,7 @@ declare function formatIssues(issues: CompositionIssue[]): string;
515
559
  //#region src/math.d.ts
516
560
  //# sourceMappingURL=validate.d.ts.map
517
561
  declare namespace math_d_exports {
518
- export { CamRect, StageKeyframes, bboxFitScale, buildLegs, buildStageKeyframes, clampCenter, cubicBezier, cursorPos, gradientEndpoints, isDragging, keyvalN, keyvalR, restStageScale, smoother, springEase, stageCamera, stageEasing };
562
+ export { CamRect, StageKeyframes, bboxFitScale, buildLegs, buildStageKeyframes, cameraRampSchedule, clampCenter, cubicBezier, cursorPos, gradientEndpoints, isDragging, keyvalN, keyvalR, restStageScale, smoother, springEase, stageCamera, stageEasing };
519
563
  }
520
564
  declare function smoother(t: number): number;
521
565
  declare function cubicBezier(x1: number, y1: number, x2: number, y2: number): (x: number) => number;
@@ -568,6 +612,16 @@ type StageKeyframes = {
568
612
  * monotone toward frame centre — no wrong-way "bounce" for ANY scale pair,
569
613
  * which scale+centre lerp can't guarantee (it hooks when scale > 2×rest). */
570
614
  declare function keyvalR(t: number, kfs: KF<CamRect>[], ease: (u: number) => number): CamRect;
615
+ /** Per-EVENT camera ramp timing (ms), for the refine surfaces (A/B windows,
616
+ * review badges): when the camera actually departs toward a beat and when it
617
+ * lands. `null` for a beat the camera holds through (no anchor). Derived from
618
+ * the same schedule the render uses, so a dwell-delayed pull-out (which
619
+ * departs after the stored inAtMs and can land after its own tMs) is
620
+ * reflected instead of approximated from inAtMs. */
621
+ declare function cameraRampSchedule(comp: TakeComposition): ({
622
+ startMs: number;
623
+ landMs: number;
624
+ } | null)[];
571
625
  declare function buildStageKeyframes(comp: TakeComposition): StageKeyframes;
572
626
  /** The one camera evaluator — scene.tsx (render) and the editor preview both
573
627
  * consume THIS, so preview and export can never drift. */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/presets.ts","../src/ffmpeg.ts","../src/plan.ts","../src/camera.ts","../src/render.ts","../src/validate.ts","../src/math.ts"],"sourcesContent":null,"mappings":";;;KAMY,EAAA;;;AAAZ,CAAA;AACY,KAAA,IAAA,GAAI;;EAKJ,CAAA,EAAA,MAAA;;;AAIZ,CAAA;;AAKQ,KATI,UAAA,GASJ,MAAA,GAAA,OAAA,GAAA,QAAA;;;AAeU,KApBN,gBAAA,GAoBM;;EAUN,CAAA,EAAA,MAAA;;;EAIA,GAAA,CAAA,EA7BJ,IA6BI;;;EAUA;;;EAiBA;;;EAUA,IAAA,CAAA,EAzDH,UAyDe;;;;AASxB;AAQA;EAAwB,SAAA,CAAA,EApEV,IAoEU;EAAA;;;;;EAKR,cACZ,CAAA,EAAA,MAAA;AAAY,CAAA;AAEhB;AAWY,KA7EA,YAAA,GAAe,gBA6EH,GAAA;EAAA,IAAA,CAAA,EAAA,OAAA;CAAA;;AAeZ;AAKA,KA7FA,WAAA,GAAc,gBA6FL,GAAA;EAAA,IAAA,EAAA,MAAA;EAAA;EAKV,IAEF,EAAA,MAAA;EAAI;EAEO,UASb,EAAA,MAAA;CAAE;AAEE;AAMX;AAWY,KAxHA,WAAA,GAAc,gBAwHF,GAAA;;;;;;;;EAiEZ,IAAA,CAAA,EAAA;;;EAUA,CAAA,EAAA;;;;;;;;AASZ,CAAA;;;KA3LY,aAAA,GAAgB;;;;EA0MhB;EA8BC,UAAA,EAAA,MASZ;AAED,CAAA;;;AASU,KAlPE,YAAA,GAAe,gBAkPjB,GAAA;EAAY,IAEP,EAAA,OAAA;EAAgB;EAEpB,UACD,EAAA,MAAA;CAAS;AAGG;;;AAKN,KAtPJ,YAAA,GAAe,gBAsPK,GAAA;EAAA,IAAA,EAAA,OAAA;EAAA;EAAqB,IAAqB,EAAA,MAAA;EAAgB;EAI7E,UAAA,EAAA,MAKZ;AAQD,CAAA;AAKa,K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AAA,OAAgB,kBAAkB;iBAoElC,SAAA,kBAA2B,aAAa,kBAAkB;;APnM9D,iBOgOI,UAAA,CP5NL,CAAA,EAAA,MAAW,EAAA,IAAA,EO4NsB,GP5NtB,EAAA,CAAA,EAAA,OAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/presets.ts","../src/ffmpeg.ts","../src/plan.ts","../src/camera.ts","../src/render.ts","../src/validate.ts","../src/math.ts"],"sourcesContent":null,"mappings":";;;KAMY,EAAA;;;AAAZ,CAAA;AACY,KAAA,IAAA,GAAI;;EAKJ,CAAA,EAAA,MAAA;;;AAIZ,CAAA;;AAKQ,KATI,UAAA,GASJ,MAAA,GAAA,OAAA,GAAA,QAAA;;;AAeU,KApBN,gBAAA,GAoBM;;EAUN,CAAA,EAAA,MAAA;;;EAIA,GAAA,CAAA,EA7BJ,IA6BI;;;EAUA;;;EAiBA;;;EAUA,IAAA,CAAA,EAzDH,UAyDe;;;;AASxB;AAQA;EAAwB,SAAA,CAAA,EApEV,IAoEU;EAAA;;;;;EAKR,cACZ,CAAA,EAAA,MAAA;AAAY,CAAA;AAEhB;AAgBY,KAlFA,YAAA,GAAe,gBAkFH,GAAA;EAAA,IAAA,CAAA,EAAA,OAAA;CAAA;;AAeZ;AAKA,KAlGA,WAAA,GAAc,gBAkGL,GAAA;EAAA,IAAA,EAAA,MAAA;EAAA;EAKV,IAEF,EAAA,MAAA;EAAI;EAEO,UASb,EAAA,MAAA;CAAE;AAEE;AAMX;AAWY,KA7HA,WAAA,GAAc,gBA6HF,GAAA;;;;;;;;EAuFZ,IAAA,CAAA,EAAA;;;EAUA,CAAA,EAAA;;;;;;;;AASZ,CAAA;;;KAtNY,aAAA,GAAgB;;;;EAqOhB;EA8BC,UAAA,EAAA,MASZ;AAED,CAAA;;;AAaU,KAjRE,YAAA,GAAe,gBAiRjB,GAAA;EAAY,IAEP,EAAA,OAAA;EAAgB;EAEpB,UACD,EAAA,MAAA;CAAS;AAWG;;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CAAA,EOmRyE,EPnRzE;AAED;AAA2B,iBO8SX,UAAA,CP9SW,CAAA,EAAA,MAAA,EAAA,IAAA,EO8SiB,GP9SjB,EAAA,CAAA,EAAA,OAAA"}
package/dist/index.js CHANGED
@@ -56,6 +56,8 @@ const DEFAULT_CURSOR = {
56
56
  holdMs: 1100,
57
57
  zoomOutMs: 1340,
58
58
  zoomInMs: 730,
59
+ zoomSettleFrac: .04,
60
+ pullOutDwellMs: 800,
59
61
  dragLagMs: 190,
60
62
  travelEase: [
61
63
  .3,
@@ -92,6 +94,7 @@ const MOTION = {
92
94
  holdMs: 1500,
93
95
  zoomInMs: 900,
94
96
  zoomOutMs: 1650,
97
+ pullOutDwellMs: 1e3,
95
98
  zoomEase: void 0
96
99
  },
97
100
  natural: {
@@ -99,6 +102,7 @@ const MOTION = {
99
102
  holdMs: 1100,
100
103
  zoomInMs: 730,
101
104
  zoomOutMs: 1340,
105
+ pullOutDwellMs: 800,
102
106
  zoomEase: void 0
103
107
  },
104
108
  brisk: {
@@ -106,11 +110,12 @@ const MOTION = {
106
110
  holdMs: 750,
107
111
  zoomInMs: 550,
108
112
  zoomOutMs: 1e3,
113
+ pullOutDwellMs: 600,
109
114
  zoomEase: void 0
110
115
  }
111
116
  };
112
117
  function motionName(cursor) {
113
- for (const [name, m] of Object.entries(MOTION)) if (Math.abs(cursor.travelWidthsPerSec - m.travelWidthsPerSec) < .015 && Math.abs(cursor.holdMs - m.holdMs) < 60 && Math.abs(cursor.zoomInMs - m.zoomInMs) < 60 && Math.abs(cursor.zoomOutMs - m.zoomOutMs) < 60) return name;
118
+ for (const [name, m] of Object.entries(MOTION)) if (Math.abs(cursor.travelWidthsPerSec - m.travelWidthsPerSec) < .015 && Math.abs(cursor.holdMs - m.holdMs) < 60 && Math.abs(cursor.zoomInMs - m.zoomInMs) < 60 && Math.abs(cursor.zoomOutMs - m.zoomOutMs) < 60 && (cursor.pullOutDwellMs == null || Math.abs(cursor.pullOutDwellMs - (m.pullOutDwellMs ?? 0)) < 60)) return name;
114
119
  return null;
115
120
  }
116
121
  const DARK_SHADOW = {
@@ -287,6 +292,7 @@ __export(math_exports, {
287
292
  bboxFitScale: () => bboxFitScale,
288
293
  buildLegs: () => buildLegs,
289
294
  buildStageKeyframes: () => buildStageKeyframes,
295
+ cameraRampSchedule: () => cameraRampSchedule,
290
296
  clampCenter: () => clampCenter,
291
297
  cubicBezier: () => cubicBezier,
292
298
  cursorPos: () => cursorPos,
@@ -436,7 +442,7 @@ function keyvalR(t, kfs, ease) {
436
442
  }
437
443
  return kfs[kfs.length - 1][1];
438
444
  }
439
- function buildStageKeyframes(comp) {
445
+ function buildCameraSchedule(comp) {
440
446
  const { videoWidth: vW, videoHeight: vH } = comp.source;
441
447
  const { width: oW, height: oH } = comp.output;
442
448
  const rest = restStageScale(vW, vH, oW, oH, comp.framing.insetFrac);
@@ -444,7 +450,6 @@ function buildStageKeyframes(comp) {
444
450
  x: vW / 2,
445
451
  y: vH / 2
446
452
  };
447
- const HOLD = comp.cursor.holdMs / 1e3;
448
453
  const ZOUT_MS = comp.cursor.zoomOutMs;
449
454
  const rectFor = (center, scale) => {
450
455
  const c = clampCenter(center, scale, vW, vH, oW, oH);
@@ -456,8 +461,9 @@ function buildStageKeyframes(comp) {
456
461
  };
457
462
  const restR = rectFor(restC, rest);
458
463
  const anchors = [];
459
- for (const e of comp.events) {
464
+ comp.events.forEach((e, evIdx) => {
460
465
  const base = {
466
+ evIdx,
461
467
  tMs: e.tMs,
462
468
  durationMs: e.durationMs ?? 0,
463
469
  inAtMs: e.zoom.inAtMs
@@ -473,19 +479,89 @@ function buildStageKeyframes(comp) {
473
479
  center: e.zoom.center,
474
480
  glide: e.zoom.glide
475
481
  });
476
- }
482
+ });
477
483
  const targets = anchors.map((e) => rectFor(e.center, e.scale));
478
484
  const ZIN_MS = comp.cursor.zoomInMs;
479
- const rampStartS = anchors.map((e, i) => {
485
+ const DWELL_MS = comp.cursor.pullOutDwellMs ?? 0;
486
+ const ramps = anchors.map((e, i) => {
480
487
  const from = i > 0 ? targets[i - 1] : restR;
481
488
  const pullOut = targets[i].w > from.w + 1e-6;
482
489
  const isDefaultInAt = Math.abs(e.inAtMs - Math.max(0, e.tMs - ZIN_MS)) < 1;
483
- if (!pullOut || !isDefaultInAt) return e.inAtMs / 1e3;
490
+ if (!pullOut || !isDefaultInAt) return {
491
+ start: e.inAtMs / 1e3,
492
+ end: e.tMs / 1e3
493
+ };
484
494
  const desired = e.tMs - ZOUT_MS;
485
495
  const prevEndMs = i > 0 ? anchors[i - 1].tMs + anchors[i - 1].durationMs : 0;
486
- const start = desired >= prevEndMs ? desired : Math.min(prevEndMs, e.tMs - Math.min(ZOUT_MS, ZIN_MS));
487
- return Math.max(start, 0) / 1e3;
496
+ const floor = prevEndMs + DWELL_MS;
497
+ if (desired >= floor) return {
498
+ start: Math.max(desired, 0) / 1e3,
499
+ end: e.tMs / 1e3
500
+ };
501
+ if (DWELL_MS > 0) return {
502
+ start: floor / 1e3,
503
+ end: (floor + ZOUT_MS) / 1e3
504
+ };
505
+ const start = Math.min(prevEndMs, e.tMs - Math.min(ZOUT_MS, ZIN_MS));
506
+ return {
507
+ start: Math.max(start, 0) / 1e3,
508
+ end: e.tMs / 1e3
509
+ };
488
510
  });
511
+ if (DWELL_MS > 0) {
512
+ const minRamp = Math.min(ZOUT_MS, ZIN_MS);
513
+ for (let i = 0; i < ramps.length - 1; i++) {
514
+ const r = ramps[i];
515
+ const e = anchors[i];
516
+ if (r.end <= e.tMs / 1e3 + 1e-9) continue;
517
+ const latestStart = ramps[i + 1].start - .01 - minRamp / 1e3;
518
+ if (r.start <= latestStart) continue;
519
+ const prevEndMs = i > 0 ? anchors[i - 1].tMs + anchors[i - 1].durationMs : 0;
520
+ if (latestStart * 1e3 >= prevEndMs) {
521
+ r.start = latestStart;
522
+ r.end = Math.min(r.start + ZOUT_MS / 1e3, ramps[i + 1].start - .01);
523
+ } else {
524
+ const start = Math.min(prevEndMs, e.tMs - minRamp);
525
+ r.start = Math.max(start, 0) / 1e3;
526
+ r.end = e.tMs / 1e3;
527
+ }
528
+ }
529
+ }
530
+ const landTs = anchors.map((e, i) => {
531
+ const nextStart = anchors[i + 1] ? ramps[i + 1].start : Number.POSITIVE_INFINITY;
532
+ const rampEnd = ramps[i].end;
533
+ return rampEnd === e.tMs / 1e3 ? rampEnd : Math.max(ramps[i].start + Math.min(ZOUT_MS, ZIN_MS) / 1e3, Math.min(rampEnd, nextStart - .01));
534
+ });
535
+ return {
536
+ anchors,
537
+ targets,
538
+ restR,
539
+ ramps,
540
+ landTs,
541
+ rectFor
542
+ };
543
+ }
544
+ /** Per-EVENT camera ramp timing (ms), for the refine surfaces (A/B windows,
545
+ * review badges): when the camera actually departs toward a beat and when it
546
+ * lands. `null` for a beat the camera holds through (no anchor). Derived from
547
+ * the same schedule the render uses, so a dwell-delayed pull-out (which
548
+ * departs after the stored inAtMs and can land after its own tMs) is
549
+ * reflected instead of approximated from inAtMs. */
550
+ function cameraRampSchedule(comp) {
551
+ const { anchors, ramps, landTs } = buildCameraSchedule(comp);
552
+ const out = comp.events.map(() => null);
553
+ anchors.forEach((a, i) => {
554
+ out[a.evIdx] = {
555
+ startMs: ramps[i].start * 1e3,
556
+ landMs: landTs[i] * 1e3
557
+ };
558
+ });
559
+ return out;
560
+ }
561
+ function buildStageKeyframes(comp) {
562
+ const { anchors, targets, restR, ramps, landTs, rectFor } = buildCameraSchedule(comp);
563
+ const HOLD = comp.cursor.holdMs / 1e3;
564
+ const ZOUT_MS = comp.cursor.zoomOutMs;
489
565
  const rf = [{
490
566
  t: 0,
491
567
  r: restR
@@ -498,16 +574,17 @@ function buildStageKeyframes(comp) {
498
574
  };
499
575
  let cur = restR;
500
576
  anchors.forEach((e, i) => {
501
- const clickT = e.tMs / 1e3;
502
577
  const actionEnd = (e.tMs + e.durationMs) / 1e3;
503
578
  const next = anchors[i + 1];
504
- const holdEndT = next ? rampStartS[i + 1] : actionEnd + HOLD;
505
- push(rampStartS[i], cur);
506
- push(clickT, targets[i]);
579
+ const nextStart = next ? ramps[i + 1].start : Number.POSITIVE_INFINITY;
580
+ const landT = landTs[i];
581
+ const holdEndT = Math.max(next ? nextStart : actionEnd + HOLD, landT);
582
+ push(ramps[i].start, cur);
583
+ push(landT, targets[i]);
507
584
  cur = targets[i];
508
585
  let holdR = cur;
509
586
  if (e.glide && (e.glide.x !== 0 || e.glide.y !== 0)) {
510
- const holdDur = Math.max(0, holdEndT - clickT);
587
+ const holdDur = Math.max(0, holdEndT - landT);
511
588
  holdR = rectFor({
512
589
  x: e.center.x + e.glide.x * holdDur,
513
590
  y: e.center.y + e.glide.y * holdDur
@@ -528,6 +605,65 @@ function buildStageKeyframes(comp) {
528
605
  T
529
606
  };
530
607
  }
608
+ /** Residual (1 − progress) of an overdamped spring's unit step response, on
609
+ * NORMALISED segment time u = (t − t0)/(t1 − t0). ω0 is solved so the
610
+ * residual at u=1 (the action instant) equals `frac`; past u=1 the same
611
+ * curve keeps decaying — the tail that replaces the legacy cut. ζ=1.2 gives
612
+ * the reference-measured shape: a fast main ramp (peak velocity ~14% in)
613
+ * plus a slow settle pole; at frac 0.04 the tail τ ≈ duration/3.6 (730ms →
614
+ * ~205ms, 1340ms → ~375ms — the frame-tracked reference tails; a different
615
+ * frac shifts ω0 and with it τ). */
616
+ function settleDecay(frac) {
617
+ const zeta = 1.2;
618
+ const s = Math.sqrt(zeta * zeta - 1);
619
+ const l1 = zeta + s;
620
+ const l2 = zeta - s;
621
+ const resid = (x) => (l1 * Math.exp(-l2 * x) - l2 * Math.exp(-l1 * x)) / (l1 - l2);
622
+ let lo = .1;
623
+ let hi = 60;
624
+ for (let i = 0; i < 60; i++) {
625
+ const mid = (lo + hi) / 2;
626
+ if (resid(mid) > frac) lo = mid;
627
+ else hi = mid;
628
+ }
629
+ const w0T = (lo + hi) / 2;
630
+ return (u) => u <= 0 ? 1 : resid(w0T * u);
631
+ }
632
+ /** Evaluate the rect track with moves that settle ASYMPTOTICALLY: each ramp
633
+ * covers 1−frac of its distance by its keyframe end, then keeps creeping
634
+ * toward the target through the following hold (never a velocity cliff). A
635
+ * ramp launches from wherever the previous tail actually is (position-
636
+ * continuous chaining); every emitted rect is a convex combination of
637
+ * build-time-clamped rects, and the valid-rect set is convex (linear
638
+ * half-plane bounds in cx,cy,w), so in-between rects stay valid exactly as
639
+ * in the lerped path. */
640
+ function settleRectAt(kfs, decay, t) {
641
+ let from = kfs[0][1];
642
+ for (let i = 0; i < kfs.length - 1; i++) {
643
+ const [t0, r0] = kfs[i];
644
+ const [t1, r1] = kfs[i + 1];
645
+ if (r0.cx === r1.cx && r0.cy === r1.cy && r0.w === r1.w) continue;
646
+ if (t < t0) break;
647
+ let handoff = Number.POSITIVE_INFINITY;
648
+ for (let j = i + 1; j < kfs.length - 1; j++) {
649
+ const [ta, ra] = kfs[j];
650
+ const [, rb] = kfs[j + 1];
651
+ if (ra.cx !== rb.cx || ra.cy !== rb.cy || ra.w !== rb.w) {
652
+ handoff = ta;
653
+ break;
654
+ }
655
+ }
656
+ const evalT = Math.min(t, handoff);
657
+ const d = decay((evalT - t0) / Math.max(t1 - t0, 1e-6));
658
+ from = {
659
+ cx: r1.cx + (from.cx - r1.cx) * d,
660
+ cy: r1.cy + (from.cy - r1.cy) * d,
661
+ w: r1.w + (from.w - r1.w) * d
662
+ };
663
+ if (t < handoff) return from;
664
+ }
665
+ return from;
666
+ }
531
667
  /** The one camera evaluator — scene.tsx (render) and the editor preview both
532
668
  * consume THIS, so preview and export can never drift. */
533
669
  function stageCamera(comp) {
@@ -535,8 +671,11 @@ function stageCamera(comp) {
535
671
  const ease = stageEasing(comp.cursor);
536
672
  const oW = comp.output.width;
537
673
  const rest = restStageScale(comp.source.videoWidth, comp.source.videoHeight, oW, comp.output.height, comp.framing.insetFrac);
674
+ const frac = comp.cursor.zoomSettleFrac ?? 0;
675
+ const useSettle = frac > 0 && comp.cursor.zoomSpring == null && !comp.cursor.zoomEase;
676
+ const decay = useSettle ? settleDecay(frac) : void 0;
538
677
  const at = (t) => {
539
- const r = keyvalR(t, stage.r, ease);
678
+ const r = decay ? settleRectAt(stage.r, decay, t) : keyvalR(t, stage.r, ease);
540
679
  return {
541
680
  scale: oW / r.w,
542
681
  center: {
@@ -673,12 +812,29 @@ function growDown(box, video) {
673
812
  h
674
813
  };
675
814
  }
676
- /** The region a beat is "about" — what the camera should frame. Prefers the
677
- * captured effect region; else shapes one from the element bbox by kind. */
815
+ /** The region a beat is "about" — what the camera should frame. A type is
816
+ * field-anchored and height-capped (its reveal is open-ended); every other
817
+ * kind trusts the captured effect region, else shapes one from the bbox. */
678
818
  function roiForBeat(b, video) {
819
+ if (b.kind === "press" && b.intent === "always" && b.box) return b.box;
820
+ if (b.kind === "type" && b.box) {
821
+ const capH = growDown(b.box, video).h;
822
+ if (b.effectBox) {
823
+ const x = Math.min(b.box.x, b.effectBox.x);
824
+ const right = Math.max(b.box.x + b.box.w, b.effectBox.x + b.effectBox.w);
825
+ const bottom = b.effectBox.y + b.effectBox.h;
826
+ const h = Math.max(b.box.h, Math.min(capH, bottom - b.box.y));
827
+ return {
828
+ x,
829
+ y: b.box.y,
830
+ w: right - x,
831
+ h
832
+ };
833
+ }
834
+ return growDown(b.box, video);
835
+ }
679
836
  if (b.effectBox) return b.effectBox;
680
837
  if (!b.box) return void 0;
681
- if (b.kind === "type") return growDown(b.box, video);
682
838
  return b.box;
683
839
  }
684
840
  function clusterLabel(beats, idx) {
@@ -709,14 +865,17 @@ function directCamera(beats, video, out, cam, rest, endMs) {
709
865
  boundary: true,
710
866
  reason: "plan: zoom=never → full view"
711
867
  };
712
- if (b.intent === "always") return {
713
- roi,
714
- scale,
715
- forceFull: false,
716
- forcePunch: true,
717
- boundary: true,
718
- reason: roi ? `plan: zoom=always → ${scale.toFixed(2)}× (framing from ROI)` : "plan: zoom=always but no bbox to frame → full view"
719
- };
868
+ if (b.intent === "always") {
869
+ const floored = roi ? Math.max(scale, cam.minZoomScale) : scale;
870
+ return {
871
+ roi,
872
+ scale: floored,
873
+ forceFull: false,
874
+ forcePunch: true,
875
+ boundary: true,
876
+ reason: roi ? floored > scale ? `plan: zoom=always → ROI fit ${scale.toFixed(2)}× is imperceptible — floored to ${floored.toFixed(2)}×` : `plan: zoom=always → ${floored.toFixed(2)}× (framing from ROI)` : "plan: zoom=always but no bbox to frame → full view"
877
+ };
878
+ }
720
879
  if (b.kind === "scroll") return {
721
880
  roi: void 0,
722
881
  scale: rest,
@@ -741,7 +900,7 @@ function directCamera(beats, video, out, cam, rest, endMs) {
741
900
  boundary: true,
742
901
  reason: `changeCoverage ${b.changeCoverage.toFixed(2)} ≥ ${cam.pullOutCoverage} (global repaint) → full view`
743
902
  };
744
- if (i === 0) return {
903
+ if (i === 0 && b.tMs < 2e3) return {
745
904
  roi,
746
905
  scale,
747
906
  forceFull: true,
@@ -843,7 +1002,7 @@ function directCamera(beats, video, out, cam, rest, endMs) {
843
1002
  //#endregion
844
1003
  //#region src/plan.ts
845
1004
  function planComposition(log, opts = {}) {
846
- const vW = log.video.width, vH = log.video.height;
1005
+ const vW = log.viewport.w, vH = log.viewport.h;
847
1006
  const oW = opts.output?.width ?? vW;
848
1007
  const oH = opts.output?.height ?? vH;
849
1008
  const fps = opts.output?.fps ?? 30;
@@ -1056,7 +1215,7 @@ function validateComposition(comp, opts = {}) {
1056
1215
  if (z.inAtMs > e.tMs) err(`${p}.zoom.inAtMs`, `inAtMs ${z.inAtMs} is AFTER the action at tMs ${e.tMs} — the zoom would arrive late`, `set inAtMs = tMs − cursor.zoomInMs (= ${Math.max(0, e.tMs - comp.cursor.zoomInMs)})`);
1057
1216
  if (z.enabled) {
1058
1217
  if (z.scale < rest - 1e-6) err(`${p}.zoom.scale`, `scale ${z.scale.toFixed(3)} is below rest ${rest.toFixed(3)} — that zooms OUT past the frame (dead space)`, `raise to ≥ ${rest.toFixed(2)}, or set zoom.enabled=false for a full-view beat`);
1059
- else if (z.scale <= rest + 1e-6) warn(`${p}.zoom.scale`, `scale ${z.scale.toFixed(3)} ≈ rest — zoom is enabled but does nothing visible`, "raise scale to actually zoom, or set enabled=false");
1218
+ else if (z.scale < rest * 1.2) warn(`${p}.zoom.scale`, `scale ${z.scale.toFixed(3)} is within 20% of rest ${rest.toFixed(3)} — an imperceptible zoom (enabled but invisible)`, "raise scale to ≥ ~1.25 to actually zoom, or set enabled=false");
1060
1219
  if (z.scale > maxScale) warn(`${p}.zoom.scale`, `scale ${z.scale.toFixed(2)} exceeds the soft cap ${maxScale} — pixels will soften`, `clamp toward ${maxScale.toFixed(1)} unless the detail truly needs it`);
1061
1220
  if (z.center.x < 0 || z.center.x > vW || z.center.y < 0 || z.center.y > vH) warn(`${p}.zoom.center`, `center (${z.center.x.toFixed(0)},${z.center.y.toFixed(0)}) is outside the video ${vW}x${vH}`, e.bbox ? "use the bbox center: { x: bbox.x+bbox.w/2, y: bbox.y+bbox.h/2 }" : "point at the on-screen target (video-px)");
1062
1221
  if (!e.bbox) warn(`${p}.zoom`, "zoom enabled on a beat with no bbox — center/scale are hand-set, not bbox-fit", "double-check the center frames the intended region");
@@ -1067,8 +1226,28 @@ function validateComposition(comp, opts = {}) {
1067
1226
  if (!(spring >= 0 && spring < .6)) err("cursor.zoomSpring", `zoomSpring ${spring} outside [0, 0.6)`, "0 = critically damped (the default feel); keep bounce ≤ 0.3");
1068
1227
  else if (spring > .3) warn("cursor.zoomSpring", `zoomSpring ${spring} is a lot of bounce — the rect overshoot can flash backdrop at edge-flush targets and over-zoom tight punches`, "keep ≤ 0.3 (the editor slider's max) unless the flash is wanted");
1069
1228
  }
1229
+ const settleFrac = comp.cursor.zoomSettleFrac;
1230
+ if (settleFrac != null && !(settleFrac >= 0 && settleFrac <= .15)) err("cursor.zoomSettleFrac", `zoomSettleFrac ${settleFrac} outside [0, 0.15]`, "~0.04 = the reference-measured tail; 0 = legacy cut spring");
1231
+ else if (settleFrac != null && settleFrac > 0 && (comp.cursor.zoomEase || spring != null)) warn("cursor.zoomSettleFrac", `zoomSettleFrac is IGNORED while cursor.${comp.cursor.zoomEase ? "zoomEase" : "zoomSpring"} is set — the render is byte-identical to not setting it`, "delete cursor.zoomEase / cursor.zoomSpring (a pace preset clears zoomEase) to activate the settle tail");
1232
+ const dwell = comp.cursor.pullOutDwellMs;
1233
+ if (dwell != null && !(dwell >= 0 && dwell <= 5e3)) err("cursor.pullOutDwellMs", `pullOutDwellMs ${dwell} outside [0, 5000]`, "600-1000 reads as a natural beat; 0 = legacy (depart as soon as the action ends)");
1070
1234
  if (comp.durationMs < lastEnd) err("durationMs", `durationMs ${comp.durationMs} ends before the last action (${lastEnd})`, `raise to ≥ ${Math.round(lastEnd + comp.cursor.holdMs + comp.cursor.zoomOutMs)}`);
1071
1235
  else if (comp.durationMs < lastEnd + comp.cursor.zoomOutMs) warn("durationMs", `only ${comp.durationMs - lastEnd}ms after the last action — the final zoom-out may be cut`, `allow ≥ ${comp.cursor.zoomOutMs}ms (cursor.zoomOutMs) of tail`);
1236
+ if ((comp.cursor.pullOutDwellMs ?? 0) > 0 && issues.every((i) => i.severity !== "error")) try {
1237
+ const kfs = buildStageKeyframes(comp).r;
1238
+ let motionEndS = 0;
1239
+ for (let i = 0; i < kfs.length - 1; i++) {
1240
+ const [, a] = kfs[i];
1241
+ const [t1, b] = kfs[i + 1];
1242
+ if (a.cx !== b.cx || a.cy !== b.cy || a.w !== b.w) motionEndS = t1;
1243
+ }
1244
+ if (motionEndS * 1e3 > comp.durationMs + 1) warn("durationMs", `the camera is still mid-motion at durationMs (dwell-delayed landing ends ~${Math.round(motionEndS * 1e3)}ms)`, `raise durationMs to ≥ ${Math.round(motionEndS * 1e3)}`);
1245
+ } catch {}
1246
+ const startMs = comp.startMs;
1247
+ if (startMs != null) {
1248
+ if (!(startMs >= 0) || startMs >= comp.durationMs) err("startMs", `startMs ${startMs} outside [0, durationMs ${comp.durationMs})`, "the head trim must leave a video");
1249
+ else if (comp.events[0] && startMs > comp.events[0].zoom.inAtMs) warn("startMs", `startMs ${startMs} cuts into the first beat (camera/cursor already moving at ${comp.events[0].zoom.inAtMs}ms)`, `keep the trim ≤ ${comp.events[0].zoom.inAtMs} so the delivered video opens at rest`);
1250
+ }
1072
1251
  if (opts.captureLog) {
1073
1252
  const log = opts.captureLog;
1074
1253
  if (log.events.length !== events.length) warn("events", `composition has ${events.length} beats but the capture log has ${log.events.length} — added/removed actions need a re-capture`, "re-capture to change the choreography; edit only renders the existing recording");
@@ -1243,6 +1422,7 @@ async function renderTakeExclusive(opts) {
1243
1422
  if (opts.logProgress && warns.length) process.stderr.write(`composition warnings:\n${formatIssues(warns)}\n`);
1244
1423
  if (errors.length) throw new Error(`composition has ${errors.length} error(s) — refusing to render:\n${formatIssues(errors)}`);
1245
1424
  }
1425
+ const rangeSec = opts.rangeSec ?? (composition.startMs && composition.startMs > 0 ? [composition.startMs / 1e3, composition.durationMs / 1e3 + 120] : void 0);
1246
1426
  await repairBundledMediaPermissions();
1247
1427
  const scratch = await prepareScratch(composition, opts.videoPath);
1248
1428
  const deps = depsRoot();
@@ -1258,7 +1438,7 @@ async function renderTakeExclusive(opts) {
1258
1438
  outFile: "take.mp4",
1259
1439
  outDir: RENDER_OUT,
1260
1440
  workers: 1,
1261
- ...opts.rangeSec ? { projectSettings: { range: opts.rangeSec } } : {},
1441
+ ...rangeSec ? { projectSettings: { range: rangeSec } } : {},
1262
1442
  logProgress: opts.logProgress ?? false,
1263
1443
  ...opts.onProgress ? { progressCallback: (_worker, progress) => opts.onProgress(progress) } : {},
1264
1444
  viteConfig: { server: { fs: { allow: [scratch, ...deps ? [deps] : []] } } },