@automovie/render 0.0.0-stage → 0.1.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 (503) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +38 -2
  3. package/lib/AUTOMOVIE_GUIDE_PASSES.d.ts +11 -0
  4. package/lib/AUTOMOVIE_GUIDE_PASSES.js +21 -0
  5. package/lib/AUTOMOVIE_GUIDE_PASSES.js.map +1 -0
  6. package/lib/IAutoMovieCaptionEntry.d.ts +28 -0
  7. package/lib/IAutoMovieCaptionEntry.js +3 -0
  8. package/lib/IAutoMovieCaptionEntry.js.map +1 -0
  9. package/lib/IAutoMovieCaptionSidecar.d.ts +25 -0
  10. package/lib/IAutoMovieCaptionSidecar.js +3 -0
  11. package/lib/IAutoMovieCaptionSidecar.js.map +1 -0
  12. package/lib/IAutoMovieCapturedFrame.d.ts +22 -0
  13. package/lib/IAutoMovieCapturedFrame.js +3 -0
  14. package/lib/IAutoMovieCapturedFrame.js.map +1 -0
  15. package/lib/IAutoMovieGuidePassOutput.d.ts +23 -0
  16. package/lib/IAutoMovieGuidePassOutput.js +3 -0
  17. package/lib/IAutoMovieGuidePassOutput.js.map +1 -0
  18. package/lib/IAutoMoviePoseKeypointActor.d.ts +36 -0
  19. package/lib/IAutoMoviePoseKeypointActor.js +3 -0
  20. package/lib/IAutoMoviePoseKeypointActor.js.map +1 -0
  21. package/lib/IAutoMoviePoseKeypointFrame.d.ts +25 -0
  22. package/lib/IAutoMoviePoseKeypointFrame.js +3 -0
  23. package/lib/IAutoMoviePoseKeypointFrame.js.map +1 -0
  24. package/lib/IAutoMoviePoseKeypointSidecar.d.ts +21 -0
  25. package/lib/IAutoMoviePoseKeypointSidecar.js +3 -0
  26. package/lib/IAutoMoviePoseKeypointSidecar.js.map +1 -0
  27. package/lib/IAutoMovieRenderAdapters.d.ts +34 -0
  28. package/lib/IAutoMovieRenderAdapters.js +3 -0
  29. package/lib/IAutoMovieRenderAdapters.js.map +1 -0
  30. package/lib/IAutoMovieRenderAndSeeRequest.d.ts +32 -0
  31. package/lib/IAutoMovieRenderAndSeeRequest.js +3 -0
  32. package/lib/IAutoMovieRenderAndSeeRequest.js.map +1 -0
  33. package/lib/IAutoMovieRenderAndSeeResult.d.ts +20 -0
  34. package/lib/IAutoMovieRenderAndSeeResult.js +3 -0
  35. package/lib/IAutoMovieRenderAndSeeResult.js.map +1 -0
  36. package/lib/IAutoMovieRenderChunk.d.ts +48 -0
  37. package/lib/IAutoMovieRenderChunk.js +3 -0
  38. package/lib/IAutoMovieRenderChunk.js.map +1 -0
  39. package/lib/IAutoMovieRenderChunkPlan.d.ts +32 -0
  40. package/lib/IAutoMovieRenderChunkPlan.js +3 -0
  41. package/lib/IAutoMovieRenderChunkPlan.js.map +1 -0
  42. package/lib/IAutoMovieRenderPassManifest.d.ts +21 -0
  43. package/lib/IAutoMovieRenderPassManifest.js +3 -0
  44. package/lib/IAutoMovieRenderPassManifest.js.map +1 -0
  45. package/lib/IAutoMovieRenderReassembly.d.ts +24 -0
  46. package/lib/IAutoMovieRenderReassembly.js +3 -0
  47. package/lib/IAutoMovieRenderReassembly.js.map +1 -0
  48. package/lib/IAutoMovieRenderResult.d.ts +39 -0
  49. package/lib/IAutoMovieRenderResult.js +3 -0
  50. package/lib/IAutoMovieRenderResult.js.map +1 -0
  51. package/lib/IAutoMovieSequenceRenderAdapters.d.ts +36 -0
  52. package/lib/IAutoMovieSequenceRenderAdapters.js +3 -0
  53. package/lib/IAutoMovieSequenceRenderAdapters.js.map +1 -0
  54. package/lib/IAutoMovieSequenceRenderAndSeeRequest.d.ts +36 -0
  55. package/lib/IAutoMovieSequenceRenderAndSeeRequest.js +3 -0
  56. package/lib/IAutoMovieSequenceRenderAndSeeRequest.js.map +1 -0
  57. package/lib/IAutoMovieSequenceRenderAndSeeResult.d.ts +23 -0
  58. package/lib/IAutoMovieSequenceRenderAndSeeResult.js +3 -0
  59. package/lib/IAutoMovieSequenceRenderAndSeeResult.js.map +1 -0
  60. package/lib/IAutoMovieSequenceRenderFrame.d.ts +41 -0
  61. package/lib/IAutoMovieSequenceRenderFrame.js +3 -0
  62. package/lib/IAutoMovieSequenceRenderFrame.js.map +1 -0
  63. package/lib/IAutoMovieSequenceRenderPlan.d.ts +76 -0
  64. package/lib/IAutoMovieSequenceRenderPlan.js +3 -0
  65. package/lib/IAutoMovieSequenceRenderPlan.js.map +1 -0
  66. package/lib/IAutoMovieSequenceRenderResult.d.ts +44 -0
  67. package/lib/IAutoMovieSequenceRenderResult.js +3 -0
  68. package/lib/IAutoMovieSequenceRenderResult.js.map +1 -0
  69. package/lib/IAutoMovieSequenceRenderShotSpan.d.ts +39 -0
  70. package/lib/IAutoMovieSequenceRenderShotSpan.js +3 -0
  71. package/lib/IAutoMovieSequenceRenderShotSpan.js.map +1 -0
  72. package/lib/IAutoMovieSequenceRenderTransitionSpan.d.ts +39 -0
  73. package/lib/IAutoMovieSequenceRenderTransitionSpan.js +3 -0
  74. package/lib/IAutoMovieSequenceRenderTransitionSpan.js.map +1 -0
  75. package/lib/audio/encodeAutoMovieWavPcm16.d.ts +21 -0
  76. package/lib/audio/encodeAutoMovieWavPcm16.js +59 -0
  77. package/lib/audio/encodeAutoMovieWavPcm16.js.map +1 -0
  78. package/lib/audio/index.d.ts +2 -0
  79. package/lib/audio/index.js +19 -0
  80. package/lib/audio/index.js.map +1 -0
  81. package/lib/audio/mixAutoMovieAudioPcm.d.ts +64 -0
  82. package/lib/audio/mixAutoMovieAudioPcm.js +86 -0
  83. package/lib/audio/mixAutoMovieAudioPcm.js.map +1 -0
  84. package/lib/auditAutoMovieRenderObservation.d.ts +31 -0
  85. package/lib/auditAutoMovieRenderObservation.js +63 -0
  86. package/lib/auditAutoMovieRenderObservation.js.map +1 -0
  87. package/lib/cache/createAutoMovieHttpArtifactStore.d.ts +28 -0
  88. package/lib/cache/createAutoMovieHttpArtifactStore.js +66 -0
  89. package/lib/cache/createAutoMovieHttpArtifactStore.js.map +1 -0
  90. package/lib/caption/IAutoMovieBeatCaption.d.ts +22 -0
  91. package/lib/caption/IAutoMovieBeatCaption.js +3 -0
  92. package/lib/caption/IAutoMovieBeatCaption.js.map +1 -0
  93. package/lib/caption/autoMovieCaptionLanguageComparisonKey.d.ts +18 -0
  94. package/lib/caption/autoMovieCaptionLanguageComparisonKey.js +24 -0
  95. package/lib/caption/autoMovieCaptionLanguageComparisonKey.js.map +1 -0
  96. package/lib/caption/beatCaptions.d.ts +22 -0
  97. package/lib/caption/beatCaptions.js +50 -0
  98. package/lib/caption/beatCaptions.js.map +1 -0
  99. package/lib/caption/canonicalProductionWebVtt.d.ts +23 -0
  100. package/lib/caption/canonicalProductionWebVtt.js +60 -0
  101. package/lib/caption/canonicalProductionWebVtt.js.map +1 -0
  102. package/lib/caption/canonicalizeAutoMovieCaptionText.d.ts +18 -0
  103. package/lib/caption/canonicalizeAutoMovieCaptionText.js +24 -0
  104. package/lib/caption/canonicalizeAutoMovieCaptionText.js.map +1 -0
  105. package/lib/caption/escapeWebVttText.d.ts +17 -0
  106. package/lib/caption/escapeWebVttText.js +25 -0
  107. package/lib/caption/escapeWebVttText.js.map +1 -0
  108. package/lib/caption/index.d.ts +11 -0
  109. package/lib/caption/index.js +28 -0
  110. package/lib/caption/index.js.map +1 -0
  111. package/lib/caption/inspectAutoMovieCaptionReadabilityWithRuntime.d.ts +37 -0
  112. package/lib/caption/inspectAutoMovieCaptionReadabilityWithRuntime.js +129 -0
  113. package/lib/caption/inspectAutoMovieCaptionReadabilityWithRuntime.js.map +1 -0
  114. package/lib/caption/isAutoMovieWebVttIdentifier.d.ts +21 -0
  115. package/lib/caption/isAutoMovieWebVttIdentifier.js +28 -0
  116. package/lib/caption/isAutoMovieWebVttIdentifier.js.map +1 -0
  117. package/lib/caption/parseAutoMovieCaptionLanguage.d.ts +34 -0
  118. package/lib/caption/parseAutoMovieCaptionLanguage.js +121 -0
  119. package/lib/caption/parseAutoMovieCaptionLanguage.js.map +1 -0
  120. package/lib/caption/serializeAutoMovieWebVttCueText.d.ts +17 -0
  121. package/lib/caption/serializeAutoMovieWebVttCueText.js +27 -0
  122. package/lib/caption/serializeAutoMovieWebVttCueText.js.map +1 -0
  123. package/lib/caption/serializeAutoMovieWebVttIdentifier.d.ts +17 -0
  124. package/lib/caption/serializeAutoMovieWebVttIdentifier.js +27 -0
  125. package/lib/caption/serializeAutoMovieWebVttIdentifier.js.map +1 -0
  126. package/lib/caption/serializeAutoMovieWebVttSingleLineText.d.ts +19 -0
  127. package/lib/caption/serializeAutoMovieWebVttSingleLineText.js +26 -0
  128. package/lib/caption/serializeAutoMovieWebVttSingleLineText.js.map +1 -0
  129. package/lib/caption/webVttCaptionLanguage.d.ts +18 -0
  130. package/lib/caption/webVttCaptionLanguage.js +29 -0
  131. package/lib/caption/webVttCaptionLanguage.js.map +1 -0
  132. package/lib/caption/webVttTime.d.ts +19 -0
  133. package/lib/caption/webVttTime.js +30 -0
  134. package/lib/caption/webVttTime.js.map +1 -0
  135. package/lib/captionPlan.d.ts +1 -0
  136. package/lib/captionPlan.js +18 -0
  137. package/lib/captionPlan.js.map +1 -0
  138. package/lib/captionSidecar.d.ts +3 -0
  139. package/lib/captionSidecar.js +20 -0
  140. package/lib/captionSidecar.js.map +1 -0
  141. package/lib/captionSlice.d.ts +1 -0
  142. package/lib/captionSlice.js +18 -0
  143. package/lib/captionSlice.js.map +1 -0
  144. package/lib/chunkSequenceRender.d.ts +5 -0
  145. package/lib/chunkSequenceRender.js +22 -0
  146. package/lib/chunkSequenceRender.js.map +1 -0
  147. package/lib/delivery/AUTOMOVIE_MP4_SRGB_COLOUR.d.ts +16 -0
  148. package/lib/delivery/AUTOMOVIE_MP4_SRGB_COLOUR.js +20 -0
  149. package/lib/delivery/AUTOMOVIE_MP4_SRGB_COLOUR.js.map +1 -0
  150. package/lib/delivery/AUTOMOVIE_MP4_UNITY_MATRIX.d.ts +11 -0
  151. package/lib/delivery/AUTOMOVIE_MP4_UNITY_MATRIX.js +14 -0
  152. package/lib/delivery/AUTOMOVIE_MP4_UNITY_MATRIX.js.map +1 -0
  153. package/lib/delivery/AUTOMOVIE_PRODUCTION_OPUS_PROFILE.d.ts +15 -0
  154. package/lib/delivery/AUTOMOVIE_PRODUCTION_OPUS_PROFILE.js +19 -0
  155. package/lib/delivery/AUTOMOVIE_PRODUCTION_OPUS_PROFILE.js.map +1 -0
  156. package/lib/delivery/AutoMovieProductionPngRole.d.ts +14 -0
  157. package/lib/delivery/AutoMovieProductionPngRole.js +3 -0
  158. package/lib/delivery/AutoMovieProductionPngRole.js.map +1 -0
  159. package/lib/delivery/IAutoMovieProductionPngProfile.d.ts +41 -0
  160. package/lib/delivery/IAutoMovieProductionPngProfile.js +3 -0
  161. package/lib/delivery/IAutoMovieProductionPngProfile.js.map +1 -0
  162. package/lib/delivery/IAutoMovieProductionVideoProfile.d.ts +46 -0
  163. package/lib/delivery/IAutoMovieProductionVideoProfile.js +3 -0
  164. package/lib/delivery/IAutoMovieProductionVideoProfile.js.map +1 -0
  165. package/lib/delivery/assertAutoMovieCaptureClock.d.ts +26 -0
  166. package/lib/delivery/assertAutoMovieCaptureClock.js +29 -0
  167. package/lib/delivery/assertAutoMovieCaptureClock.js.map +1 -0
  168. package/lib/delivery/assertProductionOpusProfile.d.ts +23 -0
  169. package/lib/delivery/assertProductionOpusProfile.js +160 -0
  170. package/lib/delivery/assertProductionOpusProfile.js.map +1 -0
  171. package/lib/delivery/assertProductionPngPicture.d.ts +24 -0
  172. package/lib/delivery/assertProductionPngPicture.js +47 -0
  173. package/lib/delivery/assertProductionPngPicture.js.map +1 -0
  174. package/lib/delivery/assertProductionVideoProfile.d.ts +30 -0
  175. package/lib/delivery/assertProductionVideoProfile.js +150 -0
  176. package/lib/delivery/assertProductionVideoProfile.js.map +1 -0
  177. package/lib/delivery/auditAutoMovieDecodedFrames.d.ts +56 -0
  178. package/lib/delivery/auditAutoMovieDecodedFrames.js +92 -0
  179. package/lib/delivery/auditAutoMovieDecodedFrames.js.map +1 -0
  180. package/lib/delivery/auditAutoMovieEncodedPresentation.d.ts +27 -0
  181. package/lib/delivery/auditAutoMovieEncodedPresentation.js +62 -0
  182. package/lib/delivery/auditAutoMovieEncodedPresentation.js.map +1 -0
  183. package/lib/delivery/index.d.ts +14 -0
  184. package/lib/delivery/index.js +31 -0
  185. package/lib/delivery/index.js.map +1 -0
  186. package/lib/delivery/planAutoMovieCaptureUrl.d.ts +18 -0
  187. package/lib/delivery/planAutoMovieCaptureUrl.js +31 -0
  188. package/lib/delivery/planAutoMovieCaptureUrl.js.map +1 -0
  189. package/lib/delivery/productionOpusDescription.d.ts +41 -0
  190. package/lib/delivery/productionOpusDescription.js +125 -0
  191. package/lib/delivery/productionOpusDescription.js.map +1 -0
  192. package/lib/delivery/resolveProductionPngProfile.d.ts +27 -0
  193. package/lib/delivery/resolveProductionPngProfile.js +53 -0
  194. package/lib/delivery/resolveProductionPngProfile.js.map +1 -0
  195. package/lib/delivery/resolveProductionVideoProfile.d.ts +27 -0
  196. package/lib/delivery/resolveProductionVideoProfile.js +36 -0
  197. package/lib/delivery/resolveProductionVideoProfile.js.map +1 -0
  198. package/lib/ffmpegArgs.d.ts +33 -0
  199. package/lib/ffmpegArgs.js +56 -0
  200. package/lib/ffmpegArgs.js.map +1 -0
  201. package/lib/film/AutoMovieOrderedScalar.d.ts +15 -0
  202. package/lib/film/AutoMovieOrderedScalar.js +3 -0
  203. package/lib/film/AutoMovieOrderedScalar.js.map +1 -0
  204. package/lib/film/IAutoMovieProductionAudioAssetIdentity.d.ts +28 -0
  205. package/lib/film/IAutoMovieProductionAudioAssetIdentity.js +3 -0
  206. package/lib/film/IAutoMovieProductionAudioAssetIdentity.js.map +1 -0
  207. package/lib/film/IAutoMovieProductionAudioAssetIdentityBase.d.ts +29 -0
  208. package/lib/film/IAutoMovieProductionAudioAssetIdentityBase.js +3 -0
  209. package/lib/film/IAutoMovieProductionAudioAssetIdentityBase.js.map +1 -0
  210. package/lib/film/IAutoMovieProductionEncoderIdentity.d.ts +36 -0
  211. package/lib/film/IAutoMovieProductionEncoderIdentity.js +3 -0
  212. package/lib/film/IAutoMovieProductionEncoderIdentity.js.map +1 -0
  213. package/lib/film/IAutoMovieProductionRenderChunk.d.ts +39 -0
  214. package/lib/film/IAutoMovieProductionRenderChunk.js +3 -0
  215. package/lib/film/IAutoMovieProductionRenderChunk.js.map +1 -0
  216. package/lib/film/IAutoMovieProductionRenderJobPlan.d.ts +53 -0
  217. package/lib/film/IAutoMovieProductionRenderJobPlan.js +3 -0
  218. package/lib/film/IAutoMovieProductionRenderJobPlan.js.map +1 -0
  219. package/lib/film/IAutoMovieProductionRenderRuntimeIdentity.d.ts +31 -0
  220. package/lib/film/IAutoMovieProductionRenderRuntimeIdentity.js +3 -0
  221. package/lib/film/IAutoMovieProductionRenderRuntimeIdentity.js.map +1 -0
  222. package/lib/film/IAutoMovieProductionRenderTier.d.ts +25 -0
  223. package/lib/film/IAutoMovieProductionRenderTier.js +3 -0
  224. package/lib/film/IAutoMovieProductionRenderTier.js.map +1 -0
  225. package/lib/film/assertSingleGuidePass.d.ts +19 -0
  226. package/lib/film/assertSingleGuidePass.js +35 -0
  227. package/lib/film/assertSingleGuidePass.js.map +1 -0
  228. package/lib/film/equalOrderedScalars.d.ts +27 -0
  229. package/lib/film/equalOrderedScalars.js +52 -0
  230. package/lib/film/equalOrderedScalars.js.map +1 -0
  231. package/lib/film/index.d.ts +9 -0
  232. package/lib/film/index.js +26 -0
  233. package/lib/film/index.js.map +1 -0
  234. package/lib/film/normalizeAudioAssets.d.ts +21 -0
  235. package/lib/film/normalizeAudioAssets.js +56 -0
  236. package/lib/film/normalizeAudioAssets.js.map +1 -0
  237. package/lib/film/normalizeRenderTier.d.ts +19 -0
  238. package/lib/film/normalizeRenderTier.js +45 -0
  239. package/lib/film/normalizeRenderTier.js.map +1 -0
  240. package/lib/film/planProductionRenderJob.d.ts +48 -0
  241. package/lib/film/planProductionRenderJob.js +196 -0
  242. package/lib/film/planProductionRenderJob.js.map +1 -0
  243. package/lib/film/productionVisualDeliveryOccurrence.d.ts +20 -0
  244. package/lib/film/productionVisualDeliveryOccurrence.js +24 -0
  245. package/lib/film/productionVisualDeliveryOccurrence.js.map +1 -0
  246. package/lib/film/resolveProductionRenderTierFrameFormat.d.ts +21 -0
  247. package/lib/film/resolveProductionRenderTierFrameFormat.js +46 -0
  248. package/lib/film/resolveProductionRenderTierFrameFormat.js.map +1 -0
  249. package/lib/film/validDigest.d.ts +18 -0
  250. package/lib/film/validDigest.js +25 -0
  251. package/lib/film/validDigest.js.map +1 -0
  252. package/lib/film/validWaveAudioIdentity.d.ts +25 -0
  253. package/lib/film/validWaveAudioIdentity.js +76 -0
  254. package/lib/film/validWaveAudioIdentity.js.map +1 -0
  255. package/lib/frameName.d.ts +19 -0
  256. package/lib/frameName.js +24 -0
  257. package/lib/frameName.js.map +1 -0
  258. package/lib/framePattern.d.ts +16 -0
  259. package/lib/framePattern.js +21 -0
  260. package/lib/framePattern.js.map +1 -0
  261. package/lib/frameTimes.d.ts +20 -0
  262. package/lib/frameTimes.js +33 -0
  263. package/lib/frameTimes.js.map +1 -0
  264. package/lib/guidePassFrameName.d.ts +15 -0
  265. package/lib/guidePassFrameName.js +21 -0
  266. package/lib/guidePassFrameName.js.map +1 -0
  267. package/lib/guidePassFramePattern.d.ts +15 -0
  268. package/lib/guidePassFramePattern.js +21 -0
  269. package/lib/guidePassFramePattern.js.map +1 -0
  270. package/lib/guidePasses.d.ts +7 -0
  271. package/lib/guidePasses.js +24 -0
  272. package/lib/guidePasses.js.map +1 -0
  273. package/lib/guidePassesInternal/passExtension.d.ts +14 -0
  274. package/lib/guidePassesInternal/passExtension.js +18 -0
  275. package/lib/guidePassesInternal/passExtension.js.map +1 -0
  276. package/lib/index.d.ts +69 -0
  277. package/lib/index.js +86 -0
  278. package/lib/index.js.map +1 -0
  279. package/lib/isGuidePass.d.ts +15 -0
  280. package/lib/isGuidePass.js +20 -0
  281. package/lib/isGuidePass.js.map +1 -0
  282. package/lib/normalizeGuidePasses.d.ts +15 -0
  283. package/lib/normalizeGuidePasses.js +32 -0
  284. package/lib/normalizeGuidePasses.js.map +1 -0
  285. package/lib/planCaptionSidecar.d.ts +23 -0
  286. package/lib/planCaptionSidecar.js +56 -0
  287. package/lib/planCaptionSidecar.js.map +1 -0
  288. package/lib/planChunkedSequenceRender.d.ts +26 -0
  289. package/lib/planChunkedSequenceRender.js +132 -0
  290. package/lib/planChunkedSequenceRender.js.map +1 -0
  291. package/lib/planGuidePassOutputs.d.ts +19 -0
  292. package/lib/planGuidePassOutputs.js +31 -0
  293. package/lib/planGuidePassOutputs.js.map +1 -0
  294. package/lib/planPoseKeypointSidecar.d.ts +27 -0
  295. package/lib/planPoseKeypointSidecar.js +141 -0
  296. package/lib/planPoseKeypointSidecar.js.map +1 -0
  297. package/lib/planSequenceRender.d.ts +20 -0
  298. package/lib/planSequenceRender.js +99 -0
  299. package/lib/planSequenceRender.js.map +1 -0
  300. package/lib/planViewerFrameTimes.d.ts +33 -0
  301. package/lib/planViewerFrameTimes.js +74 -0
  302. package/lib/planViewerFrameTimes.js.map +1 -0
  303. package/lib/renderAndSee.d.ts +14 -0
  304. package/lib/renderAndSee.js +22 -0
  305. package/lib/renderAndSee.js.map +1 -0
  306. package/lib/renderBudgetPreflight/IAutoMovieRenderBudgetAssessment.d.ts +41 -0
  307. package/lib/renderBudgetPreflight/IAutoMovieRenderBudgetAssessment.js +3 -0
  308. package/lib/renderBudgetPreflight/IAutoMovieRenderBudgetAssessment.js.map +1 -0
  309. package/lib/renderBudgetPreflight/IAutoMovieRenderBudgetEvidence.d.ts +53 -0
  310. package/lib/renderBudgetPreflight/IAutoMovieRenderBudgetEvidence.js +3 -0
  311. package/lib/renderBudgetPreflight/IAutoMovieRenderBudgetEvidence.js.map +1 -0
  312. package/lib/renderBudgetPreflight/IAutoMovieRenderGraphicsIdentity.d.ts +27 -0
  313. package/lib/renderBudgetPreflight/IAutoMovieRenderGraphicsIdentity.js +3 -0
  314. package/lib/renderBudgetPreflight/IAutoMovieRenderGraphicsIdentity.js.map +1 -0
  315. package/lib/renderBudgetPreflight/assessAutoMovieRenderBudget.d.ts +28 -0
  316. package/lib/renderBudgetPreflight/assessAutoMovieRenderBudget.js +77 -0
  317. package/lib/renderBudgetPreflight/assessAutoMovieRenderBudget.js.map +1 -0
  318. package/lib/renderBudgetPreflight/autoMovieRenderBudgetEvidence.d.ts +23 -0
  319. package/lib/renderBudgetPreflight/autoMovieRenderBudgetEvidence.js +55 -0
  320. package/lib/renderBudgetPreflight/autoMovieRenderBudgetEvidence.js.map +1 -0
  321. package/lib/renderBudgetPreflight/autoMovieRenderBudgetRefusal.d.ts +17 -0
  322. package/lib/renderBudgetPreflight/autoMovieRenderBudgetRefusal.js +51 -0
  323. package/lib/renderBudgetPreflight/autoMovieRenderBudgetRefusal.js.map +1 -0
  324. package/lib/renderBudgetPreflight/autoMovieRenderTargetRendererOfGraphics.d.ts +22 -0
  325. package/lib/renderBudgetPreflight/autoMovieRenderTargetRendererOfGraphics.js +32 -0
  326. package/lib/renderBudgetPreflight/autoMovieRenderTargetRendererOfGraphics.js.map +1 -0
  327. package/lib/renderBudgetPreflight/autoMovieRenderTargetSettingsOfShot.d.ts +23 -0
  328. package/lib/renderBudgetPreflight/autoMovieRenderTargetSettingsOfShot.js +35 -0
  329. package/lib/renderBudgetPreflight/autoMovieRenderTargetSettingsOfShot.js.map +1 -0
  330. package/lib/renderBudgetPreflight/index.d.ts +9 -0
  331. package/lib/renderBudgetPreflight/index.js +26 -0
  332. package/lib/renderBudgetPreflight/index.js.map +1 -0
  333. package/lib/renderBudgetPreflight/selectAutoMovieRenderBudget.d.ts +18 -0
  334. package/lib/renderBudgetPreflight/selectAutoMovieRenderBudget.js +22 -0
  335. package/lib/renderBudgetPreflight/selectAutoMovieRenderBudget.js.map +1 -0
  336. package/lib/renderCaptionSidecar.d.ts +13 -0
  337. package/lib/renderCaptionSidecar.js +17 -0
  338. package/lib/renderCaptionSidecar.js.map +1 -0
  339. package/lib/renderObservationAudit.d.ts +1 -0
  340. package/lib/renderObservationAudit.js +18 -0
  341. package/lib/renderObservationAudit.js.map +1 -0
  342. package/lib/renderPathStem.d.ts +22 -0
  343. package/lib/renderPathStem.js +64 -0
  344. package/lib/renderPathStem.js.map +1 -0
  345. package/lib/renderPoseKeypointSidecar.d.ts +15 -0
  346. package/lib/renderPoseKeypointSidecar.js +19 -0
  347. package/lib/renderPoseKeypointSidecar.js.map +1 -0
  348. package/lib/renderSequenceAndSee.d.ts +14 -0
  349. package/lib/renderSequenceAndSee.js +32 -0
  350. package/lib/renderSequenceAndSee.js.map +1 -0
  351. package/lib/renderSequenceVideo.d.ts +15 -0
  352. package/lib/renderSequenceVideo.js +35 -0
  353. package/lib/renderSequenceVideo.js.map +1 -0
  354. package/lib/renderVideo.d.ts +17 -0
  355. package/lib/renderVideo.js +45 -0
  356. package/lib/renderVideo.js.map +1 -0
  357. package/lib/screenplay/index.d.ts +1 -0
  358. package/lib/screenplay/index.js +18 -0
  359. package/lib/screenplay/index.js.map +1 -0
  360. package/lib/screenplay/renderScreenplay.d.ts +25 -0
  361. package/lib/screenplay/renderScreenplay.js +101 -0
  362. package/lib/screenplay/renderScreenplay.js.map +1 -0
  363. package/lib/screenplay/screenplaySceneSlug.d.ts +17 -0
  364. package/lib/screenplay/screenplaySceneSlug.js +21 -0
  365. package/lib/screenplay/screenplaySceneSlug.js.map +1 -0
  366. package/lib/sequenceRenderPlan.d.ts +5 -0
  367. package/lib/sequenceRenderPlan.js +22 -0
  368. package/lib/sequenceRenderPlan.js.map +1 -0
  369. package/lib/sequenceRenderVideo.d.ts +6 -0
  370. package/lib/sequenceRenderVideo.js +23 -0
  371. package/lib/sequenceRenderVideo.js.map +1 -0
  372. package/lib/shotBeat.d.ts +18 -0
  373. package/lib/shotBeat.js +23 -0
  374. package/lib/shotBeat.js.map +1 -0
  375. package/lib/sliceCaptionSidecar.d.ts +15 -0
  376. package/lib/sliceCaptionSidecar.js +57 -0
  377. package/lib/sliceCaptionSidecar.js.map +1 -0
  378. package/package.json +46 -3
  379. package/src/AUTOMOVIE_GUIDE_PASSES.ts +19 -0
  380. package/src/IAutoMovieCaptionEntry.ts +32 -0
  381. package/src/IAutoMovieCaptionSidecar.ts +29 -0
  382. package/src/IAutoMovieCapturedFrame.ts +24 -0
  383. package/src/IAutoMovieGuidePassOutput.ts +27 -0
  384. package/src/IAutoMoviePoseKeypointActor.ts +39 -0
  385. package/src/IAutoMoviePoseKeypointFrame.ts +28 -0
  386. package/src/IAutoMoviePoseKeypointSidecar.ts +25 -0
  387. package/src/IAutoMovieRenderAdapters.ts +39 -0
  388. package/src/IAutoMovieRenderAndSeeRequest.ts +38 -0
  389. package/src/IAutoMovieRenderAndSeeResult.ts +23 -0
  390. package/src/IAutoMovieRenderChunk.ts +62 -0
  391. package/src/IAutoMovieRenderChunkPlan.ts +40 -0
  392. package/src/IAutoMovieRenderPassManifest.ts +25 -0
  393. package/src/IAutoMovieRenderReassembly.ts +28 -0
  394. package/src/IAutoMovieRenderResult.ts +46 -0
  395. package/src/IAutoMovieSequenceRenderAdapters.ts +41 -0
  396. package/src/IAutoMovieSequenceRenderAndSeeRequest.ts +47 -0
  397. package/src/IAutoMovieSequenceRenderAndSeeResult.ts +23 -0
  398. package/src/IAutoMovieSequenceRenderFrame.ts +48 -0
  399. package/src/IAutoMovieSequenceRenderPlan.ts +88 -0
  400. package/src/IAutoMovieSequenceRenderResult.ts +52 -0
  401. package/src/IAutoMovieSequenceRenderShotSpan.ts +46 -0
  402. package/src/IAutoMovieSequenceRenderTransitionSpan.ts +46 -0
  403. package/src/audio/encodeAutoMovieWavPcm16.ts +65 -0
  404. package/src/audio/index.ts +2 -0
  405. package/src/audio/mixAutoMovieAudioPcm.ts +137 -0
  406. package/src/auditAutoMovieRenderObservation.ts +79 -0
  407. package/src/cache/createAutoMovieHttpArtifactStore.ts +84 -0
  408. package/src/caption/IAutoMovieBeatCaption.ts +23 -0
  409. package/src/caption/autoMovieCaptionLanguageComparisonKey.ts +23 -0
  410. package/src/caption/beatCaptions.ts +59 -0
  411. package/src/caption/canonicalProductionWebVtt.ts +76 -0
  412. package/src/caption/canonicalizeAutoMovieCaptionText.ts +24 -0
  413. package/src/caption/escapeWebVttText.ts +23 -0
  414. package/src/caption/index.ts +11 -0
  415. package/src/caption/inspectAutoMovieCaptionReadabilityWithRuntime.ts +231 -0
  416. package/src/caption/isAutoMovieWebVttIdentifier.ts +26 -0
  417. package/src/caption/parseAutoMovieCaptionLanguage.ts +160 -0
  418. package/src/caption/serializeAutoMovieWebVttCueText.ts +28 -0
  419. package/src/caption/serializeAutoMovieWebVttIdentifier.ts +27 -0
  420. package/src/caption/serializeAutoMovieWebVttSingleLineText.ts +26 -0
  421. package/src/caption/webVttCaptionLanguage.ts +30 -0
  422. package/src/caption/webVttTime.ts +30 -0
  423. package/src/captionPlan.ts +1 -0
  424. package/src/captionSidecar.ts +3 -0
  425. package/src/captionSlice.ts +1 -0
  426. package/src/chunkSequenceRender.ts +5 -0
  427. package/src/delivery/AUTOMOVIE_MP4_SRGB_COLOUR.ts +21 -0
  428. package/src/delivery/AUTOMOVIE_MP4_UNITY_MATRIX.ts +14 -0
  429. package/src/delivery/AUTOMOVIE_PRODUCTION_OPUS_PROFILE.ts +28 -0
  430. package/src/delivery/AutoMovieProductionPngRole.ts +18 -0
  431. package/src/delivery/IAutoMovieProductionPngProfile.ts +52 -0
  432. package/src/delivery/IAutoMovieProductionVideoProfile.ts +48 -0
  433. package/src/delivery/assertAutoMovieCaptureClock.ts +37 -0
  434. package/src/delivery/assertProductionOpusProfile.ts +179 -0
  435. package/src/delivery/assertProductionPngPicture.ts +62 -0
  436. package/src/delivery/assertProductionVideoProfile.ts +180 -0
  437. package/src/delivery/auditAutoMovieDecodedFrames.ts +157 -0
  438. package/src/delivery/auditAutoMovieEncodedPresentation.ts +86 -0
  439. package/src/delivery/index.ts +14 -0
  440. package/src/delivery/planAutoMovieCaptureUrl.ts +32 -0
  441. package/src/delivery/productionOpusDescription.ts +173 -0
  442. package/src/delivery/resolveProductionPngProfile.ts +70 -0
  443. package/src/delivery/resolveProductionVideoProfile.ts +48 -0
  444. package/src/ffmpegArgs.ts +61 -0
  445. package/src/film/AutoMovieOrderedScalar.ts +15 -0
  446. package/src/film/IAutoMovieProductionAudioAssetIdentity.ts +40 -0
  447. package/src/film/IAutoMovieProductionAudioAssetIdentityBase.ts +34 -0
  448. package/src/film/IAutoMovieProductionEncoderIdentity.ts +42 -0
  449. package/src/film/IAutoMovieProductionRenderChunk.ts +47 -0
  450. package/src/film/IAutoMovieProductionRenderJobPlan.ts +73 -0
  451. package/src/film/IAutoMovieProductionRenderRuntimeIdentity.ts +37 -0
  452. package/src/film/IAutoMovieProductionRenderTier.ts +27 -0
  453. package/src/film/assertSingleGuidePass.ts +38 -0
  454. package/src/film/equalOrderedScalars.ts +56 -0
  455. package/src/film/index.ts +9 -0
  456. package/src/film/normalizeAudioAssets.ts +74 -0
  457. package/src/film/normalizeRenderTier.ts +51 -0
  458. package/src/film/planProductionRenderJob.ts +353 -0
  459. package/src/film/productionVisualDeliveryOccurrence.ts +28 -0
  460. package/src/film/resolveProductionRenderTierFrameFormat.ts +60 -0
  461. package/src/film/validDigest.ts +23 -0
  462. package/src/film/validWaveAudioIdentity.ts +88 -0
  463. package/src/frameName.ts +24 -0
  464. package/src/framePattern.ts +19 -0
  465. package/src/frameTimes.ts +36 -0
  466. package/src/guidePassFrameName.ts +29 -0
  467. package/src/guidePassFramePattern.ts +27 -0
  468. package/src/guidePasses.ts +7 -0
  469. package/src/guidePassesInternal/passExtension.ts +19 -0
  470. package/src/index.ts +69 -0
  471. package/src/isGuidePass.ts +21 -0
  472. package/src/normalizeGuidePasses.ts +33 -0
  473. package/src/planCaptionSidecar.ts +98 -0
  474. package/src/planChunkedSequenceRender.ts +200 -0
  475. package/src/planGuidePassOutputs.ts +47 -0
  476. package/src/planPoseKeypointSidecar.ts +289 -0
  477. package/src/planSequenceRender.ts +175 -0
  478. package/src/planViewerFrameTimes.ts +98 -0
  479. package/src/renderAndSee.ts +30 -0
  480. package/src/renderBudgetPreflight/IAutoMovieRenderBudgetAssessment.ts +53 -0
  481. package/src/renderBudgetPreflight/IAutoMovieRenderBudgetEvidence.ts +61 -0
  482. package/src/renderBudgetPreflight/IAutoMovieRenderGraphicsIdentity.ts +29 -0
  483. package/src/renderBudgetPreflight/assessAutoMovieRenderBudget.ts +137 -0
  484. package/src/renderBudgetPreflight/autoMovieRenderBudgetEvidence.ts +100 -0
  485. package/src/renderBudgetPreflight/autoMovieRenderBudgetRefusal.ts +82 -0
  486. package/src/renderBudgetPreflight/autoMovieRenderTargetRendererOfGraphics.ts +40 -0
  487. package/src/renderBudgetPreflight/autoMovieRenderTargetSettingsOfShot.ts +59 -0
  488. package/src/renderBudgetPreflight/index.ts +9 -0
  489. package/src/renderBudgetPreflight/selectAutoMovieRenderBudget.ts +28 -0
  490. package/src/renderCaptionSidecar.ts +17 -0
  491. package/src/renderObservationAudit.ts +1 -0
  492. package/src/renderPathStem.ts +61 -0
  493. package/src/renderPoseKeypointSidecar.ts +19 -0
  494. package/src/renderSequenceAndSee.ts +34 -0
  495. package/src/renderSequenceVideo.ts +44 -0
  496. package/src/renderVideo.ts +65 -0
  497. package/src/screenplay/index.ts +1 -0
  498. package/src/screenplay/renderScreenplay.ts +128 -0
  499. package/src/screenplay/screenplaySceneSlug.ts +29 -0
  500. package/src/sequenceRenderPlan.ts +5 -0
  501. package/src/sequenceRenderVideo.ts +6 -0
  502. package/src/shotBeat.ts +19 -0
  503. package/src/sliceCaptionSidecar.ts +85 -0
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Encode two equally long normalized channels as a canonical 44-byte-header
3
+ * RIFF/WAVE file of 16-bit little-endian PCM stereo. Each sample is
4
+ * quantized by `round(x * 32767)` for nonnegative and `round(x * 32768)` for
5
+ * negative amplitudes, the inverse of the 1/32768 decode scale up to
6
+ * rounding; a nonfinite or out-of-range amplitude is refused rather than
7
+ * clipped. Deterministic: equal channels give equal bytes.
8
+ *
9
+ * @param left Left channel, amplitudes in [-1, 1].
10
+ * @param right Right channel, the same length.
11
+ * @param sampleRate Samples per second, a positive safe integer.
12
+ * @returns The file bytes.
13
+ * @evidence contracts/development/common.md#meaningful-documentation Gives the purpose (Encode two equally long normalized channels as a canonical 44-byte-header RIFF/WAVE file of 16-bit little-endian PCM stereo) and documents parameters `left`, `right`, `sampleRate`, the returned value as stated in this comment.
14
+ * @evidence contracts/development/implementation.md#principled-implementation Implements the documented behavior (Encode two equally long normalized channels as a canonical 44-byte-header RIFF/WAVE file of 16-bit little-endian PCM stereo) directly over its typed inputs (`left`, `right`, `sampleRate`) as nested iteration of depth 2 (for loop bounded by k < text.length; for loop bounded by k < left.length; for loop bounded by channel < 2), delegating to `Number.isSafeInteger`, `text.charCodeAt`, `tag`, `view.setUint32`, `view.setUint16`; the premises are the units, frames and ranges stated in its parameter documentation, enforced only where the body throws (2 throw sites). Beyond structural 0, 1 and 2 the body uses the literals 4294967295, 36, 4, 44, 8, whose basis this answer does not independently establish and a reviewer must confirm.
15
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure One operation of 41 lines and 19 top-level statements that reuses `Number.isSafeInteger`, `text.charCodeAt`, `tag`, `view.setUint32`, `view.setUint16` from their owners instead of copying them; it adds no option, layer or abstraction beyond its documented parameters.
16
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts The body contains 0 `any`, 0 type assertion(s), 1 non-null assertion(s); these are the remaining shortcuts and are not justified here.
17
+ * @evidence contracts/development/implementation.md#efficient-algorithms Cost is driven by the sizes of `left`, `right`, `sampleRate`; the dominant cost is nested iteration of depth 2 (for loop bounded by k < text.length; for loop bounded by k < left.length; for loop bounded by channel < 2), performed once per call with 4 allocation sites (literals and constructed values). No speedup is claimed and none is measured.
18
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work The operation coordinates no requests, phases or consumers and holds no cache: each call recomputes from its arguments and shares nothing, which is correct because its result depends only on them.
19
+ * @evidenceExclude contracts/development/implementation.md#bound-retention-and-release-resources The function acquires no handle, timer, listener or task and keeps no state between calls; its 4 allocation sites become the returned value or die with the call, so nothing grows.
20
+ */
21
+ export function encodeAutoMovieWavPcm16(
22
+ left: Float32Array,
23
+ right: Float32Array,
24
+ sampleRate: number,
25
+ ): Uint8Array {
26
+ if (
27
+ left.length === 0 ||
28
+ left.length !== right.length ||
29
+ left.length > (0xffffffff - 36) / 4 ||
30
+ !Number.isSafeInteger(sampleRate) ||
31
+ sampleRate <= 0
32
+ )
33
+ throw new Error("Invalid stereo PCM length or rate");
34
+ const bytes: Uint8Array = new Uint8Array(44 + left.length * 4);
35
+ const view: DataView = new DataView(bytes.buffer);
36
+ const tag = (at: number, text: string): void => {
37
+ for (let k: number = 0; k < text.length; k++)
38
+ bytes[at + k] = text.charCodeAt(k);
39
+ };
40
+ tag(0, "RIFF");
41
+ view.setUint32(4, bytes.length - 8, true);
42
+ tag(8, "WAVE");
43
+ tag(12, "fmt ");
44
+ view.setUint32(16, 16, true);
45
+ view.setUint16(20, 1, true);
46
+ view.setUint16(22, 2, true);
47
+ view.setUint32(24, sampleRate, true);
48
+ view.setUint32(28, sampleRate * 4, true);
49
+ view.setUint16(32, 4, true);
50
+ view.setUint16(34, 16, true);
51
+ tag(36, "data");
52
+ view.setUint32(40, left.length * 4, true);
53
+ for (let k: number = 0; k < left.length; k++)
54
+ for (let channel: number = 0; channel < 2; channel++) {
55
+ const x: number = (channel === 0 ? left : right)[k]!;
56
+ if (!Number.isFinite(x) || Math.abs(x) > 1)
57
+ throw new Error(`PCM amplitude ${x} at frame ${k}, channel ${channel}`);
58
+ view.setInt16(
59
+ 44 + 4 * k + 2 * channel,
60
+ Math.round(x * (x < 0 ? 32768 : 32767)),
61
+ true,
62
+ );
63
+ }
64
+ return bytes;
65
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./encodeAutoMovieWavPcm16";
2
+ export * from "./mixAutoMovieAudioPcm";
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Sum mono audio sources into one stereo soundtrack, sample-accurately and
3
+ * deterministically.
4
+ *
5
+ * Each cue reads its source from `offsetSeconds` at `rate` source samples per
6
+ * output sample (two-tap linear interpolation), starting at output sample
7
+ * `round(seconds * sampleRate)` and lasting `round(durationSeconds *
8
+ * sampleRate)` samples (the rest of the source by default). It is shaped by
9
+ * symmetric linear edge fades of `fadeSeconds` (at most half the cue) and
10
+ * placed by equal-power pan, left `cos((pan + 1) pi / 4)` and right
11
+ * `sin((pan + 1) pi / 4)`, times its gain and the master gain. Samples past
12
+ * the soundtrack's end are dropped. The sum is clipping-safe by refusal: a
13
+ * nonfinite sample or a peak above 1 throws instead of limiting, so a mix
14
+ * never ships silently distorted. Cost is linear in audible cue samples and
15
+ * the output length.
16
+ *
17
+ * @returns Both channels the caller owns, and the peak absolute amplitude.
18
+ * @evidence contracts/development/common.md#meaningful-documentation Gives the purpose (Sum mono audio sources into one stereo soundtrack, sample-accurately and deterministically) and documents the returned value as stated in this comment.
19
+ * @evidence contracts/development/implementation.md#principled-implementation Implements the documented behavior (Sum mono audio sources into one stereo soundtrack, sample-accurately and deterministically) directly over its typed inputs (`input`) as nested iteration of depth 2 (forEach over input.cues; every over [cue.seconds, cue.gain, pan, speed, offs; for loop bounded by k < count && start + k < input.frames), delegating to `Number.isSafeInteger`, `Math.abs`, `Math.floor`, `Math.round`, `Math.cos`; the premises are the units, frames and ranges stated in its parameter documentation, enforced only where the body throws (7 throw sites). Beyond structural 0, 1 and 2 the body uses the literals 0.004, 4, whose basis this answer does not independently establish and a reviewer must confirm.
20
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure One operation of 70 lines and 12 top-level statements that reuses `Number.isSafeInteger`, `Math.abs`, `Math.floor`, `Math.round`, `Math.cos` from their owners instead of copying them; it adds no option, layer or abstraction beyond its documented parameters.
21
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts The body contains 0 `any`, 0 type assertion(s), 6 non-null assertion(s); these are the remaining shortcuts and are not justified here.
22
+ * @evidence contracts/development/implementation.md#efficient-algorithms Cost is driven by the sizes of `input`; the dominant cost is nested iteration of depth 2 (forEach over input.cues; every over [cue.seconds, cue.gain, pan, speed, offs; for loop bounded by k < count && start + k < input.frames), performed once per call with 11 allocation sites (literals and constructed values). No speedup is claimed and none is measured.
23
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work The operation coordinates no requests, phases or consumers and holds no cache: each call recomputes from its arguments and shares nothing, which is correct because its result depends only on them.
24
+ * @evidenceExclude contracts/development/implementation.md#bound-retention-and-release-resources The function acquires no handle, timer, listener or task and keeps no state between calls; its 11 allocation sites become the returned value or die with the call, so nothing grows.
25
+ */
26
+ export function mixAutoMovieAudioPcm(input: {
27
+ /** Output samples per second; a positive safe integer. */ sampleRate: number;
28
+ /** Output length in samples; a positive safe integer. */ frames: number;
29
+ /** Normalized mono sources by id, at the output rate. */ sources: Readonly<
30
+ Record<string, Float32Array>
31
+ >;
32
+ /** The cues. */ cues: readonly mixAutoMovieAudioPcm.ICue[];
33
+ /** Linear gain applied to every cue; 1 by default. */ master?: number;
34
+ /** Edge fade length, seconds; 0.004 by default. */ fadeSeconds?: number;
35
+ }): { left: Float32Array; right: Float32Array; peak: number } {
36
+ const rate: number = input.sampleRate;
37
+ if (
38
+ !Number.isSafeInteger(rate) ||
39
+ rate <= 0 ||
40
+ !Number.isSafeInteger(input.frames) ||
41
+ input.frames <= 0
42
+ )
43
+ throw new Error("Invalid audio mix rate or length");
44
+ const master: number = input.master ?? 1;
45
+ const fadeSeconds: number = input.fadeSeconds ?? 0.004;
46
+ if (!(master >= 0) || !(fadeSeconds >= 0))
47
+ throw new Error("Invalid audio mix master gain or fade");
48
+ const left: Float32Array = new Float32Array(input.frames);
49
+ const right: Float32Array = new Float32Array(input.frames);
50
+ input.cues.forEach((cue: mixAutoMovieAudioPcm.ICue, index: number): void => {
51
+ const source: Float32Array | undefined = input.sources[cue.asset];
52
+ if (source === undefined || source.length === 0)
53
+ throw new Error(`Audio cue ${index} names no source: ${cue.asset}`);
54
+ const speed: number = cue.rate ?? 1;
55
+ const offset: number = (cue.offsetSeconds ?? 0) * rate;
56
+ const pan: number = cue.pan ?? 0;
57
+ if (
58
+ ![cue.seconds, cue.gain, pan, speed, offset].every(Number.isFinite) ||
59
+ cue.seconds < 0 ||
60
+ cue.gain < 0 ||
61
+ Math.abs(pan) > 1 ||
62
+ !(speed > 0) ||
63
+ offset < 0
64
+ )
65
+ throw new Error(`Invalid audio cue ${index}: ${cue.asset}`);
66
+ const available: number =
67
+ Math.floor((source.length - 1 - offset) / speed) + 1;
68
+ const count: number =
69
+ cue.durationSeconds === undefined
70
+ ? available
71
+ : Math.round(cue.durationSeconds * rate);
72
+ if (!(count > 0) || count > available)
73
+ throw new Error(`Audio cue ${index} reads past its source: ${cue.asset}`);
74
+ const start: number = Math.round(cue.seconds * rate);
75
+ const gainLeft: number =
76
+ Math.cos(((pan + 1) * Math.PI) / 4) * cue.gain * master;
77
+ const gainRight: number =
78
+ Math.sin(((pan + 1) * Math.PI) / 4) * cue.gain * master;
79
+ const fade: number = Math.min(
80
+ Math.round(fadeSeconds * rate),
81
+ Math.floor(count / 2),
82
+ );
83
+ for (let k: number = 0; k < count && start + k < input.frames; k++) {
84
+ const position: number = offset + k * speed;
85
+ const lower: number = Math.floor(position);
86
+ const fraction: number = position - lower;
87
+ const sample: number =
88
+ source[lower]! * (1 - fraction) +
89
+ source[Math.min(lower + 1, source.length - 1)]! * fraction;
90
+ if (!Number.isFinite(sample))
91
+ throw new Error(`Nonfinite audio source sample: ${cue.asset}`);
92
+ const edge: number =
93
+ fade === 0 ? 1 : Math.min(1, k / fade, (count - 1 - k) / fade);
94
+ left[start + k] = left[start + k]! + sample * edge * gainLeft;
95
+ right[start + k] = right[start + k]! + sample * edge * gainRight;
96
+ }
97
+ });
98
+ let peak: number = 0;
99
+ for (let k: number = 0; k < input.frames; k++)
100
+ peak = Math.max(peak, Math.abs(left[k]!), Math.abs(right[k]!));
101
+ if (!Number.isFinite(peak) || peak > 1)
102
+ throw new Error(`The audio mix clips at peak ${peak}`);
103
+ return { left, right, peak };
104
+ }
105
+ /**
106
+ * Companion types of {@link mixAutoMovieAudioPcm}.
107
+ *
108
+ * @evidence contracts/development/common.md#meaningful-documentation Gives the purpose (Companion types of ) and documents 1 documented member as stated in this comment.
109
+ * @evidence contracts/development/design.md#principled-representation Represents Companion types of : companion namespace of 1 member (`ICue`); units and frames named in its text: seconds. It has no optional member, so no absent-value state combines with another.
110
+ * @evidence contracts/development/design.md#minimal-and-owned-surface Owned by the module that declares `mixAutoMovieAudioPcm` in packages/render/src/audio/mixAutoMovieAudioPcm.ts; its surface is the 1 member listed and the text shows 4 other files naming it, mostly packages/render (2), packages/viewer (1), test (1), so no member is declared for a presumed future need.
111
+ * @evidence contracts/development/design.md#prohibited-design-shortcuts Scanning the declaration finds no `any`, no `unknown`, no index signature and no cast; it duplicates no type that another owner declares as far as a name search shows.
112
+ */
113
+ export namespace mixAutoMovieAudioPcm {
114
+ /** One placed source excerpt. */
115
+ export interface ICue {
116
+ /** Source id. */
117
+ asset: string;
118
+
119
+ /** Output onset, seconds; nonnegative. */
120
+ seconds: number;
121
+
122
+ /** Linear gain; nonnegative. */
123
+ gain: number;
124
+
125
+ /** Equal-power pan in [-1, 1]; 0 by default. */
126
+ pan?: number;
127
+
128
+ /** Source offset, seconds; 0 by default. */
129
+ offsetSeconds?: number;
130
+
131
+ /** Output duration, seconds; the rest of the source by default. */
132
+ durationSeconds?: number;
133
+
134
+ /** Source samples per output sample; 1 by default. */
135
+ rate?: number;
136
+ }
137
+ }
@@ -0,0 +1,79 @@
1
+ import type {
2
+ AutoMovieRenderMetric,
3
+ IAutoMovieRenderObservation,
4
+ IAutoMovieRenderObservationBreach,
5
+ IAutoMovieRenderReport,
6
+ } from "@automovie/interface";
7
+
8
+ /**
9
+ * Check what one capture actually drew against the report that cleared it.
10
+ *
11
+ * Report measurements are exact or conservative preflight bounds. Drawing less
12
+ * is expected after culling and level-of-detail selection, while drawing more
13
+ * proves that the report describes a different render inventory. A metric for
14
+ * which the report produced no number remains `unchecked`; absence of a breach
15
+ * never turns an analysis that did not run into agreement.
16
+ *
17
+ * @evidence contracts/development/implementation.md#principled-implementation Each observable metric is compared with its unique finite non-negative report bound; duplicate findings, absent bounds and unknown observed counts remain unchecked rather than certifying agreement.
18
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure The function owns the report-versus-capture comparison only, using one table to associate observation fields with report metrics.
19
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No metric is defaulted to zero and no duplicate finding wins by position; greater observed counts become breaches while smaller counts remain admissible after culling.
20
+ * @evidence contracts/development/common.md#meaningful-documentation The comment explains conservative bounds, culling and unchecked measurements; return fields distinguish complete agreement, breaches and unknown metrics.
21
+ * @evidence contracts/development/implementation.md#efficient-algorithms For R findings, one map-building traversal plus seven fixed observation comparisons costs O(R) time and O(R) indexed entries.
22
+ * @evidence contracts/development/implementation.md#reuse-equivalent-work The per-call finding map supplies all observation lookups without repeatedly scanning the report; results cannot be reused for a different capture observation.
23
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources Maps and duplicate sets are call-local, and the returned breach and unchecked arrays contain at most seven entries with no report or graphics-context ownership.
24
+ */
25
+ export function auditAutoMovieRenderObservation(props: {
26
+ /** The report that cleared the artifact. */
27
+ report: IAutoMovieRenderReport;
28
+ /** What the captured scene actually submits. */
29
+ observed: IAutoMovieRenderObservation;
30
+ }): {
31
+ /** Whether every observable metric was measured and stayed inside its bound. */
32
+ agrees: boolean;
33
+ /** Every observed value above its report bound, in metric order. */
34
+ breaches: IAutoMovieRenderObservationBreach[];
35
+ /** Observable metrics for which the report produced no number. */
36
+ unchecked: AutoMovieRenderMetric[];
37
+ } {
38
+ const observable: ReadonlyArray<
39
+ [AutoMovieRenderMetric, keyof IAutoMovieRenderObservation]
40
+ > = [
41
+ ["triangles", "triangles"],
42
+ ["drawCalls", "drawCalls"],
43
+ ["materials", "materials"],
44
+ ["textures", "textures"],
45
+ ["lights", "lights"],
46
+ ["shadowMaps", "shadowMaps"],
47
+ ["instanceSlots", "instanceSlots"],
48
+ ];
49
+ const measured: Map<AutoMovieRenderMetric, number | null> = new Map();
50
+ const duplicate: Set<AutoMovieRenderMetric> = new Set();
51
+ for (const finding of props.report.findings) {
52
+ if (measured.has(finding.metric)) duplicate.add(finding.metric);
53
+ else measured.set(finding.metric, finding.measured);
54
+ }
55
+ const breaches: IAutoMovieRenderObservationBreach[] = [];
56
+ const unchecked: AutoMovieRenderMetric[] = [];
57
+ for (const [metric, field] of observable) {
58
+ const bound: number | null = measured.get(metric) ?? null;
59
+ const observed: number | null = props.observed[field];
60
+ if (
61
+ duplicate.has(metric) ||
62
+ bound === null ||
63
+ Number.isFinite(bound) === false ||
64
+ bound < 0 ||
65
+ observed === null ||
66
+ Number.isFinite(observed) === false ||
67
+ observed < 0
68
+ ) {
69
+ unchecked.push(metric);
70
+ continue;
71
+ }
72
+ if (observed > bound) breaches.push({ metric, bound, observed });
73
+ }
74
+ return {
75
+ agrees: breaches.length === 0 && unchecked.length === 0,
76
+ breaches,
77
+ unchecked,
78
+ };
79
+ }
@@ -0,0 +1,84 @@
1
+ import type { IAutoMovieArtifactStore } from "@automovie/engine";
2
+
3
+ /**
4
+ * An engine artifact store a browser page reaches over HTTP, served by
5
+ * `createAutoMovieArtifactMiddleware` from a directory store on the
6
+ * production's development server.
7
+ *
8
+ * A page computing an expensive deterministic stage (a prepared figure, a
9
+ * physics bake) cannot write files, and a fresh headless capture browser has
10
+ * no persistent browser storage, so the cache lives with the server: one
11
+ * directory serves the interactive Viewer and every render capture alike.
12
+ * `GET <base>/<hex>` returns the bytes with header
13
+ * `x-automovie-artifact-digest` or 404, `PUT` stores them with that header and
14
+ * `DELETE` removes them, where `<hex>` is the key without `sha256:`. Digests
15
+ * use `crypto.subtle`, available in secure contexts, which include
16
+ * `http://localhost` and `http://127.0.0.1`.
17
+ *
18
+ * @param base Route prefix or absolute URL, such as `/__automovie/artifacts`.
19
+ * @returns A store; a network failure or a non-success status rejects.
20
+ *
21
+ * @evidence contracts/development/implementation.md#principled-implementation Uses the Fetch standard's methods and status codes and Web Crypto's SHA-256, which equals Node's createHash digest on the server, so both sides verify the same content digest.
22
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure Transport only; the engine resolver decides reuse and the middleware owns files.
23
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Only 404 means absent; every other failure rejects instead of being read as a miss.
24
+ * @evidence contracts/development/implementation.md#efficient-algorithms One request per operation; digest cost is linear in artifact bytes.
25
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work The store shares nothing itself; the engine resolver decides reuse.
26
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources Each request's body is held only until it resolves; no connection or cache is retained.
27
+ * @evidence contracts/development/common.md#meaningful-documentation States why the store is server-backed, the routes and header, the secure-context requirement and failure behavior.
28
+ */
29
+ export function createAutoMovieHttpArtifactStore(
30
+ base: string,
31
+ ): IAutoMovieArtifactStore {
32
+ const url: (key: string) => string = (key: string): string => {
33
+ if (!/^sha256:[0-9a-f]{64}$/.test(key))
34
+ throw new Error(`Invalid artifact key: ${key}`);
35
+ return `${base.replace(/\/+$/, "")}/${key.slice(7)}`;
36
+ };
37
+ const expect: (response: Response, operation: string) => void = (
38
+ response: Response,
39
+ operation: string,
40
+ ): void => {
41
+ if (!response.ok)
42
+ throw new Error(
43
+ `Artifact ${operation} failed with HTTP ${response.status}`,
44
+ );
45
+ };
46
+ return {
47
+ read: async (
48
+ key: string,
49
+ ): Promise<IAutoMovieArtifactStore.IEntry | undefined> => {
50
+ const response: Response = await fetch(url(key));
51
+ if (response.status === 404) return undefined;
52
+ expect(response, "read");
53
+ const digest: string | null = response.headers.get(HEADER);
54
+ if (digest === null) throw new Error("Artifact read lacks its digest");
55
+ return { bytes: new Uint8Array(await response.arrayBuffer()), digest };
56
+ },
57
+ write: async (
58
+ key: string,
59
+ entry: IAutoMovieArtifactStore.IEntry,
60
+ ): Promise<void> => {
61
+ expect(
62
+ await fetch(url(key), {
63
+ method: "PUT",
64
+ headers: { [HEADER]: entry.digest },
65
+ body: entry.bytes as BodyInit,
66
+ }),
67
+ "write",
68
+ );
69
+ },
70
+ remove: async (key: string): Promise<void> => {
71
+ expect(await fetch(url(key), { method: "DELETE" }), "remove");
72
+ },
73
+ digest: async (bytes: Uint8Array): Promise<string> =>
74
+ `sha256:${Array.from(
75
+ new Uint8Array(
76
+ await crypto.subtle.digest("SHA-256", bytes as BufferSource),
77
+ ),
78
+ (byte: number): string => byte.toString(16).padStart(2, "0"),
79
+ ).join("")}`,
80
+ };
81
+ }
82
+
83
+ /** Response and request header carrying the entry's recorded digest. */
84
+ const HEADER: string = "x-automovie-artifact-digest";
@@ -0,0 +1,23 @@
1
+ /**
2
+ * One beat's caption and the slug of its enclosing scene, as the caption join
3
+ * reads them from the screenplay tree.
4
+ *
5
+ * `beatCaptions` builds one record per beat node, keyed by beat id, and
6
+ * `planCaptionSidecar` copies both fields onto every sidecar span whose live
7
+ * shot belongs to that beat.
8
+ *
9
+ * @evidence contracts/development/design.md#principled-representation The record carries the beat node's caption verbatim and the slug `screenplaySceneSlug` formats, so a span's scene label and the screenplay heading come from one formatter, and null mirrors the absence the tree payload itself encodes.
10
+ * @evidence contracts/development/design.md#minimal-and-owned-surface Two nullable fields are all the sidecar join reads from a beat node; the beat identity stays the map key in `beatCaptions` instead of a third field the join would never read.
11
+ * @evidence contracts/development/design.md#prohibited-design-shortcuts No consumer or fixture is special-cased: both nulls stand for states the screenplay tree can hold, an uncaptioned beat and a beat outside every scene.
12
+ * @evidence contracts/development/common.md#meaningful-documentation The prose names the producer and the reader of the record, and each member says what its null means.
13
+ */
14
+ export interface IAutoMovieBeatCaption {
15
+ /** The beat's authored shot caption, or null when the beat authored none. */
16
+ caption: string | null;
17
+
18
+ /**
19
+ * Slug of the nearest enclosing scene node, or null when no scene encloses
20
+ * the beat.
21
+ */
22
+ slug: string | null;
23
+ }
@@ -0,0 +1,23 @@
1
+ import { parseAutoMovieCaptionLanguage } from "./parseAutoMovieCaptionLanguage";
2
+
3
+ /**
4
+ * Return the ASCII case-folded identity of a well-formed RFC 5646 language
5
+ * tag, or null for a malformed tag.
6
+ *
7
+ * Two caption languages are the same language exactly when their keys are
8
+ * equal, so `EN-us` and `en-US` share a readability profile and a preceding-gap
9
+ * history. A null key matches nothing; the readability inspector leaves such a
10
+ * cue without a profile or a gap instead of guessing a language.
11
+ *
12
+ * @evidence contracts/development/implementation.md#principled-implementation RFC 5646 section 2.1.1 defines tag comparison as ASCII case-insensitive, and the key is the parser's lower-cased spelling, which is ASCII-only because the parser admits only letters, digits and hyphens.
13
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure The function is a projection of `parseAutoMovieCaptionLanguage` for callers that need only identity, so the grammar and the case fold each live in the parser once.
14
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts It consults no registry, applies no Preferred-Value and special-cases no tag; a malformed tag returns null rather than a best-effort key.
15
+ * @evidence contracts/development/common.md#meaningful-documentation The doc states the comparison rule the key implements, gives a concrete equivalence, and says what a null key means to the readability consumer.
16
+ * @evidence contracts/development/implementation.md#efficient-algorithms Cost is one parse linear in tag length, including its folded string, subtag array and variant/singleton sets. The grammar bounds each subtag's length but this boundary imposes no total tag-length quota.
17
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work A pure per-tag projection coordinates no phases; the inspector calls it once per profile and once per cue, and a cache would cost more than reparsing a short tag.
18
+ * @evidenceExclude contracts/development/implementation.md#bound-retention-and-release-resources The function retains nothing after returning a string, and it opens no handle or task.
19
+ */
20
+ export const autoMovieCaptionLanguageComparisonKey: (
21
+ value: string,
22
+ ) => string | null = (value: string): string | null =>
23
+ parseAutoMovieCaptionLanguage(value)?.comparisonKey ?? null;
@@ -0,0 +1,59 @@
1
+ import type {
2
+ IAutoMovieScript,
3
+ IAutoMovieScriptNode,
4
+ } from "@automovie/interface";
5
+
6
+ import { screenplaySceneSlug } from "../screenplay/screenplaySceneSlug";
7
+ import type { IAutoMovieBeatCaption } from "./IAutoMovieBeatCaption";
8
+
9
+ /**
10
+ * Index each beat's caption and enclosing scene slug from the screenplay tree,
11
+ * keyed by beat id: the join table `planCaptionSidecar` consults per span.
12
+ *
13
+ * The walk is depth-first from every root node, children in declaration order,
14
+ * carrying the nearest scene slug down. A script whose `tree` is null or
15
+ * absent, or a tree with no root, yields an empty map, so every span captions
16
+ * null. A node unreachable from a root is never visited, and a beat id that
17
+ * appears on two beat nodes keeps the later visit; commit validation refuses
18
+ * both shapes, so neither reaches a committed script.
19
+ *
20
+ * @evidence contracts/development/implementation.md#principled-implementation An adjacency map from parent id to children turns the parent-pointer node list into a tree the walk visits once per reachable node, and the slug is passed down as a parameter so a scene's slug scopes exactly its subtree; the walk relies on commit validation's acyclic, unique-id tree, without which a node whose id equals its own parent would recurse forever.
21
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure One function builds the adjacency map and the index together because no other caption consumer needs the adjacency; the scene slug comes from `screenplaySceneSlug` so the caption label and the screenplay heading cannot diverge, and the same parent-map walk is written again in `renderScreenplay`, a duplication this function does not own.
22
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Both null and absent `tree` values are the interface's documented treeless states, not a fixture case, and the function never repairs an invalid tree; it leaves rejection to commit validation.
23
+ * @evidence contracts/development/common.md#meaningful-documentation The doc names the consumer and key, the walk order and slug inheritance, what a treeless script yields, and what happens to an unreachable node or a repeated beat id.
24
+ * @evidence contracts/development/implementation.md#efficient-algorithms Time and space are linear in the node count N: one pass builds the adjacency map and the walk visits each reachable node once with a constant-time slug format per scene, which is the minimum for reading every beat.
25
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work The function computes one fresh index per call for one script and coordinates no phases; `planCaptionSidecar` calls it once per plan.
26
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The adjacency map is local and released on return, and the returned map, owned by the caller, holds one record per distinct beat id, bounded by the tree's beat count; recursion depth is bounded by the tree's depth.
27
+ */
28
+ export const beatCaptions: (
29
+ script: IAutoMovieScript,
30
+ ) => Map<string, IAutoMovieBeatCaption> = (
31
+ script: IAutoMovieScript,
32
+ ): Map<string, IAutoMovieBeatCaption> => {
33
+ const map: Map<string, IAutoMovieBeatCaption> = new Map();
34
+ const tree: IAutoMovieScriptNode[] | null | undefined = script.tree;
35
+ if (tree === undefined || tree === null) return map;
36
+
37
+ const children: Map<string | null, IAutoMovieScriptNode[]> = new Map();
38
+ for (const node of tree) {
39
+ const list: IAutoMovieScriptNode[] = children.get(node.parent) ?? [];
40
+ list.push(node);
41
+ children.set(node.parent, list);
42
+ }
43
+
44
+ const walk: (node: IAutoMovieScriptNode, slug: string | null) => void = (
45
+ node: IAutoMovieScriptNode,
46
+ slug: string | null,
47
+ ): void => {
48
+ const current: string | null =
49
+ node.kind === "scene" ? screenplaySceneSlug(node.payload) : slug;
50
+ if (node.kind === "beat")
51
+ map.set(node.payload.beat, {
52
+ caption: node.payload.caption,
53
+ slug: current,
54
+ });
55
+ for (const child of children.get(node.id) ?? []) walk(child, current);
56
+ };
57
+ for (const root of children.get(null) ?? []) walk(root, null);
58
+ return map;
59
+ };
@@ -0,0 +1,76 @@
1
+ import {
2
+ compareCodeUnits,
3
+ productionFrameIntervalToGridTicks,
4
+ resolveProductionFrameRate,
5
+ } from "@automovie/engine";
6
+ import type {
7
+ IAutoMovieFilmTimeline,
8
+ IAutoMovieProductionFrameRate,
9
+ } from "@automovie/interface";
10
+
11
+ import { serializeAutoMovieWebVttCueText } from "./serializeAutoMovieWebVttCueText";
12
+ import { serializeAutoMovieWebVttIdentifier } from "./serializeAutoMovieWebVttIdentifier";
13
+ import { serializeAutoMovieWebVttSingleLineText } from "./serializeAutoMovieWebVttSingleLineText";
14
+ import { webVttCaptionLanguage } from "./webVttCaptionLanguage";
15
+ import { webVttTime } from "./webVttTime";
16
+
17
+ type ICaptionCue = IAutoMovieFilmTimeline["tracks"]["captions"][number];
18
+
19
+ /**
20
+ * Serialize a compiled timeline's caption track as the one canonical WebVTT
21
+ * file its caption deliverable must equal byte for byte.
22
+ *
23
+ * The header carries the timeline id. Cues are ordered by start frame, then end
24
+ * frame, then id in code-unit order, and each cue's frame interval maps to
25
+ * whole milliseconds with nearest rounding on the exact production frame rate.
26
+ * The payload sits in a `<lang>` span, inside a `<v>` voice span when the cue
27
+ * names a speaker, and every block ends with a blank line. Throws when an id is
28
+ * not a WebVTT identifier, a language is not a well-formed RFC 5646 tag, the
29
+ * timeline's `fps` disagrees with its exact frame rate, or a cue interval is
30
+ * empty or collapses on the millisecond clock.
31
+ *
32
+ * @evidence contracts/development/implementation.md#principled-implementation The cue syntax follows the W3C WebVTT file grammar: identifiers are preserved verbatim, cue text and annotations are escaped by the shared serializers, and times come from `productionFrameIntervalToGridTicks`, whose BigInt arithmetic maps each rational frame boundary to an exact integer millisecond before formatting.
33
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure The function only orders cues and assembles lines; identifier refusal, text escaping, language validation, frame-to-tick mapping and timestamp spelling each live in the helper that owns them, so the delivery validator compares against the same bytes the writer emits.
34
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts The only fixed values are WebVTT syntax and the 1000-tick millisecond clock WebVTT timestamps require; nothing is special-cased per cue, and a malformed cue throws instead of being skipped.
35
+ * @evidence contracts/development/common.md#meaningful-documentation The doc states the byte-equality role, the header source, the cue order, the millisecond rounding, the span nesting, and every refusal.
36
+ * @evidence contracts/development/implementation.md#efficient-algorithms For C cues of text length L the cost is an O(C log C) sort of a copied array plus O(L) escaping per cue; the copy keeps the caller's timeline unmodified, and the sort is needed because the order is part of the canonical bytes.
37
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Each call serializes one timeline into a fresh string and coordinates no phases or consumers whose work it could share.
38
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources Only the sorted copy and the line array are held, both released on return; the output string, owned by the caller, grows linearly with cue count and text length.
39
+ */
40
+ export const canonicalProductionWebVtt: (
41
+ timeline: IAutoMovieFilmTimeline,
42
+ ) => string = (timeline: IAutoMovieFilmTimeline): string => {
43
+ const frameRate: IAutoMovieProductionFrameRate =
44
+ resolveProductionFrameRate(timeline);
45
+ const cues: ICaptionCue[] = [...timeline.tracks.captions].sort(
46
+ (left: ICaptionCue, right: ICaptionCue): number =>
47
+ left.startFrame - right.startFrame ||
48
+ left.endFrame - right.endFrame ||
49
+ compareCodeUnits(left.id, right.id),
50
+ );
51
+ return [
52
+ `WEBVTT ${serializeAutoMovieWebVttIdentifier(timeline.id)}`,
53
+ "",
54
+ ...cues.flatMap((cue: ICaptionCue): string[] => {
55
+ const interval: { start: number; end: number } =
56
+ productionFrameIntervalToGridTicks({
57
+ startFrame: cue.startFrame,
58
+ endFrame: cue.endFrame,
59
+ frameRate,
60
+ ticksPerSecond: 1_000,
61
+ rounding: "nearest",
62
+ });
63
+ const payload: string = serializeAutoMovieWebVttCueText(cue.text);
64
+ return [
65
+ serializeAutoMovieWebVttIdentifier(cue.id),
66
+ `${webVttTime(interval.start)} --> ${webVttTime(interval.end)}`,
67
+ `<lang ${webVttCaptionLanguage(cue.language)}>${
68
+ cue.speaker === undefined
69
+ ? payload
70
+ : `<v ${serializeAutoMovieWebVttSingleLineText(cue.speaker)}>${payload}</v>`
71
+ }</lang>`,
72
+ "",
73
+ ];
74
+ }),
75
+ ].join("\n");
76
+ };
@@ -0,0 +1,24 @@
1
+ const PROHIBITED_CAPTION_CONTROLS: RegExp =
2
+ /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/gu;
3
+
4
+ /**
5
+ * Normalize one authored caption into the presentation shared by readability
6
+ * measurement and WebVTT delivery.
7
+ *
8
+ * CRLF and lone CR become LF, tabs stay intact, and every other C0 control and
9
+ * DEL becomes one space. Lines are never reflowed or trimmed, and empty lines
10
+ * stay empty here so readability counts the exact authored presentation; the
11
+ * cue serializer, not this function, makes an empty line survive WebVTT.
12
+ *
13
+ * @evidence contracts/development/implementation.md#principled-implementation Two global regular-expression replacements implement the mapping: the first folds both legacy line terminators into LF, and the second maps the remaining C0 controls and DEL one-for-one to a space, so line count and every printable code point are preserved.
14
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure One function owns the presentation so the readability inspector, film assembly's blank-text check and the cue serializer all read the same text; it does no escaping, which belongs to the WebVTT serializers.
15
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts The character classes are the controls WebVTT cue text cannot carry, a format rule rather than a measured case, and no caption or consumer is special-cased.
16
+ * @evidence contracts/development/common.md#meaningful-documentation The doc lists the exact newline, tab and control mappings, states that lines are not reflowed or trimmed, and names which layer preserves empty lines.
17
+ * @evidence contracts/development/implementation.md#efficient-algorithms Each replacement is one linear scan of the caption, so the cost is O(L) time and at most two new strings of length L.
18
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work A pure string mapping coordinates no phases; its callers each normalize the one caption they hold, and caching short captions would cost more than the scan.
19
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The module retains only the compiled pattern for its lifetime; the global flag carries no state across calls because `String.prototype.replace` resets it.
20
+ */
21
+ export const canonicalizeAutoMovieCaptionText: (value: string) => string = (
22
+ value: string,
23
+ ): string =>
24
+ value.replace(/\r\n?/gu, "\n").replace(PROHIBITED_CAPTION_CONTROLS, " ");
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Escape the three characters WebVTT reads as cue-text syntax: `&`, `<` and
3
+ * `>`.
4
+ *
5
+ * Cue payloads and single-line annotations share this escape, because a caption
6
+ * that escaped one but not the other would publish markup in one field and
7
+ * literal text in the other.
8
+ *
9
+ * @evidence contracts/development/implementation.md#principled-implementation WebVTT cue text defines the character references `&amp;`, `&lt;` and `&gt;`, and escaping `&` first keeps the later replacements from being escaped twice, so the mapping is reversible.
10
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure A single shared escape is the only thing the cue-text and annotation serializers have in common, so it is its own function while their different line handling stays with each serializer.
11
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts The escaped set is the WebVTT syntax set and nothing else; no input is special-cased.
12
+ * @evidence contracts/development/common.md#meaningful-documentation The doc names the exact escaped characters and why both serializers must share the escape.
13
+ * @evidence contracts/development/implementation.md#efficient-algorithms Three `replaceAll` passes are each linear in the text length; a single-pass replacer would save at most two scans of one caption line.
14
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work A pure per-string escape coordinates no phases, so there is no completed work to share between its callers.
15
+ * @evidenceExclude contracts/development/implementation.md#bound-retention-and-release-resources The function returns a new string and keeps no state, handle or task.
16
+ */
17
+ export const escapeWebVttText: (value: string) => string = (
18
+ value: string,
19
+ ): string =>
20
+ value
21
+ .replaceAll("&", "&amp;")
22
+ .replaceAll("<", "&lt;")
23
+ .replaceAll(">", "&gt;");
@@ -0,0 +1,11 @@
1
+ export * from "./IAutoMovieBeatCaption";
2
+ export * from "./autoMovieCaptionLanguageComparisonKey";
3
+ export * from "./beatCaptions";
4
+ export * from "./canonicalProductionWebVtt";
5
+ export * from "./canonicalizeAutoMovieCaptionText";
6
+ export * from "./inspectAutoMovieCaptionReadabilityWithRuntime";
7
+ export * from "./isAutoMovieWebVttIdentifier";
8
+ export * from "./parseAutoMovieCaptionLanguage";
9
+ export * from "./serializeAutoMovieWebVttCueText";
10
+ export * from "./serializeAutoMovieWebVttIdentifier";
11
+ export * from "./serializeAutoMovieWebVttSingleLineText";