@open-take/compositor 0.2.7 → 0.2.9
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 +185 -40
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +257 -26
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/camera.ts +1 -1
- package/src/index.ts +1 -1
- package/src/math.ts +196 -18
- package/src/plan.ts +12 -9
- package/src/presets.ts +32 -1
- package/src/render.ts +31 -13
- package/src/scene/scene.tsx +86 -3
- package/src/types.ts +88 -7
- package/src/validate.ts +261 -1
package/src/types.ts
CHANGED
|
@@ -102,17 +102,43 @@ export type CapturePress = CaptureEventBase & {
|
|
|
102
102
|
durationMs: number;
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
+
/** A file drag-and-drop (OS-level, synthesized via CDP Input.dispatchDragEvent
|
|
106
|
+
* with real file paths): the cursor carries the file(s) from the anchor
|
|
107
|
+
* (`x,y`) along `path` to `to`, where the drop lands and the page receives
|
|
108
|
+
* actual Files. The compositor draws a "file ghost card" riding the cursor
|
|
109
|
+
* for this beat — the recording itself shows only the page's reaction. */
|
|
110
|
+
export type CaptureDropFiles = CaptureEventBase & {
|
|
111
|
+
kind: "dropFiles";
|
|
112
|
+
/** drop point, viewport CSS px */
|
|
113
|
+
to: { x: number; y: number };
|
|
114
|
+
/** full polyline incl. ends, viewport CSS px */
|
|
115
|
+
path?: { x: number; y: number }[];
|
|
116
|
+
/** ms the carry occupies on screen (ground-truth wall time) */
|
|
117
|
+
durationMs: number;
|
|
118
|
+
/** carry pacing baked into the dispatched dragOver march (see CaptureDrag) */
|
|
119
|
+
ease?: "linear" | "smooth";
|
|
120
|
+
/** dropped files' display metadata (basename + bytes) for the ghost card */
|
|
121
|
+
files: { name: string; size?: number }[];
|
|
122
|
+
};
|
|
123
|
+
|
|
105
124
|
export type CaptureEvent =
|
|
106
125
|
| CaptureClick
|
|
107
126
|
| CaptureType
|
|
108
127
|
| CaptureDrag
|
|
109
128
|
| CaptureScroll
|
|
110
129
|
| CaptureHover
|
|
111
|
-
| CapturePress
|
|
130
|
+
| CapturePress
|
|
131
|
+
| CaptureDropFiles;
|
|
112
132
|
|
|
113
133
|
export type CaptureLog = {
|
|
114
134
|
video: { width: number; height: number; fps?: number | string; durationS?: number };
|
|
115
135
|
viewport: { w: number; h: number };
|
|
136
|
+
/** the app this take was shot from (the plan's url). Written by makeTake into
|
|
137
|
+
* the KEPT log; the composition never reads it. It exists so a take can say
|
|
138
|
+
* which app it is of — `make` refuses to overwrite a take of a different
|
|
139
|
+
* app, which is what stops a second demo in the same folder from destroying
|
|
140
|
+
* the first. Absent on takes made before it was recorded. */
|
|
141
|
+
url?: string;
|
|
116
142
|
start?: { x: number; y: number };
|
|
117
143
|
/** the ordered ground-truth actions (click / type / drag) */
|
|
118
144
|
events: CaptureEvent[];
|
|
@@ -122,6 +148,26 @@ export type CaptureLog = {
|
|
|
122
148
|
* summary and (with --strict) the exit code, not just an early stderr line
|
|
123
149
|
* buried under render progress. `step` is the plan's 0-based step index. */
|
|
124
150
|
skipped?: { step: number; action: string; target?: string; reason: string }[];
|
|
151
|
+
/** Beats whose editorial hold ran out before the PAGE had finished — the
|
|
152
|
+
* capture kept waiting (see runtime/src/settle.ts) and records how much
|
|
153
|
+
* longer it needed. This is the measurement that replaces guessing
|
|
154
|
+
* `settleMs`: `heldMs + waitedMs` is what that beat actually wanted, and
|
|
155
|
+
* `reason: "budget"` means even the extra wait was not enough. Absent when
|
|
156
|
+
* every hold was already long enough. */
|
|
157
|
+
settleWaits?: {
|
|
158
|
+
step: number;
|
|
159
|
+
action: string;
|
|
160
|
+
heldMs: number;
|
|
161
|
+
waitedMs: number;
|
|
162
|
+
reason: "idle" | "budget" | "unavailable";
|
|
163
|
+
}[];
|
|
164
|
+
/** Largest share of the frame a `<canvas>`/`<video>` held during the capture.
|
|
165
|
+
* It matters because the settle probe reads the page's STRUCTURE, and a
|
|
166
|
+
* paint surface never changes structurally no matter what is drawn inside
|
|
167
|
+
* it — so on a canvas-driven app "the page settled" is not evidence the
|
|
168
|
+
* beat's payoff had appeared, and `settleMs` is doing the whole job alone.
|
|
169
|
+
* Absent on an ordinary DOM app. */
|
|
170
|
+
paintedFrac?: number;
|
|
125
171
|
};
|
|
126
172
|
|
|
127
173
|
// --- the composition (editable) ----------------------------------------
|
|
@@ -146,8 +192,18 @@ export type ZoomDecision = {
|
|
|
146
192
|
reason: string;
|
|
147
193
|
};
|
|
148
194
|
|
|
195
|
+
/** Ghost-card knobs for a dropFiles beat (editable): the macOS-style file
|
|
196
|
+
* card riding the cursor during the carry. */
|
|
197
|
+
export type GhostCardConfig = {
|
|
198
|
+
enabled: boolean;
|
|
199
|
+
/** card offset from the cursor tip, video-px (default ~{x:26,y:30}) */
|
|
200
|
+
offset?: Pt;
|
|
201
|
+
/** ms of the release pop after the drop (fade + settle; default 280) */
|
|
202
|
+
releaseMs?: number;
|
|
203
|
+
};
|
|
204
|
+
|
|
149
205
|
export type CompEvent = {
|
|
150
|
-
kind: "click" | "type" | "drag" | "scroll" | "hover" | "press";
|
|
206
|
+
kind: "click" | "type" | "drag" | "scroll" | "hover" | "press" | "dropFiles";
|
|
151
207
|
tMs: number;
|
|
152
208
|
/** anchor point (click / focus / drag start / hover) in video-px. For a
|
|
153
209
|
* scroll/press the cursor does not move; this is its resting point. */
|
|
@@ -170,6 +226,10 @@ export type CompEvent = {
|
|
|
170
226
|
/** drag stroke easing baked into the ink (kind=drag): "smooth" or "linear".
|
|
171
227
|
* The cursor replays it so it stays locked to the ink. Absent ⇒ linear. */
|
|
172
228
|
ease?: "linear" | "smooth";
|
|
229
|
+
/** dropped files' display metadata (kind=dropFiles), for the ghost card */
|
|
230
|
+
files?: { name: string; size?: number }[];
|
|
231
|
+
/** ghost-card rendering knobs (kind=dropFiles); absent ⇒ enabled defaults */
|
|
232
|
+
ghostCard?: GhostCardConfig;
|
|
173
233
|
};
|
|
174
234
|
|
|
175
235
|
export type FramingConfig = {
|
|
@@ -190,15 +250,36 @@ export type CursorConfig = {
|
|
|
190
250
|
travelMs: number;
|
|
191
251
|
/** Distance-aware travel speed, as a fraction of the source video WIDTH per
|
|
192
252
|
* second (resolution-independent). A travel leg's duration is
|
|
193
|
-
* `
|
|
194
|
-
*
|
|
253
|
+
* `distance / (widthsPerSec·videoWidth·zoomFrac)`, floored at `travelMinMs` and
|
|
254
|
+
* then capped at `travelMaxMs` (in that order — an inverted band pins short hops
|
|
255
|
+
* to the floor, not everything to the ceiling), so the cursor holds a roughly
|
|
256
|
+
* CONSTANT on-screen speed regardless of distance —
|
|
195
257
|
* the premium-recorder feel (measured ~0.30 widths/s on the reference). Set 0
|
|
196
|
-
* to fall back to the fixed `travelMs`.
|
|
258
|
+
* to fall back to the fixed `travelMs`.
|
|
259
|
+
*
|
|
260
|
+
* `zoomFrac = restScale / camera scale` — exactly 1 for a full-view take, so a
|
|
261
|
+
* zoom-less composition is unaffected. While the camera is punched in, the same
|
|
262
|
+
* video-px move covers proportionally more of the DELIVERED frame, so without
|
|
263
|
+
* this factor a 2× punch-in reads ~2× too fast precisely where the viewer is
|
|
264
|
+
* looking closest. zoomFrac is INTEGRATED across the leg, not sampled at one
|
|
265
|
+
* instant: a travel usually departs while the camera is still wide and lands
|
|
266
|
+
* after it has closed in, and pricing all of it at the landing magnification
|
|
267
|
+
* over-slows the departure by as much as a zoom-blind duration over-sped it.
|
|
268
|
+
* A leg the camera holds a frame through degenerates to that one frame's
|
|
269
|
+
* factor, which is the sampled model's only exactly-right case. */
|
|
197
270
|
travelWidthsPerSec: number;
|
|
198
|
-
/** Floor for a distance-aware travel (ms) so short hops aren't an instant snap.
|
|
271
|
+
/** Floor for a distance-aware travel (ms) so short hops aren't an instant snap.
|
|
272
|
+
* NOTE both clamps are applied AFTER the speed model and neither is part of a
|
|
273
|
+
* `pace` preset, so on the legs they bind THEY set the duration and re-pacing
|
|
274
|
+
* the take does nothing. validate.ts says so once that stops being the
|
|
275
|
+
* exception (see CLAMPED_LEGS_FRAC). */
|
|
199
276
|
travelMinMs: number;
|
|
200
277
|
/** Ceiling for a distance-aware travel (ms) so a full-width jump stays a glide,
|
|
201
|
-
* not a multi-second crawl.
|
|
278
|
+
* not a multi-second crawl. Binds on any sweep past
|
|
279
|
+
* `travelMaxMs · travelWidthsPerSec · videoWidth` — ~571px of a 1920 frame at
|
|
280
|
+
* the shipped defaults — which is deliberate (it was eye-tuned on a reference
|
|
281
|
+
* recorder's long moves), so it also bounds how much of the zoom correction
|
|
282
|
+
* above a long zoomed sweep can actually receive. */
|
|
202
283
|
travelMaxMs: number;
|
|
203
284
|
scale: number;
|
|
204
285
|
arcFrac: number;
|
package/src/validate.ts
CHANGED
|
@@ -16,9 +16,37 @@
|
|
|
16
16
|
// action needs a re-capture, not a JSON edit. Pass the capture log to enforce
|
|
17
17
|
// this; without it the check is skipped (we can't know the ground truth).
|
|
18
18
|
|
|
19
|
-
import { buildStageKeyframes, restStageScale } from "./math";
|
|
19
|
+
import { buildLegs, buildStageKeyframes, cameraRampSchedule, restStageScale } from "./math";
|
|
20
|
+
import { CLAMP_TOL_MS, MOTION, motionName } from "./presets";
|
|
21
|
+
import { DEFAULT_CURSOR } from "./types";
|
|
20
22
|
import type { CaptureLog, TakeComposition } from "./types";
|
|
21
23
|
|
|
24
|
+
/** Tail past the last beat's settle that still reads as "the shot breathing".
|
|
25
|
+
* Beyond it the delivered mp4 is a frozen screen — the padded-to-25s failure. */
|
|
26
|
+
const DEAD_TAIL_MS = 2500;
|
|
27
|
+
/** A dwell-delayed pull-out lands a little after its own action BY DESIGN, and
|
|
28
|
+
* a tail of a few frames is invisible (the spring has all but arrived). The
|
|
29
|
+
* artifact is a camera that has barely LEFT when the action fires — so gate on
|
|
30
|
+
* both an absolute floor and the fraction of the ramp still to run. */
|
|
31
|
+
const MOVING_AT_ACTION_MS = 150;
|
|
32
|
+
const MOVING_AT_ACTION_FRAC = 0.25;
|
|
33
|
+
/** How far past the SLOWEST shipped pace a camera window may run before it is
|
|
34
|
+
* worth a word. Anchored on the preset vocabulary rather than a number
|
|
35
|
+
* invented here, so the ceiling tracks the presets if they are ever retuned. */
|
|
36
|
+
const RAMP_SLACK = 2;
|
|
37
|
+
/** A travel clamp binding on the odd short hop is the point of having clamps;
|
|
38
|
+
* binding on more than this share of the legs means the speed law (and the
|
|
39
|
+
* whole `pace` preset) is not what paces the take. Under CLAMPED_LEGS_MIN legs
|
|
40
|
+
* the share says nothing — two clamped legs out of two is a fixture, not a
|
|
41
|
+
* finding. */
|
|
42
|
+
const CLAMPED_LEGS_FRAC = 0.5;
|
|
43
|
+
const CLAMPED_LEGS_MIN = 3;
|
|
44
|
+
/** A travel squeezed under this share of what the speed law asked for reads as
|
|
45
|
+
* a dart rather than a glide. Paired with an absolute floor so a few-frame
|
|
46
|
+
* shortfall on an already-short hop stays quiet. */
|
|
47
|
+
const SQUEEZE_FRAC = 0.7;
|
|
48
|
+
const SQUEEZE_MIN_MS = 200;
|
|
49
|
+
|
|
22
50
|
export type CompositionIssue = {
|
|
23
51
|
severity: "error" | "warn";
|
|
24
52
|
/** dotted/indexed field path, e.g. "events[3].zoom.scale" */
|
|
@@ -41,6 +69,7 @@ const reqField: Record<string, string> = {
|
|
|
41
69
|
type: "text",
|
|
42
70
|
press: "keys",
|
|
43
71
|
drag: "to",
|
|
72
|
+
dropFiles: "to",
|
|
44
73
|
};
|
|
45
74
|
|
|
46
75
|
export function validateComposition(
|
|
@@ -125,6 +154,18 @@ export function validateComposition(
|
|
|
125
154
|
`${e.kind} beat is missing "${need}"`,
|
|
126
155
|
`restore ${need} from the capture`,
|
|
127
156
|
);
|
|
157
|
+
if (e.kind === "dropFiles" && !e.files?.length)
|
|
158
|
+
warn(
|
|
159
|
+
`${p}.files`,
|
|
160
|
+
`dropFiles beat has no files metadata — the ghost card will show a generic "file"`,
|
|
161
|
+
"restore files [{name,size}] from the capture",
|
|
162
|
+
);
|
|
163
|
+
if (e.kind === "dropFiles" && !dur)
|
|
164
|
+
warn(
|
|
165
|
+
`${p}.durationMs`,
|
|
166
|
+
"dropFiles beat has no carry duration — the cursor teleports to the drop point and the ghost card only flashes",
|
|
167
|
+
"restore durationMs from the capture",
|
|
168
|
+
);
|
|
128
169
|
|
|
129
170
|
// --- zoom decision ---
|
|
130
171
|
const z = e.zoom;
|
|
@@ -198,6 +239,87 @@ export function validateComposition(
|
|
|
198
239
|
}
|
|
199
240
|
}
|
|
200
241
|
|
|
242
|
+
// --- cursor motion knobs ---------------------------------------------------
|
|
243
|
+
// These are plain numbers in the schema and, until here, NOTHING bounded them:
|
|
244
|
+
// a hand edit (or an agent reaching for "start the zoom earlier" and stretching
|
|
245
|
+
// the wrong knob) could put the whole take on a crawl with every other check
|
|
246
|
+
// still passing.
|
|
247
|
+
//
|
|
248
|
+
// PRESENT-but-nonsensical is an error: the schedule arithmetic turns it into
|
|
249
|
+
// NaN keyframes. ABSENT is usually the LEGACY shape — compositions predate
|
|
250
|
+
// travelWidthsPerSec / travelMin/MaxMs / zoomInMs and the schedule has a
|
|
251
|
+
// documented fallback for each — so absence is an error only where nothing
|
|
252
|
+
// can stand in. (A validator that refused to render yesterday's composition
|
|
253
|
+
// would be a worse bug than the one it catches.)
|
|
254
|
+
const cur = comp.cursor;
|
|
255
|
+
type MsKnob =
|
|
256
|
+
| "travelMs"
|
|
257
|
+
| "travelMinMs"
|
|
258
|
+
| "travelMaxMs"
|
|
259
|
+
| "holdMs"
|
|
260
|
+
| "zoomInMs"
|
|
261
|
+
| "zoomOutMs"
|
|
262
|
+
| "travelWidthsPerSec";
|
|
263
|
+
const knob = (k: MsKnob, positive: boolean, required: boolean) => {
|
|
264
|
+
const v: number | undefined = cur[k];
|
|
265
|
+
if (v == null) {
|
|
266
|
+
if (required)
|
|
267
|
+
err(
|
|
268
|
+
`cursor.${k}`,
|
|
269
|
+
`${k} is missing and the schedule has no fallback for it`,
|
|
270
|
+
`set cursor.${k} to the shipped default (${DEFAULT_CURSOR[k]})`,
|
|
271
|
+
);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
if (typeof v !== "number" || !Number.isFinite(v) || (positive ? v <= 0 : v < 0))
|
|
275
|
+
err(
|
|
276
|
+
`cursor.${k}`,
|
|
277
|
+
`${k} must be a ${positive ? "positive" : "non-negative"} number (got ${JSON.stringify(v)})`,
|
|
278
|
+
`restore the shipped default (${DEFAULT_CURSOR[k]})`,
|
|
279
|
+
);
|
|
280
|
+
};
|
|
281
|
+
// The speed law is live only with a positive travelWidthsPerSec; without it
|
|
282
|
+
// the cursor runs on the fixed travelMs and the clamps are never consulted.
|
|
283
|
+
const speedLaw = typeof cur.travelWidthsPerSec === "number" && cur.travelWidthsPerSec > 0;
|
|
284
|
+
knob("holdMs", false, true);
|
|
285
|
+
knob("zoomOutMs", true, true);
|
|
286
|
+
knob("zoomInMs", true, false); // absent ⇒ the legacy inAtMs→tMs window
|
|
287
|
+
knob("travelWidthsPerSec", false, false); // absent/0 ⇒ the documented travelMs fallback
|
|
288
|
+
knob("travelMs", true, !speedLaw);
|
|
289
|
+
knob("travelMinMs", false, speedLaw);
|
|
290
|
+
knob("travelMaxMs", true, speedLaw);
|
|
291
|
+
if (
|
|
292
|
+
Number.isFinite(cur.travelMinMs) &&
|
|
293
|
+
Number.isFinite(cur.travelMaxMs) &&
|
|
294
|
+
cur.travelMaxMs < cur.travelMinMs
|
|
295
|
+
)
|
|
296
|
+
// An inverted band has no coherent answer, and the clamps are applied in
|
|
297
|
+
// order (floor first — see math.ts travelDur), so every leg lands on one
|
|
298
|
+
// bound or the other and the ordering INVERTS: a short hop takes the
|
|
299
|
+
// 800ms floor while a full-frame sweep takes the 400ms ceiling.
|
|
300
|
+
err(
|
|
301
|
+
"cursor.travelMaxMs",
|
|
302
|
+
`travelMaxMs ${cur.travelMaxMs} is below travelMinMs ${cur.travelMinMs} — an inverted band, so every leg is pinned to one bound or the other and SHORT hops (${cur.travelMinMs}ms) end up slower than full-frame sweeps (${cur.travelMaxMs}ms)`,
|
|
303
|
+
`raise travelMaxMs above travelMinMs (defaults ${DEFAULT_CURSOR.travelMinMs}/${DEFAULT_CURSOR.travelMaxMs})`,
|
|
304
|
+
);
|
|
305
|
+
// A punch-in's ramp END is pinned to the action instant, so a LONGER window
|
|
306
|
+
// means departing EARLIER and creeping — never landing later. Past roughly
|
|
307
|
+
// twice the slowest shipped pace the settle curve reads as a drift, and
|
|
308
|
+
// nothing else here catches it (the crowded-release check below only fires on
|
|
309
|
+
// a ramp that lands LATE).
|
|
310
|
+
if (cur.zoomInMs > MOTION.calm.zoomInMs * RAMP_SLACK)
|
|
311
|
+
warn(
|
|
312
|
+
"cursor.zoomInMs",
|
|
313
|
+
`zoomInMs ${cur.zoomInMs} is over ${RAMP_SLACK}× the slowest shipped pace (calm = ${MOTION.calm.zoomInMs}) — a punch-in lands ON the action, so this departs that much earlier and creeps in`,
|
|
314
|
+
`${DEFAULT_CURSOR.zoomInMs} is the frame-measured default; use pace "calm" (${MOTION.calm.zoomInMs}) for a gentler punch`,
|
|
315
|
+
);
|
|
316
|
+
if (cur.zoomOutMs > MOTION.calm.zoomOutMs * RAMP_SLACK)
|
|
317
|
+
warn(
|
|
318
|
+
"cursor.zoomOutMs",
|
|
319
|
+
`zoomOutMs ${cur.zoomOutMs} is over ${RAMP_SLACK}× the slowest shipped pace (calm = ${MOTION.calm.zoomOutMs}) — every release drifts out for that long, and the tail must outlast it`,
|
|
320
|
+
`${DEFAULT_CURSOR.zoomOutMs} is the frame-measured default; use pace "calm" (${MOTION.calm.zoomOutMs}) for a slower release`,
|
|
321
|
+
);
|
|
322
|
+
|
|
201
323
|
// camera-rect spring: bounce shapes the ONE ease driving centre+size, so an
|
|
202
324
|
// out-of-range value corrupts every camera move (see math.ts springEase).
|
|
203
325
|
const spring = comp.cursor.zoomSpring;
|
|
@@ -240,6 +362,70 @@ export function validateComposition(
|
|
|
240
362
|
"600-1000 reads as a natural beat; 0 = legacy (depart as soon as the action ends)",
|
|
241
363
|
);
|
|
242
364
|
|
|
365
|
+
// SILENT PACE OVERRIDE: travelMinMs/travelMaxMs are applied AFTER the speed
|
|
366
|
+
// law (math.ts buildLegs), so on the legs they bind it is the clamp — not
|
|
367
|
+
// travelWidthsPerSec — that sets the duration. travelWidthsPerSec is what a
|
|
368
|
+
// `pace` preset moves and travelMin/MaxMs are NOT in the preset, so a take
|
|
369
|
+
// whose legs are mostly clamped answers a pace change with a shrug. Nothing
|
|
370
|
+
// in the JSON shows this; only the legs do.
|
|
371
|
+
if (cur.travelWidthsPerSec > 0 && issues.every((i) => i.severity !== "error")) {
|
|
372
|
+
try {
|
|
373
|
+
const travels = buildLegs(comp).filter((l) => !l.drag);
|
|
374
|
+
const pace = motionName(cur);
|
|
375
|
+
// RUSHED TRAVEL: a leg is bounded on the left by the previous beat's
|
|
376
|
+
// action end, so a beat that runs late (or a settleMs too short to hold
|
|
377
|
+
// the glide that follows it) squeezes the move into whatever is left and
|
|
378
|
+
// the cursor darts. This is the cursor's twin of the crowded-release
|
|
379
|
+
// check below, and like it the fix is in the RECORDING: nothing in the
|
|
380
|
+
// composition can widen a gap the capture never left.
|
|
381
|
+
const shortfall = (l: (typeof travels)[number]) => (l.wantSec ?? 0) - (l.t1 - l.t0);
|
|
382
|
+
const squeezed = travels
|
|
383
|
+
.filter(
|
|
384
|
+
(l) =>
|
|
385
|
+
l.wantSec != null &&
|
|
386
|
+
l.t1 - l.t0 < l.wantSec * SQUEEZE_FRAC &&
|
|
387
|
+
shortfall(l) > SQUEEZE_MIN_MS / 1000,
|
|
388
|
+
)
|
|
389
|
+
.sort((a, b) => shortfall(b) - shortfall(a));
|
|
390
|
+
const worst = squeezed[0];
|
|
391
|
+
if (worst) {
|
|
392
|
+
const got = Math.round((worst.t1 - worst.t0) * 1000);
|
|
393
|
+
const want = Math.round((worst.wantSec ?? 0) * 1000);
|
|
394
|
+
const prev = worst.evIdx != null ? events[worst.evIdx - 1] : undefined;
|
|
395
|
+
warn(
|
|
396
|
+
`events[${worst.evIdx}]`,
|
|
397
|
+
`${squeezed.length === 1 ? "this beat's" : `${squeezed.length} beats' travel is rushed; the worst`} approach gets ${got}ms of the ${want}ms the speed law asks for — the cursor darts in${prev ? ` because events[${worst.evIdx! - 1}] (${prev.kind}) is still running until ${prev.tMs + (prev.durationMs ?? 0)}ms` : " because the take starts too close to it"}`,
|
|
398
|
+
prev
|
|
399
|
+
? `raise the previous step's settleMs by ≥ ${want - got}ms and re-\`make\` — the gap is in the CAPTURE, no cursor knob can widen it`
|
|
400
|
+
: `add a leading \`wait\` (or move \`start\` closer) and re-\`make\` — the opening sweep has no room`,
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
for (const which of ["min", "max"] as const) {
|
|
404
|
+
const n = travels.filter((l) => l.clamped === which).length;
|
|
405
|
+
if (travels.length < CLAMPED_LEGS_MIN || n <= travels.length * CLAMPED_LEGS_FRAC) continue;
|
|
406
|
+
const field = which === "min" ? "travelMinMs" : "travelMaxMs";
|
|
407
|
+
// A clamp at ITS PACE'S value is not an override — it IS the pace, it
|
|
408
|
+
// was tuned with the rest of the bundle, and re-pacing moves those legs
|
|
409
|
+
// like any other. Only a clamp somebody HAND-SET away from the pace
|
|
410
|
+
// overrides it, and only then is there anything to say. (Before the
|
|
411
|
+
// clamps joined MOTION every clamped leg really was deaf to the pace,
|
|
412
|
+
// and this warning said so; saying it now would be false.)
|
|
413
|
+
const shipped = pace ? MOTION[pace] : DEFAULT_CURSOR;
|
|
414
|
+
// Same tolerance motionName uses, so the two can never disagree: a
|
|
415
|
+
// value near enough to keep the pace's NAME is near enough to be the
|
|
416
|
+
// pace, and must not be reported as overriding it.
|
|
417
|
+
if (Math.abs(cur[field] - shipped[field]) < CLAMP_TOL_MS) continue;
|
|
418
|
+
warn(
|
|
419
|
+
`cursor.${field}`,
|
|
420
|
+
`${n} of ${travels.length} travel legs are ${which === "min" ? "floored at" : "capped at"} a hand-set cursor.${field} of ${cur[field]}ms — on those the clamp sets the duration, not cursor.travelWidthsPerSec${pace ? `, so they no longer move with the "${pace}" pace (which ships ${shipped[field]}ms)` : ""}`,
|
|
421
|
+
`restore cursor.${field} to ${shipped[field]}${pace ? ` (the "${pace}" pace's own value)` : " (the shipped default)"} to put those legs back under the speed law — or keep it, if they are meant to read as ${which === "min" ? "darts" : "one steady sweep"}`,
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
} catch {
|
|
425
|
+
/* never let a diagnostics pass throw */
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
243
429
|
// tail: the composition must outlast the last action (+ a little settle)
|
|
244
430
|
if (comp.durationMs < lastEnd)
|
|
245
431
|
err(
|
|
@@ -253,6 +439,80 @@ export function validateComposition(
|
|
|
253
439
|
`only ${comp.durationMs - lastEnd}ms after the last action — the final zoom-out may be cut`,
|
|
254
440
|
`allow ≥ ${comp.cursor.zoomOutMs}ms (cursor.zoomOutMs) of tail`,
|
|
255
441
|
);
|
|
442
|
+
// …and the mirror image: a tail so long the delivered mp4 ends on a frozen
|
|
443
|
+
// screen. The classic cause is padding a plan with trailing `wait`s to hit a
|
|
444
|
+
// "~25s" target — the capture keeps rolling long after the last payoff has
|
|
445
|
+
// settled and nothing on screen changes again. Cheap to fix (durationMs is
|
|
446
|
+
// render-only), invisible to an agent that never watches the tail.
|
|
447
|
+
else if (events.length) {
|
|
448
|
+
const settledEnd = lastEnd + comp.cursor.holdMs + comp.cursor.zoomOutMs;
|
|
449
|
+
if (comp.durationMs > settledEnd + DEAD_TAIL_MS)
|
|
450
|
+
warn(
|
|
451
|
+
"durationMs",
|
|
452
|
+
`${((comp.durationMs - settledEnd) / 1000).toFixed(1)}s of tail after the last beat settles — the delivered video ends on a frozen screen`,
|
|
453
|
+
`trim durationMs to ≈ ${Math.round(settledEnd)}, or add a beat that earns the time`,
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
// CROWDED RELEASE: the camera should be PARKED at the instant an action
|
|
458
|
+
// fires. A release (a zoomed beat followed by a full-view one) needs
|
|
459
|
+
// pullOutDwellMs + zoomOutMs of room after the previous beat's payoff
|
|
460
|
+
// settles; when the gap is tighter the schedule keeps the ramp and lands it
|
|
461
|
+
// LATE — deliberately, because fleeing a frame the viewer is still reading is
|
|
462
|
+
// worse — and the frame slides out from under the next click. That trade is
|
|
463
|
+
// right given the recording, but the recording is the thing to fix, so say
|
|
464
|
+
// so. (A zoom-enabled `press` is reveal-timed by construction: it departs AT
|
|
465
|
+
// the keypress and rides the reveal in, so its late landing is the design.)
|
|
466
|
+
if (issues.every((i) => i.severity !== "error")) {
|
|
467
|
+
try {
|
|
468
|
+
const sched = cameraRampSchedule(comp);
|
|
469
|
+
const room = (comp.cursor.pullOutDwellMs ?? 0) + comp.cursor.zoomOutMs;
|
|
470
|
+
for (let i = 0; i < events.length; i++) {
|
|
471
|
+
const e = events[i]!;
|
|
472
|
+
const r = sched[i];
|
|
473
|
+
if (!r) continue;
|
|
474
|
+
const rampMs = r.landMs - r.startMs;
|
|
475
|
+
// OVER-LONG WINDOW: the ramp a beat actually gets is inAtMs → its
|
|
476
|
+
// landing, so a hand-set inAtMs — not cursor.zoomInMs — is what makes a
|
|
477
|
+
// multi-second creep. The usual cause is reading "start the zoom
|
|
478
|
+
// earlier" as "start it much earlier": the landing is pinned to the
|
|
479
|
+
// action, so the only thing that moves is how slowly it gets there.
|
|
480
|
+
// Only HAND-SET windows are flagged; the planner's own default is
|
|
481
|
+
// clamped at 0 for an early first beat and that is by design.
|
|
482
|
+
const nominal = r.pullOut ? comp.cursor.zoomOutMs : comp.cursor.zoomInMs;
|
|
483
|
+
const handSet = Math.abs(e.zoom.inAtMs - Math.max(0, e.tMs - comp.cursor.zoomInMs)) >= 1;
|
|
484
|
+
if (handSet && nominal > 0 && rampMs > nominal * RAMP_SLACK)
|
|
485
|
+
warn(
|
|
486
|
+
`events[${i}].zoom.inAtMs`,
|
|
487
|
+
`this beat's camera window runs ${Math.round(rampMs)}ms — ${(rampMs / nominal).toFixed(1)}× cursor.${r.pullOut ? "zoomOutMs" : "zoomInMs"} (${nominal}ms) — so the camera departs at ${Math.round(r.startMs)}ms and creeps to the action instead of moving at the take's pace`,
|
|
488
|
+
`set inAtMs = ${Math.max(0, e.tMs - comp.cursor.zoomInMs)} (tMs − cursor.zoomInMs) and change cursor.${r.pullOut ? "zoomOutMs" : "zoomInMs"} if the RAMP itself should be slower`,
|
|
489
|
+
);
|
|
490
|
+
if (e.kind === "press") continue;
|
|
491
|
+
const lateMs = Math.round(r.landMs - e.tMs);
|
|
492
|
+
if (lateMs <= MOVING_AT_ACTION_MS) continue;
|
|
493
|
+
if (!(rampMs > 0) || lateMs / rampMs <= MOVING_AT_ACTION_FRAC) continue;
|
|
494
|
+
const prev = events[i - 1];
|
|
495
|
+
const prevEnd = prev ? prev.tMs + (prev.durationMs ?? 0) : 0;
|
|
496
|
+
// The dwell floor can push the departure past the action entirely, and
|
|
497
|
+
// then "% of the move done" is negative — a fraction that cannot
|
|
498
|
+
// describe a camera which has not left yet. Say the stronger thing.
|
|
499
|
+
const doneFrac = 1 - lateMs / rampMs;
|
|
500
|
+
const progress =
|
|
501
|
+
doneFrac > 0
|
|
502
|
+
? `has only ${Math.round(doneFrac * 100)}% of its move done`
|
|
503
|
+
: "has not even departed";
|
|
504
|
+
warn(
|
|
505
|
+
`events[${i}].zoom`,
|
|
506
|
+
`the camera ${progress} when this beat's action fires (departs ${Math.round(r.startMs)}ms, lands ${Math.round(r.landMs)}ms, action ${e.tMs}ms) — the frame slides out from under it${prev ? `; the previous beat settles only ${Math.round(e.tMs - prevEnd)}ms earlier` : ""}`,
|
|
507
|
+
prev
|
|
508
|
+
? `hold the frame — copy events[${i - 1}].zoom onto this beat so the camera never moves at the action; or re-capture with ≥ ${room}ms of settle on events[${i - 1}] (cursor.pullOutDwellMs + cursor.zoomOutMs)`
|
|
509
|
+
: `re-capture with more lead-in before this beat, or set zoom.enabled=false`,
|
|
510
|
+
);
|
|
511
|
+
}
|
|
512
|
+
} catch {
|
|
513
|
+
/* never let a diagnostics pass throw */
|
|
514
|
+
}
|
|
515
|
+
}
|
|
256
516
|
|
|
257
517
|
// A dwell-delayed final pull-out can land LATER than the legacy tail math
|
|
258
518
|
// above assumes — check the actual schedule, not the formula. (Guarded: the
|