@kvman/kvvideo 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/README.md +1 -1
  2. package/dist/api.d.ts +31 -0
  3. package/dist/api.d.ts.map +1 -1
  4. package/dist/brand/brand.d.ts +17 -0
  5. package/dist/brand/brand.d.ts.map +1 -0
  6. package/dist/brand/brand.js +44 -0
  7. package/dist/brand/brand.js.map +1 -0
  8. package/dist/browser/launch.d.ts +2 -0
  9. package/dist/browser/launch.d.ts.map +1 -1
  10. package/dist/browser/launch.js +7 -1
  11. package/dist/browser/launch.js.map +1 -1
  12. package/dist/compose/ass-file.d.ts +5 -0
  13. package/dist/compose/ass-file.d.ts.map +1 -1
  14. package/dist/compose/ass-file.js +32 -3
  15. package/dist/compose/ass-file.js.map +1 -1
  16. package/dist/compose/background.d.ts +23 -0
  17. package/dist/compose/background.d.ts.map +1 -0
  18. package/dist/compose/background.js +31 -0
  19. package/dist/compose/background.js.map +1 -0
  20. package/dist/compose/camera.d.ts +32 -0
  21. package/dist/compose/camera.d.ts.map +1 -0
  22. package/dist/compose/camera.js +98 -0
  23. package/dist/compose/camera.js.map +1 -0
  24. package/dist/compose/caption-font.d.ts +2 -0
  25. package/dist/compose/caption-font.d.ts.map +1 -1
  26. package/dist/compose/caption-font.js +2 -1
  27. package/dist/compose/caption-font.js.map +1 -1
  28. package/dist/compose/compose-drawing.d.ts +19 -0
  29. package/dist/compose/compose-drawing.d.ts.map +1 -0
  30. package/dist/compose/compose-drawing.js +38 -0
  31. package/dist/compose/compose-drawing.js.map +1 -0
  32. package/dist/compose/compose-input.d.ts +139 -0
  33. package/dist/compose/compose-input.d.ts.map +1 -1
  34. package/dist/compose/compose-input.js +48 -9
  35. package/dist/compose/compose-input.js.map +1 -1
  36. package/dist/compose/compose-plan.d.ts +36 -0
  37. package/dist/compose/compose-plan.d.ts.map +1 -0
  38. package/dist/compose/compose-plan.js +55 -0
  39. package/dist/compose/compose-plan.js.map +1 -0
  40. package/dist/compose/compose-size.d.ts +49 -0
  41. package/dist/compose/compose-size.d.ts.map +1 -0
  42. package/dist/compose/compose-size.js +67 -0
  43. package/dist/compose/compose-size.js.map +1 -0
  44. package/dist/compose/drawn-images.d.ts +19 -0
  45. package/dist/compose/drawn-images.d.ts.map +1 -0
  46. package/dist/compose/drawn-images.js +75 -0
  47. package/dist/compose/drawn-images.js.map +1 -0
  48. package/dist/compose/final-pass.d.ts +34 -0
  49. package/dist/compose/final-pass.d.ts.map +1 -0
  50. package/dist/compose/final-pass.js +106 -0
  51. package/dist/compose/final-pass.js.map +1 -0
  52. package/dist/compose/frame-layout.d.ts +30 -0
  53. package/dist/compose/frame-layout.d.ts.map +1 -0
  54. package/dist/compose/frame-layout.js +33 -0
  55. package/dist/compose/frame-layout.js.map +1 -0
  56. package/dist/compose/overlays.d.ts +20 -0
  57. package/dist/compose/overlays.d.ts.map +1 -0
  58. package/dist/compose/overlays.js +30 -0
  59. package/dist/compose/overlays.js.map +1 -0
  60. package/dist/compose/page-again.d.ts +26 -0
  61. package/dist/compose/page-again.d.ts.map +1 -0
  62. package/dist/compose/page-again.js +50 -0
  63. package/dist/compose/page-again.js.map +1 -0
  64. package/dist/compose/player-copies.d.ts +5 -1
  65. package/dist/compose/player-copies.d.ts.map +1 -1
  66. package/dist/compose/player-copies.js +19 -16
  67. package/dist/compose/player-copies.js.map +1 -1
  68. package/dist/compose/register-compose.d.ts.map +1 -1
  69. package/dist/compose/register-compose.js +104 -20
  70. package/dist/compose/register-compose.js.map +1 -1
  71. package/dist/compose/render.d.ts +13 -4
  72. package/dist/compose/render.d.ts.map +1 -1
  73. package/dist/compose/render.js +48 -22
  74. package/dist/compose/render.js.map +1 -1
  75. package/dist/compose/scene-args.d.ts +32 -7
  76. package/dist/compose/scene-args.d.ts.map +1 -1
  77. package/dist/compose/scene-args.js +77 -16
  78. package/dist/compose/scene-args.js.map +1 -1
  79. package/dist/compose/scene-look.d.ts +31 -0
  80. package/dist/compose/scene-look.d.ts.map +1 -0
  81. package/dist/compose/scene-look.js +46 -0
  82. package/dist/compose/scene-look.js.map +1 -0
  83. package/dist/compose/scene-plan.d.ts +0 -2
  84. package/dist/compose/scene-plan.d.ts.map +1 -1
  85. package/dist/compose/scene-plan.js +7 -5
  86. package/dist/compose/scene-plan.js.map +1 -1
  87. package/dist/compose/sound-effects.d.ts +23 -0
  88. package/dist/compose/sound-effects.d.ts.map +1 -0
  89. package/dist/compose/sound-effects.js +40 -0
  90. package/dist/compose/sound-effects.js.map +1 -0
  91. package/dist/compose/transitions.d.ts +16 -0
  92. package/dist/compose/transitions.d.ts.map +1 -0
  93. package/dist/compose/transitions.js +38 -0
  94. package/dist/compose/transitions.js.map +1 -0
  95. package/dist/connector.d.ts +79 -14
  96. package/dist/connector.d.ts.map +1 -1
  97. package/dist/connector.js +33 -8
  98. package/dist/connector.js.map +1 -1
  99. package/dist/files/sidecar.d.ts +209 -0
  100. package/dist/files/sidecar.d.ts.map +1 -0
  101. package/dist/files/sidecar.js +66 -0
  102. package/dist/files/sidecar.js.map +1 -0
  103. package/dist/index.d.ts.map +1 -1
  104. package/dist/index.js +9 -1
  105. package/dist/index.js.map +1 -1
  106. package/dist/look/look-at.d.ts +15 -0
  107. package/dist/look/look-at.d.ts.map +1 -0
  108. package/dist/look/look-at.js +20 -0
  109. package/dist/look/look-at.js.map +1 -0
  110. package/dist/look/look-input.d.ts +22 -0
  111. package/dist/look/look-input.d.ts.map +1 -0
  112. package/dist/look/look-input.js +25 -0
  113. package/dist/look/look-input.js.map +1 -0
  114. package/dist/look/register-look.d.ts +3 -0
  115. package/dist/look/register-look.d.ts.map +1 -0
  116. package/dist/look/register-look.js +52 -0
  117. package/dist/look/register-look.js.map +1 -0
  118. package/dist/narration/alignment.d.ts +15 -0
  119. package/dist/narration/alignment.d.ts.map +1 -0
  120. package/dist/narration/alignment.js +21 -0
  121. package/dist/narration/alignment.js.map +1 -0
  122. package/dist/narration/captions.d.ts +22 -4
  123. package/dist/narration/captions.d.ts.map +1 -1
  124. package/dist/narration/captions.js +44 -16
  125. package/dist/narration/captions.js.map +1 -1
  126. package/dist/narration/join-args.d.ts +3 -0
  127. package/dist/narration/join-args.d.ts.map +1 -0
  128. package/dist/narration/join-args.js +19 -0
  129. package/dist/narration/join-args.js.map +1 -0
  130. package/dist/narration/narration-cache.d.ts +25 -0
  131. package/dist/narration/narration-cache.d.ts.map +1 -0
  132. package/dist/narration/narration-cache.js +36 -0
  133. package/dist/narration/narration-cache.js.map +1 -0
  134. package/dist/narration/piper.d.ts +2 -6
  135. package/dist/narration/piper.d.ts.map +1 -1
  136. package/dist/narration/piper.js +9 -15
  137. package/dist/narration/piper.js.map +1 -1
  138. package/dist/narration/pronunciations.d.ts +11 -0
  139. package/dist/narration/pronunciations.d.ts.map +1 -0
  140. package/dist/narration/pronunciations.js +40 -0
  141. package/dist/narration/pronunciations.js.map +1 -0
  142. package/dist/narration/register-narration.d.ts +8 -0
  143. package/dist/narration/register-narration.d.ts.map +1 -1
  144. package/dist/narration/register-narration.js +54 -26
  145. package/dist/narration/register-narration.js.map +1 -1
  146. package/dist/narration/register-voice.d.ts +27 -0
  147. package/dist/narration/register-voice.d.ts.map +1 -0
  148. package/dist/narration/register-voice.js +82 -0
  149. package/dist/narration/register-voice.js.map +1 -0
  150. package/dist/narration/sentence-speaker.d.ts +35 -0
  151. package/dist/narration/sentence-speaker.d.ts.map +1 -0
  152. package/dist/narration/sentence-speaker.js +44 -0
  153. package/dist/narration/sentence-speaker.js.map +1 -0
  154. package/dist/narration/speech-services.d.ts +23 -3
  155. package/dist/narration/speech-services.d.ts.map +1 -1
  156. package/dist/narration/speech-services.js +27 -10
  157. package/dist/narration/speech-services.js.map +1 -1
  158. package/dist/narration/voice-args.d.ts +3 -0
  159. package/dist/narration/voice-args.d.ts.map +1 -0
  160. package/dist/narration/voice-args.js +10 -0
  161. package/dist/narration/voice-args.js.map +1 -0
  162. package/dist/programs/media-duration.d.ts +12 -0
  163. package/dist/programs/media-duration.d.ts.map +1 -1
  164. package/dist/programs/media-duration.js +13 -0
  165. package/dist/programs/media-duration.js.map +1 -1
  166. package/dist/programs/run-program.d.ts +1 -0
  167. package/dist/programs/run-program.d.ts.map +1 -1
  168. package/dist/programs/run-program.js +1 -0
  169. package/dist/programs/run-program.js.map +1 -1
  170. package/dist/record/address.d.ts +1 -1
  171. package/dist/record/address.d.ts.map +1 -1
  172. package/dist/record/address.js +5 -7
  173. package/dist/record/address.js.map +1 -1
  174. package/dist/record/cursor-script.d.ts +2 -1
  175. package/dist/record/cursor-script.d.ts.map +1 -1
  176. package/dist/record/cursor-script.js +52 -14
  177. package/dist/record/cursor-script.js.map +1 -1
  178. package/dist/record/encoder-args.js +1 -1
  179. package/dist/record/motion.d.ts +19 -0
  180. package/dist/record/motion.d.ts.map +1 -0
  181. package/dist/record/motion.js +59 -0
  182. package/dist/record/motion.js.map +1 -0
  183. package/dist/record/narration-cues.d.ts +14 -0
  184. package/dist/record/narration-cues.d.ts.map +1 -0
  185. package/dist/record/narration-cues.js +12 -0
  186. package/dist/record/narration-cues.js.map +1 -0
  187. package/dist/record/page-clock.d.ts +7 -0
  188. package/dist/record/page-clock.d.ts.map +1 -0
  189. package/dist/record/page-clock.js +13 -0
  190. package/dist/record/page-clock.js.map +1 -0
  191. package/dist/record/page-ready.d.ts +4 -0
  192. package/dist/record/page-ready.d.ts.map +1 -0
  193. package/dist/record/page-ready.js +15 -0
  194. package/dist/record/page-ready.js.map +1 -0
  195. package/dist/record/page-route.d.ts +13 -0
  196. package/dist/record/page-route.d.ts.map +1 -0
  197. package/dist/record/page-route.js +64 -0
  198. package/dist/record/page-route.js.map +1 -0
  199. package/dist/record/pointer.d.ts +6 -7
  200. package/dist/record/pointer.d.ts.map +1 -1
  201. package/dist/record/pointer.js +11 -10
  202. package/dist/record/pointer.js.map +1 -1
  203. package/dist/record/record-source.d.ts +16 -0
  204. package/dist/record/record-source.d.ts.map +1 -0
  205. package/dist/record/record-source.js +11 -0
  206. package/dist/record/record-source.js.map +1 -0
  207. package/dist/record/recorder.d.ts +19 -7
  208. package/dist/record/recorder.d.ts.map +1 -1
  209. package/dist/record/recorder.js +52 -18
  210. package/dist/record/recorder.js.map +1 -1
  211. package/dist/record/register-record.d.ts.map +1 -1
  212. package/dist/record/register-record.js +45 -13
  213. package/dist/record/register-record.js.map +1 -1
  214. package/dist/record/run-step.d.ts +16 -3
  215. package/dist/record/run-step.d.ts.map +1 -1
  216. package/dist/record/run-step.js +43 -23
  217. package/dist/record/run-step.js.map +1 -1
  218. package/dist/record/screencast.js +1 -1
  219. package/dist/record/steps.d.ts +56 -1
  220. package/dist/record/steps.d.ts.map +1 -1
  221. package/dist/record/steps.js +36 -18
  222. package/dist/record/steps.js.map +1 -1
  223. package/dist/review/analysis.d.ts +19 -0
  224. package/dist/review/analysis.d.ts.map +1 -0
  225. package/dist/review/analysis.js +36 -0
  226. package/dist/review/analysis.js.map +1 -0
  227. package/dist/review/frames.d.ts +9 -0
  228. package/dist/review/frames.d.ts.map +1 -0
  229. package/dist/review/frames.js +28 -0
  230. package/dist/review/frames.js.map +1 -0
  231. package/dist/review/register-review.d.ts +24 -0
  232. package/dist/review/register-review.d.ts.map +1 -0
  233. package/dist/review/register-review.js +81 -0
  234. package/dist/review/register-review.js.map +1 -0
  235. package/dist/review/sheet-args.d.ts +11 -0
  236. package/dist/review/sheet-args.d.ts.map +1 -0
  237. package/dist/review/sheet-args.js +24 -0
  238. package/dist/review/sheet-args.js.map +1 -0
  239. package/dist/settings.d.ts +4 -0
  240. package/dist/settings.d.ts.map +1 -1
  241. package/dist/settings.js +4 -2
  242. package/dist/settings.js.map +1 -1
  243. package/dist/setup/ffmpeg-readiness.js +1 -1
  244. package/dist/setup/ffmpeg-readiness.js.map +1 -1
  245. package/dist/ui.d.ts.map +1 -1
  246. package/dist/ui.js +3 -2
  247. package/dist/ui.js.map +1 -1
  248. package/dist/web/components/player.css +1 -1
  249. package/dist/web/components/player.js +33 -21
  250. package/docs/guide.md +39 -10
  251. package/locales/ar.json +12 -1
  252. package/locales/en.json +12 -1
  253. package/package.json +11 -5
  254. package/sounds/SOURCES.md +13 -0
  255. package/sounds/click.wav +0 -0
  256. package/sounds/keys.wav +0 -0
  257. package/sounds/pop.wav +0 -0
  258. package/sounds/whoosh.wav +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"register-record.d.ts","sourceRoot":"","sources":["../../src/record/register-record.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAetC,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CA+B7C"}
1
+ {"version":3,"file":"register-record.d.ts","sourceRoot":"","sources":["../../src/record/register-record.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAqCtC,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAwC7C"}
@@ -3,17 +3,42 @@ import { launchChannel } from "../browser/launch.js";
3
3
  import { startBrowser } from "../browser/start-browser.js";
4
4
  import { answerPath } from "../files/answer-path.js";
5
5
  import { placeOutput, workFolder } from "../files/place-output.js";
6
- import { outputPath } from "../files/workspace-paths.js";
6
+ import { readSidecar, sidecarOutputPath, writeSidecar } from "../files/sidecar.js";
7
+ import { inputPath, outputPath } from "../files/workspace-paths.js";
7
8
  import { programOf } from "../programs/programs.js";
8
- import { localAddress } from "./address.js";
9
+ import { invalid } from "../problems.js";
10
+ import { audioExtensions } from "../compose/scene-plan.js";
11
+ import { recordableAddress } from "./address.js";
12
+ import { cuesOf } from "./narration-cues.js";
9
13
  import { ownPortOf } from "./own-port.js";
10
14
  import { record } from "./recorder.js";
15
+ import { defaultSize, sourceOf } from "./record-source.js";
11
16
  import { recordInputSchema, recordOutputSchema } from "./steps.js";
12
- // `video record` (plan 16 §16.5): every address and the output are checked before a browser starts; the browser is
13
- // closed when the call ends, fails, or is cancelled, and the work folder removed.
17
+ // `video record` (plan 16 §16.5): the addresses, the page, the narration, and the outputs are checked before a browser
18
+ // starts; the browser is closed when the call ends, fails, or is cancelled, and the work folder removed. The
19
+ // recording's sidecar is placed beside it (ADR 0115, 31).
20
+ function recordSourceOf(root, input, ownPort) {
21
+ for (const step of input.steps ?? [])
22
+ if (step.do === 'goto')
23
+ recordableAddress(step.url, ownPort);
24
+ return sourceOf(root, input, ownPort);
25
+ }
26
+ function cuesFor(root, input) {
27
+ if (input.narration === undefined)
28
+ return undefined;
29
+ const narration = readSidecar(inputPath(root, input.narration, audioExtensions));
30
+ if (narration?.kind !== 'narration')
31
+ throw invalid(`${input.narration} has no captions beside it; make it with narrate or voice.`, { path: input.narration });
32
+ const lines = narration.captions.length;
33
+ for (const step of input.steps ?? []) {
34
+ if (step.do !== 'wait' && step.atLine !== undefined && step.atLine > lines)
35
+ throw invalid(`atLine ${String(step.atLine)} is past the narration's ${String(lines)} caption lines.`, { atLine: step.atLine, lines });
36
+ }
37
+ return cuesOf(narration);
38
+ }
14
39
  export function registerRecord(ctx) {
15
40
  ctx.registerCommand('kvvideo.clip.record', {
16
- description: 'Records a page of an app running on this computer, with its steps, as an MP4 file in the workspace.',
41
+ description: 'Records a website or an HTML page of the workspace, with its steps, as an MP4 file in the workspace.',
17
42
  input: recordInputSchema,
18
43
  output: recordOutputSchema,
19
44
  public: true,
@@ -22,21 +47,28 @@ export function registerRecord(ctx) {
22
47
  handle: async (input) => {
23
48
  const root = ctx.job.workspace.path;
24
49
  const ownPort = ownPortOf(process.env['KVMAN_HOME']);
25
- const url = localAddress(input.url, ownPort).href;
26
- for (const step of input.steps ?? [])
27
- if (step.do === 'goto')
28
- localAddress(step.url, ownPort);
29
- const output = outputPath(root, input.file, '.mp4', input.replace === true);
50
+ const source = recordSourceOf(root, input, ownPort);
51
+ const cues = cuesFor(root, input);
52
+ const replace = input.replace === true;
53
+ const output = outputPath(root, input.file, '.mp4', replace);
54
+ const sidecar = sidecarOutputPath(output, replace, input.file);
55
+ const device = input.device ?? 'desktop';
56
+ const width = input.width ?? defaultSize[device].width;
57
+ const height = input.height ?? defaultSize[device].height;
30
58
  const ffmpeg = await programOf(ctx, 'ffmpeg');
31
59
  const browser = await startBrowser(await ctx.settings.get('kvvideo.browser'), launchChannel);
32
60
  const work = workFolder();
33
61
  const stop = () => void browser.close();
34
62
  ctx.job.signal.addEventListener('abort', stop, { once: true });
35
63
  try {
36
- const plan = { url, steps: input.steps ?? [], width: input.width ?? 1280, height: input.height ?? 720, folder: work.folder, ownPort, ffmpeg, signal: ctx.job.signal, now: () => performance.now() };
37
- const recording = await record(browser, plan);
64
+ const stepStarted = (n, of) => ctx.job.progress({ key: 'kvvideo.progress.step', params: { n, of } });
65
+ const recording = await record(browser, { source, steps: input.steps ?? [], width, height, device, cues, folder: work.folder, ownPort, ffmpeg, signal: ctx.job.signal, now: () => performance.now(), stepStarted });
66
+ const steps = input.steps ?? [];
67
+ const sourceName = source.kind === 'site' ? source.url : answerPath(root, source.file);
68
+ const made = writeSidecar(work.folder, { kind: source.kind, source: sourceName, width, height, device, scale: 2, durationMs: recording.durationMs, steps: [...steps], actions: recording.actions });
38
69
  placeOutput(recording.video, output);
39
- return { file: answerPath(root, output), durationMs: recording.durationMs, steps: recording.steps };
70
+ placeOutput(made, sidecar);
71
+ return { file: answerPath(root, output), durationMs: recording.durationMs, steps: recording.actions };
40
72
  }
41
73
  finally {
42
74
  ctx.job.signal.removeEventListener('abort', stop);
@@ -1 +1 @@
1
- {"version":3,"file":"register-record.js","sourceRoot":"","sources":["../../src/record/register-record.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,E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AAC;gBACpM,WAAW,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;gBACrC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;gBAC3B,OAAO,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,UAAU,EAAE,SAAS,CAAC,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,OAAO,EAAE,CAAC;YACxG,CAAC;oBAAS,CAAC;gBACT,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;gBAClD,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;gBACtB,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,CAAC;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -1,7 +1,20 @@
1
1
  import type { Page } from 'playwright-core';
2
- import { type Pointer } from './pointer.ts';
3
- import type { Step } from './steps.ts';
4
- export declare function runStep(page: Page, step: Step, pointer: Pointer): Promise<Pointer>;
2
+ import { type Point } from './motion.ts';
3
+ import type { Box, Step } from './steps.ts';
4
+ export type StepState = {
5
+ page: Page;
6
+ device: 'desktop' | 'phone';
7
+ pointer: Point;
8
+ elapsed(): number;
9
+ };
10
+ export type StepResult = {
11
+ pointer: Point;
12
+ act?: {
13
+ atMs: number;
14
+ box: Box;
15
+ };
16
+ };
17
+ export declare function runStep(state: StepState, step: Step): Promise<StepResult>;
5
18
  /** Whether the page is held a moment after the step, so the viewer sees what it did. */
6
19
  export declare function pausesAfter(step: Step): boolean;
7
20
  //# sourceMappingURL=run-step.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"run-step.d.ts","sourceRoot":"","sources":["../../src/record/run-step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAqB,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAgBvC,wBAAsB,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CA+BxF;AAED,wFAAwF;AACxF,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAE/C"}
1
+ {"version":3,"file":"run-step.d.ts","sourceRoot":"","sources":["../../src/record/run-step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAqC,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAE5E,OAAO,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAK5C,MAAM,MAAM,SAAS,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC;IAAC,OAAO,EAAE,KAAK,CAAC;IAAC,OAAO,IAAI,MAAM,CAAA;CAAE,CAAC;AAEvG,MAAM,MAAM,UAAU,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,GAAG,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,GAAG,CAAA;KAAE,CAAA;CAAE,CAAC;AA+B9E,wBAAsB,OAAO,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,CAgC/E;AAED,wFAAwF;AACxF,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAE/C"}
@@ -1,45 +1,65 @@
1
- import { centerOf, glideTo } from "./pointer.js";
2
- // What each step does on the page (plan 16 §16.5). It answers where the mouse is afterwards.
3
- const scrollStep = 100;
1
+ import { frameMs, scrollPlan, typingDelays } from "./motion.js";
2
+ import { centerOf, glideTo, targetBox } from "./pointer.js";
3
+ async function typeText(page, text) {
4
+ const delays = typingDelays(text);
5
+ for (const [index, character] of [...text].entries()) {
6
+ await page.waitForTimeout(delays[index] ?? 0);
7
+ await page.keyboard.type(character);
8
+ }
9
+ }
4
10
  async function scroll(page, pixels) {
5
- let left = pixels;
6
- while (left !== 0) {
7
- const part = Math.sign(left) * Math.min(scrollStep, Math.abs(left));
8
- await page.mouse.wheel(0, part);
9
- await page.waitForTimeout(30);
10
- left -= part;
11
+ for (const move of scrollPlan(pixels).moves) {
12
+ if (move !== 0)
13
+ await page.mouse.wheel(0, move);
14
+ await page.waitForTimeout(frameMs);
11
15
  }
12
16
  }
13
- export async function runStep(page, step, pointer) {
17
+ // Brings the pointer or the finger to the target, and answers where it is and when it arrived.
18
+ async function reach(state, target) {
19
+ const box = await targetBox(state.page, target);
20
+ const center = centerOf(box);
21
+ if (state.device === 'phone')
22
+ return { pointer: center, act: { atMs: state.elapsed(), box } };
23
+ const pointer = await glideTo(state.page, state.pointer, center);
24
+ return { pointer, act: { atMs: state.elapsed(), box } };
25
+ }
26
+ async function press(state, at) {
27
+ if (state.device === 'phone')
28
+ await state.page.touchscreen.tap(at.x, at.y);
29
+ else
30
+ await state.page.mouse.click(at.x, at.y);
31
+ }
32
+ export async function runStep(state, step) {
33
+ const { page } = state;
14
34
  switch (step.do) {
15
35
  case 'goto':
16
36
  await page.goto(step.url, { waitUntil: 'load', timeout: 30_000 });
17
- return pointer;
37
+ return { pointer: state.pointer };
18
38
  case 'click': {
19
- const at = await glideTo(page, pointer, await centerOf(page, step.target));
20
- await page.mouse.click(at.x, at.y);
21
- return at;
39
+ const reached = await reach(state, step.target);
40
+ await press(state, reached.pointer);
41
+ return reached;
22
42
  }
23
43
  case 'type': {
24
- const at = await glideTo(page, pointer, await centerOf(page, step.target));
25
- await page.mouse.click(at.x, at.y);
26
- await page.keyboard.type(step.text, { delay: 50 });
27
- return at;
44
+ const reached = await reach(state, step.target);
45
+ await press(state, reached.pointer);
46
+ await typeText(page, step.text);
47
+ return reached;
28
48
  }
29
49
  case 'press':
30
50
  await page.keyboard.press(step.key);
31
- return pointer;
51
+ return { pointer: state.pointer };
32
52
  case 'hover':
33
- return glideTo(page, pointer, await centerOf(page, step.target));
53
+ return reach(state, step.target);
34
54
  case 'scroll':
35
55
  await scroll(page, step.pixels);
36
- return pointer;
56
+ return { pointer: state.pointer };
37
57
  case 'wait':
38
58
  await page.waitForTimeout(step.ms);
39
- return pointer;
59
+ return { pointer: state.pointer };
40
60
  case 'waitFor':
41
61
  await page.locator(step.target).first().waitFor({ state: 'visible', timeout: 10_000 });
42
- return pointer;
62
+ return { pointer: state.pointer };
43
63
  }
44
64
  }
45
65
  /** Whether the page is held a moment after the step, so the viewer sees what it did. */
@@ -1 +1 @@
1
- {"version":3,"file":"run-step.js","sourceRoot":"","sources":["../../src/record/run-step.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAgB,MAAM,cAAc,CAAC;AAG/D,6FAA6F;AAE7F,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB,KAAK,UAAU,MAAM,CAAC,IAAU,EAAE,MAAc;IAC9C,IAAI,IAAI,GAAG,MAAM,CAAC;IAClB,OAAO,IAAI,KAAK,CAAC,EAAE,CAAC;QAClB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;QACpE,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QAChC,MAAM,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;QAC9B,IAAI,IAAI,IAAI,CAAC;IACf,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,IAAU,EAAE,IAAU,EAAE,OAAgB;IACpE,QAAQ,IAAI,CAAC,EAAE,EAAE,CAAC;QAChB,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ACnC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;QACpC,KAAK,SAAS;YACZ,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;YACvF,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;IACtC,CAAC;AACH,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,WAAW,CAAC,IAAU;IACpC,OAAO,IAAI,CAAC,EAAE,KAAK,MAAM,IAAI,IAAI,CAAC,EAAE,KAAK,SAAS,CAAC;AACrD,CAAC"}
@@ -23,7 +23,7 @@ export async function startScreencast(page, size, onFrame, now) {
23
23
  }
24
24
  });
25
25
  });
26
- await session.send('Page.startScreencast', { format: 'jpeg', quality: 90, maxWidth: size.width, maxHeight: size.height, everyNthFrame: 1 });
26
+ await session.send('Page.startScreencast', { format: 'jpeg', quality: 95, maxWidth: size.width, maxHeight: size.height, everyNthFrame: 1 });
27
27
  return {
28
28
  stop: async () => {
29
29
  stopped = true;
@@ -1,71 +1,126 @@
1
1
  import { z } from '@kvman/sdk';
2
+ export declare const address: z.ZodString;
2
3
  export declare const stepSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
3
4
  do: z.ZodLiteral<"goto">;
4
5
  url: z.ZodString;
6
+ atLine: z.ZodExactOptional<z.ZodNumber>;
5
7
  }, z.core.$strict>, z.ZodObject<{
6
8
  do: z.ZodLiteral<"click">;
7
9
  target: z.ZodString;
10
+ atLine: z.ZodExactOptional<z.ZodNumber>;
8
11
  }, z.core.$strict>, z.ZodObject<{
9
12
  do: z.ZodLiteral<"type">;
10
13
  target: z.ZodString;
11
14
  text: z.ZodString;
15
+ atLine: z.ZodExactOptional<z.ZodNumber>;
12
16
  }, z.core.$strict>, z.ZodObject<{
13
17
  do: z.ZodLiteral<"press">;
14
18
  key: z.ZodString;
19
+ atLine: z.ZodExactOptional<z.ZodNumber>;
15
20
  }, z.core.$strict>, z.ZodObject<{
16
21
  do: z.ZodLiteral<"hover">;
17
22
  target: z.ZodString;
23
+ atLine: z.ZodExactOptional<z.ZodNumber>;
18
24
  }, z.core.$strict>, z.ZodObject<{
19
25
  do: z.ZodLiteral<"scroll">;
20
26
  pixels: z.ZodNumber;
27
+ atLine: z.ZodExactOptional<z.ZodNumber>;
21
28
  }, z.core.$strict>, z.ZodObject<{
22
29
  do: z.ZodLiteral<"wait">;
23
30
  ms: z.ZodNumber;
24
31
  }, z.core.$strict>, z.ZodObject<{
25
32
  do: z.ZodLiteral<"waitFor">;
26
33
  target: z.ZodString;
34
+ atLine: z.ZodExactOptional<z.ZodNumber>;
27
35
  }, z.core.$strict>], "do">;
28
36
  /** One step of a recording. */
29
37
  export type Step = z.output<typeof stepSchema>;
38
+ export declare const side: z.ZodNumber;
30
39
  export declare const recordInputSchema: z.ZodObject<{
31
- url: z.ZodString;
40
+ url: z.ZodExactOptional<z.ZodString>;
41
+ page: z.ZodExactOptional<z.ZodString>;
32
42
  steps: z.ZodExactOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
33
43
  do: z.ZodLiteral<"goto">;
34
44
  url: z.ZodString;
45
+ atLine: z.ZodExactOptional<z.ZodNumber>;
35
46
  }, z.core.$strict>, z.ZodObject<{
36
47
  do: z.ZodLiteral<"click">;
37
48
  target: z.ZodString;
49
+ atLine: z.ZodExactOptional<z.ZodNumber>;
38
50
  }, z.core.$strict>, z.ZodObject<{
39
51
  do: z.ZodLiteral<"type">;
40
52
  target: z.ZodString;
41
53
  text: z.ZodString;
54
+ atLine: z.ZodExactOptional<z.ZodNumber>;
42
55
  }, z.core.$strict>, z.ZodObject<{
43
56
  do: z.ZodLiteral<"press">;
44
57
  key: z.ZodString;
58
+ atLine: z.ZodExactOptional<z.ZodNumber>;
45
59
  }, z.core.$strict>, z.ZodObject<{
46
60
  do: z.ZodLiteral<"hover">;
47
61
  target: z.ZodString;
62
+ atLine: z.ZodExactOptional<z.ZodNumber>;
48
63
  }, z.core.$strict>, z.ZodObject<{
49
64
  do: z.ZodLiteral<"scroll">;
50
65
  pixels: z.ZodNumber;
66
+ atLine: z.ZodExactOptional<z.ZodNumber>;
51
67
  }, z.core.$strict>, z.ZodObject<{
52
68
  do: z.ZodLiteral<"wait">;
53
69
  ms: z.ZodNumber;
54
70
  }, z.core.$strict>, z.ZodObject<{
55
71
  do: z.ZodLiteral<"waitFor">;
56
72
  target: z.ZodString;
73
+ atLine: z.ZodExactOptional<z.ZodNumber>;
57
74
  }, z.core.$strict>], "do">>>;
58
75
  file: z.ZodString;
59
76
  width: z.ZodExactOptional<z.ZodNumber>;
60
77
  height: z.ZodExactOptional<z.ZodNumber>;
78
+ device: z.ZodExactOptional<z.ZodEnum<{
79
+ phone: "phone";
80
+ desktop: "desktop";
81
+ }>>;
82
+ narration: z.ZodExactOptional<z.ZodString>;
61
83
  replace: z.ZodExactOptional<z.ZodBoolean>;
62
84
  }, z.core.$strict>;
85
+ /** A recording's input. */
86
+ export type RecordInput = z.output<typeof recordInputSchema>;
87
+ declare const boxSchema: z.ZodObject<{
88
+ x: z.ZodNumber;
89
+ y: z.ZodNumber;
90
+ width: z.ZodNumber;
91
+ height: z.ZodNumber;
92
+ }, z.core.$strip>;
93
+ /** A target's box, in CSS pixels of the viewport. */
94
+ export type Box = z.output<typeof boxSchema>;
95
+ export declare const actionSchema: z.ZodObject<{
96
+ do: z.ZodString;
97
+ atMs: z.ZodNumber;
98
+ actMs: z.ZodOptional<z.ZodNumber>;
99
+ endMs: z.ZodNumber;
100
+ box: z.ZodOptional<z.ZodObject<{
101
+ x: z.ZodNumber;
102
+ y: z.ZodNumber;
103
+ width: z.ZodNumber;
104
+ height: z.ZodNumber;
105
+ }, z.core.$strip>>;
106
+ }, z.core.$strip>;
107
+ /** What a step did, and when, from the recording's start. */
108
+ export type Action = z.output<typeof actionSchema>;
63
109
  export declare const recordOutputSchema: z.ZodObject<{
64
110
  file: z.ZodString;
65
111
  durationMs: z.ZodNumber;
66
112
  steps: z.ZodArray<z.ZodObject<{
67
113
  do: z.ZodString;
68
114
  atMs: z.ZodNumber;
115
+ actMs: z.ZodOptional<z.ZodNumber>;
116
+ endMs: z.ZodNumber;
117
+ box: z.ZodOptional<z.ZodObject<{
118
+ x: z.ZodNumber;
119
+ y: z.ZodNumber;
120
+ width: z.ZodNumber;
121
+ height: z.ZodNumber;
122
+ }, z.core.$strip>>;
69
123
  }, z.core.$strip>>;
70
124
  }, z.core.$strip>;
125
+ export {};
71
126
  //# sourceMappingURL=steps.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"steps.d.ts","sourceRoot":"","sources":["../../src/record/steps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,YAAY,CAAC;AAO/B,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;0BASrB,CAAC;AAEH,+BAA+B;AAC/B,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AAI/C,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAO5B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;iBAI7B,CAAC"}
1
+ {"version":3,"file":"steps.d.ts","sourceRoot":"","sources":["../../src/record/steps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,YAAY,CAAC;AAM/B,eAAO,MAAM,OAAO,aAA8B,CAAC;AAGnD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BASrB,CAAC;AAEH,+BAA+B;AAC/B,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AAE/C,eAAO,MAAM,IAAI,aAAkH,CAAC;AAcpI,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAK5B,CAAC;AAEH,2BAA2B;AAC3B,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE7D,QAAA,MAAM,SAAS;;;;;iBAAwI,CAAC;AAExJ,qDAAqD;AACrD,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,SAAS,CAAC,CAAC;AAE7C,eAAO,MAAM,YAAY;;;;;;;;;;;iBAMvB,CAAC;AAEH,6DAA6D;AAC7D,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,YAAY,CAAC,CAAC;AAEnD,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;iBAA2G,CAAC"}
@@ -1,29 +1,47 @@
1
1
  import { z } from '@kvman/sdk';
2
- // A recording's input (plan 16 §16.5): the page, up to 200 steps, the size, and the output.
2
+ // A recording's input and answer (plan 16 §16.5): a website or a page of the workspace, up to 200 steps, the size and
3
+ // device, the narration whose caption lines the steps may wait for, and the output.
3
4
  const target = z.string().min(1).max(500).describe('A Playwright selector: CSS, text=Save, or role=button[name="Save"]; its first match is used once visible.');
4
- const address = z.string().min(1).max(2000);
5
+ export const address = z.string().min(1).max(2000);
6
+ const atLine = z.number().int().min(1).max(1000).describe('Start no earlier than this caption line (from 1) of the narration is heard.').exactOptional();
5
7
  export const stepSchema = z.discriminatedUnion('do', [
6
- z.strictObject({ do: z.literal('goto'), url: address.describe('A localhost address to open.') }),
7
- z.strictObject({ do: z.literal('click'), target }),
8
- z.strictObject({ do: z.literal('type'), target, text: z.string().min(1).max(2000).describe('The text typed, one character every 50 ms.') }),
9
- z.strictObject({ do: z.literal('press'), key: z.string().min(1).max(100).describe('A key or combination, as Enter or Control+A.') }),
10
- z.strictObject({ do: z.literal('hover'), target }),
11
- z.strictObject({ do: z.literal('scroll'), pixels: z.number().int().min(-20_000).max(20_000).describe('Pixels to scroll down; negative scrolls up.') }),
8
+ z.strictObject({ do: z.literal('goto'), url: address.describe('An http or https address to open.'), atLine }),
9
+ z.strictObject({ do: z.literal('click'), target, atLine }),
10
+ z.strictObject({ do: z.literal('type'), target, text: z.string().min(1).max(2000).describe('The text typed, at a natural pace.'), atLine }),
11
+ z.strictObject({ do: z.literal('press'), key: z.string().min(1).max(100).describe('A key or combination, as Enter or Control+A.'), atLine }),
12
+ z.strictObject({ do: z.literal('hover'), target, atLine }),
13
+ z.strictObject({ do: z.literal('scroll'), pixels: z.number().int().min(-20_000).max(20_000).describe('Pixels to scroll down; negative scrolls up.'), atLine }),
12
14
  z.strictObject({ do: z.literal('wait'), ms: z.number().int().min(0).max(60_000).describe('How long the picture holds.') }),
13
- z.strictObject({ do: z.literal('waitFor'), target }),
15
+ z.strictObject({ do: z.literal('waitFor'), target, atLine }),
14
16
  ]);
15
- const side = z.number().int().min(320).max(1920).refine((pixels) => pixels % 2 === 0, 'A side is an even number of pixels.');
16
- export const recordInputSchema = z.strictObject({
17
- url: address.describe('The page to record: http or https on localhost, 127.0.0.1, or [::1].'),
17
+ export const side = z.number().int().min(320).max(1920).refine((pixels) => pixels % 2 === 0, 'A side is an even number of pixels.');
18
+ const recordFields = z.strictObject({
19
+ url: address.describe('A website to record: any http or https address.').exactOptional(),
20
+ page: z.string().min(1).max(1000).describe('An .html file of the workspace to record, with the files beside it.').exactOptional(),
18
21
  steps: z.array(stepSchema).max(200).describe('What happens on the page, in order.').exactOptional(),
19
22
  file: z.string().min(1).max(1000).describe('The .mp4 file to write, in the workspace.'),
20
- width: side.describe('The width in pixels, 1280 by default.').exactOptional(),
21
- height: side.describe('The height in pixels, 720 by default.').exactOptional(),
23
+ width: side.describe('The page width in CSS pixels: 1280 by default, 390 on a phone. The file is twice as wide.').exactOptional(),
24
+ height: side.describe('The page height in CSS pixels: 720 by default, 844 on a phone. The file is twice as high.').exactOptional(),
25
+ device: z.enum(['desktop', 'phone']).describe('desktop (the default), or phone: a touch screen with taps.').exactOptional(),
26
+ narration: z.string().min(1).max(1000).describe("The scene's narration (.mp3, .wav, .m4a), as narrate or voice made it; steps may wait for its lines with atLine.").exactOptional(),
22
27
  replace: z.boolean().describe('Write over an existing file.').exactOptional(),
23
28
  });
24
- export const recordOutputSchema = z.object({
25
- file: z.string(),
26
- durationMs: z.number().int().nonnegative(),
27
- steps: z.array(z.object({ do: z.string(), atMs: z.number().int().nonnegative() })),
29
+ export const recordInputSchema = recordFields.superRefine((input, context) => {
30
+ if ((input.url === undefined) === (input.page === undefined))
31
+ context.addIssue({ code: 'custom', path: ['url'], message: 'Give exactly one of url and page.' });
32
+ const steps = input.steps ?? [];
33
+ if (input.page !== undefined && steps.some((step) => step.do === 'goto'))
34
+ context.addIssue({ code: 'custom', path: ['steps'], message: 'A page has no goto steps.' });
35
+ if (input.narration === undefined && steps.some((step) => step.do !== 'wait' && step.atLine !== undefined))
36
+ context.addIssue({ code: 'custom', path: ['narration'], message: 'atLine needs a narration.' });
28
37
  });
38
+ const boxSchema = z.object({ x: z.number().int(), y: z.number().int(), width: z.number().int().nonnegative(), height: z.number().int().nonnegative() });
39
+ export const actionSchema = z.object({
40
+ do: z.string(),
41
+ atMs: z.number().int().nonnegative(),
42
+ actMs: z.number().int().nonnegative().optional(),
43
+ endMs: z.number().int().nonnegative(),
44
+ box: boxSchema.optional(),
45
+ });
46
+ export const recordOutputSchema = z.object({ file: z.string(), durationMs: z.number().int().nonnegative(), steps: z.array(actionSchema) });
29
47
  //# sourceMappingURL=steps.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"steps.js","sourceRoot":"","sources":["../../src/record/steps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,YAAY,CAAC;AAE/B,4FAA4F;AAE5F,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,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AAC"}
@@ -0,0 +1,19 @@
1
+ export type ProblemKind = 'silence' | 'black' | 'frozen' | 'loudness';
2
+ export type Problem = {
3
+ kind: ProblemKind;
4
+ atMs: number;
5
+ lengthMs: number;
6
+ };
7
+ export type Loudness = {
8
+ integratedLufs: number;
9
+ truePeakDb: number;
10
+ };
11
+ export type Analysis = {
12
+ loudness: Loudness | null;
13
+ problems: Problem[];
14
+ };
15
+ /** ffmpeg's arguments to analyse `video`, with its sound when it has one. */
16
+ export declare function analysisArgs(video: string, hasSound: boolean): string[];
17
+ /** The analysis in ffmpeg's output, over a video of `durationMs`. */
18
+ export declare function analysisOf(output: string, durationMs: number, hasSound: boolean): Analysis;
19
+ //# sourceMappingURL=analysis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analysis.d.ts","sourceRoot":"","sources":["../../src/review/analysis.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEtE,MAAM,MAAM,OAAO,GAAG;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5E,MAAM,MAAM,QAAQ,GAAG;IAAE,cAAc,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtE,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE,OAAO,EAAE,CAAA;CAAE,CAAC;AAE1E,6EAA6E;AAC7E,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,EAAE,CAIvE;AAoBD,qEAAqE;AACrE,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,QAAQ,CAQ1F"}
@@ -0,0 +1,36 @@
1
+ // What `review` measures in one ffmpeg run (plan 16 §16.10; ADR 0115, 20 and 48): black pictures of 0.5 s or more,
2
+ // pictures unchanged for 6 s or more, sound below −50 dB for 3 s or more, and the loudness, read from what ffmpeg's
3
+ // filters print. A video without sound is measured for its picture only.
4
+ /** ffmpeg's arguments to analyse `video`, with its sound when it has one. */
5
+ export function analysisArgs(video, hasSound) {
6
+ const picture = '[0:v]blackdetect=d=0.5:pix_th=0.10,freezedetect=n=-60dB:d=6[v]';
7
+ const sound = hasSound ? ';[0:a]silencedetect=n=-50dB:d=3,ebur128=peak=true[a]' : '';
8
+ return ['-hide_banner', '-nostats', '-loglevel', 'info', '-i', video, '-filter_complex', `${picture}${sound}`, '-map', '[v]', ...(hasSound ? ['-map', '[a]'] : []), '-f', 'null', '-'];
9
+ }
10
+ const ms = (seconds) => Math.round(Number(seconds ?? 0) * 1000);
11
+ // Spans that start on one line and end on a later one; one that never ends lasts to the video's end.
12
+ function spans(output, start, end, durationMs) {
13
+ const starts = [...output.matchAll(start)].map((match) => ms(match[1]));
14
+ const ends = [...output.matchAll(end)].map((match) => ms(match[1]));
15
+ return starts.map((atMs, index) => ({ atMs, lengthMs: Math.max(0, (ends[index] ?? durationMs) - atMs) }));
16
+ }
17
+ function loudnessOf(output) {
18
+ const summary = output.slice(output.lastIndexOf('Summary:'));
19
+ const integrated = /I:\s+(-?[\d.]+|-inf) LUFS/.exec(summary)?.[1];
20
+ const peak = /Peak:\s+(-?[\d.]+|-inf) dBFS/.exec(summary)?.[1];
21
+ if (integrated === undefined || peak === undefined)
22
+ return null;
23
+ // ebur128 floors its loudness at −70 LUFS; a peak of no sound at all, -inf, is read at that floor too.
24
+ return { integratedLufs: integrated === '-inf' ? -70 : Number(integrated), truePeakDb: peak === '-inf' ? -70 : Number(peak) };
25
+ }
26
+ /** The analysis in ffmpeg's output, over a video of `durationMs`. */
27
+ export function analysisOf(output, durationMs, hasSound) {
28
+ const black = [...output.matchAll(/black_start:([\d.]+) black_end:([\d.]+)/g)].map((match) => ({ kind: 'black', atMs: ms(match[1]), lengthMs: ms(match[2]) - ms(match[1]) }));
29
+ const frozen = spans(output, /freeze_start: ([\d.]+)/g, /freeze_end: ([\d.]+)/g, durationMs).map((span) => ({ kind: 'frozen', ...span }));
30
+ const silence = hasSound ? spans(output, /silence_start: (-?[\d.]+)/g, /silence_end: ([\d.]+)/g, durationMs).map((span) => ({ kind: 'silence', atMs: Math.max(0, span.atMs), lengthMs: span.lengthMs })) : [];
31
+ const loudness = hasSound ? loudnessOf(output) : null;
32
+ const off = loudness !== null && (loudness.integratedLufs < -15 || loudness.integratedLufs > -13 || loudness.truePeakDb > -1);
33
+ const problems = [...(off ? [{ kind: 'loudness', atMs: 0, lengthMs: durationMs }] : []), ...silence, ...black, ...frozen];
34
+ return { loudness, problems: problems.sort((a, b) => a.atMs - b.atMs) };
35
+ }
36
+ //# sourceMappingURL=analysis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analysis.js","sourceRoot":"","sources":["../../src/review/analysis.ts"],"names":[],"mappings":"AAAA,mHAAmH;AACnH,oHAAoH;AACpH,yEAAyE;AAUzE,6EAA6E;AAC7E,MAAM,UAAU,YAAY,CAAC,KAAa,EAAE,QAAiB;IAC3D,MAAM,OAAO,GAAG,gEAAgE,CAAC;IACjF,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,sDAAsD,CAAC,CAAC,CAAC,EAAE,CAAC;IACrF,OAAO,CAAC,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,iBAAiB,EAAE,GAAG,OAAO,GAAG,KAAK,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;AACzL,CAAC;A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CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACvN,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACtD,MAAM,GAAG,GAAG,QAAQ,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,cAAc,GAAG,CAAC,EAAE,IAAI,QAAQ,CAAC,cAAc,GAAG,CAAC,EAAE,IAAI,QAAQ,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC;IAC9H,MAAM,QAAQ,GAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAmB,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,KAAK,EAAE,GAAG,MAAM,CAAC,CAAC;IAC9I,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AAC1E,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { z } from '@kvman/sdk';
2
+ import type { videoSidecarSchema } from '../files/sidecar.ts';
3
+ export type VideoSidecar = z.output<typeof videoSidecarSchema>;
4
+ export declare const perSheet = 12;
5
+ /** The frames' times in ms, in order. */
6
+ export declare function frameTimes(sidecar: VideoSidecar | undefined, durationMs: number): number[];
7
+ /** The frames in sheets of 12. */
8
+ export declare function sheetsOf(times: readonly number[]): number[][];
9
+ //# sourceMappingURL=frames.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frames.d.ts","sourceRoot":"","sources":["../../src/review/frames.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAM9D,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAI/D,eAAO,MAAM,QAAQ,KAAK,CAAC;AAU3B,yCAAyC;AACzC,wBAAgB,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAQ1F;AAED,kCAAkC;AAClC,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,CAE7D"}
@@ -0,0 +1,28 @@
1
+ const closest = 500;
2
+ const most = 96;
3
+ export const perSheet = 12;
4
+ function wanted(sidecar, durationMs) {
5
+ if (sidecar === undefined)
6
+ return Array.from({ length: Math.max(1, Math.ceil(durationMs / 5000)) }, (_, index) => index * 5000);
7
+ const middles = sidecar.scenes.map((scene) => Math.round((scene.startMs + scene.endMs) / 2));
8
+ const afterTransitions = sidecar.scenes.slice(1).map((scene) => scene.startMs + 400);
9
+ const captions = sidecar.captions.map((caption) => Math.round((caption.startMs + caption.endMs) / 2));
10
+ return [...middles, ...afterTransitions, ...captions];
11
+ }
12
+ /** The frames' times in ms, in order. */
13
+ export function frameTimes(sidecar, durationMs) {
14
+ const kept = [];
15
+ for (const time of wanted(sidecar, durationMs).filter((at) => at >= 0 && at < durationMs).sort((a, b) => a - b)) {
16
+ const last = kept.at(-1);
17
+ if (last === undefined || time - last >= closest)
18
+ kept.push(time);
19
+ }
20
+ if (kept.length <= most)
21
+ return kept;
22
+ return Array.from({ length: most }, (_, index) => kept[Math.round((index * (kept.length - 1)) / (most - 1))] ?? 0);
23
+ }
24
+ /** The frames in sheets of 12. */
25
+ export function sheetsOf(times) {
26
+ return Array.from({ length: Math.ceil(times.length / perSheet) }, (_, index) => times.slice(index * perSheet, (index + 1) * perSheet));
27
+ }
28
+ //# sourceMappingURL=frames.js.map
@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