hyperframes 0.9.16 → 0.9.18

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 (237) hide show
  1. package/README.md +3 -2
  2. package/dist/{add-GEGI5ERI.js → add-R3OQEWVP.js} +12 -12
  3. package/dist/{agentPromptGenerator-VV7UQDGL.js → agentPromptGenerator-53UGASPS.js} +6 -7
  4. package/dist/{animatedGifPrep-JTPCKJ44.js → animatedGifPrep-XTZ3NW4D.js} +6 -7
  5. package/dist/api.js +29 -30
  6. package/dist/{asset-ZTXZ6HGB.js → asset-7BXTM7P4.js} +2 -2
  7. package/dist/{assetCataloger-ATGUE5IY.js → assetCataloger-B6QCN7D4.js} +7 -8
  8. package/dist/{audio-5SBZBNSP.js → audio-6QT2263V.js} +16 -17
  9. package/dist/{auth-NDUIJ4HS.js → auth-JIVRJDOA.js} +2 -2
  10. package/dist/{autoUpdate-PZTBUAA5.js → autoUpdate-PL2F3J42.js} +2 -2
  11. package/dist/{avatars-YY7FU76E.js → avatars-3BH2GOU2.js} +10 -11
  12. package/dist/{backgroundChecks-6KERI5QL.js → backgroundChecks-MVBPFASG.js} +3 -3
  13. package/dist/backgroundChecksWorker.js +3 -3
  14. package/dist/{batchRender-L3IIY2FT.js → batchRender-MRZD6NEE.js} +3 -3
  15. package/dist/{beats-UBUJBSVD.js → beats-FSTI2GOV.js} +8 -9
  16. package/dist/{benchmark-YJ2U5KE3.js → benchmark-7RQP4OKL.js} +8 -8
  17. package/dist/{billing-YN35KTEH.js → billing-ERTIEJRM.js} +11 -11
  18. package/dist/{browser-NRDSXRX7.js → browser-SHRES7YO.js} +3 -3
  19. package/dist/{bundleWithLocalizedFonts-5T25BRZU.js → bundleWithLocalizedFonts-FBN6DQG7.js} +1 -1
  20. package/dist/{capture-7K7VWXBQ.js → capture-FI236QMK.js} +13 -14
  21. package/dist/{capture-MP46JHB7.js → capture-JGEPACNE.js} +3 -3
  22. package/dist/{captureCompositionFrame-4VZCJGGD.js → captureCompositionFrame-G35BXLQV.js} +12 -13
  23. package/dist/{catalog-32CQF7IT.js → catalog-TASPLI6U.js} +12 -12
  24. package/dist/{catch-up-IVBUCPZM.js → catch-up-HGAVR2VQ.js} +4 -4
  25. package/dist/{check-U5PPKHG5.js → check-LOIL7QDO.js} +40 -41
  26. package/dist/{checkAudio-ZCRRON4E.js → checkAudio-GLG3SWWQ.js} +9 -10
  27. package/dist/{checkBrowser-MS5NKDXR.js → checkBrowser-YQETGZSL.js} +32 -33
  28. package/dist/{chunk-G4OGVFUJ.js → chunk-35STY5XW.js} +1 -1
  29. package/dist/{chunk-4FHTWYDZ.js → chunk-3ACGV3PF.js} +1 -1
  30. package/dist/{chunk-AD2T3VAJ.js → chunk-3OS2U5V2.js} +2 -2
  31. package/dist/{chunk-SE4WJJ43.js → chunk-4JI4P3J6.js} +1 -1
  32. package/dist/{chunk-5L2CII4L.js → chunk-4M42XMWZ.js} +1 -1
  33. package/dist/{chunk-S7UUJ77M.js → chunk-4WV3XDN4.js} +1 -1
  34. package/dist/{chunk-B2W2CPXF.js → chunk-53YFWZOA.js} +1 -1
  35. package/dist/{chunk-IR3JMMFT.js → chunk-56XJDA3H.js} +33 -2
  36. package/dist/{chunk-SREJU7NR.js → chunk-5IUSAGDH.js} +1 -1
  37. package/dist/{chunk-A4OX3TI6.js → chunk-5O4RH4G3.js} +1 -1
  38. package/dist/{chunk-YQ4LB3XC.js → chunk-6AFDBTX6.js} +1 -1
  39. package/dist/{chunk-TEEPLD64.js → chunk-6GJ7QJL7.js} +17 -8
  40. package/dist/{chunk-JCIPZMKD.js → chunk-6LMZ677L.js} +3 -3
  41. package/dist/{chunk-JWCMOC7O.js → chunk-6OBCXHIF.js} +1 -1
  42. package/dist/{chunk-BB5CZTGW.js → chunk-75AH7UVP.js} +1 -1
  43. package/dist/{chunk-U7MRV4RM.js → chunk-7NRTBDXX.js} +7 -7
  44. package/dist/{chunk-UXS7VE75.js → chunk-7PZLR2JZ.js} +1 -1
  45. package/dist/{chunk-J2I2LTJM.js → chunk-7WEOM6IL.js} +1 -1
  46. package/dist/{chunk-U7LBN2BQ.js → chunk-A64V7MWG.js} +7 -7
  47. package/dist/{chunk-S6AMEEGZ.js → chunk-AAEPGDLX.js} +3 -3
  48. package/dist/{chunk-TTEOPEJJ.js → chunk-AAQ32CJQ.js} +2 -2
  49. package/dist/{chunk-ZLWRAHBZ.js → chunk-AXCL2A3T.js} +10 -10
  50. package/dist/{chunk-344RFO72.js → chunk-C6GJQWRL.js} +32 -33
  51. package/dist/{chunk-VPBE4USM.js → chunk-CNCKUJSI.js} +38 -25
  52. package/dist/{chunk-Q5M3JAME.js → chunk-CQ7H3AHT.js} +13 -13
  53. package/dist/{chunk-PNZD5LZL.js → chunk-DGDTF64K.js} +47 -17
  54. package/dist/{chunk-ALQAHCK5.js → chunk-DNECYN6I.js} +1 -1
  55. package/dist/{chunk-G54QPS3F.js → chunk-DQ64M2ZV.js} +4 -4
  56. package/dist/chunk-DSSDDLGX.js +5035 -0
  57. package/dist/{chunk-R5LSL2C7.js → chunk-DUIVM4DL.js} +1 -1
  58. package/dist/{chunk-ZEOPRYFK.js → chunk-DXOAVIPV.js} +2 -2
  59. package/dist/{chunk-K2JGJUMR.js → chunk-EOIDKM7D.js} +3 -3
  60. package/dist/{chunk-LHRQP7TF.js → chunk-FDYNOOQZ.js} +5 -5
  61. package/dist/{chunk-NNXS4VBX.js → chunk-FSHSG2G5.js} +1 -1
  62. package/dist/{chunk-XS27ELRN.js → chunk-FUQPQDBA.js} +2 -2
  63. package/dist/{chunk-JPODNK2G.js → chunk-GBRXAHOL.js} +2 -2
  64. package/dist/{chunk-TNTQ7H24.js → chunk-GDQQ4U3L.js} +75 -9
  65. package/dist/{chunk-N32TVQYQ.js → chunk-GOLNW4NI.js} +2 -2
  66. package/dist/{chunk-GGSTJZQL.js → chunk-H3YLGOKX.js} +1 -1
  67. package/dist/{chunk-ZUZPIM6R.js → chunk-HEZYZUF5.js} +1 -1
  68. package/dist/{chunk-QXGT6KRX.js → chunk-HVACLBWZ.js} +25 -11
  69. package/dist/{chunk-IX5QY54Q.js → chunk-IJOCZ7ND.js} +2 -2
  70. package/dist/{chunk-L4ZMCB52.js → chunk-JALAIYCE.js} +9 -9
  71. package/dist/{chunk-YKAK4ALT.js → chunk-JQTQM6RE.js} +2 -2
  72. package/dist/{chunk-AKE744C5.js → chunk-JWORQ5WQ.js} +5 -1
  73. package/dist/{chunk-DM7WRHB5.js → chunk-K2KFYRVX.js} +1 -1
  74. package/dist/{chunk-W2BP25U5.js → chunk-K336C37N.js} +1 -1
  75. package/dist/{chunk-OIJHKOV2.js → chunk-KAUUM3TL.js} +2 -2
  76. package/dist/{chunk-PLVIN7X6.js → chunk-KWF5BWC7.js} +1 -1
  77. package/dist/{chunk-6H5KN7CJ.js → chunk-LFQLYI7R.js} +5 -5
  78. package/dist/{chunk-PWOMLJFV.js → chunk-LKT5BLRG.js} +2 -2
  79. package/dist/{chunk-XDT2DMH6.js → chunk-LPDYBJ2K.js} +2 -2
  80. package/dist/{chunk-UGYQBRHG.js → chunk-LPIHSJAU.js} +3 -3
  81. package/dist/{chunk-TABWG4IT.js → chunk-M7VAMZQW.js} +18 -11
  82. package/dist/{chunk-75PTCQAO.js → chunk-MBHKOK7C.js} +1 -1
  83. package/dist/{chunk-DV7RLE6B.js → chunk-MBZ56OAU.js} +2 -2
  84. package/dist/{chunk-M2Y245ET.js → chunk-MHSQBZQJ.js} +6 -3
  85. package/dist/{chunk-BSPE37DP.js → chunk-MQ3LHGNO.js} +2 -2
  86. package/dist/{chunk-YNAKUHSJ.js → chunk-N5U63MJG.js} +4 -4
  87. package/dist/{chunk-UK5DBUJX.js → chunk-NC7I6JJZ.js} +6 -6
  88. package/dist/{chunk-JFUXZERX.js → chunk-NTMMUK6Q.js} +113 -67
  89. package/dist/{chunk-KWORPYKW.js → chunk-NYN24QRB.js} +1 -1
  90. package/dist/chunk-ORM4MISE.js +59 -0
  91. package/dist/{chunk-OK3IQC32.js → chunk-P6QX426Y.js} +1 -1
  92. package/dist/{chunk-LOKTVSTM.js → chunk-PBKY4VTZ.js} +1 -1
  93. package/dist/{chunk-PC662ORN.js → chunk-PIPBEVLP.js} +2 -1
  94. package/dist/{chunk-5IVECOVN.js → chunk-PKUGO6D3.js} +1 -1
  95. package/dist/{chunk-4ECLIUTB.js → chunk-PPCD5YIU.js} +2 -2
  96. package/dist/{chunk-6M3TQUDF.js → chunk-PPWKGSEV.js} +2 -2
  97. package/dist/{chunk-L6X4ONBM.js → chunk-PX7EV4SO.js} +7 -7
  98. package/dist/{chunk-YFHOTWWE.js → chunk-QBV3XGXU.js} +1 -1
  99. package/dist/{chunk-SOQNCHO5.js → chunk-QT2SLY7N.js} +885 -516
  100. package/dist/{chunk-PWTWZF3F.js → chunk-QVPHMXKR.js} +1 -1
  101. package/dist/{chunk-HK4AN44J.js → chunk-QVR75TAB.js} +2 -2
  102. package/dist/{chunk-WWEFNXQI.js → chunk-T3K56YF2.js} +2 -2
  103. package/dist/{chunk-O2B3YNUH.js → chunk-T6CCPIDG.js} +3 -3
  104. package/dist/{chunk-HNZ2FZIB.js → chunk-TTCNUS5M.js} +3 -3
  105. package/dist/{chunk-6H5NILM5.js → chunk-UJOQZRIS.js} +1 -1
  106. package/dist/{chunk-65XOIIBM.js → chunk-UUZL4X3G.js} +1 -1
  107. package/dist/{chunk-AGQNRDYJ.js → chunk-VDQPHJVR.js} +1 -1
  108. package/dist/{chunk-PGM5YXBA.js → chunk-W3O7S7FC.js} +1 -1
  109. package/dist/{chunk-QCHPM3C2.js → chunk-WJBP3LIO.js} +1 -1
  110. package/dist/{chunk-LIUJRACZ.js → chunk-WPID5YHT.js} +15 -5
  111. package/dist/{chunk-ZAD422DC.js → chunk-WTOPHBYH.js} +4 -4
  112. package/dist/{chunk-BJAESOYP.js → chunk-X2TDLUIK.js} +4 -12
  113. package/dist/{chunk-72PVZ2A4.js → chunk-XJZR7MXG.js} +5 -5
  114. package/dist/{chunk-P2AOKCAC.js → chunk-Y3P26O7I.js} +3 -3
  115. package/dist/{chunk-SPJX4LQR.js → chunk-YJNI2NM7.js} +10 -10
  116. package/dist/{chunk-ZO5QD2FA.js → chunk-ZHP26FJS.js} +2 -2
  117. package/dist/{chunk-NPDBBMXX.js → chunk-ZII5GCHN.js} +1 -1
  118. package/dist/{clean-5K2KTH5M.js → clean-J6NG7RNU.js} +16 -17
  119. package/dist/cli.js +76 -68
  120. package/dist/{cloud-7O2Q7IHJ.js → cloud-LETWSUJR.js} +4 -4
  121. package/dist/{cloudrun-3HRDMWIS.js → cloudrun-RERXEEVM.js} +4 -4
  122. package/dist/commands/contrast-audit.browser.js +50 -14
  123. package/dist/commands/motion-signature.browser.js +8 -1
  124. package/dist/{compare-D22HJO5V.js → compare-ARPUHHYW.js} +29 -30
  125. package/dist/{compiler-RY6IVESI.js → compiler-DGB2I53W.js} +3 -4
  126. package/dist/{component-B7V7A5AP.js → component-2USQBQOH.js} +3 -3
  127. package/dist/{compositions-HFBRVNYW.js → compositions-X4GSF4RG.js} +11 -13
  128. package/dist/{curve-7PLN35CZ.js → curve-4OYTBAKF.js} +10 -11
  129. package/dist/{cuts-ZG7TBYVD.js → cuts-7MWGKKPB.js} +11 -12
  130. package/dist/{delete-YL4IMJJZ.js → delete-IY5EUCTR.js} +3 -3
  131. package/dist/{deploy-A6CDKFQZ.js → deploy-PEN3EL7H.js} +1 -1
  132. package/dist/{describeProject-VZCHDSWT.js → describeProject-STLWIUTD.js} +7 -8
  133. package/dist/{diff-PBVZRS5Z.js → diff-7T6PMH3C.js} +29 -30
  134. package/dist/{dist-BU547SVG.js → dist-7W5T76QK.js} +12 -2
  135. package/dist/{dist-HRK4GWLN.js → dist-K4BOTYAM.js} +9 -10
  136. package/dist/{dist-FPRADDH6.js → dist-URQMS2HM.js} +5 -4
  137. package/dist/{doctor-IFTYCM3E.js → doctor-65DXV54T.js} +10 -11
  138. package/dist/{energy-ENGAT6Z5.js → energy-BJVPUQDC.js} +11 -12
  139. package/dist/{events-AZ5XEDBE.js → events-FVEDX5PT.js} +13 -14
  140. package/dist/{events-CMAXQTDX.js → events-KLSIFOUP.js} +3 -3
  141. package/dist/{events-A6SBEKVH.js → events-MMV4IZQE.js} +2 -2
  142. package/dist/{extract-IE74J44O.js → extract-ZDOKCY4G.js} +11 -12
  143. package/dist/{face-JAPTS7VJ.js → face-SP6O3QUI.js} +11 -12
  144. package/dist/{feedback-QCFWXJCD.js → feedback-CCNOYJZG.js} +10 -7
  145. package/dist/{ffmpeg-4YMUUJP7.js → ffmpeg-2V25MA6C.js} +6 -7
  146. package/dist/{figma-C36IECKZ.js → figma-C7GSU5XD.js} +3 -3
  147. package/dist/fontLocalizeCli.js +9 -10
  148. package/dist/{frames-ZW26G4UP.js → frames-GW7MG4PX.js} +12 -13
  149. package/dist/{generate-ZXR73M22.js → generate-TBA3D3BT.js} +21 -22
  150. package/dist/{get-3KICFW3X.js → get-EUPFU4PY.js} +3 -3
  151. package/dist/{gpuPolicy-SBYZLOAU.js → gpuPolicy-7WYJ73JK.js} +6 -7
  152. package/dist/{grade-compare-DCL3OPKF.js → grade-compare-V62HD24E.js} +30 -31
  153. package/dist/{heifImagePrep-YQWEIVTC.js → heifImagePrep-K2VOQAMS.js} +7 -8
  154. package/dist/{help-PUL7OS7X.js → help-WIRMKAY5.js} +1 -1
  155. package/dist/{history-GPBKC5DE.js → history-3JEFAPPA.js} +6 -6
  156. package/dist/hyperframe.manifest.json +1 -1
  157. package/dist/hyperframe.runtime.iife.js +62 -62
  158. package/dist/hyperframes-player.global.js +3 -3
  159. package/dist/{info-7I6ZVJ64.js → info-XD7XL4UA.js} +39 -11
  160. package/dist/{init-5MCEGVHR.js → init-OCITZW56.js} +27 -28
  161. package/dist/{ink-NLYWOBTK.js → ink-RIBPCBLJ.js} +11 -12
  162. package/dist/{inspect-52COR3TB.js → inspect-O3KNTVYU.js} +30 -31
  163. package/dist/{installer-ARMP4WLF.js → installer-JC737YVC.js} +4 -4
  164. package/dist/{keyframes-3UMSTEYW.js → keyframes-4YEMPCE3.js} +6 -6
  165. package/dist/{lambda-FYHLXH4H.js → lambda-6RI6AZCI.js} +10 -11
  166. package/dist/{layout-QKWAPDPV.js → layout-U323JUYY.js} +30 -31
  167. package/dist/{lint-WJCUB2CR.js → lint-HL2ZMYYD.js} +7 -8
  168. package/dist/{lintProject-FPLCK7VP.js → lintProject-6TML32JZ.js} +1 -2
  169. package/dist/{list-4FQ4BDXW.js → list-YVRLEZ5C.js} +3 -3
  170. package/dist/{localPage-YINL6OV7.js → localPage-Z4A2OOHF.js} +6 -7
  171. package/dist/{login-P74VBTVA.js → login-Z53XVXB2.js} +4 -4
  172. package/dist/{look-QCOMYMSD.js → look-QAEW6NLB.js} +11 -12
  173. package/dist/{manager-V2ZJSF3Q.js → manager-Y5JESME2.js} +7 -8
  174. package/dist/{measure-7IODZ7VY.js → measure-QAPM6I7P.js} +11 -11
  175. package/dist/{media-treatment-UJIFSAXV.js → media-treatment-QBSD7Z4H.js} +12 -13
  176. package/dist/{media-use-4Y5XRY6B.js → media-use-HWZY3QEN.js} +3 -3
  177. package/dist/{models-WPBGJ7K6.js → models-MKZN7KP3.js} +10 -11
  178. package/dist/{motionShot-DZZXLIIT.js → motionShot-EF2FD7HF.js} +15 -16
  179. package/dist/{normalize-audio-QS2GZ5IT.js → normalize-audio-UI7VGKNU.js} +31 -12
  180. package/dist/{open-SIWIC52J.js → open-PUWUKUNK.js} +12 -12
  181. package/dist/{parakeetRunner-YUUCCA3S.js → parakeetRunner-3XQTNEZS.js} +11 -12
  182. package/dist/{pipeline-AJKIZGUM.js → pipeline-UECOYEZ2.js} +9 -10
  183. package/dist/{play-4EF3JLTU.js → play-4KFBSJLJ.js} +20 -21
  184. package/dist/{preflight-LSDOTWZ5.js → preflight-NREEVZKH.js} +7 -8
  185. package/dist/{present-AOLHT3YC.js → present-5GDW3P4H.js} +15 -16
  186. package/dist/{preview-WP5VAX3M.js → preview-MU3SNNHO.js} +19 -20
  187. package/dist/{probe-WZ3OWMKG.js → probe-ZZ5F7LF4.js} +11 -12
  188. package/dist/{producer-C72VSLBR.js → producer-AMLHR4XV.js} +1 -1
  189. package/dist/{projectConfig-LPC7WK4W.js → projectConfig-LQDSRYHS.js} +7 -7
  190. package/dist/{publication-QGBUXKB2.js → publication-VFQY5MS4.js} +2 -2
  191. package/dist/{publish-KA2LPVL7.js → publish-KFUMQFD4.js} +11 -12
  192. package/dist/{remove-background-MC6HXEAW.js → remove-background-GXQLMKYN.js} +10 -11
  193. package/dist/{render-RPMLSL7M.js → render-5YMMU4K3.js} +5 -5
  194. package/dist/{render-IQUQ7EKS.js → render-U63G4NFP.js} +25 -26
  195. package/dist/{render-2STR3XR5.js → render-X2TJ52JS.js} +32 -33
  196. package/dist/{render-batch-2AWWGFNK.js → render-batch-EJCIXNZ4.js} +5 -5
  197. package/dist/renderSetupWorker.js +5 -3
  198. package/dist/{resolver-D3Q6LTIO.js → resolver-3AZ6BDNT.js} +5 -5
  199. package/dist/{reverse-62TKSQ7Q.js → reverse-SGQLQDPZ.js} +1 -1
  200. package/dist/{run-GQNVIYMD.js → run-WZP6HXIH.js} +2 -2
  201. package/dist/{screenshotCapture-MM5V4H7M.js → screenshotCapture-YHT6OFSL.js} +7 -8
  202. package/dist/{sherpa-ZHAABYE3.js → sherpa-DHJ4KV3O.js} +10 -11
  203. package/dist/skills/hyperframes-cli/SKILL.md +3 -1
  204. package/dist/{skills-BYABSOL3.js → skills-PSIYCWQF.js} +6 -6
  205. package/dist/{skillsUpdateCheck-FKOS3ME7.js → skillsUpdateCheck-INFQ6JY4.js} +3 -3
  206. package/dist/{snapshot-N5O5VEBT.js → snapshot-BRJWWBVL.js} +70 -54
  207. package/dist/{src-272JLFKW.js → src-4HGQRHW6.js} +5 -6
  208. package/dist/{src-O6ITP7WU.js → src-Q4HPEI72.js} +8 -9
  209. package/dist/{start-K2LGEUB5.js → start-BF77FALB.js} +19 -20
  210. package/dist/{staticProjectServer-C7A4W2B4.js → staticProjectServer-MJGRVAHU.js} +18 -19
  211. package/dist/{status-USHH6OD5.js → status-GKDPASRO.js} +11 -11
  212. package/dist/studio/assets/{hyperframes-player-Bb-Fbf5k.js → hyperframes-player-pLs7eSzg.js} +1 -1
  213. package/dist/studio/assets/{index-Cap2SGKw.js → index-DZ7OLB7p.js} +1 -1
  214. package/dist/studio/assets/{index-BZuKog_A.js → index-D_iVCwL3.js} +116 -116
  215. package/dist/studio/index.html +1 -1
  216. package/dist/{studio-api-FVBB2MVZ.js → studio-api-UOW3KWGH.js} +9 -10
  217. package/dist/{studioServer-SFN7YUNV.js → studioServer-6HZXHHM2.js} +50 -51
  218. package/dist/{sync-JUDSPP46.js → sync-STGNZI3G.js} +11 -12
  219. package/dist/{telemetry-3DEZK5Q3.js → telemetry-3CL4XRJJ.js} +3 -3
  220. package/dist/{templates-3FJRJ6KB.js → templates-GK4UAT6M.js} +11 -11
  221. package/dist/{timeline-P4CS4INR.js → timeline-QPB6QGXD.js} +19 -20
  222. package/dist/{tokens-EFAVVV56.js → tokens-S7IZD453.js} +2 -2
  223. package/dist/{transcribe-JKV42B3Q.js → transcribe-LPYK5H76.js} +23 -24
  224. package/dist/{transcribe-YTBSMCFG.js → transcribe-TL74MCTG.js} +9 -10
  225. package/dist/{update-6QVOSVBW.js → update-WXPQPKMO.js} +7 -7
  226. package/dist/{updateCheck-2FWJ2X62.js → updateCheck-QRNGICLU.js} +2 -2
  227. package/dist/{upgrade-AUHNDKNP.js → upgrade-NH3NQOMG.js} +3 -3
  228. package/dist/{upload-HMRWGZIO.js → upload-YQMBLKH5.js} +3 -1
  229. package/dist/{urlDownloader-6ZSSYTOY.js → urlDownloader-JELHNEVH.js} +5 -6
  230. package/dist/{validate-DKEWYJ3V.js → validate-SRIEIBQV.js} +23 -24
  231. package/dist/{video-N6AEYBUW.js → video-ZMNAGSOC.js} +7 -8
  232. package/dist/{voices-MT7CM6O5.js → voices-YVWEHLRS.js} +19 -20
  233. package/dist/warmCheck.js +40 -41
  234. package/package.json +1 -1
  235. package/dist/chunk-CAD6G75K.js +0 -29
  236. package/dist/chunk-CZGHFATT.js +0 -31
  237. package/dist/chunk-J3G5KEPY.js +0 -5035
@@ -16,12 +16,12 @@ import {
16
16
  Semaphore,
17
17
  prepareHeifImageInputs,
18
18
  withMediaProbeSlot
19
- } from "./chunk-WWEFNXQI.js";
19
+ } from "./chunk-T3K56YF2.js";
20
20
  import {
21
21
  EncoderInterruptedError,
22
22
  encoderFailureError,
23
23
  prepareAnimatedGifInputs
24
- } from "./chunk-JPODNK2G.js";
24
+ } from "./chunk-GBRXAHOL.js";
25
25
  import {
26
26
  openRangeEnd,
27
27
  parseEncoderOptions
@@ -186,7 +186,7 @@ import {
186
186
  videoAudioId,
187
187
  videoStartOnMediaTimeline,
188
188
  writeCapturedFrame
189
- } from "./chunk-QXGT6KRX.js";
189
+ } from "./chunk-HVACLBWZ.js";
190
190
  import {
191
191
  assignBundledRuntimeCompositionIds,
192
192
  emitMountedModuleScripts,
@@ -198,7 +198,7 @@ import {
198
198
  parsesAsScript,
199
199
  prepareFlattenedInnerRoot,
200
200
  stripSdrPngColourTags
201
- } from "./chunk-TEEPLD64.js";
201
+ } from "./chunk-6GJ7QJL7.js";
202
202
  import {
203
203
  collectScratchLeftovers,
204
204
  removeScratch,
@@ -219,7 +219,7 @@ import {
219
219
  parseVfxChain,
220
220
  resolveAuthoredTimingWindow,
221
221
  toFps
222
- } from "./chunk-IR3JMMFT.js";
222
+ } from "./chunk-56XJDA3H.js";
223
223
  import {
224
224
  COMPOSITION_SOURCE_URL,
225
225
  HF_COLOR_GRADING_ATTR,
@@ -254,7 +254,7 @@ import {
254
254
  sourceTimeAt,
255
255
  styleElementsFor,
256
256
  timeAtSourceTime
257
- } from "./chunk-J3G5KEPY.js";
257
+ } from "./chunk-DSSDDLGX.js";
258
258
  import {
259
259
  TRANSITIONS,
260
260
  convertTransfer,
@@ -270,7 +270,7 @@ import {
270
270
  import {
271
271
  lintHyperframeHtml,
272
272
  resolveReferencedStart
273
- } from "./chunk-JFUXZERX.js";
273
+ } from "./chunk-NTMMUK6Q.js";
274
274
  import {
275
275
  isUnresolvedAssetPlaceholder,
276
276
  readProjectFile,
@@ -317,16 +317,16 @@ import {
317
317
  // ../producer/src/services/renderOrchestrator.ts
318
318
  import {
319
319
  existsSync as existsSync19,
320
- mkdirSync as mkdirSync8,
321
- readdirSync as readdirSync5,
322
- rmSync as rmSync8,
323
- statSync as statSync6,
320
+ mkdirSync as mkdirSync10,
321
+ readdirSync as readdirSync6,
322
+ rmSync as rmSync10,
323
+ statSync as statSync7,
324
324
  writeFileSync as writeFileSync6,
325
325
  copyFileSync as copyFileSync3,
326
326
  appendFileSync
327
327
  } from "fs";
328
328
  import { tmpdir as tmpdir2 } from "os";
329
- import { join as join26, dirname as dirname10, resolve as resolve6 } from "path";
329
+ import { join as join29, dirname as dirname11, resolve as resolve6 } from "path";
330
330
  import { totalmem as totalmem2 } from "os";
331
331
  import { randomUUID } from "crypto";
332
332
  import { fileURLToPath as fileURLToPath4 } from "url";
@@ -4024,42 +4024,47 @@ function createDrainFrameGuard(args) {
4024
4024
  sizes.push(buf.length);
4025
4025
  if (sizes.length > 60) sizes.shift();
4026
4026
  }
4027
- const truth = session.deVerifyFrames?.get(idx);
4028
- if (truth) {
4029
- let db;
4030
- try {
4031
- db = await psnrDb(buf, truth);
4032
- } catch (err) {
4033
- log.warn("[Render] drawElement self-verify sample skipped (psnr infrastructure)", {
4034
- frame: idx,
4035
- error: err instanceof Error ? err.message : String(err)
4036
- });
4037
- return buf;
4038
- }
4039
- if (db < verifyMinDb) {
4040
- const dumpDir = await mkdtemp(join9(tmpdir(), "hf-de-verify-fail-")).catch(() => null);
4041
- if (dumpDir) {
4042
- await Promise.all([
4043
- writeFile(join9(dumpDir, `frame-${idx}-de.jpg`), buf),
4044
- writeFile(join9(dumpDir, `frame-${idx}-truth.jpg`), truth)
4045
- ]).catch(() => {
4046
- });
4047
- }
4048
- throw new DrawElementVerificationError(
4049
- `drawElement self-verify failed at frame ${idx}: ${db.toFixed(1)}dB < ${verifyMinDb}dB vs pre-injection screenshot${dumpDir ? ` (pair: ${dumpDir})` : ""}`,
4050
- { kind: "psnr", frameIndex: idx, failedDb: db, verifyThresholdDb: verifyMinDb }
4051
- );
4052
- }
4053
- stats.verifyChecked += 1;
4054
- stats.verifyMinDb = stats.verifyMinDb === void 0 ? db : Math.min(stats.verifyMinDb, db);
4055
- log.info("[Render] drawElement self-verify passed", {
4056
- frame: idx,
4057
- psnrDb: db === Infinity ? "inf" : Number(db.toFixed(1))
4058
- });
4059
- }
4027
+ await verifyDrawElementSample(session, idx, buf, { log, stats, verifyMinDb });
4060
4028
  return buf;
4061
4029
  };
4062
4030
  }
4031
+ async function verifyDrawElementSample(session, idx, buf, ctx) {
4032
+ const { log, stats, verifyMinDb } = ctx;
4033
+ const truth = session.deVerifyFrames?.get(idx);
4034
+ if (!truth) return;
4035
+ let db;
4036
+ try {
4037
+ db = await psnrDb(buf, truth);
4038
+ } catch (err) {
4039
+ log.warn("[Render] drawElement self-verify sample skipped (psnr infrastructure)", {
4040
+ frame: idx,
4041
+ error: err instanceof Error ? err.message : String(err)
4042
+ });
4043
+ return;
4044
+ }
4045
+ if (db < verifyMinDb) {
4046
+ const dumpDir = await mkdtemp(join9(tmpdir(), "hf-de-verify-fail-")).catch(() => null);
4047
+ if (dumpDir) {
4048
+ await Promise.all([
4049
+ writeFile(join9(dumpDir, `frame-${idx}-de.jpg`), buf),
4050
+ writeFile(join9(dumpDir, `frame-${idx}-truth.jpg`), truth)
4051
+ ]).catch(() => {
4052
+ });
4053
+ }
4054
+ throw new DrawElementVerificationError(
4055
+ `drawElement self-verify failed at frame ${idx}: ${db.toFixed(1)}dB < ${verifyMinDb}dB vs pre-injection screenshot${dumpDir ? ` (pair: ${dumpDir})` : ""}`,
4056
+ { kind: "psnr", frameIndex: idx, failedDb: db, verifyThresholdDb: verifyMinDb }
4057
+ );
4058
+ }
4059
+ if (stats) {
4060
+ stats.verifyChecked += 1;
4061
+ stats.verifyMinDb = stats.verifyMinDb === void 0 ? db : Math.min(stats.verifyMinDb, db);
4062
+ }
4063
+ log.info("[Render] drawElement self-verify passed", {
4064
+ frame: idx,
4065
+ psnrDb: db === Infinity ? "inf" : Number(db.toFixed(1))
4066
+ });
4067
+ }
4063
4068
  async function runWorkerEncodePipelineLoop(session, totalFrames, job, currentEncoder, reorderBuffer, assertNotAborted, onProgress, log, stats, abortSignal, resume, risk) {
4064
4069
  let prev = null;
4065
4070
  const frameTime = (i) => i * job.config.fps.den / job.config.fps.num;
@@ -4523,6 +4528,7 @@ async function runCaptureStreamingStage(input) {
4523
4528
  );
4524
4529
  } else {
4525
4530
  const stallTimeoutMs = resolveCaptureStallTimeoutMs();
4531
+ const verifyMinDb = resolveDeVerifyMinDb();
4526
4532
  let lastProgressAt = Date.now();
4527
4533
  for (let i = resume.from; i < totalFrames; i++) {
4528
4534
  assertNotAborted();
@@ -4539,6 +4545,7 @@ async function runCaptureStreamingStage(input) {
4539
4545
  { session, frameIndex: i, totalFrames, stallTimeoutMs: budget },
4540
4546
  abortSignal
4541
4547
  );
4548
+ await verifyDrawElementSample(session, i, buffer, { log, verifyMinDb });
4542
4549
  await reorderBuffer.waitForFrame(i);
4543
4550
  ensureFrameWritten(await currentEncoder.writeFrame(buffer), i, currentEncoder);
4544
4551
  reorderBuffer.advanceTo(i + 1);
@@ -4647,6 +4654,10 @@ async function captureSegmentFrames(ctx, segment, encoder) {
4647
4654
  },
4648
4655
  ctx.abortSignal
4649
4656
  );
4657
+ await verifyDrawElementSample(ctx.session, i, buffer, {
4658
+ log: ctx.log,
4659
+ verifyMinDb: ctx.verifyMinDb
4660
+ });
4650
4661
  ensureFrameWritten(await encoder.writeFrame(buffer), i, encoder);
4651
4662
  ctx.job.framesRendered = i + 1;
4652
4663
  lastProgressAt = Date.now();
@@ -4661,6 +4672,25 @@ async function captureSegmentFrames(ctx, segment, encoder) {
4661
4672
  }
4662
4673
  }
4663
4674
  async function captureSegment(ctx, segment) {
4675
+ const { frames } = ctx;
4676
+ if (!frames) return captureSegmentToEncoder(ctx, segment);
4677
+ try {
4678
+ reportFrameProgress(
4679
+ ctx.job,
4680
+ `Reading video for segment ${segment.index + 1}/${ctx.segmentCount}`,
4681
+ Math.round(25 + segment.startFrame / ctx.totalFrames * 55),
4682
+ ctx.onProgress,
4683
+ segment.startFrame,
4684
+ ctx.totalFrames
4685
+ );
4686
+ await frames.prepare(segment);
4687
+ ctx.assertNotAborted();
4688
+ return await captureSegmentToEncoder(ctx, segment);
4689
+ } finally {
4690
+ frames.release();
4691
+ }
4692
+ }
4693
+ async function captureSegmentToEncoder(ctx, segment) {
4664
4694
  const segmentPath = segmentOutputPath(ctx.segmentDir, segment.index);
4665
4695
  let encoder;
4666
4696
  try {
@@ -4713,16 +4743,16 @@ var DEFAULT_DEPS = {
4713
4743
  function defaultSessionFactory(input) {
4714
4744
  let probeSession = input.probeSession;
4715
4745
  return {
4716
- create: async () => {
4746
+ create: async (injector = input.createRenderVideoFrameInjector) => {
4717
4747
  const probeCannotCaptureEveryFrame = Boolean(probeSession?.deRiskFrames?.size);
4718
4748
  if (probeSession && probeCannotCaptureEveryFrame) {
4719
4749
  await closeCaptureSession(probeSession).catch(() => {
4720
4750
  });
4721
4751
  probeSession = null;
4722
4752
  }
4723
- const session = probeSession ?? await openSegmentedSession(input);
4753
+ const session = probeSession ?? await openSegmentedSession(input, injector);
4724
4754
  if (probeSession) {
4725
- openSegmentedSessionReuse(input, probeSession);
4755
+ openSegmentedSessionReuse(input, probeSession, injector);
4726
4756
  probeSession = null;
4727
4757
  }
4728
4758
  try {
@@ -4737,12 +4767,12 @@ function defaultSessionFactory(input) {
4737
4767
  }
4738
4768
  };
4739
4769
  }
4740
- function openSegmentedSessionReuse(input, session) {
4741
- prepareCaptureSessionForReuse(session, input.framesDir, input.createRenderVideoFrameInjector());
4770
+ function openSegmentedSessionReuse(input, session, injector) {
4771
+ prepareCaptureSessionForReuse(session, input.framesDir, injector());
4742
4772
  }
4743
- async function openSegmentedSession(input) {
4773
+ async function openSegmentedSession(input, injector) {
4744
4774
  const captureCfg = input.cfg.forceScreenshot === input.plan.forceScreenshot ? input.cfg : { ...input.cfg, forceScreenshot: input.plan.forceScreenshot };
4745
- const videoInjector = input.createRenderVideoFrameInjector();
4775
+ const videoInjector = injector();
4746
4776
  const captureOptions = { ...input.buildCaptureOptions(), deFrameFallback: false };
4747
4777
  const ownBrowser = shouldDisableBrowserPoolForParallelWorker({
4748
4778
  parallel: (input.workerCount ?? 1) > 1
@@ -4755,6 +4785,19 @@ async function openSegmentedSession(input) {
4755
4785
  ownBrowser ? { ...captureCfg, enableBrowserPool: false } : captureCfg
4756
4786
  );
4757
4787
  }
4788
+ function removeJoinedSegments(run, segmentPaths) {
4789
+ if (!run.input.segmentVideoFrames || run.input.job.config.keepSegments === true) return;
4790
+ for (const path of segmentPaths) {
4791
+ try {
4792
+ run.deps.removeFile(path);
4793
+ } catch (err) {
4794
+ run.input.log.warn("[Render] could not remove a joined segment file", {
4795
+ path,
4796
+ error: err instanceof Error ? err.message : String(err)
4797
+ });
4798
+ }
4799
+ }
4800
+ }
4758
4801
  async function concatSegments(concat, segmentPaths, videoOnlyPath, abortSignal, cfg) {
4759
4802
  const result = await concat(segmentPaths, videoOnlyPath, abortSignal, cfg);
4760
4803
  if (result.success) return;
@@ -4766,12 +4809,14 @@ async function concatSegments(concat, segmentPaths, videoOnlyPath, abortSignal,
4766
4809
  async function createSegmentWorker(run, id) {
4767
4810
  const { input, deps } = run;
4768
4811
  const factory = input.sessionFactoryForWorker?.(id) ?? run.sessionFactory;
4812
+ const frames = input.segmentVideoFrames?.forWorker();
4769
4813
  return {
4770
4814
  id,
4771
4815
  factory,
4772
4816
  sessionSegments: 0,
4773
4817
  ctx: {
4774
- session: await factory.create(),
4818
+ session: await factory.create(frames && (() => frames.hook)),
4819
+ frames,
4775
4820
  job: input.job,
4776
4821
  cfg: input.cfg,
4777
4822
  totalFrames: input.totalFrames,
@@ -4782,6 +4827,8 @@ async function createSegmentWorker(run, id) {
4782
4827
  spawnEncoder: deps.spawnEncoder,
4783
4828
  captureFrame: deps.captureFrame,
4784
4829
  stallTimeoutMs: resolveCaptureStallTimeoutMs(),
4830
+ log: input.log,
4831
+ verifyMinDb: resolveDeVerifyMinDb(),
4785
4832
  abortSignal: input.abortSignal,
4786
4833
  assertNotAborted: input.assertNotAborted,
4787
4834
  onProgress: input.onProgress,
@@ -4801,7 +4848,8 @@ async function recycleWorkerSession(run, worker, why) {
4801
4848
  run.input.dedupPerfs.push(getCapturePerfSummary(worker.ctx.session));
4802
4849
  const memory = worker.ctx.session.chromeMemory?.stats();
4803
4850
  await run.deps.closeSession(worker.ctx.session);
4804
- worker.ctx.session = await worker.factory.create();
4851
+ const { frames } = worker.ctx;
4852
+ worker.ctx.session = await worker.factory.create(frames && (() => frames.hook));
4805
4853
  worker.sessionSegments = 0;
4806
4854
  if (why === "cadence") run.totals.browserRecycles += 1;
4807
4855
  run.input.log.info(`[Render] segment browser recycled (${why})`, {
@@ -4869,6 +4917,7 @@ async function concatResumedRun(run, segmentPaths) {
4869
4917
  input.abortSignal,
4870
4918
  input.cfg
4871
4919
  );
4920
+ removeJoinedSegments(run, segmentPaths);
4872
4921
  return {
4873
4922
  success: true,
4874
4923
  encodeMs: 0,
@@ -4943,6 +4992,7 @@ async function runCaptureSegmentedStage(input) {
4943
4992
  input.abortSignal,
4944
4993
  input.cfg
4945
4994
  );
4995
+ removeJoinedSegments(run, segmentPaths);
4946
4996
  return {
4947
4997
  success: true,
4948
4998
  encodeMs: run.totals.encodeMs,
@@ -5365,10 +5415,264 @@ function checkPageNeverReady(input) {
5365
5415
  return new PageNeverReadyError(error);
5366
5416
  }
5367
5417
 
5418
+ // ../producer/src/services/render/deferredVideoFrames.ts
5419
+ import { mkdirSync as mkdirSync4, rmSync as rmSync7 } from "fs";
5420
+ import { dirname as dirname5, join as join12 } from "path";
5421
+ function contiguousRuns(sortedIndexes) {
5422
+ const runs2 = [];
5423
+ for (const index of sortedIndexes) {
5424
+ const last = runs2[runs2.length - 1];
5425
+ if (last && last.firstFrame + last.frames === index) last.frames++;
5426
+ else runs2.push({ firstFrame: index, frames: 1 });
5427
+ }
5428
+ return runs2;
5429
+ }
5430
+ function shownDeferredFrameIndexes(source, frames, fps) {
5431
+ const shown = /* @__PURE__ */ new Map();
5432
+ const deferred = source.extracted.filter((video) => video.deferredRange);
5433
+ if (deferred.length === 0) return shown;
5434
+ const table = createFrameLookupTable(
5435
+ source.videos,
5436
+ deferred.map((video) => ({
5437
+ ...video,
5438
+ outputDir: "",
5439
+ framePaths: new Map(Array.from({ length: video.totalFrames }, (_, i) => [i, String(i)]))
5440
+ })),
5441
+ resolveRenderFpsConfig(fps).value
5442
+ );
5443
+ for (const frame of frames) {
5444
+ const globalTime = frame * fps.den / fps.num;
5445
+ for (const [videoId, payload] of table.getActiveFramePayloads(globalTime)) {
5446
+ const indexes = shown.get(videoId) ?? /* @__PURE__ */ new Set();
5447
+ indexes.add(payload.frameIndex);
5448
+ shown.set(videoId, indexes);
5449
+ }
5450
+ }
5451
+ return shown;
5452
+ }
5453
+ async function extractDeferredFrames(input) {
5454
+ const deferred = input.extracted.filter((video) => video.deferredRange);
5455
+ if (deferred.length === 0) return [];
5456
+ const shown = shownDeferredFrameIndexes(input, input.frames, input.fps);
5457
+ return Promise.all(
5458
+ deferred.map(async (video) => {
5459
+ const outputDir = join12(input.outputRoot, video.videoId);
5460
+ const indexes = [...shown.get(video.videoId) ?? []].sort((a, b) => a - b);
5461
+ if (indexes.length === 0) {
5462
+ return { ...video, outputDir, framePaths: /* @__PURE__ */ new Map(), ownedByLookup: false };
5463
+ }
5464
+ const range = video.deferredRange;
5465
+ const extracted = await extractVideoFramesRange(
5466
+ input.sourceOf(video),
5467
+ video.videoId,
5468
+ range.startTime,
5469
+ range.durationSeconds,
5470
+ {
5471
+ fps: input.fps,
5472
+ outputDir: input.outputRoot,
5473
+ format: range.format,
5474
+ frameRanges: contiguousRuns(indexes),
5475
+ shownBox: input.shownBoxes?.get(video.videoId)
5476
+ },
5477
+ input.signal,
5478
+ input.cfg
5479
+ );
5480
+ const missing = indexes.find((index) => !extracted.framePaths.has(index));
5481
+ if (missing !== void 0) throw input.onMissingFrame(video, missing);
5482
+ return { ...video, outputDir, framePaths: extracted.framePaths, ownedByLookup: false };
5483
+ })
5484
+ );
5485
+ }
5486
+ async function extractAllDeferredFrames(extracted, input) {
5487
+ const framesTotal = extracted.reduce(
5488
+ (sum2, video) => sum2 + (video.deferredRange ? video.totalFrames : 0),
5489
+ 0
5490
+ );
5491
+ let framesDone = 0;
5492
+ for (const video of extracted) {
5493
+ const range = video.deferredRange;
5494
+ if (!range) continue;
5495
+ const { result: filled } = await runVideoExtractionWithRetry(
5496
+ () => extractVideoFramesRange(
5497
+ input.sourceOf?.(video) ?? video.srcPath,
5498
+ video.videoId,
5499
+ range.startTime,
5500
+ range.durationSeconds,
5501
+ { fps: input.fps, outputDir: dirname5(video.outputDir), format: range.format },
5502
+ input.signal,
5503
+ input.cfg
5504
+ ),
5505
+ {
5506
+ signal: input.signal,
5507
+ maxTransientRetries: input.maxTransientRetries,
5508
+ onRetry: () => {
5509
+ rmSync7(video.outputDir, { recursive: true, force: true });
5510
+ mkdirSync4(video.outputDir, { recursive: true });
5511
+ }
5512
+ }
5513
+ );
5514
+ if (filled.framePaths.size < video.totalFrames) {
5515
+ throw new Error(
5516
+ `[Render] video ${JSON.stringify(video.videoId)} has ${filled.framePaths.size} frames; it was expected to have ${video.totalFrames} frames.`
5517
+ );
5518
+ }
5519
+ video.framePaths = filled.framePaths;
5520
+ delete video.deferredRange;
5521
+ framesDone += video.totalFrames;
5522
+ input.onProgress?.(framesDone, framesTotal);
5523
+ }
5524
+ }
5525
+
5526
+ // ../producer/src/services/render/segmentVideoFrames.ts
5527
+ import { mkdirSync as mkdirSync5, rmSync as rmSync8 } from "fs";
5528
+ import { join as join13 } from "path";
5529
+ function segmentFramesDir(rootDir, index) {
5530
+ return join13(rootDir, "segment-frames", `segment_${String(index).padStart(5, "0")}`);
5531
+ }
5532
+ function createSegmentVideoFrames(input) {
5533
+ const extractFrames = input.extractFrames ?? extractDeferredFrames;
5534
+ const sourceOf = input.sourceOf ?? ((video) => video.srcPath);
5535
+ const fullyExtracted = input.extracted.filter((video) => !video.deferredRange);
5536
+ const tableFor = async (frames, dir) => {
5537
+ const sliced = await extractFrames({
5538
+ videos: input.videos,
5539
+ extracted: input.extracted,
5540
+ frames,
5541
+ fps: input.fps,
5542
+ outputRoot: dir,
5543
+ cfg: input.cfg,
5544
+ signal: input.abortSignal,
5545
+ sourceOf,
5546
+ onMissingFrame: (video, index) => new Error(
5547
+ `[Render] video ${JSON.stringify(video.videoId)} has no frame ${index}; it was expected to have ${video.totalFrames} frames.`
5548
+ )
5549
+ });
5550
+ return createFrameLookupTable(
5551
+ input.videos,
5552
+ [...fullyExtracted, ...sliced],
5553
+ resolveRenderFpsConfig(input.fps).value
5554
+ );
5555
+ };
5556
+ const injectorFor = async (frames, dir) => createVideoFrameInjector(await tableFor(frames, dir), input.injectorOptions);
5557
+ let onDemandCalls = 0;
5558
+ const onDemandHook = () => Object.assign(
5559
+ async (page, time, heldVideoTime) => {
5560
+ const dir = join13(
5561
+ input.rootDir,
5562
+ "segment-frames",
5563
+ `on-demand_${String(onDemandCalls++).padStart(5, "0")}`
5564
+ );
5565
+ try {
5566
+ const frames = [time, heldVideoTime].filter((t) => t !== void 0).map((t) => Math.round(t * input.fps.num / input.fps.den));
5567
+ const injector = await injectorFor(frames, dir);
5568
+ await injector?.(page, time, heldVideoTime);
5569
+ } finally {
5570
+ rmSync8(dir, { recursive: true, force: true });
5571
+ }
5572
+ },
5573
+ { fresh: onDemandHook }
5574
+ );
5575
+ return {
5576
+ async forFrames(frames, name) {
5577
+ const dir = join13(input.rootDir, "segment-frames", name);
5578
+ const release = () => rmSync8(dir, { recursive: true, force: true });
5579
+ try {
5580
+ release();
5581
+ mkdirSync5(dir, { recursive: true });
5582
+ const table = await tableFor([...frames], dir);
5583
+ return { injector: () => createVideoFrameInjector(table, input.injectorOptions), release };
5584
+ } catch (error) {
5585
+ release();
5586
+ throw error;
5587
+ }
5588
+ },
5589
+ forWorker() {
5590
+ let injector = null;
5591
+ let folder = null;
5592
+ const onDemand = onDemandHook();
5593
+ const release = () => {
5594
+ injector = null;
5595
+ if (folder) rmSync8(folder, { recursive: true, force: true });
5596
+ folder = null;
5597
+ };
5598
+ return {
5599
+ hook: Object.assign(
5600
+ (page, time, heldVideoTime) => (injector ?? onDemand)(page, time, heldVideoTime),
5601
+ { fresh: onDemandHook }
5602
+ ),
5603
+ release,
5604
+ async prepare(segment) {
5605
+ release();
5606
+ const dir = segmentFramesDir(input.rootDir, segment.index);
5607
+ folder = dir;
5608
+ try {
5609
+ rmSync8(dir, { recursive: true, force: true });
5610
+ mkdirSync5(dir, { recursive: true });
5611
+ injector = await injectorFor(
5612
+ Array.from(
5613
+ { length: segment.endFrame - segment.startFrame },
5614
+ (_, i) => segment.startFrame + i
5615
+ ),
5616
+ dir
5617
+ );
5618
+ } catch (error) {
5619
+ release();
5620
+ throw error;
5621
+ }
5622
+ }
5623
+ };
5624
+ }
5625
+ };
5626
+ }
5627
+
5628
+ // ../producer/src/services/render/videoFrameWindow.ts
5629
+ import { readdirSync as readdirSync3, statSync as statSync4 } from "fs";
5630
+ import { join as join14 } from "path";
5631
+ function shouldWindowVideoFrames(args) {
5632
+ return args.segmented && args.env.HF_VIDEO_FRAME_WINDOW?.trim().toLowerCase() === "true";
5633
+ }
5634
+ function directoryBytes(path) {
5635
+ let bytes = 0;
5636
+ let entries;
5637
+ try {
5638
+ entries = readdirSync3(path, { withFileTypes: true });
5639
+ } catch {
5640
+ return 0;
5641
+ }
5642
+ for (const entry of entries) {
5643
+ const child2 = join14(path, entry.name);
5644
+ try {
5645
+ bytes += entry.isDirectory() ? directoryBytes(child2) : statSync4(child2).size;
5646
+ } catch {
5647
+ }
5648
+ }
5649
+ return bytes;
5650
+ }
5651
+ function trackSegmentFramePeak(frames, rootDir, onPeak) {
5652
+ let peak = 0;
5653
+ return {
5654
+ forFrames: (frameIndexes, name) => frames.forFrames(frameIndexes, name),
5655
+ forWorker() {
5656
+ const worker = frames.forWorker();
5657
+ return {
5658
+ ...worker,
5659
+ async prepare(segment) {
5660
+ await worker.prepare(segment);
5661
+ const held = directoryBytes(join14(rootDir, "segment-frames"));
5662
+ if (held > peak) {
5663
+ peak = held;
5664
+ onPeak(peak);
5665
+ }
5666
+ }
5667
+ };
5668
+ }
5669
+ };
5670
+ }
5671
+
5368
5672
  // ../producer/src/services/render/segmentManifest.ts
5369
5673
  import { createHash as createHash2 } from "crypto";
5370
- import { existsSync as existsSync7, mkdirSync as mkdirSync4, readFileSync as readFileSync4, statSync as statSync4, writeFileSync as writeFileSync3 } from "fs";
5371
- import { join as join12 } from "path";
5674
+ import { existsSync as existsSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync4, statSync as statSync5, writeFileSync as writeFileSync3 } from "fs";
5675
+ import { join as join15 } from "path";
5372
5676
  var MANIFEST_FILENAME = "segments.json";
5373
5677
  function computeSegmentPlanHash(input) {
5374
5678
  const ordered = [
@@ -5395,7 +5699,7 @@ function computeSegmentPlanHash(input) {
5395
5699
  return createHash2("sha256").update(ordered.join(" ")).digest("hex").slice(0, 16);
5396
5700
  }
5397
5701
  function segmentDirFor(projectRendersDir, planHash) {
5398
- return join12(projectRendersDir, ".hf-segments", planHash);
5702
+ return join15(projectRendersDir, ".hf-segments", planHash);
5399
5703
  }
5400
5704
  function hasNumber(value, key) {
5401
5705
  return key in value && typeof Reflect.get(value, key) === "number";
@@ -5413,7 +5717,7 @@ function isManifest(value) {
5413
5717
  return Reflect.get(value, "version") === 1 && hasString(value, "planHash") && hasNumber(value, "totalFrames") && hasNumber(value, "segmentFrames") && Array.isArray(completed) && completed.every(isEntry);
5414
5718
  }
5415
5719
  function readSegmentManifest(segmentDir) {
5416
- const path = join12(segmentDir, MANIFEST_FILENAME);
5720
+ const path = join15(segmentDir, MANIFEST_FILENAME);
5417
5721
  if (!existsSync7(path)) return null;
5418
5722
  try {
5419
5723
  const parsed = JSON.parse(readFileSync4(path, "utf-8"));
@@ -5423,10 +5727,10 @@ function readSegmentManifest(segmentDir) {
5423
5727
  }
5424
5728
  }
5425
5729
  function writeSegmentManifest(segmentDir, manifest) {
5426
- mkdirSync4(segmentDir, { recursive: true });
5427
- const tmp = join12(segmentDir, `${MANIFEST_FILENAME}.${process.pid}.tmp`);
5730
+ mkdirSync6(segmentDir, { recursive: true });
5731
+ const tmp = join15(segmentDir, `${MANIFEST_FILENAME}.${process.pid}.tmp`);
5428
5732
  writeFileSync3(tmp, JSON.stringify(manifest, null, 2), "utf-8");
5429
- renameWithRetry(tmp, join12(segmentDir, MANIFEST_FILENAME));
5733
+ renameWithRetry(tmp, join15(segmentDir, MANIFEST_FILENAME));
5430
5734
  }
5431
5735
  async function probeSegmentFrameCount(path, probe) {
5432
5736
  try {
@@ -5444,7 +5748,7 @@ async function validateCompletedSegments(manifest, expectedHash, probeFrames) {
5444
5748
  if (manifest.planHash !== expectedHash) return ok;
5445
5749
  for (const entry of manifest.completed) {
5446
5750
  if (!existsSync7(entry.path)) continue;
5447
- const size = statSync4(entry.path).size;
5751
+ const size = statSync5(entry.path).size;
5448
5752
  if (size <= 0 || size !== entry.bytes) continue;
5449
5753
  const frames = await probeFrames(entry.path);
5450
5754
  if (frames !== entry.endFrame - entry.startFrame) continue;
@@ -5966,7 +6270,7 @@ function computeVideoFrameCoverage(videos, extracted, fps) {
5966
6270
  for (const video of videos) {
5967
6271
  const entry = byId.get(video.id);
5968
6272
  const expectedFrames = expectedFramesForVideo(video, entry, fps);
5969
- const capturedFrames = entry ? entry.framePaths.size : 0;
6273
+ const capturedFrames = entry ? entry.deferredRange ? entry.totalFrames : entry.framePaths.size : 0;
5970
6274
  const ratio = expectedFrames === 0 ? 1 : capturedFrames / expectedFrames;
5971
6275
  reports.push({
5972
6276
  videoId: video.id,
@@ -6002,12 +6306,12 @@ function countAuthoredTimedClips(html) {
6002
6306
 
6003
6307
  // ../producer/src/services/render/stages/compileStage.ts
6004
6308
  import { existsSync as existsSync10, writeFileSync as writeFileSync4 } from "fs";
6005
- import { join as join14 } from "path";
6309
+ import { join as join17 } from "path";
6006
6310
 
6007
6311
  // ../producer/src/services/htmlCompiler.ts
6008
6312
  import { createHash as createHash4 } from "crypto";
6009
- import { createReadStream as createReadStream2, existsSync as existsSync9, mkdirSync as mkdirSync5, readFileSync as readFileSync5 } from "fs";
6010
- import { join as join13, dirname as dirname5, resolve as resolve5, basename as basename4, relative as relative2 } from "path";
6313
+ import { createReadStream as createReadStream2, existsSync as existsSync9, mkdirSync as mkdirSync7, readFileSync as readFileSync5 } from "fs";
6314
+ import { join as join16, dirname as dirname6, resolve as resolve5, basename as basename4, relative as relative2 } from "path";
6011
6315
 
6012
6316
  // ../producer/src/services/renderMediaCollector.ts
6013
6317
  function resolveHostEnd(host, hostStart) {
@@ -6463,8 +6767,8 @@ function detectShaderTransitionUsage(html) {
6463
6767
  async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, downloadDir, tagName, elementIdentity, log, urlByAbsentLocalPath, probes) {
6464
6768
  let filePath = src;
6465
6769
  if (isHttpUrl(src)) {
6466
- const remoteDir = join13(downloadDir, REMOTE_MEDIA_SUBDIR);
6467
- if (!existsSync9(remoteDir)) mkdirSync5(remoteDir, { recursive: true });
6770
+ const remoteDir = join16(downloadDir, REMOTE_MEDIA_SUBDIR);
6771
+ if (!existsSync9(remoteDir)) mkdirSync7(remoteDir, { recursive: true });
6468
6772
  try {
6469
6773
  filePath = await downloadToTemp(src, remoteDir, void 0, void 0, void 0, {
6470
6774
  onTelemetry: logRemoteDownloadTelemetry
@@ -6474,7 +6778,7 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, down
6474
6778
  }
6475
6779
  } else {
6476
6780
  filePath = decodedUrlPath(src);
6477
- if (!filePath.startsWith("/")) filePath = join13(baseDir, filePath);
6781
+ if (!filePath.startsWith("/")) filePath = join16(baseDir, filePath);
6478
6782
  filePath = urlByAbsentLocalPath?.get(filePath) ?? filePath;
6479
6783
  }
6480
6784
  if (!isHttpUrl(filePath) && !existsSync9(filePath)) {
@@ -6635,7 +6939,7 @@ async function parseSubCompositions(html, projectDir, downloadDir, visited = /*
6635
6939
  workItems.map(async (item) => {
6636
6940
  const { html: compiledSub } = await compileHtmlFile(
6637
6941
  rewriteUnresolvableGsapToCdn(item.rawSubHtml, projectDir, item.srcPath),
6638
- dirname5(item.filePath),
6942
+ dirname6(item.filePath),
6639
6943
  downloadDir,
6640
6944
  void 0,
6641
6945
  urlByAbsentLocalPath,
@@ -7065,7 +7369,7 @@ var REMOTE_SOURCE_TAG_RE = /<source\b[^>]*?\bsrc\s*=\s*["'](https?:\/\/[^"']+)["
7065
7369
  var REMOTE_IMG_TAG_RE = /<img\b[^>]*?(?<![\w-])src\s*=\s*["'](https?:\/\/[^"']+)["'][^>]*>/gi;
7066
7370
  async function downloadAndRewriteUrls(urlSet, html, remoteDir, warnLabel, logLabel, extraRewrite) {
7067
7371
  if (urlSet.size === 0) return { html, remoteMediaAssets: /* @__PURE__ */ new Map() };
7068
- if (!existsSync9(remoteDir)) mkdirSync5(remoteDir, { recursive: true });
7372
+ if (!existsSync9(remoteDir)) mkdirSync7(remoteDir, { recursive: true });
7069
7373
  const urlToLocal = /* @__PURE__ */ new Map();
7070
7374
  await Promise.all(
7071
7375
  [...urlSet].map(async (url) => {
@@ -7112,7 +7416,7 @@ async function localizeRemoteMediaSources(html, downloadDir) {
7112
7416
  return downloadAndRewriteUrls(
7113
7417
  urlSet,
7114
7418
  html,
7115
- join13(downloadDir, REMOTE_MEDIA_SUBDIR),
7419
+ join16(downloadDir, REMOTE_MEDIA_SUBDIR),
7116
7420
  "Remote media download failed",
7117
7421
  "Localized remote media source(s)"
7118
7422
  );
@@ -7127,7 +7431,7 @@ async function localizeRemoteImageSources(html, downloadDir) {
7127
7431
  return downloadAndRewriteUrls(
7128
7432
  urlSet,
7129
7433
  html,
7130
- join13(downloadDir, REMOTE_MEDIA_SUBDIR),
7434
+ join16(downloadDir, REMOTE_MEDIA_SUBDIR),
7131
7435
  "Remote image download failed",
7132
7436
  "Localized remote image source(s)"
7133
7437
  );
@@ -7143,7 +7447,7 @@ async function localizeRemoteBackgroundImages(html, downloadDir) {
7143
7447
  return downloadAndRewriteUrls(
7144
7448
  urlSet,
7145
7449
  html,
7146
- join13(downloadDir, REMOTE_MEDIA_SUBDIR),
7450
+ join16(downloadDir, REMOTE_MEDIA_SUBDIR),
7147
7451
  "Remote background-image download failed",
7148
7452
  "Localized remote background-image(s)",
7149
7453
  // Quoted url('..')/url("..") are rewritten by downloadAndRewriteUrls' default
@@ -7253,7 +7557,7 @@ function projectStylesheetFontFamilies(html, projectDir) {
7253
7557
  const family = /font-family\s*:\s*([^;}]+)/i.exec(face)?.[1]?.trim().replace(/^['"]|['"]$/g, "");
7254
7558
  const shipsFile = [...face.matchAll(LOCAL_FONTFACE_URL_RE)].some(([, url = ""]) => {
7255
7559
  const path = decodedUrlPath(url);
7256
- const file = path.startsWith("/") ? resolve5(projectDir, `.${path}`) : resolve5(dirname5(sheet), path);
7560
+ const file = path.startsWith("/") ? resolve5(projectDir, `.${path}`) : resolve5(dirname6(sheet), path);
7257
7561
  return isPathInside2(file, projectDir) && existsSync9(file);
7258
7562
  });
7259
7563
  if (family && shipsFile) families.push(family);
@@ -7298,7 +7602,7 @@ function localizeFontFaceUrls(html, downloadDir) {
7298
7602
  return downloadAndRewriteUrls(
7299
7603
  collectFontFaceUrls(html),
7300
7604
  html,
7301
- join13(downloadDir, REMOTE_MEDIA_SUBDIR),
7605
+ join16(downloadDir, REMOTE_MEDIA_SUBDIR),
7302
7606
  "Remote font download failed",
7303
7607
  "Localized remote font face(s)",
7304
7608
  (h, url, relPath) => h.replaceAll(`url(${url})`, `url("${relPath}")`)
@@ -7972,10 +8276,10 @@ function adaptAspectAgnosticResolution(requested, aspectAgnostic, width, height,
7972
8276
  }
7973
8277
  function resolveEntryHtmlPath(input) {
7974
8278
  const { projectDir, workDir, entryFile, log } = input;
7975
- const htmlPath = join14(projectDir, entryFile);
8279
+ const htmlPath = join17(projectDir, entryFile);
7976
8280
  const rawEntry = readTextFile(htmlPath);
7977
8281
  if (entryFile === "index.html" || !isTemplateEntry(rawEntry)) return htmlPath;
7978
- const projectIndexPath = join14(projectDir, "index.html");
8282
+ const projectIndexPath = join17(projectDir, "index.html");
7979
8283
  if (!existsSync10(projectIndexPath)) {
7980
8284
  throw new Error(
7981
8285
  `Template entry file "${entryFile}" requires a project index.html to extract its render shell.`
@@ -7991,7 +8295,7 @@ function resolveEntryHtmlPath(input) {
7991
8295
  `Entry file "${entryFile}" is not mounted from index.html via data-composition-src, so it cannot be rendered independently.`
7992
8296
  );
7993
8297
  }
7994
- const wrapperPath = join14(workDir, "standalone-entry.html");
8298
+ const wrapperPath = join17(workDir, "standalone-entry.html");
7995
8299
  writeFileSync4(wrapperPath, standaloneHtml, "utf-8");
7996
8300
  log.info("Extracted standalone entry from index.html host context", { entryFile });
7997
8301
  return wrapperPath;
@@ -8012,7 +8316,7 @@ async function runCompileStage(input) {
8012
8316
  } = input;
8013
8317
  const htmlPath = resolveEntryHtmlPath({ projectDir, workDir, entryFile, log });
8014
8318
  const compileStart = Date.now();
8015
- const compiled = await compileForRender(projectDir, htmlPath, join14(workDir, "downloads"), {
8319
+ const compiled = await compileForRender(projectDir, htmlPath, join17(workDir, "downloads"), {
8016
8320
  log,
8017
8321
  failClosedFontFetch: failClosedFontFetch === true,
8018
8322
  allowSystemFontCapture,
@@ -8020,7 +8324,7 @@ async function runCompileStage(input) {
8020
8324
  variables: input.variables,
8021
8325
  urlByAbsentLocalPath: input.urlByAbsentLocalPath,
8022
8326
  pageMotionBlur: input.pageMotionBlur,
8023
- animatedGifCacheDir: cfg.extractCacheDir ? join14(cfg.extractCacheDir, "animated-gif") : void 0,
8327
+ animatedGifCacheDir: cfg.extractCacheDir ? join17(cfg.extractCacheDir, "animated-gif") : void 0,
8024
8328
  ffmpegProcessTimeout: cfg.ffmpegProcessTimeout
8025
8329
  });
8026
8330
  assertNotAborted();
@@ -8077,7 +8381,7 @@ async function runCompileStage(input) {
8077
8381
  };
8078
8382
  await preflightCompositionAssetMediaTypes({
8079
8383
  projectDir,
8080
- compiledDir: join14(workDir, "compiled"),
8384
+ compiledDir: join17(workDir, "compiled"),
8081
8385
  composition,
8082
8386
  signal: abortSignal
8083
8387
  });
@@ -8123,7 +8427,7 @@ async function runCompileStage(input) {
8123
8427
 
8124
8428
  // ../producer/src/services/render/stages/probeStage.ts
8125
8429
  import { createHash as createHash5 } from "crypto";
8126
- import { basename as basename5, join as join15 } from "path";
8430
+ import { basename as basename5, join as join18 } from "path";
8127
8431
 
8128
8432
  // ../producer/src/services/render/stages/probeFailures.ts
8129
8433
  var NETWORK_FAILURE_PATTERN = /404|ERR_NAME_NOT_RESOLVED|ERR_CONNECTION_REFUSED|net::ERR_/i;
@@ -8308,7 +8612,7 @@ async function runProbeStage(input) {
8308
8612
  });
8309
8613
  fileServer = await createFileServer({
8310
8614
  projectDir,
8311
- compiledDir: join15(workDir, "compiled"),
8615
+ compiledDir: join18(workDir, "compiled"),
8312
8616
  port: 0,
8313
8617
  preHeadScripts: [VIRTUAL_TIME_SHIM],
8314
8618
  fps: job.config.fps
@@ -8338,7 +8642,7 @@ async function runProbeStage(input) {
8338
8642
  log.info("Creating capture session...", { attempt, maxAttempts: PROBE_MAX_ATTEMPTS });
8339
8643
  probeSession = await createCaptureSession(
8340
8644
  fileServer.url,
8341
- join15(workDir, "probe"),
8645
+ join18(workDir, "probe"),
8342
8646
  captureOpts,
8343
8647
  null,
8344
8648
  probeCfg
@@ -8423,7 +8727,7 @@ async function runProbeStage(input) {
8423
8727
  });
8424
8728
  probeSession = await createCaptureSession(
8425
8729
  fileServer.url,
8426
- join15(workDir, "probe-screenshot"),
8730
+ join18(workDir, "probe-screenshot"),
8427
8731
  captureOpts,
8428
8732
  null,
8429
8733
  { ...probeCfg, forceScreenshot: true }
@@ -8461,7 +8765,7 @@ async function runProbeStage(input) {
8461
8765
  compiled,
8462
8766
  resolutions,
8463
8767
  projectDir,
8464
- join15(workDir, "downloads")
8768
+ join18(workDir, "downloads")
8465
8769
  );
8466
8770
  assertNotAborted();
8467
8771
  composition.videos = compiled.videos;
@@ -8652,7 +8956,7 @@ async function runProbeStage(input) {
8652
8956
  }
8653
8957
  await preflightCompositionAssetMediaTypes({
8654
8958
  projectDir,
8655
- compiledDir: join15(workDir, "compiled"),
8959
+ compiledDir: join18(workDir, "compiled"),
8656
8960
  composition,
8657
8961
  signal: abortSignal
8658
8962
  });
@@ -8810,7 +9114,7 @@ function validateDistributedDuration(input) {
8810
9114
 
8811
9115
  // ../producer/src/services/render/stages/extractVideosStage.ts
8812
9116
  import { existsSync as existsSync11 } from "fs";
8813
- import { join as join16 } from "path";
9117
+ import { join as join19 } from "path";
8814
9118
 
8815
9119
  // ../producer/src/services/render/extractionFailureMetadata.ts
8816
9120
  function stringOrEmpty(value) {
@@ -9138,14 +9442,14 @@ async function runExtractVideosStage(input) {
9138
9442
  // because short boundary counts can differ by one frame.
9139
9443
  {
9140
9444
  fps: job.config.fps,
9141
- outputDir: join16(compiledDir, "__hyperframes_video_frames"),
9445
+ outputDir: join19(compiledDir, "__hyperframes_video_frames"),
9142
9446
  format: job.config.videoFrameFormat ?? "auto",
9143
9447
  toneMapHdrToSdr: rendersSdrOnly(job.config, composition),
9144
9448
  timelineEnd: composition.duration,
9145
9449
  maxTransientRetries: extractionPolicy.maxTransientRetries,
9146
9450
  collectProbeFailures: extractionPolicy.failureMode === "enforce",
9147
9451
  deferRangeExtraction,
9148
- contentKeyedDirs: [join16(compiledDir, REMOTE_MEDIA_SUBDIR)],
9452
+ contentKeyedDirs: [join19(compiledDir, REMOTE_MEDIA_SUBDIR)],
9149
9453
  urlByAbsentLocalPath,
9150
9454
  onProgress: ({ planned = 0, done = 0 }) => {
9151
9455
  framesPlanned += planned;
@@ -9322,16 +9626,16 @@ async function planVideoLayerPassthrough(input) {
9322
9626
 
9323
9627
  // ../producer/src/services/render/stages/audioStage.ts
9324
9628
  import { existsSync as existsSync14 } from "fs";
9325
- import { join as join19 } from "path";
9629
+ import { join as join22 } from "path";
9326
9630
 
9327
9631
  // ../producer/src/services/render/audioDeliveryLimit.ts
9328
9632
  import { existsSync as existsSync13 } from "fs";
9329
- import { dirname as dirname7, join as join18 } from "path";
9633
+ import { dirname as dirname8, join as join21 } from "path";
9330
9634
 
9331
9635
  // ../producer/src/services/render/audioPadTrim.ts
9332
9636
  import { spawn } from "child_process";
9333
9637
  import { mkdtempSync as mkdtempSync3 } from "fs";
9334
- import { dirname as dirname6, join as join17 } from "path";
9638
+ import { dirname as dirname7, join as join20 } from "path";
9335
9639
 
9336
9640
  // ../producer/src/services/render/audioTruePeak.ts
9337
9641
  var toDbfs = (token) => token.toLowerCase() === "-inf" ? Number.NEGATIVE_INFINITY : Number(token);
@@ -9591,7 +9895,7 @@ async function constrainAacTruePeak(input) {
9591
9895
  }
9592
9896
  async function cutSource(input, scratchDir, attenuationDb) {
9593
9897
  if (!input.sourcePath || !input.rewriteSource) return true;
9594
- const cutPath = join17(scratchDir, "source.wav");
9898
+ const cutPath = join20(scratchDir, "source.wav");
9595
9899
  try {
9596
9900
  const result = await input.rewriteSource(input.sourcePath, cutPath, gainFilter(attenuationDb));
9597
9901
  if (!result.success) throw new Error(result.error);
@@ -9605,8 +9909,8 @@ async function cutSource(input, scratchDir, attenuationDb) {
9605
9909
  async function enforceAacTruePeak(input) {
9606
9910
  let scratchDir;
9607
9911
  try {
9608
- scratchDir = mkdtempSync3(join17(dirname6(input.audioPath), ".true-peak-"));
9609
- const correctedPath = join17(scratchDir, "audio.m4a");
9912
+ scratchDir = mkdtempSync3(join20(dirname7(input.audioPath), ".true-peak-"));
9913
+ const correctedPath = join20(scratchDir, "audio.m4a");
9610
9914
  const measurements = [];
9611
9915
  let attenuationDb = 0;
9612
9916
  let sourcePeakDbfs;
@@ -9797,11 +10101,13 @@ async function runFfprobeJson(args, signal) {
9797
10101
  }
9798
10102
 
9799
10103
  // ../producer/src/services/render/audioDeliveryLimit.ts
9800
- var LIMIT_CEILING_DBTP = AAC_DELIVERY_TRUE_PEAK_DBFS - 2;
9801
- var LIMIT_CHAIN = {
10104
+ var LIMIT_PASSES = 3;
10105
+ var LOWEST_CEILING_DBTP = AAC_DELIVERY_TRUE_PEAK_DBFS - 2;
10106
+ var PASS_HEADROOM_DB = 0.05;
10107
+ var limitChain = (ceiling) => ({
9802
10108
  version: 1,
9803
- nodes: [{ type: "truepeak", id: "delivery", params: { ceiling: LIMIT_CEILING_DBTP } }]
9804
- };
10109
+ nodes: [{ type: "truepeak", id: "delivery", params: { ceiling } }]
10110
+ });
9805
10111
  async function limitDeliveryPeaks(input, deps = {
9806
10112
  measure: measureTruePeakDbfs,
9807
10113
  applyChain: applyAudioFxChain,
@@ -9813,15 +10119,39 @@ async function limitDeliveryPeaks(input, deps = {
9813
10119
  if (!deps.sourceExists(sourcePath)) return { success: true };
9814
10120
  const peak = await deps.measure(audioPath, { timeoutMs, signal });
9815
10121
  if (peak <= AAC_DELIVERY_TRUE_PEAK_DBFS) return { success: true };
9816
- const limitedPath = join18(dirname7(sourcePath), "audio-source-limited.wav");
10122
+ const alternating = ["a", "b"].map(
10123
+ (k) => join21(dirname8(sourcePath), `audio-source-limited-${k}.wav`)
10124
+ );
10125
+ let encodedFrom;
10126
+ let ceiling = AAC_DELIVERY_TRUE_PEAK_DBFS;
10127
+ for (let pass = 0; pass < LIMIT_PASSES; pass++) {
10128
+ const limitedPath = alternating[pass % 2];
10129
+ const result = await limitPass(input, deps, ceiling, limitedPath);
10130
+ if ("encodeFailure" in result) return result.encodeFailure;
10131
+ if ("limitFailed" in result) break;
10132
+ encodedFrom = limitedPath;
10133
+ if (result.peak <= AAC_DELIVERY_TRUE_PEAK_DBFS || ceiling <= LOWEST_CEILING_DBTP) break;
10134
+ ceiling = Math.max(
10135
+ ceiling - (result.peak - AAC_DELIVERY_TRUE_PEAK_DBFS) - PASS_HEADROOM_DB,
10136
+ LOWEST_CEILING_DBTP
10137
+ );
10138
+ }
10139
+ if (encodedFrom) deps.rename(encodedFrom, sourcePath, { copyFallback: true });
10140
+ return { success: true };
10141
+ }
10142
+ async function limitPass(input, deps, ceiling, limitedPath) {
10143
+ const { audioPath, sourcePath, signal, timeoutMs } = input;
9817
10144
  try {
9818
- await deps.applyChain(sourcePath, LIMIT_CHAIN, limitedPath, { trackId: "delivery", signal });
10145
+ await deps.applyChain(sourcePath, limitChain(ceiling), limitedPath, {
10146
+ trackId: "delivery",
10147
+ signal
10148
+ });
9819
10149
  } catch (error) {
9820
10150
  if (signal?.aborted) throw error;
9821
10151
  input.warn?.("[audio] true-peak limit failed, the whole-mix cut applies", {
9822
10152
  error: error instanceof Error ? error.message : String(error)
9823
10153
  });
9824
- return { success: true };
10154
+ return { limitFailed: true };
9825
10155
  }
9826
10156
  const encoded = await deps.encode(limitedPath, audioPath, input.targetDurationSeconds, {
9827
10157
  signal,
@@ -9829,13 +10159,14 @@ async function limitDeliveryPeaks(input, deps = {
9829
10159
  });
9830
10160
  if (!encoded.success) {
9831
10161
  return {
9832
- success: false,
9833
- error: `[audioDeliveryLimit] ${describeFfmpegFailure(encoded, timeoutMs)}`,
9834
- failureReason: encoded.failureReason
10162
+ encodeFailure: {
10163
+ success: false,
10164
+ error: `[audioDeliveryLimit] ${describeFfmpegFailure(encoded, timeoutMs)}`,
10165
+ failureReason: encoded.failureReason
10166
+ }
9835
10167
  };
9836
10168
  }
9837
- deps.rename(limitedPath, sourcePath, { copyFallback: true });
9838
- return { success: true };
10169
+ return { peak: await deps.measure(audioPath, { timeoutMs, signal }) };
9839
10170
  }
9840
10171
 
9841
10172
  // ../producer/src/services/render/stages/audioStage.ts
@@ -9861,7 +10192,7 @@ function runAudioStage(input) {
9861
10192
  }
9862
10193
  async function runAudioStageScoped(input) {
9863
10194
  const stageStart = Date.now();
9864
- const pcmSourcePath = join19(input.workDir, "audio-source.wav");
10195
+ const pcmSourcePath = join22(input.workDir, "audio-source.wav");
9865
10196
  const duration = input.totalFrames * input.fps.den / input.fps.num;
9866
10197
  let deliverySourcePath;
9867
10198
  try {
@@ -9926,7 +10257,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
9926
10257
  assertNotAborted,
9927
10258
  log
9928
10259
  } = input;
9929
- const audioOutputPath = join19(workDir, MIXED_AUDIO_FILENAME);
10260
+ const audioOutputPath = join22(workDir, MIXED_AUDIO_FILENAME);
9930
10261
  let hasAudio = false;
9931
10262
  let audioError;
9932
10263
  let audioFailures;
@@ -9937,7 +10268,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
9937
10268
  audioResult = await processCompositionAudio(
9938
10269
  audios,
9939
10270
  projectDir,
9940
- join19(workDir, "audio-work"),
10271
+ join22(workDir, "audio-work"),
9941
10272
  audioOutputPath,
9942
10273
  duration,
9943
10274
  abortSignal,
@@ -10005,8 +10336,8 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
10005
10336
  }
10006
10337
 
10007
10338
  // ../producer/src/services/render/stages/captureStage.ts
10008
- import { existsSync as existsSync15, readdirSync as readdirSync3, statfsSync as statfsSync2 } from "fs";
10009
- import { join as join20 } from "path";
10339
+ import { existsSync as existsSync15, readdirSync as readdirSync4, statfsSync as statfsSync2 } from "fs";
10340
+ import { join as join23 } from "path";
10010
10341
  function shouldAllowAdaptiveCaptureRetry(workerCount, _explicitlyConfigured) {
10011
10342
  return workerCount > 1;
10012
10343
  }
@@ -10063,15 +10394,15 @@ function diskCaptureShortfallError(needBytes, freeBytes, framesDir, basis, remed
10063
10394
  function measureCaptureFrameBytes(workDir, framesDir) {
10064
10395
  let total = sampleDirectoryBytes(framesDir);
10065
10396
  if (!existsSync15(workDir)) return total;
10066
- for (const attempt of readdirSync3(workDir)) {
10397
+ for (const attempt of readdirSync4(workDir)) {
10067
10398
  if (/^retry-\d+-batch-\d+-worker-\d+$/.test(attempt)) {
10068
- total += sampleDirectoryBytes(join20(workDir, attempt));
10399
+ total += sampleDirectoryBytes(join23(workDir, attempt));
10069
10400
  continue;
10070
10401
  }
10071
10402
  if (!/^capture-attempt-\d+$/.test(attempt)) continue;
10072
- const attemptDir = join20(workDir, attempt);
10073
- for (const name of readdirSync3(attemptDir)) {
10074
- if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(join20(attemptDir, name));
10403
+ const attemptDir = join23(workDir, attempt);
10404
+ for (const name of readdirSync4(attemptDir)) {
10405
+ if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(join23(attemptDir, name));
10075
10406
  }
10076
10407
  }
10077
10408
  return total;
@@ -10365,8 +10696,8 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
10365
10696
  }
10366
10697
 
10367
10698
  // ../producer/src/services/render/stages/captureHdrStage.ts
10368
- import { existsSync as existsSync17, mkdirSync as mkdirSync6 } from "fs";
10369
- import { join as join24 } from "path";
10699
+ import { existsSync as existsSync17, mkdirSync as mkdirSync8 } from "fs";
10700
+ import { join as join27 } from "path";
10370
10701
 
10371
10702
  // ../producer/src/services/hdrImageTransferCache.ts
10372
10703
  var DEFAULT_MAX_BYTES = 200 * 1024 * 1024;
@@ -10428,7 +10759,7 @@ function createHdrImageTransferCache(options = {}) {
10428
10759
  }
10429
10760
 
10430
10761
  // ../producer/src/services/render/stages/captureHdrSequentialLoop.ts
10431
- import { join as join21 } from "path";
10762
+ import { join as join24 } from "path";
10432
10763
  async function runSequentialLayeredFrameLoop(input) {
10433
10764
  const {
10434
10765
  job,
@@ -10549,7 +10880,7 @@ async function runSequentialLayeredFrameLoop(input) {
10549
10880
  );
10550
10881
  if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
10551
10882
  writeFileExclusiveSync(
10552
- join21(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
10883
+ join24(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
10553
10884
  normalCanvas
10554
10885
  );
10555
10886
  }
@@ -10581,12 +10912,12 @@ async function runSequentialLayeredFrameLoop(input) {
10581
10912
  }
10582
10913
 
10583
10914
  // ../producer/src/services/render/stages/captureHdrHybridLoop.ts
10584
- import { join as join23 } from "path";
10915
+ import { join as join26 } from "path";
10585
10916
 
10586
10917
  // ../producer/src/services/shaderTransitionWorkerPool.ts
10587
10918
  import { Worker } from "worker_threads";
10588
10919
  import { fileURLToPath as fileURLToPath3, pathToFileURL } from "url";
10589
- import { dirname as dirname8, join as join22 } from "path";
10920
+ import { dirname as dirname9, join as join25 } from "path";
10590
10921
  import { createRequire } from "module";
10591
10922
  import { existsSync as existsSync16 } from "fs";
10592
10923
  import { cpus as cpus2 } from "os";
@@ -10599,10 +10930,10 @@ function resolveWorkerEntry(explicit) {
10599
10930
  const isTs = override.endsWith(".ts");
10600
10931
  return { path: override, isTs };
10601
10932
  }
10602
- const moduleDir = dirname8(fileURLToPath3(import.meta.url));
10603
- const jsPath = join22(moduleDir, "shaderTransitionWorker.js");
10933
+ const moduleDir = dirname9(fileURLToPath3(import.meta.url));
10934
+ const jsPath = join25(moduleDir, "shaderTransitionWorker.js");
10604
10935
  if (existsSync16(jsPath)) return { path: jsPath, isTs: false };
10605
- const tsPath = join22(moduleDir, "shaderTransitionWorker.ts");
10936
+ const tsPath = join25(moduleDir, "shaderTransitionWorker.ts");
10606
10937
  return { path: tsPath, isTs: true };
10607
10938
  }
10608
10939
  function buildExecArgv(entryIsTs) {
@@ -10970,7 +11301,7 @@ async function runHybridLayeredFrameLoop(input) {
10970
11301
  );
10971
11302
  if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
10972
11303
  writeFileExclusiveSync(
10973
- join23(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
11304
+ join26(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
10974
11305
  canvas
10975
11306
  );
10976
11307
  }
@@ -11161,9 +11492,9 @@ async function runCaptureHdrStage(input) {
11161
11492
  if (hdrVideoFrameSources.has(v.id)) hdrVideoEndTimes.set(v.id, v.end);
11162
11493
  }
11163
11494
  const debugDumpEnabled = process.env.KEEP_TEMP === "1";
11164
- const debugDumpDir = debugDumpEnabled ? join24(framesDir, "debug-composite") : null;
11495
+ const debugDumpDir = debugDumpEnabled ? join27(framesDir, "debug-composite") : null;
11165
11496
  if (debugDumpDir && !existsSync17(debugDumpDir)) {
11166
- mkdirSync6(debugDumpDir, { recursive: true });
11497
+ mkdirSync8(debugDumpDir, { recursive: true });
11167
11498
  }
11168
11499
  const compositeTransfer = resolveCompositeTransfer(hasHdrContent, effectiveHdr);
11169
11500
  const hdrTargetTransfer = compositeTransfer === "srgb" ? void 0 : compositeTransfer;
@@ -11320,15 +11651,15 @@ async function runCaptureHdrStage(input) {
11320
11651
  import {
11321
11652
  copyFileSync as copyFileSync2,
11322
11653
  existsSync as existsSync18,
11323
- mkdirSync as mkdirSync7,
11324
- readdirSync as readdirSync4,
11654
+ mkdirSync as mkdirSync9,
11655
+ readdirSync as readdirSync5,
11325
11656
  readFileSync as readFileSync6,
11326
- rmSync as rmSync7,
11327
- statSync as statSync5,
11657
+ rmSync as rmSync9,
11658
+ statSync as statSync6,
11328
11659
  writeFileSync as writeFileSync5
11329
11660
  } from "fs";
11330
11661
  import { readFile as readFile2 } from "fs/promises";
11331
- import { dirname as dirname9, join as join25 } from "path";
11662
+ import { dirname as dirname10, join as join28 } from "path";
11332
11663
 
11333
11664
  // ../producer/src/services/render/stages/gifEncodeArgs.ts
11334
11665
  function fpsToFfmpegArg2(fps) {
@@ -11411,7 +11742,7 @@ async function reencodeWithClearedWholeFrames(argsInput, run, startTime) {
11411
11742
  }
11412
11743
  async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
11413
11744
  const startTime = Date.now();
11414
- const files = readdirSync4(framesDir).filter((file) => file.match(/\.(jpg|jpeg|png)$/i));
11745
+ const files = readdirSync5(framesDir).filter((file) => file.match(/\.(jpg|jpeg|png)$/i));
11415
11746
  const frameCount = files.length;
11416
11747
  if (frameCount === 0) {
11417
11748
  return gifEncodeFailure(startTime, outputPath, "[FFmpeg] No frame files found in directory");
@@ -11438,7 +11769,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
11438
11769
  const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
11439
11770
  if (failure) return failure;
11440
11771
  }
11441
- const fileSize = existsSync18(outputPath) ? statSync5(outputPath).size : 0;
11772
+ const fileSize = existsSync18(outputPath) ? statSync6(outputPath).size : 0;
11442
11773
  return {
11443
11774
  success: true,
11444
11775
  outputPath,
@@ -11447,7 +11778,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
11447
11778
  fileSize
11448
11779
  };
11449
11780
  } finally {
11450
- rmSync7(input.palettePath, { force: true });
11781
+ rmSync9(input.palettePath, { force: true });
11451
11782
  }
11452
11783
  }
11453
11784
  function startEncodeProgress(job, stage, onProgress) {
@@ -11524,7 +11855,7 @@ function encodeWhileCapturing(input, totalFrames) {
11524
11855
  await new Promise((resolve11) => wake = resolve11);
11525
11856
  }
11526
11857
  if (signal.aborted) return;
11527
- const mergedPath = join25(input.framesDir, formatCaptureFrameName(next, "jpg"));
11858
+ const mergedPath = join28(input.framesDir, formatCaptureFrameName(next, "jpg"));
11528
11859
  const frame = await readLandedFrame(landed.get(next), mergedPath);
11529
11860
  landed.delete(next);
11530
11861
  if (!await stream.writeFrame(frame)) {
@@ -11599,19 +11930,19 @@ async function runEncodeStage(input) {
11599
11930
  const stage5Start = Date.now();
11600
11931
  if (isPngSequence) {
11601
11932
  const encoded = startEncodeProgress(job, "Writing PNG sequence", onProgress);
11602
- if (!existsSync18(outputPath)) mkdirSync7(outputPath, { recursive: true });
11603
- const captured = readdirSync4(framesDir).filter((name) => name.endsWith(".png")).sort();
11933
+ if (!existsSync18(outputPath)) mkdirSync9(outputPath, { recursive: true });
11934
+ const captured = readdirSync5(framesDir).filter((name) => name.endsWith(".png")).sort();
11604
11935
  if (captured.length === 0) {
11605
11936
  throw new Error(
11606
11937
  `[Render] png-sequence output requested but no PNGs were captured to ${framesDir}`
11607
11938
  );
11608
11939
  }
11609
11940
  captured.forEach((name, i) => {
11610
- const dst = join25(outputPath, formatExportFrameName(i, "png"));
11611
- copyFileSync2(join25(framesDir, name), dst);
11941
+ const dst = join28(outputPath, formatExportFrameName(i, "png"));
11942
+ copyFileSync2(join28(framesDir, name), dst);
11612
11943
  });
11613
11944
  if (hasAudio && audioOutputPath && existsSync18(audioOutputPath)) {
11614
- copyFileSync2(audioOutputPath, join25(outputPath, MIXED_AUDIO_FILENAME));
11945
+ copyFileSync2(audioOutputPath, join28(outputPath, MIXED_AUDIO_FILENAME));
11615
11946
  log.info(
11616
11947
  `[Render] png-sequence: ${MIXED_AUDIO_FILENAME} sidecar written to ${outputPath}/${MIXED_AUDIO_FILENAME}`
11617
11948
  );
@@ -11631,7 +11962,7 @@ async function runEncodeStage(input) {
11631
11962
  const encodeResult2 = await encodeGifFromDir(framesDir, framePattern2, outputPath, {
11632
11963
  fps: job.config.fps,
11633
11964
  loop,
11634
- palettePath: join25(dirname9(videoOnlyPath), "gif-palette.png"),
11965
+ palettePath: join28(dirname10(videoOnlyPath), "gif-palette.png"),
11635
11966
  preserveAlpha: needsAlpha,
11636
11967
  signal: abortSignal,
11637
11968
  timeout: engineCfg.ffmpegEncodeTimeout
@@ -11836,14 +12167,14 @@ function sampleDirectoryBytes(dir) {
11836
12167
  if (!current) continue;
11837
12168
  let entries = [];
11838
12169
  try {
11839
- entries = readdirSync5(current);
12170
+ entries = readdirSync6(current);
11840
12171
  } catch {
11841
12172
  continue;
11842
12173
  }
11843
12174
  for (const name of entries) {
11844
- const full = join26(current, name);
12175
+ const full = join29(current, name);
11845
12176
  try {
11846
- const st = statSync6(full);
12177
+ const st = statSync7(full);
11847
12178
  if (st.isDirectory()) {
11848
12179
  stack.push(full);
11849
12180
  } else if (st.isFile()) {
@@ -11997,8 +12328,8 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
11997
12328
  const ranges = [];
11998
12329
  let rangeStart = null;
11999
12330
  for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
12000
- const framePath = join26(framesDir, formatCaptureFrameName(frameIndex, frameExt));
12001
- const missing = !existsSync19(framePath) || statSync6(framePath).size <= 8;
12331
+ const framePath = join29(framesDir, formatCaptureFrameName(frameIndex, frameExt));
12332
+ const missing = !existsSync19(framePath) || statSync7(framePath).size <= 8;
12002
12333
  if (missing && rangeStart === null) {
12003
12334
  rangeStart = frameIndex;
12004
12335
  } else if (!missing && rangeStart !== null) {
@@ -12014,7 +12345,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
12014
12345
  function buildMissingFrameRetryBatches(ranges, maxWorkers, workDir, attempt, rangeStart = 0, stride = 1) {
12015
12346
  const workersPerBatch = Math.max(1, Math.floor(maxWorkers));
12016
12347
  const batches = [];
12017
- const outputDirFor = (batchIndex, workerId) => join26(workDir, `retry-${attempt}-batch-${batchIndex}-worker-${workerId}`);
12348
+ const outputDirFor = (batchIndex, workerId) => join29(workDir, `retry-${attempt}-batch-${batchIndex}-worker-${workerId}`);
12018
12349
  if (stride > 1) {
12019
12350
  const spans = /* @__PURE__ */ new Map();
12020
12351
  for (const range of ranges) {
@@ -12074,8 +12405,8 @@ function getNextRetryWorkerCount(currentWorkers) {
12074
12405
  return Math.max(1, Math.floor(currentWorkers / 2));
12075
12406
  }
12076
12407
  function resolveRenderWorkDirPrefix(outputPath, jobId, platform2 = process.platform, systemTempDir = tmpdir2()) {
12077
- if (platform2 === "win32" || platform2 === "darwin") return join26(systemTempDir, "hf-render-");
12078
- return join26(dirname10(outputPath), `work-${jobId}-`);
12408
+ if (platform2 === "win32" || platform2 === "darwin") return join29(systemTempDir, "hf-render-");
12409
+ return join29(dirname11(outputPath), `work-${jobId}-`);
12079
12410
  }
12080
12411
  var MAX_TRANSIENT_CAPTURE_RETRIES = 1;
12081
12412
  function isTransientCaptureRetryEligible(failureKind, missing, retriesUsed) {
@@ -12122,7 +12453,7 @@ The composition is too large for the available memory. To reduce memory pressure
12122
12453
  function countCapturedFrames(totalFrames, framesDir, frameExt) {
12123
12454
  let captured = 0;
12124
12455
  for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
12125
- const framePath = join26(framesDir, formatCaptureFrameName(frameIndex, frameExt));
12456
+ const framePath = join29(framesDir, formatCaptureFrameName(frameIndex, frameExt));
12126
12457
  if (existsSync19(framePath)) captured++;
12127
12458
  }
12128
12459
  return captured;
@@ -12148,7 +12479,7 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
12148
12479
  reason: attempt === 0 ? "initial" : pendingTransientRetry ? "transient-retry" : "retry"
12149
12480
  });
12150
12481
  pendingTransientRetry = false;
12151
- const attemptWorkDir = join26(options.workDir, `capture-attempt-${attempt}`);
12482
+ const attemptWorkDir = join29(options.workDir, `capture-attempt-${attempt}`);
12152
12483
  const batches = missingRanges ? buildMissingFrameRetryBatches(
12153
12484
  missingRanges,
12154
12485
  currentWorkers,
@@ -12780,19 +13111,19 @@ function deVerifyFallbackTelemetry(err) {
12780
13111
  };
12781
13112
  }
12782
13113
  function resolveRenderDebugDir() {
12783
- const producerRoot = process.env.PRODUCER_RENDERS_DIR ? resolve6(process.env.PRODUCER_RENDERS_DIR, "..") : resolve6(dirname10(fileURLToPath4(import.meta.url)), "../..");
12784
- return join26(producerRoot, ".debug");
13114
+ const producerRoot = process.env.PRODUCER_RENDERS_DIR ? resolve6(process.env.PRODUCER_RENDERS_DIR, "..") : resolve6(dirname11(fileURLToPath4(import.meta.url)), "../..");
13115
+ return join29(producerRoot, ".debug");
12785
13116
  }
12786
13117
  async function executeRenderJob(job, projectDir, outputPath, progressSink, abortSignal, assertRenderActive) {
12787
13118
  validateHlsRenderConfig(job.config);
12788
13119
  validateDeliveryEncoderConfig(job.config);
12789
13120
  const debugDir = resolveRenderDebugDir();
12790
- const outputDir = dirname10(outputPath);
12791
- if (!existsSync19(outputDir)) mkdirSync8(outputDir, { recursive: true });
12792
- const workDir = job.config.debug ? join26(debugDir, job.id) : createRenderWorkDir(resolveRenderWorkDirPrefix(outputPath, job.id), outputDir);
13121
+ const outputDir = dirname11(outputPath);
13122
+ if (!existsSync19(outputDir)) mkdirSync10(outputDir, { recursive: true });
13123
+ const workDir = job.config.debug ? join29(debugDir, job.id) : createRenderWorkDir(resolveRenderWorkDirPrefix(outputPath, job.id), outputDir);
12793
13124
  const pipelineStart = Date.now();
12794
13125
  const baseLog = job.config.logger ?? defaultLogger;
12795
- const logPath = job.config.debug ? join26(workDir, "render.log") : null;
13126
+ const logPath = job.config.debug ? join29(workDir, "render.log") : null;
12796
13127
  const execution = new RenderExecutionContext({
12797
13128
  request: { renderJobId: job.id, projectDir, outputPath },
12798
13129
  logger: logPath ? createRenderFileLogger(logPath, baseLog) : baseLog,
@@ -12806,7 +13137,7 @@ async function executeRenderJob(job, projectDir, outputPath, progressSink, abort
12806
13137
  log.info("KEEP_TEMP=1, leaving workDir on disk for inspection", { workDir });
12807
13138
  return;
12808
13139
  }
12809
- rmSync8(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
13140
+ rmSync10(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
12810
13141
  });
12811
13142
  try {
12812
13143
  await executeRenderPipeline({
@@ -12854,7 +13185,7 @@ async function executeRenderPipeline(input) {
12854
13185
  imageDecodeFailures: 0
12855
13186
  };
12856
13187
  let hdrPerf;
12857
- const perfOutputPath = join26(workDir, "perf-summary.json");
13188
+ const perfOutputPath = join29(workDir, "perf-summary.json");
12858
13189
  const cfg = { ...job.config.producerConfig ?? resolveConfig() };
12859
13190
  const observability = new RenderObservabilityRecorder({
12860
13191
  pipelineStartMs: pipelineStart,
@@ -12930,7 +13261,7 @@ async function executeRenderPipeline(input) {
12930
13261
  job.startedAt = /* @__PURE__ */ new Date();
12931
13262
  assertNotAborted();
12932
13263
  assertConfiguredFfmpegBinariesExist();
12933
- if (!existsSync19(workDir)) mkdirSync8(workDir, { recursive: true });
13264
+ if (!existsSync19(workDir)) mkdirSync10(workDir, { recursive: true });
12934
13265
  if (job.config.debug) {
12935
13266
  log.info("[Render] Debug artifacts enabled", { workDir, logPath });
12936
13267
  }
@@ -12959,7 +13290,7 @@ async function executeRenderPipeline(input) {
12959
13290
  requestedWorkers: job.config.workers ?? "auto"
12960
13291
  });
12961
13292
  const entryFile = job.config.entryFile || "index.html";
12962
- const htmlPath = join26(projectDir, entryFile);
13293
+ const htmlPath = join29(projectDir, entryFile);
12963
13294
  if (!existsSync19(htmlPath)) {
12964
13295
  throw new Error(`Entry file not found: ${htmlPath}`);
12965
13296
  }
@@ -13136,7 +13467,7 @@ async function executeRenderPipeline(input) {
13136
13467
  canvas: { width, height },
13137
13468
  page: probeSession.page,
13138
13469
  projectDir,
13139
- compiledDir: join26(workDir, "compiled")
13470
+ compiledDir: join29(workDir, "compiled")
13140
13471
  });
13141
13472
  if (videoLayerPlan.videoId === void 0) {
13142
13473
  log.info(`[Render] Video layer passthrough off: ${videoLayerPlan.reason}`);
@@ -13154,7 +13485,22 @@ async function executeRenderPipeline(input) {
13154
13485
  updateJobStatus(job, "preprocessing", "Extracting video frames", 10, onProgress, {
13155
13486
  code: "extract_video"
13156
13487
  });
13157
- const compiledDir = join26(workDir, "compiled");
13488
+ const compiledDir = join29(workDir, "compiled");
13489
+ const segmentsCapture = (layeredOrEffectRoute) => shouldSegmentCapture({
13490
+ env: process.env,
13491
+ durationSeconds: probeResult.duration,
13492
+ outputFormat,
13493
+ layeredOrEffectRoute,
13494
+ streamingOk: shouldUseStreamingEncode(cfg, outputFormat, 1, probeResult.duration)
13495
+ });
13496
+ const segmentedForWindow = segmentsCapture(compiled.hasShaderTransitions);
13497
+ const windowVideoFrames = job.config.motionBlur === void 0 && shouldWindowVideoFrames({ env: process.env, segmented: segmentedForWindow });
13498
+ if (!windowVideoFrames && shouldWindowVideoFrames({ env: process.env, segmented: true })) {
13499
+ const reason = job.config.motionBlur !== void 0 ? "motion blur" : outputFormat !== "mp4" && outputFormat !== "mov" ? `${outputFormat} output` : "capture is not segmented";
13500
+ log.info("[Render] HF_VIDEO_FRAME_WINDOW is set but this render extracts every frame", {
13501
+ reason
13502
+ });
13503
+ }
13158
13504
  const extractResult = await observeRenderStage(
13159
13505
  observability,
13160
13506
  "video_extract",
@@ -13171,6 +13517,7 @@ async function executeRenderPipeline(input) {
13171
13517
  assertNotAborted,
13172
13518
  // Local staging can use links; distributed plan() alone requires real copies.
13173
13519
  materializeSymlinks: false,
13520
+ deferRangeExtraction: windowVideoFrames ? true : void 0,
13174
13521
  onProgress
13175
13522
  })
13176
13523
  );
@@ -13267,7 +13614,7 @@ async function executeRenderPipeline(input) {
13267
13614
  try {
13268
13615
  fileServer = await createFileServer({
13269
13616
  projectDir,
13270
- compiledDir: join26(workDir, "compiled"),
13617
+ compiledDir: join29(workDir, "compiled"),
13271
13618
  port: 0,
13272
13619
  preHeadScripts: [VIRTUAL_TIME_SHIM],
13273
13620
  fps: job.config.fps
@@ -13285,8 +13632,8 @@ async function executeRenderPipeline(input) {
13285
13632
  if (!activeFileServer) {
13286
13633
  throw new Error("File server failed to initialize before frame capture");
13287
13634
  }
13288
- const framesDir = join26(workDir, "captured-frames");
13289
- if (!existsSync19(framesDir)) mkdirSync8(framesDir, { recursive: true });
13635
+ const framesDir = join29(workDir, "captured-frames");
13636
+ if (!existsSync19(framesDir)) mkdirSync10(framesDir, { recursive: true });
13290
13637
  updateJobStatus(job, "rendering", "Checking browser GPU", 25, onProgress, {
13291
13638
  code: "start_browsers"
13292
13639
  });
@@ -13364,7 +13711,55 @@ async function executeRenderPipeline(input) {
13364
13711
  });
13365
13712
  const buildPrepCaptureOptions = () => stopPrepSessionOnScriptFailure(buildCaptureOptions());
13366
13713
  const buildWorkerCaptureOptions = () => withScriptFailureStop(buildCaptureOptions(), job, log);
13714
+ let videoFrameWindow = windowVideoFrames && (extractionResult?.extracted.some((video) => video.deferredRange) ?? false);
13715
+ if (windowVideoFrames) {
13716
+ const extracted = extractionResult?.extracted ?? [];
13717
+ log.info("[Render] Video frame window", {
13718
+ windowed: extracted.filter((video) => video.deferredRange).length,
13719
+ fullyExtracted: extracted.filter((video) => !video.deferredRange).length
13720
+ });
13721
+ }
13722
+ const buildSegmentVideoFrames = () => trackSegmentFramePeak(
13723
+ createSegmentVideoFrames({
13724
+ videos: composition.videos,
13725
+ extracted: extractionResult?.extracted ?? [],
13726
+ fps: job.config.fps,
13727
+ rootDir: workDir,
13728
+ cfg,
13729
+ injectorOptions: frameCacheOptions(cfg, workerCount),
13730
+ abortSignal: executionSignal
13731
+ }),
13732
+ workDir,
13733
+ (bytes) => updateCaptureObservability({ videoFrameWindowPeakBytes: bytes })
13734
+ );
13367
13735
  const createRenderVideoFrameInjector = () => createVideoFrameInjector(frameLookup, frameCacheOptions(cfg, workerCount));
13736
+ const extractDeferredVideoFrames = async () => {
13737
+ videoFrameWindow = false;
13738
+ updateCaptureObservability({ videoFrameWindow: "off" });
13739
+ const extracted = extractionResult?.extracted ?? [];
13740
+ const videoCount = extracted.filter((video) => video.deferredRange).length;
13741
+ const startedAt = Date.now();
13742
+ log.info("[Render] Extracting the frames of the videos a window would have held back", {
13743
+ videoCount
13744
+ });
13745
+ await observeRenderStage(
13746
+ observability,
13747
+ "video_extract_deferred",
13748
+ { videoCount },
13749
+ () => extractAllDeferredFrames(extracted, {
13750
+ fps: job.config.fps,
13751
+ cfg,
13752
+ signal: executionSignal,
13753
+ maxTransientRetries: resolveVideoExtractionPolicy().maxTransientRetries,
13754
+ onProgress: (done, total) => reportExtractProgress(job, done, total, onProgress)
13755
+ })
13756
+ );
13757
+ assertNotAborted();
13758
+ log.info("[Render] Extracted the deferred video frames", {
13759
+ videoCount,
13760
+ elapsedMs: Date.now() - startedAt
13761
+ });
13762
+ };
13368
13763
  let captureCalibration;
13369
13764
  const htmlInCanvasDetected = compiled.renderModeHints.reasons.some(
13370
13765
  (r) => r.code === "htmlInCanvas"
@@ -13530,32 +13925,41 @@ async function executeRenderPipeline(input) {
13530
13925
  updateJobStatus(job, "rendering", "Measuring capture speed", 25, onProgress, {
13531
13926
  code: "start_browsers"
13532
13927
  });
13533
- const outcome = await observeRenderStage(
13534
- observability,
13535
- "capture_calibration",
13536
- captureStageObservationData({
13537
- forceScreenshot: captureForceScreenshot,
13538
- // Override the default `capturing` — calibration writes probe
13539
- // frames only, not `job.framesRendered`, so heartbeats reporting
13540
- // `framesCompleted: 0` misread as broken. Field signal
13541
- // ts=1784019503.
13542
- stagePhase: "calibrating"
13543
- }),
13544
- () => runCaptureCalibration({
13545
- cfg: calibrationCaptureConfig(cfg),
13546
- fileServer: activeFileServer,
13547
- workDir,
13548
- log,
13549
- job,
13550
- totalFrames,
13551
- forceScreenshot: captureForceScreenshot,
13552
- probeSession,
13553
- buildCaptureOptions: buildPrepCaptureOptions,
13554
- createRenderVideoFrameInjector,
13555
- assertNotAborted
13556
- }),
13557
- { heartbeatMessage: "browser calibrating (frames not started)" }
13558
- );
13928
+ const calibrationFrames = videoFrameWindow ? await buildSegmentVideoFrames().forFrames(
13929
+ selectCaptureCalibrationFrames(totalFrames),
13930
+ "calibration"
13931
+ ) : void 0;
13932
+ let outcome;
13933
+ try {
13934
+ outcome = await observeRenderStage(
13935
+ observability,
13936
+ "capture_calibration",
13937
+ captureStageObservationData({
13938
+ forceScreenshot: captureForceScreenshot,
13939
+ // Override the default `capturing` — calibration writes probe
13940
+ // frames only, not `job.framesRendered`, so heartbeats reporting
13941
+ // `framesCompleted: 0` misread as broken. Field signal
13942
+ // ts=1784019503.
13943
+ stagePhase: "calibrating"
13944
+ }),
13945
+ () => runCaptureCalibration({
13946
+ cfg: calibrationCaptureConfig(cfg),
13947
+ fileServer: activeFileServer,
13948
+ workDir,
13949
+ log,
13950
+ job,
13951
+ totalFrames,
13952
+ forceScreenshot: captureForceScreenshot,
13953
+ probeSession,
13954
+ buildCaptureOptions: buildPrepCaptureOptions,
13955
+ createRenderVideoFrameInjector: calibrationFrames ? calibrationFrames.injector : createRenderVideoFrameInjector,
13956
+ assertNotAborted
13957
+ }),
13958
+ { heartbeatMessage: "browser calibrating (frames not started)" }
13959
+ );
13960
+ } finally {
13961
+ calibrationFrames?.release();
13962
+ }
13559
13963
  captureCalibration = outcome.calibration;
13560
13964
  calibrationEvaluateTimedOut = outcome.calibrationEvaluateTimedOut;
13561
13965
  captureForceScreenshot = outcome.forceScreenshot;
@@ -13787,7 +14191,7 @@ async function executeRenderPipeline(input) {
13787
14191
  hls: ".mp4"
13788
14192
  };
13789
14193
  const videoExt = FORMAT_EXT[outputFormat] ?? ".mp4";
13790
- const videoOnlyPath = join26(workDir, `video-only${videoExt}`);
14194
+ const videoOnlyPath = join29(workDir, `video-only${videoExt}`);
13791
14195
  const usePageSideCompositingForTransitions = (cfg.enablePageSideCompositing || isGif) && compiled.hasShaderTransitions && !hasHdrContent && outputSupportsPageSideShaderCompositing(outputFormat);
13792
14196
  if (usePageSideCompositingForTransitions) {
13793
14197
  activeFileServer.addPreHeadScript(HF_PAGE_SIDE_COMPOSITING_STUB);
@@ -13888,13 +14292,7 @@ async function executeRenderPipeline(input) {
13888
14292
  // excluded routes are the ones whose concat-copy or capture loop the
13889
14293
  // segment contract does not cover (webm VP9 concat is fragile, HDR and
13890
14294
  // shader transitions run their own compositor).
13891
- useSegmentedCapture: shouldSegmentCapture({
13892
- env: process.env,
13893
- durationSeconds: job.duration,
13894
- outputFormat,
13895
- layeredOrEffectRoute: hasHdrContent || compiled.hasShaderTransitions,
13896
- streamingOk: shouldUseStreamingEncode(cfg, outputFormat, 1, job.duration)
13897
- }),
14295
+ useSegmentedCapture: segmentsCapture(hasHdrContent || compiled.hasShaderTransitions),
13898
14296
  useLayeredComposite,
13899
14297
  usePageSideCompositing: usePageSideCompositingForTransitions,
13900
14298
  hasHdrContent,
@@ -13934,10 +14332,14 @@ async function executeRenderPipeline(input) {
13934
14332
  deWorkerInversion,
13935
14333
  deParallelRouter
13936
14334
  });
14335
+ if (videoFrameWindow && capturePlan.kind !== "sdr_segmented")
14336
+ await extractDeferredVideoFrames();
14337
+ updateCaptureObservability({ videoFrameWindow: videoFrameWindow ? "on" : "off" });
13937
14338
  observability.checkpoint("capture_strategy", "resolved", {
13938
14339
  plan: capturePlan.kind,
13939
14340
  workerCount: capturePlan.workerCount,
13940
14341
  forceScreenshot: capturePlan.forceScreenshot,
14342
+ videoFrameWindow: videoFrameWindow ? "on" : "off",
13941
14343
  captureBeyondViewport: resolvedCaptureBeyondViewport ?? null,
13942
14344
  useStreamingEncode: capturePlan.kind === "sdr_streaming",
13943
14345
  useLayeredComposite: capturePlan.kind === "hdr_layered",
@@ -14075,7 +14477,7 @@ async function executeRenderPipeline(input) {
14075
14477
  pageMotionBlur: job.config.pageMotionBlur,
14076
14478
  captureQuality: captureOptions.quality
14077
14479
  });
14078
- const segmentDir = segmentDirFor(join26(projectDir, "renders"), segmentPlanHash);
14480
+ const segmentDir = segmentDirFor(join29(projectDir, "renders"), segmentPlanHash);
14079
14481
  let completedSegments = /* @__PURE__ */ new Set();
14080
14482
  if (job.config.resumeSegments === true) {
14081
14483
  const existing = readSegmentManifest(segmentDir);
@@ -14090,10 +14492,10 @@ async function executeRenderPipeline(input) {
14090
14492
  });
14091
14493
  }
14092
14494
  if (completedSegments.size === 0) {
14093
- rmSync8(segmentDir, { recursive: true, force: true });
14495
+ rmSync10(segmentDir, { recursive: true, force: true });
14094
14496
  }
14095
14497
  } else {
14096
- rmSync8(segmentDir, { recursive: true, force: true });
14498
+ rmSync10(segmentDir, { recursive: true, force: true });
14097
14499
  }
14098
14500
  const emptySegmentManifest = () => ({
14099
14501
  version: 1,
@@ -14143,6 +14545,7 @@ async function executeRenderPipeline(input) {
14143
14545
  },
14144
14546
  buildCaptureOptions: buildWorkerCaptureOptions,
14145
14547
  createRenderVideoFrameInjector,
14548
+ segmentVideoFrames: videoFrameWindow ? buildSegmentVideoFrames() : void 0,
14146
14549
  abortSignal: executionSignal,
14147
14550
  assertNotAborted,
14148
14551
  onProgress,
@@ -14194,7 +14597,7 @@ async function executeRenderPipeline(input) {
14194
14597
  probeSession = null;
14195
14598
  await closeOrphanedProbeForRetry(orphaned, closeCaptureSession, log, "segmented");
14196
14599
  }
14197
- rmSync8(segmentDir, { recursive: true, force: true });
14600
+ rmSync10(segmentDir, { recursive: true, force: true });
14198
14601
  completedSegments = /* @__PURE__ */ new Set();
14199
14602
  segmentManifest = emptySegmentManifest();
14200
14603
  dedupPerfs.length = 0;
@@ -14233,11 +14636,12 @@ async function executeRenderPipeline(input) {
14233
14636
  );
14234
14637
  updateCaptureObservability({ segmentRetries: segmentedRes.segmentRetries });
14235
14638
  if (job.config.keepSegments !== true) {
14236
- rmSync8(segmentDir, { recursive: true, force: true });
14639
+ rmSync10(segmentDir, { recursive: true, force: true });
14237
14640
  }
14238
14641
  } else {
14239
14642
  capturePlan = replanAfterFailure(capturePlan, { kind: "streaming_unavailable" });
14240
14643
  syncCapturePlan();
14644
+ if (videoFrameWindow) await extractDeferredVideoFrames();
14241
14645
  probeSession = null;
14242
14646
  observability.checkpoint(
14243
14647
  "capture_segmented",
@@ -14508,8 +14912,8 @@ async function executeRenderPipeline(input) {
14508
14912
  "capture_disk",
14509
14913
  "drawElement capture failed; retrying with a fresh screenshot session"
14510
14914
  );
14511
- rmSync8(framesDir, { recursive: true, force: true });
14512
- mkdirSync8(framesDir, { recursive: true });
14915
+ rmSync10(framesDir, { recursive: true, force: true });
14916
+ mkdirSync10(framesDir, { recursive: true });
14513
14917
  resetCaptureAttemptProgress(job);
14514
14918
  dedupPerfs.length = 0;
14515
14919
  cfg.useDrawElement = false;
@@ -14696,7 +15100,7 @@ async function executeRenderPipeline(input) {
14696
15100
  }
14697
15101
  if (job.config.debug) {
14698
15102
  if (!isPngSequence && !isHls && existsSync19(stagedOutputPath)) {
14699
- const debugOutput = join26(workDir, `output${videoExt}`);
15103
+ const debugOutput = join29(workDir, `output${videoExt}`);
14700
15104
  copyFileSync3(stagedOutputPath, debugOutput);
14701
15105
  }
14702
15106
  }
@@ -14806,14 +15210,14 @@ async function executeRenderPipeline(input) {
14806
15210
  }
14807
15211
 
14808
15212
  // ../producer/src/services/distributed/renderSpan.ts
14809
- import { mkdirSync as mkdirSync16, mkdtempSync as mkdtempSync7, readFileSync as readFileSync12, rmSync as rmSync14 } from "fs";
14810
- import { join as join40 } from "path";
15213
+ import { mkdirSync as mkdirSync18, mkdtempSync as mkdtempSync7, readFileSync as readFileSync12, rmSync as rmSync16 } from "fs";
15214
+ import { join as join43 } from "path";
14811
15215
  import { tmpdir as tmpdir4 } from "os";
14812
15216
 
14813
15217
  // ../producer/src/services/distributed/mp4Stitch.ts
14814
- import { createReadStream as createReadStream3, createWriteStream, mkdirSync as mkdirSync9, mkdtempSync as mkdtempSync4, rmSync as rmSync9 } from "fs";
15218
+ import { createReadStream as createReadStream3, createWriteStream, mkdirSync as mkdirSync11, mkdtempSync as mkdtempSync4, rmSync as rmSync11 } from "fs";
14815
15219
  import { open } from "fs/promises";
14816
- import { dirname as dirname11, join as join27 } from "path";
15220
+ import { dirname as dirname12, join as join30 } from "path";
14817
15221
  import { finished, pipeline } from "stream/promises";
14818
15222
  function boxAt(src, off, at, limit) {
14819
15223
  let size = src.readUInt32BE(off);
@@ -15177,18 +15581,18 @@ async function writeStitchedMp4(chunkPaths, outputPath, audioPath) {
15177
15581
  const sourcePaths = audioPath ? [audioPath, ...chunkPaths] : chunkPaths;
15178
15582
  const layouts = await Promise.all(sourcePaths.map((path) => readMp4Layout(fileRange(path))));
15179
15583
  const header = audioPath ? buildStitchedHeader(layouts.slice(1), layouts[0]) : buildStitchedHeader(layouts);
15180
- mkdirSync9(dirname11(outputPath), { recursive: true });
15584
+ mkdirSync11(dirname12(outputPath), { recursive: true });
15181
15585
  const workDir = mkdtempSync4(`${outputPath}.stitch-`);
15182
- const out = createWriteStream(join27(workDir, "out.mp4"));
15586
+ const out = createWriteStream(join30(workDir, "out.mp4"));
15183
15587
  try {
15184
15588
  out.write(header);
15185
15589
  for (const [i, path] of sourcePaths.entries()) await copyPayload(path, layouts[i], i, out);
15186
15590
  out.end();
15187
15591
  await finished(out);
15188
- renameWithRetry(join27(workDir, "out.mp4"), outputPath);
15592
+ renameWithRetry(join30(workDir, "out.mp4"), outputPath);
15189
15593
  } finally {
15190
15594
  out.destroy();
15191
- rmSync9(workDir, { recursive: true, force: true });
15595
+ rmSync11(workDir, { recursive: true, force: true });
15192
15596
  }
15193
15597
  }
15194
15598
 
@@ -15198,22 +15602,22 @@ import {
15198
15602
  cpSync as cpSync2,
15199
15603
  existsSync as existsSync24,
15200
15604
  linkSync,
15201
- mkdirSync as mkdirSync12,
15202
- rmSync as rmSync10,
15605
+ mkdirSync as mkdirSync14,
15606
+ rmSync as rmSync12,
15203
15607
  writeFileSync as writeFileSync9
15204
15608
  } from "fs";
15205
- import { extname as extname6, isAbsolute as isAbsolute2, join as join35, relative as relative5, sep as sep2 } from "path";
15609
+ import { extname as extname6, isAbsolute as isAbsolute2, join as join38, relative as relative5, sep as sep2 } from "path";
15206
15610
 
15207
15611
  // ../producer/src/services/distributed/planFrameCost.ts
15208
- import { join as join30 } from "path";
15612
+ import { join as join33 } from "path";
15209
15613
 
15210
15614
  // ../producer/src/services/distributed/chunkFrames.ts
15211
- import { existsSync as existsSync21, readdirSync as readdirSync6 } from "fs";
15212
- import { extname as extname4, join as join29 } from "path";
15615
+ import { existsSync as existsSync21, readdirSync as readdirSync7 } from "fs";
15616
+ import { extname as extname4, join as join32 } from "path";
15213
15617
 
15214
15618
  // ../producer/src/services/distributed/shared.ts
15215
15619
  import { execFile as execFileCallback } from "child_process";
15216
- import { dirname as dirname12, join as join28 } from "path";
15620
+ import { dirname as dirname13, join as join31 } from "path";
15217
15621
  import { existsSync as existsSync20, readFileSync as readFileSync7 } from "fs";
15218
15622
  import { fileURLToPath as fileURLToPath5 } from "url";
15219
15623
  import { promisify as promisify2 } from "util";
@@ -15225,7 +15629,7 @@ function isPlanAudioArtifactPath(path) {
15225
15629
  }
15226
15630
  function resolvePlanAudioPath(planDir) {
15227
15631
  for (const name of [PLAN_AUDIO_RELATIVE_PATH, PLAN_AUDIO_LEGACY_RELATIVE_PATH]) {
15228
- const candidate = join28(planDir, name);
15632
+ const candidate = join31(planDir, name);
15229
15633
  if (existsSync20(candidate)) return candidate;
15230
15634
  }
15231
15635
  return null;
@@ -15483,10 +15887,10 @@ function buildSyntheticRenderJob(input) {
15483
15887
  var cachedProducerVersion = null;
15484
15888
  function readProducerVersion() {
15485
15889
  if (cachedProducerVersion !== null) return cachedProducerVersion;
15486
- const startDir = dirname12(fileURLToPath5(import.meta.url));
15890
+ const startDir = dirname13(fileURLToPath5(import.meta.url));
15487
15891
  let current = startDir;
15488
15892
  for (let i = 0; i < 10; i++) {
15489
- const candidate = join28(current, "package.json");
15893
+ const candidate = join31(current, "package.json");
15490
15894
  if (existsSync20(candidate)) {
15491
15895
  try {
15492
15896
  const pkg = JSON.parse(readFileSync7(candidate, "utf-8"));
@@ -15497,7 +15901,7 @@ function readProducerVersion() {
15497
15901
  } catch {
15498
15902
  }
15499
15903
  }
15500
- const parent = dirname12(current);
15904
+ const parent = dirname13(current);
15501
15905
  if (parent === current) break;
15502
15906
  current = parent;
15503
15907
  }
@@ -15540,14 +15944,14 @@ function frameNumberFromFileName(name) {
15540
15944
  function rebuildExtractedFramesFromPlanDir(planDir, videos, indexMode = "dense-v1") {
15541
15945
  const result = [];
15542
15946
  for (const v of videos) {
15543
- const outputDir = join29(planDir, "video-frames", v.videoId);
15947
+ const outputDir = join32(planDir, "video-frames", v.videoId);
15544
15948
  if (!existsSync21(outputDir)) {
15545
15949
  throw new Error(
15546
15950
  `[renderChunk] planDir missing extracted video frames for ${JSON.stringify(v.videoId)}: ${outputDir} not present. plan() should have written frames here; the planDir is malformed.`
15547
15951
  );
15548
15952
  }
15549
15953
  const ext = (extname4(v.framePattern) || ".jpg").toLowerCase();
15550
- const frames = readdirSync6(outputDir).filter((name) => name.toLowerCase().endsWith(ext)).sort((left, right) => {
15954
+ const frames = readdirSync7(outputDir).filter((name) => name.toLowerCase().endsWith(ext)).sort((left, right) => {
15551
15955
  const leftNumber = frameNumberFromFileName(left);
15552
15956
  const rightNumber = frameNumberFromFileName(right);
15553
15957
  if (leftNumber === null || rightNumber === null) return left.localeCompare(right);
@@ -15559,7 +15963,7 @@ function rebuildExtractedFramesFromPlanDir(planDir, videos, indexMode = "dense-v
15559
15963
  if (!frameName) continue;
15560
15964
  const frameNumber = indexMode === "sparse-v2" ? frameNumberFromFileName(frameName) : null;
15561
15965
  const frameIndex = frameNumber === null ? i : frameNumber - 1;
15562
- framePaths.set(frameIndex, join29(outputDir, frameName));
15966
+ framePaths.set(frameIndex, join32(outputDir, frameName));
15563
15967
  }
15564
15968
  result.push({
15565
15969
  videoId: v.videoId,
@@ -15576,15 +15980,6 @@ function rebuildExtractedFramesFromPlanDir(planDir, videos, indexMode = "dense-v
15576
15980
  }
15577
15981
  return result;
15578
15982
  }
15579
- function contiguousRuns(sortedIndexes) {
15580
- const runs2 = [];
15581
- for (const index of sortedIndexes) {
15582
- const last = runs2[runs2.length - 1];
15583
- if (last && last.firstFrame + last.frames === index) last.frames++;
15584
- else runs2.push({ firstFrame: index, frames: 1 });
15585
- }
15586
- return runs2;
15587
- }
15588
15983
  function buildChunkCaptureOptions(input) {
15589
15984
  const { dimensions, encoder } = input;
15590
15985
  const videoCaptureBeyondViewport = resolveVideoCaptureBeyondViewport(input.videoCount);
@@ -15607,28 +16002,19 @@ function buildChunkCaptureOptions(input) {
15607
16002
  requiresWebGpu: compositionRequiresWebGpu(input.html)
15608
16003
  };
15609
16004
  }
15610
- function shownDeferredFrameIndexes(planVideos, frames, fps) {
15611
- const shown = /* @__PURE__ */ new Map();
15612
- const deferred = planVideos.extracted.filter((video) => video.deferredRange);
15613
- if (deferred.length === 0) return shown;
15614
- const table = createFrameLookupTable(
15615
- planVideos.videos,
15616
- deferred.map((video) => ({
15617
- ...video,
15618
- outputDir: "",
15619
- framePaths: new Map(Array.from({ length: video.totalFrames }, (_, i) => [i, String(i)]))
15620
- })),
15621
- resolveRenderFpsConfig(fps).value
16005
+ function planExtractedFrames(planVideos) {
16006
+ return planVideos.extracted.map((video) => ({
16007
+ ...video,
16008
+ outputDir: "",
16009
+ framePaths: /* @__PURE__ */ new Map()
16010
+ }));
16011
+ }
16012
+ function shownPlanFrameIndexes(planVideos, frames, fps) {
16013
+ return shownDeferredFrameIndexes(
16014
+ { videos: planVideos.videos, extracted: planExtractedFrames(planVideos) },
16015
+ frames,
16016
+ fps
15622
16017
  );
15623
- for (const frame of frames) {
15624
- const globalTime = frame * fps.den / fps.num;
15625
- for (const [videoId, payload] of table.getActiveFramePayloads(globalTime)) {
15626
- const indexes = shown.get(videoId) ?? /* @__PURE__ */ new Set();
15627
- indexes.add(payload.frameIndex);
15628
- shown.set(videoId, indexes);
15629
- }
15630
- }
15631
- return shown;
15632
16018
  }
15633
16019
  async function extractDeferredVideoFramesForChunk(input) {
15634
16020
  const deferred = input.planVideos.extracted.filter((video) => video.deferredRange);
@@ -15645,49 +16031,32 @@ async function extractDeferredVideoFramesForChunk(input) {
15645
16031
  url: remoteSources[path].split("?")[0]
15646
16032
  });
15647
16033
  }
15648
- if (deferred.length === 0) return [];
15649
- const shown = shownDeferredFrameIndexes(input.planVideos, input.frames, input.fps);
15650
- return Promise.all(
15651
- deferred.map(async (video) => {
15652
- const outputDir = join29(input.outputRoot, video.videoId);
15653
- const indexes = [...shown.get(video.videoId) ?? []].sort((a, b) => a - b);
15654
- if (indexes.length === 0) {
15655
- return { ...video, outputDir, framePaths: /* @__PURE__ */ new Map(), ownedByLookup: false };
15656
- }
15657
- const range = video.deferredRange;
16034
+ const planned = new Map(input.planVideos.extracted.map((video) => [video.videoId, video]));
16035
+ return extractDeferredFrames({
16036
+ videos: input.planVideos.videos,
16037
+ extracted: planExtractedFrames(input.planVideos),
16038
+ frames: input.frames,
16039
+ fps: input.fps,
16040
+ outputRoot: input.outputRoot,
16041
+ cfg: input.cfg,
16042
+ shownBoxes: input.shownBoxes,
16043
+ sourceOf: (video) => {
16044
+ const range = planned.get(video.videoId).deferredRange;
15658
16045
  const remoteUrl = remoteSources[range.sourcePath];
15659
- const sourcePath = remoteUrl ?? join29(input.planDir, ...range.sourcePath.split("/"));
16046
+ const sourcePath = remoteUrl ?? join32(input.planDir, ...range.sourcePath.split("/"));
15660
16047
  if (remoteUrl === void 0 && !existsSync21(sourcePath)) {
15661
16048
  throw new RenderChunkValidationError(
15662
16049
  MISSING_PLAN_ARTIFACT,
15663
16050
  `[renderChunk] planDir is missing the source for video ${JSON.stringify(video.videoId)}: ${range.sourcePath}`
15664
16051
  );
15665
16052
  }
15666
- const extracted = await extractVideoFramesRange(
15667
- sourcePath,
15668
- video.videoId,
15669
- range.startTime,
15670
- range.durationSeconds,
15671
- {
15672
- fps: input.fps,
15673
- outputDir: input.outputRoot,
15674
- format: range.format,
15675
- frameRanges: contiguousRuns(indexes),
15676
- shownBox: input.shownBoxes?.get(video.videoId)
15677
- },
15678
- void 0,
15679
- input.cfg
15680
- );
15681
- const missing = indexes.find((index) => !extracted.framePaths.has(index));
15682
- if (missing !== void 0) {
15683
- throw new RenderChunkValidationError(
15684
- INVALID_VIDEO_METADATA,
15685
- `[renderChunk] video ${JSON.stringify(video.videoId)} has no frame ${missing}; the plan expected ${video.totalFrames} frames from ${range.sourcePath}.`
15686
- );
15687
- }
15688
- return { ...video, outputDir, framePaths: extracted.framePaths, ownedByLookup: false };
15689
- })
15690
- );
16053
+ return sourcePath;
16054
+ },
16055
+ onMissingFrame: (video, index) => new RenderChunkValidationError(
16056
+ INVALID_VIDEO_METADATA,
16057
+ `[renderChunk] video ${JSON.stringify(video.videoId)} has no frame ${index}; the plan expected ${video.totalFrames} frames from ${planned.get(video.videoId).deferredRange.sourcePath}.`
16058
+ )
16059
+ });
15691
16060
  }
15692
16061
 
15693
16062
  // ../producer/src/services/distributed/planFrameCost.ts
@@ -15705,12 +16074,12 @@ async function measurePlanSecondsPerFrame(input) {
15705
16074
  planVideos,
15706
16075
  frames: sampled,
15707
16076
  fps: fpsRatio,
15708
- outputRoot: join30(workDir, "frame-cost-video-frames"),
16077
+ outputRoot: join33(workDir, "frame-cost-video-frames"),
15709
16078
  cfg: input.cfg
15710
16079
  })
15711
16080
  ];
15712
16081
  const lookup = extracted.length > 0 ? createFrameLookupTable(planVideos.videos, extracted, resolveRenderFpsConfig(fpsRatio).value) : null;
15713
- const compiledDir = join30(planDir, "compiled");
16082
+ const compiledDir = join33(planDir, "compiled");
15714
16083
  const fileServer = await createFileServer({
15715
16084
  projectDir: compiledDir,
15716
16085
  compiledDir,
@@ -15722,7 +16091,7 @@ async function measurePlanSecondsPerFrame(input) {
15722
16091
  try {
15723
16092
  session = await createCaptureSession(
15724
16093
  fileServer.url,
15725
- join30(workDir, "frame-cost"),
16094
+ join33(workDir, "frame-cost"),
15726
16095
  buildChunkCaptureOptions({
15727
16096
  dimensions: { ...input, fpsNum: fps, fpsDen: 1 },
15728
16097
  encoder: input,
@@ -15818,21 +16187,21 @@ function buildWeightedChunkSlices(weights, chunkCount, minFrames, maxFrames) {
15818
16187
  }
15819
16188
 
15820
16189
  // ../producer/src/services/render/planReferenceBackground.ts
15821
- import { join as join31 } from "path";
16190
+ import { join as join34 } from "path";
15822
16191
  async function readPlanReferenceBackground(input) {
15823
16192
  let server;
15824
16193
  let session;
15825
16194
  try {
15826
16195
  server = await createFileServer({
15827
16196
  projectDir: input.projectDir,
15828
- compiledDir: join31(input.workDir, "compiled"),
16197
+ compiledDir: join34(input.workDir, "compiled"),
15829
16198
  port: 0,
15830
16199
  preHeadScripts: [VIRTUAL_TIME_SHIM],
15831
16200
  fps: input.options.fps
15832
16201
  });
15833
16202
  session = await createCaptureSession(
15834
16203
  server.url,
15835
- join31(input.workDir, "reference"),
16204
+ join34(input.workDir, "reference"),
15836
16205
  {
15837
16206
  ...input.options,
15838
16207
  requiresWebGpu: false
@@ -15868,8 +16237,8 @@ async function readPlanReferenceBackground(input) {
15868
16237
  }
15869
16238
 
15870
16239
  // ../producer/src/services/render/stages/freezePlan.ts
15871
- import { existsSync as existsSync22, mkdirSync as mkdirSync10, readFileSync as readFileSync8, readdirSync as readdirSync7, writeFileSync as writeFileSync7 } from "fs";
15872
- import { join as join32, relative as relative3, resolve as resolve7 } from "path";
16240
+ import { existsSync as existsSync22, mkdirSync as mkdirSync12, readFileSync as readFileSync8, readdirSync as readdirSync8, writeFileSync as writeFileSync7 } from "fs";
16241
+ import { join as join35, relative as relative3, resolve as resolve7 } from "path";
15873
16242
 
15874
16243
  // ../producer/src/services/distributed/planProtocol.ts
15875
16244
  var PLAN_SCHEMA_VERSION = 1;
@@ -16081,9 +16450,9 @@ function listPlanFiles(planDir) {
16081
16450
  const results = [];
16082
16451
  const rootResolved = resolve7(planDir);
16083
16452
  function walk(dir) {
16084
- const entries = readdirSync7(dir, { withFileTypes: true });
16453
+ const entries = readdirSync8(dir, { withFileTypes: true });
16085
16454
  for (const entry of entries) {
16086
- const full = join32(dir, entry.name);
16455
+ const full = join35(dir, entry.name);
16087
16456
  if (entry.isDirectory()) {
16088
16457
  walk(full);
16089
16458
  } else if (entry.isFile()) {
@@ -16124,15 +16493,15 @@ var PLAN_REMOTE_FILES_RELATIVE_PATH = "meta/remote-files.json";
16124
16493
  function writePlanRemoteFiles(planDir, files) {
16125
16494
  if (files.length === 0) return;
16126
16495
  const sorted = [...files].sort((a, b) => a.path < b.path ? -1 : 1);
16127
- writeFileSync7(join32(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH), JSON.stringify(sorted), "utf-8");
16496
+ writeFileSync7(join35(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH), JSON.stringify(sorted), "utf-8");
16128
16497
  }
16129
16498
  function readPlanRemoteFiles(planDir) {
16130
- const path = join32(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH);
16499
+ const path = join35(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH);
16131
16500
  return existsSync22(path) ? JSON.parse(readFileSync8(path, "utf-8")) : [];
16132
16501
  }
16133
16502
  function recomputePlanHashFromPlanDir(planDir, digests) {
16134
- const planJsonPath = join32(planDir, "plan.json");
16135
- const encoderJsonPath = join32(planDir, "meta", "encoder.json");
16503
+ const planJsonPath = join35(planDir, "plan.json");
16504
+ const encoderJsonPath = join35(planDir, "meta", "encoder.json");
16136
16505
  if (!existsSync22(planJsonPath)) {
16137
16506
  throw new Error(`[freezePlan] plan.json missing: ${planJsonPath}`);
16138
16507
  }
@@ -16169,18 +16538,18 @@ async function freezePlan(input) {
16169
16538
  if (!existsSync22(planDir)) {
16170
16539
  throw new Error(`[freezePlan] planDir does not exist: ${planDir}`);
16171
16540
  }
16172
- const metaDir = join32(planDir, "meta");
16173
- if (!existsSync22(metaDir)) mkdirSync10(metaDir, { recursive: true });
16541
+ const metaDir = join35(planDir, "meta");
16542
+ if (!existsSync22(metaDir)) mkdirSync12(metaDir, { recursive: true });
16174
16543
  writeFileSync7(
16175
- join32(metaDir, "composition.json"),
16544
+ join35(metaDir, "composition.json"),
16176
16545
  `${JSON.stringify(composition, null, 2)}
16177
16546
  `,
16178
16547
  "utf-8"
16179
16548
  );
16180
16549
  const encoderForCanonical = stripUndefined(encoder);
16181
16550
  const encoderConfigCanonicalJson = canonicalJsonStringify(encoderForCanonical);
16182
- writeFileSync7(join32(metaDir, "encoder.json"), encoderConfigCanonicalJson, "utf-8");
16183
- writeFileSync7(join32(metaDir, "chunks.json"), `${JSON.stringify(chunks, null, 2)}
16551
+ writeFileSync7(join35(metaDir, "encoder.json"), encoderConfigCanonicalJson, "utf-8");
16552
+ writeFileSync7(join35(metaDir, "chunks.json"), `${JSON.stringify(chunks, null, 2)}
16184
16553
  `, "utf-8");
16185
16554
  const { compositionHtml, assets } = collectPlanAssetShas(planDir, digests);
16186
16555
  const planHash = computePlanHash({
@@ -16205,7 +16574,7 @@ async function freezePlan(input) {
16205
16574
  duration: durationSeconds,
16206
16575
  hasAudio
16207
16576
  };
16208
- const planJsonPath = join32(planDir, "plan.json");
16577
+ const planJsonPath = join35(planDir, "plan.json");
16209
16578
  writeFileSync7(planJsonPath, `${JSON.stringify(planJson, null, 2)}
16210
16579
  `, "utf-8");
16211
16580
  return { planJsonPath, planHash };
@@ -16247,9 +16616,9 @@ function applyRuntimeEnvSnapshot(snapshot, env = process.env) {
16247
16616
  }
16248
16617
 
16249
16618
  // ../producer/src/services/distributed/chunkAudio.ts
16250
- import { closeSync as closeSync5, existsSync as existsSync23, ftruncateSync, mkdirSync as mkdirSync11, openSync as openSync5, readFileSync as readFileSync9 } from "fs";
16619
+ import { closeSync as closeSync5, existsSync as existsSync23, ftruncateSync, mkdirSync as mkdirSync13, openSync as openSync5, readFileSync as readFileSync9 } from "fs";
16251
16620
  import { writeFileSync as writeFileSync8, writeSync } from "fs";
16252
- import { join as join33 } from "path";
16621
+ import { join as join36 } from "path";
16253
16622
  function audioCutForChunk(grid, chunks, index, fps) {
16254
16623
  const firstPacketAt = (frame) => Math.min(
16255
16624
  grid.packetCount,
@@ -16336,7 +16705,7 @@ async function writeChunkAudioSlices(input) {
16336
16705
  });
16337
16706
  const bytes = readFileSync9(input.audioPath);
16338
16707
  const layout = { sizeBytes: bytes.length, payloadStart, payloadEnd, partStarts: {} };
16339
- mkdirSync11(join33(input.planDir, SLICE_DIR), { recursive: true });
16708
+ mkdirSync13(join36(input.planDir, SLICE_DIR), { recursive: true });
16340
16709
  input.chunks.forEach((_, index) => {
16341
16710
  const cut = audioCutForChunk(grid, input.chunks, index, input.fps);
16342
16711
  if (!cut) return;
@@ -16344,17 +16713,17 @@ async function writeChunkAudioSlices(input) {
16344
16713
  const start = offsets[cut.firstPacket];
16345
16714
  layout.partStarts[index] = start;
16346
16715
  const end = offsets[last] + track.sizes[last];
16347
- writeFileSync8(join33(input.planDir, chunkAudioSlicePath(index)), bytes.subarray(start, end));
16716
+ writeFileSync8(join36(input.planDir, chunkAudioSlicePath(index)), bytes.subarray(start, end));
16348
16717
  });
16349
16718
  const frame = [bytes.subarray(0, payloadStart), bytes.subarray(payloadEnd)];
16350
- writeFileSync8(join33(input.planDir, SLICE_FRAME), Buffer.concat(frame));
16351
- writeFileSync8(join33(input.planDir, SLICE_LAYOUT), JSON.stringify(layout));
16719
+ writeFileSync8(join36(input.planDir, SLICE_FRAME), Buffer.concat(frame));
16720
+ writeFileSync8(join36(input.planDir, SLICE_LAYOUT), JSON.stringify(layout));
16352
16721
  }
16353
16722
  function chunkAudioSource(planDir, chunkIndex, scratchPath) {
16354
- const layoutPath = join33(planDir, SLICE_LAYOUT);
16723
+ const layoutPath = join36(planDir, SLICE_LAYOUT);
16355
16724
  if (!existsSync23(layoutPath)) return resolvePlanAudioPath(planDir);
16356
16725
  const layout = JSON.parse(readFileSync9(layoutPath, "utf-8"));
16357
- const frame = readFileSync9(join33(planDir, SLICE_FRAME));
16726
+ const frame = readFileSync9(join36(planDir, SLICE_FRAME));
16358
16727
  const fd = openSync5(scratchPath, "w");
16359
16728
  try {
16360
16729
  writeSync(fd, frame, 0, layout.payloadStart, 0);
@@ -16367,7 +16736,7 @@ function chunkAudioSource(planDir, chunkIndex, scratchPath) {
16367
16736
  );
16368
16737
  const start = layout.partStarts[chunkIndex];
16369
16738
  if (start !== void 0) {
16370
- const part = readFileSync9(join33(planDir, chunkAudioSlicePath(chunkIndex)));
16739
+ const part = readFileSync9(join36(planDir, chunkAudioSlicePath(chunkIndex)));
16371
16740
  writeSync(fd, part, 0, part.length, start);
16372
16741
  }
16373
16742
  ftruncateSync(fd, layout.sizeBytes);
@@ -16422,8 +16791,8 @@ async function muxChunkWithAudio(input) {
16422
16791
 
16423
16792
  // ../producer/src/services/distributed/planSize.ts
16424
16793
  import { createHash as createHash7 } from "crypto";
16425
- import { lstatSync as lstatSync2, readdirSync as readdirSync8 } from "fs";
16426
- import { extname as extname5, join as join34, relative as relative4 } from "path";
16794
+ import { lstatSync as lstatSync2, readdirSync as readdirSync9 } from "fs";
16795
+ import { extname as extname5, join as join37, relative as relative4 } from "path";
16427
16796
  var MAX_TOP_COMPONENTS = 10;
16428
16797
  var SOURCE_MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
16429
16798
  ".aac",
@@ -16530,12 +16899,12 @@ function recordFile(result, components, rootDir, rootKind, filePath) {
16530
16899
  function walkRegularFiles(dir, visit) {
16531
16900
  let entries;
16532
16901
  try {
16533
- entries = readdirSync8(dir, { withFileTypes: true });
16902
+ entries = readdirSync9(dir, { withFileTypes: true });
16534
16903
  } catch {
16535
16904
  return;
16536
16905
  }
16537
16906
  for (const entry of entries) {
16538
- const full = join34(dir, entry.name);
16907
+ const full = join37(dir, entry.name);
16539
16908
  if (entry.isDirectory()) {
16540
16909
  walkRegularFiles(full, visit);
16541
16910
  } else if (entry.isFile()) {
@@ -16747,13 +17116,13 @@ function assertPositiveInteger2(name, value) {
16747
17116
  }
16748
17117
  var FREEZE_OWNED_PLAN_FILES = [
16749
17118
  "plan.json",
16750
- join35("meta", "composition.json"),
16751
- join35("meta", "encoder.json"),
16752
- join35("meta", "chunks.json")
17119
+ join38("meta", "composition.json"),
17120
+ join38("meta", "encoder.json"),
17121
+ join38("meta", "chunks.json")
16753
17122
  ];
16754
17123
  function removeFreezeOwnedPlanFiles(planDir) {
16755
17124
  for (const relativePath of FREEZE_OWNED_PLAN_FILES) {
16756
- rmSync10(join35(planDir, relativePath), { force: true });
17125
+ rmSync12(join38(planDir, relativePath), { force: true });
16757
17126
  }
16758
17127
  }
16759
17128
  function buildChunkSlices(totalFrames, chunkCount, effectiveChunkSize) {
@@ -16908,19 +17277,19 @@ function createVideoSourceShipper(input) {
16908
17277
  const known = shipped.get(srcPath);
16909
17278
  if (known) return known;
16910
17279
  const stagedRel = pathInside(input.workVideoFramesDir, srcPath);
16911
- const current = stagedRel === null ? srcPath : join35(input.planDir, "video-frames", stagedRel);
17280
+ const current = stagedRel === null ? srcPath : join38(input.planDir, "video-frames", stagedRel);
16912
17281
  let result = null;
16913
17282
  for (const root of stagedRel === null ? [input.workCompiledDir, input.projectDir] : []) {
16914
17283
  const rel = pathInside(root, srcPath);
16915
- if (rel !== null && (existsSync24(join35(input.planDir, "compiled", rel)) || input.isRemote(srcPath))) {
17284
+ if (rel !== null && (existsSync24(join38(input.planDir, "compiled", rel)) || input.isRemote(srcPath))) {
16916
17285
  result = ["compiled", ...rel.split(sep2)].join("/");
16917
17286
  break;
16918
17287
  }
16919
17288
  }
16920
17289
  if (result === null) {
16921
17290
  result = `video-sources/${shipped.size}${extname6(current)}`;
16922
- const destination = join35(input.planDir, ...result.split("/"));
16923
- mkdirSync12(join35(input.planDir, "video-sources"), { recursive: true });
17291
+ const destination = join38(input.planDir, ...result.split("/"));
17292
+ mkdirSync14(join38(input.planDir, "video-sources"), { recursive: true });
16924
17293
  try {
16925
17294
  linkSync(current, destination);
16926
17295
  } catch {
@@ -16940,7 +17309,7 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
16940
17309
  useGpu: false,
16941
17310
  browserGpuMode: "software"
16942
17311
  });
16943
- if (!existsSync24(planDir)) mkdirSync12(planDir, { recursive: true });
17312
+ if (!existsSync24(planDir)) mkdirSync14(planDir, { recursive: true });
16944
17313
  const log = config.logger ?? defaultLogger;
16945
17314
  const sizeLimitBytes = options.executionPlanSizeLimitBytes ?? config.planDirSizeLimitBytes ?? PLAN_DIR_SIZE_LIMIT_BYTES;
16946
17315
  const abortSignal = config.abortSignal;
@@ -16969,15 +17338,15 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
16969
17338
  variables: config.variables
16970
17339
  });
16971
17340
  const entryFile = config.entryFile ?? "index.html";
16972
- const htmlPath = join35(projectDir, entryFile);
17341
+ const htmlPath = join38(projectDir, entryFile);
16973
17342
  if (!existsSync24(htmlPath)) {
16974
17343
  throw new Error(`[plan] entry file not found: ${htmlPath}`);
16975
17344
  }
16976
- const workDir = join35(planDir, ".plan-work");
16977
- rmSync10(workDir, { recursive: true, force: true });
16978
- mkdirSync12(workDir, { recursive: true });
16979
- const compiledDir = join35(workDir, "compiled");
16980
- mkdirSync12(compiledDir, { recursive: true });
17345
+ const workDir = join38(planDir, ".plan-work");
17346
+ rmSync12(workDir, { recursive: true, force: true });
17347
+ mkdirSync14(workDir, { recursive: true });
17348
+ const compiledDir = join38(workDir, "compiled");
17349
+ mkdirSync14(compiledDir, { recursive: true });
16981
17350
  let stageStarted = Date.now();
16982
17351
  cpSync2(projectDir, compiledDir, {
16983
17352
  recursive: true,
@@ -16990,10 +17359,10 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
16990
17359
  }
16991
17360
  });
16992
17361
  logPlanStage(log, "copy", stageStarted);
16993
- const finalCompiledDir = join35(planDir, "compiled");
17362
+ const finalCompiledDir = join38(planDir, "compiled");
16994
17363
  const needsAlpha = outputNeedsAlpha(config.format);
16995
17364
  const remoteFiles = Object.entries(options.remoteFiles ?? {});
16996
- const remoteLocalPath = (rel) => join35(projectDir, ...rel.split("/"));
17365
+ const remoteLocalPath = (rel) => join38(projectDir, ...rel.split("/"));
16997
17366
  for (const [, file] of remoteFiles) {
16998
17367
  declareContentAddressedUrl(file.url, file.sha256);
16999
17368
  if (file.probeFactsUrl) declareProbeFactsUrl(file.url, file.probeFactsUrl);
@@ -17089,7 +17458,7 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
17089
17458
  if (probeResult.fileServer) closeFileServerSafely(probeResult.fileServer, "plan", log);
17090
17459
  if (probeResult.probeSession) {
17091
17460
  try {
17092
- const { closeCaptureSession: closeCaptureSession2 } = await import("./src-272JLFKW.js");
17461
+ const { closeCaptureSession: closeCaptureSession2 } = await import("./src-4HGQRHW6.js");
17093
17462
  await closeCaptureSession2(probeResult.probeSession);
17094
17463
  } catch (err) {
17095
17464
  log.warn("[plan] probe session close failed", {
@@ -17196,17 +17565,17 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
17196
17565
  let stageStarted = Date.now();
17197
17566
  const extractResult = await extractPlanVideos(c, options.deferVideoExtraction);
17198
17567
  logPlanStage(log, "extract", stageStarted);
17199
- const stagedVideoFrames = join35(compiledDir, "__hyperframes_video_frames");
17200
- const videoFramesDst = join35(planDir, "video-frames");
17201
- if (existsSync24(videoFramesDst)) rmSync10(videoFramesDst, { recursive: true, force: true });
17202
- const videoSourcesDir = join35(planDir, "video-sources");
17203
- rmSync10(videoSourcesDir, { recursive: true, force: true });
17568
+ const stagedVideoFrames = join38(compiledDir, "__hyperframes_video_frames");
17569
+ const videoFramesDst = join38(planDir, "video-frames");
17570
+ if (existsSync24(videoFramesDst)) rmSync12(videoFramesDst, { recursive: true, force: true });
17571
+ const videoSourcesDir = join38(planDir, "video-sources");
17572
+ rmSync12(videoSourcesDir, { recursive: true, force: true });
17204
17573
  if (existsSync24(stagedVideoFrames)) {
17205
17574
  renameWithRetry(stagedVideoFrames, videoFramesDst);
17206
17575
  } else {
17207
- mkdirSync12(videoFramesDst, { recursive: true });
17576
+ mkdirSync14(videoFramesDst, { recursive: true });
17208
17577
  }
17209
- if (existsSync24(finalCompiledDir)) rmSync10(finalCompiledDir, { recursive: true, force: true });
17578
+ if (existsSync24(finalCompiledDir)) rmSync12(finalCompiledDir, { recursive: true, force: true });
17210
17579
  renameWithRetry(compiledDir, finalCompiledDir);
17211
17580
  const shipVideoSource = createVideoSourceShipper({
17212
17581
  planDir,
@@ -17236,7 +17605,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
17236
17605
  };
17237
17606
  })
17238
17607
  });
17239
- mkdirSync12(join35(planDir, "meta"), { recursive: true });
17608
+ mkdirSync14(join38(planDir, "meta"), { recursive: true });
17240
17609
  writePlanRemoteFiles(
17241
17610
  planDir,
17242
17611
  remoteFiles.map(([rel, { sha256, sizeBytes }]) => ({
@@ -17246,7 +17615,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
17246
17615
  }))
17247
17616
  );
17248
17617
  writeFileSync9(
17249
- join35(planDir, PLAN_VIDEOS_META_RELATIVE_PATH),
17618
+ join38(planDir, PLAN_VIDEOS_META_RELATIVE_PATH),
17250
17619
  JSON.stringify(planVideosJson, null, 2),
17251
17620
  "utf-8"
17252
17621
  );
@@ -17325,7 +17694,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
17325
17694
  if (audioResult?.audioError) {
17326
17695
  applyDistributedAudioWarningPolicy(job, audioResult.audioError, audioResult.audioFailures, log);
17327
17696
  }
17328
- const planAudioPath = join35(planDir, PLAN_AUDIO_RELATIVE_PATH);
17697
+ const planAudioPath = join38(planDir, PLAN_AUDIO_RELATIVE_PATH);
17329
17698
  if (audioResult?.hasAudio && existsSync24(audioResult.audioOutputPath)) {
17330
17699
  renameWithRetry(audioResult.audioOutputPath, planAudioPath);
17331
17700
  }
@@ -17375,7 +17744,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
17375
17744
  format: config.format
17376
17745
  };
17377
17746
  try {
17378
- rmSync10(workDir, { recursive: true, force: true });
17747
+ rmSync12(workDir, { recursive: true, force: true });
17379
17748
  } catch (err) {
17380
17749
  log.warn("[plan] failed to remove temp work dir", {
17381
17750
  workDir,
@@ -17447,38 +17816,38 @@ async function plan(projectDir, config, planDir, options = {}) {
17447
17816
 
17448
17817
  // ../producer/src/services/distributed/renderChunk.ts
17449
17818
  import { randomBytes } from "crypto";
17450
- import { existsSync as existsSync27, mkdirSync as mkdirSync15, readFileSync as readFileSync11, readdirSync as readdirSync10, rmSync as rmSync13, writeFileSync as writeFileSync12 } from "fs";
17819
+ import { existsSync as existsSync27, mkdirSync as mkdirSync17, readFileSync as readFileSync11, readdirSync as readdirSync11, rmSync as rmSync15, writeFileSync as writeFileSync12 } from "fs";
17451
17820
  import { cpus as cpus3 } from "os";
17452
- import { join as join39 } from "path";
17821
+ import { join as join42 } from "path";
17453
17822
 
17454
17823
  // ../producer/src/services/distributed/planV2.ts
17455
17824
  import {
17456
17825
  copyFileSync as copyFileSync6,
17457
17826
  existsSync as existsSync26,
17458
17827
  lstatSync as lstatSync3,
17459
- mkdirSync as mkdirSync14,
17828
+ mkdirSync as mkdirSync16,
17460
17829
  mkdtempSync as mkdtempSync6,
17461
17830
  readFileSync as readFileSync10,
17462
- readdirSync as readdirSync9,
17463
- rmSync as rmSync12,
17464
- statSync as statSync8,
17831
+ readdirSync as readdirSync10,
17832
+ rmSync as rmSync14,
17833
+ statSync as statSync9,
17465
17834
  writeFileSync as writeFileSync11
17466
17835
  } from "fs";
17467
17836
  import { tmpdir as tmpdir3 } from "os";
17468
- import { dirname as dirname14, isAbsolute as isAbsolute3, join as join38, relative as relative6, resolve as resolve8, sep as sep3 } from "path";
17837
+ import { dirname as dirname15, isAbsolute as isAbsolute3, join as join41, relative as relative6, resolve as resolve8, sep as sep3 } from "path";
17469
17838
 
17470
17839
  // ../producer/src/services/distributed/planV2Publisher.ts
17471
17840
  import {
17472
17841
  copyFileSync as copyFileSync5,
17473
17842
  existsSync as existsSync25,
17474
17843
  linkSync as linkSync2,
17475
- mkdirSync as mkdirSync13,
17844
+ mkdirSync as mkdirSync15,
17476
17845
  mkdtempSync as mkdtempSync5,
17477
- rmSync as rmSync11,
17478
- statSync as statSync7,
17846
+ rmSync as rmSync13,
17847
+ statSync as statSync8,
17479
17848
  writeFileSync as writeFileSync10
17480
17849
  } from "fs";
17481
- import { dirname as dirname13, join as join37 } from "path";
17850
+ import { dirname as dirname14, join as join40 } from "path";
17482
17851
 
17483
17852
  // ../producer/src/services/distributed/planV2Errors.ts
17484
17853
  var PLAN_V2_INTEGRITY_UNRECOVERABLE = "PLAN_V2_INTEGRITY_UNRECOVERABLE";
@@ -17493,7 +17862,7 @@ var PlanV2IntegrityError = class extends Error {
17493
17862
  };
17494
17863
 
17495
17864
  // ../producer/src/services/distributed/planV2Layout.ts
17496
- import { join as join36 } from "path";
17865
+ import { join as join39 } from "path";
17497
17866
  var SHA256_PATTERN = /^[0-9a-f]{64}$/;
17498
17867
  function assertPlanV2Sha256(value, field) {
17499
17868
  if (typeof value !== "string" || !SHA256_PATTERN.test(value)) {
@@ -17503,7 +17872,7 @@ function assertPlanV2Sha256(value, field) {
17503
17872
  }
17504
17873
  function planV2BlobPath(root, sha256) {
17505
17874
  const digest = assertPlanV2Sha256(sha256, "artifact sha256");
17506
- return join36(root, "artifacts", "sha256", digest.slice(0, 2), digest);
17875
+ return join39(root, "artifacts", "sha256", digest.slice(0, 2), digest);
17507
17876
  }
17508
17877
 
17509
17878
  // ../producer/src/services/distributed/planV2Publisher.ts
@@ -17543,12 +17912,12 @@ var LocalPlanV2ArtifactPublisher = class {
17543
17912
  }
17544
17913
  this.destinationDir = destinationDir;
17545
17914
  this.#linkFile = options.linkFile ?? linkSync2;
17546
- mkdirSync13(dirname13(destinationDir), { recursive: true });
17547
- this.temporaryDir = mkdtempSync5(join37(dirname13(destinationDir), ".plan-v2-publish-"));
17915
+ mkdirSync15(dirname14(destinationDir), { recursive: true });
17916
+ this.temporaryDir = mkdtempSync5(join40(dirname14(destinationDir), ".plan-v2-publish-"));
17548
17917
  }
17549
17918
  async putBlob(blob) {
17550
17919
  const digest = assertPlanV2Sha256(blob.sha256, "published blob sha256");
17551
- const sourceSize = statSync7(blob.sourcePath).size;
17920
+ const sourceSize = statSync8(blob.sourcePath).size;
17552
17921
  if (sourceSize !== blob.sizeBytes) {
17553
17922
  throw new PlanV2IntegrityError(
17554
17923
  `published blob size changed for ${digest}: expected ${blob.sizeBytes}, got ${sourceSize}`
@@ -17556,9 +17925,9 @@ var LocalPlanV2ArtifactPublisher = class {
17556
17925
  }
17557
17926
  const destinationPath = planV2BlobPath(this.temporaryDir, digest);
17558
17927
  if (existsSync25(destinationPath)) return;
17559
- mkdirSync13(dirname13(destinationPath), { recursive: true });
17560
- const stagingDir = mkdtempSync5(join37(dirname13(destinationPath), ".plan-v2-blob-"));
17561
- const temporaryPath = join37(stagingDir, "blob");
17928
+ mkdirSync15(dirname14(destinationPath), { recursive: true });
17929
+ const stagingDir = mkdtempSync5(join40(dirname14(destinationPath), ".plan-v2-blob-"));
17930
+ const temporaryPath = join40(stagingDir, "blob");
17562
17931
  try {
17563
17932
  try {
17564
17933
  this.#linkFile(blob.sourcePath, temporaryPath);
@@ -17568,7 +17937,7 @@ var LocalPlanV2ArtifactPublisher = class {
17568
17937
  }
17569
17938
  renameWithRetry(temporaryPath, destinationPath);
17570
17939
  } finally {
17571
- rmSync11(stagingDir, { recursive: true, force: true });
17940
+ rmSync13(stagingDir, { recursive: true, force: true });
17572
17941
  }
17573
17942
  }
17574
17943
  async commitManifest(manifestBytes) {
@@ -17579,13 +17948,13 @@ var LocalPlanV2ArtifactPublisher = class {
17579
17948
  );
17580
17949
  }
17581
17950
  }
17582
- writeFileSync10(join37(this.temporaryDir, "plan.json"), manifestBytes, "utf-8");
17951
+ writeFileSync10(join40(this.temporaryDir, "plan.json"), manifestBytes, "utf-8");
17583
17952
  renameWithRetry(this.temporaryDir, this.destinationDir);
17584
17953
  this.#committed = true;
17585
17954
  }
17586
17955
  async abort() {
17587
17956
  if (!this.#committed) {
17588
- rmSync11(this.temporaryDir, { recursive: true, force: true });
17957
+ rmSync13(this.temporaryDir, { recursive: true, force: true });
17589
17958
  }
17590
17959
  }
17591
17960
  };
@@ -17623,8 +17992,8 @@ function listFiles(root) {
17623
17992
  const files = [];
17624
17993
  const rootResolved = resolve8(root);
17625
17994
  function walk(dir) {
17626
- for (const entry of readdirSync9(dir, { withFileTypes: true })) {
17627
- const absolutePath = join38(dir, entry.name);
17995
+ for (const entry of readdirSync10(dir, { withFileTypes: true })) {
17996
+ const absolutePath = join41(dir, entry.name);
17628
17997
  if (entry.isDirectory()) {
17629
17998
  walk(absolutePath);
17630
17999
  } else if (entry.isFile()) {
@@ -17651,13 +18020,13 @@ function assertValidExtractionCacheCompleteSentinel(path) {
17651
18020
  }
17652
18021
  }
17653
18022
  function validateExtractionCacheCompleteSentinels(executionPlanDir) {
17654
- const videoRoot = join38(executionPlanDir, "video-frames");
18023
+ const videoRoot = join41(executionPlanDir, "video-frames");
17655
18024
  if (!existsSync26(videoRoot)) return;
17656
- for (const videoEntry of readdirSync9(videoRoot, { withFileTypes: true })) {
18025
+ for (const videoEntry of readdirSync10(videoRoot, { withFileTypes: true })) {
17657
18026
  if (!videoEntry.isDirectory()) continue;
17658
- const videoDir = join38(videoRoot, videoEntry.name);
17659
- if (readdirSync9(videoDir).includes(EXTRACTION_CACHE_COMPLETE_SENTINEL)) {
17660
- const sentinelPath = join38(videoDir, EXTRACTION_CACHE_COMPLETE_SENTINEL);
18027
+ const videoDir = join41(videoRoot, videoEntry.name);
18028
+ if (readdirSync10(videoDir).includes(EXTRACTION_CACHE_COMPLETE_SENTINEL)) {
18029
+ const sentinelPath = join41(videoDir, EXTRACTION_CACHE_COMPLETE_SENTINEL);
17661
18030
  assertValidExtractionCacheCompleteSentinel(sentinelPath);
17662
18031
  }
17663
18032
  }
@@ -17704,15 +18073,15 @@ function listVideoFramePaths(executionPlanDir, videos) {
17704
18073
  if (video.deferredRange) {
17705
18074
  const framePaths2 = /* @__PURE__ */ new Map();
17706
18075
  for (let index = 0; index < video.totalFrames; index++) {
17707
- framePaths2.set(index, join38(outputDir, String(index)));
18076
+ framePaths2.set(index, join41(outputDir, String(index)));
17708
18077
  }
17709
18078
  return { ...video, outputDir, framePaths: framePaths2, ownedByLookup: false };
17710
18079
  }
17711
- const frameNames = readdirSync9(outputDir).sort();
18080
+ const frameNames = readdirSync10(outputDir).sort();
17712
18081
  const framePaths = /* @__PURE__ */ new Map();
17713
18082
  for (const frameName of frameNames) {
17714
18083
  if (frameName === EXTRACTION_CACHE_COMPLETE_SENTINEL) {
17715
- assertValidExtractionCacheCompleteSentinel(join38(outputDir, frameName));
18084
+ assertValidExtractionCacheCompleteSentinel(join41(outputDir, frameName));
17716
18085
  continue;
17717
18086
  }
17718
18087
  const match = /(\d+)(?=\.[^.]+$)/.exec(frameName);
@@ -17731,7 +18100,7 @@ function listVideoFramePaths(executionPlanDir, videos) {
17731
18100
  `duplicate extracted frame index ${frameIndex} in ${outputDir}`
17732
18101
  );
17733
18102
  }
17734
- framePaths.set(frameIndex, join38(outputDir, frameName));
18103
+ framePaths.set(frameIndex, join41(outputDir, frameName));
17735
18104
  }
17736
18105
  return {
17737
18106
  ...video,
@@ -17752,11 +18121,11 @@ function parsePlanVideosJson2(value) {
17752
18121
  }
17753
18122
  }
17754
18123
  function materializeExtractedVideoDirectories(planDir) {
17755
- const videosPath = join38(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
18124
+ const videosPath = join41(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
17756
18125
  if (!existsSync26(videosPath)) return;
17757
18126
  const videos = parsePlanVideosJson2(readJsonFile(videosPath, PLAN_VIDEOS_META_RELATIVE_PATH));
17758
18127
  for (const video of videos.extracted) {
17759
- mkdirSync14(resolveExtractedVideoOutputDir(planDir, video.videoId), { recursive: true });
18128
+ mkdirSync16(resolveExtractedVideoOutputDir(planDir, video.videoId), { recursive: true });
17760
18129
  }
17761
18130
  }
17762
18131
  function parseChunkSlices(value) {
@@ -17786,13 +18155,13 @@ function parseChunkSlices(value) {
17786
18155
  });
17787
18156
  }
17788
18157
  function buildVideoChunkDependencies(executionPlanDir, dimensions) {
17789
- const videoRoot = join38(executionPlanDir, "video-frames");
18158
+ const videoRoot = join41(executionPlanDir, "video-frames");
17790
18159
  const hasExtractedFrames = existsSync26(videoRoot) && listFiles(videoRoot).length > 0;
17791
- const videosPath = join38(executionPlanDir, PLAN_VIDEOS_META_RELATIVE_PATH);
18160
+ const videosPath = join41(executionPlanDir, PLAN_VIDEOS_META_RELATIVE_PATH);
17792
18161
  if (!existsSync26(videosPath)) {
17793
18162
  return hasExtractedFrames ? { mode: "full-source-pack", dependencies: null } : { mode: "exact-rendered-frames", dependencies: /* @__PURE__ */ new Map() };
17794
18163
  }
17795
- const chunksPath = join38(executionPlanDir, "meta", "chunks.json");
18164
+ const chunksPath = join41(executionPlanDir, "meta", "chunks.json");
17796
18165
  const videos = readJsonFile(videosPath, PLAN_VIDEOS_META_RELATIVE_PATH);
17797
18166
  const chunks = readJsonFile(chunksPath, "meta/chunks.json");
17798
18167
  const parsedVideos = parsePlanVideosJson2(videos);
@@ -17847,21 +18216,21 @@ function computeManifestHash(manifest) {
17847
18216
  }
17848
18217
  function writeBlob(sourcePath, destinationPath) {
17849
18218
  if (existsSync26(destinationPath)) return;
17850
- mkdirSync14(dirname14(destinationPath), { recursive: true });
17851
- const temporaryDir = mkdtempSync6(join38(dirname14(destinationPath), ".plan-v2-blob-"));
17852
- const temporaryPath = join38(temporaryDir, "blob");
18219
+ mkdirSync16(dirname15(destinationPath), { recursive: true });
18220
+ const temporaryDir = mkdtempSync6(join41(dirname15(destinationPath), ".plan-v2-blob-"));
18221
+ const temporaryPath = join41(temporaryDir, "blob");
17853
18222
  try {
17854
18223
  copyFileSync6(sourcePath, temporaryPath);
17855
18224
  renameWithRetry(temporaryPath, destinationPath);
17856
18225
  } finally {
17857
- rmSync12(temporaryDir, { recursive: true, force: true });
18226
+ rmSync14(temporaryDir, { recursive: true, force: true });
17858
18227
  }
17859
18228
  }
17860
18229
  function publishBlobFor(absolutePath, digests) {
17861
18230
  return {
17862
18231
  sourcePath: absolutePath,
17863
18232
  sha256: planFileSha256(absolutePath, digests),
17864
- sizeBytes: statSync8(absolutePath).size
18233
+ sizeBytes: statSync9(absolutePath).size
17865
18234
  };
17866
18235
  }
17867
18236
  async function putBlobs(publisher, blobs) {
@@ -17885,7 +18254,7 @@ async function putTasks(tasks) {
17885
18254
  if (failure) throw failure.reason;
17886
18255
  }
17887
18256
  function buildPlanV2Publication(executionPlanDir, digests) {
17888
- const executionPlanPath = join38(executionPlanDir, "plan.json");
18257
+ const executionPlanPath = join41(executionPlanDir, "plan.json");
17889
18258
  if (!existsSync26(executionPlanPath)) {
17890
18259
  throw new PlanV2IntegrityError(`execution plan is missing plan.json: ${executionPlanPath}`);
17891
18260
  }
@@ -17913,7 +18282,7 @@ function buildPlanV2Publication(executionPlanDir, digests) {
17913
18282
  }
17914
18283
  validateExtractionCacheCompleteSentinels(executionPlanDir);
17915
18284
  const videoDependencyPlan = buildVideoChunkDependencies(executionPlanDir, dimensions);
17916
- const encoder = readJsonFile(join38(executionPlanDir, "meta", "encoder.json"), "meta/encoder.json");
18285
+ const encoder = readJsonFile(join41(executionPlanDir, "meta", "encoder.json"), "meta/encoder.json");
17917
18286
  const files = listFiles(executionPlanDir);
17918
18287
  const chunkAudio = !isRecord3(encoder) || encoder.chunksCarryAudio !== true ? "none" : files.some((file) => chunkAudioSliceTarget(file.path) !== null) ? "sliced" : "whole";
17919
18288
  for (const file of files) {
@@ -17973,21 +18342,21 @@ function createPlanV2FromExecutionPlan(executionPlanDir, planV2Dir) {
17973
18342
  if (publication.storedBlobs.length > 0) {
17974
18343
  throw new PlanV2IntegrityError("a local plan v2 directory cannot reference remote files");
17975
18344
  }
17976
- mkdirSync14(dirname14(planV2Dir), { recursive: true });
17977
- const tempDir = mkdtempSync6(join38(dirname14(planV2Dir), ".plan-v2-build-"));
18345
+ mkdirSync16(dirname15(planV2Dir), { recursive: true });
18346
+ const tempDir = mkdtempSync6(join41(dirname15(planV2Dir), ".plan-v2-build-"));
17978
18347
  try {
17979
18348
  for (const blob of publication.blobs) {
17980
18349
  writeBlob(blob.sourcePath, planV2BlobPath(tempDir, blob.sha256));
17981
18350
  }
17982
18351
  writeFileSync11(
17983
- join38(tempDir, "plan.json"),
18352
+ join41(tempDir, "plan.json"),
17984
18353
  canonicalJsonStringify(publication.manifest),
17985
18354
  "utf-8"
17986
18355
  );
17987
18356
  renameWithRetry(tempDir, planV2Dir);
17988
18357
  return resultFromManifest(planV2Dir, publication.manifest);
17989
18358
  } catch (error) {
17990
- rmSync12(tempDir, { recursive: true, force: true });
18359
+ rmSync14(tempDir, { recursive: true, force: true });
17991
18360
  throw error;
17992
18361
  }
17993
18362
  }
@@ -18021,7 +18390,7 @@ async function publishExecutionPlan(executionPlanDir, publisher, { digests, log
18021
18390
  }
18022
18391
  }
18023
18392
  async function planV2WithPublisher(projectDir, config, publisher, options = {}) {
18024
- const stagingRoot = mkdtempSync6(join38(options.stagingParentDir ?? tmpdir3(), ".execution-plan-"));
18393
+ const stagingRoot = mkdtempSync6(join41(options.stagingParentDir ?? tmpdir3(), ".execution-plan-"));
18025
18394
  const digests = /* @__PURE__ */ new Map();
18026
18395
  try {
18027
18396
  await buildLocalExecutionPlan(projectDir, config, stagingRoot, {
@@ -18032,7 +18401,7 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
18032
18401
  // artifactTargets ships every compiled/ file to all chunks, so each is in the manifest.
18033
18402
  whileAudioMixes: () => putBlobs(
18034
18403
  publisher,
18035
- listFiles(join38(stagingRoot, "compiled")).map(
18404
+ listFiles(join41(stagingRoot, "compiled")).map(
18036
18405
  (file) => publishBlobFor(file.absolutePath, digests)
18037
18406
  )
18038
18407
  ),
@@ -18048,7 +18417,7 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
18048
18417
  }
18049
18418
  throw error;
18050
18419
  } finally {
18051
- rmSync12(stagingRoot, { recursive: true, force: true });
18420
+ rmSync14(stagingRoot, { recursive: true, force: true });
18052
18421
  }
18053
18422
  }
18054
18423
  async function planV2(projectDir, config, planV2Dir) {
@@ -18057,7 +18426,7 @@ async function planV2(projectDir, config, planV2Dir) {
18057
18426
  }
18058
18427
  const publisher = new LocalPlanV2ArtifactPublisher(planV2Dir);
18059
18428
  const manifest = await planV2WithPublisher(projectDir, config, publisher, {
18060
- stagingParentDir: dirname14(planV2Dir)
18429
+ stagingParentDir: dirname15(planV2Dir)
18061
18430
  });
18062
18431
  return resultFromManifest(planV2Dir, manifest);
18063
18432
  }
@@ -18069,7 +18438,7 @@ function resultFromManifest(planV2Dir, manifest) {
18069
18438
  isRecord3(executionPlan) ? executionPlan[REFERENCE_BACKGROUND_FIELD] : void 0
18070
18439
  ),
18071
18440
  planDir: planV2Dir,
18072
- manifestPath: join38(planV2Dir, "plan.json"),
18441
+ manifestPath: join41(planV2Dir, "plan.json"),
18073
18442
  planProtocol: PLAN_PROTOCOL_V2,
18074
18443
  planHash: manifest.planHash,
18075
18444
  sourcePlanV1Hash: getPlanV2ExecutionPlanHash(manifest),
@@ -18205,7 +18574,7 @@ function parsePlanV2Manifest(value) {
18205
18574
  return parsed;
18206
18575
  }
18207
18576
  function readPlanV2Manifest(planV2Dir) {
18208
- const manifestPath = join38(planV2Dir, "plan.json");
18577
+ const manifestPath = join41(planV2Dir, "plan.json");
18209
18578
  if (!existsSync26(manifestPath)) {
18210
18579
  throw new PlanV2IntegrityError(`missing v2 manifest: ${manifestPath}`);
18211
18580
  }
@@ -18228,7 +18597,7 @@ function verifyBlob(planV2Dir, artifact) {
18228
18597
  if (!existsSync26(sourcePath)) {
18229
18598
  throw new PlanV2IntegrityError(`missing content-addressed artifact ${artifact.sha256}`);
18230
18599
  }
18231
- const stats = statSync8(sourcePath);
18600
+ const stats = statSync9(sourcePath);
18232
18601
  if (!stats.isFile() || stats.size !== artifact.sizeBytes) {
18233
18602
  throw new PlanV2IntegrityError(`artifact size mismatch for ${artifact.path}`);
18234
18603
  }
@@ -18250,17 +18619,17 @@ function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}
18250
18619
  artifact,
18251
18620
  sourcePath: verifyBlob(planV2Dir, artifact)
18252
18621
  }));
18253
- mkdirSync14(dirname14(destinationDir), { recursive: true });
18254
- const tempDir = mkdtempSync6(join38(dirname14(destinationDir), ".plan-v2-materialize-"));
18622
+ mkdirSync16(dirname15(destinationDir), { recursive: true });
18623
+ const tempDir = mkdtempSync6(join41(dirname15(destinationDir), ".plan-v2-materialize-"));
18255
18624
  try {
18256
18625
  for (const { artifact, sourcePath } of verified) {
18257
- const destinationPath = join38(tempDir, ...artifact.path.split("/"));
18258
- mkdirSync14(dirname14(destinationPath), { recursive: true });
18626
+ const destinationPath = join41(tempDir, ...artifact.path.split("/"));
18627
+ mkdirSync16(dirname15(destinationPath), { recursive: true });
18259
18628
  copyFileSync6(sourcePath, destinationPath);
18260
18629
  }
18261
18630
  if (target.role === "chunk") materializeExtractedVideoDirectories(tempDir);
18262
18631
  writeFileSync11(
18263
- join38(tempDir, PLAN_V2_MATERIALIZATION_MARKER),
18632
+ join41(tempDir, PLAN_V2_MATERIALIZATION_MARKER),
18264
18633
  canonicalJsonStringify({
18265
18634
  manifest,
18266
18635
  target,
@@ -18270,7 +18639,7 @@ function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}
18270
18639
  );
18271
18640
  renameWithRetry(tempDir, destinationDir);
18272
18641
  } catch (error) {
18273
- rmSync12(tempDir, { recursive: true, force: true });
18642
+ rmSync14(tempDir, { recursive: true, force: true });
18274
18643
  throw error;
18275
18644
  }
18276
18645
  return {
@@ -18283,7 +18652,7 @@ function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}
18283
18652
  // Join the artifact's OWN name, not the current constant: a plan written
18284
18653
  // before the container change carries the legacy name, and materializing it
18285
18654
  // under the new one would point at a file that was never written.
18286
- audioPath: target.role === "assembler" ? audioArtifact ? join38(destinationDir, audioArtifact.path) : null : null
18655
+ audioPath: target.role === "assembler" ? audioArtifact ? join41(destinationDir, audioArtifact.path) : null : null
18287
18656
  };
18288
18657
  }
18289
18658
  function assertRemoteSources(remoteSources, artifacts) {
@@ -18302,7 +18671,7 @@ function validatePlanV2MaterializedTarget(planDir, expectedTarget) {
18302
18671
  return readValidatedPlanV2Materialization(planDir, expectedTarget)?.manifest ?? null;
18303
18672
  }
18304
18673
  function readValidatedPlanV2Materialization(planDir, expectedTarget) {
18305
- const markerPath = join38(planDir, PLAN_V2_MATERIALIZATION_MARKER);
18674
+ const markerPath = join41(planDir, PLAN_V2_MATERIALIZATION_MARKER);
18306
18675
  if (!existsSync26(markerPath)) return null;
18307
18676
  const marker = readJsonFile(markerPath, "materialization marker");
18308
18677
  if (!isRecord3(marker) || !isRecord3(marker.manifest) || !isRecord3(marker.target)) {
@@ -18320,8 +18689,8 @@ function readValidatedPlanV2Materialization(planDir, expectedTarget) {
18320
18689
  assertRemoteSources(remoteSources, required);
18321
18690
  for (const artifact of required) {
18322
18691
  if (Object.hasOwn(remoteSources, artifact.path)) continue;
18323
- const path = join38(planDir, ...artifact.path.split("/"));
18324
- if (!existsSync26(path) || statSync8(path).size !== artifact.sizeBytes) {
18692
+ const path = join41(planDir, ...artifact.path.split("/"));
18693
+ if (!existsSync26(path) || statSync9(path).size !== artifact.sizeBytes) {
18325
18694
  throw new PlanV2IntegrityError(
18326
18695
  `materialized artifact missing or truncated: ${artifact.path}`
18327
18696
  );
@@ -18438,9 +18807,9 @@ async function beginFrameSessionNeedsScreenshotFallback(session, probe = probeBe
18438
18807
  }
18439
18808
  function hashChunkOutput(outputPath, kind) {
18440
18809
  if (kind === "file") return sha256Hex(readFileSync11(outputPath));
18441
- const entries = readdirSync10(outputPath).filter((name) => /\.(png|jpg|jpeg)$/i.test(name)).sort();
18810
+ const entries = readdirSync11(outputPath).filter((name) => /\.(png|jpg|jpeg)$/i.test(name)).sort();
18442
18811
  const lines = entries.map(
18443
- (name) => `${name}\0${sha256Hex(readFileSync11(join39(outputPath, name)))}`
18812
+ (name) => `${name}\0${sha256Hex(readFileSync11(join42(outputPath, name)))}`
18444
18813
  );
18445
18814
  return sha256Hex(lines.join("\0"));
18446
18815
  }
@@ -18457,9 +18826,9 @@ function resolveLockedVp9CpuUsed(lockedEncoder) {
18457
18826
  async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
18458
18827
  const start = Date.now();
18459
18828
  const log = defaultLogger;
18460
- const planJsonPath = join39(planDir, "plan.json");
18461
- const encoderJsonPath = join39(planDir, "meta", "encoder.json");
18462
- const chunksJsonPath = join39(planDir, "meta", "chunks.json");
18829
+ const planJsonPath = join42(planDir, "plan.json");
18830
+ const encoderJsonPath = join42(planDir, "meta", "encoder.json");
18831
+ const chunksJsonPath = join42(planDir, "meta", "chunks.json");
18463
18832
  if (!existsSync27(planJsonPath)) {
18464
18833
  throw new RenderChunkValidationError(
18465
18834
  MISSING_PLAN_ARTIFACT,
@@ -18485,7 +18854,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
18485
18854
  }
18486
18855
  const encoder = JSON.parse(readFileSync11(encoderJsonPath, "utf-8"));
18487
18856
  const chunks = JSON.parse(readFileSync11(chunksJsonPath, "utf-8"));
18488
- const videosJsonPath = join39(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
18857
+ const videosJsonPath = join42(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
18489
18858
  let planVideos = null;
18490
18859
  if (existsSync27(videosJsonPath)) {
18491
18860
  try {
@@ -18517,7 +18886,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
18517
18886
  }
18518
18887
  const range = resolveChunkFrameRange(slice, chunkIndex, options?.frameRange);
18519
18888
  const framesInChunk = range.endFrame - range.startFrame;
18520
- const compiledDir = join39(planDir, "compiled");
18889
+ const compiledDir = join42(planDir, "compiled");
18521
18890
  if (!existsSync27(compiledDir)) {
18522
18891
  throw new RenderChunkValidationError(
18523
18892
  MISSING_PLAN_ARTIFACT,
@@ -18574,14 +18943,14 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
18574
18943
  forceScreenshotExplicitlyOptedOut: !encoder.forceScreenshot
18575
18944
  };
18576
18945
  const workDir = `${outputChunkPath}.work.${process.pid}.${randomBytes(4).toString("hex")}`;
18577
- mkdirSync15(workDir, { recursive: true });
18578
- const framesDir = join39(workDir, "captured-frames");
18579
- mkdirSync15(framesDir, { recursive: true });
18946
+ mkdirSync17(workDir, { recursive: true });
18947
+ const framesDir = join42(workDir, "captured-frames");
18948
+ mkdirSync17(framesDir, { recursive: true });
18580
18949
  const videoFramesDir = `${workDir}.video-frames`;
18581
18950
  const chunkFrameNumbers = Array.from({ length: framesInChunk }, (_, i) => range.startFrame + i);
18582
18951
  const chunkFps = { num: plan2.dimensions.fpsNum, den: plan2.dimensions.fpsDen };
18583
18952
  const deferredVideos = planVideos?.extracted.filter((video) => video.deferredRange) ?? [];
18584
- const shownFrames = planVideos ? shownDeferredFrameIndexes(planVideos, chunkFrameNumbers, chunkFps) : /* @__PURE__ */ new Map();
18953
+ const shownFrames = planVideos ? shownPlanFrameIndexes(planVideos, chunkFrameNumbers, chunkFps) : /* @__PURE__ */ new Map();
18585
18954
  const remoteVideoIds = new Set(
18586
18955
  planVideos?.extracted.filter(
18587
18956
  (video) => video.deferredRange && Object.hasOwn(remoteSources, video.deferredRange.sourcePath)
@@ -18600,7 +18969,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
18600
18969
  dimensions: plan2.dimensions,
18601
18970
  encoder,
18602
18971
  videoCount: planVideos?.videos.length ?? 0,
18603
- html: readFileSync11(join39(compiledDir, "index.html"), "utf-8"),
18972
+ html: readFileSync11(join42(compiledDir, "index.html"), "utf-8"),
18604
18973
  // The plan ships a deferred source only to chunks that show it; don't wait on the rest.
18605
18974
  skipReadinessVideoIds: deferredVideos.filter(
18606
18975
  (video) => !shownFrames.get(video.videoId)?.size || remoteVideoIds.has(video.videoId)
@@ -18768,10 +19137,10 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
18768
19137
  const effectiveBitrate = encoder.crf != null ? void 0 : encoder.bitrate;
18769
19138
  const videoOnlyPath = encoder.chunksCarryAudio ? `${outputChunkPath}.video.mp4` : outputChunkPath;
18770
19139
  if (isPngSequence) {
18771
- if (!existsSync27(outputChunkPath)) mkdirSync15(outputChunkPath, { recursive: true });
19140
+ if (!existsSync27(outputChunkPath)) mkdirSync17(outputChunkPath, { recursive: true });
18772
19141
  } else {
18773
- const outDir = join39(outputChunkPath, "..");
18774
- if (!existsSync27(outDir)) mkdirSync15(outDir, { recursive: true });
19142
+ const outDir = join42(outputChunkPath, "..");
19143
+ if (!existsSync27(outDir)) mkdirSync17(outDir, { recursive: true });
18775
19144
  }
18776
19145
  const encodeInput = {
18777
19146
  job,
@@ -18887,9 +19256,9 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
18887
19256
  return observedChunkCaptureMode(capturePerfs);
18888
19257
  },
18889
19258
  resetForScreenshotRetry: () => {
18890
- rmSync13(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
19259
+ rmSync15(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
18891
19260
  boxesMeasured();
18892
- mkdirSync15(framesDir, { recursive: true });
19261
+ mkdirSync17(framesDir, { recursive: true });
18893
19262
  capturePerfs.length = 0;
18894
19263
  captureAttempts.length = 0;
18895
19264
  job.framesRendered = 0;
@@ -18933,8 +19302,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
18933
19302
  fps: { num: plan2.dimensions.fpsNum, den: plan2.dimensions.fpsDen },
18934
19303
  timeoutMs: cfg.ffmpegProcessTimeout
18935
19304
  });
18936
- rmSync13(videoOnlyPath, { force: true });
18937
- rmSync13(audioScratchPath, { force: true });
19305
+ rmSync15(videoOnlyPath, { force: true });
19306
+ rmSync15(audioScratchPath, { force: true });
18938
19307
  }
18939
19308
  encodeStageMs = Date.now() - encodeStarted;
18940
19309
  } finally {
@@ -18984,8 +19353,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
18984
19353
  writeFileSync12(perfPath, `${JSON.stringify(perfPayload, null, 2)}
18985
19354
  `, "utf-8");
18986
19355
  try {
18987
- rmSync13(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
18988
- rmSync13(videoFramesDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
19356
+ rmSync15(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
19357
+ rmSync15(videoFramesDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
18989
19358
  } catch (err) {
18990
19359
  log.warn("[renderChunk] failed to remove work dir", {
18991
19360
  workDir,
@@ -19044,11 +19413,11 @@ async function renderSpan(projectDir, config, span, outputPath) {
19044
19413
  if (config.cfr === true) {
19045
19414
  throw new RenderSpanUnsupportedError("--start/--end cannot be combined with a cfr re-encode.");
19046
19415
  }
19047
- const workDir = mkdtempSync7(join40(tmpdir4(), "hf-render-span-"));
19416
+ const workDir = mkdtempSync7(join43(tmpdir4(), "hf-render-span-"));
19048
19417
  try {
19049
- const planDir = join40(workDir, "plan");
19050
- const partsDir = join40(workDir, "parts");
19051
- mkdirSync16(partsDir, { recursive: true });
19418
+ const planDir = join43(workDir, "plan");
19419
+ const partsDir = join43(workDir, "parts");
19420
+ mkdirSync18(partsDir, { recursive: true });
19052
19421
  const planned = await plan(
19053
19422
  projectDir,
19054
19423
  { ...config, rejectOnSystemFonts: false, failClosedFontFetch: false },
@@ -19062,7 +19431,7 @@ async function renderSpan(projectDir, config, span, outputPath) {
19062
19431
  planned.totalFrames
19063
19432
  );
19064
19433
  const slices = JSON.parse(
19065
- readFileSync12(join40(planDir, "meta", "chunks.json"), "utf-8")
19434
+ readFileSync12(join43(planDir, "meta", "chunks.json"), "utf-8")
19066
19435
  );
19067
19436
  const parts = [];
19068
19437
  for (const slice of slices) {
@@ -19072,7 +19441,7 @@ async function renderSpan(projectDir, config, span, outputPath) {
19072
19441
  };
19073
19442
  if (range.endFrame <= range.startFrame) continue;
19074
19443
  throwIfAborted(config.abortSignal);
19075
- const part = join40(partsDir, `part-${String(parts.length).padStart(4, "0")}.mp4`);
19444
+ const part = join43(partsDir, `part-${String(parts.length).padStart(4, "0")}.mp4`);
19076
19445
  await renderChunk(planDir, slice.index, part, { frameRange: range });
19077
19446
  parts.push(part);
19078
19447
  }
@@ -19085,7 +19454,7 @@ async function renderSpan(projectDir, config, span, outputPath) {
19085
19454
  framesEncoded: endFrame - startFrame
19086
19455
  };
19087
19456
  } finally {
19088
- rmSync14(workDir, { recursive: true, force: true });
19457
+ rmSync16(workDir, { recursive: true, force: true });
19089
19458
  }
19090
19459
  }
19091
19460
 
@@ -19632,14 +20001,14 @@ function renderRequestFromDistributedConfig(input) {
19632
20001
  // ../producer/src/server.ts
19633
20002
  import {
19634
20003
  existsSync as existsSync30,
19635
- mkdirSync as mkdirSync17,
19636
- statSync as statSync10,
20004
+ mkdirSync as mkdirSync19,
20005
+ statSync as statSync11,
19637
20006
  mkdtempSync as mkdtempSync8,
19638
20007
  writeFileSync as writeFileSync13,
19639
- rmSync as rmSync15,
20008
+ rmSync as rmSync17,
19640
20009
  createReadStream as createReadStream5
19641
20010
  } from "fs";
19642
- import { resolve as resolve10, dirname as dirname16, join as join43 } from "path";
20011
+ import { resolve as resolve10, dirname as dirname17, join as join46 } from "path";
19643
20012
  import { tmpdir as tmpdir5 } from "os";
19644
20013
  import { parseArgs } from "util";
19645
20014
  import crypto from "crypto";
@@ -19651,13 +20020,13 @@ import { serve as serve2 } from "@hono/node-server";
19651
20020
  import {
19652
20021
  existsSync as existsSync28,
19653
20022
  readFileSync as readFileSync13,
19654
- statSync as statSync9,
20023
+ statSync as statSync10,
19655
20024
  openSync as openSync6,
19656
20025
  fstatSync as fstatSync3,
19657
20026
  closeSync as closeSync6,
19658
20027
  constants as constants3
19659
20028
  } from "fs";
19660
- import { resolve as resolve9, join as join41, relative as relative7, isAbsolute as isAbsolute4, sep as sep4 } from "path";
20029
+ import { resolve as resolve9, join as join44, relative as relative7, isAbsolute as isAbsolute4, sep as sep4 } from "path";
19661
20030
  function isStringRecord(value) {
19662
20031
  if (!value || typeof value !== "object" || Array.isArray(value)) {
19663
20032
  return false;
@@ -19690,7 +20059,7 @@ function readEntryHtml(filePath) {
19690
20059
  } catch (error) {
19691
20060
  if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR"))
19692
20061
  return null;
19693
- if (!statSync9(filePath, { throwIfNoEntry: false })?.isFile()) return null;
20062
+ if (!statSync10(filePath, { throwIfNoEntry: false })?.isFile()) return null;
19694
20063
  throw error;
19695
20064
  }
19696
20065
  try {
@@ -19702,7 +20071,7 @@ function readEntryHtml(filePath) {
19702
20071
  }
19703
20072
  function readProjectEntryFile(projectDir, preferredEntryFile) {
19704
20073
  const absProjectDir = resolve9(projectDir);
19705
- if (!existsSync28(absProjectDir) || !statSync9(absProjectDir).isDirectory()) {
20074
+ if (!existsSync28(absProjectDir) || !statSync10(absProjectDir).isDirectory()) {
19706
20075
  return { error: `Project directory not found: ${absProjectDir}` };
19707
20076
  }
19708
20077
  const entryCandidates = [preferredEntryFile, "index.html", "src/index.html"].filter(
@@ -19724,7 +20093,7 @@ function readProjectEntryFile(projectDir, preferredEntryFile) {
19724
20093
  }
19725
20094
  }
19726
20095
  return {
19727
- error: `No HTML entry file found in project directory: ${join41(absProjectDir, preferredEntryFile || "index.html")}`
20096
+ error: `No HTML entry file found in project directory: ${join44(absProjectDir, preferredEntryFile || "index.html")}`
19728
20097
  };
19729
20098
  }
19730
20099
  function prepareHyperframeLintBody(body) {
@@ -19770,7 +20139,7 @@ async function runHyperframeLint(prepared) {
19770
20139
  // ../producer/src/services/healthWorker.ts
19771
20140
  import { Worker as Worker2 } from "worker_threads";
19772
20141
  import { fileURLToPath as fileURLToPath6 } from "url";
19773
- import { dirname as dirname15, join as join42 } from "path";
20142
+ import { dirname as dirname16, join as join45 } from "path";
19774
20143
  import { existsSync as existsSync29 } from "fs";
19775
20144
  var DEFAULT_HEALTH_PORT = 9848;
19776
20145
  async function startHealthWorker(options = {}) {
@@ -19845,8 +20214,8 @@ function defaultLogger2() {
19845
20214
  };
19846
20215
  }
19847
20216
  function resolveWorkerEntry2() {
19848
- const here = dirname15(fileURLToPath6(import.meta.url));
19849
- const candidates = [join42(here, "healthWorkerThread.js"), join42(here, "healthWorkerThread.ts")];
20217
+ const here = dirname16(fileURLToPath6(import.meta.url));
20218
+ const candidates = [join45(here, "healthWorkerThread.js"), join45(here, "healthWorkerThread.ts")];
19850
20219
  for (const candidate of candidates) {
19851
20220
  if (existsSync29(candidate)) return candidate;
19852
20221
  }
@@ -19987,8 +20356,8 @@ function buildRenderJobConfig(input, outputPath, log) {
19987
20356
  function resolvePreparedRenderOutput(prepared, rendersDir, log) {
19988
20357
  const { input, cleanupProjectDir } = prepared;
19989
20358
  const absoluteOutputPath = resolveOutputPath(input.projectDir, input.outputPath, rendersDir, log);
19990
- const outputDir = dirname16(absoluteOutputPath);
19991
- if (!existsSync30(outputDir)) mkdirSync17(outputDir, { recursive: true });
20359
+ const outputDir = dirname17(absoluteOutputPath);
20360
+ if (!existsSync30(outputDir)) mkdirSync19(outputDir, { recursive: true });
19992
20361
  return { input, cleanupProjectDir, absoluteOutputPath };
19993
20362
  }
19994
20363
  function validateRenderOverrides(body) {
@@ -20029,7 +20398,7 @@ function prepareProjectDirectory(projectDir, options) {
20029
20398
  const candidate = nonEmptyString(projectDir);
20030
20399
  if (!candidate) return null;
20031
20400
  const absProjectDir = resolve10(candidate);
20032
- if (!existsSync30(absProjectDir) || !statSync10(absProjectDir).isDirectory()) {
20401
+ if (!existsSync30(absProjectDir) || !statSync11(absProjectDir).isDirectory()) {
20033
20402
  return { error: `Project directory not found: ${absProjectDir}` };
20034
20403
  }
20035
20404
  const entry = options.entryFile || "index.html";
@@ -20054,8 +20423,8 @@ async function resolveInlineRenderHtml(body) {
20054
20423
  }
20055
20424
  function materializeInlineProject(html, options) {
20056
20425
  const tempRoot = process.env.PRODUCER_TMP_PROJECT_DIR || tmpdir5();
20057
- const tempProjectDir = mkdtempSync8(join43(tempRoot, "producer-project-"));
20058
- writeFileSync13(join43(tempProjectDir, "index.html"), html, "utf-8");
20426
+ const tempProjectDir = mkdtempSync8(join46(tempRoot, "producer-project-"));
20427
+ writeFileSync13(join46(tempProjectDir, "index.html"), html, "utf-8");
20059
20428
  return {
20060
20429
  prepared: {
20061
20430
  input: { projectDir: tempProjectDir, ...options },
@@ -20116,7 +20485,7 @@ function createArtifactStore(ttlMs) {
20116
20485
  function cleanupTempDir(dir, log) {
20117
20486
  if (!dir) return;
20118
20487
  try {
20119
- rmSync15(dir, { recursive: true, force: true });
20488
+ rmSync17(dir, { recursive: true, force: true });
20120
20489
  } catch (error) {
20121
20490
  log.warn("Failed to cleanup temp project dir", {
20122
20491
  cleanupProjectDir: dir,
@@ -20125,7 +20494,7 @@ function cleanupTempDir(dir, log) {
20125
20494
  }
20126
20495
  }
20127
20496
  function outputFileSize(path) {
20128
- return existsSync30(path) ? statSync10(path).size : 0;
20497
+ return existsSync30(path) ? statSync11(path).size : 0;
20129
20498
  }
20130
20499
  function createBlockingProgressReporter(log, requestId) {
20131
20500
  let lastLoggedPct = -10;
@@ -20433,7 +20802,7 @@ function createRenderHandlers(options = {}) {
20433
20802
  store.delete(token);
20434
20803
  return c.json({ success: false, error: "Output artifact file missing" }, 404);
20435
20804
  }
20436
- const stats = statSync10(artifact.path);
20805
+ const stats = statSync11(artifact.path);
20437
20806
  return new Response(createReadStream5(artifact.path), {
20438
20807
  headers: {
20439
20808
  "content-type": "video/mp4",
@@ -20476,7 +20845,7 @@ function startServer(options = {}) {
20476
20845
  });
20477
20846
  async function shutdown(signal) {
20478
20847
  log.info(`Received ${signal}, shutting down`);
20479
- const { drainBrowserPool } = await import("./src-272JLFKW.js");
20848
+ const { drainBrowserPool } = await import("./src-4HGQRHW6.js");
20480
20849
  await drainBrowserPool().catch(() => {
20481
20850
  });
20482
20851
  const handle = await Promise.race([
@@ -20512,23 +20881,23 @@ if (isPublicServerEntry) {
20512
20881
  }
20513
20882
 
20514
20883
  // ../producer/src/services/distributed/planV2Execution.ts
20515
- import { mkdtempSync as mkdtempSync10, rmSync as rmSync17 } from "fs";
20884
+ import { mkdtempSync as mkdtempSync10, rmSync as rmSync19 } from "fs";
20516
20885
  import { tmpdir as tmpdir6 } from "os";
20517
- import { join as join45 } from "path";
20886
+ import { join as join48 } from "path";
20518
20887
 
20519
20888
  // ../producer/src/services/distributed/assemble.ts
20520
20889
  import {
20521
20890
  cpSync as cpSync3,
20522
20891
  existsSync as existsSync31,
20523
- mkdirSync as mkdirSync18,
20892
+ mkdirSync as mkdirSync20,
20524
20893
  mkdtempSync as mkdtempSync9,
20525
20894
  readFileSync as readFileSync14,
20526
- readdirSync as readdirSync11,
20527
- rmSync as rmSync16,
20528
- statSync as statSync11,
20895
+ readdirSync as readdirSync12,
20896
+ rmSync as rmSync18,
20897
+ statSync as statSync12,
20529
20898
  writeFileSync as writeFileSync14
20530
20899
  } from "fs";
20531
- import { dirname as dirname17, join as join44 } from "path";
20900
+ import { dirname as dirname18, join as join47 } from "path";
20532
20901
  function cfrRateControlArgs(locked) {
20533
20902
  const preset = getEncoderPreset(locked.quality ?? "standard", "mp4");
20534
20903
  if (locked.crf == null && locked.bitrate) {
@@ -20556,13 +20925,13 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
20556
20925
  outputPath,
20557
20926
  durationMs: Date.now() - start,
20558
20927
  framesEncoded: plan2.totalFrames,
20559
- fileSize: statSync11(outputPath).size
20928
+ fileSize: statSync12(outputPath).size
20560
20929
  };
20561
20930
  }
20562
20931
  const format = plan2.dimensions.format;
20563
20932
  const cfrEncoder = cfr ? readCfrEncoder(planDir, format) : null;
20564
- if (!existsSync31(dirname17(outputPath))) {
20565
- mkdirSync18(dirname17(outputPath), { recursive: true });
20933
+ if (!existsSync31(dirname18(outputPath))) {
20934
+ mkdirSync20(dirname18(outputPath), { recursive: true });
20566
20935
  }
20567
20936
  const workDir = mkdtempSync9(`${outputPath}.assemble-work-`);
20568
20937
  const fps = { num: plan2.dimensions.fpsNum, den: plan2.dimensions.fpsDen };
@@ -20584,7 +20953,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
20584
20953
  };
20585
20954
  try {
20586
20955
  const videoSources = cfrEncoder ? [await reencodeCfr(ctx, chunkPaths, cfrEncoder)] : chunkPaths;
20587
- const finalPath = join44(workDir, `output.${format}`);
20956
+ const finalPath = join47(workDir, `output.${format}`);
20588
20957
  const audio = audioPath !== null && existsSync31(audioPath) ? audioPath : null;
20589
20958
  await writeJoined(ctx, videoSources, audio, finalPath);
20590
20959
  renameWithRetry(finalPath, outputPath);
@@ -20595,7 +20964,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
20595
20964
  });
20596
20965
  } finally {
20597
20966
  try {
20598
- rmSync16(workDir, { recursive: true, force: true });
20967
+ rmSync18(workDir, { recursive: true, force: true });
20599
20968
  } catch (err) {
20600
20969
  log.warn("[assemble] failed to remove work dir", {
20601
20970
  workDir,
@@ -20603,7 +20972,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
20603
20972
  });
20604
20973
  }
20605
20974
  }
20606
- const fileSize = existsSync31(outputPath) ? statSync11(outputPath).size : 0;
20975
+ const fileSize = existsSync31(outputPath) ? statSync12(outputPath).size : 0;
20607
20976
  return {
20608
20977
  ...referenceBackgroundResult(plan2[REFERENCE_BACKGROUND_FIELD]),
20609
20978
  outputPath,
@@ -20613,8 +20982,8 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
20613
20982
  };
20614
20983
  }
20615
20984
  function readAssemblePlan(planDir, chunkPaths) {
20616
- const planJsonPath = join44(planDir, "plan.json");
20617
- const chunksJsonPath = join44(planDir, "meta", "chunks.json");
20985
+ const planJsonPath = join47(planDir, "plan.json");
20986
+ const chunksJsonPath = join47(planDir, "meta", "chunks.json");
20618
20987
  if (!existsSync31(planJsonPath)) {
20619
20988
  throw new Error(`[assemble] planDir missing plan.json: ${planJsonPath}`);
20620
20989
  }
@@ -20665,7 +21034,7 @@ function cfrEncodeArgs(inputArgs, encoder, fpsArg) {
20665
21034
  return args;
20666
21035
  }
20667
21036
  async function reencodeCfr(ctx, chunkPaths, encoder) {
20668
- const cfrOutputPath = join44(ctx.workDir, `cfr.${ctx.format}`);
21037
+ const cfrOutputPath = join47(ctx.workDir, `cfr.${ctx.format}`);
20669
21038
  const cfrArgs = cfrEncodeArgs(videoInputArgs(ctx, chunkPaths), encoder, ctx.fpsArg);
20670
21039
  appendRenderProvenanceArgs(cfrArgs, cfrOutputPath);
20671
21040
  cfrArgs.push("-y", cfrOutputPath);
@@ -20692,7 +21061,7 @@ async function writeJoined(ctx, videoSources, audioPath, finalPath) {
20692
21061
  );
20693
21062
  return;
20694
21063
  }
20695
- const paddedAudioPath = join44(ctx.workDir, "audio-padded.m4a");
21064
+ const paddedAudioPath = join47(ctx.workDir, "audio-padded.m4a");
20696
21065
  const padTrimResult = await ctx.timed(
20697
21066
  "audioMs",
20698
21067
  () => padOrTrimAudioToVideoFrameCount({
@@ -20732,7 +21101,7 @@ async function writeJoined(ctx, videoSources, audioPath, finalPath) {
20732
21101
  }
20733
21102
  }
20734
21103
  function concatDemuxerInput(chunkPaths, workDir, fpsArg) {
20735
- const listPath = join44(workDir, "concat-list.txt");
21104
+ const listPath = join47(workDir, "concat-list.txt");
20736
21105
  const body = chunkPaths.map((path) => `file '${path.replace(/'/g, "'\\''")}'`).join("\n");
20737
21106
  writeFileSync14(listPath, `${body}
20738
21107
  `, "utf-8");
@@ -20770,11 +21139,11 @@ function stitchesSeparateAudio(planDir) {
20770
21139
  return lockedAudio(planDir).separateAudio === true;
20771
21140
  }
20772
21141
  function planFormat(planDir) {
20773
- const plan2 = JSON.parse(readFileSync14(join44(planDir, "plan.json"), "utf-8"));
21142
+ const plan2 = JSON.parse(readFileSync14(join47(planDir, "plan.json"), "utf-8"));
20774
21143
  return plan2.dimensions.format;
20775
21144
  }
20776
21145
  function lockedAudio(planDir) {
20777
- const encoderJsonPath = join44(planDir, "meta", "encoder.json");
21146
+ const encoderJsonPath = join47(planDir, "meta", "encoder.json");
20778
21147
  if (!existsSync31(encoderJsonPath)) return {};
20779
21148
  return JSON.parse(readFileSync14(encoderJsonPath, "utf-8"));
20780
21149
  }
@@ -20784,7 +21153,7 @@ function readCfrEncoder(planDir, format) {
20784
21153
  `[assemble] cfr=true is only supported for format="mp4" (got "${format}"). Stream-copy paths for webm and mov already produce exact avg_frame_rate; cfr re-encode is not needed.`
20785
21154
  );
20786
21155
  }
20787
- const encoderJsonPath = join44(planDir, "meta", "encoder.json");
21156
+ const encoderJsonPath = join47(planDir, "meta", "encoder.json");
20788
21157
  if (!existsSync31(encoderJsonPath)) {
20789
21158
  throw new Error(`[assemble] planDir missing meta/encoder.json: ${encoderJsonPath}`);
20790
21159
  }
@@ -20797,22 +21166,22 @@ function readCfrEncoder(planDir, format) {
20797
21166
  return encoderJson;
20798
21167
  }
20799
21168
  function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, startTimeMs) {
20800
- if (existsSync31(outputPath)) rmSync16(outputPath, { recursive: true, force: true });
20801
- mkdirSync18(outputPath, { recursive: true });
21169
+ if (existsSync31(outputPath)) rmSync18(outputPath, { recursive: true, force: true });
21170
+ mkdirSync20(outputPath, { recursive: true });
20802
21171
  let globalIdx = 0;
20803
21172
  for (const chunkDir of chunkPaths) {
20804
- if (!statSync11(chunkDir).isDirectory()) {
21173
+ if (!statSync12(chunkDir).isDirectory()) {
20805
21174
  throw new Error(
20806
21175
  `[assemble] png-sequence chunk must be a directory: ${chunkDir} (got a file)`
20807
21176
  );
20808
21177
  }
20809
- const frames = readdirSync11(chunkDir).filter((name) => name.endsWith(".png")).sort();
21178
+ const frames = readdirSync12(chunkDir).filter((name) => name.endsWith(".png")).sort();
20810
21179
  if (frames.length === 0) {
20811
21180
  throw new Error(`[assemble] png-sequence chunk has no frames: ${chunkDir}`);
20812
21181
  }
20813
21182
  for (const frame of frames) {
20814
- const dst = join44(outputPath, formatExportFrameName(globalIdx, "png"));
20815
- cpSync3(join44(chunkDir, frame), dst);
21183
+ const dst = join47(outputPath, formatExportFrameName(globalIdx, "png"));
21184
+ cpSync3(join47(chunkDir, frame), dst);
20816
21185
  globalIdx += 1;
20817
21186
  }
20818
21187
  }
@@ -20822,13 +21191,13 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
20822
21191
  );
20823
21192
  }
20824
21193
  if (audioPath !== null && existsSync31(audioPath)) {
20825
- const sidecar = join44(outputPath, MIXED_AUDIO_FILENAME);
21194
+ const sidecar = join47(outputPath, MIXED_AUDIO_FILENAME);
20826
21195
  cpSync3(audioPath, sidecar);
20827
21196
  }
20828
21197
  let fileSize = 0;
20829
- for (const name of readdirSync11(outputPath)) {
21198
+ for (const name of readdirSync12(outputPath)) {
20830
21199
  try {
20831
- fileSize += statSync11(join44(outputPath, name)).size;
21200
+ fileSize += statSync12(join47(outputPath, name)).size;
20832
21201
  } catch {
20833
21202
  }
20834
21203
  }
@@ -20842,18 +21211,18 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
20842
21211
 
20843
21212
  // ../producer/src/services/distributed/planV2Execution.ts
20844
21213
  async function renderChunkV2(planV2Dir, chunkIndex, outputChunkPath, options) {
20845
- const workRoot = mkdtempSync10(join45(tmpdir6(), "hf-plan-v2-chunk-"));
20846
- const materializedPlanDir = join45(workRoot, "plan");
21214
+ const workRoot = mkdtempSync10(join48(tmpdir6(), "hf-plan-v2-chunk-"));
21215
+ const materializedPlanDir = join48(workRoot, "plan");
20847
21216
  try {
20848
21217
  materializePlanV2Target(planV2Dir, { role: "chunk", chunkIndex }, materializedPlanDir);
20849
21218
  return await renderChunk(materializedPlanDir, chunkIndex, outputChunkPath, options);
20850
21219
  } finally {
20851
- rmSync17(workRoot, { recursive: true, force: true });
21220
+ rmSync19(workRoot, { recursive: true, force: true });
20852
21221
  }
20853
21222
  }
20854
21223
  async function assembleV2(planV2Dir, chunkPaths, outputPath, options) {
20855
- const workRoot = mkdtempSync10(join45(tmpdir6(), "hf-plan-v2-assembler-"));
20856
- const materializedPlanDir = join45(workRoot, "plan");
21224
+ const workRoot = mkdtempSync10(join48(tmpdir6(), "hf-plan-v2-assembler-"));
21225
+ const materializedPlanDir = join48(workRoot, "plan");
20857
21226
  try {
20858
21227
  const materialized = materializePlanV2Target(
20859
21228
  planV2Dir,
@@ -20868,14 +21237,14 @@ async function assembleV2(planV2Dir, chunkPaths, outputPath, options) {
20868
21237
  options
20869
21238
  );
20870
21239
  } finally {
20871
- rmSync17(workRoot, { recursive: true, force: true });
21240
+ rmSync19(workRoot, { recursive: true, force: true });
20872
21241
  }
20873
21242
  }
20874
21243
 
20875
21244
  // ../producer/src/services/distributed/projectHash.ts
20876
- import { closeSync as closeSync7, openSync as openSync7, readdirSync as readdirSync12, readSync as readSync5, realpathSync as realpathSync2, statSync as statSync12 } from "fs";
21245
+ import { closeSync as closeSync7, openSync as openSync7, readdirSync as readdirSync13, readSync as readSync5, realpathSync as realpathSync2, statSync as statSync13 } from "fs";
20877
21246
  import { createHash as createHash8 } from "crypto";
20878
- import { join as join46 } from "path";
21247
+ import { join as join49 } from "path";
20879
21248
  var READ_CHUNK_BYTES = 256 * 1024;
20880
21249
 
20881
21250
  // ../producer/src/services/distributed/audioSidecar.ts