demoman 0.7.0 → 0.7.1

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/demoman.mjs CHANGED
@@ -41,7 +41,7 @@ This server runs them in its own browser on this machine: signed in only where t
41
41
 
42
42
  When the studio tool is listed and no links.studio is in hand, offer studio({ takeId }) after a run, a window where the user can edit and export the take; never open it unasked.
43
43
 
44
- Before opening a pull request, check status.pullRequests; the recipe says when to film and attach.
44
+ Before opening a pull request, check status.pullRequests; the recipe says when to record and attach.
45
45
 
46
46
  Every refusal carries a "reason" to branch on and a "detail" to tell the user; recipe lists them all.`;
47
47
 
@@ -205,7 +205,8 @@ var VERBS = {
205
205
  type: { cursorTravels: true, approach: "nearest" },
206
206
  moveTo: { cursorTravels: true, approach: "nearest" },
207
207
  scrollTo: { cursorTravels: false, approach: "landing" },
208
- waitFor: { cursorTravels: false, approach: "none" }
208
+ waitFor: { cursorTravels: false, approach: "none" },
209
+ drag: { cursorTravels: true, approach: "nearest" }
209
210
  };
210
211
 
211
212
  // ../../packages/compositor/dist/bundle.js
@@ -248,7 +249,14 @@ var CursorGapSchema = z.object({
248
249
  var AnchorRectSchema = z.object({
249
250
  actionId: z.string().min(1),
250
251
  anchorId: z.string().min(1),
251
- rect: RectSchema
252
+ rect: RectSchema,
253
+ /** A drag's end, measured with its start; absent for every other verb. */
254
+ end: RectSchema.optional()
255
+ });
256
+ var HeldPressSchema = z.object({
257
+ actionId: z.string().min(1),
258
+ pressMs: z.number().nonnegative(),
259
+ releaseMs: z.number().nonnegative()
252
260
  });
253
261
  var ViewportTransformSchema = z.object({
254
262
  sourceTimeMs: z.number().nonnegative(),
@@ -291,7 +299,7 @@ var MadeFromStepSchema = z.object({
291
299
  /** The typed text; null for every verb that types nothing, and for a
292
300
  * redacted field whose value was never recorded. */
293
301
  text: z.string().nullable(),
294
- cut: z.boolean()
302
+ cut: z.boolean().optional()
295
303
  });
296
304
  var DegradationSchema = z.object({
297
305
  startMs: z.number().nonnegative(),
@@ -366,7 +374,16 @@ var DegradationSchema = z.object({
366
374
  // `buildLaneModel` turns a nonzero count into a capture-lane clip and a
367
375
  // lane-label chip under this name. Named here so the two surfaces share
368
376
  // one word for one condition.
369
- "pacingUnplaced"
377
+ "pacingUnplaced",
378
+ // A drag whose press and release both arrived and that changed nothing
379
+ // on screen: no native drag began and the pixels between its ends were
380
+ // the same after as before. The page ignored it, so the step is listed
381
+ // as diverged rather than read as done (2026-10-21).
382
+ "notDragged",
383
+ // A native drag's picture could not be drawn in the page (the element
384
+ // the page named for it was gone, or copying it threw). The drag still
385
+ // ran; the film shows the card jump to its drop instead of travelling.
386
+ "dragPictureMissing"
370
387
  ]),
371
388
  note: z.string()
372
389
  });
@@ -422,6 +439,8 @@ var FrameBundleSchema = z.object({
422
439
  // written without this field, and they are all still readable.
423
440
  cursorGaps: z.array(CursorGapSchema).default([]),
424
441
  anchorRects: z.array(AnchorRectSchema),
442
+ // Optional, and absent is none: only a run with a drag writes any.
443
+ heldPresses: z.array(HeldPressSchema).optional(),
425
444
  // Optional, and absent is identity: every bundle written before
426
445
  // 2026-10-11 carries none, and identity is what they were drawn as.
427
446
  // See `ViewportTransformSchema`.
@@ -753,7 +772,7 @@ function captureDeviceOf(device) {
753
772
 
754
773
  // ../../packages/scene-schema/dist/document.js
755
774
  import { z as z3 } from "zod";
756
- var CURRENT_SCHEMA_VERSION = 10;
775
+ var CURRENT_SCHEMA_VERSION = 12;
757
776
  var Rect = z3.object({
758
777
  x: z3.number(),
759
778
  y: z3.number(),
@@ -924,17 +943,43 @@ var WaitFor = z3.object({
924
943
  kind: z3.literal("waitFor"),
925
944
  condition: z3.enum(["visible", "hidden", "loaded"]).optional()
926
945
  });
946
+ var Spot = z3.object({
947
+ x: z3.number().min(0).max(1),
948
+ y: z3.number().min(0).max(1)
949
+ });
950
+ var Drag = z3.object({
951
+ ...actionBase,
952
+ kind: z3.literal("drag"),
953
+ /** Null when the end was an offset, which names no element. */
954
+ toAnchorId: z3.string().min(1).nullable(),
955
+ toRect: Rect.optional(),
956
+ fromAt: Spot.optional(),
957
+ /** Where it pressed when the walk chose the spot itself — a native
958
+ * range's thumb, where a press at the centre would jump its value — as a
959
+ * spot in `rect`. Absent: `fromAt`, else the centre. Never written back
960
+ * into a script: a re-run reads the thumb afresh. */
961
+ pressedAt: Spot.optional(),
962
+ to: z3.union([
963
+ z3.object({ at: Spot.optional() }).strict(),
964
+ z3.object({ by: z3.object({ x: z3.number(), y: z3.number() }) }).strict()
965
+ ])
966
+ });
927
967
  var Action = z3.discriminatedUnion("kind", [
928
968
  MoveTo,
929
969
  Click,
930
970
  TypeAction,
931
971
  ScrollTo,
932
- WaitFor
972
+ WaitFor,
973
+ Drag
933
974
  ]);
934
975
  var MarkerSchema2 = z3.object({
935
976
  actionId: z3.string().min(1),
936
977
  offsetMs: z3.number()
937
978
  });
979
+ var SourcePointSchema = z3.object({
980
+ actionId: z3.string().min(1),
981
+ sourceOffsetMs: z3.number()
982
+ });
938
983
  var Point = z3.object({ x: z3.number(), y: z3.number() });
939
984
  var CameraEvent = z3.object({
940
985
  id: z3.string().min(1),
@@ -971,20 +1016,6 @@ function skipActionIds(skip) {
971
1016
  named2.push(["afterActionId", skip.afterActionId]);
972
1017
  return named2;
973
1018
  }
974
- function withoutStaleZoomsSkipped(doc) {
975
- if (doc.zoomsSkipped === void 0)
976
- return doc;
977
- const live = new Set(doc.actions.map((a) => a.id));
978
- const kept = doc.zoomsSkipped.filter((s) => skipActionIds(s).every(([, id]) => live.has(id)));
979
- const { zoomsSkipped: _dropped, ...rest2 } = doc;
980
- return kept.length > 0 ? { ...rest2, zoomsSkipped: kept } : rest2;
981
- }
982
- var Replacement = z3.object({
983
- id: z3.string().min(1),
984
- targetAnchorId: z3.string().min(1).nullable(),
985
- find: z3.string().nullable(),
986
- replace: z3.string()
987
- });
988
1019
  var Mask = z3.object({
989
1020
  id: z3.string().min(1),
990
1021
  rect: Rect,
@@ -1004,12 +1035,6 @@ var Gap = z3.object({
1004
1035
  afterActionId: z3.string().min(1),
1005
1036
  durationMs: z3.number().nonnegative()
1006
1037
  });
1007
- var Cut = z3.object({
1008
- id: z3.string().min(1),
1009
- actionId: z3.string().min(1),
1010
- /** The author chose to keep a jump rather than have export rebuild it. */
1011
- keepJump: z3.literal(true).optional()
1012
- });
1013
1038
  var NetworkEntry = z3.object({
1014
1039
  id: z3.string().min(1),
1015
1040
  method: z3.enum(["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]),
@@ -1220,11 +1245,21 @@ var SceneDocumentSchema = z3.object({
1220
1245
  /** See `ZoomSkipped`. */
1221
1246
  zoomsSkipped: z3.array(ZoomSkipped).optional(),
1222
1247
  edits: z3.object({
1223
- replacements: z3.array(Replacement),
1224
1248
  masks: z3.array(Mask),
1225
1249
  holds: z3.array(Hold),
1226
1250
  gaps: z3.array(Gap).default([]),
1227
- cuts: z3.array(Cut).default([]),
1251
+ /** Where the author split the clip. A split alone removes nothing. */
1252
+ splits: z3.array(z3.object({ id: z3.string().min(1), at: SourcePointSchema })).default([]),
1253
+ /**
1254
+ * Stretches of the frames the author removed. A null side is that end
1255
+ * of the take. Its edits stay in the document; what it removes is
1256
+ * resolved against the frames by the compositor.
1257
+ */
1258
+ removed: z3.array(z3.object({
1259
+ id: z3.string().min(1),
1260
+ start: SourcePointSchema.nullable(),
1261
+ end: SourcePointSchema.nullable()
1262
+ })).default([]),
1228
1263
  /**
1229
1264
  * A cut on the OUTPUT axis, never on the action log: a step outside
1230
1265
  * the trim still exists and a Rebuild still performs it (that is what
@@ -1275,19 +1310,10 @@ var SceneDocumentSchema = z3.object({
1275
1310
  unique(doc.edits.holds, "hold", ["edits", "holds"]);
1276
1311
  unique(doc.edits.gaps, "gap", ["edits", "gaps"]);
1277
1312
  unique(doc.edits.gaps.map((g) => ({ id: g.afterActionId })), "gap for an action", ["edits", "gaps"]);
1278
- unique(doc.edits.cuts, "cut", ["edits", "cuts"]);
1279
- unique(doc.edits.cuts.map((c) => ({ id: c.actionId })), "cut for an action", ["edits", "cuts"]);
1313
+ unique(doc.edits.splits, "split", ["edits", "splits"]);
1314
+ unique(doc.edits.removed, "removed piece", ["edits", "removed"]);
1280
1315
  const anchorIds = new Set(doc.anchors.map((a) => a.id));
1281
1316
  const actionIds = new Set(doc.actions.map((a) => a.id));
1282
- doc.edits.cuts.forEach((c, i) => {
1283
- if (!actionIds.has(c.actionId)) {
1284
- ctx.addIssue({
1285
- code: "custom",
1286
- message: `unknown action "${c.actionId}"`,
1287
- path: ["edits", "cuts", i, "actionId"]
1288
- });
1289
- }
1290
- });
1291
1317
  doc.actions.forEach((a, i) => {
1292
1318
  if (a.anchorId !== null && !anchorIds.has(a.anchorId)) {
1293
1319
  ctx.addIssue({
@@ -1377,24 +1403,36 @@ var SceneDocumentSchema = z3.object({
1377
1403
  });
1378
1404
  }
1379
1405
  }
1380
- doc.edits.replacements.forEach((r, i) => {
1381
- if (r.targetAnchorId !== null && !anchorIds.has(r.targetAnchorId)) {
1406
+ doc.edits.holds.forEach((h, i) => {
1407
+ if (!actionIds.has(h.marker.actionId)) {
1382
1408
  ctx.addIssue({
1383
1409
  code: "custom",
1384
- message: `unknown anchor "${r.targetAnchorId}"`,
1385
- path: ["edits", "replacements", i, "targetAnchorId"]
1410
+ message: `unknown action "${h.marker.actionId}"`,
1411
+ path: ["edits", "holds", i, "marker", "actionId"]
1386
1412
  });
1387
1413
  }
1388
1414
  });
1389
- doc.edits.holds.forEach((h, i) => {
1390
- if (!actionIds.has(h.marker.actionId)) {
1415
+ (doc.edits.splits ?? []).forEach((split, i) => {
1416
+ if (!actionIds.has(split.at.actionId)) {
1391
1417
  ctx.addIssue({
1392
1418
  code: "custom",
1393
- message: `unknown action "${h.marker.actionId}"`,
1394
- path: ["edits", "holds", i, "marker", "actionId"]
1419
+ message: `unknown action "${split.at.actionId}"`,
1420
+ path: ["edits", "splits", i, "at", "actionId"]
1395
1421
  });
1396
1422
  }
1397
1423
  });
1424
+ (doc.edits.removed ?? []).forEach((range, i) => {
1425
+ for (const side of ["start", "end"]) {
1426
+ const point2 = range[side];
1427
+ if (point2 !== null && !actionIds.has(point2.actionId)) {
1428
+ ctx.addIssue({
1429
+ code: "custom",
1430
+ message: `unknown action "${point2.actionId}"`,
1431
+ path: ["edits", "removed", i, side, "actionId"]
1432
+ });
1433
+ }
1434
+ }
1435
+ });
1398
1436
  doc.edits.gaps.forEach((g, i) => {
1399
1437
  if (!actionIds.has(g.afterActionId)) {
1400
1438
  ctx.addIssue({
@@ -1406,6 +1444,26 @@ var SceneDocumentSchema = z3.object({
1406
1444
  });
1407
1445
  });
1408
1446
 
1447
+ // ../../packages/scene-schema/dist/drag.js
1448
+ function spotIn(rect2, at2) {
1449
+ if (at2 === void 0) {
1450
+ return { x: rect2.x + rect2.width / 2, y: rect2.y + rect2.height / 2 };
1451
+ }
1452
+ return { x: rect2.x + at2.x * rect2.width, y: rect2.y + at2.y * rect2.height };
1453
+ }
1454
+ function dragEndPoint(start, to, toRect) {
1455
+ if ("by" in to)
1456
+ return { x: start.x + to.by.x, y: start.y + to.by.y };
1457
+ return toRect == null ? null : spotIn(toRect, to.at);
1458
+ }
1459
+ function dragPoints(action, rect2, toRect) {
1460
+ if (rect2 === void 0)
1461
+ return null;
1462
+ const start = spotIn(rect2, action.pressedAt ?? action.fromAt);
1463
+ const end = dragEndPoint(start, action.to, toRect);
1464
+ return end === null ? null : { start, end };
1465
+ }
1466
+
1409
1467
  // ../../packages/scene-schema/dist/migrations.js
1410
1468
  var SchemaVersionError = class extends Error {
1411
1469
  /** True when the document is from a newer schema than this build reads —
@@ -1573,8 +1631,61 @@ var steps = {
1573
1631
  // filmed as a phone. Nothing in a v9 document changes. The bump exists so
1574
1632
  // a build from before refuses a v10 phone take rather than rebuilding it
1575
1633
  // on the desktop (spec 2026-10-10 §4).
1576
- 9: (doc) => ({ ...doc, schemaVersion: 10 })
1634
+ 9: (doc) => ({ ...doc, schemaVersion: 10 }),
1635
+ // v11 adds the `drag` action kind; no v10 document has one.
1636
+ 10: (doc) => ({ ...doc, schemaVersion: 11 }),
1637
+ // v11 -> v12 (2026-10-22, spec split-tool): step cuts become removed
1638
+ // pieces, and text overlays leave the editor. See `cutsToRemoved`.
1639
+ 11: (doc, notes) => {
1640
+ const edits = doc.edits;
1641
+ if (edits === null || typeof edits !== "object") {
1642
+ return { ...doc, schemaVersion: 12 };
1643
+ }
1644
+ const e = edits;
1645
+ const replacements = Array.isArray(e.replacements) ? e.replacements : [];
1646
+ const blocked = new Set((Array.isArray(doc.actions) ? doc.actions : []).flatMap((a) => a !== null && typeof a === "object" && a.kind === "type" && a.redacted === true ? [a.anchorId] : []));
1647
+ const values = replacements.filter((r) => r !== null && typeof r === "object" && blocked.has(r.targetAnchorId)).length;
1648
+ const overlays = replacements.length - values;
1649
+ if (overlays > 0) {
1650
+ notes.push(`${overlays} text ${overlays === 1 ? "overlay was" : "overlays were"} removed from this take: the video shows the text that was recorded.`);
1651
+ }
1652
+ if (values > 0) {
1653
+ notes.push(`${values} typed ${values === 1 ? "value for a blocked field was" : "values for blocked fields were"} removed from this take: rebuilding the take stops at ${values === 1 ? "that step. Put the value" : "those steps. Put the values"} in the script and record it again.`);
1654
+ }
1655
+ const { replacements: _r, cuts, ...rest2 } = e;
1656
+ return {
1657
+ ...doc,
1658
+ edits: { ...rest2, removed: cutsToRemoved(doc.actions, cuts) },
1659
+ schemaVersion: 12
1660
+ };
1661
+ }
1577
1662
  };
1663
+ function cutsToRemoved(actions, cuts) {
1664
+ if (!Array.isArray(actions) || !Array.isArray(cuts))
1665
+ return [];
1666
+ const cut = new Set(cuts.flatMap((c) => c !== null && typeof c === "object" && "actionId" in c ? [c.actionId] : []));
1667
+ const ids = actions.map((a) => a?.id);
1668
+ const removed = [];
1669
+ let i = 0;
1670
+ while (i < ids.length) {
1671
+ if (!cut.has(ids[i])) {
1672
+ i += 1;
1673
+ continue;
1674
+ }
1675
+ const start = ids[i];
1676
+ let j = i;
1677
+ while (j < ids.length && cut.has(ids[j]))
1678
+ j += 1;
1679
+ const end = ids[j];
1680
+ removed.push({
1681
+ id: `removed-${String(start)}`,
1682
+ start: { actionId: start, sourceOffsetMs: 0 },
1683
+ end: end === void 0 ? null : { actionId: end, sourceOffsetMs: 0 }
1684
+ });
1685
+ i = j;
1686
+ }
1687
+ return removed;
1688
+ }
1578
1689
  function migrateHoldsToGaps(doc) {
1579
1690
  const holds = doc.edits.holds ?? [];
1580
1691
  const actions = doc.actions ?? [];
@@ -1601,7 +1712,7 @@ function migrateHoldsToGaps(doc) {
1601
1712
  }
1602
1713
  return { ...doc, edits: { ...doc.edits, holds: kept, gaps } };
1603
1714
  }
1604
- function migrateToCurrent(raw) {
1715
+ function migrateToCurrent(raw, notes = []) {
1605
1716
  if (typeof raw !== "object" || raw === null || typeof raw.schemaVersion !== "number") {
1606
1717
  throw new SchemaVersionError("document has no numeric schemaVersion");
1607
1718
  }
@@ -1614,12 +1725,31 @@ function migrateToCurrent(raw) {
1614
1725
  const step = steps[version];
1615
1726
  if (!step)
1616
1727
  throw new SchemaVersionError(`no migration path from schemaVersion ${version}`);
1617
- doc = step(doc);
1728
+ doc = step(doc, notes);
1618
1729
  version = doc.schemaVersion;
1619
1730
  }
1620
1731
  return migrateHoldsToGaps(SceneDocumentSchema.parse(doc));
1621
1732
  }
1622
1733
 
1734
+ // ../../packages/scene-schema/dist/removed.js
1735
+ function stepsInsideRemoved(doc) {
1736
+ const index = new Map(doc.actions.map((a, i) => [a.id, i]));
1737
+ const inside = /* @__PURE__ */ new Set();
1738
+ for (const range of doc.edits.removed ?? []) {
1739
+ const s = range.start === null ? null : index.get(range.start.actionId);
1740
+ const e = range.end === null ? null : index.get(range.end.actionId);
1741
+ if (s === void 0 || e === void 0)
1742
+ continue;
1743
+ doc.actions.forEach((action, i) => {
1744
+ const afterStart = range.start === null || s === null || s < i || i === s && range.start.sourceOffsetMs <= 0;
1745
+ const beforeEnd = range.end === null || e === null || i < e || i === e && range.end.sourceOffsetMs > 0;
1746
+ if (afterStart && beforeEnd)
1747
+ inside.add(action.id);
1748
+ });
1749
+ }
1750
+ return inside;
1751
+ }
1752
+
1623
1753
  // ../../packages/scene-schema/dist/script.js
1624
1754
  import { z as z4 } from "zod";
1625
1755
  var SCRIPT_VERSION = 1;
@@ -1627,6 +1757,7 @@ var SCRIPT_VERSION_KIT = 2;
1627
1757
  var SCRIPT_VERSION_MOTION = 3;
1628
1758
  var SCRIPT_VERSION_DEVICE = 4;
1629
1759
  var SCRIPT_VERSION_ACCOUNT = 5;
1760
+ var SCRIPT_VERSION_DRAG = 6;
1630
1761
  var ACCOUNT_NAME = /^[a-z0-9][a-z0-9_-]{0,63}$/;
1631
1762
  var ACCOUNT_NAME_RULE = 'lower-case letters, digits, "-" and "_", starting with a letter or digit, at most 64 characters';
1632
1763
  var ScriptTargetSchema = z4.union([
@@ -1648,6 +1779,14 @@ function targetStrategy(target) {
1648
1779
  throw new Error(`unknown script target ${JSON.stringify(unknown)}`);
1649
1780
  }
1650
1781
  var RecordedSchema = z4.string().min(1).optional();
1782
+ var DragSpotSchema = z4.object({ x: z4.number().min(0).max(1), y: z4.number().min(0).max(1) }).strict();
1783
+ var DragFromSchema = z4.object({ on: ScriptTargetSchema, at: DragSpotSchema.optional() }).strict();
1784
+ var DragToSchema = z4.union([
1785
+ DragFromSchema,
1786
+ z4.object({
1787
+ by: z4.object({ x: z4.number().finite(), y: z4.number().finite() }).strict()
1788
+ }).strict()
1789
+ ]);
1651
1790
  var ScriptStepSchema = z4.discriminatedUnion("do", [
1652
1791
  z4.object({
1653
1792
  do: z4.literal("click"),
@@ -1698,6 +1837,12 @@ var ScriptStepSchema = z4.discriminatedUnion("do", [
1698
1837
  until: z4.enum(["visible", "hidden"]),
1699
1838
  recorded: RecordedSchema
1700
1839
  }).strict(),
1840
+ z4.object({
1841
+ do: z4.literal("drag"),
1842
+ from: DragFromSchema,
1843
+ to: DragToSchema,
1844
+ recorded: RecordedSchema
1845
+ }).strict(),
1701
1846
  z4.object({ do: z4.literal("waitForLoad"), recorded: RecordedSchema }).strict(),
1702
1847
  z4.object({ do: z4.literal("pause"), ms: z4.number().positive() }).strict()
1703
1848
  ]);
@@ -1707,6 +1852,7 @@ var ACTS_ON_THE_PAGE = {
1707
1852
  hover: true,
1708
1853
  scrollTo: true,
1709
1854
  waitFor: true,
1855
+ drag: true,
1710
1856
  waitForLoad: true,
1711
1857
  pause: false
1712
1858
  };
@@ -1719,7 +1865,8 @@ var DemoScriptShape = z4.object({
1719
1865
  SCRIPT_VERSION_KIT,
1720
1866
  SCRIPT_VERSION_MOTION,
1721
1867
  SCRIPT_VERSION_DEVICE,
1722
- SCRIPT_VERSION_ACCOUNT
1868
+ SCRIPT_VERSION_ACCOUNT,
1869
+ SCRIPT_VERSION_DRAG
1723
1870
  ]),
1724
1871
  name: z4.string().min(1),
1725
1872
  target: z4.url(),
@@ -1795,17 +1942,36 @@ var DemoScriptSchema = DemoScriptShape.superRefine((script, ctx) => {
1795
1942
  if (script.device !== void 0 && script.scriptVersion < SCRIPT_VERSION_DEVICE) {
1796
1943
  ctx.addIssue({
1797
1944
  code: "custom",
1798
- message: `a script that names device declares scriptVersion ${SCRIPT_VERSION_DEVICE}: a build from before devices would drop it and film the desktop`,
1945
+ message: `a script that names device declares scriptVersion ${SCRIPT_VERSION_DEVICE}: a build from before devices would drop it and record the desktop`,
1799
1946
  path: ["scriptVersion"]
1800
1947
  });
1801
1948
  }
1802
1949
  if (script.account !== void 0 && script.scriptVersion < SCRIPT_VERSION_ACCOUNT) {
1803
1950
  ctx.addIssue({
1804
1951
  code: "custom",
1805
- message: `a script that names account declares scriptVersion ${SCRIPT_VERSION_ACCOUNT}: a build from before accounts would drop it and film as whoever is signed in`,
1952
+ message: `a script that names account declares scriptVersion ${SCRIPT_VERSION_ACCOUNT}: a build from before accounts would drop it and record as whoever is signed in`,
1806
1953
  path: ["scriptVersion"]
1807
1954
  });
1808
1955
  }
1956
+ script.steps.forEach((step, index) => {
1957
+ if (step.do !== "drag")
1958
+ return;
1959
+ if (script.scriptVersion < SCRIPT_VERSION_DRAG) {
1960
+ ctx.addIssue({
1961
+ code: "custom",
1962
+ message: `a script that uses drag declares scriptVersion ${SCRIPT_VERSION_DRAG}: a build from before drag would refuse the step`,
1963
+ path: ["scriptVersion"]
1964
+ });
1965
+ }
1966
+ const nowhere = "by" in step.to ? step.to.by.x === 0 && step.to.by.y === 0 : JSON.stringify(step.to.on) === JSON.stringify(step.from.on) && (step.to.at?.x ?? 0.5) === (step.from.at?.x ?? 0.5) && (step.to.at?.y ?? 0.5) === (step.from.at?.y ?? 0.5);
1967
+ if (nowhere) {
1968
+ ctx.addIssue({
1969
+ code: "custom",
1970
+ message: `step ${index + 1} is a drag that starts and ends at the same point: give \`to\` another target, spot or offset, or make it a click`,
1971
+ path: ["steps", index, "to"]
1972
+ });
1973
+ }
1974
+ });
1809
1975
  script.steps.forEach((step, index) => {
1810
1976
  if (step.do !== "type" || !/\{secret:/.test(step.text))
1811
1977
  return;
@@ -1893,7 +2059,8 @@ function sawOf(anchor2) {
1893
2059
  };
1894
2060
  }
1895
2061
  function targetSentence(n, field, failure3, anchor2) {
1896
- const fix = `Add "${field}" as {stableId}, {role, name} or {text} \u2014 "saw" lists what the recording saw, or take the name from an accessibility snapshot of the page.`;
2062
+ const shape = field === "from" ? `{ "on": \u2026 } with {stableId}, {role, name} or {text}` : "{stableId}, {role, name} or {text}";
2063
+ const fix = `Add "${field}" as ${shape} \u2014 "saw" lists what the recording saw, or take the name from an accessibility snapshot of the page.`;
1897
2064
  switch (failure3.reason) {
1898
2065
  case "ambiguousAtCapture":
1899
2066
  return `Step ${n}'s element matched ${anchor2.resolution.candidates} elements when it was recorded, so no name the recording saw picks it out. ${fix}`;
@@ -1924,7 +2091,7 @@ function scriptFromTake(doc) {
1924
2091
  const holes = [];
1925
2092
  const notes = [];
1926
2093
  const steps3 = [];
1927
- const cut = new Set(doc.edits.cuts.map((c) => c.actionId));
2094
+ const cut = stepsInsideRemoved(doc);
1928
2095
  const head = indexOfAction(doc, doc.edits.trim?.head?.actionId);
1929
2096
  const tail = indexOfAction(doc, doc.edits.trim?.tail?.actionId);
1930
2097
  doc.actions.forEach((action, i) => {
@@ -1959,7 +2126,7 @@ function scriptFromTake(doc) {
1959
2126
  if (found === void 0) {
1960
2127
  throw new Error(`scriptFromTake: action "${action.id}" names anchor "${action.anchorId}", which this take does not have`);
1961
2128
  }
1962
- const field = action.kind === "type" ? "into" : "on";
2129
+ const field = action.kind === "type" ? "into" : action.kind === "drag" ? "from" : "on";
1963
2130
  const answer = targetOf(found);
1964
2131
  const on = answer.ok ? { on: answer.target } : {};
1965
2132
  const into = answer.ok ? { into: answer.target } : {};
@@ -2049,6 +2216,39 @@ function scriptFromTake(doc) {
2049
2216
  until: action.condition === "hidden" ? "hidden" : "visible"
2050
2217
  });
2051
2218
  return;
2219
+ case "drag": {
2220
+ const at2 = action.fromAt === void 0 ? {} : { at: action.fromAt };
2221
+ const step = {
2222
+ do: "drag",
2223
+ ...answer.ok ? { from: { on: answer.target, ...at2 } } : {},
2224
+ recorded: action.id
2225
+ };
2226
+ if ("by" in action.to) {
2227
+ step.to = { by: action.to.by };
2228
+ } else {
2229
+ const end = action.toAnchorId === null ? void 0 : anchors.get(action.toAnchorId);
2230
+ const toAnswer = end === void 0 ? null : targetOf(end);
2231
+ if (toAnswer?.ok === true) {
2232
+ step.to = {
2233
+ on: toAnswer.target,
2234
+ ...action.to.at === void 0 ? {} : { at: action.to.at }
2235
+ };
2236
+ } else {
2237
+ hole({
2238
+ field: "to",
2239
+ reason: toAnswer === null ? "unnameable" : toAnswer.reason,
2240
+ sentence: `Step ${n} was a drag whose drop target cannot be named from the recording. Add "to" with a target, or an offset as { "by": { "x": \u2026, "y": \u2026 } }.`,
2241
+ ...end === void 0 ? {} : { saw: sawOf(end) }
2242
+ });
2243
+ }
2244
+ }
2245
+ steps3.push(step);
2246
+ return;
2247
+ }
2248
+ default: {
2249
+ const unknown = action;
2250
+ throw new Error(`scriptFromTake: no step for ${JSON.stringify(unknown)}`);
2251
+ }
2052
2252
  }
2053
2253
  });
2054
2254
  const origin = doc.meta.capture.originUrl;
@@ -2080,7 +2280,7 @@ function scriptFromTake(doc) {
2080
2280
  // the same version (`cursorPolishNamed`), motion block or not.
2081
2281
  // A phone take declares the device version, which is past motion's,
2082
2282
  // so it may carry the take's motion too.
2083
- scriptVersion: doc.meta.capture.device !== void 0 ? SCRIPT_VERSION_DEVICE : doc.motion === void 0 && !cursorPolishNamed(doc.cursor) ? SCRIPT_VERSION : SCRIPT_VERSION_MOTION,
2283
+ scriptVersion: doc.actions.some((a) => a.kind === "drag") ? SCRIPT_VERSION_DRAG : doc.meta.capture.device !== void 0 ? SCRIPT_VERSION_DEVICE : doc.motion === void 0 && !cursorPolishNamed(doc.cursor) ? SCRIPT_VERSION : SCRIPT_VERSION_MOTION,
2084
2284
  name,
2085
2285
  ...scrubbed ? {} : { target: origin },
2086
2286
  ...doc.meta.capture.device === void 0 ? { viewport: doc.meta.capture.viewport } : { device: doc.meta.capture.device.preset },
@@ -2126,55 +2326,48 @@ function cutRanges(plan, bundle, sourceDurationMs) {
2126
2326
  const markerAt = new Map(bundle.markers.map((m) => [m.actionId, m.sourceTimeMs]));
2127
2327
  const resolved = [];
2128
2328
  const unplacedCuts = [];
2129
- for (const run2 of plan.cuts ?? []) {
2130
- const { ids, actionIds } = run2;
2131
- const first = actionIds[0];
2132
- const unplaced = (reason) => {
2133
- unplacedCuts.push({ ids, actionIds, reason });
2329
+ for (const piece of plan.removed ?? []) {
2330
+ const ids = [piece.id];
2331
+ const sourceOf = (point2, ifNull) => {
2332
+ if (point2 === null)
2333
+ return ifNull;
2334
+ const marker = markerAt.get(point2.actionId);
2335
+ if (marker === void 0) {
2336
+ return `these frames carry no marker for "${point2.actionId}", so where this piece ${ifNull === 0 ? "starts" : "ends"} is unknown and no frames were removed`;
2337
+ }
2338
+ return clamp(marker + point2.sourceOffsetMs, 0, sourceDurationMs);
2134
2339
  };
2135
- if (first === void 0) {
2136
- unplaced("this cut names no step");
2137
- continue;
2138
- }
2139
- const srcStartMs = markerAt.get(first);
2140
- if (srcStartMs === void 0) {
2141
- unplaced(`these frames carry no marker for "${first}", so they never contained that step and no frames were removed`);
2340
+ const start = sourceOf(piece.start, 0);
2341
+ const end = sourceOf(piece.end, sourceDurationMs);
2342
+ if (typeof start === "string" || typeof end === "string") {
2343
+ unplacedCuts.push({
2344
+ ids,
2345
+ reason: typeof start === "string" ? start : end
2346
+ });
2142
2347
  continue;
2143
2348
  }
2144
- let srcEndMs;
2145
- if (run2.untilActionId === null) {
2146
- srcEndMs = sourceDurationMs;
2147
- } else {
2148
- const end = markerAt.get(run2.untilActionId);
2149
- if (end === void 0) {
2150
- unplaced(`these frames carry no marker for "${run2.untilActionId}", the step this cut runs up to, so where the cut ends is unknown and no frames were removed`);
2151
- continue;
2152
- }
2153
- srcEndMs = end;
2154
- }
2155
- if (srcEndMs <= srcStartMs) {
2156
- unplaced(`this cut's two markers land at the same instant (${Math.round(srcStartMs)}ms) or out of order, so it covers no frames`);
2349
+ if (end <= start) {
2350
+ unplacedCuts.push({
2351
+ ids,
2352
+ reason: `this piece's two ends land at the same instant (${Math.round(start)}ms) or out of order, so it covers no frames`
2353
+ });
2157
2354
  continue;
2158
2355
  }
2159
2356
  resolved.push({
2160
2357
  ids,
2161
- actionIds,
2162
- srcStartMs,
2163
- srcEndMs,
2164
- keepJump: run2.keepJump,
2165
- trailing: run2.untilActionId === null
2358
+ srcStartMs: start,
2359
+ srcEndMs: end,
2360
+ trailing: end >= sourceDurationMs
2166
2361
  });
2167
2362
  }
2168
2363
  resolved.sort((a, b) => a.srcStartMs - b.srcStartMs);
2169
2364
  const cuts = [];
2170
2365
  for (const cut of resolved) {
2171
2366
  const previous = cuts[cuts.length - 1];
2172
- if (previous && cut.srcStartMs < previous.srcEndMs) {
2173
- unplacedCuts.push({
2174
- ids: cut.ids,
2175
- actionIds: cut.actionIds,
2176
- reason: `this cut's frames overlap the cut before it (${Math.round(previous.srcStartMs)}\u2013${Math.round(previous.srcEndMs)}ms), which means these frames run the take's steps out of order \u2014 nothing was removed for it`
2177
- });
2367
+ if (previous && cut.srcStartMs <= previous.srcEndMs) {
2368
+ previous.ids.push(...cut.ids);
2369
+ previous.srcEndMs = Math.max(previous.srcEndMs, cut.srcEndMs);
2370
+ previous.trailing ||= cut.trailing;
2178
2371
  continue;
2179
2372
  }
2180
2373
  cuts.push(cut);
@@ -2373,10 +2566,8 @@ function buildTimeline(plan, bundle, hints = []) {
2373
2566
  ...cuts,
2374
2567
  ...interruptions.map((span) => ({
2375
2568
  ids: [],
2376
- actionIds: [],
2377
2569
  srcStartMs: span.startMs,
2378
2570
  srcEndMs: span.endMs,
2379
- keepJump: false,
2380
2571
  trailing: false
2381
2572
  }))
2382
2573
  ].sort((a, b) => a.srcStartMs - b.srcStartMs);
@@ -2533,7 +2724,7 @@ function motionTimings(smoothness) {
2533
2724
  stiffness: lerp(8, 5.5, smoothness),
2534
2725
  zoomInMs: lerp(1e3, 1600, smoothness),
2535
2726
  zoomOutMs: lerp(700, 1150, smoothness),
2536
- followPanMs: lerp(500, 900, smoothness)
2727
+ followRatePerS: lerp(13, 7, smoothness)
2537
2728
  };
2538
2729
  }
2539
2730
  var DEFAULT_TIMINGS = motionTimings(MOTION_DEFAULTS.smoothness);
@@ -2625,6 +2816,25 @@ var CAMERA_DEFAULTS = {
2625
2816
  };
2626
2817
  function planCameraIntents(scene, cutSteps, attached) {
2627
2818
  const order = new Map(scene.actions.map((a, i) => [a.id, i]));
2819
+ const actionOf = new Map(scene.actions.map((a) => [a.id, a]));
2820
+ const fitOf = (event) => {
2821
+ const action = actionOf.get(event.marker.actionId);
2822
+ if (event.point === void 0 || action?.kind !== "drag")
2823
+ return {};
2824
+ const ends = dragPoints(action, action.rect, action.toRect);
2825
+ if (ends === null)
2826
+ return {};
2827
+ const x = Math.min(ends.start.x, ends.end.x);
2828
+ const y = Math.min(ends.start.y, ends.end.y);
2829
+ return {
2830
+ fit: {
2831
+ x,
2832
+ y,
2833
+ width: Math.max(ends.start.x, ends.end.x) - x,
2834
+ height: Math.max(ends.start.y, ends.end.y) - y
2835
+ }
2836
+ };
2837
+ };
2628
2838
  return scene.camera.flatMap((event) => {
2629
2839
  if (cutSteps.has(event.marker.actionId)) {
2630
2840
  attached.push({
@@ -2643,16 +2853,18 @@ function planCameraIntents(scene, cutSteps, attached) {
2643
2853
  actionId: event.marker.actionId,
2644
2854
  offsetMs: event.marker.offsetMs,
2645
2855
  scale: clamp(event.scale ?? 1, 1, CAMERA_DEFAULTS.maxScale),
2646
- end: event.end ?? null
2856
+ end: event.end ?? null,
2857
+ ...fitOf(event)
2647
2858
  })).filter((intent) => intent.scale > 1).sort((a, b) => {
2648
2859
  const byAction = (order.get(a.actionId) ?? 0) - (order.get(b.actionId) ?? 0);
2649
2860
  return byAction !== 0 ? byAction : a.offsetMs - b.offsetMs;
2650
2861
  });
2651
2862
  }
2652
- function solveCamera(intents, rectOf, timeline, markerSourceMs, viewport, fitWindow = null, motion = MOTION_DEFAULTS, actEnds = /* @__PURE__ */ new Map()) {
2863
+ function solveCamera(intents, rectOf, timeline, markerSourceMs, viewport, fitWindow = null, motion = MOTION_DEFAULTS, actEnds = /* @__PURE__ */ new Map(), holds = []) {
2653
2864
  const timings = motionTimings(motion.smoothness);
2654
2865
  const neutral = { x: viewport.width / 2, y: viewport.height / 2 };
2655
2866
  const seeds = [];
2867
+ const actEndOf2 = /* @__PURE__ */ new Map();
2656
2868
  for (const intent of intents) {
2657
2869
  const rect2 = intent.point ? { x: intent.point.x, y: intent.point.y, width: 0, height: 0 } : intent.anchorId ? rectOf(intent.anchorId, intent.actionId) : null;
2658
2870
  if (!rect2)
@@ -2665,21 +2877,21 @@ function solveCamera(intents, rectOf, timeline, markerSourceMs, viewport, fitWin
2665
2877
  const resolvedEndMs = intent.end ? markerOutputMs(intent.end, timeline, markerSourceMs) : null;
2666
2878
  const asked = clamp(intent.scale, 1, CAMERA_DEFAULTS.maxScale);
2667
2879
  const requested = Math.max(asked, clamp(intent.requestedScale ?? intent.scale, 1, CAMERA_DEFAULTS.maxScale));
2668
- const scale = fitWindow === null ? asked : clamp(fitScaleFor(rect2, fitWindow), 1, asked);
2669
- let notBeforeMs = Number.NEGATIVE_INFINITY;
2880
+ const scale = fitWindow === null ? asked : clamp(fitScaleFor(intent.fit ?? rect2, fitWindow), 1, asked);
2881
+ let actEndMs = Number.NEGATIVE_INFINITY;
2670
2882
  for (const [actionId, endMs] of actEnds) {
2671
2883
  const at2 = markerSourceMs.get(actionId);
2672
2884
  if (at2 === void 0 || at2 >= sourceMs)
2673
2885
  continue;
2674
- notBeforeMs = Math.max(notBeforeMs, toOutputMs(timeline, endMs) + CAMERA_DEFAULTS.actSettleMs);
2886
+ actEndMs = Math.max(actEndMs, toOutputMs(timeline, endMs));
2675
2887
  }
2676
- const transitionMs = outputMs - timings.zoomInMs < notBeforeMs ? Math.max(MIN_PAN_MS, Math.min(timings.zoomInMs, outputMs - notBeforeMs)) : timings.zoomInMs;
2677
- seeds.push({
2888
+ const seed = {
2678
2889
  id: intent.id,
2679
2890
  outputTimeMs: outputMs,
2680
2891
  center: rectCenter(rect2),
2681
2892
  scale,
2682
- transitionMs,
2893
+ // Shortened below for an earlier act, once every seed is known.
2894
+ transitionMs: timings.zoomInMs,
2683
2895
  stiffness: timings.stiffness,
2684
2896
  zoom: true,
2685
2897
  authoredEndMs: resolvedEndMs,
@@ -2691,7 +2903,18 @@ function solveCamera(intents, rectOf, timeline, markerSourceMs, viewport, fitWin
2691
2903
  } : null,
2692
2904
  actionMs,
2693
2905
  plannedTransitionMs: timings.zoomInMs
2694
- });
2906
+ };
2907
+ seeds.push(seed);
2908
+ actEndOf2.set(seed, actEndMs);
2909
+ }
2910
+ seeds.sort((a, b) => a.outputTimeMs - b.outputTimeMs);
2911
+ for (const [i, seed] of seeds.entries()) {
2912
+ const before = seeds[i - 1];
2913
+ const pans = before !== void 0 && !returnsBetween(heldUntilOf(before, seed.actionMs, holds), seed.outputTimeMs, timings);
2914
+ const notBeforeMs = (actEndOf2.get(seed) ?? Number.NEGATIVE_INFINITY) + (pans ? 0 : CAMERA_DEFAULTS.actSettleMs);
2915
+ if (seed.outputTimeMs - timings.zoomInMs < notBeforeMs) {
2916
+ seed.transitionMs = Math.max(MIN_PAN_MS, Math.min(timings.zoomInMs, seed.outputTimeMs - notBeforeMs));
2917
+ }
2695
2918
  }
2696
2919
  return insertNeutralKeys([
2697
2920
  {
@@ -2711,7 +2934,7 @@ function solveCamera(intents, rectOf, timeline, markerSourceMs, viewport, fitWin
2711
2934
  plannedTransitionMs: 0
2712
2935
  },
2713
2936
  ...seeds
2714
- ].sort((a, b) => a.outputTimeMs - b.outputTimeMs), timeline.outputDurationMs, timings);
2937
+ ].sort((a, b) => a.outputTimeMs - b.outputTimeMs), timeline.outputDurationMs, timings, holds);
2715
2938
  }
2716
2939
  function fitScaleFor(rect2, window) {
2717
2940
  const margin = 2 * CAMERA_DEFAULTS.fitMarginPx;
@@ -2719,7 +2942,15 @@ function fitScaleFor(rect2, window) {
2719
2942
  return Math.floor(fit * 100) / 100;
2720
2943
  }
2721
2944
  var MIN_PAN_MS = 150;
2722
- function insertNeutralKeys(seeds, outputDurationMs, timings) {
2945
+ function heldUntilOf(seed, nextActionMs, holds) {
2946
+ const outBy = Math.min(seed.outputTimeMs + CAMERA_DEFAULTS.neutral.zoomHoldMs, nextActionMs);
2947
+ return Math.max(seed.outputTimeMs, ...holds.filter((h) => h.startMs >= seed.actionMs && h.startMs < outBy).map((h) => h.endMs));
2948
+ }
2949
+ function returnsBetween(heldUntilMs, nextArrivalMs, timings) {
2950
+ const { minPlateauMs } = CAMERA_DEFAULTS.neutral;
2951
+ return nextArrivalMs - timings.zoomInMs - minPlateauMs >= heldUntilMs + minPlateauMs + timings.zoomOutMs;
2952
+ }
2953
+ function insertNeutralKeys(seeds, outputDurationMs, timings, holds = []) {
2723
2954
  const { neutral } = CAMERA_DEFAULTS;
2724
2955
  const { zoomOutMs } = timings;
2725
2956
  const keys = [];
@@ -2739,21 +2970,25 @@ function insertNeutralKeys(seeds, outputDurationMs, timings) {
2739
2970
  stiffness: timings.stiffness
2740
2971
  });
2741
2972
  for (const [i, seed] of seeds.entries()) {
2973
+ const previousMs = keys[keys.length - 1]?.outputTimeMs ?? seed.outputTimeMs;
2974
+ const departMs = Math.max(previousMs, seed.outputTimeMs - seed.transitionMs);
2742
2975
  keys.push(strip(seed));
2743
2976
  if (!seed.zoom)
2744
2977
  continue;
2745
- const earliestMs = seed.outputTimeMs + neutral.minPlateauMs + zoomOutMs;
2746
- const idealMs = seed.outputTimeMs + neutral.zoomHoldMs + zoomOutMs;
2978
+ const next = seeds[i + 1];
2979
+ const heldUntil = heldUntilOf(seed, next?.actionMs ?? Number.POSITIVE_INFINITY, holds);
2980
+ const earliestMs = heldUntil + neutral.minPlateauMs + zoomOutMs;
2981
+ const idealMs = heldUntil + neutral.zoomHoldMs + zoomOutMs;
2747
2982
  const wantedMs = seed.authoredEndMs ?? idealMs;
2748
2983
  const resolvedAuthored = seed.authoredEndMs !== null;
2749
2984
  const authored = resolvedAuthored || seed.endUnplaced;
2750
2985
  const movedFromWanted = (endMs) => resolvedAuthored && Math.abs(endMs - wantedMs) > 1e-6;
2751
- const next = seeds[i + 1];
2752
2986
  if (!next) {
2753
2987
  const atMs2 = Math.min(Math.max(wantedMs, earliestMs), outputDurationMs);
2754
2988
  if (atMs2 <= seed.outputTimeMs) {
2755
2989
  segments.push({
2756
2990
  id: seed.id,
2991
+ departMs,
2757
2992
  startMs: seed.outputTimeMs,
2758
2993
  endMs: outputDurationMs,
2759
2994
  endAuthored: authored,
@@ -2766,6 +3001,7 @@ function insertNeutralKeys(seeds, outputDurationMs, timings) {
2766
3001
  keys.push(pullOut(atMs2, seed.center));
2767
3002
  segments.push({
2768
3003
  id: seed.id,
3004
+ departMs,
2769
3005
  startMs: seed.outputTimeMs,
2770
3006
  endMs: atMs2,
2771
3007
  endAuthored: authored,
@@ -2776,14 +3012,18 @@ function insertNeutralKeys(seeds, outputDurationMs, timings) {
2776
3012
  continue;
2777
3013
  }
2778
3014
  const latestMs = next.outputTimeMs - next.plannedTransitionMs - neutral.minPlateauMs;
2779
- if (latestMs < earliestMs) {
2780
- const settledMs = Math.max(seed.outputTimeMs, seed.actionMs) + neutral.minPlateauMs;
3015
+ if (!returnsBetween(heldUntil, next.outputTimeMs, {
3016
+ zoomInMs: next.plannedTransitionMs,
3017
+ zoomOutMs
3018
+ })) {
3019
+ const settledMs = Math.max(seed.outputTimeMs, seed.actionMs, heldUntil) + neutral.minPlateauMs;
2781
3020
  seeds[i + 1] = {
2782
3021
  ...next,
2783
3022
  transitionMs: Math.max(MIN_PAN_MS, Math.min(next.transitionMs, next.outputTimeMs - settledMs))
2784
3023
  };
2785
3024
  segments.push({
2786
3025
  id: seed.id,
3026
+ departMs,
2787
3027
  startMs: seed.outputTimeMs,
2788
3028
  endMs: next.outputTimeMs,
2789
3029
  endAuthored: authored,
@@ -2797,6 +3037,7 @@ function insertNeutralKeys(seeds, outputDurationMs, timings) {
2797
3037
  keys.push(pullOut(atMs, lerpVec(seed.center, next.center, 0.5)));
2798
3038
  segments.push({
2799
3039
  id: seed.id,
3040
+ departMs,
2800
3041
  startMs: seed.outputTimeMs,
2801
3042
  endMs: atMs,
2802
3043
  endAuthored: authored,
@@ -2875,6 +3116,89 @@ function sampleCamera(keys, outputTimeMs) {
2875
3116
  return { center: last.center, scale: last.scale };
2876
3117
  }
2877
3118
 
3119
+ // ../../packages/compositor/dist/plan/camera-follow.js
3120
+ var FOLLOW_STEP_MS = 8;
3121
+ function departs(keys, i) {
3122
+ const key = keys[i];
3123
+ const before = keys[i - 1];
3124
+ if (!before)
3125
+ return key.outputTimeMs;
3126
+ return key.outputTimeMs - Math.min(key.transitionMs, key.outputTimeMs - before.outputTimeMs);
3127
+ }
3128
+ function solveFollow(args2) {
3129
+ const { keys, cursorAt, holds, outputDurationMs } = args2;
3130
+ const omega = args2.rate / 1e3;
3131
+ const held = (t) => holds.some((h) => h.startMs <= t && t < h.endMs);
3132
+ const stretches = [];
3133
+ for (let i = 1; i < keys.length; i++) {
3134
+ const landing = keys[i];
3135
+ if (landing.scale <= 1 || keys[i - 1].scale > 1)
3136
+ continue;
3137
+ let last = i;
3138
+ while ((keys[last + 1]?.scale ?? 0) > 1)
3139
+ last++;
3140
+ const out = last + 1 < keys.length ? last + 1 : null;
3141
+ const endMs = out === null ? outputDurationMs : keys[out].outputTimeMs;
3142
+ const pullOutDepartMs = out === null ? outputDurationMs : departs(keys, out);
3143
+ const departures = keys.slice(i + 1, last + 1).map((key, k) => ({ at: departs(keys, i + 1 + k), center: key.center }));
3144
+ let aimed = -1;
3145
+ const aimAt = (t) => {
3146
+ while (aimed + 1 < departures.length && (departures[aimed + 1]?.at ?? Number.POSITIVE_INFINITY) <= t) {
3147
+ aimed++;
3148
+ }
3149
+ return departures[aimed]?.center ?? landing.center;
3150
+ };
3151
+ const targetAt = (t) => (cursorAt !== null && !held(t) ? cursorAt(t) : null) ?? aimAt(t);
3152
+ let x = landing.center;
3153
+ let v = { x: 0, y: 0 };
3154
+ const centers = [x];
3155
+ for (let t = landing.outputTimeMs; t < endMs; t += FOLLOW_STEP_MS) {
3156
+ const target = targetAt(t);
3157
+ const dt = Math.min(FOLLOW_STEP_MS, endMs - t);
3158
+ const e = Math.exp(-omega * dt);
3159
+ const step = (y, vel) => {
3160
+ const k = vel + omega * y;
3161
+ return { y: (y + k * dt) * e, v: (vel - omega * k * dt) * e };
3162
+ };
3163
+ const sx = step(x.x - target.x, v.x);
3164
+ const sy = step(x.y - target.y, v.y);
3165
+ x = { x: target.x + sx.y, y: target.y + sy.y };
3166
+ v = { x: sx.v, y: sy.v };
3167
+ centers.push(x);
3168
+ }
3169
+ stretches.push({
3170
+ startMs: landing.outputTimeMs,
3171
+ pullOutDepartMs,
3172
+ endMs,
3173
+ centers
3174
+ });
3175
+ i = last;
3176
+ }
3177
+ return stretches;
3178
+ }
3179
+ function sampleTrack(track, outputTimeMs) {
3180
+ const base = sampleCamera(track.cameraKeys, outputTimeMs);
3181
+ if (base.scale <= 1)
3182
+ return base;
3183
+ const stretch = track.cameraFollow.find((s) => s.startMs <= outputTimeMs && outputTimeMs <= s.endMs);
3184
+ if (!stretch)
3185
+ return base;
3186
+ const last = stretch.centers.length - 1;
3187
+ const i = Math.min(Math.floor((outputTimeMs - stretch.startMs) / FOLLOW_STEP_MS), last);
3188
+ const timeOf = (k) => Math.min(stretch.startMs + k * FOLLOW_STEP_MS, stretch.endMs);
3189
+ const here = stretch.centers[i];
3190
+ const next = stretch.centers[i + 1];
3191
+ const spring = next === void 0 ? here : lerpVec(here, next, (outputTimeMs - timeOf(i)) / (timeOf(i + 1) - timeOf(i)));
3192
+ if (outputTimeMs < stretch.pullOutDepartMs) {
3193
+ return { center: spring, scale: base.scale };
3194
+ }
3195
+ const from = sampleCamera(track.cameraKeys, stretch.pullOutDepartMs).scale;
3196
+ if (from <= 1)
3197
+ return base;
3198
+ const w = (base.scale - 1) / (from - 1);
3199
+ return { center: lerpVec(base.center, spring, w), scale: base.scale };
3200
+ }
3201
+
2878
3202
  // ../../packages/compositor/dist/plan/cursor.js
2879
3203
  var CURSOR_DEFAULTS2 = {
2880
3204
  // Half the pace these once set (240-700ms, 180ms + 0.35ms/px): the author
@@ -2961,170 +3285,22 @@ function planCursorSegments(scene, rectOf) {
2961
3285
  // ../../packages/compositor/dist/version.js
2962
3286
  var COMPOSITOR_VERSION = "1.1.0";
2963
3287
 
2964
- // ../../packages/compositor/dist/plan/scene-walk.js
2965
- function nextKeptActionId(scene, actionId, cutSteps) {
2966
- const idx = scene.actions.findIndex((a) => a.id === actionId);
2967
- if (idx === -1)
2968
- return null;
2969
- for (let i = idx + 1; i < scene.actions.length; i++) {
2970
- const action = scene.actions[i];
2971
- if (action && !cutSteps.has(action.id))
2972
- return action.id;
2973
- }
2974
- return null;
2975
- }
2976
- function pageKey(url) {
2977
- const hash = url.indexOf("#");
2978
- return hash === -1 ? url : url.slice(0, hash);
2979
- }
2980
- function pageChangeAfter(scene, actionId) {
2981
- const index = scene.actions.findIndex((a) => a.id === actionId);
2982
- const step = scene.actions[index];
2983
- if (step === void 0)
2984
- return null;
2985
- const trace = scene.sideChannels.urlTrace;
2986
- let here = scene.meta.capture.originUrl;
2987
- for (const entry of trace)
2988
- if (entry.timestamp <= step.timestamp)
2989
- here = entry.url;
2990
- const anchorPage = (anchorId) => anchorId === null ? null : scene.anchors.find((a) => a.id === anchorId)?.resolution.url ?? null;
2991
- const stepPage = anchorPage(step.anchorId);
2992
- const nav = trace.find((entry) => entry.timestamp > step.timestamp && pageKey(entry.url) !== pageKey(here));
2993
- let leaveAt = nav === void 0 ? null : nav.timestamp;
2994
- if (stepPage !== null) {
2995
- for (let i = index + 1; i < scene.actions.length; i++) {
2996
- const later = scene.actions[i];
2997
- if (later === void 0)
2998
- continue;
2999
- const page2 = anchorPage(later.anchorId);
3000
- if (page2 !== null && pageKey(page2) !== pageKey(stepPage)) {
3001
- if (leaveAt === null || later.timestamp < leaveAt)
3002
- leaveAt = later.timestamp;
3003
- break;
3004
- }
3005
- }
3006
- }
3007
- if (leaveAt === null)
3008
- return null;
3009
- let from = step;
3010
- for (let i = index + 1; i < scene.actions.length; i++) {
3011
- const later = scene.actions[i];
3012
- if (later === void 0 || later.timestamp > leaveAt)
3013
- break;
3014
- from = later;
3015
- }
3016
- return { actionId: from.id, offsetMs: Math.max(0, leaveAt - from.timestamp) };
3017
- }
3018
-
3019
3288
  // ../../packages/compositor/dist/plan/cosmetics.js
3020
- function planCosmetics(scene, cutSteps, attached, overlays) {
3021
- const replacements = scene.edits.replacements.filter((r) => r.targetAnchorId !== null).map((r) => ({
3022
- id: r.id,
3023
- kind: "replacement",
3024
- anchorId: r.targetAnchorId,
3025
- rect: null,
3026
- text: r.replace,
3027
- range: null,
3028
- reveal: null
3029
- }));
3030
- const retexts2 = overlays.flatMap((overlay) => {
3031
- if (cutSteps.has(overlay.actionId)) {
3032
- attached.push({
3033
- id: `retext:${overlay.actionId}`,
3034
- kind: "retext",
3035
- actionId: overlay.actionId
3036
- });
3037
- return [];
3038
- }
3039
- const until = nextKeptActionId(scene, overlay.actionId, cutSteps);
3040
- return [
3041
- {
3042
- id: `retext:${overlay.actionId}`,
3043
- kind: "replacement",
3044
- anchorId: overlay.anchorId,
3045
- rect: null,
3046
- text: overlay.text,
3047
- // From the step until the take leaves its page: the field holds its
3048
- // value while it is on screen, and not a moment after — the end of
3049
- // the video only when the take never leaves (`pageChangeAfter`).
3050
- range: {
3051
- start: { actionId: overlay.actionId, offsetMs: 0 },
3052
- end: pageChangeAfter(scene, overlay.actionId)
3053
- },
3054
- // Typed across the step's own stretch — the same span a cut of this
3055
- // step would remove, and the closest thing the take has to "how long
3056
- // the author spent typing".
3057
- reveal: {
3058
- start: { actionId: overlay.actionId, offsetMs: 0 },
3059
- end: until === null ? null : { actionId: until, offsetMs: 0 }
3060
- }
3061
- }
3062
- ];
3063
- });
3064
- const masks = scene.edits.masks.flatMap((m) => {
3289
+ function planCosmetics(scene, cutSteps, attached) {
3290
+ return scene.edits.masks.flatMap((m) => {
3065
3291
  const range = m.start && m.end ? { start: m.start, end: m.end } : null;
3066
3292
  if (range && cutSteps.has(range.start.actionId)) {
3067
3293
  attached.push({ id: m.id, kind: "mask", actionId: range.start.actionId });
3068
3294
  return [];
3069
3295
  }
3070
- return [
3071
- {
3072
- id: m.id,
3073
- kind: "mask",
3074
- anchorId: null,
3075
- rect: m.rect,
3076
- text: null,
3077
- range,
3078
- reveal: null
3079
- }
3080
- ];
3296
+ return [{ id: m.id, kind: "mask", rect: m.rect, range }];
3081
3297
  });
3082
- return [...replacements, ...retexts2, ...masks];
3083
3298
  }
3084
3299
 
3085
3300
  // ../../packages/compositor/dist/plan/plan.js
3086
3301
  var RETIMING_DEFAULTS = {
3087
3302
  motionDiffThreshold: 0.02
3088
3303
  };
3089
- function planCuts(scene) {
3090
- const cutOf = new Map((scene.edits.cuts ?? []).map((cut) => [cut.actionId, cut]));
3091
- if (cutOf.size === 0)
3092
- return [];
3093
- const cutSteps = new Set(cutOf.keys());
3094
- const runs = [];
3095
- const { actions } = scene;
3096
- let i = 0;
3097
- while (i < actions.length) {
3098
- const here = actions[i];
3099
- if (!here || !cutOf.has(here.id)) {
3100
- i += 1;
3101
- continue;
3102
- }
3103
- let j = i;
3104
- const ids = [];
3105
- const actionIds = [];
3106
- let keepJump = true;
3107
- while (j < actions.length) {
3108
- const step = actions[j];
3109
- const cut = step ? cutOf.get(step.id) : void 0;
3110
- if (!step || !cut)
3111
- break;
3112
- ids.push(cut.id);
3113
- actionIds.push(step.id);
3114
- keepJump &&= cut.keepJump === true;
3115
- j += 1;
3116
- }
3117
- const lastActionId = actionIds[actionIds.length - 1];
3118
- runs.push({
3119
- ids,
3120
- actionIds,
3121
- untilActionId: lastActionId === void 0 ? null : nextKeptActionId(scene, lastActionId, cutSteps),
3122
- keepJump
3123
- });
3124
- i = j;
3125
- }
3126
- return runs;
3127
- }
3128
3304
  function planScene(scene, opts = {}) {
3129
3305
  const anchorRects = /* @__PURE__ */ new Map();
3130
3306
  for (const anchor2 of scene.anchors) {
@@ -3139,8 +3315,8 @@ function planScene(scene, opts = {}) {
3139
3315
  }
3140
3316
  const rectOf = (anchorId, actionId) => actionRects.get(actionId) ?? anchorRects.get(anchorId) ?? null;
3141
3317
  const lastAction = scene.actions[scene.actions.length - 1];
3142
- const cuts = planCuts(scene);
3143
- const cutSteps = new Set(cuts.flatMap((run2) => run2.actionIds));
3318
+ const removed = scene.edits.removed ?? [];
3319
+ const cutSteps = stepsInsideRemoved(scene);
3144
3320
  const attachedToCuts = [];
3145
3321
  const gapAfter = new Map((scene.edits.gaps ?? []).map((gap) => [gap.afterActionId, gap]));
3146
3322
  const paces = [];
@@ -3191,7 +3367,7 @@ function planScene(scene, opts = {}) {
3191
3367
  // the author never recorded.
3192
3368
  cursorSegments: planCursorSegments(scene, rectOf),
3193
3369
  cameraIntents: planCameraIntents(scene, cutSteps, attachedToCuts),
3194
- cosmetics: planCosmetics(scene, cutSteps, attachedToCuts, opts.retexts ?? []),
3370
+ cosmetics: planCosmetics(scene, cutSteps, attachedToCuts),
3195
3371
  holds: (scene.edits.holds ?? []).flatMap((hold) => {
3196
3372
  if (cutSteps.has(hold.marker.actionId)) {
3197
3373
  attachedToCuts.push({
@@ -3211,7 +3387,8 @@ function planScene(scene, opts = {}) {
3211
3387
  ];
3212
3388
  }),
3213
3389
  paces,
3214
- cuts,
3390
+ removed,
3391
+ removedSteps: [...cutSteps],
3215
3392
  attachedToCuts,
3216
3393
  trim: {
3217
3394
  head: scene.edits.trim?.head ?? null,
@@ -3223,105 +3400,6 @@ function planScene(scene, opts = {}) {
3223
3400
  };
3224
3401
  }
3225
3402
 
3226
- // ../../packages/compositor/dist/render/draw-cursor.js
3227
- var PULSE_DURATION_MS = 400;
3228
- var CURSOR_UPRIGHT = Object.freeze({
3229
- press: 1,
3230
- angleRad: 0
3231
- });
3232
- var ARROW = [
3233
- { x: 0, y: 0 },
3234
- { x: 0, y: 0.75 },
3235
- { x: 0.19, y: 0.58 },
3236
- { x: 0.31, y: 0.87 },
3237
- { x: 0.45, y: 0.81 },
3238
- { x: 0.33, y: 0.53 },
3239
- { x: 0.56, y: 0.52 }
3240
- ];
3241
- var TOUCH_RADIUS = 0.42;
3242
- var CURSOR_ART = {
3243
- light: { height: 40, hotspot: { x: 0, y: 0 }, ink: bounds(ARROW) },
3244
- dark: { height: 40, hotspot: { x: 0, y: 0 }, ink: bounds(ARROW) },
3245
- touch: {
3246
- height: 40,
3247
- hotspot: { x: 0.5, y: 0.5 },
3248
- ink: {
3249
- min: { x: 0.5 - TOUCH_RADIUS, y: 0.5 - TOUCH_RADIUS },
3250
- max: { x: 0.5 + TOUCH_RADIUS, y: 0.5 + TOUCH_RADIUS }
3251
- }
3252
- }
3253
- };
3254
- function bounds(points) {
3255
- const xs = points.map((p) => p.x);
3256
- const ys = points.map((p) => p.y);
3257
- return {
3258
- min: { x: Math.min(...xs), y: Math.min(...ys) },
3259
- max: { x: Math.max(...xs), y: Math.max(...ys) }
3260
- };
3261
- }
3262
-
3263
- // ../../packages/compositor/dist/plan/camera-follow.js
3264
- var FOLLOW_STEP_MS = 33;
3265
- var FOLLOW_SAFE_INSET = 0.25;
3266
- var FOLLOW_MIN_MOVE_PX = 4;
3267
- var FOLLOW_CLICK_LEAD_MS = 100;
3268
- function followCursor(args2) {
3269
- const { keys, cursorAt, outputDurationMs, viewport, timings, minPlateauMs } = args2;
3270
- const shown = args2.fitWindow ?? viewport;
3271
- const panMs = timings.followPanMs;
3272
- const crossesClick = (startMs) => args2.clickOutputMs.some((click) => startMs < click + PULSE_DURATION_MS && startMs + panMs > click - FOLLOW_CLICK_LEAD_MS);
3273
- const out = [];
3274
- for (const [i, key] of keys.entries()) {
3275
- out.push(key);
3276
- if (key.scale <= 1)
3277
- continue;
3278
- const next = keys[i + 1];
3279
- const plateauEndMs = next ? next.outputTimeMs - Math.min(next.transitionMs, next.outputTimeMs - key.outputTimeMs) : outputDurationMs;
3280
- const window = {
3281
- width: shown.width / key.scale,
3282
- height: shown.height / key.scale
3283
- };
3284
- const halfWidth = Math.min(window.width, viewport.width) / 2;
3285
- const halfHeight = Math.min(window.height, viewport.height) / 2;
3286
- const inside = (p) => ({
3287
- x: clamp(p.x, halfWidth, viewport.width - halfWidth),
3288
- y: clamp(p.y, halfHeight, viewport.height - halfHeight)
3289
- });
3290
- const safeX = window.width * (0.5 - FOLLOW_SAFE_INSET);
3291
- const safeY = window.height * (0.5 - FOLLOW_SAFE_INSET);
3292
- let zone = inside(key.center);
3293
- let held = key.center;
3294
- let t = key.outputTimeMs;
3295
- while (t + panMs + minPlateauMs <= plateauEndMs) {
3296
- const pointer = cursorAt(t);
3297
- if (pointer === null)
3298
- break;
3299
- const leftX = Math.abs(pointer.x - zone.x) > safeX;
3300
- const leftY = Math.abs(pointer.y - zone.y) > safeY;
3301
- const wanted = inside(pointer);
3302
- if (!(leftX || leftY) || Math.hypot(wanted.x - zone.x, wanted.y - zone.y) < FOLLOW_MIN_MOVE_PX || crossesClick(t)) {
3303
- t += FOLLOW_STEP_MS;
3304
- continue;
3305
- }
3306
- t += panMs;
3307
- held = {
3308
- x: leftX ? wanted.x : held.x + (wanted.x - zone.x),
3309
- y: leftY ? wanted.y : held.y + (wanted.y - zone.y)
3310
- };
3311
- zone = wanted;
3312
- out.push({
3313
- outputTimeMs: t,
3314
- center: held,
3315
- scale: key.scale,
3316
- transitionMs: panMs,
3317
- stiffness: timings.stiffness,
3318
- followPan: true
3319
- });
3320
- }
3321
- }
3322
- return out;
3323
- }
3324
-
3325
3403
  // ../../packages/compositor/dist/plan/smooth.js
3326
3404
  var CURSOR_SMOOTHING_MS = 30;
3327
3405
  var KERNEL_REACH_SIGMAS = 3;
@@ -4112,7 +4190,7 @@ function bridgeCutSeams(samples, timeline, bridgeMs) {
4112
4190
  return samples;
4113
4191
  const bridges = [];
4114
4192
  for (const cut of timeline.cuts) {
4115
- if (cut.trailing)
4193
+ if (cut.trailing || cut.srcStartMs <= 0)
4116
4194
  continue;
4117
4195
  const from = sampleCursor(samples, cut.srcStartMs);
4118
4196
  if (from === null)
@@ -4184,7 +4262,22 @@ function cursorRestSpans(samples, timeline, clickOutputMs) {
4184
4262
  function scaleText(scale) {
4185
4263
  return String(Number(scale.toFixed(2)));
4186
4264
  }
4187
- function resolvePlan(plan, given, givenScene, hints = [], cameraFitWindow = null) {
4265
+ function resolveCameraFollow(args2) {
4266
+ const { keys, plan, bundle, timeline, cursor: cursor2, motion } = args2;
4267
+ const zoomedActions = new Set(plan.cameraIntents.map((i) => i.actionId));
4268
+ return solveFollow({
4269
+ keys,
4270
+ cursorAt: motion.follow && args2.drawsPointer ? (outputMs) => sampleCursor(cursor2, toSourceMs(timeline, outputMs)) : null,
4271
+ holds: (bundle.heldPresses ?? []).filter((h) => zoomedActions.has(h.actionId)).map((h) => ({
4272
+ startMs: toOutputMs(timeline, h.pressMs),
4273
+ endMs: toOutputMs(timeline, h.releaseMs)
4274
+ })),
4275
+ outputDurationMs: timeline.outputDurationMs,
4276
+ rate: motionTimings(motion.smoothness).followRatePerS
4277
+ });
4278
+ }
4279
+ function resolvePlan(givenPlan, given, givenScene, hints = [], cameraFitWindow = null) {
4280
+ let plan = givenPlan;
4188
4281
  const { bundle, scene } = inScreenSpace(given, givenScene);
4189
4282
  const anchorRects = /* @__PURE__ */ new Map();
4190
4283
  for (const anchor2 of scene?.anchors ?? []) {
@@ -4217,13 +4310,33 @@ function resolvePlan(plan, given, givenScene, hints = [], cameraFitWindow = null
4217
4310
  ) : travelled;
4218
4311
  const settleMs = bundle.source === "capture" ? springSettleMs(CURSOR_SPRING_TAU_MS) : 0;
4219
4312
  const leadMs = bundle.source === "capture" ? springLeadMs(CURSOR_SPRING_TAU_MS) : 0;
4220
- const timeline = buildTimeline(plan, bundle, [
4313
+ const motionHints = [
4221
4314
  ...hints,
4222
4315
  ...cursorMotionSpans(travelled).map((span) => ({
4223
4316
  startMs: Math.max(0, span.startMs - leadMs),
4224
4317
  endMs: span.endMs + settleMs
4225
4318
  }))
4226
- ]);
4319
+ ];
4320
+ let timeline = buildTimeline(plan, bundle, motionHints);
4321
+ const unplacedIds = new Set(timeline.unplacedCuts.flatMap((u) => u.ids));
4322
+ if (unplacedIds.size > 0 && givenScene !== void 0) {
4323
+ const kept = planScene({
4324
+ ...givenScene,
4325
+ edits: {
4326
+ ...givenScene.edits,
4327
+ removed: (givenScene.edits.removed ?? []).filter((r) => !unplacedIds.has(r.id))
4328
+ }
4329
+ }, { retiming: plan.retiming });
4330
+ plan = {
4331
+ ...plan,
4332
+ cameraIntents: kept.cameraIntents,
4333
+ cosmetics: kept.cosmetics,
4334
+ holds: kept.holds,
4335
+ removedSteps: kept.removedSteps,
4336
+ attachedToCuts: kept.attachedToCuts
4337
+ };
4338
+ timeline = buildTimeline(plan, bundle, motionHints);
4339
+ }
4227
4340
  const bridged = bridgeCutSeams(cursor2, timeline, CUT_BRIDGE_MS);
4228
4341
  const trim = resolveRange({
4229
4342
  id: "trim",
@@ -4235,9 +4348,13 @@ function resolvePlan(plan, given, givenScene, hints = [], cameraFitWindow = null
4235
4348
  });
4236
4349
  const clampedRanges = trim.clamped ? [trim.clamped] : [];
4237
4350
  const motion = scene?.motion ?? MOTION_DEFAULTS;
4238
- const cutIds = new Set(plan.cuts.flatMap((run2) => run2.actionIds));
4351
+ const cutIds = new Set(plan.removedSteps ?? []);
4239
4352
  const actEnds = new Map(bundle.markers.flatMap((m) => m.actEndSourceTimeMs === void 0 || cutIds.has(m.actionId) ? [] : [[m.actionId, m.actEndSourceTimeMs]]));
4240
- const camera = solveCamera(plan.cameraIntents, rectOf, timeline, markerSourceMs, plan.viewport, cameraFitWindow, motion, actEnds);
4353
+ const holdOutputMs = (bundle.heldPresses ?? []).map((h) => ({
4354
+ startMs: toOutputMs(timeline, h.pressMs),
4355
+ endMs: toOutputMs(timeline, h.releaseMs)
4356
+ }));
4357
+ const camera = solveCamera(plan.cameraIntents, rectOf, timeline, markerSourceMs, plan.viewport, cameraFitWindow, motion, actEnds, holdOutputMs);
4241
4358
  const intentAction = new Map(plan.cameraIntents.map((intent) => [intent.id, intent.actionId]));
4242
4359
  const loweredZooms = [];
4243
4360
  for (const segment of camera.segments) {
@@ -4270,7 +4387,7 @@ function resolvePlan(plan, given, givenScene, hints = [], cameraFitWindow = null
4270
4387
  note: `zoom "${segment.id}" was asked to end at an instant the camera cannot reach \u2014 too close to its own push-in or to the next zoom \u2014 so it returns at ${Math.round(segment.endMs)}ms instead`
4271
4388
  });
4272
4389
  }
4273
- const clickKinds = new Set(bundle.source === "replay" ? ["click", "type"] : ["click"]);
4390
+ const clickKinds = new Set(bundle.source === "replay" ? ["click", "type", "drag"] : ["click"]);
4274
4391
  const clickActionIds = new Set((scene?.actions ?? []).filter((a) => clickKinds.has(a.kind)).map((a) => a.id));
4275
4392
  const clickOutputMs = bundle.markers.filter((m) => clickActionIds.has(m.actionId)).map((m) => toOutputMs(timeline, m.sourceTimeMs)).sort((a, b) => a - b);
4276
4393
  const touch = scene?.meta.capture.device?.touch === true;
@@ -4278,36 +4395,22 @@ function resolvePlan(plan, given, givenScene, hints = [], cameraFitWindow = null
4278
4395
  const at2 = sampleCursor(bridged, m.sourceTimeMs);
4279
4396
  return at2 === null ? [] : [{ outputMs: toOutputMs(timeline, m.sourceTimeMs), at: at2 }];
4280
4397
  }).sort((a, b) => a.outputMs - b.outputMs) : [];
4281
- const cameraKeys = motion.follow ? followCursor({
4398
+ const cameraFollow = resolveCameraFollow({
4282
4399
  keys: camera.keys,
4283
- cursorAt: (outputMs) => sampleCursor(bridged, toSourceMs(timeline, outputMs)),
4284
- outputDurationMs: timeline.outputDurationMs,
4285
- viewport: plan.viewport,
4286
- fitWindow: cameraFitWindow,
4287
- timings: motionTimings(motion.smoothness),
4288
- minPlateauMs: CAMERA_DEFAULTS.neutral.minPlateauMs,
4289
- clickOutputMs
4290
- }) : camera.keys;
4291
- const cosmetics = plan.cosmetics.flatMap((binding) => {
4292
- const rectStep = binding.kind === "replacement" ? binding.range?.start?.actionId ?? "" : "";
4293
- const rect2 = binding.rect ?? (binding.anchorId ? rectOf(binding.anchorId, rectStep) : null);
4294
- if (!rect2) {
4295
- clampedRanges.push({
4296
- id: binding.id,
4297
- kind: binding.kind === "mask" ? "mask" : binding.range !== null ? "retext" : "replacement",
4298
- note: `${binding.kind === "mask" ? "mask" : binding.range !== null ? "retext" : "replacement"} "${binding.id}" is not drawn: nothing recorded where its element is on screen`
4299
- });
4300
- return [];
4301
- }
4400
+ plan,
4401
+ bundle,
4402
+ timeline,
4403
+ cursor: bridged,
4404
+ motion,
4405
+ drawsPointer: !touch && !(scene?.cursor ?? CURSOR_DEFAULTS).hidden
4406
+ });
4407
+ const cosmetics = plan.cosmetics.map((binding) => {
4302
4408
  let range = null;
4303
4409
  let unplaced = [];
4304
4410
  if (binding.range) {
4305
4411
  const resolved = resolveRange({
4306
4412
  id: binding.id,
4307
- // A replacement carrying a range is a retext overlay — the only
4308
- // shape that pairs the two (`plan/types.ts`) — so it reports under
4309
- // its own name rather than as a mask.
4310
- kind: binding.kind === "mask" ? "mask" : "retext",
4413
+ kind: "mask",
4311
4414
  start: binding.range.start,
4312
4415
  end: binding.range.end,
4313
4416
  timeline,
@@ -4318,39 +4421,23 @@ function resolvePlan(plan, given, givenScene, hints = [], cameraFitWindow = null
4318
4421
  unplaced = resolved.unplaced;
4319
4422
  range = resolved.range;
4320
4423
  }
4321
- let reveal = null;
4322
- if (binding.reveal) {
4323
- const resolved = resolveRange({
4324
- id: binding.id,
4325
- kind: "retext",
4326
- start: binding.reveal.start,
4327
- end: binding.reveal.end,
4328
- timeline,
4329
- markerSourceMs
4330
- });
4331
- if (resolved.clamped)
4332
- clampedRanges.push(resolved.clamped);
4333
- reveal = resolved.range;
4334
- }
4335
- return [
4336
- {
4337
- id: binding.id,
4338
- kind: binding.kind,
4339
- rect: rect2,
4340
- text: binding.text,
4341
- range,
4342
- unplaced,
4343
- reveal
4344
- }
4345
- ];
4424
+ return {
4425
+ id: binding.id,
4426
+ kind: "mask",
4427
+ rect: binding.rect,
4428
+ range,
4429
+ unplaced
4430
+ };
4346
4431
  });
4347
4432
  return {
4348
4433
  plan,
4349
4434
  timeline,
4350
- cameraKeys,
4435
+ cameraKeys: camera.keys,
4436
+ cameraFollow,
4351
4437
  cameraSegments: camera.segments,
4352
4438
  cursor: bridged,
4353
4439
  clickOutputMs,
4440
+ holdOutputMs,
4354
4441
  touch,
4355
4442
  taps,
4356
4443
  cursorLook: scene?.cursor ?? CURSOR_DEFAULTS,
@@ -4376,6 +4463,42 @@ var { applyPalette, GIFEncoder, quantize } = gifenc;
4376
4463
  // ../../packages/compositor/dist/ports/sink-mp4.js
4377
4464
  import { BufferTarget, Mp4OutputFormat, Output, Quality, VideoSample, VideoSampleSource } from "mediabunny";
4378
4465
 
4466
+ // ../../packages/compositor/dist/render/draw-cursor.js
4467
+ var CURSOR_UPRIGHT = Object.freeze({
4468
+ press: 1,
4469
+ angleRad: 0
4470
+ });
4471
+ var ARROW = [
4472
+ { x: 0, y: 0 },
4473
+ { x: 0, y: 0.75 },
4474
+ { x: 0.19, y: 0.58 },
4475
+ { x: 0.31, y: 0.87 },
4476
+ { x: 0.45, y: 0.81 },
4477
+ { x: 0.33, y: 0.53 },
4478
+ { x: 0.56, y: 0.52 }
4479
+ ];
4480
+ var TOUCH_RADIUS = 0.42;
4481
+ var CURSOR_ART = {
4482
+ light: { height: 40, hotspot: { x: 0, y: 0 }, ink: bounds(ARROW) },
4483
+ dark: { height: 40, hotspot: { x: 0, y: 0 }, ink: bounds(ARROW) },
4484
+ touch: {
4485
+ height: 40,
4486
+ hotspot: { x: 0.5, y: 0.5 },
4487
+ ink: {
4488
+ min: { x: 0.5 - TOUCH_RADIUS, y: 0.5 - TOUCH_RADIUS },
4489
+ max: { x: 0.5 + TOUCH_RADIUS, y: 0.5 + TOUCH_RADIUS }
4490
+ }
4491
+ }
4492
+ };
4493
+ function bounds(points) {
4494
+ const xs = points.map((p) => p.x);
4495
+ const ys = points.map((p) => p.y);
4496
+ return {
4497
+ min: { x: Math.min(...xs), y: Math.min(...ys) },
4498
+ max: { x: Math.max(...xs), y: Math.max(...ys) }
4499
+ };
4500
+ }
4501
+
4379
4502
  // ../../packages/compositor/dist/render/cursor-pose.js
4380
4503
  var TILT_MAX_RAD = 15 * Math.PI / 180;
4381
4504
  var TILT_VELOCITY_MS = 16;
@@ -4583,6 +4706,19 @@ function landscapeFrame(aspect, tier, recording, padding) {
4583
4706
  }
4584
4707
  var MAX_MP4_MACROBLOCKS = 36864;
4585
4708
  var macroblocks = (w, h) => Math.ceil(w / 16) * Math.ceil(h / 16);
4709
+ function fitH264Frame(width, height) {
4710
+ if (macroblocks(width, height) <= MAX_MP4_MACROBLOCKS) {
4711
+ return { width, height };
4712
+ }
4713
+ const even = (x) => Math.max(2, 2 * Math.floor(x / 2));
4714
+ let scale = Math.sqrt(MAX_MP4_MACROBLOCKS * 256 / (width * height));
4715
+ for (; ; ) {
4716
+ const fit = { width: even(width * scale), height: even(height * scale) };
4717
+ if (macroblocks(fit.width, fit.height) <= MAX_MP4_MACROBLOCKS)
4718
+ return fit;
4719
+ scale *= 0.995;
4720
+ }
4721
+ }
4586
4722
  function autoTarget(tier, viewport, padding) {
4587
4723
  const aspect = viewport.width / viewport.height;
4588
4724
  const inner = 1 - 2 * padding;
@@ -4616,6 +4752,14 @@ function autoTarget(tier, viewport, padding) {
4616
4752
  };
4617
4753
  }
4618
4754
 
4755
+ // ../../packages/run-core/dist/drag-points.js
4756
+ var pointRect = (p) => ({
4757
+ x: p.x,
4758
+ y: p.y,
4759
+ width: 0,
4760
+ height: 0
4761
+ });
4762
+
4619
4763
  // ../../packages/run-core/dist/zoom-defaults.js
4620
4764
  function zoomDefaultMs(smoothness) {
4621
4765
  return CAMERA_DEFAULTS.neutral.zoomHoldMs + motionTimings(smoothness).zoomOutMs;
@@ -4650,15 +4794,30 @@ function decideZoom(last, click, viewport, scaleOf) {
4650
4794
  }
4651
4795
  return { zoom: true, scale: fitted };
4652
4796
  }
4797
+ function dragBox(action) {
4798
+ const points = dragPoints(action, action.rect, action.toRect);
4799
+ const rects = points === null ? [action.rect, action.toRect].filter((r) => r !== void 0) : [pointRect(points.start), pointRect(points.end)];
4800
+ if (rects.length === 0)
4801
+ return void 0;
4802
+ const x = Math.min(...rects.map((r) => r.x));
4803
+ const y = Math.min(...rects.map((r) => r.y));
4804
+ return {
4805
+ x,
4806
+ y,
4807
+ width: Math.max(...rects.map((r) => r.x + r.width)) - x,
4808
+ height: Math.max(...rects.map((r) => r.y + r.height)) - y
4809
+ };
4810
+ }
4653
4811
  function zoomsForClicks(actions, viewport, scaleAt = () => 1) {
4654
4812
  const { leadInMs } = CAMERA_DEFAULTS;
4655
4813
  const camera = [];
4656
4814
  const zoomsSkipped = [];
4657
4815
  let last = null;
4658
4816
  for (const action of actions) {
4659
- if (action.kind !== "click")
4817
+ if (action.kind !== "click" && action.kind !== "drag")
4660
4818
  continue;
4661
- const decided = decideZoom(last, action, viewport, () => scaleAt(action));
4819
+ const box = action.kind === "drag" ? dragBox(action) : void 0;
4820
+ const decided = decideZoom(last, box === void 0 ? action : { ...action, rect: box }, viewport, () => scaleAt(action));
4662
4821
  if (!decided.zoom) {
4663
4822
  zoomsSkipped.push(decided.skipped);
4664
4823
  continue;
@@ -4666,7 +4825,12 @@ function zoomsForClicks(actions, viewport, scaleAt = () => 1) {
4666
4825
  camera.push({
4667
4826
  id: `zoom-${camera.length + 1}`,
4668
4827
  kind: "zoom",
4669
- anchorId: action.anchorId,
4828
+ ...box === void 0 ? { anchorId: action.anchorId } : {
4829
+ point: {
4830
+ x: box.x + box.width / 2,
4831
+ y: box.y + box.height / 2
4832
+ }
4833
+ },
4670
4834
  marker: { actionId: action.id, offsetMs: leadInMs },
4671
4835
  scale: decided.scale
4672
4836
  });
@@ -4994,8 +5158,8 @@ function warningsOf(facts, args2) {
4994
5158
  detailViolations: facts.detailViolations,
4995
5159
  ...facts.unplacedStills === void 0 ? {} : { unplacedStills: facts.unplacedStills },
4996
5160
  ...args2.zooms === void 0 ? {} : { zooms: args2.zooms },
4997
- ...args2.retexts === void 0 ? {} : { retexts: args2.retexts },
4998
- ...args2.editedSinceFilmed === void 0 ? {} : { editedSinceFilmed: args2.editedSinceFilmed },
5161
+ ...args2.migration === void 0 || args2.migration.length === 0 ? {} : { migration: args2.migration },
5162
+ ...args2.editedSinceRecorded === void 0 ? {} : { editedSinceRecorded: args2.editedSinceRecorded },
4999
5163
  ...args2.targetCheck === void 0 ? {} : { targetCheck: args2.targetCheck },
5000
5164
  ...args2.masks === void 0 ? {} : { masks: args2.masks },
5001
5165
  ...args2.gifSize === void 0 ? {} : { gifSize: args2.gifSize },
@@ -5077,53 +5241,45 @@ function unplacedClauses(unplaced) {
5077
5241
  `${plural2(unplaced.length, "step got no still", "steps got no still")} (${first.actionId}: ${first.reason})`
5078
5242
  ];
5079
5243
  }
5080
- function retextClauses(retexts2) {
5081
- const of = retexts2.filter((r) => r.kind === "notDrawn");
5082
- const first = of[0];
5083
- if (first === void 0)
5084
- return [];
5085
- return [
5086
- `edited text is not drawn for ${plural2(of.length, "typed step", "typed steps")} (${first.actionId}: ${first.reason})`
5087
- ];
5088
- }
5089
- function editedWhat(e, undrawn) {
5244
+ function editedWhat(e) {
5090
5245
  switch (e.what) {
5091
5246
  case "text":
5092
- return undrawn.has(e.actionId) ? `${e.actionId}: "${e.was ?? ""}" \u2192 "${e.now ?? ""}"; the video still shows the old text` : `${e.actionId}: "${e.was ?? ""}" \u2192 "${e.now ?? ""}"; the field shows the new text, the page's response the old one`;
5247
+ return `${e.actionId}: "${e.was ?? ""}" \u2192 "${e.now ?? ""}"; the video still shows the old text`;
5093
5248
  case "kind":
5094
- return `${e.actionId}: its step changed from ${e.was ?? ""} to ${e.now ?? ""}; the video shows the step as filmed \u2014 derive this take, check the step, and run the draft`;
5249
+ return `${e.actionId}: its step changed from ${e.was ?? ""} to ${e.now ?? ""}; the video shows the step as recorded \u2014 derive this take, check the step, and run the draft`;
5095
5250
  case "target":
5096
- return `${e.actionId}: its target changed; the video shows the step as filmed`;
5251
+ return `${e.actionId}: its target changed; the video shows the step as recorded`;
5097
5252
  case "added":
5098
- return `${e.actionId}: added after filming; it is not in the video`;
5253
+ return `${e.actionId}: added after recording; it is not in the video`;
5099
5254
  case "removed":
5100
- return `${e.actionId}: removed after filming; the video still shows it`;
5255
+ return `${e.actionId}: removed after recording; the video still shows it`;
5101
5256
  }
5102
5257
  }
5103
- function editedClauses(edited2, takeId, undrawn, masks) {
5258
+ function editedClauses(edited2, takeId, masks) {
5104
5259
  const first = edited2[0];
5105
5260
  if (first === void 0)
5106
5261
  return [];
5107
5262
  const changed = edited2.find((e) => e.what === "kind");
5108
- const move = changed === void 0 ? ` \u2014 run({ takeId: "${takeId}" }) re-films it` : changed === first ? "" : ` \u2014 ${changed.actionId}'s step changed from ${changed.was ?? ""} to ${changed.now ?? ""}, so derive this take, check the step, and run the draft`;
5263
+ const move = changed === void 0 ? ` \u2014 run({ takeId: "${takeId}" }) re-records it` : changed === first ? "" : ` \u2014 ${changed.actionId}'s step changed from ${changed.was ?? ""} to ${changed.now ?? ""}, so derive this take, check the step, and run the draft`;
5109
5264
  return [
5110
- `${plural2(edited2.length, "step was", "steps were")} edited after filming (${editedWhat(first, undrawn)})${move}`,
5111
- ...masks > 0 ? [`a re-film leaves its ${plural2(masks, "mask", "masks")} behind`] : []
5265
+ `${plural2(edited2.length, "step was", "steps were")} edited after recording (${editedWhat(first)})${move}`,
5266
+ ...masks > 0 ? [`a re-recording leaves its ${plural2(masks, "mask", "masks")} behind`] : []
5112
5267
  ];
5113
5268
  }
5114
5269
  function withSummary(report) {
5115
5270
  return { ...report, summary: exportVerdict(report) };
5116
5271
  }
5117
5272
  function exportCaveats(report) {
5118
- const { logo, unavailableSpans, retexts: retexts2, editedSinceFilmed: editedSinceFilmed2, masks, unplacedStills, gifSize } = report.warnings;
5273
+ const { logo, unavailableSpans, migration, editedSinceRecorded: editedSinceRecorded2, masks, unplacedStills, gifSize } = report.warnings;
5119
5274
  return [
5120
5275
  ...logo === null ? [] : [`the logo is missing (${logo})`],
5121
5276
  ...unavailableSpans.length === 0 ? [] : [
5122
5277
  `${plural2(unavailableSpans.length, "stretch of motion is a still", "stretches of motion are stills")}`
5123
5278
  ],
5124
5279
  ...unplacedClauses(unplacedStills ?? []),
5125
- ...retextClauses(retexts2 ?? []),
5126
- ...editedClauses(editedSinceFilmed2 ?? [], report.takeId, new Set((retexts2 ?? []).filter((r) => r.kind === "notDrawn").map((r) => r.actionId)), masks ?? 0),
5280
+ // Each note is a whole sentence; a clause carries no period of its own.
5281
+ ...(migration ?? []).map((note) => note.replace(/\.$/, "")),
5282
+ ...editedClauses(editedSinceRecorded2 ?? [], report.takeId, masks ?? 0),
5127
5283
  ...gifOverBudget(gifSize, report.width)
5128
5284
  ];
5129
5285
  }
@@ -5280,6 +5436,7 @@ function checkLogoFile(file) {
5280
5436
 
5281
5437
  // ../../packages/run-core/dist/pull-requests.js
5282
5438
  var PULL_REQUESTS_VALUES = ["off", "ask", "attach"];
5439
+ var PULL_REQUESTS_DEFAULT = "ask";
5283
5440
  var isPullRequestsValue = (v) => typeof v === "string" && PULL_REQUESTS_VALUES.includes(v);
5284
5441
 
5285
5442
  // ../../packages/run-core/dist/refilm/skeleton.js
@@ -5331,6 +5488,8 @@ var VERBS2 = {
5331
5488
  hover: true,
5332
5489
  scrollTo: true,
5333
5490
  waitFor: true,
5491
+ // Its digest is the start's anchor: the end is re-measured from the script.
5492
+ drag: true,
5334
5493
  waitForLoad: true
5335
5494
  };
5336
5495
  var isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
@@ -5392,7 +5551,7 @@ function targetCheckOf(read) {
5392
5551
  return { unreadable: read.error };
5393
5552
  }
5394
5553
  }
5395
- function editedSinceFilmed(scene, madeFrom, read) {
5554
+ function editedSinceRecorded(scene, madeFrom, read) {
5396
5555
  if (madeFrom === null)
5397
5556
  return null;
5398
5557
  const filmed = new Map(madeFrom.map((m) => [m.actionId, m]));
@@ -5495,7 +5654,7 @@ function mergeSkeleton(derivation, read, options) {
5495
5654
  ok: false,
5496
5655
  reason: "invalidScript",
5497
5656
  field: `steps.${k}.do`,
5498
- detail: `step ${k + 1} was a ${s.do} when filmed and its action in scene.json is now a ${found.step.do}; a re-film does not guess which you meant \u2014 derive the take, write the step as you want it, and run that draft`
5657
+ detail: `step ${k + 1} was a ${s.do} when recorded and its action in scene.json is now a ${found.step.do}; a re-recording does not guess which you meant \u2014 derive the take, write the step as you want it, and run that draft`
5499
5658
  };
5500
5659
  }
5501
5660
  notes.push({
@@ -5554,11 +5713,11 @@ function mergeSkeleton(derivation, read, options) {
5554
5713
  function notCarriedOf(scene) {
5555
5714
  const e = scene.edits;
5556
5715
  return [
5557
- ...(e.cuts ?? []).map((c) => ({ kind: "cut", id: c.id })),
5716
+ ...(e.removed ?? []).map((r) => ({ kind: "removed", id: r.id })),
5717
+ ...(e.splits ?? []).map((p) => ({ kind: "split", id: p.id })),
5558
5718
  ...e.masks.map((m) => ({ kind: "mask", id: m.id })),
5559
5719
  ...e.holds.map((h) => ({ kind: "hold", id: h.id })),
5560
5720
  ...(e.gaps ?? []).map((g) => ({ kind: "gap", id: g.id })),
5561
- ...e.replacements.map((r) => ({ kind: "replacement", id: r.id })),
5562
5721
  ...e.trim?.head === void 0 ? [] : [{ kind: "trim", id: "head" }],
5563
5722
  ...e.trim?.tail === void 0 ? [] : [{ kind: "trim", id: "tail" }],
5564
5723
  // Only the editor writes a zoom's `point` (aimed where the author
@@ -5573,9 +5732,9 @@ function refilmScript(scene, read) {
5573
5732
  if (derivation.outcome === "nothingToDerive") {
5574
5733
  return {
5575
5734
  ok: false,
5576
- reason: "nothingToRefilm",
5735
+ reason: "nothingToRerecord",
5577
5736
  field: null,
5578
- detail: `take ${scene.meta.id} has no steps left in scene.json to film again`
5737
+ detail: `take ${scene.meta.id} has no steps left in scene.json to record again`
5579
5738
  };
5580
5739
  }
5581
5740
  const merged = mergeSkeleton(derivation, read, {
@@ -5590,7 +5749,7 @@ function refilmScript(scene, read) {
5590
5749
  ok: false,
5591
5750
  reason: "unfilledHoles",
5592
5751
  field: paths.join(", "),
5593
- detail: `${merged.holes.map((h) => h.sentence.trim()).join(" ")} A re-film never invents a value \u2014 derive the take, fill ${merged.holes.length === 1 ? "the hole" : "the holes"}, and run the draft`
5752
+ detail: `${merged.holes.map((h) => h.sentence.trim()).join(" ")} A re-recording never invents a value \u2014 derive the take, fill ${merged.holes.length === 1 ? "the hole" : "the holes"}, and run the draft`
5594
5753
  };
5595
5754
  }
5596
5755
  const { target, ...rest2 } = merged.draft;
@@ -5711,7 +5870,7 @@ function againstRecording(run2, recording) {
5711
5870
  if (trail.length === 0)
5712
5871
  cursor2 = { unavailable: "noTrail" };
5713
5872
  else if (markedAt === void 0)
5714
- cursor2 = { unavailable: "notInRunFilm" };
5873
+ cursor2 = { unavailable: "notInRunVideo" };
5715
5874
  else {
5716
5875
  const near = recorded === void 0 ? null : nearestSample(trail, recorded.timestamp);
5717
5876
  const runAt = sampleCursor(run2.bundle.cursorSamples, markedAt);
@@ -5734,9 +5893,9 @@ function againstRecording(run2, recording) {
5734
5893
  if (previous === null)
5735
5894
  pace = { unavailable: "firstStep" };
5736
5895
  else if (recNow === void 0 || recTimes.get(previous.recordedActionId) === void 0)
5737
- pace = { unavailable: "notInRecordingFilm" };
5896
+ pace = { unavailable: "notInRecordingVideo" };
5738
5897
  else if (runNow === void 0 || runTimes.get(previous.runActionId) === void 0)
5739
- pace = { unavailable: "notInRunFilm" };
5898
+ pace = { unavailable: "notInRunVideo" };
5740
5899
  else {
5741
5900
  const recordedGapMs = recNow - recTimes.get(previous.recordedActionId);
5742
5901
  const runGapMs = runNow - runTimes.get(previous.runActionId);
@@ -5776,13 +5935,23 @@ function visibleRegion(sampled, viewport, branding, target) {
5776
5935
  const x = Math.max(shot.x, 0);
5777
5936
  const y = Math.max(shot.y, 0);
5778
5937
  return {
5779
- x,
5780
- y,
5781
- width: Math.min(shot.x + shot.width, viewport.width) - x,
5782
- height: Math.min(shot.y + shot.height, viewport.height) - y
5938
+ visible: {
5939
+ x,
5940
+ y,
5941
+ width: Math.min(shot.x + shot.width, viewport.width) - x,
5942
+ height: Math.min(shot.y + shot.height, viewport.height) - y
5943
+ },
5944
+ shot
5783
5945
  };
5784
5946
  }
5785
- function framingOf(target, visible) {
5947
+ var BADNESS = {
5948
+ inside: 0,
5949
+ atEdge: 1,
5950
+ cutOff: 2,
5951
+ outOfFrame: 3
5952
+ };
5953
+ var worse = (a, b) => BADNESS[b] > BADNESS[a] ? b : a;
5954
+ function framingOf(target, visible, shot) {
5786
5955
  const left = target.x - visible.x;
5787
5956
  const top = target.y - visible.y;
5788
5957
  const right = visible.x + visible.width - (target.x + target.width);
@@ -5792,7 +5961,7 @@ function framingOf(target, visible) {
5792
5961
  return "outOfFrame";
5793
5962
  if (left < 0 || top < 0 || right < 0 || bottom < 0)
5794
5963
  return "cutOff";
5795
- return Math.min(left, top, right, bottom) < EDGE_MARGIN_PX ? "atEdge" : "inside";
5964
+ return Math.min(target.x - shot.x, target.y - shot.y, shot.x + shot.width - (target.x + target.width), shot.y + shot.height - (target.y + target.height)) < EDGE_MARGIN_PX ? "atEdge" : "inside";
5796
5965
  }
5797
5966
  var STILL_MS = 100;
5798
5967
  var MIN_JOURNEY_PX = 4;
@@ -5855,9 +6024,10 @@ function filmQuality(givenScene, givenBundle, paused = /* @__PURE__ */ new Map()
5855
6024
  const out = (sourceMs) => toOutputMs(resolved.timeline, sourceMs);
5856
6025
  const markerAt = new Map(bundle.markers.map((m) => [m.actionId, m.sourceTimeMs]));
5857
6026
  const rectAt = new Map(bundle.anchorRects.map((a) => [a.actionId, a.rect]));
6027
+ const endAt = new Map(bundle.anchorRects.flatMap((a) => a.end === void 0 ? [] : [[a.actionId, a.end]]));
5858
6028
  const heldAt = new Map(bundle.markers.flatMap((m) => m.roomHeldMs === void 0 ? [] : [[m.actionId, m.roomHeldMs]]));
5859
6029
  const roomAt = new Map(bundle.markers.flatMap((m) => m.roomMs === void 0 ? [] : [[m.actionId, m.roomMs]]));
5860
- const cut = new Set(scene.edits.cuts.map((c) => c.actionId));
6030
+ const cut = new Set(resolved.plan.removedSteps);
5861
6031
  const frame = landscapeFrame(scene.canvas.aspect, LANDSCAPE_1080P, bundle.viewport, scene.branding.padding);
5862
6032
  const steps3 = scene.actions.map((action) => {
5863
6033
  const blank = {
@@ -5874,7 +6044,7 @@ function filmQuality(givenScene, givenBundle, paused = /* @__PURE__ */ new Map()
5874
6044
  }
5875
6045
  const sourceMs = markerAt.get(action.id);
5876
6046
  if (sourceMs === void 0) {
5877
- return { ...blank, outputMs: null, unknown: "notInFilm", framing: null };
6047
+ return { ...blank, outputMs: null, unknown: "notInVideo", framing: null };
5878
6048
  }
5879
6049
  const outputMs = out(sourceMs);
5880
6050
  if (!VERBS[action.kind].cursorTravels) {
@@ -5884,12 +6054,22 @@ function filmQuality(givenScene, givenBundle, paused = /* @__PURE__ */ new Map()
5884
6054
  if (target === void 0) {
5885
6055
  return { ...blank, outputMs, unknown: "noRect", framing: null };
5886
6056
  }
5887
- const visible = visibleRegion(sampleCamera(resolved.cameraKeys, outputMs), bundle.viewport, scene.branding, frame);
6057
+ const { visible, shot } = visibleRegion(sampleTrack(resolved, outputMs), bundle.viewport, scene.branding, frame);
6058
+ const points = action.kind === "drag" ? dragPoints(action, target, endAt.get(action.id)) : null;
6059
+ const startRect = points === null ? target : pointRect(points.start);
6060
+ const endRect = points === null ? endAt.get(action.id) : pointRect(points.end);
6061
+ const label = framingOf(startRect, visible, shot);
6062
+ const end = endRect === void 0 ? void 0 : { label: framingOf(endRect, visible, shot), rect: endRect };
5888
6063
  return {
5889
6064
  ...blank,
5890
6065
  outputMs,
5891
6066
  unknown: null,
5892
- framing: { label: framingOf(target, visible), rect: target, visible }
6067
+ framing: {
6068
+ label: end === void 0 ? label : worse(label, end.label),
6069
+ rect: startRect,
6070
+ visible,
6071
+ ...end === void 0 ? {} : { end }
6072
+ }
5893
6073
  };
5894
6074
  });
5895
6075
  const removed = (ms) => resolved.timeline.cuts.some((c) => ms > c.srcStartMs && ms <= c.srcEndMs);
@@ -5907,6 +6087,17 @@ function filmQuality(givenScene, givenBundle, paused = /* @__PURE__ */ new Map()
5907
6087
  });
5908
6088
  }
5909
6089
  const travelling = steps3.filter((s) => VERBS[s.kind].cursorTravels && s.outputMs !== null).sort((a, b) => a.outputMs - b.outputMs);
6090
+ const dragEnds = steps3.flatMap((s) => {
6091
+ const held = bundle.heldPresses?.find((h) => h.actionId === s.actionId);
6092
+ return s.kind === "drag" && s.outputMs !== null && s.framing?.end !== void 0 && held !== void 0 ? [
6093
+ {
6094
+ actionId: s.actionId,
6095
+ outputMs: s.outputMs,
6096
+ releasedMs: out(held.releaseMs),
6097
+ end: s.framing.end.rect
6098
+ }
6099
+ ] : [];
6100
+ });
5910
6101
  const journeys = [];
5911
6102
  for (const run2 of groups.flatMap(splitJourneys)) {
5912
6103
  let travelledPx = 0;
@@ -5918,8 +6109,9 @@ function filmQuality(givenScene, givenBundle, paused = /* @__PURE__ */ new Map()
5918
6109
  const last = run2[run2.length - 1];
5919
6110
  const chord = dist(first, last);
5920
6111
  const detourPx = Math.max(...run2.map((p) => offChord(p, first, last)));
5921
- const next = travelling.find((s) => s.outputMs >= last.t) ?? null;
5922
- const nextRect = next === null ? void 0 : rectAt.get(next.actionId);
6112
+ const dragged = dragEnds.find((d) => first.t >= d.outputMs && first.t <= d.releasedMs && contains(inflate(d.end, ARRIVAL_SLACK_PX), last));
6113
+ const next = dragged === void 0 ? travelling.find((s) => s.outputMs >= last.t) ?? null : { actionId: dragged.actionId };
6114
+ const nextRect = dragged !== void 0 ? dragged.end : next === null ? void 0 : rectAt.get(next.actionId);
5923
6115
  const onTarget = nextRect !== void 0 && contains(inflate(nextRect, ARRIVAL_SLACK_PX), last);
5924
6116
  journeys.push({
5925
6117
  fromOutputMs: first.t,
@@ -5977,7 +6169,7 @@ function filmForRun(args2) {
5977
6169
  try {
5978
6170
  return filmQuality(args2.scene, args2.bundle, args2.paused);
5979
6171
  } catch (error) {
5980
- console.error("demoman run: the film check failed", error);
6172
+ console.error("demoman run: the video check failed", error);
5981
6173
  return {
5982
6174
  unavailable: "checkFailed",
5983
6175
  error: error instanceof Error ? error.message : String(error)
@@ -6026,7 +6218,7 @@ function recordingForRun(args2) {
6026
6218
  return args2.loaded.report;
6027
6219
  const { scene, bundle } = args2.run;
6028
6220
  if (scene === null || bundle === null)
6029
- return { unavailable: "noRunFilm" };
6221
+ return { unavailable: "noRunVideo" };
6030
6222
  try {
6031
6223
  return againstRecording({ scene, bundle, links: args2.run.links, unlinked: args2.run.unlinked }, args2.loaded);
6032
6224
  } catch (error) {
@@ -6295,10 +6487,13 @@ var CLICK_PROBE_INSTALL = `function(token){
6295
6487
  : () => undefined;
6296
6488
  const onDown = (e) => { if (e.isTrusted && seen.down === null) { seen.down = point(e); report(); } };
6297
6489
  const onUp = (e) => { if (e.isTrusted && seen.up === null) { seen.up = point(e); report(); } };
6490
+ // A native drag ends in a drop, not a pointerup: it is the release.
6491
+ const onDrop = (e) => { if (e.isTrusted && seen.up === null) { seen.up = point(e); report(); } };
6298
6492
  const onCancel = (e) => { if (e.isTrusted) { seen.cancelled = true; report(); } };
6299
6493
  view.addEventListener("pointerdown", onDown, true);
6300
6494
  view.addEventListener("pointerup", onUp, true);
6301
6495
  view.addEventListener("pointercancel", onCancel, true);
6496
+ view.addEventListener("drop", onDrop, true);
6302
6497
  const target = this;
6303
6498
  return {
6304
6499
  measure() { own = rect(); },
@@ -6306,6 +6501,7 @@ var CLICK_PROBE_INSTALL = `function(token){
6306
6501
  view.removeEventListener("pointerdown", onDown, true);
6307
6502
  view.removeEventListener("pointerup", onUp, true);
6308
6503
  view.removeEventListener("pointercancel", onCancel, true);
6504
+ view.removeEventListener("drop", onDrop, true);
6309
6505
  const root = target.getRootNode();
6310
6506
  const active = root && root.activeElement;
6311
6507
  // A label passes its click to its control, so a type aimed at the
@@ -6336,18 +6532,39 @@ function pagePointOf(sent, box, own) {
6336
6532
  };
6337
6533
  }
6338
6534
  function clickVerdict(seen, expected, scale = { x: 1, y: 1 }) {
6339
- if (seen.cancelled) {
6535
+ return judge(seen, expected, expected, scale, `sent to ${at(expected)}`, null);
6536
+ }
6537
+ function dragVerdict(seen, start, end, scale = { x: 1, y: 1 }, touch = false) {
6538
+ return judge(seen, start, end, scale, `sent from ${at(start)} to ${at(end)}`, touch ? "touch" : "mouse");
6539
+ }
6540
+ function judge(seen, press, release, scale, sent, dragging) {
6541
+ if (dragging === "touch" && seen.cancelled) {
6542
+ return {
6543
+ kind: "unconfirmed",
6544
+ why: "the browser cancelled the touch, taking it as its own scroll or zoom (the page's touch-action), so the page never saw the drag",
6545
+ seen
6546
+ };
6547
+ }
6548
+ if (dragging === "mouse" && seen.cancelled && seen.up === null) {
6549
+ return {
6550
+ kind: "unconfirmed",
6551
+ why: "the drag began, and nothing at its end accepted the drop",
6552
+ seen
6553
+ };
6554
+ }
6555
+ if (seen.cancelled && !(dragging === "mouse" && seen.up !== null)) {
6340
6556
  return {
6341
6557
  kind: "unconfirmed",
6342
6558
  why: "the browser cancelled the pointer, so no click was dispatched to check",
6343
6559
  seen
6344
6560
  };
6345
6561
  }
6346
- if (expected.x < 0 || expected.y < 0 || expected.x > seen.viewport.width || expected.y > seen.viewport.height) {
6562
+ const outside = (p) => p.x < 0 || p.y < 0 || p.x > seen.viewport.width || p.y > seen.viewport.height;
6563
+ if (outside(press) || outside(release)) {
6347
6564
  return {
6348
6565
  kind: "misdelivered",
6349
6566
  seen,
6350
- why: `sent to ${at(expected)}, outside the page's ${Math.round(seen.viewport.width)}x${Math.round(seen.viewport.height)} viewport \u2014 the target is off screen \u2014 so it reached nothing`
6567
+ why: `${sent}, outside the page's ${Math.round(seen.viewport.width)}x${Math.round(seen.viewport.height)} viewport \u2014 the target is off screen \u2014 so it reached nothing`
6351
6568
  };
6352
6569
  }
6353
6570
  const { down, up } = seen;
@@ -6358,10 +6575,10 @@ function clickVerdict(seen, expected, scale = { x: 1, y: 1 }) {
6358
6575
  seen
6359
6576
  };
6360
6577
  }
6361
- const far = (p) => Math.abs(p.x - expected.x) / scale.x > CLICK_DRIFT_PX || Math.abs(p.y - expected.y) / scale.y > CLICK_DRIFT_PX;
6578
+ const far = (p, expected) => Math.abs(p.x - expected.x) / scale.x > CLICK_DRIFT_PX || Math.abs(p.y - expected.y) / scale.y > CLICK_DRIFT_PX;
6362
6579
  const arrival = (p) => p === null ? "was never seen" : `arrived at ${at(p)}`;
6363
- const said = `sent to ${at(expected)}, the press ${arrival(down)} and the release ${arrival(up)}`;
6364
- if (down !== null && far(down) || up !== null && far(up)) {
6580
+ const said = `${sent}, the press ${arrival(down)} and the release ${arrival(up)}`;
6581
+ if (down !== null && far(down, press) || up !== null && far(up, release)) {
6365
6582
  return { kind: "misdelivered", seen, why: said };
6366
6583
  }
6367
6584
  if (down === null || up === null) {
@@ -6482,7 +6699,7 @@ async function discardClickProbe(cdp, probe) {
6482
6699
  return;
6483
6700
  await readClickProbe(cdp, probe, { x: 0, y: 0 });
6484
6701
  }
6485
- async function readClickProbe(cdp, probe, sent, sightings = null) {
6702
+ async function readClickProbe(cdp, probe, sent, sightings = null, drag = null) {
6486
6703
  if ("unplaced" in probe) {
6487
6704
  return {
6488
6705
  kind: "unconfirmed",
@@ -6523,6 +6740,10 @@ async function readClickProbe(cdp, probe, sent, sightings = null) {
6523
6740
  };
6524
6741
  }
6525
6742
  const expected = pagePointOf(sent, probe.box, value.own);
6743
+ if (drag !== null) {
6744
+ const end = pagePointOf(drag.releasedAt, probe.box, value.own);
6745
+ return dragVerdict(value, expected, end, expected.scale, drag.touch);
6746
+ }
6526
6747
  return clickVerdict(value, expected, expected.scale);
6527
6748
  }
6528
6749
  function isPoint(v) {
@@ -6584,6 +6805,238 @@ async function applyDevice(cdp, device, scale = 1) {
6584
6805
  });
6585
6806
  }
6586
6807
 
6808
+ // ../../packages/replay-engine/dist/drag.js
6809
+ var DRAG_LEAD_STEPS = 3;
6810
+ var DRAG_LEAD_PX = 3;
6811
+ function rangeThumb(rect2, input) {
6812
+ const span = input.max - input.min;
6813
+ const along2 = span === 0 ? 0 : Math.min(1, Math.max(0, (input.value - input.min) / span));
6814
+ const f = input.reversed ? 1 - along2 : along2;
6815
+ return input.vertical ? { x: rect2.x + rect2.width / 2, y: rect2.y + rect2.height * f } : { x: rect2.x + rect2.width * f, y: rect2.y + rect2.height / 2 };
6816
+ }
6817
+ function heldPath(start, end, actionId) {
6818
+ const length = Math.hypot(end.x - start.x, end.y - start.y);
6819
+ const ux = length === 0 ? 0 : (end.x - start.x) / length;
6820
+ const uy = length === 0 ? 0 : (end.y - start.y) / length;
6821
+ const lead = Array.from({ length: DRAG_LEAD_STEPS }, (_, i) => ({
6822
+ x: start.x + ux * DRAG_LEAD_PX * (i + 1),
6823
+ y: start.y + uy * DRAG_LEAD_PX * (i + 1)
6824
+ }));
6825
+ const from = lead[lead.length - 1] ?? start;
6826
+ const planned = planCursorSegment({
6827
+ from,
6828
+ to: end,
6829
+ index: 0,
6830
+ fromActionId: actionId,
6831
+ toActionId: actionId
6832
+ });
6833
+ const mid = { x: (from.x + end.x) / 2, y: (from.y + end.y) / 2 };
6834
+ return { lead, segment: { ...planned, via: [from, mid, end] } };
6835
+ }
6836
+ function inViewport(p, viewport) {
6837
+ return p.x >= 0 && p.y >= 0 && p.x <= viewport.width && p.y <= viewport.height;
6838
+ }
6839
+ var DRAG_WATCH_INSTALL = `function (box) {
6840
+ const doc = this.ownerDocument;
6841
+ // The drag's bounds, widened by a cursor's reach: a drop target's hover
6842
+ // highlight sits on the target's own box, at the edge of the bounds.
6843
+ const pad = 24;
6844
+ const meets = (r) =>
6845
+ r.right > box.x - pad && r.left < box.x + box.width + pad &&
6846
+ r.bottom > box.y - pad && r.top < box.y + box.height + pad;
6847
+ // A canvas's pixels under the drag only, copied into a canvas of ours and
6848
+ // read there: no PNG encode of a page-sized canvas on the page's thread
6849
+ // (review of 2026-10-21), and no context asked of the page's own canvas,
6850
+ // which would create one a WebGL page could then never get. Null when it
6851
+ // cannot be read: a canvas another origin's image tainted.
6852
+ const regionOf = (c) => {
6853
+ const r = c.getBoundingClientRect();
6854
+ const sx = c.width / r.width;
6855
+ const sy = c.height / r.height;
6856
+ const left = Math.max(r.left, box.x - pad);
6857
+ const top = Math.max(r.top, box.y - pad);
6858
+ const right = Math.min(r.right, box.x + box.width + pad);
6859
+ const bottom = Math.min(r.bottom, box.y + box.height + pad);
6860
+ return {
6861
+ x: Math.floor((left - r.left) * sx),
6862
+ y: Math.floor((top - r.top) * sy),
6863
+ w: Math.max(1, Math.ceil((right - left) * sx)),
6864
+ h: Math.max(1, Math.ceil((bottom - top) * sy)),
6865
+ };
6866
+ };
6867
+ const read = (c, g) => {
6868
+ const ours = doc.createElement("canvas");
6869
+ ours.width = g.w;
6870
+ ours.height = g.h;
6871
+ const ctx = ours.getContext("2d");
6872
+ try {
6873
+ ctx.drawImage(c, g.x, g.y, g.w, g.h, 0, 0, g.w, g.h);
6874
+ return ctx.getImageData(0, 0, g.w, g.h).data;
6875
+ } catch {
6876
+ return null;
6877
+ }
6878
+ };
6879
+ const watch = { changed: false, read };
6880
+ watch.canvases = [...doc.querySelectorAll("canvas")]
6881
+ .filter((c) => {
6882
+ const r = c.getBoundingClientRect();
6883
+ return c.width > 0 && c.height > 0 && r.width > 0 && r.height > 0 && meets(r);
6884
+ })
6885
+ .map((c) => {
6886
+ const g = regionOf(c);
6887
+ return { c, g, before: read(c, g) };
6888
+ });
6889
+ const mark = () => { watch.changed = true; };
6890
+ // The drag's own picture (\`DRAG_PICTURE_SHOW\`) is ours, not the page's.
6891
+ const ours = (n) => n instanceof Element && n.closest("[data-demoman-drag]") !== null;
6892
+ // Only what changed where the drag happened: a live page changes on its
6893
+ // own elsewhere (a clock, a toast, a carousel), and counting that read a
6894
+ // drag the page ignored as done (final review, finding 5). Each change is
6895
+ // judged by the node it made \u2014 never by its parent, whose box (the body,
6896
+ // an app's root) overlaps every drag (review of 2026-10-21). A removed
6897
+ // node is judged by its neighbours, where it was, else by a parent it was
6898
+ // alone in.
6899
+ const boxOf = (n) => {
6900
+ if (!n || !n.isConnected) return null;
6901
+ if (n instanceof Element) return n.getBoundingClientRect();
6902
+ if (n instanceof Text) {
6903
+ const range = doc.createRange();
6904
+ range.selectNodeContents(n);
6905
+ return range.getBoundingClientRect();
6906
+ }
6907
+ return null;
6908
+ };
6909
+ const near = (n) => {
6910
+ const r = boxOf(n);
6911
+ return r !== null && meets(r);
6912
+ };
6913
+ const observer = new MutationObserver((records) => {
6914
+ for (const r of records) {
6915
+ if (ours(r.target) || [...r.addedNodes, ...r.removedNodes].some(ours)) continue;
6916
+ const touched =
6917
+ r.type !== "childList"
6918
+ ? near(r.target)
6919
+ : [...r.addedNodes].some(near) ||
6920
+ (r.removedNodes.length > 0 &&
6921
+ (r.previousSibling || r.nextSibling
6922
+ ? near(r.previousSibling) || near(r.nextSibling)
6923
+ : near(r.target)));
6924
+ if (touched) return mark();
6925
+ }
6926
+ });
6927
+ observer.observe(doc, { subtree: true, childList: true, attributes: true, characterData: true });
6928
+ // A scroll of the document moves everything under the drag; an element's
6929
+ // scroll, or a field's input, counts where that element is.
6930
+ const kinds = ["scroll", "input", "change"];
6931
+ const heard = (e) => {
6932
+ if (e.target === doc || e.target === doc.defaultView || near(e.target)) mark();
6933
+ };
6934
+ for (const k of kinds) doc.addEventListener(k, heard, true);
6935
+ watch.stop = () => {
6936
+ observer.disconnect();
6937
+ for (const k of kinds) doc.removeEventListener(k, heard, true);
6938
+ };
6939
+ return watch;
6940
+ }`;
6941
+ var DRAG_WATCH_READ = `function () {
6942
+ this.stop();
6943
+ if (this.changed) return { changed: true, unknown: false };
6944
+ let unknown = false;
6945
+ for (const { c, g, before } of this.canvases) {
6946
+ const after = this.read(c, g);
6947
+ if (before === null || after === null) { unknown = true; continue; }
6948
+ if (after.length !== before.length) return { changed: true, unknown: false };
6949
+ for (let i = 0; i < after.length; i++) {
6950
+ if (after[i] !== before[i]) return { changed: true, unknown: false };
6951
+ }
6952
+ if (after.every((v) => v === 0)) unknown = true;
6953
+ }
6954
+ return { changed: false, unknown };
6955
+ }`;
6956
+ var DRAG_PICTURE_INSTALL = `function () {
6957
+ const view = this.ownerDocument.defaultView;
6958
+ const state = { image: null, source: null };
6959
+ view.__demomanDrag = state;
6960
+ if (!view.__demomanDragWrapped) {
6961
+ view.__demomanDragWrapped = true;
6962
+ const original = view.DataTransfer.prototype.setDragImage;
6963
+ view.DataTransfer.prototype.setDragImage = function (element, x, y) {
6964
+ if (view.__demomanDrag) view.__demomanDrag.image = { element, x, y };
6965
+ return original.call(this, element, x, y);
6966
+ };
6967
+ }
6968
+ view.addEventListener("dragstart", (e) => {
6969
+ const el = e.target instanceof view.Element ? e.target : null;
6970
+ if (el === null) return;
6971
+ const r = el.getBoundingClientRect();
6972
+ state.source = { element: el, x: e.clientX - r.left, y: e.clientY - r.top };
6973
+ }, { capture: true, once: true });
6974
+ }`;
6975
+ var DRAG_PICTURE_SHOW = `function (x, y) {
6976
+ const doc = this.ownerDocument;
6977
+ const view = doc.defaultView;
6978
+ const state = view.__demomanDrag;
6979
+ const declared = state && (state.image || state.source);
6980
+ if (!declared || !declared.element) return "the page named no element for its drag picture";
6981
+ const el = declared.element;
6982
+ const r = el.getBoundingClientRect();
6983
+ let copy;
6984
+ if (el instanceof view.HTMLCanvasElement) {
6985
+ copy = doc.createElement("img");
6986
+ copy.src = el.toDataURL();
6987
+ } else {
6988
+ copy = el.cloneNode(true);
6989
+ copy.removeAttribute("id");
6990
+ // With its computed look, element by element: outside the page's own
6991
+ // tree it inherits no font and matches no descendant selector (final
6992
+ // review, finding 6: a card drew in the default serif).
6993
+ // shortcut: the first 300 elements only, for a huge picture; upgrade to
6994
+ // a canvas snapshot if a demo drags something that big.
6995
+ let budget = 300;
6996
+ const dress = (from, to) => {
6997
+ if (budget-- <= 0 || !(to instanceof view.Element)) return;
6998
+ const cs = view.getComputedStyle(from);
6999
+ for (let i = 0; i < cs.length; i++) {
7000
+ to.style.setProperty(cs[i], cs.getPropertyValue(cs[i]));
7001
+ }
7002
+ // Never the drop target: a copied \`pointer-events: auto\` would take
7003
+ // the drop meant for the page under it.
7004
+ to.style.setProperty("pointer-events", "none");
7005
+ for (let i = 0; i < from.children.length; i++) {
7006
+ dress(from.children[i], to.children[i]);
7007
+ }
7008
+ };
7009
+ dress(el, copy);
7010
+ }
7011
+ copy.style.position = "static";
7012
+ copy.style.margin = "0";
7013
+ copy.style.width = r.width + "px";
7014
+ copy.style.height = r.height + "px";
7015
+ const frame = doc.createElement("div");
7016
+ frame.setAttribute("data-demoman-drag", "");
7017
+ frame.style.cssText =
7018
+ "position:fixed;pointer-events:none;opacity:0.7;z-index:2147483647;margin:0;";
7019
+ frame.append(copy);
7020
+ frame.__grab = { x: declared.x, y: declared.y };
7021
+ frame.style.left = x - declared.x + "px";
7022
+ frame.style.top = y - declared.y + "px";
7023
+ doc.documentElement.append(frame);
7024
+ return null;
7025
+ }`;
7026
+ var DRAG_PICTURE_MOVE = `function (x, y) {
7027
+ const frame = this.ownerDocument.querySelector("[data-demoman-drag]");
7028
+ if (frame === null) return;
7029
+ frame.style.left = x - frame.__grab.x + "px";
7030
+ frame.style.top = y - frame.__grab.y + "px";
7031
+ }`;
7032
+ var DRAG_PICTURE_REMOVE = `function () {
7033
+ const doc = this.ownerDocument;
7034
+ for (const f of doc.querySelectorAll("[data-demoman-drag]")) f.remove();
7035
+ const view = doc.defaultView;
7036
+ if (view) view.__demomanDrag = null;
7037
+ return doc.querySelectorAll("[data-demoman-drag]").length;
7038
+ }`;
7039
+
6587
7040
  // ../../packages/replay-engine/dist/image.js
6588
7041
  function decodeBase64(data) {
6589
7042
  const binary = atob(data);
@@ -7135,6 +7588,17 @@ function settlePaintExpression(timeoutMs, quietTimeoutMs = SETTLE_QUIET_TIMEOUT_
7135
7588
  }
7136
7589
 
7137
7590
  // ../../packages/replay-engine/dist/walk.js
7591
+ var RANGE_READ = `function () {
7592
+ if (!(this instanceof HTMLInputElement) || this.type !== "range") return null;
7593
+ const style = getComputedStyle(this);
7594
+ return {
7595
+ value: Number(this.value),
7596
+ min: this.min === "" ? 0 : Number(this.min),
7597
+ max: this.max === "" ? 100 : Number(this.max),
7598
+ vertical: style.writingMode.startsWith("vertical"),
7599
+ reversed: style.direction === "rtl",
7600
+ };
7601
+ }`;
7138
7602
  var PATH_STEP_MS = 8;
7139
7603
  var NO_STEPS = {
7140
7604
  async *[Symbol.asyncIterator]() {
@@ -7210,6 +7674,8 @@ async function runWalk(source, deps, config) {
7210
7674
  let pendingAct = null;
7211
7675
  let latestActEnd = null;
7212
7676
  let roomAdded = 0;
7677
+ let lastHeldUntil = null;
7678
+ let lastZoom = null;
7213
7679
  const keyframes = [];
7214
7680
  const motionSpans = [];
7215
7681
  const cursorSamples = [];
@@ -7221,6 +7687,8 @@ async function runWalk(source, deps, config) {
7221
7687
  let completed = 0;
7222
7688
  let lastCompletedActionId = null;
7223
7689
  const unconfirmedClicks = [];
7690
+ const heldPresses = [];
7691
+ const ignoredDrags = [];
7224
7692
  let inFlight = null;
7225
7693
  let reason = null;
7226
7694
  let hoverSensitive = config.hoverSensitive;
@@ -7504,6 +7972,249 @@ async function runWalk(source, deps, config) {
7504
7972
  }
7505
7973
  cursor2 = to;
7506
7974
  };
7975
+ const performDrag = async (actionId, plan, objectId, touch) => {
7976
+ const watchChanges = async (probeObjectId) => {
7977
+ const box = {
7978
+ x: Math.min(plan.start.x, plan.endRect.x),
7979
+ y: Math.min(plan.start.y, plan.endRect.y),
7980
+ width: 0,
7981
+ height: 0
7982
+ };
7983
+ box.width = Math.max(plan.start.x, plan.endRect.x + plan.endRect.width) - box.x;
7984
+ box.height = Math.max(plan.start.y, plan.endRect.y + plan.endRect.height) - box.y;
7985
+ let watchId = null;
7986
+ try {
7987
+ const reply = await cdp.send("Runtime.callFunctionOn", {
7988
+ objectId: probeObjectId,
7989
+ functionDeclaration: DRAG_WATCH_INSTALL,
7990
+ arguments: [{ value: box }],
7991
+ returnByValue: false
7992
+ });
7993
+ watchId = reply.result?.objectId ?? null;
7994
+ } catch {
7995
+ watchId = null;
7996
+ }
7997
+ return async () => {
7998
+ if (watchId === null)
7999
+ return null;
8000
+ try {
8001
+ const reply = await cdp.send("Runtime.callFunctionOn", {
8002
+ objectId: watchId,
8003
+ functionDeclaration: DRAG_WATCH_READ,
8004
+ returnByValue: true
8005
+ });
8006
+ return reply.result?.value ?? null;
8007
+ } catch {
8008
+ return null;
8009
+ }
8010
+ };
8011
+ };
8012
+ const point2 = (p) => ({
8013
+ x: p.x,
8014
+ y: p.y,
8015
+ radiusX: 4,
8016
+ radiusY: 4,
8017
+ force: 1,
8018
+ id: 0
8019
+ });
8020
+ let dragData = null;
8021
+ let native = false;
8022
+ const offIntercept = touch ? () => void 0 : cdp.on("Input.dragIntercepted", (params) => {
8023
+ dragData = params.data ?? {};
8024
+ });
8025
+ const onPage = (fn, args2 = []) => cdp.send("Runtime.callFunctionOn", {
8026
+ objectId,
8027
+ functionDeclaration: fn,
8028
+ arguments: args2.map((value) => ({ value })),
8029
+ returnByValue: true
8030
+ });
8031
+ const pictureSays = (reply) => reply.result?.value;
8032
+ let pictureShown = false;
8033
+ const move = async (p) => {
8034
+ if (native) {
8035
+ await cdp.send("Input.dispatchDragEvent", {
8036
+ type: "dragOver",
8037
+ x: p.x,
8038
+ y: p.y,
8039
+ data: dragData
8040
+ });
8041
+ if (pictureShown)
8042
+ await onPage(DRAG_PICTURE_MOVE, [p.x, p.y]);
8043
+ } else if (touch) {
8044
+ await cdp.send("Input.dispatchTouchEvent", {
8045
+ type: "touchMove",
8046
+ touchPoints: [point2(p)]
8047
+ });
8048
+ } else {
8049
+ await cdp.send("Input.dispatchMouseEvent", {
8050
+ type: "mouseMoved",
8051
+ x: p.x,
8052
+ y: p.y,
8053
+ button: "left",
8054
+ buttons: 1
8055
+ });
8056
+ if (dragData !== null) {
8057
+ native = true;
8058
+ await cdp.send("Input.dispatchDragEvent", {
8059
+ type: "dragEnter",
8060
+ x: p.x,
8061
+ y: p.y,
8062
+ data: dragData
8063
+ });
8064
+ let why2;
8065
+ try {
8066
+ why2 = pictureSays(await onPage(DRAG_PICTURE_SHOW, [p.x, p.y]));
8067
+ } catch (error) {
8068
+ why2 = error instanceof Error ? error.message : String(error);
8069
+ }
8070
+ pictureShown = why2 === null;
8071
+ if (!pictureShown) {
8072
+ degradations.push(degradation("dragPictureMissing", at2(), at2(), `a native drag's picture could not be drawn: ${String(why2)}`));
8073
+ }
8074
+ }
8075
+ }
8076
+ cursorSamples.push({ sourceTimeMs: at2(), x: p.x, y: p.y });
8077
+ };
8078
+ const probe = await placeClickProbe(cdp, objectId, actionId);
8079
+ const changes = await watchChanges(objectId);
8080
+ let pressMs;
8081
+ try {
8082
+ if (!touch) {
8083
+ await onPage(DRAG_PICTURE_INSTALL);
8084
+ await cdp.send("Input.setInterceptDrags", { enabled: true });
8085
+ }
8086
+ await (touch ? cdp.send("Input.dispatchTouchEvent", {
8087
+ type: "touchStart",
8088
+ touchPoints: [point2(plan.start)]
8089
+ }) : cdp.send("Input.dispatchMouseEvent", {
8090
+ type: "mousePressed",
8091
+ x: plan.start.x,
8092
+ y: plan.start.y,
8093
+ button: "left",
8094
+ buttons: 1,
8095
+ clickCount: 1
8096
+ }));
8097
+ pressMs = at2();
8098
+ cursorSamples.push({ sourceTimeMs: pressMs, ...plan.start });
8099
+ const { lead, segment } = heldPath(plan.start, plan.end, actionId);
8100
+ for (const p of lead) {
8101
+ await move(p);
8102
+ await clock.sleep(PATH_STEP_MS);
8103
+ }
8104
+ const begun = at2();
8105
+ let sentAt = begun;
8106
+ for (; ; ) {
8107
+ const elapsed = sentAt - begun;
8108
+ await move(pathPointAt(segment, elapsed));
8109
+ if (elapsed >= segment.durationMs)
8110
+ break;
8111
+ const wait2 = PATH_STEP_MS - (at2() - sentAt);
8112
+ if (wait2 > 0)
8113
+ await clock.sleep(wait2);
8114
+ sentAt = at2();
8115
+ }
8116
+ await clock.sleep(SETTLE_MS);
8117
+ await (native ? cdp.send("Input.dispatchDragEvent", {
8118
+ type: "drop",
8119
+ x: plan.end.x,
8120
+ y: plan.end.y,
8121
+ data: dragData
8122
+ }) : touch ? cdp.send("Input.dispatchTouchEvent", {
8123
+ type: "touchEnd",
8124
+ touchPoints: []
8125
+ }) : cdp.send("Input.dispatchMouseEvent", {
8126
+ type: "mouseReleased",
8127
+ x: plan.end.x,
8128
+ y: plan.end.y,
8129
+ button: "left",
8130
+ buttons: 0,
8131
+ clickCount: 1
8132
+ }));
8133
+ } catch (error) {
8134
+ await discardClickProbe(cdp, probe);
8135
+ throw error;
8136
+ } finally {
8137
+ offIntercept();
8138
+ if (!touch) {
8139
+ await cdp.send("Input.setInterceptDrags", { enabled: false }).catch(() => void 0);
8140
+ }
8141
+ if (pictureShown) {
8142
+ let left;
8143
+ try {
8144
+ left = pictureSays(await onPage(DRAG_PICTURE_REMOVE));
8145
+ } catch {
8146
+ left = 0;
8147
+ }
8148
+ if (left !== 0) {
8149
+ degradations.push(degradation("dragPictureMissing", at2(), at2(), `a native drag's picture could not be removed after its drop (${String(left)} left on the page)`));
8150
+ }
8151
+ }
8152
+ }
8153
+ const releaseMs = at2();
8154
+ heldPresses.push({ actionId, pressMs, releaseMs });
8155
+ cursor2 = plan.end;
8156
+ const verdict = await readClickProbe(cdp, probe, plan.start, sightings, {
8157
+ releasedAt: plan.end,
8158
+ touch
8159
+ });
8160
+ const seen = await changes();
8161
+ if (native && verdict.kind === "unconfirmed" && verdict.seen?.cancelled === true && verdict.seen.up === null) {
8162
+ const note = `a native drag to (${Math.round(plan.end.x)}, ${Math.round(plan.end.y)}) found nothing there that accepted the drop`;
8163
+ degradations.push(degradation("notDragged", pressMs, releaseMs, note));
8164
+ ignoredDrags.push({ actionId, note });
8165
+ }
8166
+ if (verdict.kind === "delivered") {
8167
+ if (seen !== null && !seen.changed && !seen.unknown) {
8168
+ const note = `the drag from (${Math.round(plan.start.x)}, ${Math.round(plan.start.y)}) to (${Math.round(plan.end.x)}, ${Math.round(plan.end.y)}) reached the page, and nothing on screen between its ends changed`;
8169
+ degradations.push(degradation("notDragged", pressMs, releaseMs, note));
8170
+ ignoredDrags.push({ actionId, note });
8171
+ }
8172
+ }
8173
+ return verdict;
8174
+ };
8175
+ const planDrag = async (handle, drag) => {
8176
+ let start = spotIn(handle.rect, drag.fromAt);
8177
+ let pressedAt;
8178
+ if (drag.fromAt === void 0) {
8179
+ const reply = await cdp.send("Runtime.callFunctionOn", {
8180
+ objectId: handle.objectId,
8181
+ functionDeclaration: RANGE_READ,
8182
+ returnByValue: true
8183
+ });
8184
+ const range = reply.result?.value;
8185
+ if (range !== null && range !== void 0) {
8186
+ start = rangeThumb(handle.rect, range);
8187
+ const { x, y, width, height } = handle.rect;
8188
+ const part = (v, size) => size > 0 ? Math.min(1, Math.max(0, v / size)) : 0.5;
8189
+ pressedAt = {
8190
+ x: part(start.x - x, width),
8191
+ y: part(start.y - y, height)
8192
+ };
8193
+ }
8194
+ }
8195
+ let endRect = null;
8196
+ if (!("by" in drag.to)) {
8197
+ if (drag.end === null)
8198
+ return { stop: "unresolvedAnchor" };
8199
+ const located = await locate(drag.end);
8200
+ if (located.handle === null) {
8201
+ return { stop: stopForResolveFailure(located.failureReason) };
8202
+ }
8203
+ endRect = located.handle.rect;
8204
+ }
8205
+ const end = dragEndPoint(start, drag.to, endRect);
8206
+ if (end === null)
8207
+ return { stop: "unresolvedAnchor" };
8208
+ endRect ??= { x: end.x, y: end.y, width: 0, height: 0 };
8209
+ if (!inViewport(start, viewport) || !inViewport(end, viewport)) {
8210
+ return { stop: "dragEndOutOfView" };
8211
+ }
8212
+ if (Math.hypot(end.x - start.x, end.y - start.y) < 2 * CLICK_DRIFT_PX) {
8213
+ return { stop: "dragNoDistance" };
8214
+ }
8215
+ drag.onEnd?.(endRect, pressedAt);
8216
+ return { start, end, endRect };
8217
+ };
7507
8218
  const settlePaint = async () => {
7508
8219
  let reply;
7509
8220
  try {
@@ -7572,6 +8283,10 @@ async function runWalk(source, deps, config) {
7572
8283
  if (anchorRects[i]?.actionId === id)
7573
8284
  anchorRects.splice(i, 1);
7574
8285
  }
8286
+ for (let i = heldPresses.length - 1; i >= 0; i--) {
8287
+ if (heldPresses[i]?.actionId === id)
8288
+ heldPresses.splice(i, 1);
8289
+ }
7575
8290
  for (const k of keyframes)
7576
8291
  if (k.actionId === id)
7577
8292
  k.actionId = null;
@@ -7601,7 +8316,7 @@ async function runWalk(source, deps, config) {
7601
8316
  if (verdict === null || verdict.kind === "delivered")
7602
8317
  return false;
7603
8318
  const actionId = inFlight ?? "";
7604
- const subject = kind === "click" ? "the click" : `the ${kind}'s click`;
8319
+ const subject = kind === "click" ? "the click" : kind === "drag" ? "the drag" : `the ${kind}'s click`;
7605
8320
  const said = (note) => {
7606
8321
  degradations.push(degradation("clickUnconfirmed", at2(), at2(), note));
7607
8322
  unconfirmedClicks.push({ actionId, note });
@@ -7734,42 +8449,71 @@ async function runWalk(source, deps, config) {
7734
8449
  reason = "redactedWithoutReplacement";
7735
8450
  break;
7736
8451
  }
8452
+ let dragPlan = null;
8453
+ if (step.action.kind === "drag") {
8454
+ if (step.drag === void 0) {
8455
+ throw new Error("the walk was handed a drag with no ends");
8456
+ }
8457
+ const planned = await planDrag(handle, step.drag);
8458
+ if ("stop" in planned) {
8459
+ reason = planned.stop;
8460
+ break;
8461
+ }
8462
+ dragPlan = planned;
8463
+ }
7737
8464
  const segment = step.segment;
7738
- if (room !== void 0 && step.action.kind === "click") {
7739
- const ahead = (segment === void 0 ? 0 : retargetSegment(segment, cursor2, rectCentre(handle.rect)).durationMs) + SETTLE_MS;
8465
+ const rhythmDue = () => {
8466
+ const lastMarkerAt = markers.at(-1)?.sourceTimeMs;
8467
+ return continuous && step.recordedIntervalMs !== void 0 && lastMarkerAt !== void 0 ? lastMarkerAt + step.recordedIntervalMs + pausedSince(lastMarkerAt) : null;
8468
+ };
8469
+ let zoomedClick = false;
8470
+ let zoomedDrag = false;
8471
+ if (room !== void 0 && (step.action.kind === "click" || dragPlan !== null)) {
8472
+ const ahead = (segment === void 0 ? 0 : retargetSegment(segment, cursor2, dragPlan?.start ?? rectCentre(handle.rect)).durationMs) + SETTLE_MS;
7740
8473
  const zooms = room.zooms({
7741
8474
  actionId: step.action.id,
7742
8475
  anchorId: step.action.anchorId,
7743
- rect: handle.rect,
8476
+ rect: dragPlan === null ? handle.rect : {
8477
+ x: Math.min(dragPlan.start.x, dragPlan.end.x),
8478
+ y: Math.min(dragPlan.start.y, dragPlan.end.y),
8479
+ width: Math.abs(dragPlan.end.x - dragPlan.start.x),
8480
+ height: Math.abs(dragPlan.end.y - dragPlan.start.y)
8481
+ },
7744
8482
  unwaitedMs: at2() + ahead - roomAdded - roomHere,
7745
8483
  scale: viewportTransforms.at(-1)?.scale ?? 1
7746
8484
  });
7747
- if (zooms) {
8485
+ if (zooms && dragPlan === null) {
7748
8486
  roomHere += await quietThenFinalize();
7749
8487
  if (latestActEnd !== null) {
7750
- const short = latestActEnd + room.neededMs - (at2() + ahead);
8488
+ const needed = room.neededMs({
8489
+ heldUntilMs: lastHeldUntil,
8490
+ clickMs: Math.max(at2() + ahead, rhythmDue() ?? 0)
8491
+ });
8492
+ const short = latestActEnd + needed - (at2() + ahead);
7751
8493
  if (short > 0) {
7752
8494
  await clock.sleep(short);
7753
8495
  roomHere += short;
7754
8496
  heldHere = Math.max(heldHere, short);
7755
8497
  }
7756
8498
  }
8499
+ zoomedClick = true;
7757
8500
  } else {
7758
8501
  finalizeAct();
7759
8502
  }
8503
+ zoomedDrag = zooms && dragPlan !== null;
7760
8504
  }
7761
8505
  roomAdded += roomHere;
7762
8506
  const pathFrom = at2();
7763
8507
  if (segment !== void 0) {
7764
- await gate.section(() => dispatchPath(segment, rectCentre(handle.rect)));
8508
+ await gate.section(() => dispatchPath(segment, dragPlan?.start ?? rectCentre(handle.rect)));
7765
8509
  }
7766
8510
  await clock.sleep(SETTLE_MS);
7767
8511
  if (continuous && step.action.kind === "moveTo" && segment !== void 0) {
7768
8512
  moveToWindows.push({ startMs: pathFrom, endMs: at2() });
7769
8513
  }
7770
- const lastMarkerAt = markers.at(-1)?.sourceTimeMs;
7771
- if (continuous && step.recordedIntervalMs !== void 0 && lastMarkerAt !== void 0) {
7772
- const wait2 = lastMarkerAt + step.recordedIntervalMs + pausedSince(lastMarkerAt) - at2();
8514
+ const due = rhythmDue();
8515
+ if (due !== null) {
8516
+ const wait2 = due - at2();
7773
8517
  if (wait2 > 0)
7774
8518
  await clock.sleep(wait2);
7775
8519
  if (step.pacedGap !== void 0)
@@ -7779,7 +8523,8 @@ async function runWalk(source, deps, config) {
7779
8523
  anchorRects.push({
7780
8524
  actionId: step.action.id,
7781
8525
  anchorId: step.action.anchorId,
7782
- rect: handle.rect
8526
+ rect: handle.rect,
8527
+ ...dragPlan === null ? {} : { end: dragPlan.endRect }
7783
8528
  });
7784
8529
  const markedAt = at2();
7785
8530
  const marker = {
@@ -7789,20 +8534,31 @@ async function runWalk(source, deps, config) {
7789
8534
  ...heldHere > 0 ? { roomHeldMs: Math.round(heldHere) } : {}
7790
8535
  };
7791
8536
  markers.push(marker);
8537
+ if (zoomedClick || zoomedDrag) {
8538
+ lastZoom = {
8539
+ actionMs: markedAt,
8540
+ arrivalMs: markedAt + CAMERA_DEFAULTS.leadInMs
8541
+ };
8542
+ }
8543
+ if (zoomedClick)
8544
+ lastHeldUntil = lastZoom?.arrivalMs ?? null;
7792
8545
  await shot(step.action.id);
7793
8546
  if (continuous) {
7794
- const clicked = await gate.section(() => performVerb(step.action, text, cdp, cursor2, device?.touch === true, handle.objectId, sightings, clock.sleep));
8547
+ const clicked = await gate.section(() => dragPlan !== null ? performDrag(step.action.id, dragPlan, handle.objectId, device?.touch === true) : performVerb(step.action, text, cdp, cursor2, device?.touch === true, handle.objectId, sightings, clock.sleep));
7795
8548
  stillOwed = true;
7796
8549
  if (clickStopped(step.action.kind, clicked))
7797
8550
  break;
7798
8551
  if (room !== void 0)
7799
8552
  pendingAct = { marker, verbEndMs: at2() };
8553
+ if (dragPlan !== null && lastZoom !== null && markedAt >= lastZoom.actionMs && markedAt < lastZoom.arrivalMs + CAMERA_DEFAULTS.neutral.zoomHoldMs) {
8554
+ lastHeldUntil = Math.max(lastHeldUntil ?? at2(), at2());
8555
+ }
7800
8556
  if (step.action.kind === "moveTo") {
7801
8557
  moveToWindows.push({ startMs: markedAt, endMs: at2() });
7802
8558
  }
7803
8559
  } else {
7804
8560
  recorder.open();
7805
- const clicked = await gate.section(() => performVerb(step.action, text, cdp, cursor2, device?.touch === true, handle.objectId, sightings, clock.sleep));
8561
+ const clicked = await gate.section(() => dragPlan !== null ? performDrag(step.action.id, dragPlan, handle.objectId, device?.touch === true) : performVerb(step.action, text, cdp, cursor2, device?.touch === true, handle.objectId, sightings, clock.sleep));
7806
8562
  const spansBefore = motionSpans.length;
7807
8563
  await recorder.close();
7808
8564
  if (clickStopped(step.action.kind, clicked))
@@ -7890,6 +8646,7 @@ async function runWalk(source, deps, config) {
7890
8646
  cursorSamples,
7891
8647
  cursorGaps: [],
7892
8648
  anchorRects,
8649
+ ...heldPresses.length === 0 ? {} : { heldPresses },
7893
8650
  ...viewportTransforms.length === 0 ? {} : { viewportTransforms },
7894
8651
  markers,
7895
8652
  degradations,
@@ -7930,6 +8687,7 @@ async function runWalk(source, deps, config) {
7930
8687
  reason,
7931
8688
  degradations,
7932
8689
  unconfirmedClicks,
8690
+ ignoredDrags,
7933
8691
  storageRefused,
7934
8692
  hoverSensitive,
7935
8693
  counters
@@ -8001,6 +8759,8 @@ async function performVerb(action, text, cdp, cursor2, touch, objectId, sighting
8001
8759
  return null;
8002
8760
  case "waitFor":
8003
8761
  return null;
8762
+ case "drag":
8763
+ throw new Error("performVerb: a drag is performed by performDrag");
8004
8764
  default: {
8005
8765
  const unknown = action;
8006
8766
  throw new Error(`performVerb: no verb for ${JSON.stringify(unknown)}`);
@@ -8051,7 +8811,11 @@ function authoredTotal(script) {
8051
8811
  return script.steps.filter((step) => step.do !== "pause").length;
8052
8812
  }
8053
8813
  function targetOf2(step) {
8054
- return "into" in step ? step.into : step.on;
8814
+ if ("into" in step)
8815
+ return step.into;
8816
+ if ("from" in step)
8817
+ return step.from.on;
8818
+ return step.on;
8055
8819
  }
8056
8820
  function pageKeyOf(url) {
8057
8821
  const hash = url.indexOf("#");
@@ -8070,8 +8834,14 @@ function kindOf(step) {
8070
8834
  return "moveTo";
8071
8835
  case "scrollTo":
8072
8836
  return "scrollTo";
8073
- default:
8837
+ case "waitFor":
8074
8838
  return "waitFor";
8839
+ case "drag":
8840
+ return "drag";
8841
+ default: {
8842
+ const unknown = step;
8843
+ throw new Error(`kindOf: no kind for ${JSON.stringify(unknown)}`);
8844
+ }
8075
8845
  }
8076
8846
  }
8077
8847
  function synthesize(step, ids, hidden = false) {
@@ -8085,8 +8855,20 @@ function synthesize(step, ids, hidden = false) {
8085
8855
  return { ...base, kind: "moveTo" };
8086
8856
  case "scrollTo":
8087
8857
  return { ...base, kind: "scrollTo" };
8088
- default:
8858
+ case "waitFor":
8089
8859
  return { ...base, kind: "waitFor", condition: step.until };
8860
+ case "drag":
8861
+ return {
8862
+ ...base,
8863
+ kind: "drag",
8864
+ toAnchorId: null,
8865
+ ...step.from.at === void 0 ? {} : { fromAt: step.from.at },
8866
+ to: "by" in step.to ? { by: step.to.by } : { at: step.to.at }
8867
+ };
8868
+ default: {
8869
+ const unknown = step;
8870
+ throw new Error(`synthesize: no action for ${JSON.stringify(unknown)}`);
8871
+ }
8090
8872
  }
8091
8873
  }
8092
8874
  function navigationWait(ids) {
@@ -8127,8 +8909,7 @@ function createAuthoredRun(script, deps, viewport) {
8127
8909
  actionId: action.id,
8128
8910
  kind: action.kind,
8129
8911
  anchorId: action.anchorId,
8130
- text: action.kind === "type" ? action.text : null,
8131
- cut: false
8912
+ text: action.kind === "type" ? action.text : null
8132
8913
  });
8133
8914
  record.actionId = action.id;
8134
8915
  record.marker = action.marker;
@@ -8245,6 +9026,22 @@ function createAuthoredRun(script, deps, viewport) {
8245
9026
  stop = "pageWentElsewhere";
8246
9027
  return;
8247
9028
  }
9029
+ let endAnchor = null;
9030
+ if (step.do === "drag" && "on" in step.to) {
9031
+ const answer = await deps.captureResolved({
9032
+ id: deps.newId("an"),
9033
+ fingerprint: fingerprintFromTarget(step.to.on)
9034
+ });
9035
+ if (answer.anchor === null) {
9036
+ record.failureReason = answer.failureReason;
9037
+ record.pageUrl = answer.pageUrl;
9038
+ stop = stopForFailedCapture();
9039
+ return;
9040
+ }
9041
+ endAnchor = answer.anchor;
9042
+ }
9043
+ let measuredEnd = null;
9044
+ let pressedAt;
8248
9045
  const action = synthesize(step, {
8249
9046
  id: deps.newId("ac"),
8250
9047
  anchorId: anchor2.id,
@@ -8269,6 +9066,17 @@ function createAuthoredRun(script, deps, viewport) {
8269
9066
  // where the walk's own measurement says the target is.
8270
9067
  segment: VERBS[action.kind].cursorTravels ? segmentTo(cursor2, anchor2.fingerprint.boundingRect, segments, previousActionId, action.id) : void 0,
8271
9068
  text: step.do === "type" ? step.text : null,
9069
+ ...step.do === "drag" ? {
9070
+ drag: {
9071
+ fromAt: step.from.at,
9072
+ to: "by" in step.to ? { by: step.to.by } : { at: step.to.at },
9073
+ end: endAnchor,
9074
+ onEnd: (rect2, spot) => {
9075
+ measuredEnd = rect2;
9076
+ pressedAt = spot;
9077
+ }
9078
+ }
9079
+ } : {},
8272
9080
  // Intent, handed to the walk's aim — not written into `action.rect`,
8273
9081
  // which stays the rect the run measured (`commit`), so the produced
8274
9082
  // take claims no evidence it did not witness.
@@ -8289,6 +9097,24 @@ function createAuthoredRun(script, deps, viewport) {
8289
9097
  segments++;
8290
9098
  previousActionId = action.id;
8291
9099
  }
9100
+ if (action.kind === "drag") {
9101
+ if (measuredEnd !== null) {
9102
+ action.toRect = measuredEnd;
9103
+ cursor2 = rectCentre(measuredEnd);
9104
+ }
9105
+ if (pressedAt !== void 0)
9106
+ action.pressedAt = pressedAt;
9107
+ if (endAnchor !== null) {
9108
+ action.toAnchorId = endAnchor.id;
9109
+ anchors.push({
9110
+ ...endAnchor,
9111
+ resolution: {
9112
+ ...endAnchor.resolution,
9113
+ actionIndex: actions.length
9114
+ }
9115
+ });
9116
+ }
9117
+ }
8292
9118
  commit(action, anchor2, record, measured);
8293
9119
  }
8294
9120
  }
@@ -8359,7 +9185,7 @@ function assembleAuthored(script, args2) {
8359
9185
  camera: args2.camera.camera,
8360
9186
  ...args2.camera.zoomsSkipped.length > 0 ? { zoomsSkipped: args2.camera.zoomsSkipped } : {},
8361
9187
  // Nothing has edited this take: it is one second old.
8362
- edits: { replacements: [], masks: [], holds: [], gaps: [], cuts: [] },
9188
+ edits: { masks: [], holds: [], gaps: [], splits: [], removed: [] },
8363
9189
  // Nothing observed any of these. The walk has no network, console or
8364
9190
  // navigation collector, and an entry in `urlTrace` would have to claim an
8365
9191
  // instant the run never measured — it only knows which page each step's
@@ -8501,95 +9327,6 @@ async function runAuthored(script, deps) {
8501
9327
  };
8502
9328
  }
8503
9329
 
8504
- // ../../packages/replay-engine/dist/scene-cuts.js
8505
- function withoutCutSteps(scene) {
8506
- const cuts = scene.edits.cuts ?? [];
8507
- if (cuts.length === 0)
8508
- return scene;
8509
- const gone = new Set(cuts.map((c) => c.actionId));
8510
- const kept = (actionId) => !gone.has(actionId);
8511
- return withoutStaleZoomsSkipped({
8512
- ...scene,
8513
- actions: scene.actions.filter((a) => kept(a.id)),
8514
- // `scene.camera` and `scene.edits.masks` below are read UNGUARDED — no
8515
- // `?? []` — where `edits.cuts`/`edits.gaps`/`edits.holds` above and below
8516
- // carry one. That split is real, not an oversight, and it is the same
8517
- // split `packages/compositor/src/plan/plan.ts` (`planCuts`, `gapAfter`),
8518
- // `packages/scene-schema/src/migrations.ts`'s `migrateHoldsToGaps` and
8519
- // `apps/extension/src/editor/timeline.ts`'s `gapAfterAction` already
8520
- // draw, for the same reason:
8521
- //
8522
- // `edits.cuts` and `edits.gaps` carry `z.array(...).default([])` in
8523
- // `SceneDocumentSchema`, and `edits.holds` was backfilled by
8524
- // `migrateHoldsToGaps` at schema v3 — so a document written before any
8525
- // of the three existed reaches a caller with the field simply absent,
8526
- // UNLESS something ran it through `SceneDocumentSchema.parse` (Zod's
8527
- // `.default([])` fires only inside `.parse`) or `migrateToCurrent` first.
8528
- // `camera` and `edits.masks` are required arrays with no `.default()`,
8529
- // present on `SceneDocumentSchema` since schemaVersion 1 with no
8530
- // migration that ever back-fills them — there is no historical document
8531
- // shape missing either one for a guard to defend against.
8532
- //
8533
- // Whether that matters here turns on how `withoutCutSteps` is actually
8534
- // reached. Its production callers are `runReplayInWindow` (the scene
8535
- // comes from `createIdbSceneStore().get()`) and `failedPerformedStep`
8536
- // (fed whatever `staleness.ts`/`replay-runner.ts` already loaded the
8537
- // same way) — and `createIdbSceneStore().get()` runs every row through
8538
- // `migrateToCurrent` before handing it back (`scene-store.ts`), so both
8539
- // paths are parsed, not raw IndexedDB rows. A raw-row reader — the frame
8540
- // store's own cast, which is what forces the `?? []` at the four sites
8541
- // above — never calls this function. If one someday does, the `?? []`
8542
- // on `cuts`/`gaps`/`holds` above still degrade it safely; `camera` and
8543
- // `masks` would throw, the same trade the timeline's own comment names:
8544
- // "not reachable... but a TypeError here would take the whole render
8545
- // down." Worth stating rather than guarding against silently, since a
8546
- // reader who hits this file after a crash should find the reasoning
8547
- // here, not rediscover it the way this task's own hand-built test
8548
- // fixtures did.
8549
- //
8550
- // A zoom whose own MARKER names a cut step goes entirely — the step it
8551
- // was aimed at no longer happens. A zoom whose `end` alone names one is
8552
- // different: the zoom's own step survived, and dropping the whole event
8553
- // would remove a camera move the rebuild still performs. Dropping just
8554
- // `end` falls back to the compositor's own return timing
8555
- // (`insertNeutralKeys`), which is what every pre-2026-09-13 document
8556
- // already gets.
8557
- camera: scene.camera.flatMap((event) => {
8558
- if (!kept(event.marker.actionId))
8559
- return [];
8560
- if (event.end !== void 0 && !kept(event.end.actionId)) {
8561
- const { end: _dropped, ...rest2 } = event;
8562
- return [rest2];
8563
- }
8564
- return [event];
8565
- }),
8566
- edits: {
8567
- ...scene.edits,
8568
- cuts: [],
8569
- gaps: (scene.edits.gaps ?? []).filter((g) => kept(g.afterActionId)),
8570
- holds: (scene.edits.holds ?? []).filter((h) => kept(h.marker.actionId)),
8571
- // Unguarded, no `?? []` — see the comment above `camera` for why
8572
- // `masks` is one of the two fields that gets none.
8573
- //
8574
- // Both-or-neither, whichever side names the cut step: the schema
8575
- // refuses a mask with only one side, so a mask that loses either side
8576
- // loses both — it is a filter, not a partial edit, exactly like a
8577
- // whole-take mask (neither side) already reads.
8578
- masks: scene.edits.masks.filter((m) => (m.start === void 0 || kept(m.start.actionId)) && (m.end === void 0 || kept(m.end.actionId))),
8579
- trim: trimWithout(scene.edits.trim, kept)
8580
- }
8581
- });
8582
- }
8583
- function trimWithout(trim, kept) {
8584
- if (trim === void 0)
8585
- return trim;
8586
- const head = trim.head && kept(trim.head.actionId) ? trim.head : void 0;
8587
- const tail = trim.tail && kept(trim.tail.actionId) ? trim.tail : void 0;
8588
- if (head === void 0 && tail === void 0)
8589
- return void 0;
8590
- return { ...trim, head, tail };
8591
- }
8592
-
8593
9330
  // ../../packages/replay-engine/dist/explain.js
8594
9331
  var REASON_TEXT = {
8595
9332
  mutating: "this flow writes data and rebuilding is switched off for it, so what you have is what this take itself recorded \u2014 turn on rebuilds for write flows, then rebuild it",
@@ -8637,7 +9374,7 @@ var REASON_TEXT = {
8637
9374
  // witnesses this is raised from are a change of page, so the sentence can
8638
9375
  // state that as fact rather than hedging it.
8639
9376
  pageWentElsewhere: "the app moved to a different page partway through this script, and nothing in the script asked it to \u2014 either a step navigated, or the session expired and it went to a sign-in page; check the app is still signed in, and add a waitForLoad after any step that navigates, then run it again",
8640
- signedOut: "the app sent this browser to its sign-in page, so nothing was filmed \u2014 sign in again with demoman signin, then run it again",
9377
+ signedOut: "the app sent this browser to its sign-in page, so nothing was recorded \u2014 sign in again with demoman signin, then run it again",
8641
9378
  // Also authored only. Not a failure of the app or of the page: the script
8642
9379
  // asked for something this door does not perform, and the run refused
8643
9380
  // rather than perform a different thing and call it done.
@@ -8647,6 +9384,8 @@ var REASON_TEXT = {
8647
9384
  // honest move — the cause, input during a still, is gated since
8648
9385
  // 2026-10-13, so a repeat is news worth saying.
8649
9386
  clickNotDelivered: "the browser put a click somewhere other than where it was sent, so the page never saw that click and the step did not happen \u2014 nothing is wrong with the steps; run it again, and say so if it repeats",
9387
+ dragEndOutOfView: "a drag's start or end was off the page once its start was in view, and a drag cannot scroll while it moves, so it was not begun; drag to a target on the same screen, or scroll first",
9388
+ dragNoDistance: "a drag's two ends landed on the same point once measured, which is a click, not a drag, so it was not begun; give the drag's end another target, spot or offset",
8650
9389
  waitTimeout: "the page never reached a state the take was waiting for",
8651
9390
  occlusionTimeout: "the render window stayed covered, so the frames would not have been usable",
8652
9391
  windowClosed: "the replay window was closed before the run finished \u2014 nothing is wrong with the take, run it again",
@@ -8655,12 +9394,10 @@ var REASON_TEXT = {
8655
9394
  // allowance for a rerun: this said "usually worth simply running it again"
8656
9395
  // until M4 (2026-10-01), and an agent spent the last run of its cap
8657
9396
  // repeating a muxer fault no rerun could get past.
8658
- deviceFailed: "the browser refused to emulate the device, so nothing was filmed \u2014 the note says which command and why",
9397
+ deviceFailed: "the browser refused to emulate the device, so nothing was recorded \u2014 the note says which command and why",
8659
9398
  portFailure: "something underneath the run gave way \u2014 not a fault in the take, so re-recording will not fix it; run it once more, and if it stops the same way, report it",
8660
- // Reported by the caller, not the engine: `withoutCutSteps` left nothing
8661
- // to perform. Not a break to explain — the author's own edit did this —
8662
- // so the instruction is the fix, not an apology.
8663
- noActions: "every step in this take is cut, so there is nothing to re-shoot \u2014 restore a step, then re-shoot it in Runs"
9399
+ // Reported by the caller, not the engine: there was nothing to perform.
9400
+ noActions: "this take has no step that acts on the page, so there is nothing to record"
8664
9401
  };
8665
9402
  function reasonSentence(reason) {
8666
9403
  return reason in REASON_TEXT ? REASON_TEXT[reason] : reason;
@@ -8687,7 +9424,7 @@ function failedStep(scene, replay) {
8687
9424
  };
8688
9425
  }
8689
9426
  function failedPerformedStep(scene, replay) {
8690
- return failedStep(withoutCutSteps(scene), replay);
9427
+ return failedStep(scene, replay);
8691
9428
  }
8692
9429
 
8693
9430
  // ../../packages/replay-engine/dist/loaded.js
@@ -8862,6 +9599,8 @@ var NO_RECORD = "these frames carry no record of what produced them, so which of
8862
9599
  function targetOfStep(step) {
8863
9600
  if ("into" in step)
8864
9601
  return step.into;
9602
+ if ("from" in step)
9603
+ return step.from.on;
8865
9604
  if ("on" in step)
8866
9605
  return step.on;
8867
9606
  return null;
@@ -8878,7 +9617,7 @@ function compareToScript(scene, madeFrom, resolved) {
8878
9617
  found.push({
8879
9618
  kind: "missing",
8880
9619
  actionId: action.id,
8881
- reason: "the film has no record of this step"
9620
+ reason: "the video does not show this step"
8882
9621
  });
8883
9622
  continue;
8884
9623
  }
@@ -9003,7 +9742,7 @@ function buildStopped(walk, scene, steps3, detail) {
9003
9742
  ...detail === void 0 ? {} : { detail }
9004
9743
  };
9005
9744
  }
9006
- function buildVerdict(outcome, scene, madeFrom, steps3) {
9745
+ function buildVerdict(outcome, scene, madeFrom, steps3, ignoredDrags = []) {
9007
9746
  if (scene === null) {
9008
9747
  return {
9009
9748
  kind: "diverged",
@@ -9016,13 +9755,20 @@ function buildVerdict(outcome, scene, madeFrom, steps3) {
9016
9755
  diverged: [{ kind: "unverifiable", reason: NO_RECORD }]
9017
9756
  };
9018
9757
  }
9019
- const diverged = compareToScript(scene, madeFrom, steps3);
9758
+ const diverged = [
9759
+ ...compareToScript(scene, madeFrom, steps3),
9760
+ ...ignoredDrags.map(({ actionId, note }) => ({
9761
+ kind: "ignored",
9762
+ actionId,
9763
+ reason: note
9764
+ }))
9765
+ ];
9020
9766
  if (outcome === "complete") {
9021
9767
  return diverged.length === 0 ? { kind: "matches", diverged: [] } : { kind: "diverged", diverged };
9022
9768
  }
9023
9769
  if (diverged.length > 0)
9024
9770
  return { kind: "diverged", diverged };
9025
- const reason = outcome === "refused" ? "the run was refused before it could produce anything to compare" : "the run stopped before the script finished, so the film cannot be said to match it";
9771
+ const reason = outcome === "refused" ? "the run was refused before it could produce anything to compare" : "the run stopped before the script finished, so the video cannot be said to match it";
9026
9772
  return { kind: "diverged", diverged: [{ kind: "unverifiable", reason }] };
9027
9773
  }
9028
9774
  function buildRunReport(args2) {
@@ -9052,7 +9798,7 @@ function buildRunReport(args2) {
9052
9798
  storageRefused: false,
9053
9799
  shrunkSpans: 0
9054
9800
  },
9055
- film: args2.film,
9801
+ video: args2.film,
9056
9802
  recording: args2.recording,
9057
9803
  look: args2.look,
9058
9804
  size: args2.size,
@@ -9077,11 +9823,11 @@ function buildRunReport(args2) {
9077
9823
  shrunkSpans: args2.walk.counters.encodeShrunkSpans,
9078
9824
  ...unconfirmedClicksOf(args2.walk, args2.steps)
9079
9825
  },
9080
- film: args2.film,
9826
+ video: args2.film,
9081
9827
  recording: args2.recording,
9082
9828
  look: args2.look,
9083
9829
  size: args2.size,
9084
- verdict: buildVerdict(outcome, args2.scene, args2.madeFrom, steps3)
9830
+ verdict: buildVerdict(outcome, args2.scene, args2.madeFrom, steps3, args2.walk.ignoredDrags)
9085
9831
  };
9086
9832
  }
9087
9833
  function verdictLine(report) {
@@ -9109,13 +9855,15 @@ var NOT_KEPT = {
9109
9855
  // Since 2026-09-30 a landing comes from the take's recorded rect OR a
9110
9856
  // script step's hand-written `landing: { top }`, so the words name neither.
9111
9857
  scrollLandingOffscreen: "a scroll's landing would have left its target off screen, so the page was centred on it instead",
9112
- clickUnconfirmed: "a click could not be confirmed to have reached its target, so the film may show a step that did nothing \u2014 frames.unconfirmedClicks names the step and says why",
9858
+ clickUnconfirmed: "a click could not be confirmed to have reached its target, so the video may show a step that did nothing \u2014 frames.unconfirmedClicks names the step and says why",
9113
9859
  // No run writes it since 2026-10-10 (see the compositor's enum); kept
9114
9860
  // because the Record must cover every kind a bundle can carry.
9115
9861
  textLinesUnmeasured: "the text around a click could not all be measured, so its zoom may cut a line beside the target",
9116
9862
  cursorSynthesized: "the cursor is reconstructed from the steps rather than recorded",
9117
9863
  motionReclaimed: "motion was reclaimed to free storage",
9118
- pacingUnplaced: "a pause could not be placed on its step"
9864
+ pacingUnplaced: "a pause could not be placed on its step",
9865
+ notDragged: "a drag reached the page and changed nothing on screen, so the page may not take drags this way",
9866
+ dragPictureMissing: "a native drag's picture could not be drawn, so the dragged item jumps to its drop in the video instead of travelling"
9119
9867
  };
9120
9868
  function lookClause(report) {
9121
9869
  const error = report.look?.brandKitError ?? null;
@@ -9144,10 +9892,10 @@ function runVerdictLine(report) {
9144
9892
  }
9145
9893
  const asked = "takeId" in report.run.script ? "the take recorded" : "the script asked for";
9146
9894
  if (report.verdict.kind === "matches") {
9147
- return `Complete: the film matches every step ${asked}.`;
9895
+ return `Complete: the video matches every step ${asked}.`;
9148
9896
  }
9149
9897
  const n = report.verdict.diverged.length;
9150
- return `Complete: ${n} step${n === 1 ? "" : "s"} the film does not show the way ${asked} it.`;
9898
+ return `Complete: ${n} step${n === 1 ? "" : "s"} the video does not show the way ${asked} it.`;
9151
9899
  }
9152
9900
  function whyStopped(report) {
9153
9901
  return report.stopped?.detail ?? report.stopped?.sentence ?? report.stopped?.reason ?? "it did not finish";
@@ -9169,7 +9917,7 @@ function viewportForScreen(screen2, setting) {
9169
9917
  if (!Number.isFinite(width) || !Number.isFinite(height) || width < 1 || height < 1) {
9170
9918
  return {
9171
9919
  ok: false,
9172
- error: `the screen reported ${width}x${height}, which no page can be filmed at`
9920
+ error: `the screen reported ${width}x${height}, which no page can be recorded at`
9173
9921
  };
9174
9922
  }
9175
9923
  const w = Math.floor(width);
@@ -9354,83 +10102,15 @@ async function snapshotOnStage(stage, url, contains2, device, desktop) {
9354
10102
  };
9355
10103
  }
9356
10104
 
9357
- // ../../packages/run-core/dist/runs-route.js
9358
- function isAuthoredScene(scene) {
9359
- return scene.meta.capture.mode === "authored";
9360
- }
9361
- function runsRouteClause(authored) {
9362
- return authored ? "run its script again in Runs" : "re-shoot it in Runs";
9363
- }
9364
-
9365
- // ../../packages/run-core/dist/retext.js
9366
- function noRecordReason(hasFrames, authored, routeClause = runsRouteClause) {
9367
- const route = `${routeClause(authored)} to film it`;
9368
- return hasFrames ? `these frames were made before the editor recorded what they typed, so a change to this text cannot be drawn over them \u2014 ${route}` : `this take has no frames yet, so there is nothing to draw a change to this text over \u2014 ${route}`;
9369
- }
9370
- var NO_ANCHOR = "no element was recorded for this step, so there is nowhere on screen to draw the new text";
9371
- function retexts(scene, madeFrom, hasFrames, routeClause = runsRouteClause) {
9372
- const typedSteps = scene.actions.filter((a) => a.kind === "type");
9373
- if (madeFrom === null) {
9374
- const reason = noRecordReason(hasFrames, isAuthoredScene(scene), routeClause);
9375
- return {
9376
- overlays: [],
9377
- unshown: typedSteps.map((a) => ({ actionId: a.id, reason }))
9378
- };
9379
- }
9380
- const was = new Map(madeFrom.map((s) => [s.actionId, s]));
9381
- const out = { overlays: [], unshown: [] };
9382
- for (const action of typedSteps) {
9383
- if (action.kind !== "type")
9384
- continue;
9385
- const then = was.get(action.id);
9386
- if (then === void 0 || then.kind !== "type")
9387
- continue;
9388
- if (then.text === action.text)
9389
- continue;
9390
- if (action.anchorId === null || action.text === null) {
9391
- out.unshown.push({ actionId: action.id, reason: NO_ANCHOR });
9392
- continue;
9393
- }
9394
- out.overlays.push({
9395
- actionId: action.id,
9396
- anchorId: action.anchorId,
9397
- text: action.text
9398
- });
9399
- }
9400
- return out;
9401
- }
9402
- var RETEXT_BINDING = "retext:";
9403
- var NO_RECT = "nothing was recorded where this field is on screen, so the new text has nowhere to be drawn";
9404
- function retextUnshownOf(shown, clamped, cosmeticIds) {
9405
- const out = new Map(shown.unshown.map((u) => [u.actionId, u.reason]));
9406
- const drawn = new Set(cosmeticIds);
9407
- for (const note of clamped) {
9408
- if (note.kind !== "retext" || !note.id.startsWith(RETEXT_BINDING))
9409
- continue;
9410
- if (drawn.has(note.id))
9411
- continue;
9412
- out.set(note.id.slice(RETEXT_BINDING.length), NO_RECT);
9413
- }
9414
- return out;
9415
- }
9416
- function retextWarnings(shown, recorded, clamped, cosmeticIds) {
9417
- if (!recorded) {
9418
- return shown.unshown.map((u) => ({ ...u, kind: "unchecked" }));
9419
- }
9420
- const unshown = retextUnshownOf(shown, clamped, cosmeticIds);
9421
- return [...unshown].map(([actionId, reason]) => ({
9422
- actionId,
9423
- kind: "notDrawn",
9424
- reason
9425
- }));
9426
- }
9427
-
9428
10105
  // ../../packages/run-core/dist/room.js
10106
+ var PAN_MARGIN_MS = 300;
9429
10107
  function createRoomPolicy(viewport, motion) {
9430
10108
  let last = null;
9431
10109
  let clicks = 0;
10110
+ const timings = motionTimings(motion.smoothness);
10111
+ const pushIn = CAMERA_DEFAULTS.actSettleMs + timings.zoomInMs + Math.abs(CAMERA_DEFAULTS.leadInMs);
9432
10112
  return {
9433
- neededMs: CAMERA_DEFAULTS.actSettleMs + motionTimings(motion.smoothness).zoomInMs + Math.abs(CAMERA_DEFAULTS.leadInMs),
10113
+ neededMs: ({ heldUntilMs, clickMs }) => heldUntilMs !== null && !returnsBetween(heldUntilMs, clickMs + CAMERA_DEFAULTS.leadInMs + PAN_MARGIN_MS, timings) ? 0 : pushIn,
9434
10114
  zooms({ anchorId, rect: rect2, unwaitedMs, scale }) {
9435
10115
  const id = `click-${++clicks}`;
9436
10116
  const decided = decideZoom(last, { id, anchorId, timestamp: unwaitedMs, rect: rect2 }, viewport, () => scale);
@@ -9616,13 +10296,13 @@ function agentName(server) {
9616
10296
  return null;
9617
10297
  return fits(info.title) ? { name: info.name, title: info.title } : { name: info.name };
9618
10298
  }
9619
- var SNAPSHOT_TARGETS = "list the page's targets: each one a run resolves to exactly that element, checked before it is listed. Copy a target into a step verbatim; never compose one. Answers {url, landedUrl, landedElsewhere, title, settled, settleNote, targets: [{target, kind, text, rect, inFirstViewport}], unresolvable, notExamined, walkMs, size, kits}. size is {width, height, from, error}, the size the page was laid out at and a run with no viewport films; an error means it is the run window's own size instead, so tell the user.";
9620
- var SNAPSHOT_TAIL = "rect is in page coordinates and null for an element that is not shown (a closed FAQ answer). It sees only the page as it loads: content a click creates is not listed. Elements inside iframes and shadow roots are not listed. At most 250 targets: notExamined above 0 means elements were left unexamined. Without contains, pass one (case-insensitive, matched against text and name) to ask for one part of the page; with contains, notExamined counts only elements that match it, so narrow contains further. Pass device (phone or tablet) to see the page as a phone or a tablet; a run films that device only if its script names the same device.";
10299
+ var SNAPSHOT_TARGETS = "list the page's targets: each one a run resolves to exactly that element, checked before it is listed. Copy a target into a step verbatim; never compose one. Answers {url, landedUrl, landedElsewhere, title, settled, settleNote, targets: [{target, kind, text, rect, inFirstViewport}], unresolvable, notExamined, walkMs, size, kits}. size is {width, height, from, error}, the size the page was laid out at and a run with no viewport records; an error means it is the run window's own size instead, so tell the user.";
10300
+ var SNAPSHOT_TAIL = "rect is in page coordinates and null for an element that is not shown (a closed FAQ answer). It sees only the page as it loads: content a click creates is not listed. Elements inside iframes and shadow roots are not listed. At most 250 targets: notExamined above 0 means elements were left unexamined. Without contains, pass one (case-insensitive, matched against text and name) to ask for one part of the page; with contains, notExamined counts only elements that match it, so narrow contains further. Pass device (phone or tablet) to see the page as a phone or a tablet; a run records that device only if its script names the same device.";
9621
10301
  var DESCRIPTIONS = {
9622
10302
  status: `Is this demoman-mcp's own browser up? executor "cli": this server runs scripts in a browser of its own, with no extension to connect or approve. Answers version, browserInstalled (false: the first snapshot or run answers browserMissing with the command that installs it), browserRunning (the window opens on the first snapshot, run or export and stays open between calls), runnerVersion, runPage (the latest run's report or its progress), and update (newer: true means a newer Demoman is out; tell the user once). sessions lists the sessions saved (site, savedAt, refreshedAt, signInUrl; an account's carries account and origin too, a plain entry is the site's manual session), or {unreadable} saying why it could not be read. accounts is the demo accounts in .demoman/accounts.json: {file, sites: [{origin, default, accounts: [{name, about, session}]}]}, {file: null, searchedFrom} when there is none, or {file, invalid, field} when it cannot be used; secretsFile is null, {path, absent}, {path, git: ignored or notGit} or {path, refused}. Never a value. pullRequests is the pull-request video setting: {value: off, ask or attach, from: repo, user or default, file?}, or {unreadable, file} when its file cannot be used (never read that as off; file null: project is not a usable folder); pass project (absolute path) to read another checkout's.`,
9623
10303
  snapshot: `Open url in this server's own browser \u2014 signed in where the user ran npx demoman signin, or as a demo account (account; project: absolute path) \u2014 and ${SNAPSHOT_TARGETS} kits is {ok: true, kits: [{name, default, valid}]}: the user's brand kits; name one in a script's look.kit (with scriptVersion 2) only when the user asked for that look; {ok: false, reason} means unreadable: name none. landedElsewhere true means the app redirected: session "signedOut" (or a plain sign-in landedUrl with "none"/"unchecked") means a sign-in page: spend no run; set up a demo account (recipe) or give the user sessionDetail's command (npx demoman signin <the page>). signedIn means Demoman signed in first. If landedUrl is not a sign-in page, use it as the target. ${SNAPSHOT_TAIL} Past about 50 s it answers {outcome: "stillRunning", id}; then call report with that id.`,
9624
10304
  takes: "The takes this demoman-mcp's own browser made, newest first: id, name, createdAt, mode, actions. A folder that is not a readable take comes last as {id, unreadable}, saying why. Not the user's Demoman library in their browser.",
9625
- run: `Run a DemoScript in this demoman-mcp's own browser (signed in where the user ran npx demoman signin, or as the account the script names, at scriptVersion 5; project is the absolute path of another checkout) and answer its report, which carries account and signedIn; the take is saved on disk. Pass {takeId} instead of {script} to re-film a take whose scene.json was edited: a new take, counted as a run. A second run or snapshot while one is in progress is refused (alreadyRunning). Answers {outcome: "stillRunning", id} if it takes longer than about 50 s; then call report with that id.`,
10305
+ run: `Run a DemoScript in this demoman-mcp's own browser (signed in where the user ran npx demoman signin, or as the account the script names, at scriptVersion 5; project is the absolute path of another checkout) and answer its report, which carries account and signedIn; the take is saved on disk. Pass {takeId} instead of {script} to re-record a take whose scene.json was edited: a new take, counted as a run. A second run or snapshot while one is in progress is refused (alreadyRunning). Answers {outcome: "stillRunning", id} if it takes longer than about 50 s; then call report with that id.`,
9626
10306
  export: `Render a take this server made to an MP4, a GIF (fileType "gif") or a folder of PNG stills, one per step (fileType "stills"; stills.width in px or "native", stills.zoom "none" or "step"; MP4 quality "full" for the largest file, default "share": as small as stays crisp; maxMB caps an MP4's size, lowering fps, then size, then quality), and save it on this machine \u2014 in ~/Downloads, or the folder demoman-mcp was started with --out-dir \u2014 in the take's frame (Auto, 16:9 or 9:16) and branding, logo included. Answers the export report; on "saved", file.path is the file's absolute path, or folder.path the stills folder's, summary is the sentence to give the user, and links holds one-click links for them (studio, reveal, copy; linksError says why there are none). A second export, run or snapshot while one is in progress is refused (busy, alreadyRunning). Past about 50 s it answers {outcome: "stillRunning", id}; then call report with that id.`
9627
10307
  };
9628
10308
  function registerTools(server, bare2, options) {
@@ -10125,7 +10805,7 @@ var JXA = `ObjC["import"]("AppKit");
10125
10805
  const s = $.NSScreen.screens.objectAtIndex(0);
10126
10806
  JSON.stringify({ width: s.frame.size.width, height: s.frame.size.height, scale: s.backingScaleFactor });`;
10127
10807
  function displayUnreadSentence(failed2, tense) {
10128
- const names = tense === "films" ? "names" : "named";
10808
+ const names = tense === "records" ? "names" : "named";
10129
10809
  return `Demoman could not read this computer's display (${failed2}), so headless ${tense} at 1x, and at its own window size unless the script or its device ${names} one \u2014 set DEMOMAN_DISPLAY to <width>x<height>@<scale> (such as 1710x1107@2), or start Demoman with --headed`;
10130
10810
  }
10131
10811
  var DISPLAY_SETTING = /^(\d+)x(\d+)@(\d+(?:\.\d+)?)$/;
@@ -10445,7 +11125,7 @@ function createBrowserSession(options) {
10445
11125
  if (options.headless && options.readDisplay !== void 0) {
10446
11126
  const read = await readDisplayNow(options.readDisplay);
10447
11127
  if ("failed" in read) {
10448
- const why2 = displayUnreadSentence(read.failed, "filmed");
11128
+ const why2 = displayUnreadSentence(read.failed, "recorded");
10449
11129
  if (why2 !== screenUnknown)
10450
11130
  options.log(why2);
10451
11131
  screenUnknown = why2;
@@ -11262,6 +11942,27 @@ function mergeStates(files) {
11262
11942
  origins: files.flatMap((f) => f.state.origins)
11263
11943
  };
11264
11944
  }
11945
+ function writeBackOf(state, saved) {
11946
+ const slice = sliceForSite(state, saved.site);
11947
+ const held = new Set(saved.state.origins.map((o) => o.origin));
11948
+ return { ...slice, origins: slice.origins.filter((o) => held.has(o.origin)) };
11949
+ }
11950
+ function restorable(state) {
11951
+ const dropped = [];
11952
+ const origins = state.origins.map((o) => {
11953
+ const saved = o.indexedDB;
11954
+ if (saved === void 0)
11955
+ return o;
11956
+ const indexedDB = saved.filter((db) => {
11957
+ const lost = db.stores.some((s) => s.keyPath === void 0 && s.keyPathArray === void 0 && !s.autoIncrement && s.records.some((r) => r.key === void 0 && r.keyEncoded === void 0));
11958
+ if (lost)
11959
+ dropped.push(`${o.origin} "${db.name}"`);
11960
+ return !lost;
11961
+ });
11962
+ return { ...o, indexedDB };
11963
+ });
11964
+ return { state: { ...state, origins }, dropped };
11965
+ }
11265
11966
  function sliceForSite(state, site) {
11266
11967
  return {
11267
11968
  cookies: state.cookies.filter((c) => siteOf(`http://${c.domain.replace(/^\./, "")}/`) === site),
@@ -11993,7 +12694,7 @@ function createRenderServer(store, allowed) {
11993
12694
  });
11994
12695
  }
11995
12696
  async function renderToFiles(input) {
11996
- const { scene, bundle, store, page: page2, target, fileType, logo, retexts: retexts2, onFrame, gifBudget, mp4Cap, stills } = input;
12697
+ const { scene, bundle, store, page: page2, target, fileType, logo, onFrame, gifBudget, mp4Cap, stills } = input;
11997
12698
  const stamped = {
11998
12699
  ...scene,
11999
12700
  meta: {
@@ -12022,7 +12723,6 @@ async function renderToFiles(input) {
12022
12723
  base64: Buffer.from(logo.bytes).toString("base64"),
12023
12724
  contentType: logo.contentType
12024
12725
  } : null,
12025
- retexts: [...retexts2],
12026
12726
  ...gifBudget === void 0 ? {} : { gifBudget },
12027
12727
  ...mp4Cap === void 0 ? {} : { mp4Cap },
12028
12728
  ...stills === void 0 ? {} : { stills }
@@ -12044,7 +12744,6 @@ async function renderToFiles(input) {
12044
12744
  unplacedStills: facts.unplacedStills,
12045
12745
  logoWarning: logo !== null && !logo.ok ? `The logo was left out: ${logo.error}` : facts.logoWarning,
12046
12746
  clampedRanges: facts.clampedRanges,
12047
- cosmeticIds: facts.cosmeticIds,
12048
12747
  rendered: facts.rendered,
12049
12748
  ...facts.gifBudget === void 0 ? {} : { gifBudget: facts.gifBudget },
12050
12749
  ...facts.videoCap === void 0 ? {} : { videoCap: facts.videoCap },
@@ -12232,7 +12931,6 @@ async function checkExportFolder(dir) {
12232
12931
  }
12233
12932
 
12234
12933
  // ../runner/dist/executor/export.js
12235
- var CLI_ROUTE = () => "call run({ takeId })";
12236
12934
  var FILE_TYPES = ["mp4", "gif", "stills"];
12237
12935
  async function exportTake(args2, deps, onProgress) {
12238
12936
  const { library } = deps;
@@ -12263,17 +12961,18 @@ async function exportTake(args2, deps, onProgress) {
12263
12961
  return refused2("invalidMaxMB", maxBytes.refusal);
12264
12962
  }
12265
12963
  const store = library.frameStore(takeId);
12266
- let scene;
12964
+ let sceneRead;
12267
12965
  let bundle;
12268
12966
  try {
12269
- scene = await library.getScene(takeId);
12270
- bundle = scene === null ? null : await store.getBundle(takeId);
12967
+ sceneRead = await library.getSceneRead(takeId);
12968
+ bundle = sceneRead === null ? null : await store.getBundle(takeId);
12271
12969
  } catch (error) {
12272
12970
  return refused2("takeUnreadable", `the library could not be read for take ${takeId} (${messageOf4(error)})`);
12273
12971
  }
12274
- if (scene === null) {
12972
+ if (sceneRead === null) {
12275
12973
  return refused2("takeNotFound", `there is no take ${takeId} in the library`);
12276
12974
  }
12975
+ const { scene, notes } = sceneRead;
12277
12976
  if (bundle === null) {
12278
12977
  return refused2("noFrames", `take ${takeId} has no frames to render \u2014 run its script again`);
12279
12978
  }
@@ -12295,6 +12994,7 @@ async function exportTake(args2, deps, onProgress) {
12295
12994
  quality,
12296
12995
  maxBytes,
12297
12996
  scene,
12997
+ notes,
12298
12998
  bundle,
12299
12999
  store,
12300
13000
  deps,
@@ -12334,7 +13034,7 @@ async function listed(answer, takeId, scene, deps) {
12334
13034
  }
12335
13035
  }
12336
13036
  async function exportLeased(a) {
12337
- const { takeId, asked, stills, quality, maxBytes, scene, bundle, store, deps, onProgress } = a;
13037
+ const { takeId, asked, stills, quality, maxBytes, scene, notes, bundle, store, deps, onProgress } = a;
12338
13038
  const { library } = deps;
12339
13039
  const aspect = scene.canvas.aspect;
12340
13040
  const target = targetFor(asked, aspect, bundle, frameOf(scene), {
@@ -12349,9 +13049,8 @@ async function exportLeased(a) {
12349
13049
  }
12350
13050
  const logo = scene.branding.logo === null ? null : await readLogo(deps.home, scene.branding.logo.ref);
12351
13051
  const madeFrom = bundle.madeFrom ?? null;
12352
- const shown = retexts(scene, madeFrom, true, CLI_ROUTE);
12353
13052
  const read = await library.getSkeleton(takeId);
12354
- const edited2 = editedSinceFilmed(scene, madeFrom, read);
13053
+ const edited2 = editedSinceRecorded(scene, madeFrom, read);
12355
13054
  const folder = await checkExportFolder(deps.outDir);
12356
13055
  if (folder !== null) {
12357
13056
  return withSummary({
@@ -12378,7 +13077,6 @@ async function exportLeased(a) {
12378
13077
  target,
12379
13078
  fileType: asked,
12380
13079
  logo,
12381
- retexts: shown.overlays,
12382
13080
  // As wide as fits: sharp on a Retina screen when the take is short,
12383
13081
  // narrower (and said) when it is long.
12384
13082
  ...asked === "gif" ? { gifBudget: { maxBytes: GIF_BUDGET_BYTES } } : {},
@@ -12424,10 +13122,9 @@ async function exportLeased(a) {
12424
13122
  // The take's own skips under the floor and the render's caps and
12425
13123
  // narrowings: an export whose zooms did not play as asked says which.
12426
13124
  zooms: zoomWarnings(scene, rendered.loweredZooms),
12427
- // Every edit the video does not show: what `retexts` could not hand
12428
- // the plan, and what the plan was handed and could not draw.
12429
- retexts: retextWarnings(shown, madeFrom !== null, rendered.clampedRanges, rendered.cosmeticIds),
12430
- ...edited2 === null ? {} : { editedSinceFilmed: edited2 },
13125
+ // What reading the take took away from it (schema 12: text overlays).
13126
+ migration: notes,
13127
+ ...edited2 === null ? {} : { editedSinceRecorded: edited2 },
12431
13128
  targetCheck: targetCheckOf(read),
12432
13129
  // A re-film leaves every mask behind; an edited take's summary says so.
12433
13130
  masks: scene.edits.masks.length
@@ -13030,8 +13727,9 @@ function createLibrary(home, options = {}) {
13030
13727
  throw new LibraryError("libraryUnreadable", `could not read ${path} (${messageOf4(error)})`);
13031
13728
  }
13032
13729
  let doc;
13730
+ const notes = [];
13033
13731
  try {
13034
- doc = migrateToCurrent(JSON.parse(text));
13732
+ doc = migrateToCurrent(JSON.parse(text), notes);
13035
13733
  } catch (error) {
13036
13734
  const fix = error instanceof SchemaVersionError && error.tooNew && options.updateCommand !== void 0 ? ` \u2014 it was written by a newer Demoman; run \`${options.updateCommand}\`` : "";
13037
13735
  throw new LibraryError("libraryUnreadable", `${path} is not a take (${messageOf4(error)})${fix}`);
@@ -13039,7 +13737,7 @@ function createLibrary(home, options = {}) {
13039
13737
  if (doc.meta.id !== id) {
13040
13738
  throw new LibraryError("libraryUnreadable", `${takeDir(id)} holds the take ${doc.meta.id}, so it was copied or renamed: a take's folder must be named after its id`);
13041
13739
  }
13042
- return { doc, revision: sha256(text) };
13740
+ return { doc, revision: sha256(text), notes };
13043
13741
  }
13044
13742
  async function readTake(id) {
13045
13743
  const read = await readTakeRaw(id);
@@ -13093,7 +13791,11 @@ function createLibrary(home, options = {}) {
13093
13791
  getScene: readTake,
13094
13792
  async getSceneRead(id) {
13095
13793
  const read = await readTakeRaw(id);
13096
- return read === null ? null : { scene: untitleTimestampName(read.doc), revision: read.revision };
13794
+ return read === null ? null : {
13795
+ scene: untitleTimestampName(read.doc),
13796
+ revision: read.revision,
13797
+ notes: read.notes
13798
+ };
13097
13799
  },
13098
13800
  async putSceneIf(doc, ifMatch) {
13099
13801
  guard(doc.meta.id, "libraryUnwritable");
@@ -13792,7 +14494,7 @@ async function resolvePullRequests(from, home) {
13792
14494
  if (user.pullRequests !== null) {
13793
14495
  return { value: user.pullRequests, from: "user", file };
13794
14496
  }
13795
- return { value: "off", from: "default" };
14497
+ return { value: PULL_REQUESTS_DEFAULT, from: "default" };
13796
14498
  }
13797
14499
 
13798
14500
  // ../runner/dist/executor/refilm.js
@@ -13805,15 +14507,16 @@ async function refilmFromLibrary(library, takeId) {
13805
14507
  if (id === "" || !library.isTakeId(id)) {
13806
14508
  return refuse5("takeNotFound", `no take has the id ${JSON.stringify(takeId)} \u2014 call takes for the ids there are`, "takeId");
13807
14509
  }
13808
- let scene;
14510
+ let read;
13809
14511
  try {
13810
- scene = await library.getScene(id);
14512
+ read = await library.getSceneRead(id);
13811
14513
  } catch (error) {
13812
14514
  return refuse5("takeUnreadable", error instanceof LibraryError ? error.message : messageOf4(error), "takeId");
13813
14515
  }
13814
- if (scene === null) {
14516
+ if (read === null) {
13815
14517
  return refuse5("takeNotFound", `no take has the id ${id} \u2014 call takes for the ids there are`, "takeId");
13816
14518
  }
14519
+ const { scene, notes } = read;
13817
14520
  const skeleton = await library.getSkeleton(id);
13818
14521
  let built;
13819
14522
  try {
@@ -13823,6 +14526,7 @@ async function refilmFromLibrary(library, takeId) {
13823
14526
  }
13824
14527
  if (!built.ok)
13825
14528
  return refuse5(built.reason, built.detail, built.field);
14529
+ built.refilm.notes.push(...notes.map((sentence2) => ({ kind: "migrated", sentence: sentence2 })));
13826
14530
  return built;
13827
14531
  }
13828
14532
 
@@ -13978,8 +14682,8 @@ async function muxSpans(input) {
13978
14682
  frames.clear();
13979
14683
  const manifestFrames = [];
13980
14684
  for (const frame of slice) {
13981
- const size = jpegSize(frame.bytes);
13982
- if (size.width <= 0 || size.height <= 0)
14685
+ const size2 = jpegSize(frame.bytes);
14686
+ if (size2.width <= 0 || size2.height <= 0)
13983
14687
  continue;
13984
14688
  const paintedMs = span.frameMs[frame.index - span.firstFrameIndex];
13985
14689
  if (paintedMs === void 0) {
@@ -13993,10 +14697,11 @@ async function muxSpans(input) {
13993
14697
  if (manifestFrames.length === 0) {
13994
14698
  throw new Error(`span ${span.ref} has no usable frames to mux`);
13995
14699
  }
14700
+ const size = fitH264Frame(bundleSpan.width, bundleSpan.height);
13996
14701
  const manifest = {
13997
14702
  frames: manifestFrames,
13998
- width: bundleSpan.width,
13999
- height: bundleSpan.height,
14703
+ width: size.width,
14704
+ height: size.height,
14000
14705
  fps: bundleSpan.fps,
14001
14706
  bitrate: MUX_BITRATE,
14002
14707
  durationSec: 1 / bundleSpan.fps
@@ -14010,6 +14715,8 @@ async function muxSpans(input) {
14010
14715
  const bytes = new Uint8Array(Buffer.concat(parts));
14011
14716
  await store.putSpan(span.ref, bytes);
14012
14717
  bundleSpan.byteLength = bytes.byteLength;
14718
+ bundleSpan.width = size.width;
14719
+ bundleSpan.height = size.height;
14013
14720
  muxed.push({
14014
14721
  index,
14015
14722
  spanIndex: span.index,
@@ -14125,7 +14832,7 @@ async function runScript(script, deps, onProgress) {
14125
14832
  const sceneId = newId("scene");
14126
14833
  const noFilm = () => ({
14127
14834
  film: filmForRun({ refused: false, scene: null, bundle: null }),
14128
- recording: script.recordedFrom === void 0 ? { unavailable: "noRecording" } : { unavailable: "noRunFilm" }
14835
+ recording: script.recordedFrom === void 0 ? { unavailable: "noRecording" } : { unavailable: "noRunVideo" }
14129
14836
  });
14130
14837
  const noTake = (reason, note) => {
14131
14838
  onProgress({ step: 0, total, keyframes: 0, state: "failed", note });
@@ -14172,7 +14879,7 @@ async function runScript(script, deps, onProgress) {
14172
14879
  if (sizePlan.kind === "fixed") {
14173
14880
  size = scaleLost !== null && sizePlan.size.error === null ? { ...sizePlan.size, error: scaleLost } : sizePlan.size;
14174
14881
  } else {
14175
- log2(`${sizePlan.error}; filming at the window's own size`);
14882
+ log2(`${sizePlan.error}; recording at the window's own size`);
14176
14883
  try {
14177
14884
  size = {
14178
14885
  ...await measureViewport(page2),
@@ -14203,7 +14910,7 @@ async function runScript(script, deps, onProgress) {
14203
14910
  facts = await readLandingFacts(page2, script.target);
14204
14911
  } catch (error) {
14205
14912
  landingNote = { unchecked: messageOf4(error) };
14206
- log2(`the page could not be checked for a sign-in page (${messageOf4(error)}); filming on`);
14913
+ log2(`the page could not be checked for a sign-in page (${messageOf4(error)}); recording on`);
14207
14914
  return null;
14208
14915
  }
14209
14916
  const verdict = landingVerdict(facts, sessions, deps.signinCommand);
@@ -14394,7 +15101,7 @@ async function runScript(script, deps, onProgress) {
14394
15101
  run: { scene: document2, bundle: walked.bundle, links, unlinked }
14395
15102
  });
14396
15103
  const ownDetail = result.reason === "portFailure" && lostHeadlessPage ? `Demoman's headless browser lost the run's page before the run finished: the browser crashed, or the page closed itself. There is no window anyone could have closed, and nothing in the script is at fault \u2014 run it once more${failedNote === void 0 ? "" : ` (${failedNote})`}` : result.reason === "portFailure" && failedNote !== void 0 ? portFailureDetail(failedNote) : result.reason === "deviceFailed" && failedNote !== void 0 ? failedNote : result.reason === "clickNotDelivered" && failedNote !== void 0 ? clickNotDeliveredDetail(failedNote) : navigationError !== null && result.outcome !== "complete" ? `${script.target} did not load (${navigationError}) \u2014 check that the app is running at that address` : void 0;
14397
- const detail = signedOutAfter !== null && result.reason !== null ? `${signedOutAfter} The take was not kept: it would end on the sign-in page. ${ownStop(result, ownDetail ?? reasonSentence(result.reason))}` : walked.reason === "signedOut" && failedNote !== void 0 ? `${failedNote} Nothing was filmed.` : ownDetail;
15104
+ const detail = signedOutAfter !== null && result.reason !== null ? `${signedOutAfter} The take was not kept: it would end on the sign-in page. ${ownStop(result, ownDetail ?? reasonSentence(result.reason))}` : walked.reason === "signedOut" && failedNote !== void 0 ? `${failedNote} Nothing was recorded.` : ownDetail;
14398
15105
  if (!signedOut) {
14399
15106
  await writeSessionBack(page2, launched.context, script.target, { ...deps, sessions }, notStored, log2);
14400
15107
  }
@@ -14423,7 +15130,7 @@ async function runScript(script, deps, onProgress) {
14423
15130
  const report = {
14424
15131
  ...built,
14425
15132
  ...landingNote === void 0 ? {} : { landing: landingNote },
14426
- ...deps.refilm === void 0 ? {} : { refilm: deps.refilm }
15133
+ ...deps.refilm === void 0 ? {} : { rerecord: deps.refilm }
14427
15134
  };
14428
15135
  if (takeId !== null) {
14429
15136
  await library.putJson(takeId, "report.json", deps.scrub === void 0 ? report : deps.scrub(report)).catch((error) => {
@@ -14491,7 +15198,7 @@ async function writeSessionBack(page2, context, target, deps, notStored, log2) {
14491
15198
  }
14492
15199
  try {
14493
15200
  const state = await context.storageState({ indexedDB: true });
14494
- const slice = sliceForSite(state, site);
15201
+ const slice = writeBackOf(state, loaded);
14495
15202
  const expiredBy = Date.now() / 1e3;
14496
15203
  const gone = loaded.state.cookies.filter((c) => !(c.expires > 0 && c.expires <= expiredBy) && !slice.cookies.some((n) => n.name === c.name && n.domain === c.domain && n.path === c.path));
14497
15204
  if (gone.length > 0) {
@@ -14534,6 +15241,8 @@ function stepWords(step) {
14534
15241
  return `scroll to ${nameOf2(step.on)}`;
14535
15242
  case "waitFor":
14536
15243
  return step.until === "visible" ? `wait for ${nameOf2(step.on)}` : `wait for ${nameOf2(step.on)} to go`;
15244
+ case "drag":
15245
+ return `drag ${nameOf2(step.from.on)} to ${"on" in step.to ? nameOf2(step.to.on) : "a point"}`;
14537
15246
  case "waitForLoad":
14538
15247
  return "wait for the page to load";
14539
15248
  case "pause":
@@ -14542,7 +15251,7 @@ function stepWords(step) {
14542
15251
  }
14543
15252
  function runningWords(script, completed, total) {
14544
15253
  if (completed >= total)
14545
- return "finishing the film";
15254
+ return "finishing the video";
14546
15255
  const where2 = `step ${completed + 1} of ${total}`;
14547
15256
  if (total !== authoredTotal(script))
14548
15257
  return where2;
@@ -14551,7 +15260,7 @@ function runningWords(script, completed, total) {
14551
15260
  }
14552
15261
 
14553
15262
  // ../runner/dist/executor/session-loader.js
14554
- function createSessionLoader(store) {
15263
+ function createSessionLoader(store, log2) {
14555
15264
  let loaded = /* @__PURE__ */ new WeakMap();
14556
15265
  return {
14557
15266
  /**
@@ -14579,8 +15288,12 @@ function createSessionLoader(store) {
14579
15288
  const stamp = `${read.stamp}#${choice === null ? "" : `${choice.origin} ${choice.name}`}`;
14580
15289
  const files = filesFor(read.files, choice);
14581
15290
  if (loaded.get(context) !== stamp) {
15291
+ const { state, dropped } = restorable(mergeStates(files));
15292
+ for (const db of dropped) {
15293
+ log2(`the saved IndexedDB database ${db} lost a record's key when it was saved, so it was not restored; the rest of the session was`);
15294
+ }
14582
15295
  try {
14583
- await context.setStorageState(mergeStates(files));
15296
+ await context.setStorageState(state);
14584
15297
  } catch (error) {
14585
15298
  return {
14586
15299
  ok: false,
@@ -14692,7 +15405,7 @@ function createLocalExecutor(options) {
14692
15405
  const library = createLibrary(home, options.updateCommand === void 0 ? {} : { updateCommand: options.updateCommand });
14693
15406
  const outDir = options.outDir ?? join15(homedir2(), "Downloads");
14694
15407
  const sessionStore = createSessionStore(home);
14695
- const sessions = createSessionLoader(sessionStore);
15408
+ const sessions = createSessionLoader(sessionStore, log2);
14696
15409
  const signinCommand = options.signinCommand ?? DEFAULT_SIGNIN_COMMAND;
14697
15410
  async function projectFolder(project) {
14698
15411
  if (project === void 0)
@@ -14774,7 +15487,7 @@ function createLocalExecutor(options) {
14774
15487
  };
14775
15488
  const hasSession = (files, c) => files.some((f) => f.account?.origin === c.site.origin && f.account.name === c.account.name && f.account.definition === accountDefinition(c.account));
14776
15489
  const stoppedAtStart = (report) => report.stopped?.reason === "signedOut" && report.steps.length === 0;
14777
- const stillSignedOut = (c, target) => `signed in as ${c.account.name} just now, but ${target} still sends this browser to its sign-in page: this account cannot open that page, or the sign-in did not really sign in (checkUrl is public, or the password is wrong) \u2014 choose another account, or film a page it can see`;
15490
+ const stillSignedOut = (c, target) => `signed in as ${c.account.name} just now, but ${target} still sends this browser to its sign-in page: this account cannot open that page, or the sign-in did not really sign in (checkUrl is public, or the password is wrong) \u2014 choose another account, or record a page it can see`;
14778
15491
  async function accountsForStatus() {
14779
15492
  const found = await findAccounts(projectDir);
14780
15493
  if (found.kind === "none") {
@@ -14839,9 +15552,9 @@ function createLocalExecutor(options) {
14839
15552
  async function displayForStatus() {
14840
15553
  try {
14841
15554
  const read = await readDisplay(options.env ?? process.env);
14842
- return "failed" in read ? { unreadable: displayUnreadSentence(read.failed, "films") } : read;
15555
+ return "failed" in read ? { unreadable: displayUnreadSentence(read.failed, "records") } : read;
14843
15556
  } catch (error) {
14844
- return { unreadable: displayUnreadSentence(messageOf4(error), "films") };
15557
+ return { unreadable: displayUnreadSentence(messageOf4(error), "records") };
14845
15558
  }
14846
15559
  }
14847
15560
  const session = createBrowserSession({
@@ -14914,7 +15627,7 @@ function createLocalExecutor(options) {
14914
15627
  const hasScript = args2.script !== void 0;
14915
15628
  const hasTake = args2.takeId !== void 0;
14916
15629
  if (hasScript === hasTake) {
14917
- return hasScript ? refusal("invalidScript", "run takes a script or the takeId of a take to re-film, not both", "script, takeId") : refusal("invalidScript", "run needs a script, or the takeId of a take to re-film", "script");
15630
+ return hasScript ? refusal("invalidScript", "run takes a script or the takeId of a take to re-record, not both", "script, takeId") : refusal("invalidScript", "run needs a script, or the takeId of a take to re-record", "script");
14918
15631
  }
14919
15632
  let raw = args2.script;
14920
15633
  let refilm;
@@ -19175,7 +19888,7 @@ function parseStudioArgs(args2) {
19175
19888
  }
19176
19889
 
19177
19890
  // src/version.ts
19178
- var VERSION = "0.7.0";
19891
+ var VERSION = "0.7.1";
19179
19892
 
19180
19893
  // src/main.ts
19181
19894
  var log = (line2) => {
@@ -19198,13 +19911,13 @@ function requirePageBundles(pages, say) {
19198
19911
  var USAGE = `demoman ${VERSION}
19199
19912
 
19200
19913
  npx demoman setup install the browser and connect your coding agents
19201
- npx demoman signin <url> sign in to your app once, so agents can film behind the login
19914
+ npx demoman signin <url> sign in to your app once, so agents can record behind the login
19202
19915
  npx demoman signin --account <name> [--site <origin>] [--project <dir>]
19203
19916
  sign in as a demo account from .demoman/accounts.json (CI, or a check)
19204
19917
  npx demoman studio [take] open the studio, to look over and edit takes and export them
19205
19918
  npx demoman studio --stop close the studio
19206
19919
  demoman mcp [--headed] serve Demoman's tools on stdio (your agent runs this);
19207
- --headed shows the browser while it films
19920
+ --headed shows the browser while it records
19208
19921
  demoman --version
19209
19922
  `;
19210
19923
  async function mcp(args2) {