automovie 0.3.4 → 0.4.0

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 (331) hide show
  1. package/README.md +40 -139
  2. package/lib/AUTOMOVIE_CAPTURE_OPTIONS.d.ts +5 -2
  3. package/lib/AUTOMOVIE_CAPTURE_OPTIONS.js +6 -2
  4. package/lib/AUTOMOVIE_CAPTURE_OPTIONS.js.map +1 -1
  5. package/lib/AUTOMOVIE_DEFAULT_PROJECT_NAME.d.ts +3 -1
  6. package/lib/AUTOMOVIE_DEFAULT_PROJECT_NAME.js +3 -1
  7. package/lib/AUTOMOVIE_DEFAULT_PROJECT_NAME.js.map +1 -1
  8. package/lib/AUTOMOVIE_INSPECT_OPTIONS.d.ts +5 -2
  9. package/lib/AUTOMOVIE_INSPECT_OPTIONS.js +5 -2
  10. package/lib/AUTOMOVIE_INSPECT_OPTIONS.js.map +1 -1
  11. package/lib/AUTOMOVIE_RENDER_OPTIONS.d.ts +6 -2
  12. package/lib/AUTOMOVIE_RENDER_OPTIONS.js +8 -2
  13. package/lib/AUTOMOVIE_RENDER_OPTIONS.js.map +1 -1
  14. package/lib/AUTOMOVIE_REVIEW_OPTIONS.d.ts +3 -1
  15. package/lib/AUTOMOVIE_REVIEW_OPTIONS.js +12 -1
  16. package/lib/AUTOMOVIE_REVIEW_OPTIONS.js.map +1 -1
  17. package/lib/AutoMovieCaptureBackend.d.ts +4 -6
  18. package/lib/AutoMovieCaptureHost.d.ts +73 -53
  19. package/lib/AutoMovieCaptureHost.js +89 -56
  20. package/lib/AutoMovieCaptureHost.js.map +1 -1
  21. package/lib/AutoMovieCommand.d.ts +69 -20
  22. package/lib/AutoMovieFfmpegStaticPath.d.ts +6 -0
  23. package/lib/AutoMovieFfmpegStaticPath.js +3 -0
  24. package/lib/AutoMovieFfmpegStaticPath.js.map +1 -0
  25. package/lib/AutoMovieMp4Boxes.d.ts +78 -0
  26. package/lib/AutoMovieMp4Boxes.js +227 -0
  27. package/lib/AutoMovieMp4Boxes.js.map +1 -0
  28. package/lib/AutoMovieRenderOutputReservation.d.ts +18 -0
  29. package/lib/AutoMovieRenderOutputReservation.js +118 -0
  30. package/lib/AutoMovieRenderOutputReservation.js.map +1 -0
  31. package/lib/IAutoMovieChromium.d.ts +13 -57
  32. package/lib/IAutoMovieDeliveryAudioTrack.d.ts +17 -0
  33. package/lib/IAutoMovieDeliveryAudioTrack.js +3 -0
  34. package/lib/IAutoMovieDeliveryAudioTrack.js.map +1 -0
  35. package/lib/IAutoMovieDeliveryProfileFinding.d.ts +21 -0
  36. package/lib/IAutoMovieDeliveryProfileFinding.js +3 -0
  37. package/lib/IAutoMovieDeliveryProfileFinding.js.map +1 -0
  38. package/lib/IAutoMovieFfmpegSources.d.ts +11 -0
  39. package/lib/IAutoMovieFfmpegSources.js +3 -0
  40. package/lib/IAutoMovieFfmpegSources.js.map +1 -0
  41. package/lib/IAutoMovieReviewObservation.d.ts +66 -0
  42. package/lib/IAutoMovieReviewObservation.js +3 -0
  43. package/lib/IAutoMovieReviewObservation.js.map +1 -0
  44. package/lib/IAutoMovieVerification.d.ts +163 -0
  45. package/lib/IAutoMovieVerification.js +3 -0
  46. package/lib/IAutoMovieVerification.js.map +1 -0
  47. package/lib/auditAutoMovieAlphaSamples.d.ts +23 -0
  48. package/lib/auditAutoMovieAlphaSamples.js +183 -0
  49. package/lib/auditAutoMovieAlphaSamples.js.map +1 -0
  50. package/lib/auditAutoMovieDeliveryProfile.d.ts +33 -0
  51. package/lib/auditAutoMovieDeliveryProfile.js +93 -0
  52. package/lib/auditAutoMovieDeliveryProfile.js.map +1 -0
  53. package/lib/captureAutoMovie.d.ts +23 -11
  54. package/lib/captureAutoMovie.js +102 -18
  55. package/lib/captureAutoMovie.js.map +1 -1
  56. package/lib/createAutoMovieDeliveryAudioLog.d.ts +31 -0
  57. package/lib/createAutoMovieDeliveryAudioLog.js +110 -0
  58. package/lib/createAutoMovieDeliveryAudioLog.js.map +1 -0
  59. package/lib/createAutoMovieDeliveryAudioScan.d.ts +39 -0
  60. package/lib/createAutoMovieDeliveryAudioScan.js +125 -0
  61. package/lib/createAutoMovieDeliveryAudioScan.js.map +1 -0
  62. package/lib/createAutoMovieVerificationInputScope.d.ts +19 -0
  63. package/lib/createAutoMovieVerificationInputScope.js +147 -0
  64. package/lib/createAutoMovieVerificationInputScope.js.map +1 -0
  65. package/lib/createAutoMovieVerificationMediaHash.d.ts +5 -0
  66. package/lib/createAutoMovieVerificationMediaHash.js +61 -0
  67. package/lib/createAutoMovieVerificationMediaHash.js.map +1 -0
  68. package/lib/decodeAutoMovieDeliveryAudio.d.ts +24 -0
  69. package/lib/decodeAutoMovieDeliveryAudio.js +77 -0
  70. package/lib/decodeAutoMovieDeliveryAudio.js.map +1 -0
  71. package/lib/deriveAutoMovieProjectName.d.ts +14 -11
  72. package/lib/deriveAutoMovieProjectName.js +14 -11
  73. package/lib/deriveAutoMovieProjectName.js.map +1 -1
  74. package/lib/findAutoMovieFreePort.d.ts +5 -10
  75. package/lib/findAutoMovieFreePort.js +5 -10
  76. package/lib/findAutoMovieFreePort.js.map +1 -1
  77. package/lib/formatAutoMovieInspectUrl.d.ts +6 -10
  78. package/lib/formatAutoMovieInspectUrl.js +6 -10
  79. package/lib/formatAutoMovieInspectUrl.js.map +1 -1
  80. package/lib/hashAutoMovieFile.d.ts +5 -0
  81. package/lib/hashAutoMovieFile.js +16 -0
  82. package/lib/hashAutoMovieFile.js.map +1 -0
  83. package/lib/importAutoMovieVerificationEntry.d.mts +2 -0
  84. package/lib/importAutoMovieVerificationEntry.mjs +6 -0
  85. package/lib/importAutoMovieVerificationEntry.mjs.map +1 -0
  86. package/lib/index.d.ts +9 -0
  87. package/lib/index.js +9 -0
  88. package/lib/index.js.map +1 -1
  89. package/lib/inspectAutoMovie.d.ts +15 -9
  90. package/lib/inspectAutoMovie.js +25 -9
  91. package/lib/inspectAutoMovie.js.map +1 -1
  92. package/lib/inspectAutoMovieVerificationCapture.d.ts +15 -0
  93. package/lib/inspectAutoMovieVerificationCapture.js +221 -0
  94. package/lib/inspectAutoMovieVerificationCapture.js.map +1 -0
  95. package/lib/inspectAutoMovieVerificationDelivery.d.ts +13 -0
  96. package/lib/inspectAutoMovieVerificationDelivery.js +247 -0
  97. package/lib/inspectAutoMovieVerificationDelivery.js.map +1 -0
  98. package/lib/inspectAutoMovieVerificationReview.d.ts +11 -0
  99. package/lib/inspectAutoMovieVerificationReview.js +141 -0
  100. package/lib/inspectAutoMovieVerificationReview.js.map +1 -0
  101. package/lib/launchAutoMovieChromium.d.ts +9 -11
  102. package/lib/launchAutoMovieChromium.js +10 -11
  103. package/lib/launchAutoMovieChromium.js.map +1 -1
  104. package/lib/listAutoMovieReleaseFindings.d.ts +9 -0
  105. package/lib/listAutoMovieReleaseFindings.js +58 -0
  106. package/lib/listAutoMovieReleaseFindings.js.map +1 -0
  107. package/lib/loadAutoMovieProductionModule.d.ts +11 -10
  108. package/lib/loadAutoMovieProductionModule.js +18 -10
  109. package/lib/loadAutoMovieProductionModule.js.map +1 -1
  110. package/lib/loadAutoMovieVerificationModule.d.ts +6 -0
  111. package/lib/loadAutoMovieVerificationModule.js +246 -0
  112. package/lib/loadAutoMovieVerificationModule.js.map +1 -0
  113. package/lib/planAutoMovieChromiumLaunch.d.ts +7 -13
  114. package/lib/planAutoMovieChromiumLaunch.js +7 -13
  115. package/lib/planAutoMovieChromiumLaunch.js.map +1 -1
  116. package/lib/planAutoMovieDeliveryAudioDecode.d.ts +10 -0
  117. package/lib/planAutoMovieDeliveryAudioDecode.js +29 -0
  118. package/lib/planAutoMovieDeliveryAudioDecode.js.map +1 -0
  119. package/lib/planAutoMovieDeliveryDecode.d.ts +19 -0
  120. package/lib/planAutoMovieDeliveryDecode.js +57 -0
  121. package/lib/planAutoMovieDeliveryDecode.js.map +1 -0
  122. package/lib/planAutoMovieDeliveryInput.d.ts +11 -0
  123. package/lib/planAutoMovieDeliveryInput.js +26 -0
  124. package/lib/planAutoMovieDeliveryInput.js.map +1 -0
  125. package/lib/planAutoMovieModulePageViteConfig.d.ts +13 -10
  126. package/lib/planAutoMovieModulePageViteConfig.js +13 -10
  127. package/lib/planAutoMovieModulePageViteConfig.js.map +1 -1
  128. package/lib/promptAutoMovieProjectName.d.ts +6 -10
  129. package/lib/promptAutoMovieProjectName.js +6 -10
  130. package/lib/promptAutoMovieProjectName.js.map +1 -1
  131. package/lib/publishAutoMovieRenderAttempt.d.ts +32 -0
  132. package/lib/publishAutoMovieRenderAttempt.js +91 -0
  133. package/lib/publishAutoMovieRenderAttempt.js.map +1 -0
  134. package/lib/readAutoMovieAddArguments.d.ts +10 -11
  135. package/lib/readAutoMovieAddArguments.js +10 -11
  136. package/lib/readAutoMovieAddArguments.js.map +1 -1
  137. package/lib/readAutoMovieCaptureHostOptions.d.ts +19 -17
  138. package/lib/readAutoMovieCaptureHostOptions.js +16 -17
  139. package/lib/readAutoMovieCaptureHostOptions.js.map +1 -1
  140. package/lib/readAutoMovieCommandArguments.d.ts +6 -9
  141. package/lib/readAutoMovieCommandArguments.js +9 -10
  142. package/lib/readAutoMovieCommandArguments.js.map +1 -1
  143. package/lib/readAutoMovieCreateArguments.d.ts +7 -11
  144. package/lib/readAutoMovieCreateArguments.js +7 -11
  145. package/lib/readAutoMovieCreateArguments.js.map +1 -1
  146. package/lib/readAutoMovieDeliveryAudioTrack.d.ts +21 -0
  147. package/lib/readAutoMovieDeliveryAudioTrack.js +104 -0
  148. package/lib/readAutoMovieDeliveryAudioTrack.js.map +1 -0
  149. package/lib/readAutoMovieDeliveryDecode.d.ts +19 -0
  150. package/lib/readAutoMovieDeliveryDecode.js +209 -0
  151. package/lib/readAutoMovieDeliveryDecode.js.map +1 -0
  152. package/lib/readAutoMovieDeliveryProbe.d.ts +35 -0
  153. package/lib/readAutoMovieDeliveryProbe.js +363 -0
  154. package/lib/readAutoMovieDeliveryProbe.js.map +1 -0
  155. package/lib/readAutoMovieErrorCode.d.ts +9 -0
  156. package/lib/readAutoMovieErrorCode.js +18 -0
  157. package/lib/readAutoMovieErrorCode.js.map +1 -0
  158. package/lib/readAutoMovieInspectHostOptions.d.ts +15 -16
  159. package/lib/readAutoMovieInspectHostOptions.js +11 -15
  160. package/lib/readAutoMovieInspectHostOptions.js.map +1 -1
  161. package/lib/readAutoMovieNameOption.d.ts +4 -10
  162. package/lib/readAutoMovieNameOption.js +4 -10
  163. package/lib/readAutoMovieNameOption.js.map +1 -1
  164. package/lib/readAutoMoviePageTimeout.d.ts +13 -0
  165. package/lib/readAutoMoviePageTimeout.js +21 -0
  166. package/lib/readAutoMoviePageTimeout.js.map +1 -0
  167. package/lib/readAutoMovieRenderOptions.d.ts +24 -16
  168. package/lib/readAutoMovieRenderOptions.js +23 -16
  169. package/lib/readAutoMovieRenderOptions.js.map +1 -1
  170. package/lib/readAutoMovieReviewObservation.d.ts +6 -0
  171. package/lib/readAutoMovieReviewObservation.js +108 -0
  172. package/lib/readAutoMovieReviewObservation.js.map +1 -0
  173. package/lib/readAutoMovieReviewOptions.d.ts +32 -24
  174. package/lib/readAutoMovieReviewOptions.js +82 -18
  175. package/lib/readAutoMovieReviewOptions.js.map +1 -1
  176. package/lib/readAutoMovieRevision.d.ts +3 -9
  177. package/lib/readAutoMovieRevision.js +3 -9
  178. package/lib/readAutoMovieRevision.js.map +1 -1
  179. package/lib/readAutoMovieVerifyOptions.d.ts +17 -0
  180. package/lib/readAutoMovieVerifyOptions.js +45 -0
  181. package/lib/readAutoMovieVerifyOptions.js.map +1 -0
  182. package/lib/readAutoMovieVideoProbe.d.ts +6 -10
  183. package/lib/readAutoMovieVideoProbe.js +20 -13
  184. package/lib/readAutoMovieVideoProbe.js.map +1 -1
  185. package/lib/recordAutoMoviePlayback.d.ts +18 -11
  186. package/lib/recordAutoMoviePlayback.js +26 -13
  187. package/lib/recordAutoMoviePlayback.js.map +1 -1
  188. package/lib/renderAutoMovie.d.ts +16 -10
  189. package/lib/renderAutoMovie.js +31 -14
  190. package/lib/renderAutoMovie.js.map +1 -1
  191. package/lib/renderAutoMovieScaffoldNextSteps.d.ts +10 -10
  192. package/lib/renderAutoMovieScaffoldNextSteps.js +10 -10
  193. package/lib/renderAutoMovieVideo.d.ts +53 -15
  194. package/lib/renderAutoMovieVideo.js +290 -45
  195. package/lib/renderAutoMovieVideo.js.map +1 -1
  196. package/lib/resolveAutoMovieFfmpeg.d.ts +12 -15
  197. package/lib/resolveAutoMovieFfmpeg.js +12 -17
  198. package/lib/resolveAutoMovieFfmpeg.js.map +1 -1
  199. package/lib/reviewAutoMovie.d.ts +10 -10
  200. package/lib/reviewAutoMovie.js +15 -10
  201. package/lib/reviewAutoMovie.js.map +1 -1
  202. package/lib/reviewAutoMovieFile.d.ts +21 -0
  203. package/lib/reviewAutoMovieFile.js +378 -0
  204. package/lib/reviewAutoMovieFile.js.map +1 -0
  205. package/lib/run.d.ts +32 -18
  206. package/lib/run.js +67 -23
  207. package/lib/run.js.map +1 -1
  208. package/lib/runAutoMovieDeliveryAudioDecode.d.ts +18 -0
  209. package/lib/runAutoMovieDeliveryAudioDecode.js +28 -0
  210. package/lib/runAutoMovieDeliveryAudioDecode.js.map +1 -0
  211. package/lib/runAutoMovieDeliveryDecode.d.ts +19 -0
  212. package/lib/runAutoMovieDeliveryDecode.js +42 -0
  213. package/lib/runAutoMovieDeliveryDecode.js.map +1 -0
  214. package/lib/runAutoMovieDeliveryReferenceDecode.d.ts +28 -0
  215. package/lib/runAutoMovieDeliveryReferenceDecode.js +77 -0
  216. package/lib/runAutoMovieDeliveryReferenceDecode.js.map +1 -0
  217. package/lib/runAutoMovieDeliverySourceAudioDecode.d.ts +20 -0
  218. package/lib/runAutoMovieDeliverySourceAudioDecode.js +56 -0
  219. package/lib/runAutoMovieDeliverySourceAudioDecode.js.map +1 -0
  220. package/lib/runAutoMovieFfmpeg.d.ts +15 -10
  221. package/lib/runAutoMovieFfmpeg.js +36 -13
  222. package/lib/runAutoMovieFfmpeg.js.map +1 -1
  223. package/lib/runAutoMovieVerification.d.ts +28 -0
  224. package/lib/runAutoMovieVerification.js +393 -0
  225. package/lib/runAutoMovieVerification.js.map +1 -0
  226. package/lib/sameAutoMovieReviewFile.d.ts +2 -0
  227. package/lib/sameAutoMovieReviewFile.js +57 -0
  228. package/lib/sameAutoMovieReviewFile.js.map +1 -0
  229. package/lib/selectAutoMovieProjectName.d.ts +8 -11
  230. package/lib/selectAutoMovieProjectName.js +8 -11
  231. package/lib/selectAutoMovieProjectName.js.map +1 -1
  232. package/lib/serveAutoMovieDrawPage.d.ts +14 -11
  233. package/lib/serveAutoMovieDrawPage.js +14 -11
  234. package/lib/serveAutoMovieDrawPage.js.map +1 -1
  235. package/lib/serveAutoMovieInspectorPage.d.ts +4 -8
  236. package/lib/serveAutoMovieInspectorPage.js +3 -9
  237. package/lib/serveAutoMovieInspectorPage.js.map +1 -1
  238. package/lib/verifyAutoMovie.d.ts +19 -0
  239. package/lib/verifyAutoMovie.js +44 -0
  240. package/lib/verifyAutoMovie.js.map +1 -0
  241. package/lib/writeAutoMovieModulePage.d.ts +17 -12
  242. package/lib/writeAutoMovieModulePage.js +13 -11
  243. package/lib/writeAutoMovieModulePage.js.map +1 -1
  244. package/lib/writeAutoMovieVerificationReceipt.d.ts +2 -0
  245. package/lib/writeAutoMovieVerificationReceipt.js +75 -0
  246. package/lib/writeAutoMovieVerificationReceipt.js.map +1 -0
  247. package/package.json +8 -8
  248. package/src/AUTOMOVIE_CAPTURE_OPTIONS.ts +6 -2
  249. package/src/AUTOMOVIE_DEFAULT_PROJECT_NAME.ts +3 -1
  250. package/src/AUTOMOVIE_INSPECT_OPTIONS.ts +5 -2
  251. package/src/AUTOMOVIE_RENDER_OPTIONS.ts +8 -2
  252. package/src/AUTOMOVIE_REVIEW_OPTIONS.ts +12 -1
  253. package/src/AutoMovieCaptureBackend.ts +4 -6
  254. package/src/AutoMovieCaptureHost.ts +122 -68
  255. package/src/AutoMovieCommand.ts +71 -20
  256. package/src/AutoMovieFfmpegStaticPath.ts +7 -0
  257. package/src/AutoMovieMp4Boxes.ts +263 -0
  258. package/src/AutoMovieRenderOutputReservation.ts +97 -0
  259. package/src/IAutoMovieChromium.ts +13 -57
  260. package/src/IAutoMovieDeliveryAudioTrack.ts +19 -0
  261. package/src/IAutoMovieDeliveryProfileFinding.ts +24 -0
  262. package/src/IAutoMovieFfmpegSources.ts +13 -0
  263. package/src/IAutoMovieReviewObservation.ts +59 -0
  264. package/src/IAutoMovieVerification.ts +207 -0
  265. package/src/auditAutoMovieAlphaSamples.ts +201 -0
  266. package/src/auditAutoMovieDeliveryProfile.ts +125 -0
  267. package/src/captureAutoMovie.ts +137 -28
  268. package/src/createAutoMovieDeliveryAudioLog.ts +141 -0
  269. package/src/createAutoMovieDeliveryAudioScan.ts +150 -0
  270. package/src/createAutoMovieVerificationInputScope.ts +156 -0
  271. package/src/createAutoMovieVerificationMediaHash.ts +32 -0
  272. package/src/decodeAutoMovieDeliveryAudio.ts +95 -0
  273. package/src/deriveAutoMovieProjectName.ts +14 -11
  274. package/src/findAutoMovieFreePort.ts +5 -10
  275. package/src/formatAutoMovieInspectUrl.ts +6 -10
  276. package/src/hashAutoMovieFile.ts +12 -0
  277. package/src/importAutoMovieVerificationEntry.mts +6 -0
  278. package/src/index.ts +9 -0
  279. package/src/inspectAutoMovie.ts +28 -11
  280. package/src/inspectAutoMovieVerificationCapture.ts +292 -0
  281. package/src/inspectAutoMovieVerificationDelivery.ts +301 -0
  282. package/src/inspectAutoMovieVerificationReview.ts +130 -0
  283. package/src/launchAutoMovieChromium.ts +14 -12
  284. package/src/listAutoMovieReleaseFindings.ts +87 -0
  285. package/src/loadAutoMovieProductionModule.ts +22 -15
  286. package/src/loadAutoMovieVerificationModule.ts +278 -0
  287. package/src/planAutoMovieChromiumLaunch.ts +7 -13
  288. package/src/planAutoMovieDeliveryAudioDecode.ts +26 -0
  289. package/src/planAutoMovieDeliveryDecode.ts +66 -0
  290. package/src/planAutoMovieDeliveryInput.ts +25 -0
  291. package/src/planAutoMovieModulePageViteConfig.ts +13 -10
  292. package/src/promptAutoMovieProjectName.ts +6 -10
  293. package/src/publishAutoMovieRenderAttempt.ts +89 -0
  294. package/src/readAutoMovieAddArguments.ts +10 -11
  295. package/src/readAutoMovieCaptureHostOptions.ts +22 -17
  296. package/src/readAutoMovieCommandArguments.ts +8 -10
  297. package/src/readAutoMovieCreateArguments.ts +7 -11
  298. package/src/readAutoMovieDeliveryAudioTrack.ts +137 -0
  299. package/src/readAutoMovieDeliveryDecode.ts +269 -0
  300. package/src/readAutoMovieDeliveryProbe.ts +499 -0
  301. package/src/readAutoMovieErrorCode.ts +13 -0
  302. package/src/readAutoMovieInspectHostOptions.ts +15 -16
  303. package/src/readAutoMovieNameOption.ts +4 -10
  304. package/src/readAutoMoviePageTimeout.ts +19 -0
  305. package/src/readAutoMovieRenderOptions.ts +34 -16
  306. package/src/readAutoMovieReviewObservation.ts +146 -0
  307. package/src/readAutoMovieReviewOptions.ts +133 -28
  308. package/src/readAutoMovieRevision.ts +3 -9
  309. package/src/readAutoMovieVerifyOptions.ts +50 -0
  310. package/src/readAutoMovieVideoProbe.ts +24 -13
  311. package/src/recordAutoMoviePlayback.ts +26 -13
  312. package/src/renderAutoMovie.ts +38 -17
  313. package/src/renderAutoMovieScaffoldNextSteps.ts +10 -10
  314. package/src/renderAutoMovieVideo.ts +474 -85
  315. package/src/resolveAutoMovieFfmpeg.ts +17 -24
  316. package/src/reviewAutoMovie.ts +21 -16
  317. package/src/reviewAutoMovieFile.ts +479 -0
  318. package/src/run.ts +75 -25
  319. package/src/runAutoMovieDeliveryAudioDecode.ts +45 -0
  320. package/src/runAutoMovieDeliveryDecode.ts +63 -0
  321. package/src/runAutoMovieDeliveryReferenceDecode.ts +107 -0
  322. package/src/runAutoMovieDeliverySourceAudioDecode.ts +71 -0
  323. package/src/runAutoMovieFfmpeg.ts +48 -14
  324. package/src/runAutoMovieVerification.ts +487 -0
  325. package/src/sameAutoMovieReviewFile.ts +23 -0
  326. package/src/selectAutoMovieProjectName.ts +8 -11
  327. package/src/serveAutoMovieDrawPage.ts +16 -12
  328. package/src/serveAutoMovieInspectorPage.ts +6 -9
  329. package/src/verifyAutoMovie.ts +67 -0
  330. package/src/writeAutoMovieModulePage.ts +17 -12
  331. package/src/writeAutoMovieVerificationReceipt.ts +51 -0
@@ -1,14 +1,17 @@
1
1
  import type {
2
2
  IAutoMovieCaptureCellComparison,
3
3
  IAutoMovieCaptureCellRecord,
4
+ IAutoMovieCaptureFindingDiff,
4
5
  IAutoMovieCapturePlanRequest,
5
6
  IAutoMovieCaptureRecord,
7
+ IAutoMovieCaptureStorage,
6
8
  } from "@automovie/interface";
7
9
  import type * as Render from "@automovie/render";
8
10
  import * as fs from "node:fs/promises";
9
11
  import * as path from "node:path";
10
12
 
11
13
  import { AutoMovieCaptureHost } from "./AutoMovieCaptureHost";
14
+ import type { AutoMovieFfmpegStaticPath } from "./AutoMovieFfmpegStaticPath";
12
15
  import { loadAutoMovieProductionModule } from "./loadAutoMovieProductionModule";
13
16
  import { readAutoMovieCaptureHostOptions } from "./readAutoMovieCaptureHostOptions";
14
17
  import { readAutoMovieRevision } from "./readAutoMovieRevision";
@@ -17,19 +20,25 @@ import { resolveAutoMovieFfmpeg } from "./resolveAutoMovieFfmpeg";
17
20
  import { runAutoMovieFfmpeg } from "./runAutoMovieFfmpeg";
18
21
 
19
22
  /**
20
- * Run `automovie capture` in a production: read the options through the request grammar, capture a subject drawn by the draw page or a video file's own frames, print what was written, and resolve to the exit status.
23
+ * Run `automovie capture` in a production: read the options through the request
24
+ * grammar, capture a subject drawn by the draw page or a video file's own
25
+ * frames, print what was written, and resolve to the exit status.
21
26
  *
22
- * Options are read by `readAutoMovieCaptureArguments` and split by `readAutoMovieCaptureHostOptions`; the rest is the request `parseAutoMovieCapturePlanRequest` reads, so the command takes exactly the keys of a page's address. With `--module` the subject is drawn through `AutoMovieCaptureHost`, its module called with the JSON of `--props` when given; with `--file` the file is probed by FFmpeg and captured by `runAutoMovieVideoCapture`, its subject named by `subject` or the file's name. Both write into `--out`, or `media/capture/<subject>`.
27
+ * Options are read by `readAutoMovieCaptureArguments` and split by
28
+ * `readAutoMovieCaptureHostOptions`; the rest is the request
29
+ * `parseAutoMovieCapturePlanRequest` reads, so the command takes exactly the
30
+ * keys of a page's address. With `--module` the subject is drawn through
31
+ * `AutoMovieCaptureHost`, its module called with the JSON of `--props` when
32
+ * given; with `--file` the file is probed by FFmpeg and captured by
33
+ * `runAutoMovieVideoCapture`, its subject named by `subject` or the file's
34
+ * name. Both write into `--out`, or `media/capture/<subject>`.
23
35
  *
24
- * It prints the folder and how many cells were drawn, the backend, every sheet, every cell not drawn with its cause, and each unmatched or changed comparison entry. The status is 1 when any cell was not drawn, because an undrawn cell is unverified evidence, and 0 otherwise; a refusal throws to `run`, which prints it.
25
- *
26
- * @evidence contracts/development/common.md#meaningful-documentation States how options are read and split, both sources, where they write, what is printed, and the exit status with its reason.
27
- * @evidence contracts/development/implementation.md#principled-implementation Every rule of a capture is the render package's; the command loads that package from the production, supplies the browser or FFmpeg, and reports.
28
- * @evidence contracts/development/implementation.md#clear-and-simple-structure Read, then one branch per source, then one report.
29
- * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts An unknown option is refused by the request reader instead of ignored, and FFmpeg is resolved only for a video so a drawn capture never needs it.
30
- * @evidence contracts/development/implementation.md#efficient-algorithms One host or two FFmpeg runs plus the probe; printing is linear in the record.
31
- * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work One capture per command.
32
- * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The host is closed on every outcome.
36
+ * It prints the folder and how many cells were drawn, the backend, every sheet,
37
+ * every cell not drawn with its cause, each unmatched or changed comparison
38
+ * entry, and the comparison's finding outcome with each fixed, new, worse or
39
+ * unmatched finding. The finding outcome does not change the status: the status
40
+ * is 1 when any cell was not drawn, because an undrawn cell is unverified
41
+ * evidence, and 0 otherwise; a refusal throws to `run`, which prints it.
33
42
  */
34
43
  export async function captureAutoMovie(props: {
35
44
  /** The tokens after `capture`. */
@@ -40,12 +49,21 @@ export async function captureAutoMovie(props: {
40
49
 
41
50
  /** The environment, read for `CHROME_PATH` and `FFMPEG_PATH`. */
42
51
  env: Readonly<Record<string, string | undefined>>;
52
+
53
+ /** The caller's output sink, default standard output. */
54
+ write?: (text: string) => void;
55
+
56
+ /** The absolute record path verification expects this capture to write. */
57
+ expectedRecord?: string;
58
+
59
+ /** Receives the absolute path of this attempt's completed capture record. */
60
+ recorded?: (file: string, text: string) => void;
43
61
  }): Promise<number> {
44
62
  const { root } = props;
45
- const render: typeof Render = loadAutoMovieProductionModule(
63
+ const render: typeof Render = loadAutoMovieProductionModule<typeof Render>(
46
64
  root,
47
65
  "@automovie/render",
48
- ) as typeof Render;
66
+ );
49
67
  const options: ReturnType<typeof readAutoMovieCaptureHostOptions> =
50
68
  readAutoMovieCaptureHostOptions(
51
69
  render.readAutoMovieCaptureArguments(props.args),
@@ -53,34 +71,83 @@ export async function captureAutoMovie(props: {
53
71
  const request: IAutoMovieCapturePlanRequest =
54
72
  render.parseAutoMovieCapturePlanRequest(options.request);
55
73
 
74
+ const recordPath = (folder: string): string =>
75
+ path.join(
76
+ folder,
77
+ ...(request.round === null ? [] : ["rounds", request.round]),
78
+ "record.json",
79
+ );
80
+ const admitFolder = (folder: string): void => {
81
+ if (props.expectedRecord === undefined) return;
82
+ const file: string = recordPath(folder);
83
+ if (path.relative(props.expectedRecord, file) !== "")
84
+ throw new Error(
85
+ `The configured capture would write ${file}. The check declares ${props.expectedRecord}.`,
86
+ );
87
+ };
88
+ if (options.out !== null && props.expectedRecord !== undefined)
89
+ admitFolder(path.resolve(root, options.out));
90
+
91
+ let recordText: string | undefined;
92
+ const storage: IAutoMovieCaptureStorage =
93
+ props.recorded === undefined
94
+ ? fs
95
+ : {
96
+ ...fs,
97
+ writeFile: async (
98
+ file: string,
99
+ data: Parameters<IAutoMovieCaptureStorage["writeFile"]>[1],
100
+ ): Promise<void> => {
101
+ await fs.writeFile(file, data);
102
+ if (
103
+ typeof data === "string" &&
104
+ path.basename(file) === "record.json"
105
+ )
106
+ recordText = data;
107
+ },
108
+ };
109
+
56
110
  let record: Extract<IAutoMovieCaptureRecord, { state: "complete" }>;
57
111
  let backend: string;
58
112
  let folder: string;
59
113
  if (options.file !== null) {
60
114
  // A video file: probe it, then capture its own frames.
61
- const ffmpeg: string = resolveAutoMovieFfmpeg({
62
- env: props.env,
63
- load: (id: string): unknown => loadAutoMovieProductionModule(root, id),
64
- });
65
115
  const file: string = path.resolve(root, options.file);
66
- const probe: ReturnType<typeof readAutoMovieVideoProbe> =
67
- readAutoMovieVideoProbe(
68
- await runAutoMovieFfmpeg(
69
- ffmpeg,
70
- ["-hide_banner", "-i", file],
71
- (): boolean => true,
72
- ),
73
- );
74
116
  const name: string = request.subject ?? path.parse(file).name;
75
117
  folder = path.resolve(
76
118
  root,
77
119
  options.out ?? path.join("media", "capture", name),
78
120
  );
121
+ if (options.out === null) admitFolder(folder);
122
+ const ffmpeg: string = resolveAutoMovieFfmpeg({
123
+ env: props.env,
124
+ load: (id: "ffmpeg-static"): AutoMovieFfmpegStaticPath =>
125
+ loadAutoMovieProductionModule<AutoMovieFfmpegStaticPath>(root, id),
126
+ });
127
+ const probe: ReturnType<typeof readAutoMovieVideoProbe> =
128
+ readAutoMovieVideoProbe(
129
+ await runAutoMovieFfmpeg(ffmpeg, [
130
+ "-hide_banner",
131
+ "-threads",
132
+ "1",
133
+ "-i",
134
+ file,
135
+ "-map",
136
+ "0:v:0",
137
+ "-vf",
138
+ "showinfo=checksum=0",
139
+ "-frames:v",
140
+ "1",
141
+ "-f",
142
+ "null",
143
+ "-",
144
+ ]),
145
+ );
79
146
  record = await render.runAutoMovieVideoCapture({
80
147
  file,
81
148
  subject: { name, ...probe },
82
149
  request,
83
- storage: fs,
150
+ storage,
84
151
  root: folder,
85
152
  run: async (args: readonly string[]): Promise<void> => {
86
153
  await runAutoMovieFfmpeg(ffmpeg, args);
@@ -94,6 +161,7 @@ export async function captureAutoMovie(props: {
94
161
  root,
95
162
  module: options.module!,
96
163
  backend: options.backend,
164
+ timeout: options.timeout,
97
165
  env: props.env,
98
166
  });
99
167
  try {
@@ -105,7 +173,8 @@ export async function captureAutoMovie(props: {
105
173
  : JSON.parse(
106
174
  await fs.readFile(path.resolve(root, options.props), "utf8"),
107
175
  ),
108
- ...(options.out === null ? {} : { out: options.out }),
176
+ ...(options.out === null ? { admitFolder } : { out: options.out }),
177
+ storage,
109
178
  });
110
179
  } finally {
111
180
  await host.close();
@@ -144,7 +213,47 @@ export async function captureAutoMovie(props: {
144
213
  ? [`changed ${entry.current}: ${entry.changed} pixels`]
145
214
  : [],
146
215
  )),
216
+ ...(record.comparison === null
217
+ ? []
218
+ : describeFindings(record.comparison.findings)),
147
219
  ];
148
- process.stdout.write(`${lines.join("\n")}\n`);
220
+ if (props.recorded !== undefined) {
221
+ if (recordText === undefined)
222
+ throw new Error("The capture completed without writing its record.");
223
+ props.recorded(recordPath(folder), recordText);
224
+ }
225
+ const output: string = `${lines.join("\n")}\n`;
226
+ if (props.write === undefined) process.stdout.write(output);
227
+ else props.write(output);
149
228
  return failed.length === 0 ? 0 : 1;
150
229
  }
230
+
231
+ /**
232
+ * The finding outcome, then each fixed, new, worse or unmatched finding, one
233
+ * per line.
234
+ */
235
+ function describeFindings(diff: IAutoMovieCaptureFindingDiff): string[] {
236
+ if (diff.state === "omitted")
237
+ return [
238
+ `findings not compared: no diagnostics in ${diff.lacking
239
+ .map((side: "earlier" | "current"): string =>
240
+ side === "earlier" ? "the earlier round" : "this capture",
241
+ )
242
+ .join(" or ")}`,
243
+ ];
244
+ return [
245
+ `findings ${diff.outcome}`,
246
+ ...diff.entries.flatMap(
247
+ (entry: IAutoMovieCaptureFindingDiff.IEntry): string[] => {
248
+ const name: string = `${entry.category} ${entry.check} ${entry.code} ${entry.key} in ${entry.scope}`;
249
+ return entry.state === "unmatched"
250
+ ? [`unmatched ${name}: ${entry.cause}`]
251
+ : entry.state === "carried"
252
+ ? entry.change === "worse"
253
+ ? [`worse ${name}`]
254
+ : []
255
+ : [`${entry.state} ${name}`];
256
+ },
257
+ ),
258
+ ];
259
+ }
@@ -0,0 +1,141 @@
1
+ import type { IAutoMovieDeliveryContentAudit } from "@automovie/interface";
2
+
3
+ import type { createAutoMovieDeliveryAudioScan } from "./createAutoMovieDeliveryAudioScan";
4
+
5
+ type Observation = IAutoMovieDeliveryContentAudit.IObservation;
6
+ type Stream = IAutoMovieDeliveryContentAudit.Stream;
7
+ type Timestamp = IAutoMovieDeliveryContentAudit.ITimestamp;
8
+ type PcmEvidence = ReturnType<
9
+ ReturnType<typeof createAutoMovieDeliveryAudioScan>["finish"]
10
+ >;
11
+
12
+ /** The decoded sample rate and interleaved channel count. */
13
+ interface IAudioFormat {
14
+ sampleRate: number;
15
+ channels: number;
16
+ }
17
+
18
+ /**
19
+ * Accumulates exact decoded coverage from FFmpeg's audio frame log.
20
+ *
21
+ * The decoder returns whole codec frames, so the last one can extend past the
22
+ * presentation the container records. Samples beyond that end, all within the
23
+ * final decoded frame, are codec padding: they leave the stream's coverage and
24
+ * content and are reported as trailing padding. A longer overrun is kept, so
25
+ * the audit still sees the real duration.
26
+ *
27
+ * @returns A line consumer, the first decoded frame format and a completion
28
+ * operation that reconciles timing with the PCM byte stream and the
29
+ * container.
30
+ */
31
+ export function createAutoMovieDeliveryAudioLog() {
32
+ let format: IAudioFormat | undefined;
33
+ let firstPts = 0;
34
+ let nextPts = 0;
35
+ let frames = 0;
36
+ let sampleFrames = 0;
37
+ let lastSamples = 0;
38
+ let malformed = false;
39
+ let continuous = true;
40
+
41
+ return {
42
+ push(line: string): void {
43
+ const output = /^\[Parsed_ashowinfo_\d+ @ [^\]]+\]\s+(n:.*)$/u.exec(
44
+ line,
45
+ )?.[1];
46
+ if (output === undefined) return;
47
+ const row =
48
+ /^n:(\d+)\s+pts:(-?\d+)\s+pts_time:\S+\s+fmt:flt\s+channels:(\d+)\s+chlayout:.*?\s+rate:(\d+)\s+nb_samples:(\d+)\s/u.exec(
49
+ output,
50
+ );
51
+ const index = Number(row?.[1]);
52
+ const pts = Number(row?.[2]);
53
+ const channels = Number(row?.[3]);
54
+ const sampleRate = Number(row?.[4]);
55
+ const samples = Number(row?.[5]);
56
+ if (
57
+ ![
58
+ index,
59
+ pts,
60
+ channels,
61
+ sampleRate,
62
+ samples,
63
+ pts + samples,
64
+ sampleFrames + samples,
65
+ ].every(Number.isSafeInteger) ||
66
+ channels < 1 ||
67
+ sampleRate < 1 ||
68
+ samples < 1
69
+ ) {
70
+ malformed = true;
71
+ return;
72
+ }
73
+ if (format === undefined) {
74
+ format = { channels, sampleRate };
75
+ firstPts = pts;
76
+ nextPts = pts;
77
+ } else if (
78
+ format.channels !== channels ||
79
+ format.sampleRate !== sampleRate
80
+ )
81
+ malformed = true;
82
+
83
+ continuous &&= index === frames && pts === nextPts;
84
+ frames++;
85
+ sampleFrames += samples;
86
+ lastSamples = samples;
87
+ nextPts = pts + samples;
88
+ },
89
+ format: (): IAudioFormat | undefined => format,
90
+ finish(
91
+ index: number,
92
+ pcm: PcmEvidence,
93
+ presented: { timescale: number; duration: number } | undefined,
94
+ ): Stream {
95
+ if (malformed || format === undefined)
96
+ return {
97
+ status: "uncovered",
98
+ reason: "Incomplete or invalid audio frame evidence",
99
+ };
100
+ if (!pcm.valid || pcm.sampleFrames !== sampleFrames)
101
+ return {
102
+ status: "uncovered",
103
+ reason: "Decoded audio samples and frame evidence do not agree",
104
+ };
105
+ const sampleRate = format.sampleRate;
106
+ if (presented !== undefined && presented.timescale !== sampleRate)
107
+ return {
108
+ status: "uncovered",
109
+ reason: "The container and decoded audio clocks differ",
110
+ };
111
+ const overrun =
112
+ presented === undefined ? 0 : sampleFrames - presented.duration;
113
+ const padding = overrun > 0 && overrun < lastSamples ? overrun : 0;
114
+ const timestamp = (ticks: number): Timestamp => ({
115
+ ticks,
116
+ timeBase: [1, sampleRate],
117
+ });
118
+ return {
119
+ status: "decoded",
120
+ index,
121
+ start: timestamp(firstPts),
122
+ end: timestamp(nextPts - padding),
123
+ sampleRate,
124
+ continuous,
125
+ ...(padding === 0 ? {} : { trailingPadding: padding }),
126
+ ...(pcm.loudness === undefined ? {} : { loudness: pcm.loudness }),
127
+ observations:
128
+ continuous && overrun < lastSamples
129
+ ? pcm.silent.map(
130
+ (range): Observation => ({
131
+ detector: "silence",
132
+ start: timestamp(firstPts + range.start),
133
+ end:
134
+ range.end === null ? null : timestamp(firstPts + range.end),
135
+ }),
136
+ )
137
+ : [],
138
+ };
139
+ },
140
+ };
141
+ }
@@ -0,0 +1,150 @@
1
+ import type {
2
+ IAutoMovieDeliveryContentAudit,
3
+ IAutoMovieLoudnessMeter,
4
+ } from "@automovie/interface";
5
+
6
+ /** A qualifying quiet run in sample frames; a null end runs to the stream end. */
7
+ interface ISampleRange {
8
+ start: number;
9
+ end: number | null;
10
+ }
11
+
12
+ /**
13
+ * Measures silence at exact sample frame boundaries in f32le PCM. Every channel
14
+ * must be within the amplitude limit. Separate pipe chunks can split a float or
15
+ * an interleaved sample frame. Sample frames from the presented count on are
16
+ * counted for coverage but not measured, and an interval still open there ends
17
+ * with the stream.
18
+ *
19
+ * When a loudness meter is supplied, the presented samples also feed it, so the
20
+ * decoded delivery's loudness and true peak exclude codec padding. The meter
21
+ * measures 48 kHz mono or stereo; other formats are not measured.
22
+ *
23
+ * @param format Decoded sample rate and interleaved channel count.
24
+ * @param settings Maximum normalized amplitude and minimum qualifying duration.
25
+ * @param presented Sample frames the container presents, after which decoded
26
+ * samples are padding.
27
+ * @param meter Creates the render's BS.1770-5 meter for the channel count, when
28
+ * loudness is measured.
29
+ * @returns A byte stream consumer and its complete sample, interval and
30
+ * loudness evidence.
31
+ */
32
+ export function createAutoMovieDeliveryAudioScan(
33
+ format: { sampleRate: number; channels: number },
34
+ settings: IAutoMovieDeliveryContentAudit.IThresholds["silence"],
35
+ presented: number,
36
+ meter?: (channels: 1 | 2) => IAutoMovieLoudnessMeter,
37
+ ) {
38
+ const floatBytes = 4;
39
+ const carry = Buffer.alloc(floatBytes);
40
+ let carryLength = 0;
41
+ let sampleFrames = 0;
42
+ let channel = 0;
43
+ let quiet = true;
44
+ let quietStart: number | undefined;
45
+ let valid = true;
46
+ const silent: ISampleRange[] = [];
47
+
48
+ const { maximumAmplitude, minimumDuration } = settings;
49
+ const [seconds, timeTicks] = minimumDuration.timeBase;
50
+ if (
51
+ ![format.channels, format.sampleRate, seconds, timeTicks, presented].every(
52
+ (value) => Number.isSafeInteger(value) && value > 0,
53
+ ) ||
54
+ !Number.isSafeInteger(minimumDuration.ticks) ||
55
+ minimumDuration.ticks < 0 ||
56
+ !Number.isFinite(maximumAmplitude) ||
57
+ maximumAmplitude < 0 ||
58
+ maximumAmplitude > 1
59
+ )
60
+ throw new Error("Invalid decoded audio format or silence thresholds");
61
+
62
+ const ticks = BigInt(timeTicks);
63
+ const rate = BigInt(format.sampleRate);
64
+ const minimumSamples = Number(
65
+ (BigInt(minimumDuration.ticks) * BigInt(seconds) * rate + ticks - 1n) /
66
+ ticks,
67
+ );
68
+
69
+ // Presented samples reach the meter in batches of whole frames.
70
+ const loudness: IAutoMovieLoudnessMeter | undefined =
71
+ meter !== undefined &&
72
+ format.sampleRate === 48_000 &&
73
+ (format.channels === 1 || format.channels === 2)
74
+ ? meter(format.channels)
75
+ : undefined;
76
+ const batch = new Float32Array(4096 * format.channels);
77
+ let batched = 0;
78
+
79
+ const flush = (end: number | null): void => {
80
+ if (
81
+ quietStart !== undefined &&
82
+ Math.min(sampleFrames, presented) - quietStart >= minimumSamples
83
+ )
84
+ silent.push({ start: quietStart, end });
85
+ quietStart = undefined;
86
+ };
87
+ const take = (sample: number): void => {
88
+ if (!Number.isFinite(sample)) valid = false;
89
+ quiet &&= Math.abs(sample) <= maximumAmplitude;
90
+ if (loudness !== undefined && sampleFrames < presented) {
91
+ batch[batched++] = sample;
92
+ if (batched === batch.length) {
93
+ loudness.push(batch);
94
+ batched = 0;
95
+ }
96
+ }
97
+ if (++channel !== format.channels) return;
98
+ if (sampleFrames < presented) {
99
+ if (quiet) quietStart ??= sampleFrames;
100
+ else flush(sampleFrames);
101
+ }
102
+ sampleFrames++;
103
+ channel = 0;
104
+ quiet = true;
105
+ };
106
+
107
+ return {
108
+ push(chunk: Buffer): void {
109
+ let offset = 0;
110
+ if (carryLength > 0) {
111
+ offset = Math.min(floatBytes - carryLength, chunk.length);
112
+ chunk.copy(carry, carryLength, 0, offset);
113
+ carryLength += offset;
114
+ if (carryLength !== floatBytes) return;
115
+ take(carry.readFloatLE(0));
116
+ }
117
+ for (; offset + floatBytes <= chunk.length; offset += floatBytes)
118
+ take(chunk.readFloatLE(offset));
119
+ carryLength = chunk.length - offset;
120
+ if (carryLength > 0) chunk.copy(carry, 0, offset);
121
+ },
122
+ finish(): {
123
+ sampleFrames: number;
124
+ valid: boolean;
125
+ silent: ISampleRange[];
126
+ loudness?: Omit<IAutoMovieLoudnessMeter.IMeasurement, "sampleFrames">;
127
+ } {
128
+ flush(null);
129
+ let measured: IAutoMovieLoudnessMeter.IMeasurement | undefined;
130
+ if (loudness !== undefined) {
131
+ loudness.push(batch.subarray(0, batched));
132
+ batched = 0;
133
+ measured = loudness.measure();
134
+ }
135
+ return {
136
+ sampleFrames,
137
+ valid: valid && carryLength === 0 && channel === 0,
138
+ silent,
139
+ ...(measured === undefined
140
+ ? {}
141
+ : {
142
+ loudness: {
143
+ integratedLufs: measured.integratedLufs,
144
+ truePeakDbtp: measured.truePeakDbtp,
145
+ },
146
+ }),
147
+ };
148
+ },
149
+ };
150
+ }
@@ -0,0 +1,156 @@
1
+ import { execFileSync } from "node:child_process";
2
+ import { createHash } from "node:crypto";
3
+ import * as fs from "node:fs/promises";
4
+ import * as path from "node:path";
5
+
6
+ import type { IAutoMovieVerification } from "./IAutoMovieVerification";
7
+ import { hashAutoMovieFile } from "./hashAutoMovieFile";
8
+
9
+ /**
10
+ * Resolve explicitly named verification inputs to files in the production or
11
+ * its Git checkout. Check the named path and the actual destination so a link
12
+ * cannot redirect the verifier beyond those boundaries. Discover the checkout
13
+ * only when a declared file or a legacy capture needs it.
14
+ *
15
+ * @param root The production directory.
16
+ * @returns Lazy production and checkout directories and an input resolver.
17
+ */
18
+ export function createAutoMovieVerificationInputScope(root: string): {
19
+ /** Canonical production directory. */
20
+ readonly project: () => Promise<string>;
21
+ /** Canonical Git worktree containing the project, when there is one. */
22
+ readonly checkout: () => Promise<string | null>;
23
+ /** The normalized input name and its admitted filesystem location. */
24
+ readonly verifySources: (
25
+ sources: ReadonlyMap<string, string>,
26
+ ) => Promise<void>;
27
+ readonly identify: (
28
+ check:
29
+ | IAutoMovieVerification.IMeasurement
30
+ | IAutoMovieVerification.ICapture,
31
+ sources?: (file: string | undefined) => ReadonlyMap<string, string>,
32
+ ) => Promise<string>;
33
+ } {
34
+ let projectDirectory: Promise<string> | undefined;
35
+ let checkoutDirectory: Promise<string | null> | undefined;
36
+ const project = (): Promise<string> =>
37
+ (projectDirectory ??= fs.realpath(root));
38
+ const checkout = (): Promise<string | null> =>
39
+ (checkoutDirectory ??= project().then(findCheckout));
40
+ const admits = async (directory: string, file: string): Promise<boolean> => {
41
+ if (contains(directory, file)) return true;
42
+ const worktree: string | null = await checkout();
43
+ return worktree !== null && contains(worktree, file);
44
+ };
45
+ const resolve = async (
46
+ name: string,
47
+ ): Promise<readonly [relative: string, actual: string]> => {
48
+ if (path.isAbsolute(name) || path.win32.parse(name).root !== "")
49
+ throw new Error(`Verification input must be project-relative: ${name}.`);
50
+ const directory: string = await project();
51
+ const file: string = path.resolve(directory, name);
52
+ if (!(await admits(directory, file)))
53
+ throw new Error(
54
+ `Verification input is outside the project and its Git checkout: ${name}.`,
55
+ );
56
+ const actual: string = await fs.realpath(file);
57
+ if (!(await admits(directory, actual)))
58
+ throw new Error(
59
+ `Verification input resolves outside the project and its Git checkout: ${name}.`,
60
+ );
61
+ return [path.relative(directory, file), actual];
62
+ };
63
+ return {
64
+ project,
65
+ checkout,
66
+ verifySources: async (
67
+ sources: ReadonlyMap<string, string>,
68
+ ): Promise<void> => {
69
+ for (const [name, loaded] of sources) {
70
+ const [relative, actual] = await resolve(name);
71
+ const current: string = await hashAutoMovieFile(actual);
72
+ if (current !== loaded) throw changedSource(relative);
73
+ }
74
+ },
75
+ /**
76
+ * Hash a check definition and the exact named inputs without walking the
77
+ * project.
78
+ */
79
+ identify: async (check, sources): Promise<string> => {
80
+ const names: readonly string[] = check.inputs ?? [];
81
+ const source: string | undefined =
82
+ check.kind === "measure" ? check.source : undefined;
83
+ const graph: ReadonlyMap<string, string> | undefined =
84
+ check.kind === "measure" && sources !== undefined
85
+ ? sources(
86
+ source === undefined ? undefined : (await resolve(source))[1],
87
+ )
88
+ : undefined;
89
+ if (
90
+ !Array.isArray(names) ||
91
+ (names.length === 0 && source === undefined && graph === undefined)
92
+ )
93
+ throw new Error(
94
+ "Declare the scoped input files to establish result currentness.",
95
+ );
96
+
97
+ const inputs: [string, string][] = [];
98
+ for (const name of new Set([
99
+ ...names,
100
+ ...(graph?.keys() ?? (source === undefined ? [] : [source])),
101
+ ])) {
102
+ const [relative, actual] = await resolve(name);
103
+ const hash: string = await hashAutoMovieFile(actual);
104
+ const loaded: string | undefined = graph?.get(relative);
105
+ if (loaded !== undefined && hash !== loaded)
106
+ throw changedSource(relative);
107
+ inputs.push([relative, hash]);
108
+ }
109
+ return createHash("sha256")
110
+ .update(
111
+ JSON.stringify([
112
+ { ...check, enabled: undefined },
113
+ check.kind === "measure" ? String(check.measure) : null,
114
+ inputs,
115
+ ]),
116
+ )
117
+ .digest("hex");
118
+ },
119
+ };
120
+ }
121
+
122
+ function changedSource(relative: string): Error {
123
+ return new Error(
124
+ `Verification source changed after it loaded: ${relative}. Run verify again.`,
125
+ );
126
+ }
127
+
128
+ /** Locate the owning Git worktree without scanning its working files. */
129
+ async function findCheckout(project: string): Promise<string | null> {
130
+ try {
131
+ const top: string = execFileSync(
132
+ "git",
133
+ ["-C", project, "rev-parse", "--show-toplevel"],
134
+ {
135
+ encoding: "utf8",
136
+ stdio: ["ignore", "pipe", "ignore"],
137
+ windowsHide: true,
138
+ },
139
+ ).replace(/\r?\n$/u, "");
140
+ if (!path.isAbsolute(top)) return null;
141
+ const directory: string = await fs.realpath(top);
142
+ return contains(directory, project) ? directory : null;
143
+ } catch {
144
+ return null;
145
+ }
146
+ }
147
+
148
+ /** Resolve native case, separator and drive semantics through relative paths. */
149
+ function contains(directory: string, candidate: string): boolean {
150
+ const relative: string = path.relative(directory, candidate);
151
+ return (
152
+ !path.isAbsolute(relative) &&
153
+ relative !== ".." &&
154
+ !relative.startsWith(`..${path.sep}`)
155
+ );
156
+ }