hyperframes 0.8.206 → 0.8.208

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 (240) hide show
  1. package/bin/hyperframes.mjs +1 -0
  2. package/dist/{add-FFMNAJXJ.js → add-XMWRBMBR.js} +22 -20
  3. package/dist/{agentPromptGenerator-KYO5MKTW.js → agentPromptGenerator-4NJ252MR.js} +6 -2
  4. package/dist/{animatedGifPrep-BIIIIVWL.js → animatedGifPrep-6XURJIPV.js} +14 -13
  5. package/dist/api.js +33 -32
  6. package/dist/{appHistory-QVCSAOI4.js → appHistory-HIBH6XZW.js} +3 -1
  7. package/dist/{asset-IPUHGZSL.js → asset-I5GGEOB2.js} +2 -2
  8. package/dist/{assetCataloger-M5FWXLAJ.js → assetCataloger-YBPXUNUP.js} +17 -14
  9. package/dist/{audio-VYWWM4DB.js → audio-GFJCHH5W.js} +420 -138
  10. package/dist/{auth-GZQZCUPL.js → auth-QOA55RYR.js} +4 -4
  11. package/dist/{autoUpdate-GJUDDLLO.js → autoUpdate-SPS4QPJU.js} +4 -4
  12. package/dist/{backgroundChecks-BTMSW34Z.js → backgroundChecks-HRJO7YK7.js} +5 -5
  13. package/dist/backgroundChecksWorker.js +5 -5
  14. package/dist/{batchRender-LI2BJRGO.js → batchRender-FBP3RKUF.js} +11 -10
  15. package/dist/{beats-H73CSYT4.js → beats-VNGJ7F6W.js} +32 -25
  16. package/dist/{benchmark-XT3A5REC.js → benchmark-NZ3N3MIV.js} +16 -16
  17. package/dist/{browser-VIOK66YK.js → browser-BD5BKRJ5.js} +9 -9
  18. package/dist/{bundleWithLocalizedFonts-PFRVWYOO.js → bundleWithLocalizedFonts-WXVNPAWD.js} +3 -3
  19. package/dist/{capture-KKD5GMAF.js → capture-CXWXKWS5.js} +120 -54
  20. package/dist/{capture-252WNPCD.js → capture-LMJ4TQRL.js} +63 -17
  21. package/dist/{captureCompositionFrame-YLYVGNN2.js → captureCompositionFrame-ZKVCRYYU.js} +21 -20
  22. package/dist/{captureFile-LYOJOUIE.js → captureFile-VIVGKFY4.js} +2 -1
  23. package/dist/{catalog-6IJGNN3T.js → catalog-WRXQSCAU.js} +28 -26
  24. package/dist/{catch-up-BFW7Z35W.js → catch-up-MDSPABFC.js} +7 -7
  25. package/dist/{check-XUWBZASR.js → check-SIBBK5HA.js} +53 -52
  26. package/dist/{checkAudio-2NRR3VHQ.js → checkAudio-QQBR4HR7.js} +19 -18
  27. package/dist/{checkBrowser-JW74KWTF.js → checkBrowser-4EBJLLIH.js} +45 -44
  28. package/dist/{chunk-XDMZY3H7.js → chunk-3O2E4Q66.js} +15 -20
  29. package/dist/{chunk-VEA7Z4PZ.js → chunk-43MW4SY7.js} +15 -7
  30. package/dist/{chunk-HJAJ6W4V.js → chunk-4F5NRJ6M.js} +2 -2
  31. package/dist/{chunk-2RT7MXFL.js → chunk-4HT2L6W2.js} +1 -1
  32. package/dist/{chunk-QVTCXN42.js → chunk-4KG3ESVO.js} +30 -4
  33. package/dist/{chunk-42KN6I6A.js → chunk-4LTBQEPD.js} +2 -2
  34. package/dist/{chunk-C6KE4AFW.js → chunk-56ANHX5U.js} +1 -1
  35. package/dist/{chunk-NVLPW3DG.js → chunk-5HB4JM7H.js} +2 -2
  36. package/dist/{chunk-2ST4WAFY.js → chunk-5PCALX6G.js} +13 -1
  37. package/dist/{chunk-AYH5ANVS.js → chunk-5YHQBCWH.js} +52 -3
  38. package/dist/{chunk-X5HHHFTX.js → chunk-6CWKORZO.js} +3 -3
  39. package/dist/{chunk-ZF3R2IPC.js → chunk-6DSYBW7Z.js} +1 -0
  40. package/dist/{chunk-VHVSBOZH.js → chunk-6JNSYFOH.js} +4 -4
  41. package/dist/{chunk-AJSU6KGS.js → chunk-6N7D2GUV.js} +15 -15
  42. package/dist/{chunk-F2ASNL2K.js → chunk-6PWQH77E.js} +1 -1
  43. package/dist/{chunk-ZNAOBFU5.js → chunk-6WRN4WC6.js} +1 -1
  44. package/dist/{chunk-GAV56VJL.js → chunk-7CPI2DWL.js} +2 -2
  45. package/dist/{chunk-CMDVJP4T.js → chunk-7PAK7LZ5.js} +11 -11
  46. package/dist/{chunk-3CISA3OS.js → chunk-AF3L5JJX.js} +1 -1
  47. package/dist/{chunk-X7RXXBYM.js → chunk-B5MPMIKQ.js} +2 -2
  48. package/dist/{chunk-RW4DMP2Y.js → chunk-BKDQFOKK.js} +4 -4
  49. package/dist/{chunk-DZG565OO.js → chunk-BLCKQPBE.js} +1 -1
  50. package/dist/chunk-BQMAPNDA.js +4830 -0
  51. package/dist/{chunk-CPSGXAYD.js → chunk-CP225S5H.js} +3 -3
  52. package/dist/{chunk-3R6SXPHD.js → chunk-CSWCZA6V.js} +3 -3
  53. package/dist/{chunk-4CY5RXXC.js → chunk-D2CE2J2A.js} +4 -4
  54. package/dist/{chunk-FMWACL3L.js → chunk-DHQSDCWD.js} +6 -2
  55. package/dist/chunk-DROFHVQD.js +240 -0
  56. package/dist/{chunk-OZUAVHFE.js → chunk-DXACKQ3F.js} +3 -3
  57. package/dist/{chunk-5QKJPCQ4.js → chunk-EGOXYG3M.js} +2 -2
  58. package/dist/{chunk-QL4ZYSIB.js → chunk-ENRFKCI6.js} +5 -71
  59. package/dist/{chunk-MRF4AMKD.js → chunk-EQBDKYXR.js} +5 -10
  60. package/dist/{chunk-4UMPIPCQ.js → chunk-ERUQ3S6D.js} +2 -2
  61. package/dist/{chunk-T2EUWCJE.js → chunk-EU7MVORF.js} +13 -1
  62. package/dist/{chunk-FULMZCDW.js → chunk-EYEEZXLI.js} +11 -11
  63. package/dist/{chunk-2MLMO25E.js → chunk-FC4WT5FX.js} +105 -7
  64. package/dist/{chunk-PLGGKTCB.js → chunk-FFDYRJBE.js} +37 -21
  65. package/dist/{chunk-7SXL476O.js → chunk-G2A6RC5R.js} +72 -28
  66. package/dist/{chunk-HTIUNMTP.js → chunk-GDZA4ALG.js} +8 -2
  67. package/dist/{chunk-CZYS6UKP.js → chunk-GEO6THL3.js} +61 -30
  68. package/dist/{chunk-MFHYBSJC.js → chunk-GHSO62LK.js} +3 -3
  69. package/dist/{chunk-P2I4RLJE.js → chunk-HTZJNQYI.js} +1 -1
  70. package/dist/{chunk-4DGLKB2H.js → chunk-HUKQW4YE.js} +1 -1
  71. package/dist/{chunk-WYB3VKLK.js → chunk-HZN7ICAF.js} +8 -8
  72. package/dist/{chunk-6ZFDNEMY.js → chunk-IIJVSCSH.js} +16 -16
  73. package/dist/{chunk-VDVVQNTK.js → chunk-IL2TMC6F.js} +5 -5
  74. package/dist/{chunk-L5MFWGGU.js → chunk-J67FSI3Q.js} +623 -376
  75. package/dist/chunk-JLCAHJUO.js +91 -0
  76. package/dist/{chunk-N7ZMDVAK.js → chunk-JLGVBK5M.js} +1 -1
  77. package/dist/{chunk-SFYLZX5C.js → chunk-K4PHB3YQ.js} +59 -15
  78. package/dist/{chunk-G6W55MTX.js → chunk-KTWGVEN6.js} +40 -11
  79. package/dist/{chunk-FNNGQ3DB.js → chunk-LSMFOZ4F.js} +2 -2
  80. package/dist/{chunk-ELP5QZWL.js → chunk-M4QZFUMW.js} +1 -1
  81. package/dist/{chunk-PNKLOMHQ.js → chunk-MBGM26P5.js} +17 -22
  82. package/dist/{chunk-ZTEKVSZ6.js → chunk-MMJAHBH2.js} +1 -1
  83. package/dist/{chunk-RDDVQSNQ.js → chunk-MPO25DQW.js} +451 -208
  84. package/dist/{chunk-E2ZZSDDQ.js → chunk-MW2NQQ6Z.js} +2 -2
  85. package/dist/{chunk-TSJVPPXT.js → chunk-MYO77JWR.js} +1 -1
  86. package/dist/{chunk-PSX5SF2N.js → chunk-NEASABW6.js} +1 -1
  87. package/dist/{chunk-OFRRUYBA.js → chunk-NHA4NRBE.js} +135 -24
  88. package/dist/{chunk-NNLQTG3M.js → chunk-NZ6G5YWZ.js} +2 -2
  89. package/dist/{chunk-WHD5IAHI.js → chunk-ORFRUZPB.js} +2 -2
  90. package/dist/{chunk-Z3XXLTVB.js → chunk-OTXXDONS.js} +3 -3
  91. package/dist/{chunk-2S263R6D.js → chunk-P7WGVXR7.js} +9 -9
  92. package/dist/{chunk-AXEEZKIL.js → chunk-PKVA6MPV.js} +6 -6
  93. package/dist/{chunk-FJW757TF.js → chunk-PSOAGSNO.js} +2 -2
  94. package/dist/{chunk-AEC4T4IF.js → chunk-PWEOSJ3E.js} +12 -12
  95. package/dist/{chunk-X7A7C4JS.js → chunk-Q43YUROE.js} +3 -3
  96. package/dist/{chunk-PQYWYBEQ.js → chunk-QP2MJYTJ.js} +1 -1
  97. package/dist/{chunk-VW2LVMKB.js → chunk-QWBVPWUI.js} +47 -55
  98. package/dist/{chunk-AAX2A7LQ.js → chunk-S2OLTAEL.js} +2 -2
  99. package/dist/{chunk-CNVHMLPI.js → chunk-S4KHJERB.js} +1 -1
  100. package/dist/{chunk-2BGOB2QK.js → chunk-SE2MXV2N.js} +136 -25
  101. package/dist/{chunk-3CS6QYL7.js → chunk-SI7QCT2J.js} +8 -8
  102. package/dist/{chunk-CIHW6VM2.js → chunk-SKKQMW5X.js} +1 -1
  103. package/dist/{chunk-3B2DBUQX.js → chunk-TNTGGDSD.js} +1 -1
  104. package/dist/chunk-TSYRN646.js +84 -0
  105. package/dist/{chunk-XOM3XTJ4.js → chunk-U6KN6OIP.js} +2 -2
  106. package/dist/{chunk-63DGZRZP.js → chunk-ULL3U6PV.js} +1 -1
  107. package/dist/{chunk-IXXVS2Z4.js → chunk-VQB7G5BM.js} +1 -1
  108. package/dist/{chunk-UMUVGNOH.js → chunk-VR3JLTZD.js} +3 -3
  109. package/dist/{chunk-DEVZJ4AL.js → chunk-VS4SK7BN.js} +17 -11
  110. package/dist/{chunk-6N65ZMC5.js → chunk-VYRJAQGC.js} +1 -1
  111. package/dist/{chunk-FLREUEHW.js → chunk-W4DMQZL5.js} +1 -1
  112. package/dist/chunk-WABB4LZS.js +62 -0
  113. package/dist/{chunk-RXATE6FZ.js → chunk-WC4MTXGN.js} +22 -0
  114. package/dist/{chunk-36QE3P6B.js → chunk-WNMVC3IT.js} +1 -1
  115. package/dist/{chunk-T6SD37JZ.js → chunk-X6MCIK7L.js} +103 -16
  116. package/dist/chunk-XFMO3BEN.js +71 -0
  117. package/dist/{chunk-BBUK6A7Q.js → chunk-XG3IZV62.js} +7 -7
  118. package/dist/chunk-XMRA7CQG.js +22 -0
  119. package/dist/{chunk-G6QDFWDN.js → chunk-XOFBXLMG.js} +2 -2
  120. package/dist/{chunk-H4JO7VSI.js → chunk-XUQYC5DD.js} +12 -12
  121. package/dist/chunk-Z5J67X44.js +40 -0
  122. package/dist/{chunk-HEP5XMXV.js → chunk-Z5TGBEPJ.js} +9 -2
  123. package/dist/{chunk-7JAD4MEW.js → chunk-ZA5TNF4R.js} +1 -0
  124. package/dist/{clean-N5VSKUVS.js → clean-6GX7WAEC.js} +32 -31
  125. package/dist/cli.js +58 -58
  126. package/dist/{cloud-74NF5FXC.js → cloud-6PFJKLNL.js} +4 -4
  127. package/dist/{cloudrun-7UOH335V.js → cloudrun-UGG3ZFH7.js} +13 -12
  128. package/dist/commands/layout-audit.browser.js +3 -15
  129. package/dist/{compare-AY2LS2TZ.js → compare-P4EBOP4B.js} +46 -45
  130. package/dist/{compiler-4MHMC777.js → compiler-PG4RKX6K.js} +8 -8
  131. package/dist/{component-CFWQOAZI.js → component-SQPMI3W7.js} +3 -3
  132. package/dist/{compositions-DXLJTDSP.js → compositions-KRIHY3IY.js} +20 -19
  133. package/dist/{contactSheet-5APX35L3.js → contactSheet-RYAE7Y5D.js} +3 -2
  134. package/dist/{delete-GB4MS7LM.js → delete-T5TO4SV6.js} +7 -7
  135. package/dist/{deploy-NXD3Q3KD.js → deploy-AO6LQR5G.js} +6 -6
  136. package/dist/{deterministicFonts-775YXAQ2.js → deterministicFonts-LKAGUNE5.js} +3 -3
  137. package/dist/{dist-3ZJMZU75.js → dist-23AAB5X2.js} +36 -36
  138. package/dist/{dist-ZY6IFESG.js → dist-6IMEDVMC.js} +6 -3
  139. package/dist/docker/Dockerfile.render +1 -1
  140. package/dist/docs/rendering.md +3 -0
  141. package/dist/{doctor-CVY2XXKS.js → doctor-QBUJQ655.js} +23 -22
  142. package/dist/{events-RYQYEWBV.js → events-J7CESLKQ.js} +4 -4
  143. package/dist/{events-T3CLIYRG.js → events-SIZO7YHI.js} +5 -5
  144. package/dist/{feedback-K5ZMMLTA.js → feedback-74WOJ5PN.js} +22 -22
  145. package/dist/{ffmpeg-UNDAJ2IC.js → ffmpeg-AKUP6U2S.js} +17 -16
  146. package/dist/{figma-MYYCX635.js → figma-GGMYRR4Q.js} +3 -3
  147. package/dist/fontLocalizeCli.js +21 -19
  148. package/dist/{get-JVIDYMVP.js → get-PLKAI6JM.js} +7 -7
  149. package/dist/{gpuPolicy-KEX7GDRJ.js → gpuPolicy-EYDAAPJF.js} +14 -13
  150. package/dist/{grade-compare-QEF6VASJ.js → grade-compare-UADJP4AV.js} +44 -43
  151. package/dist/{gsapParserAcorn-LZJKCFQI.js → gsapParserAcorn-5YD4N6HQ.js} +2 -2
  152. package/dist/hangReport.js +47 -0
  153. package/dist/{heifImagePrep-A3ZPVQGU.js → heifImagePrep-KDF3OPOK.js} +15 -14
  154. package/dist/{help-XPPSLIRY.js → help-WSQQ555Q.js} +1 -1
  155. package/dist/{history-OFOPRD27.js → history-VSQ2DQ3V.js} +110 -62
  156. package/dist/hyperframe.manifest.json +1 -1
  157. package/dist/hyperframe.runtime.iife.js +76 -71
  158. package/dist/hyperframes-player.global.js +3 -3
  159. package/dist/{info-7RF6FQX5.js → info-MOQ4LRC3.js} +18 -18
  160. package/dist/{init-NTIXWA3D.js → init-EONQSZJG.js} +62 -60
  161. package/dist/{inspect-MYMCV5E7.js → inspect-OLCVLHOU.js} +43 -42
  162. package/dist/{installer-PYJIJ3PJ.js → installer-GHISA75B.js} +10 -10
  163. package/dist/{keyframes-UJ52PYE4.js → keyframes-DGQYCY24.js} +13 -13
  164. package/dist/{lambda-SBNUYEQE.js → lambda-AMMWF2YH.js} +35 -15
  165. package/dist/{layout-IOMCOABO.js → layout-R6CAPGRO.js} +43 -42
  166. package/dist/{lint-AQWHHMPS.js → lint-QZJEYPHD.js} +14 -11
  167. package/dist/{lintProject-5A4SCW3S.js → lintProject-W3YVHAGP.js} +6 -3
  168. package/dist/{list-WKAJ5SP3.js → list-KCJID4SP.js} +7 -7
  169. package/dist/localPage-V3HBGM3Z.js +27 -0
  170. package/dist/{login-3ZDK5JOA.js → login-7HKBEPJS.js} +7 -7
  171. package/dist/{logout-JYFWWUGK.js → logout-3IID4KXD.js} +3 -3
  172. package/dist/{manager-QYFYWZOK.js → manager-6YSKJMVD.js} +19 -18
  173. package/dist/{manager-F2YREC5X.js → manager-Z7W4GQGF.js} +9 -5
  174. package/dist/{media-treatment-4OLWVHUY.js → media-treatment-E3DL6LEZ.js} +34 -31
  175. package/dist/{models-MR55FAUX.js → models-URWI7YEG.js} +30 -29
  176. package/dist/{motionShot-DC47S7BT.js → motionShot-27IXMDJK.js} +25 -24
  177. package/dist/{normalize-audio-M2TK4NG5.js → normalize-audio-WGRLPR3P.js} +16 -16
  178. package/dist/{open-YXWBWTKL.js → open-LQ35PLEN.js} +21 -21
  179. package/dist/{parakeetRunner-J6QR3GTG.js → parakeetRunner-XASVIDTI.js} +27 -26
  180. package/dist/{pipeline-7MJ5H4SW.js → pipeline-GA7QVCHS.js} +18 -17
  181. package/dist/{play-S562STR4.js → play-RYZP77CI.js} +31 -31
  182. package/dist/{policies-GHVXA5PE.js → policies-PKLD4UW5.js} +1 -1
  183. package/dist/{preflight-QWGXMISC.js → preflight-HJFSJXXF.js} +19 -18
  184. package/dist/{present-PGOHZT3L.js → present-YBMLOWZV.js} +26 -26
  185. package/dist/{preview-JU75H4QN.js → preview-QIRKJCRV.js} +52 -39
  186. package/dist/{producer-H66OMZLW.js → producer-524FDOLX.js} +1 -1
  187. package/dist/{projectConfig-COSP24YT.js → projectConfig-IDQN5ZRW.js} +14 -13
  188. package/dist/{publication-J3XYHPGB.js → publication-3X3IGSDO.js} +8 -8
  189. package/dist/{publish-7GCCEPJZ.js → publish-2BF7K6HX.js} +21 -20
  190. package/dist/{refresh-USSFPJAU.js → refresh-3IRHJEQA.js} +3 -3
  191. package/dist/{remove-background-WRCGIU32.js → remove-background-EZBCEFT6.js} +22 -21
  192. package/dist/{render-QS3YJCBR.js → render-EFUA2A6A.js} +15 -11
  193. package/dist/{render-VUVTK2JM.js → render-JFMTAXHD.js} +87 -53
  194. package/dist/{render-5J5PP3UK.js → render-TEEBI2UT.js} +49 -43
  195. package/dist/{render-batch-Q2LQ3D4P.js → render-batch-XTYNXVSW.js} +16 -12
  196. package/dist/renderSetupWorker.js +12 -9
  197. package/dist/{resolver-QCBWPRSC.js → resolver-FZS6TN6B.js} +10 -10
  198. package/dist/{screenshotCapture-I5EDCITF.js → screenshotCapture-HOW4VSV6.js} +3 -2
  199. package/dist/{sherpa-IZ22SC5W.js → sherpa-TQIAIKTH.js} +26 -25
  200. package/dist/skills/hyperframes/SKILL.md +1 -1
  201. package/dist/skills/hyperframes/references/format.md +1 -0
  202. package/dist/skills/hyperframes-cli/references/beats.md +2 -0
  203. package/dist/skills/hyperframes-cli/references/init-and-scaffold.md +1 -0
  204. package/dist/skills/hyperframes-cli/references/lambda.md +3 -0
  205. package/dist/skills/hyperframes-cli/references/preview-render.md +3 -0
  206. package/dist/skills/media-use/references/grading.md +2 -0
  207. package/dist/skills/media-use/references/local.md +1 -0
  208. package/dist/{skills-3RFMPMJA.js → skills-S6ZG5KKH.js} +10 -10
  209. package/dist/{skillsUpdateCheck-DWBFVUBT.js → skillsUpdateCheck-XC7JQL3F.js} +5 -5
  210. package/dist/{snapshot-5PHA43DK.js → snapshot-ERYZIM32.js} +152 -80
  211. package/dist/{src-4YJKYMNF.js → src-6XOMREMS.js} +21 -12
  212. package/dist/{src-36BQVJL3.js → src-OL6RHPE4.js} +22 -20
  213. package/dist/{staticProjectServer-3XFB76XS.js → staticProjectServer-JYDDGPAH.js} +26 -26
  214. package/dist/{status-LR7VXITS.js → status-DTP6ZYDU.js} +3 -3
  215. package/dist/studio/assets/hyperframes-player-5dRdMVOq.js +478 -0
  216. package/dist/studio/assets/{index-CwreIGoq.js → index-Bu3mJUU2.js} +131 -131
  217. package/dist/studio/assets/{index-BNuxGFZK.js → index-ZqyQ91pm.js} +1 -1
  218. package/dist/studio/index.html +1 -1
  219. package/dist/{studio-api-WL6EZ4KE.js → studio-api-GRU4SHKD.js} +18 -18
  220. package/dist/{studioServer-ZS5RA6U3.js → studioServer-OYPBEI5B.js} +76 -73
  221. package/dist/{synthesize-QCRP3NI7.js → synthesize-QZHRXGRY.js} +26 -4
  222. package/dist/{telemetry-IHU4HL3R.js → telemetry-6BPSGY5W.js} +2 -2
  223. package/dist/{telemetry-W3LRO3TB.js → telemetry-CPYINR63.js} +5 -5
  224. package/dist/{timeline-BDO5DYWP.js → timeline-RGK5BMPD.js} +34 -33
  225. package/dist/{tokens-47CEMYFV.js → tokens-EX4BOWRW.js} +2 -2
  226. package/dist/{transcribe-XF3NL6JI.js → transcribe-MK367I6A.js} +24 -23
  227. package/dist/{transcribe-GEPVJO3A.js → transcribe-RI52JMVW.js} +35 -34
  228. package/dist/{tts-QM4RFE7U.js → tts-AY4JO5NQ.js} +2 -2
  229. package/dist/{updateCheck-BON6ZFYP.js → updateCheck-BIEJKQI4.js} +4 -4
  230. package/dist/{upgrade-KIF5Z4J3.js → upgrade-ES3UUI7O.js} +4 -4
  231. package/dist/upstreamProxy-W5FWAT5Z.js +17 -0
  232. package/dist/{urlDownloader-UDRHVUWR.js → urlDownloader-XAGYSTAG.js} +13 -12
  233. package/dist/{validate-2OPSQT3W.js → validate-A6GZHNEI.js} +36 -35
  234. package/dist/{video-ECWXMY4F.js → video-OEMGR3MN.js} +19 -15
  235. package/dist/warmCheck.js +53 -52
  236. package/package.json +2 -1
  237. package/dist/chunk-4YYJOFKS.js +0 -28
  238. package/dist/chunk-KLIPVNCO.js +0 -4824
  239. package/dist/studio/assets/hyperframes-player-lCVwx9d3.js +0 -478
  240. package/dist/{destroy-SSPAKADI.js → destroy-CGAZIL2C.js} +4 -4
@@ -4,6 +4,9 @@ import { dirname as __hf_dirname } from "node:path";
4
4
  var require = __hf_createRequire(import.meta.url);
5
5
  var __filename = __hf_fileURLToPath(import.meta.url);
6
6
  var __dirname = __hf_dirname(__filename);
7
+ import {
8
+ removeTreeBestEffort
9
+ } from "./chunk-Z5J67X44.js";
7
10
  import {
8
11
  alphaDecoderFor,
9
12
  pixelFormatHasAlpha,
@@ -29,7 +32,7 @@ import {
29
32
  renderFrameIdForRenderId,
30
33
  resolveAuthoredTimingWindow,
31
34
  toFps
32
- } from "./chunk-VW2LVMKB.js";
35
+ } from "./chunk-QWBVPWUI.js";
33
36
  import {
34
37
  AUDIO_GROUP_RENDER_ID_ATTR,
35
38
  AUTHORED_SOURCE_BEGIN,
@@ -72,7 +75,7 @@ import {
72
75
  sourceTimeAt,
73
76
  timeAtSourceTime,
74
77
  volumeSegmentSampleCount
75
- } from "./chunk-KLIPVNCO.js";
78
+ } from "./chunk-BQMAPNDA.js";
76
79
  import {
77
80
  redactTelemetryString,
78
81
  redactUrlQueryStrings
@@ -87,10 +90,10 @@ import {
87
90
  exceedsChromeCeiling,
88
91
  isManagedChromeDir,
89
92
  pickSharedShell
90
- } from "./chunk-4UMPIPCQ.js";
93
+ } from "./chunk-ERUQ3S6D.js";
91
94
  import {
92
95
  resolveReferencedStart
93
- } from "./chunk-2MLMO25E.js";
96
+ } from "./chunk-FC4WT5FX.js";
94
97
  import {
95
98
  FFMPEG_PATH_ENV,
96
99
  FFPROBE_PATH_ENV,
@@ -102,7 +105,7 @@ import {
102
105
  } from "./chunk-PBNWRWKA.js";
103
106
  import {
104
107
  isPathInside
105
- } from "./chunk-2BGOB2QK.js";
108
+ } from "./chunk-SE2MXV2N.js";
106
109
  import {
107
110
  parseHTML
108
111
  } from "./chunk-GWTIFRF5.js";
@@ -590,6 +593,86 @@ var SDR_RGB_TO_BT709_FILTER = "scale=out_color_matrix=bt709:out_range=tv:flags=n
590
593
  var SDR_RGB_TO_TAGGED_BT709_FILTER = `${SDR_RGB_TO_BT709_FILTER},setparams=color_primaries=bt709:color_trc=bt709:colorspace=bt709:range=tv`;
591
594
  var SDR_CAPTURE_TO_BT709_FILTER = `scale=in_color_matrix=bt601:in_range=pc:flags=neighbor+accurate_rnd,format=gbrp,${SDR_RGB_TO_TAGGED_BT709_FILTER}`;
592
595
 
596
+ // ../engine/src/services/chromeStartup.ts
597
+ import { spawn } from "child_process";
598
+ import { mkdtempSync } from "fs";
599
+ import { tmpdir as tmpdir2 } from "os";
600
+ import { join as join2 } from "path";
601
+ var STDERR_TAIL_LINES = 8;
602
+ var PROBE_TIMEOUT_MS = 8e3;
603
+ var WINDOWS_EXITS = [
604
+ [3221225781, "0xC0000135: a required runtime or DLL is missing (Visual C++ runtime)."],
605
+ [3221225495, "0xC0000017: Windows had no memory to start it (out of memory)."],
606
+ [3221225794, "0xC0000142: a DLL failed to initialise, often security software blocking it."],
607
+ [3221225506, "0xC0000022: access denied, often antivirus or a policy blocking the executable."],
608
+ [3221225595, "0xC000007B: the executable and a DLL do not match (32-bit and 64-bit)."]
609
+ ];
610
+ function nameChromeExit(code, platform = process.platform) {
611
+ if (platform !== "win32" || code === null) return void 0;
612
+ const unsigned = code >>> 0;
613
+ return WINDOWS_EXITS.find(([known]) => known === unsigned)?.[1];
614
+ }
615
+ function startupArgs(args, profile) {
616
+ const kept = args.filter(
617
+ (arg) => arg.startsWith("--") && !arg.startsWith("--remote-debugging") && !arg.startsWith("--user-data-dir")
618
+ );
619
+ return [...kept, `--user-data-dir=${profile}`, "--remote-debugging-port=0", "about:blank"];
620
+ }
621
+ function tail(stderr) {
622
+ return stderr.split(/\r?\n/).map((line) => line.trim()).filter(Boolean).slice(-STDERR_TAIL_LINES).join("\n");
623
+ }
624
+ async function diagnoseChromeStartup(executablePath, args, options = {}) {
625
+ const profile = mkdtempSync(join2(tmpdir2(), "hf-chrome-probe-"));
626
+ const timeoutMs = options.timeoutMs ?? PROBE_TIMEOUT_MS;
627
+ try {
628
+ return await new Promise((resolve2) => {
629
+ let stderr = "";
630
+ const child = spawn(executablePath, startupArgs(args, profile), {
631
+ stdio: ["ignore", "ignore", "pipe"],
632
+ windowsHide: true
633
+ });
634
+ const timer = setTimeout(() => {
635
+ child.kill();
636
+ resolve2(`Chrome started and kept running for ${timeoutMs} ms when launched on its own.`);
637
+ }, timeoutMs);
638
+ options.signal?.addEventListener(
639
+ "abort",
640
+ () => {
641
+ clearTimeout(timer);
642
+ child.kill();
643
+ resolve2("The startup check was cancelled.");
644
+ },
645
+ { once: true }
646
+ );
647
+ child.stderr.on("data", (chunk) => {
648
+ stderr = (stderr + chunk.toString()).slice(-4e3);
649
+ });
650
+ child.once("error", (error) => {
651
+ clearTimeout(timer);
652
+ resolve2(`Chrome could not be started: ${error.message}`);
653
+ });
654
+ child.once("exit", (code, signal) => {
655
+ clearTimeout(timer);
656
+ const how = signal ? `was stopped by ${signal}` : `exited with code ${code}`;
657
+ const named = nameChromeExit(code, options.platform);
658
+ const lines = tail(stderr);
659
+ resolve2(
660
+ [`Chrome ${how} when launched on its own.`, named, lines && `stderr:
661
+ ${lines}`].filter(Boolean).join("\n")
662
+ );
663
+ });
664
+ });
665
+ } finally {
666
+ removeTreeBestEffort(profile);
667
+ }
668
+ }
669
+ async function explainChromeLaunchFailure(error, executablePath, args, signal) {
670
+ if (!executablePath || !(error instanceof Error)) return error;
671
+ const diagnosis = await diagnoseChromeStartup(executablePath, args ?? [], { signal });
672
+ return new Error(`${error.message}
673
+ ${diagnosis}`, { cause: error });
674
+ }
675
+
593
676
  // ../parsers/dist/htmlAttributeSpans.js
594
677
  function readAttributeValue(html, at) {
595
678
  while (/[\t\n\f\r ]/.test(html.charAt(at))) at++;
@@ -677,7 +760,7 @@ function scanHtmlOpeningTags(html) {
677
760
  // ../engine/src/services/browserManager.ts
678
761
  import { execSync } from "child_process";
679
762
  import { existsSync, readdirSync, statSync } from "fs";
680
- import { join as join2 } from "path";
763
+ import { join as join3 } from "path";
681
764
  import { homedir } from "os";
682
765
 
683
766
  // ../engine/src/services/browserLeasePool.ts
@@ -999,7 +1082,7 @@ function findCachedHeadlessShell(baseDir) {
999
1082
  const versions = readdirSync(baseDir).sort(compareBrowserVersionsDescending);
1000
1083
  for (const version of versions) {
1001
1084
  if (exceedsChromeCeiling(version, ceiling)) continue;
1002
- const binary = join2(baseDir, version, ...executable);
1085
+ const binary = join3(baseDir, version, ...executable);
1003
1086
  if (isNonEmptyFile(binary)) return binary;
1004
1087
  }
1005
1088
  } catch {
@@ -1011,7 +1094,7 @@ function findSharedHeadlessShell(baseDir) {
1011
1094
  if (!executable || !existsSync(baseDir)) return void 0;
1012
1095
  try {
1013
1096
  return pickSharedShell(readdirSync(baseDir), (version) => {
1014
- const binary = join2(baseDir, version, ...executable);
1097
+ const binary = join3(baseDir, version, ...executable);
1015
1098
  return isNonEmptyFile(binary) ? binary : void 0;
1016
1099
  });
1017
1100
  } catch {
@@ -1023,7 +1106,7 @@ function findManagedHeadlessShell(baseDir) {
1023
1106
  if (!executable || !existsSync(baseDir)) return void 0;
1024
1107
  try {
1025
1108
  const version = readdirSync(baseDir).find(isManagedChromeDir);
1026
- const binary = version && join2(baseDir, version, ...executable);
1109
+ const binary = version && join3(baseDir, version, ...executable);
1027
1110
  return binary && isNonEmptyFile(binary) ? binary : void 0;
1028
1111
  } catch {
1029
1112
  return void 0;
@@ -1042,12 +1125,12 @@ function resolveHeadlessShellPath(config) {
1042
1125
  }
1043
1126
  return fromEnv.path;
1044
1127
  }
1045
- const ours = join2(homedir(), ".cache", "hyperframes", "chrome", "chrome-headless-shell");
1046
- const shared = join2(homedir(), ".cache", "puppeteer", "chrome-headless-shell");
1128
+ const ours = join3(homedir(), ".cache", "hyperframes", "chrome", "chrome-headless-shell");
1129
+ const shared = join3(homedir(), ".cache", "puppeteer", "chrome-headless-shell");
1047
1130
  return findManagedHeadlessShell(ours) ?? findSharedHeadlessShell(shared) ?? findCachedHeadlessShell(ours);
1048
1131
  }
1049
1132
  function resolveFullChromePath() {
1050
- const baseDir = join2(homedir(), ".cache", "puppeteer", "chrome");
1133
+ const baseDir = join3(homedir(), ".cache", "puppeteer", "chrome");
1051
1134
  let versions;
1052
1135
  try {
1053
1136
  versions = readdirSync(baseDir).sort(compareBrowserVersionsDescending);
@@ -1056,7 +1139,7 @@ function resolveFullChromePath() {
1056
1139
  }
1057
1140
  for (const version of versions) {
1058
1141
  const candidates = [
1059
- join2(
1142
+ join3(
1060
1143
  baseDir,
1061
1144
  version,
1062
1145
  "chrome-mac-arm64",
@@ -1065,7 +1148,7 @@ function resolveFullChromePath() {
1065
1148
  "MacOS",
1066
1149
  "Google Chrome for Testing"
1067
1150
  ),
1068
- join2(
1151
+ join3(
1069
1152
  baseDir,
1070
1153
  version,
1071
1154
  "chrome-mac-x64",
@@ -1074,8 +1157,8 @@ function resolveFullChromePath() {
1074
1157
  "MacOS",
1075
1158
  "Google Chrome for Testing"
1076
1159
  ),
1077
- join2(baseDir, version, "chrome-linux64", "chrome"),
1078
- join2(baseDir, version, "chrome-win64", "chrome.exe")
1160
+ join3(baseDir, version, "chrome-linux64", "chrome"),
1161
+ join3(baseDir, version, "chrome-win64", "chrome.exe")
1079
1162
  ];
1080
1163
  for (const binary of candidates) {
1081
1164
  if (existsSync(binary)) return binary;
@@ -1297,7 +1380,8 @@ async function probeWebGlMode(ppt, options, env, label = "") {
1297
1380
  return resolved === "hardware" ? { mode: "hardware" } : { mode: "software", cause: "no-gpu" };
1298
1381
  } catch (err) {
1299
1382
  logResolvedBrowserGpuMode("software", label + formatProbeFailure(err));
1300
- return { mode: "software", cause: "probe-error" };
1383
+ const aborted = err instanceof Error && err.name === "AbortError";
1384
+ return { mode: "software", cause: "probe-error", ...aborted && { aborted } };
1301
1385
  }
1302
1386
  }
1303
1387
  function envWithoutWaylandDisplay() {
@@ -1328,11 +1412,20 @@ function wslAccess(options) {
1328
1412
  const lines = describeWslGpuAccess(options.wslHost);
1329
1413
  return lines ? { wslAccess: lines } : {};
1330
1414
  }
1415
+ async function sharedGpuProbe(options) {
1416
+ const shared = _autoBrowserGpuModeCache ??= probeAutoBrowserGpuMode(options);
1417
+ const outcome = await shared;
1418
+ if (!outcome.aborted) return outcome;
1419
+ if (_autoBrowserGpuModeCache === shared) _autoBrowserGpuModeCache = void 0;
1420
+ const own = await probeAutoBrowserGpuMode(options);
1421
+ if (!own.aborted) _autoBrowserGpuModeCache ??= Promise.resolve(own);
1422
+ return own;
1423
+ }
1331
1424
  function resolveBrowserGpuMode(mode, options = {}) {
1332
1425
  if (mode === "software") return Promise.resolve(mode);
1333
- _autoBrowserGpuModeCache ??= probeAutoBrowserGpuMode(options);
1426
+ const probe = sharedGpuProbe(options);
1334
1427
  if (mode === "auto") {
1335
- return _autoBrowserGpuModeCache.then((probed) => {
1428
+ return probe.then((probed) => {
1336
1429
  if (probed.mode === "software" && probed.wslAccess && !_wslSoftwareNoteLogged) {
1337
1430
  _wslSoftwareNoteLogged = true;
1338
1431
  console.error(buildWslSoftwareNote(probed));
@@ -1340,7 +1433,7 @@ function resolveBrowserGpuMode(mode, options = {}) {
1340
1433
  return probed.mode;
1341
1434
  });
1342
1435
  }
1343
- return _autoBrowserGpuModeCache.then((probed) => {
1436
+ return probe.then((probed) => {
1344
1437
  if (probed.mode === "software" && !_unverifiedHardwareGpuWarned) {
1345
1438
  _unverifiedHardwareGpuWarned = true;
1346
1439
  console.warn(buildUnverifiedHardwareGpuWarning(options.platform ?? process.platform, probed));
@@ -1407,6 +1500,12 @@ async function launchBrowser(fingerprint) {
1407
1500
  env,
1408
1501
  timeout: fingerprint.browserTimeoutMs,
1409
1502
  protocolTimeout: fingerprint.protocolTimeoutMs
1503
+ }).catch(async (error) => {
1504
+ const defaults = await ppt.defaultArgs({
1505
+ headless: true,
1506
+ args: withHyperframesBrowserMarker(args)
1507
+ });
1508
+ throw await explainChromeLaunchFailure(error, fingerprint.executablePath, defaults);
1410
1509
  });
1411
1510
  const probe = (target, timeoutMs) => probeBeginFrameSupport(target, timeoutMs).catch((error) => ({
1412
1511
  supported: true,
@@ -1452,6 +1551,8 @@ async function launchBrowser(fingerprint) {
1452
1551
  }
1453
1552
  function forceCloseBrowserProcess(browser) {
1454
1553
  const proc = browser.process?.();
1554
+ for (const stream of proc?.stdio ?? []) stream?.on("error", () => {
1555
+ });
1455
1556
  if (proc && !proc.killed) {
1456
1557
  try {
1457
1558
  proc.kill("SIGKILL");
@@ -1750,7 +1851,7 @@ identically under Docker. Consider:
1750
1851
 
1751
1852
  // ../engine/src/services/frameCapture.ts
1752
1853
  import { existsSync as existsSync3, mkdirSync, writeFileSync } from "fs";
1753
- import { join as join3 } from "path";
1854
+ import { join as join4 } from "path";
1754
1855
 
1755
1856
  // ../engine/src/services/renderFrameVideoHold.ts
1756
1857
  function holdRenderFrameVideos(ids, renderIdAttr) {
@@ -1783,6 +1884,19 @@ var DrawElementCaptureError = class extends Error {
1783
1884
  this.frameIndex = frameIndex;
1784
1885
  }
1785
1886
  };
1887
+ function markRejectionHandled(promise) {
1888
+ promise.catch(() => {
1889
+ });
1890
+ }
1891
+ function asDrawElementCaptureFailure(frameIndex, encodeResult) {
1892
+ const wrapped = encodeResult.catch((cause) => {
1893
+ if (isDrawElementCaptureError(cause)) throw cause;
1894
+ const reason = cause instanceof Error ? cause.message : String(cause);
1895
+ throw new DrawElementCaptureError(frameIndex, reason, cause);
1896
+ });
1897
+ markRejectionHandled(wrapped);
1898
+ return wrapped;
1899
+ }
1786
1900
  function isDrawElementCaptureError(error) {
1787
1901
  let current = error;
1788
1902
  for (let depth = 0; depth < 5 && typeof current === "object" && current !== null; depth++) {
@@ -6801,9 +6915,9 @@ async function initializeSession(session) {
6801
6915
  }
6802
6916
  async function captureFrameErrorDiagnostics(session, frameIndex, time, error) {
6803
6917
  try {
6804
- const diagnosticsDir = join3(session.outputDir, "diagnostics");
6918
+ const diagnosticsDir = join4(session.outputDir, "diagnostics");
6805
6919
  if (!existsSync3(diagnosticsDir)) mkdirSync(diagnosticsDir, { recursive: true });
6806
- const base = join3(diagnosticsDir, `frame-error-${frameIndex}`);
6920
+ const base = join4(diagnosticsDir, `frame-error-${frameIndex}`);
6807
6921
  const pageScreenshotCanResolve = session.launchCaptureMode !== "beginframe";
6808
6922
  if (pageScreenshotCanResolve) {
6809
6923
  await session.page.screenshot({ path: `${base}.png`, type: "png", fullPage: true });
@@ -7799,7 +7913,7 @@ function frameFileExtension(format) {
7799
7913
  }
7800
7914
  function writeCapturedFrame(session, fileIndex, buffer) {
7801
7915
  const ext = frameFileExtension(session.options.format);
7802
- const framePath = join3(session.outputDir, `frame_${String(fileIndex).padStart(6, "0")}.${ext}`);
7916
+ const framePath = join4(session.outputDir, `frame_${String(fileIndex).padStart(6, "0")}.${ext}`);
7803
7917
  writeFileSync(framePath, buffer);
7804
7918
  return framePath;
7805
7919
  }
@@ -7844,13 +7958,14 @@ async function captureFrameToBufferPipelined(session, frameIndex, time) {
7844
7958
  "boundary screenshot requested on an injected canvas page"
7845
7959
  );
7846
7960
  }
7847
- const { encodeResult } = await produceDrawElementFrame(
7961
+ const produced = await produceDrawElementFrame(
7848
7962
  page,
7849
7963
  options.width,
7850
7964
  options.height,
7851
7965
  options.quality ?? 80,
7852
7966
  true
7853
7967
  );
7968
+ const encodeResult = asDrawElementCaptureFailure(frameIndex, produced.encodeResult);
7854
7969
  const captureTimeMs = Date.now() - startTime;
7855
7970
  session.capturePerf.frames += 1;
7856
7971
  session.capturePerf.seekMs += seekMs;
@@ -7929,7 +8044,10 @@ async function captureFramesBatchPipelined(session, frameIndices, times) {
7929
8044
  const frameIndex = frameIndices[i];
7930
8045
  const encodeResult = encodeResults[i];
7931
8046
  if (frameIndex === void 0 || !encodeResult) break;
7932
- results.push({ frameIndex, encodeResult });
8047
+ results.push({
8048
+ frameIndex,
8049
+ encodeResult: asDrawElementCaptureFailure(frameIndex, encodeResult)
8050
+ });
7933
8051
  }
7934
8052
  if (failedAt !== null) {
7935
8053
  if (isRecoverableDrawElementError(error)) {
@@ -8190,10 +8308,10 @@ function getCapturePerfSummary(session) {
8190
8308
 
8191
8309
  // ../engine/src/services/extractedFrameIndex.ts
8192
8310
  import { readdirSync as readdirSync2 } from "fs";
8193
- import { join as join4 } from "path";
8311
+ import { join as join5 } from "path";
8194
8312
  var FRAME_FILENAME_PREFIX = "frame_";
8195
8313
  function frameSequencePath(dir, framePattern) {
8196
- return join4(dir.replaceAll("%", "%%"), framePattern);
8314
+ return join5(dir.replaceAll("%", "%%"), framePattern);
8197
8315
  }
8198
8316
  var ExtractedFrameSequenceError = class extends Error {
8199
8317
  constructor(message) {
@@ -8223,7 +8341,7 @@ function framePathsFromDirectory(outputDir, format, allowGaps = false) {
8223
8341
  `Duplicate extracted frame index ${index}: ${indexed.get(index)} and ${file}`
8224
8342
  );
8225
8343
  }
8226
- indexed.set(index, join4(outputDir, file));
8344
+ indexed.set(index, join5(outputDir, file));
8227
8345
  }
8228
8346
  if (allowGaps) return new Map([...indexed].sort(([a], [b]) => a - b));
8229
8347
  const ordered = /* @__PURE__ */ new Map();
@@ -8246,7 +8364,7 @@ import {
8246
8364
  existsSync as existsSync5,
8247
8365
  ftruncateSync,
8248
8366
  mkdirSync as mkdirSync2,
8249
- mkdtempSync as mkdtempSync2,
8367
+ mkdtempSync as mkdtempSync3,
8250
8368
  openSync,
8251
8369
  readFileSync as readFileSync3,
8252
8370
  readdirSync as readdirSync3,
@@ -8254,10 +8372,10 @@ import {
8254
8372
  writeFileSync as writeFileSync2,
8255
8373
  writeSync
8256
8374
  } from "fs";
8257
- import { join as join7, dirname as dirname2, extname, resolve } from "path";
8375
+ import { join as join8, dirname as dirname2, extname, resolve } from "path";
8258
8376
 
8259
8377
  // ../engine/src/utils/gpuEncoder.ts
8260
- import { spawn } from "child_process";
8378
+ import { spawn as spawn2 } from "child_process";
8261
8379
 
8262
8380
  // ../engine/src/utils/managedChildProcess.ts
8263
8381
  import { StringDecoder } from "string_decoder";
@@ -8485,7 +8603,7 @@ async function selectUsableGpuEncoder(candidates, isUsable) {
8485
8603
  return null;
8486
8604
  }
8487
8605
  async function detectGpuEncoder() {
8488
- const ffmpeg = spawn(getFfmpegBinary(), ["-encoders"], {
8606
+ const ffmpeg = spawn2(getFfmpegBinary(), ["-encoders"], {
8489
8607
  stdio: ["pipe", "pipe", "pipe"],
8490
8608
  // See runFfmpeg.ts: keeps a console window off the user's desktop on Windows.
8491
8609
  windowsHide: true
@@ -8571,7 +8689,7 @@ function getProbeArgs(encoder) {
8571
8689
  return args;
8572
8690
  }
8573
8691
  async function canUseGpuEncoder(encoder) {
8574
- const ffmpeg = spawn(getFfmpegBinary(), getProbeArgs(encoder), {
8692
+ const ffmpeg = spawn2(getFfmpegBinary(), getProbeArgs(encoder), {
8575
8693
  stdio: ["ignore", "ignore", "pipe"],
8576
8694
  windowsHide: true
8577
8695
  });
@@ -8705,7 +8823,7 @@ function withEvenDimensionPad(vfChain, pixelFormat, width, height) {
8705
8823
  }
8706
8824
 
8707
8825
  // ../engine/src/utils/runFfmpeg.ts
8708
- import { spawn as spawn2 } from "child_process";
8826
+ import { spawn as spawn3 } from "child_process";
8709
8827
  var FFMPEG_SIGTERM_EXIT_LINE = /^Exiting normally, received signal 15\.?\r?$/m;
8710
8828
  function isExternalFfmpegInterruption(result) {
8711
8829
  if (result.terminationReason !== "exit" || result.exitCode === 0) return false;
@@ -8745,19 +8863,19 @@ function formatWindowsFfmpegExit(exitCode) {
8745
8863
  return void 0;
8746
8864
  }
8747
8865
  function formatFfmpegError(exitCode, stderr, tailLines = DEFAULT_STDERR_TAIL_LINES) {
8748
- const tail = (stderr ?? "").split(/\r?\n/).filter((line) => line.length > 0).slice(-tailLines).join("\n");
8866
+ const tail2 = (stderr ?? "").split(/\r?\n/).filter((line) => line.length > 0).slice(-tailLines).join("\n");
8749
8867
  if (exitCode === null) {
8750
- return tail ? `[FFmpeg] ${tail}` : "[FFmpeg] process error";
8868
+ return tail2 ? `[FFmpeg] ${tail2}` : "[FFmpeg] process error";
8751
8869
  }
8752
8870
  const windowsMessage = formatWindowsFfmpegExit(exitCode);
8753
8871
  if (windowsMessage) {
8754
- return tail ? `${windowsMessage}
8872
+ return tail2 ? `${windowsMessage}
8755
8873
  ffmpeg stderr (tail):
8756
- ${tail}` : windowsMessage;
8874
+ ${tail2}` : windowsMessage;
8757
8875
  }
8758
- return tail ? `FFmpeg exited with code ${exitCode}
8876
+ return tail2 ? `FFmpeg exited with code ${exitCode}
8759
8877
  ffmpeg stderr (tail):
8760
- ${tail}` : `FFmpeg exited with code ${exitCode}`;
8878
+ ${tail2}` : `FFmpeg exited with code ${exitCode}`;
8761
8879
  }
8762
8880
  function describeFfmpegFailure(result, timeoutMs) {
8763
8881
  const error = formatFfmpegError(result.exitCode, result.stderr);
@@ -8769,7 +8887,7 @@ function describeFfmpegFailure(result, timeoutMs) {
8769
8887
  return signalOrRequestedStop ? `FFmpeg ended without an exit code (${signalOrRequestedStop}). ${error}` : error;
8770
8888
  }
8771
8889
  function spawnFfmpeg(args) {
8772
- const ffmpeg = spawn2(getFfmpegBinary(), args, { windowsHide: true });
8890
+ const ffmpeg = spawn3(getFfmpegBinary(), args, { windowsHide: true });
8773
8891
  trackChildProcess(ffmpeg);
8774
8892
  return ffmpeg;
8775
8893
  }
@@ -8821,11 +8939,11 @@ async function runFfmpeg(args, opts) {
8821
8939
  }
8822
8940
 
8823
8941
  // ../engine/src/utils/ffprobe.ts
8824
- import { spawn as spawn3 } from "child_process";
8825
- import { createReadStream, mkdtempSync, readFileSync, rmSync, statSync as statSync2 } from "fs";
8942
+ import { spawn as spawn4 } from "child_process";
8943
+ import { createReadStream, mkdtempSync as mkdtempSync2, readFileSync, rmSync, statSync as statSync2 } from "fs";
8826
8944
  import { StringDecoder as StringDecoder2 } from "string_decoder";
8827
- import { tmpdir as tmpdir2 } from "os";
8828
- import { basename, join as join5 } from "path";
8945
+ import { tmpdir as tmpdir3 } from "os";
8946
+ import { basename, join as join6 } from "path";
8829
8947
 
8830
8948
  // ../engine/src/utils/urlInput.ts
8831
8949
  import { existsSync as existsSync4 } from "fs";
@@ -8899,7 +9017,7 @@ async function runFfprobe(filePath, argsWithoutInput, signal, stdoutOptions) {
8899
9017
  "--",
8900
9018
  filePath
8901
9019
  ];
8902
- const proc = spawn3(command, args, {
9020
+ const proc = spawn4(command, args, {
8903
9021
  // Nothing is ever written to the child's stdin; leaving it as a pipe is
8904
9022
  // what lets a stdin-reading invocation block indefinitely.
8905
9023
  stdio: ["ignore", "pipe", "pipe"],
@@ -9093,7 +9211,7 @@ function ffprobeMajor() {
9093
9211
  runtimeFfprobeMajor ??= new Promise((resolve2) => {
9094
9212
  let out = "";
9095
9213
  const binary = getFfprobeBinary();
9096
- const proc = spawn3(binary, ["-version"], { stdio: ["ignore", "pipe", "ignore"] });
9214
+ const proc = spawn4(binary, ["-version"], { stdio: ["ignore", "pipe", "ignore"] });
9097
9215
  proc.stdout.on("data", (chunk) => out += String(chunk));
9098
9216
  proc.on("error", () => resolve2(void 0));
9099
9217
  proc.on("close", () => resolve2(Number(/version n?(\d+)/.exec(out)?.[1]) || void 0));
@@ -9304,8 +9422,8 @@ function parseFrameRate(frameRateStr) {
9304
9422
  async function probeDecodedAlphaPlane(filePath, decoder) {
9305
9423
  let probeDir;
9306
9424
  try {
9307
- probeDir = mkdtempSync(join5(tmpdir2(), "hf-decoded-alpha-"));
9308
- const framePath = join5(probeDir, "frame.nut");
9425
+ probeDir = mkdtempSync2(join6(tmpdir3(), "hf-decoded-alpha-"));
9426
+ const framePath = join6(probeDir, "frame.nut");
9309
9427
  const decoded = await runFfmpeg(
9310
9428
  [
9311
9429
  "-v",
@@ -9725,7 +9843,7 @@ function appendSoftwareEncoderThreadsArg(args, encoder, parallelism = availableP
9725
9843
 
9726
9844
  // ../engine/src/utils/renderProvenance.ts
9727
9845
  import { readFileSync as readFileSync2 } from "fs";
9728
- import { dirname, join as join6 } from "path";
9846
+ import { dirname, join as join7 } from "path";
9729
9847
  import { fileURLToPath } from "url";
9730
9848
  var PROVENANCE_RENDERER_TAG = "hyperframes_renderer";
9731
9849
  var PROVENANCE_VERSION_TAG = "hyperframes_version";
@@ -9736,7 +9854,7 @@ var MAX_WALK_DEPTH = 12;
9736
9854
  function resolveOwnVersionFrom(startDir) {
9737
9855
  let dir = startDir;
9738
9856
  for (let depth = 0; depth < MAX_WALK_DEPTH; depth++) {
9739
- const candidate = join6(dir, "package.json");
9857
+ const candidate = join7(dir, "package.json");
9740
9858
  let pkg;
9741
9859
  try {
9742
9860
  pkg = JSON.parse(readFileSync2(candidate, "utf8"));
@@ -9882,6 +10000,34 @@ function lockedGopCodecParams(codec, gopSize) {
9882
10000
  const shared = "scenecut=0:open-gop=0:repeat-headers=1";
9883
10001
  return codec === "h264" ? shared : `keyint=${gopSize}:min-keyint=${gopSize}:${shared}`;
9884
10002
  }
10003
+ function keyframeIntervalToGopSize(fps, seconds) {
10004
+ return Math.max(1, Math.round(fpsToNumber(fps) * seconds));
10005
+ }
10006
+ var BITRATE_PATTERN = /^(\d+(?:\.\d+)?)([kKmMgG]?)$/;
10007
+ function bitrateToBitsPerSecond(value) {
10008
+ const match = BITRATE_PATTERN.exec(value);
10009
+ if (!match) throw new Error(`[chunkEncoder] invalid bitrate ${JSON.stringify(value)}`);
10010
+ const unit = match[2].toLowerCase();
10011
+ const scale = { g: 1e9, m: 1e6, k: 1e3 }[unit] ?? 1;
10012
+ return Number(match[1]) * scale;
10013
+ }
10014
+ function appendRateCapArgs(args, options) {
10015
+ const { maxBitrate, bufferSize } = options;
10016
+ if (maxBitrate === void 0) {
10017
+ if (bufferSize !== void 0) throw new Error("[chunkEncoder] bufferSize requires maxBitrate");
10018
+ return;
10019
+ }
10020
+ const codec = options.codec ?? "h264";
10021
+ if (codec !== "h264" && codec !== "h265") {
10022
+ throw new Error(`[chunkEncoder] maxBitrate is not supported for codec ${codec}`);
10023
+ }
10024
+ const cap = bitrateToBitsPerSecond(maxBitrate);
10025
+ const buffer = bufferSize !== void 0 ? bitrateToBitsPerSecond(bufferSize) : cap * 2;
10026
+ if (cap <= 0 || buffer <= 0) {
10027
+ throw new Error("[chunkEncoder] maxBitrate and bufferSize must be positive");
10028
+ }
10029
+ args.push("-maxrate", String(Math.round(cap)), "-bufsize", String(Math.round(buffer)));
10030
+ }
9885
10031
  function buildEncoderArgs(options, inputArgs, outputPath, gpuEncoder = null) {
9886
10032
  const {
9887
10033
  fps,
@@ -9901,6 +10047,7 @@ function buildEncoderArgs(options, inputArgs, outputPath, gpuEncoder = null) {
9901
10047
  }
9902
10048
  const args = ["-xerror", ...inputArgs, "-r", fpsToFfmpegArg(fps)];
9903
10049
  const shouldUseGpu = useGpu && gpuEncoder !== null;
10050
+ appendRateCapArgs(args, options);
9904
10051
  if (codec === "h264" || codec === "h265") {
9905
10052
  if (shouldUseGpu) {
9906
10053
  const encoderName = getGpuEncoderName(gpuEncoder, codec);
@@ -10142,7 +10289,7 @@ function buildConcatArgs(concatListPath, outputPath) {
10142
10289
  var concatListSeq = 0;
10143
10290
  function writeConcatList(dir, inputPaths) {
10144
10291
  concatListSeq += 1;
10145
- const listPath = join7(dir, `concat-list-${process.pid}-${concatListSeq}.txt`);
10292
+ const listPath = join8(dir, `concat-list-${process.pid}-${concatListSeq}.txt`);
10146
10293
  const body = inputPaths.map((p) => `file '${resolve(p).replace(/'/g, "'\\''")}'`).join("\n");
10147
10294
  writeFileSync2(listPath, body, "utf-8");
10148
10295
  return listPath;
@@ -10186,7 +10333,7 @@ async function encodeFramesChunkedConcat(framesDir, framePattern, outputPath, op
10186
10333
  const chunkSize = Math.max(30, Math.floor(chunkSizeFrames));
10187
10334
  const chunkCount = Math.ceil(files.length / chunkSize);
10188
10335
  mkdirSync2(dirname2(outputPath), { recursive: true });
10189
- const chunkDir = mkdtempSync2(join7(dirname2(outputPath), "chunk-encode-"));
10336
+ const chunkDir = mkdtempSync3(join8(dirname2(outputPath), "chunk-encode-"));
10190
10337
  const chunkPaths = [];
10191
10338
  for (let i = 0; i < chunkCount; i++) {
10192
10339
  if (signal?.aborted) {
@@ -10202,7 +10349,7 @@ async function encodeFramesChunkedConcat(framesDir, framePattern, outputPath, op
10202
10349
  const startNumber = i * chunkSize;
10203
10350
  const framesInChunk = Math.min(chunkSize, files.length - startNumber);
10204
10351
  const ext = outputPath.endsWith(".webm") ? ".webm" : outputPath.endsWith(".mov") ? ".mov" : ".mp4";
10205
- const chunkPath = join7(chunkDir, `chunk_${String(i).padStart(4, "0")}${ext}`);
10352
+ const chunkPath = join8(chunkDir, `chunk_${String(i).padStart(4, "0")}${ext}`);
10206
10353
  const inputPath = frameSequencePath(framesDir, framePattern);
10207
10354
  const inputArgs = [
10208
10355
  "-framerate",
@@ -10372,14 +10519,14 @@ async function packageHls(videoPath, audioPath, outputDir, options) {
10372
10519
  "-master_pl_name",
10373
10520
  HLS_MASTER_PLAYLIST,
10374
10521
  "-hls_segment_filename",
10375
- join7(outputDir, "%v_%05d.ts"),
10522
+ join8(outputDir, "%v_%05d.ts"),
10376
10523
  // Without these the mpegts muxer starts the stream at PTS 1.4 s.
10377
10524
  "-muxdelay",
10378
10525
  "0",
10379
10526
  "-muxpreload",
10380
10527
  "0"
10381
10528
  );
10382
- args.push("-y", join7(outputDir, "%v.m3u8"));
10529
+ args.push("-y", join8(outputDir, "%v.m3u8"));
10383
10530
  const processTimeout = options.ffmpegProcessTimeout ?? DEFAULT_CONFIG.ffmpegProcessTimeout;
10384
10531
  const result = await runFfmpeg(args, { signal, timeout: processTimeout });
10385
10532
  if (signal?.aborted) {
@@ -10391,7 +10538,7 @@ async function packageHls(videoPath, audioPath, outputDir, options) {
10391
10538
  };
10392
10539
  }
10393
10540
  if (result.success && hasAudio) {
10394
- const masterPath = join7(outputDir, HLS_MASTER_PLAYLIST);
10541
+ const masterPath = join8(outputDir, HLS_MASTER_PLAYLIST);
10395
10542
  let master;
10396
10543
  try {
10397
10544
  master = openSync(masterPath, "r+", 384);
@@ -10496,7 +10643,7 @@ function quantizationTableError(buffer, start, end) {
10496
10643
  }
10497
10644
 
10498
10645
  // ../engine/src/services/streamingEncoder.ts
10499
- import { spawn as spawn4 } from "child_process";
10646
+ import { spawn as spawn5 } from "child_process";
10500
10647
  import { once } from "events";
10501
10648
  import { existsSync as existsSync6, mkdirSync as mkdirSync3, statSync as statSync4 } from "fs";
10502
10649
  import { dirname as dirname3 } from "path";
@@ -10606,6 +10753,7 @@ function buildStreamingArgs(options, outputPath, gpuEncoder = null) {
10606
10753
  }
10607
10754
  args.push("-r", fpsToFfmpegArg(fps));
10608
10755
  const shouldUseGpu = useGpu && gpuEncoder !== null;
10756
+ appendRateCapArgs(args, options);
10609
10757
  if (codec === "h264" || codec === "h265") {
10610
10758
  if (shouldUseGpu) {
10611
10759
  const encoderName = getGpuEncoderName(gpuEncoder, codec);
@@ -10742,7 +10890,7 @@ async function spawnStreamingEncoder(outputPath, options, signal, config) {
10742
10890
  gpuEncoder = await getCachedGpuEncoder();
10743
10891
  }
10744
10892
  const args = buildStreamingArgs(options, outputPath, gpuEncoder);
10745
- const ffmpeg = spawn4(getFfmpegBinary(), args, {
10893
+ const ffmpeg = spawn5(getFfmpegBinary(), args, {
10746
10894
  stdio: ["pipe", "pipe", "pipe"],
10747
10895
  // See runFfmpeg.ts: keeps a console window off the user's desktop on Windows.
10748
10896
  windowsHide: true
@@ -10968,8 +11116,8 @@ function isMemberGroupHidden(groupsById, el) {
10968
11116
  }
10969
11117
 
10970
11118
  // ../engine/src/services/videoFrameExtractor.ts
10971
- import { copyFileSync as copyFileSync2, existsSync as existsSync9, linkSync as linkSync2, mkdirSync as mkdirSync6, rmSync as rmSync5 } from "fs";
10972
- import { join as join11 } from "path";
11119
+ import { copyFileSync as copyFileSync3, existsSync as existsSync9, linkSync as linkSync2, mkdirSync as mkdirSync6, rmSync as rmSync6 } from "fs";
11120
+ import { basename as basename2, join as join12 } from "path";
10973
11121
  import { cpus } from "os";
10974
11122
 
10975
11123
  // ../engine/src/utils/concurrencyLimit.ts
@@ -11011,9 +11159,9 @@ function isKnownInactiveTimelineWindow(element, resolvedStart) {
11011
11159
  }
11012
11160
 
11013
11161
  // ../engine/src/utils/alphaPlaneProbe.ts
11014
- import { mkdtempSync as mkdtempSync3, readFileSync as readFileSync4, rmSync as rmSync2 } from "fs";
11015
- import { tmpdir as tmpdir3 } from "os";
11016
- import { join as join8 } from "path";
11162
+ import { mkdtempSync as mkdtempSync4, readFileSync as readFileSync4, rmSync as rmSync2 } from "fs";
11163
+ import { tmpdir as tmpdir4 } from "os";
11164
+ import { join as join9 } from "path";
11017
11165
  var BYTES_PER_SAMPLE_FRAME = 8 * 8 * 4;
11018
11166
  var MAX_SAMPLE_BYTES = BYTES_PER_SAMPLE_FRAME * 3;
11019
11167
  function sampledRgbaAlphaIsFullyOpaque(buf) {
@@ -11028,8 +11176,8 @@ function sampledRgbaAlphaIsFullyOpaque(buf) {
11028
11176
  async function probeInputAlphaPlane(videoPath, decoder, signal) {
11029
11177
  let probeDir;
11030
11178
  try {
11031
- probeDir = mkdtempSync3(join8(tmpdir3(), "hf-alpha-probe-"));
11032
- const samplePath = join8(probeDir, "alpha.raw");
11179
+ probeDir = mkdtempSync4(join9(tmpdir4(), "hf-alpha-probe-"));
11180
+ const samplePath = join9(probeDir, "alpha.raw");
11033
11181
  const result = await runFfmpeg(
11034
11182
  [
11035
11183
  "-v",
@@ -11071,7 +11219,7 @@ import {
11071
11219
  existsSync as existsSync7,
11072
11220
  fsyncSync,
11073
11221
  linkSync,
11074
- mkdtempSync as mkdtempSync4,
11222
+ mkdtempSync as mkdtempSync5,
11075
11223
  mkdirSync as mkdirSync4,
11076
11224
  lstatSync,
11077
11225
  openSync as openSync2,
@@ -11083,7 +11231,7 @@ import {
11083
11231
  } from "fs";
11084
11232
  import { createHash, randomUUID as randomUUID2 } from "crypto";
11085
11233
  import { BlockList, isIP } from "net";
11086
- import { dirname as dirname4, extname as extname2, join as join9 } from "path";
11234
+ import { dirname as dirname4, extname as extname2, join as join10 } from "path";
11087
11235
  import { Readable, Transform } from "stream";
11088
11236
  import { pipeline } from "stream/promises";
11089
11237
  var inFlightDownloads = /* @__PURE__ */ new Map();
@@ -11275,7 +11423,7 @@ function removeCacheLockDirectoryIfEmpty(lockPath) {
11275
11423
  }
11276
11424
  function releaseOwnedCachePathLock(lockPath, owner) {
11277
11425
  try {
11278
- rmdirSync(join9(lockPath, owner));
11426
+ rmdirSync(join10(lockPath, owner));
11279
11427
  } catch (error) {
11280
11428
  if (error.code === "ENOENT") return;
11281
11429
  throw error;
@@ -11316,12 +11464,12 @@ async function acquireCachePathLock(localPath, timeoutMs, signal) {
11316
11464
  if (createdLock) {
11317
11465
  const owner = `${CACHE_LOCK_OWNER_PREFIX}${randomUUID2()}`;
11318
11466
  try {
11319
- mkdirSync4(join9(lockPath, owner));
11467
+ mkdirSync4(join10(lockPath, owner));
11320
11468
  const entries = readdirSync4(lockPath);
11321
11469
  if (entries.length === 1 && entries[0] === owner) {
11322
11470
  return () => releaseOwnedCachePathLock(lockPath, owner);
11323
11471
  }
11324
- rmdirSync(join9(lockPath, owner));
11472
+ rmdirSync(join10(lockPath, owner));
11325
11473
  removeCacheLockDirectoryIfEmpty(lockPath);
11326
11474
  continue;
11327
11475
  } catch (error) {
@@ -11339,7 +11487,7 @@ async function acquireCachePathLock(localPath, timeoutMs, signal) {
11339
11487
  if (Date.now() - observedLock.stats.mtimeMs > CACHE_LOCK_STALE_MS) {
11340
11488
  if (observedLock.owner) {
11341
11489
  try {
11342
- rmdirSync(join9(lockPath, observedLock.owner));
11490
+ rmdirSync(join10(lockPath, observedLock.owner));
11343
11491
  } catch (error) {
11344
11492
  if (error.code === "ENOENT") continue;
11345
11493
  throw error;
@@ -11347,7 +11495,7 @@ async function acquireCachePathLock(localPath, timeoutMs, signal) {
11347
11495
  removeCacheLockDirectoryIfEmpty(lockPath);
11348
11496
  continue;
11349
11497
  }
11350
- const reclaimPath = join9(lockPath, CACHE_LOCK_RECLAIM_NAME);
11498
+ const reclaimPath = join10(lockPath, CACHE_LOCK_RECLAIM_NAME);
11351
11499
  try {
11352
11500
  mkdirSync4(reclaimPath);
11353
11501
  } catch (error) {
@@ -11788,8 +11936,8 @@ function emitDownloadTelemetry(options, event) {
11788
11936
  }
11789
11937
  }
11790
11938
  async function runDownloadAttempt(url, localPath, timeoutMs, attempt, options, signal) {
11791
- const attemptDir = mkdtempSync4(join9(dirname4(localPath), ".hf-download-"));
11792
- const partialPath = join9(attemptDir, "payload");
11939
+ const attemptDir = mkdtempSync5(join10(dirname4(localPath), ".hf-download-"));
11940
+ const partialPath = join10(attemptDir, "payload");
11793
11941
  const controller = new AbortController();
11794
11942
  let timedOut = false;
11795
11943
  let callerAborted = signal?.aborted ?? false;
@@ -12035,7 +12183,7 @@ async function downloadToTemp(url, destDir, timeoutMs = 3e5, signal, onTransient
12035
12183
  mkdirSync4(destDir, { recursive: true });
12036
12184
  }
12037
12185
  const filename = getFilenameFromUrl(url, validationScope);
12038
- const localPath = join9(destDir, filename);
12186
+ const localPath = join10(destDir, filename);
12039
12187
  const downloadPromise = (async () => {
12040
12188
  const cacheStartedAt = Date.now();
12041
12189
  const reused = await reuseOrInvalidateCachedFile(
@@ -12112,53 +12260,104 @@ import {
12112
12260
  lstatSync as lstatSync2,
12113
12261
  mkdirSync as mkdirSync5,
12114
12262
  readdirSync as readdirSync5,
12115
- rmSync as rmSync4,
12263
+ rmSync as rmSync5,
12116
12264
  statSync as statSync6,
12117
12265
  utimesSync,
12118
12266
  writeFileSync as writeFileSync3
12119
12267
  } from "fs";
12120
12268
 
12121
12269
  // ../engine/src/utils/renameWithRetry.ts
12122
- import { renameSync } from "fs";
12123
- import { rename } from "fs/promises";
12270
+ import { copyFileSync as copyFileSync2, renameSync } from "fs";
12271
+ import { copyFile, rename } from "fs/promises";
12272
+
12273
+ // ../engine/src/utils/removeScratch.ts
12274
+ import { AsyncLocalStorage } from "async_hooks";
12275
+ import { rmSync as rmSync4 } from "fs";
12276
+ var collecting = new AsyncLocalStorage();
12277
+ function removeScratch(path) {
12278
+ try {
12279
+ rmSync4(path, { recursive: true, force: true });
12280
+ } catch {
12281
+ collecting.getStore()?.push(path);
12282
+ }
12283
+ }
12284
+ async function collectScratchLeftovers(run, report) {
12285
+ const left = [];
12286
+ try {
12287
+ return await collecting.run(left, run);
12288
+ } finally {
12289
+ report(left);
12290
+ }
12291
+ }
12292
+
12293
+ // ../engine/src/utils/renameWithRetry.ts
12124
12294
  var RETRYABLE = /* @__PURE__ */ new Set(["EPERM", "EACCES", "EBUSY"]);
12125
12295
  var BACKOFF_MS = [10, 20, 40, 80, 160, 320, 640];
12126
12296
  function isRetryable(error, platform) {
12127
12297
  if (platform !== "win32") return false;
12128
12298
  return RETRYABLE.has(error?.code ?? "");
12129
12299
  }
12300
+ function nextStep(error, attempt, options, platform) {
12301
+ if (!isRetryable(error, platform)) return "throw";
12302
+ if (attempt < BACKOFF_MS.length) return "wait";
12303
+ return options.copyFallback ? "copy" : "throw";
12304
+ }
12130
12305
  function sleepSync(ms) {
12131
12306
  Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
12132
12307
  }
12133
12308
  function renameWithRetry(from, to, options = {}) {
12134
12309
  const doRename = options.rename ?? renameSync;
12310
+ const doCopy = options.copy ?? copyFileSync2;
12135
12311
  const platform = options.platform ?? process.platform;
12136
12312
  for (let attempt = 0; ; attempt++) {
12137
12313
  try {
12138
12314
  doRename(from, to);
12139
12315
  return;
12140
12316
  } catch (error) {
12141
- if (attempt >= BACKOFF_MS.length || !isRetryable(error, platform)) throw error;
12142
- sleepSync(BACKOFF_MS[attempt]);
12317
+ const step = nextStep(error, attempt, options, platform);
12318
+ if (step === "throw") throw error;
12319
+ if (step === "wait") {
12320
+ sleepSync(BACKOFF_MS[attempt]);
12321
+ continue;
12322
+ }
12323
+ try {
12324
+ doCopy(from, to);
12325
+ } catch {
12326
+ throw error;
12327
+ }
12328
+ removeScratch(from);
12329
+ return;
12143
12330
  }
12144
12331
  }
12145
12332
  }
12146
12333
  async function renameWithRetryAsync(from, to, options = {}) {
12147
12334
  const doRename = options.rename ?? rename;
12335
+ const doCopy = options.copy ?? copyFile;
12148
12336
  const platform = options.platform ?? process.platform;
12149
12337
  for (let attempt = 0; ; attempt++) {
12150
12338
  try {
12151
12339
  await doRename(from, to);
12152
12340
  return;
12153
12341
  } catch (error) {
12154
- if (attempt >= BACKOFF_MS.length || !isRetryable(error, platform)) throw error;
12155
- await new Promise((resolve2) => setTimeout(resolve2, BACKOFF_MS[attempt]));
12342
+ const step = nextStep(error, attempt, options, platform);
12343
+ if (step === "throw") throw error;
12344
+ if (step === "wait") {
12345
+ await new Promise((resolve2) => setTimeout(resolve2, BACKOFF_MS[attempt]));
12346
+ continue;
12347
+ }
12348
+ try {
12349
+ await doCopy(from, to);
12350
+ } catch {
12351
+ throw error;
12352
+ }
12353
+ removeScratch(from);
12354
+ return;
12156
12355
  }
12157
12356
  }
12158
12357
  }
12159
12358
 
12160
12359
  // ../engine/src/services/extractionCache.ts
12161
- import { join as join10 } from "path";
12360
+ import { join as join11 } from "path";
12162
12361
  var COMPLETE_SENTINEL = ".hf-complete";
12163
12362
  var GC_MARKER = ".hf-last-gc";
12164
12363
  var SCHEMA_PREFIX = "hfcache-v8-";
@@ -12209,8 +12408,8 @@ function hasFrameFiles(dir) {
12209
12408
  }
12210
12409
  function lookupCacheEntry(rootDir, input) {
12211
12410
  const keyHash = computeCacheKey(input);
12212
- const dir = join10(rootDir, cacheEntryDirName(keyHash));
12213
- const complete = existsSync8(join10(dir, COMPLETE_SENTINEL)) && hasFrameFiles(dir);
12411
+ const dir = join11(rootDir, cacheEntryDirName(keyHash));
12412
+ const complete = existsSync8(join11(dir, COMPLETE_SENTINEL)) && hasFrameFiles(dir);
12214
12413
  return { entry: { dir, keyHash }, hit: complete };
12215
12414
  }
12216
12415
  function partialCacheEntryDir(entry) {
@@ -12221,13 +12420,13 @@ function isTargetExistsRenameError(err) {
12221
12420
  return code === "EEXIST" || code === "ENOTEMPTY" || code === "EPERM";
12222
12421
  }
12223
12422
  function adoptPublishedWinner(entry, partialDir) {
12224
- if (!existsSync8(join10(entry.dir, COMPLETE_SENTINEL)) || !hasFrameFiles(entry.dir)) return null;
12423
+ if (!existsSync8(join11(entry.dir, COMPLETE_SENTINEL)) || !hasFrameFiles(entry.dir)) return null;
12225
12424
  removeDir(partialDir);
12226
12425
  return { dir: entry.dir, published: true };
12227
12426
  }
12228
12427
  function publishCacheEntry(entry, partialDir) {
12229
12428
  try {
12230
- writeFileSync3(join10(partialDir, COMPLETE_SENTINEL), "", "utf-8");
12429
+ writeFileSync3(join11(partialDir, COMPLETE_SENTINEL), "", "utf-8");
12231
12430
  } catch {
12232
12431
  return { dir: partialDir, published: false };
12233
12432
  }
@@ -12240,7 +12439,7 @@ function publishCacheEntry(entry, partialDir) {
12240
12439
  const winner = adoptPublishedWinner(entry, partialDir);
12241
12440
  if (winner) return winner;
12242
12441
  try {
12243
- rmSync4(entry.dir, { recursive: true, force: true });
12442
+ rmSync5(entry.dir, { recursive: true, force: true });
12244
12443
  } catch {
12245
12444
  return { dir: partialDir, published: false };
12246
12445
  }
@@ -12258,7 +12457,7 @@ function touchCacheDir(dir) {
12258
12457
  } catch {
12259
12458
  }
12260
12459
  try {
12261
- utimesSync(join10(dir, COMPLETE_SENTINEL), now, now);
12460
+ utimesSync(join11(dir, COMPLETE_SENTINEL), now, now);
12262
12461
  } catch {
12263
12462
  }
12264
12463
  }
@@ -12287,7 +12486,7 @@ function directorySizeBytes(path) {
12287
12486
  return 0;
12288
12487
  }
12289
12488
  for (const child of children) {
12290
- const childPath = join10(path, child);
12489
+ const childPath = join11(path, child);
12291
12490
  try {
12292
12491
  const stat = lstatSync2(childPath);
12293
12492
  if (stat.isDirectory()) {
@@ -12302,7 +12501,7 @@ function directorySizeBytes(path) {
12302
12501
  }
12303
12502
  function removeDir(path) {
12304
12503
  try {
12305
- rmSync4(path, { recursive: true, force: true });
12504
+ rmSync5(path, { recursive: true, force: true });
12306
12505
  } catch {
12307
12506
  }
12308
12507
  }
@@ -12316,7 +12515,7 @@ function collectGcEntry(dir, name, now, minAgeMs, stats, remove) {
12316
12515
  }
12317
12516
  let lastUseMs = dirStat.mtimeMs;
12318
12517
  try {
12319
- lastUseMs = statSync6(join10(dir, COMPLETE_SENTINEL)).mtimeMs;
12518
+ lastUseMs = statSync6(join11(dir, COMPLETE_SENTINEL)).mtimeMs;
12320
12519
  } catch {
12321
12520
  }
12322
12521
  return { dir, size: directorySizeBytes(dir), lastUseMs, ageMs: now - lastUseMs };
@@ -12326,14 +12525,14 @@ function collectGcEntry(dir, name, now, minAgeMs, stats, remove) {
12326
12525
  }
12327
12526
  function gcSweepDue(rootDir, maxAgeMs) {
12328
12527
  try {
12329
- return Date.now() - statSync6(join10(rootDir, GC_MARKER)).mtimeMs > maxAgeMs;
12528
+ return Date.now() - statSync6(join11(rootDir, GC_MARKER)).mtimeMs > maxAgeMs;
12330
12529
  } catch {
12331
12530
  return true;
12332
12531
  }
12333
12532
  }
12334
12533
  function markGcSweep(rootDir) {
12335
12534
  try {
12336
- writeFileSync3(join10(rootDir, GC_MARKER), "", "utf-8");
12535
+ writeFileSync3(join11(rootDir, GC_MARKER), "", "utf-8");
12337
12536
  } catch {
12338
12537
  }
12339
12538
  }
@@ -12348,7 +12547,7 @@ function gcExtractionCache(rootDir, opts) {
12348
12547
  for (const child of readdirSync5(rootDir, { withFileTypes: true })) {
12349
12548
  if (!child.isDirectory() || !isCacheLikeChild(child.name)) continue;
12350
12549
  const entry = collectGcEntry(
12351
- join10(rootDir, child.name),
12550
+ join11(rootDir, child.name),
12352
12551
  child.name,
12353
12552
  now,
12354
12553
  opts.minAgeMs,
@@ -12511,18 +12710,28 @@ function downloadFailureGroup(source, error) {
12511
12710
  };
12512
12711
  }
12513
12712
  var VideoSourceExtractionError = class extends Error {
12514
- constructor(kind, retryable, message, diagnostic = message) {
12713
+ constructor(kind, retryable, message, diagnostic = message, ffmpegReason) {
12515
12714
  super(message);
12516
12715
  this.kind = kind;
12517
12716
  this.retryable = retryable;
12518
12717
  this.diagnostic = diagnostic;
12718
+ this.ffmpegReason = ffmpegReason;
12519
12719
  this.name = "VideoSourceExtractionError";
12520
12720
  }
12521
12721
  kind;
12522
12722
  retryable;
12523
12723
  diagnostic;
12724
+ ffmpegReason;
12524
12725
  hyperframesVideoSourceExtractionError = true;
12525
12726
  };
12727
+ var FFMPEG_REASON_LINES = 3;
12728
+ var FFMPEG_REASON_CHARS = 300;
12729
+ function ffmpegReasonFrom(stderr, paths) {
12730
+ let text = stderr;
12731
+ for (const known of paths.filter(Boolean).sort((a, b) => b.length - a.length))
12732
+ text = text.split(known).join("<path>");
12733
+ return text.replace(/[a-z][a-z\d+.-]*:\/\/[^\s'"]+/gi, "<url>").replace(/(?:[a-z]:)?(?:[\\/][^\s\\/:'"]+){2,}/gi, "<path>").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).slice(-FFMPEG_REASON_LINES).join(" | ").slice(-FFMPEG_REASON_CHARS);
12734
+ }
12526
12735
  function isVideoSourceExtractionError(error) {
12527
12736
  return typeof error === "object" && error !== null && "hyperframesVideoSourceExtractionError" in error && error.hyperframesVideoSourceExtractionError === true;
12528
12737
  }
@@ -12909,7 +13118,7 @@ async function extractVideoFramesRangeUnredacted(videoPath, videoId, startTime,
12909
13118
  const normalizedFps = toFps(options.fps);
12910
13119
  const fps = fpsToNumber(normalizedFps);
12911
13120
  const ffmpegFps = fpsToFfmpegArg(normalizedFps);
12912
- const videoOutputDir = outputDirOverride ?? join11(outputDir, videoId);
13121
+ const videoOutputDir = outputDirOverride ?? join12(outputDir, videoId);
12913
13122
  if (!existsSync9(videoOutputDir)) mkdirSync6(videoOutputDir, { recursive: true });
12914
13123
  let metadata;
12915
13124
  try {
@@ -12947,9 +13156,6 @@ async function extractVideoFramesRangeUnredacted(videoPath, videoId, startTime,
12947
13156
  throw new Error("frameRanges extraction needs a constant-frame-rate source");
12948
13157
  }
12949
13158
  const args = urlInputArgs(videoPath);
12950
- if (decodeWithVideoToolbox) {
12951
- args.push("-hwaccel", "videotoolbox");
12952
- }
12953
13159
  if (codecMayHaveAlpha(metadata.videoCodec)) {
12954
13160
  args.push("-c:v", decoderForCodec(metadata.videoCodec));
12955
13161
  }
@@ -12997,8 +13203,8 @@ async function extractVideoFramesRangeUnredacted(videoPath, videoId, startTime,
12997
13203
  const segmentFrames = Math.round(EXTRACTION_SEGMENT_SECONDS * fps);
12998
13204
  const totalFrames = extractionFrameCountForDuration(duration, normalizedFps, metadata.isVFR);
12999
13205
  const boundVfrFrameCount = metadata.isVFR && totalFrames > 0;
13000
- const processResult = sampleAtOutputFps && (options.frameRanges || boundVfrFrameCount || totalFrames > segmentFrames) ? await runSegmentedExtraction({
13001
- decodeArgs,
13206
+ const extract = (hwaccel) => sampleAtOutputFps && (options.frameRanges || boundVfrFrameCount || totalFrames > segmentFrames) ? runSegmentedExtraction({
13207
+ decodeArgs: [...hwaccel, ...decodeArgs],
13002
13208
  filterAndEncodeArgs: (seek) => [...filterArgsFor(seek), ...encodeArgs],
13003
13209
  videoPath,
13004
13210
  startTime,
@@ -13009,10 +13215,17 @@ async function extractVideoFramesRangeUnredacted(videoPath, videoId, startTime,
13009
13215
  segmentFrames
13010
13216
  ),
13011
13217
  runOptions
13012
- }) : await inExtractionSlot(
13013
- () => runFfmpeg([...args, ...filterArgsFor(startTime), ...encodeArgs], runOptions),
13218
+ }) : inExtractionSlot(
13219
+ () => runFfmpeg(
13220
+ [...hwaccel, ...args, ...filterArgsFor(startTime), ...encodeArgs],
13221
+ runOptions
13222
+ ),
13014
13223
  signal
13015
13224
  );
13225
+ let processResult = await extract(decodeWithVideoToolbox ? ["-hwaccel", "videotoolbox"] : []);
13226
+ const ffmpegExitedFailing = processResult.terminationReason === "exit" && !processResult.success && !processResult.failureReason;
13227
+ const videoToolboxWasOptional = decodeWithVideoToolbox && !keepsHdrForChrome;
13228
+ if (ffmpegExitedFailing && videoToolboxWasOptional) processResult = await extract([]);
13016
13229
  if (processResult.failureReason === "external_interruption") {
13017
13230
  throw new VideoSourceExtractionError(
13018
13231
  "external_interruption",
@@ -13032,12 +13245,18 @@ async function extractVideoFramesRangeUnredacted(videoPath, videoId, startTime,
13032
13245
  const timedOut = processResult.terminationReason === "inactivity";
13033
13246
  const timeoutSuffix = timedOut ? ` (no new frame for ${ffmpegProcessTimeout} ms)` : "";
13034
13247
  const diagnostic = `${hdrPrefix}FFmpeg exited with code ${processResult.exitCode}${timeoutSuffix}: ` + processResult.stderr.slice(-500);
13248
+ const ffmpegReason = ffmpegReasonFrom(processResult.stderr, [
13249
+ videoPath,
13250
+ basename2(videoPath),
13251
+ videoOutputDir
13252
+ ]);
13035
13253
  if (timedOut) {
13036
13254
  throw new VideoSourceExtractionError(
13037
13255
  "ffmpeg_timeout",
13038
13256
  true,
13039
13257
  "Video frame extraction timed out",
13040
- diagnostic
13258
+ diagnostic,
13259
+ ffmpegReason
13041
13260
  );
13042
13261
  }
13043
13262
  const transientIo = /resource temporarily unavailable|device or resource busy|input\/output error/i.test(
@@ -13047,7 +13266,8 @@ async function extractVideoFramesRangeUnredacted(videoPath, videoId, startTime,
13047
13266
  transientIo ? "ffmpeg_transient" : "ffmpeg_failed",
13048
13267
  transientIo,
13049
13268
  transientIo ? "Video frame extraction hit a transient I/O failure" : "Video source could not be decoded",
13050
- diagnostic
13269
+ diagnostic,
13270
+ ffmpegReason
13051
13271
  );
13052
13272
  }
13053
13273
  const framePaths = framePathsFromDirectory(videoOutputDir, format, !!options.frameRanges);
@@ -13311,7 +13531,7 @@ function linkOrCopyFrame(src, dest) {
13311
13531
  try {
13312
13532
  linkSync2(src, dest);
13313
13533
  } catch {
13314
- copyFileSync2(src, dest);
13534
+ copyFileSync3(src, dest);
13315
13535
  }
13316
13536
  }
13317
13537
  function supersetGroupingKey(work, fps) {
@@ -13401,7 +13621,7 @@ function planSupersetGroups(misses, fps) {
13401
13621
  }
13402
13622
  function sliceSupersetMember(member, superset, outputDir, fps, configuredFps) {
13403
13623
  const { work } = member.miss;
13404
- rmSync5(outputDir, { recursive: true, force: true });
13624
+ rmSync6(outputDir, { recursive: true, force: true });
13405
13625
  mkdirSync6(outputDir, { recursive: true });
13406
13626
  const requestedFrames = extractionFrameCountForDuration(
13407
13627
  work.videoDuration,
@@ -13413,7 +13633,7 @@ function sliceSupersetMember(member, superset, outputDir, fps, configuredFps) {
13413
13633
  for (let i = 0; i < frameCount; i += 1) {
13414
13634
  const sourceFrame = superset.framePaths.get(member.offsetFrames + i);
13415
13635
  if (!sourceFrame) throw new Error(`superset frame ${member.offsetFrames + i} missing`);
13416
- linkOrCopyFrame(sourceFrame, join11(outputDir, frameFileName(i + 1, work.format)));
13636
+ linkOrCopyFrame(sourceFrame, join12(outputDir, frameFileName(i + 1, work.format)));
13417
13637
  }
13418
13638
  return extractedFramesFromDirectory(work, outputDir, work.videoPath, fps);
13419
13639
  }
@@ -13469,7 +13689,7 @@ async function extractAllVideoFrames(videos, baseDir, options, signal, config, c
13469
13689
  continue;
13470
13690
  }
13471
13691
  if (isHttpUrl(videoPath)) {
13472
- const downloadDir = join11(options.outputDir, DOWNLOAD_SUBDIR);
13692
+ const downloadDir = join12(options.outputDir, DOWNLOAD_SUBDIR);
13473
13693
  mkdirSync6(downloadDir, { recursive: true });
13474
13694
  videoPath = await downloadToTemp(
13475
13695
  videoPath,
@@ -13498,19 +13718,15 @@ async function extractAllVideoFrames(videos, baseDir, options, signal, config, c
13498
13718
  }
13499
13719
  resolvedVideos.push({ video, videoPath });
13500
13720
  } catch (err) {
13501
- const classified = classifyVideoExtractionError(err);
13502
13721
  errors.push({
13503
- videoId: video.id,
13504
- kind: classified.kind,
13505
- retryable: classified.retryable,
13506
- ...err instanceof UrlDownloadError ? { group: downloadFailureGroup(video.src, err) } : {},
13507
- error: classified.diagnostic
13722
+ ...extractionError(video.id, err),
13723
+ ...err instanceof UrlDownloadError ? { group: downloadFailureGroup(video.src, err) } : {}
13508
13724
  });
13509
13725
  }
13510
13726
  }
13511
13727
  breakdown.resolveMs = Date.now() - phase1Start;
13512
13728
  const contentKeyedDirs = [
13513
- join11(options.outputDir, DOWNLOAD_SUBDIR),
13729
+ join12(options.outputDir, DOWNLOAD_SUBDIR),
13514
13730
  ...options.contentKeyedDirs ?? []
13515
13731
  ];
13516
13732
  const cacheKeyInputs = resolvedVideos.map(({ video, videoPath }) => {
@@ -13645,7 +13861,8 @@ async function extractAllVideoFrames(videos, baseDir, options, signal, config, c
13645
13861
  videoId,
13646
13862
  kind: classified.kind,
13647
13863
  retryable: classified.retryable,
13648
- error: classified.diagnostic
13864
+ error: classified.diagnostic,
13865
+ ...classified.ffmpegReason ? { ffmpegReason: classified.ffmpegReason } : {}
13649
13866
  };
13650
13867
  }
13651
13868
  function scopedExtractionOptions(work) {
@@ -13717,7 +13934,7 @@ async function extractAllVideoFrames(videos, baseDir, options, signal, config, c
13717
13934
  async function extractDirectMiss(miss, maxTransientRetries = options.maxTransientRetries ?? 0) {
13718
13935
  const { work, cacheTarget } = miss;
13719
13936
  if (!cacheTarget) {
13720
- const outputDir = join11(options.outputDir, work.video.id);
13937
+ const outputDir = join12(options.outputDir, work.video.id);
13721
13938
  const attempted2 = await runVideoExtractionWithRetry(
13722
13939
  () => extractVideoFramesRange(
13723
13940
  work.videoPath,
@@ -13733,14 +13950,14 @@ async function extractAllVideoFrames(videos, baseDir, options, signal, config, c
13733
13950
  maxTransientRetries,
13734
13951
  onRetry: () => {
13735
13952
  recordTransientRetries(1);
13736
- rmSync5(outputDir, { recursive: true, force: true });
13953
+ rmSync6(outputDir, { recursive: true, force: true });
13737
13954
  }
13738
13955
  }
13739
13956
  );
13740
13957
  return attempted2.result;
13741
13958
  }
13742
13959
  const partialDir = partialCacheEntryDir(cacheTarget.entry);
13743
- rmSync5(partialDir, { recursive: true, force: true });
13960
+ rmSync6(partialDir, { recursive: true, force: true });
13744
13961
  mkdirSync6(partialDir, { recursive: true });
13745
13962
  const attempted = await runVideoExtractionWithRetry(
13746
13963
  () => extractVideoFramesRange(
@@ -13758,7 +13975,7 @@ async function extractAllVideoFrames(videos, baseDir, options, signal, config, c
13758
13975
  maxTransientRetries,
13759
13976
  onRetry: () => {
13760
13977
  recordTransientRetries(1);
13761
- rmSync5(partialDir, { recursive: true, force: true });
13978
+ rmSync6(partialDir, { recursive: true, force: true });
13762
13979
  mkdirSync6(partialDir, { recursive: true });
13763
13980
  }
13764
13981
  }
@@ -13783,7 +14000,7 @@ async function extractAllVideoFrames(videos, baseDir, options, signal, config, c
13783
14000
  const tailFrames = Math.min(expectedFrames, Math.ceil(fps));
13784
14001
  if (expectedFrames <= tailFrames) return null;
13785
14002
  const deferred = (totalFrames) => {
13786
- const outputDir = join11(options.outputDir, work.video.id);
14003
+ const outputDir = join12(options.outputDir, work.video.id);
13787
14004
  mkdirSync6(outputDir, { recursive: true });
13788
14005
  return {
13789
14006
  videoId: work.video.id,
@@ -13820,9 +14037,9 @@ async function extractAllVideoFrames(videos, baseDir, options, signal, config, c
13820
14037
  const totalFrames = firstTailFrame + storedTailFrames;
13821
14038
  return totalFrames <= expectedFrames * 0.6 ? null : deferred(totalFrames);
13822
14039
  }
13823
- const probeDir = join11(options.outputDir, `${work.video.id}.tail-probe`);
14040
+ const probeDir = join12(options.outputDir, `${work.video.id}.tail-probe`);
13824
14041
  try {
13825
- const tail = await extractVideoFramesRange(
14042
+ const tail2 = await extractVideoFramesRange(
13826
14043
  work.videoPath,
13827
14044
  work.video.id,
13828
14045
  work.extractionMediaStart,
@@ -13836,13 +14053,13 @@ async function extractAllVideoFrames(videos, baseDir, options, signal, config, c
13836
14053
  config,
13837
14054
  probeDir
13838
14055
  );
13839
- const totalFrames = firstTailFrame + tail.totalFrames;
14056
+ const totalFrames = firstTailFrame + tail2.totalFrames;
13840
14057
  if (totalFrames <= expectedFrames * 0.6) return null;
13841
14058
  return deferred(totalFrames);
13842
14059
  } catch {
13843
14060
  return null;
13844
14061
  } finally {
13845
- rmSync5(probeDir, { recursive: true, force: true });
14062
+ rmSync6(probeDir, { recursive: true, force: true });
13846
14063
  }
13847
14064
  }
13848
14065
  async function executeDirectMiss(miss, maxTransientRetries = options.maxTransientRetries ?? 0) {
@@ -13859,7 +14076,7 @@ async function extractAllVideoFrames(videos, baseDir, options, signal, config, c
13859
14076
  return sliceSupersetMember(
13860
14077
  member,
13861
14078
  superset,
13862
- join11(options.outputDir, work.video.id),
14079
+ join12(options.outputDir, work.video.id),
13863
14080
  fps,
13864
14081
  configuredFps
13865
14082
  );
@@ -13876,9 +14093,9 @@ async function extractAllVideoFrames(videos, baseDir, options, signal, config, c
13876
14093
  async function executeSupersetGroup(group) {
13877
14094
  const first = group.members[0]?.miss.work;
13878
14095
  if (!first) return [];
13879
- const tempDir = cacheRootDir ? join11(cacheRootDir, `${group.groupId}.partial-${process.pid}`) : join11(options.outputDir, group.groupId);
14096
+ const tempDir = cacheRootDir ? join12(cacheRootDir, `${group.groupId}.partial-${process.pid}`) : join12(options.outputDir, group.groupId);
13880
14097
  try {
13881
- rmSync5(tempDir, { recursive: true, force: true });
14098
+ rmSync6(tempDir, { recursive: true, force: true });
13882
14099
  const superset = await extractVideoFramesRange(
13883
14100
  first.videoPath,
13884
14101
  group.groupId,
@@ -13911,7 +14128,7 @@ async function extractAllVideoFrames(videos, baseDir, options, signal, config, c
13911
14128
  );
13912
14129
  return fallback;
13913
14130
  } finally {
13914
- rmSync5(tempDir, { recursive: true, force: true });
14131
+ rmSync6(tempDir, { recursive: true, force: true });
13915
14132
  }
13916
14133
  }
13917
14134
  const preparedExtractions = await Promise.all(
@@ -14021,12 +14238,7 @@ async function extractAllVideoFrames(videos, baseDir, options, signal, config, c
14021
14238
  const isFollower = outcome.error.videoId !== prepared.work.video.id;
14022
14239
  const message = isFollower ? `[shared extraction, leader ${outcome.error.videoId}] ${outcome.error.error}` : outcome.error.error;
14023
14240
  results.push({
14024
- error: {
14025
- videoId: prepared.work.video.id,
14026
- kind: outcome.error.kind,
14027
- retryable: outcome.error.retryable,
14028
- error: message
14029
- }
14241
+ error: { ...outcome.error, videoId: prepared.work.video.id, error: message }
14030
14242
  });
14031
14243
  continue;
14032
14244
  }
@@ -14220,7 +14432,7 @@ var FrameLookupTable = class {
14220
14432
  for (const video of this.videos.values()) {
14221
14433
  if (video.extracted.ownedByLookup) continue;
14222
14434
  if (existsSync9(video.extracted.outputDir)) {
14223
- rmSync5(video.extracted.outputDir, { recursive: true, force: true });
14435
+ rmSync6(video.extracted.outputDir, { recursive: true, force: true });
14224
14436
  }
14225
14437
  }
14226
14438
  this.videos.clear();
@@ -14725,8 +14937,8 @@ async function queryElementStacking(page, nativeHdrIds) {
14725
14937
  }
14726
14938
 
14727
14939
  // ../engine/src/services/audioMixer.ts
14728
- import { closeSync as closeSync4, existsSync as existsSync11, mkdirSync as mkdirSync7, mkdtempSync as mkdtempSync8, openSync as openSync4, rmSync as rmSync9, writeFileSync as writeFileSync7 } from "fs";
14729
- import { join as join15, dirname as dirname7, isAbsolute, relative } from "path";
14940
+ import { closeSync as closeSync4, existsSync as existsSync11, mkdirSync as mkdirSync7, mkdtempSync as mkdtempSync9, openSync as openSync4, rmSync as rmSync8, writeFileSync as writeFileSync7 } from "fs";
14941
+ import { join as join16, dirname as dirname7, isAbsolute, relative } from "path";
14730
14942
 
14731
14943
  // ../engine/src/utils/notMediaPayload.ts
14732
14944
  import { createHash as createHash3 } from "crypto";
@@ -14845,8 +15057,8 @@ import { cpus as cpus2 } from "os";
14845
15057
 
14846
15058
  // ../engine/src/services/aacEncode.ts
14847
15059
  import { execFile as execFile3 } from "child_process";
14848
- import { mkdtempSync as mkdtempSync5, readFileSync as readFileSync5, rmSync as rmSync6, writeFileSync as writeFileSync4 } from "fs";
14849
- import { dirname as dirname5, join as join12 } from "path";
15060
+ import { mkdtempSync as mkdtempSync6, readFileSync as readFileSync5, writeFileSync as writeFileSync4 } from "fs";
15061
+ import { dirname as dirname5, join as join13 } from "path";
14850
15062
  var SAMPLE_RATE = 48e3;
14851
15063
  var FRAME_SAMPLES = 1024;
14852
15064
  var MIN_SEGMENT_SECONDS = 60;
@@ -14909,11 +15121,11 @@ async function encodeAac(input, outputPath, totalDuration, {
14909
15121
  if (!await supportsSettsDuration()) {
14910
15122
  return encodeInOnePass(input, outputPath, { signal, timeout, filter });
14911
15123
  }
14912
- const dir = mkdtempSync5(join12(dirname5(outputPath), ".aac-segments-"));
15124
+ const dir = mkdtempSync6(join13(dirname5(outputPath), ".aac-segments-"));
14913
15125
  try {
14914
15126
  const segments = planSegments(totalDuration, count).map((segment, k) => ({
14915
15127
  ...segment,
14916
- path: join12(dir, `${k}.aac`)
15128
+ path: join13(dir, `${k}.aac`)
14917
15129
  }));
14918
15130
  const results = await Promise.all(
14919
15131
  segments.map(
@@ -14940,7 +15152,7 @@ async function encodeAac(input, outputPath, totalDuration, {
14940
15152
  );
14941
15153
  const failed = results.find((result) => !result.success);
14942
15154
  if (failed) return failed;
14943
- const joined = join12(dir, "joined.aac");
15155
+ const joined = join13(dir, "joined.aac");
14944
15156
  const frames = segments.flatMap(({ path, keepFrom, keepTo }) => {
14945
15157
  const segmentFrames = splitAdtsFrames(readFileSync5(path));
14946
15158
  if (segmentFrames.length < keepTo) {
@@ -14971,7 +15183,7 @@ async function encodeAac(input, outputPath, totalDuration, {
14971
15183
  const slowest = Math.max(...results.map((result) => result.durationMs));
14972
15184
  return { ...muxed, durationMs: slowest + muxed.durationMs };
14973
15185
  } finally {
14974
- rmSync6(dir, { recursive: true, force: true });
15186
+ removeScratch(dir);
14975
15187
  }
14976
15188
  }
14977
15189
 
@@ -15074,8 +15286,8 @@ function audioFailureDiagnostics(values) {
15074
15286
  }
15075
15287
 
15076
15288
  // ../engine/src/services/audioVolumeEnvelope.ts
15077
- import { mkdtempSync as mkdtempSync6, readFileSync as readFileSync6, rmSync as rmSync7, writeFileSync as writeFileSync5 } from "fs";
15078
- import { dirname as dirname6, join as join13 } from "path";
15289
+ import { mkdtempSync as mkdtempSync7, readFileSync as readFileSync6, rmSync as rmSync7, writeFileSync as writeFileSync5 } from "fs";
15290
+ import { dirname as dirname6, join as join14 } from "path";
15079
15291
 
15080
15292
  // ../core/dist/runtime/mediaVolumeEnvelope.js
15081
15293
  function normaliseEnvelope(keyframes, trackStart, baseVolume) {
@@ -15201,8 +15413,8 @@ function applyVolumeEnvelopeToWav(wavPath, keyframes, trackStart, baseVolume) {
15201
15413
  const layout = parseWavLayout(buffer);
15202
15414
  if (!layout) return false;
15203
15415
  scaleSamples(buffer, layout, gainAt);
15204
- stagingDir = mkdtempSync6(join13(dirname6(wavPath), ".hf-volume-"));
15205
- const tempPath = join13(stagingDir, "audio.wav");
15416
+ stagingDir = mkdtempSync7(join14(dirname6(wavPath), ".hf-volume-"));
15417
+ const tempPath = join14(stagingDir, "audio.wav");
15206
15418
  writeFileSync5(tempPath, buffer, { flag: "wx" });
15207
15419
  renameWithRetry(tempPath, wavPath);
15208
15420
  return true;
@@ -15432,17 +15644,16 @@ function chainTailSeconds(chain, automation) {
15432
15644
  import {
15433
15645
  closeSync as closeSync3,
15434
15646
  existsSync as existsSync10,
15435
- mkdtempSync as mkdtempSync7,
15647
+ mkdtempSync as mkdtempSync8,
15436
15648
  openSync as openSync3,
15437
15649
  readFileSync as readFileSync7,
15438
15650
  readSync,
15439
- rmSync as rmSync8,
15440
15651
  statSync as statSync7,
15441
15652
  writeFileSync as writeFileSync6,
15442
15653
  writeSync as writeSync2
15443
15654
  } from "fs";
15444
- import { tmpdir as tmpdir4 } from "os";
15445
- import { join as join14 } from "path";
15655
+ import { tmpdir as tmpdir5 } from "os";
15656
+ import { join as join15 } from "path";
15446
15657
  import { pathToFileURL } from "url";
15447
15658
 
15448
15659
  // ../core/dist/generated/audio-fx-runtime-inline.js
@@ -15794,7 +16005,7 @@ async function applyAudioFxChain(inputWav, chain, outputWav, options) {
15794
16005
  });
15795
16006
  }
15796
16007
  async function withFxBrowser(options, body) {
15797
- const hostDir = mkdtempSync7(join14(tmpdir4(), "hf-fx-host-"));
16008
+ const hostDir = mkdtempSync8(join15(tmpdir5(), "hf-fx-host-"));
15798
16009
  let lease = null;
15799
16010
  try {
15800
16011
  if (options.signal?.aborted) {
@@ -15809,14 +16020,14 @@ async function withFxBrowser(options, body) {
15809
16020
  `Audio FX failed for track ${options.trackId}: ${err.message}`
15810
16021
  );
15811
16022
  } finally {
15812
- rmSync8(hostDir, { recursive: true, force: true });
16023
+ removeScratch(hostDir);
15813
16024
  await lease?.release().catch(() => void 0);
15814
16025
  }
15815
16026
  }
15816
16027
  async function openFxPage(browser, hostDir) {
15817
16028
  const page = await browser.newPage();
15818
16029
  try {
15819
- const hostPage = join14(hostDir, "audio-fx.html");
16030
+ const hostPage = join15(hostDir, "audio-fx.html");
15820
16031
  writeFileSync6(hostPage, "<!doctype html><meta charset=utf-8><title>audio fx</title>");
15821
16032
  await page.goto(pathToFileURL(hostPage).href, {
15822
16033
  waitUntil: "domcontentloaded"
@@ -16281,8 +16492,8 @@ async function extractAudioSegment(srcPath, outputPath, stage, mediaStart, durat
16281
16492
  });
16282
16493
  const loopDuration = (metadata?.durationSeconds ?? 0) - mediaStart;
16283
16494
  if (options?.loop && loopDuration > 0 && sourceDuration > loopDuration) {
16284
- const cycleDir = mkdtempSync8(join15(outputDir, ".audio-loop-"));
16285
- const cyclePath = join15(cycleDir, "cycle.wav");
16495
+ const cycleDir = mkdtempSync9(join16(outputDir, ".audio-loop-"));
16496
+ const cyclePath = join16(cycleDir, "cycle.wav");
16286
16497
  try {
16287
16498
  const cycle = await extractAudioSegment(
16288
16499
  srcPath,
@@ -16328,7 +16539,7 @@ async function extractAudioSegment(srcPath, outputPath, stage, mediaStart, durat
16328
16539
  failure: failure2
16329
16540
  };
16330
16541
  } finally {
16331
- rmSync9(cycleDir, { recursive: true, force: true });
16542
+ removeScratch(cycleDir);
16332
16543
  }
16333
16544
  }
16334
16545
  const inputSeek = mediaStart >= (metadata?.latestStreamLeadSeconds ?? 0);
@@ -16470,8 +16681,8 @@ async function mixAudioTracksFlat(tracks, outputPath, totalDuration, signal, con
16470
16681
  const runMix = async (ignoreAutomation, useNormalize2) => {
16471
16682
  const inputs = [];
16472
16683
  tracks.forEach((track) => inputs.push("-i", track.srcPath));
16473
- const scriptDir = mkdtempSync8(join15(outputDir, ".filter-complex-"));
16474
- const scriptPath = join15(scriptDir, "graph.txt");
16684
+ const scriptDir = mkdtempSync9(join16(outputDir, ".filter-complex-"));
16685
+ const scriptPath = join16(scriptDir, "graph.txt");
16475
16686
  const fd = openSync4(scriptPath, "wx", 384);
16476
16687
  try {
16477
16688
  writeFileSync7(fd, buildFilterComplex(ignoreAutomation, useNormalize2));
@@ -16502,7 +16713,7 @@ async function mixAudioTracksFlat(tracks, outputPath, totalDuration, signal, con
16502
16713
  currentArgs[currentArgs.indexOf("-filter_complex_script")] = "-/filter_complex";
16503
16714
  return await runFfmpeg(currentArgs, { signal, timeout: ffmpegProcessTimeout });
16504
16715
  } finally {
16505
- rmSync9(scriptDir, { recursive: true, force: true });
16716
+ removeScratch(scriptDir);
16506
16717
  }
16507
16718
  };
16508
16719
  let useNormalize = true;
@@ -16581,8 +16792,8 @@ async function mixGroupMembersFlat(memberTracks, outputPath, totalDuration, sign
16581
16792
  `${mixInputs}amix=inputs=${memberTracks.length}:duration=longest:dropout_transition=0[mixed];[mixed]volume=${formatFilterNumber(memberTracks.length)}[out]`
16582
16793
  );
16583
16794
  const filterComplex = [...inputFilters, mixFilter].join(";");
16584
- const scriptDir = mkdtempSync8(join15(outputDir, ".group-filter-complex-"));
16585
- const scriptPath = join15(scriptDir, "graph.txt");
16795
+ const scriptDir = mkdtempSync9(join16(outputDir, ".group-filter-complex-"));
16796
+ const scriptPath = join16(scriptDir, "graph.txt");
16586
16797
  const fd = openSync4(scriptPath, "wx", 384);
16587
16798
  try {
16588
16799
  writeFileSync7(fd, filterComplex);
@@ -16622,7 +16833,7 @@ async function mixGroupMembersFlat(memberTracks, outputPath, totalDuration, sign
16622
16833
  currentArgs[currentArgs.indexOf("-filter_complex_script")] = "-/filter_complex";
16623
16834
  return await runFfmpeg(currentArgs, { signal, timeout: ffmpegProcessTimeout });
16624
16835
  } finally {
16625
- rmSync9(scriptDir, { recursive: true, force: true });
16836
+ removeScratch(scriptDir);
16626
16837
  }
16627
16838
  };
16628
16839
  let useNormalize = true;
@@ -16661,7 +16872,7 @@ async function sumInSlices(tracks, scratchDir, totalDuration, signal, config) {
16661
16872
  let degradedAutomation = false;
16662
16873
  for (let at = 0; at < tracks.length; at += MAX_MIX_INPUTS) {
16663
16874
  const id = `sum-${at / MAX_MIX_INPUTS}`;
16664
- const slicePath = join15(scratchDir, `${id}-slice.wav`);
16875
+ const slicePath = join16(scratchDir, `${id}-slice.wav`);
16665
16876
  const slice = await mixGroupMembersFlat(
16666
16877
  tracks.slice(at, at + MAX_MIX_INPUTS),
16667
16878
  slicePath,
@@ -16675,7 +16886,7 @@ async function sumInSlices(tracks, scratchDir, totalDuration, signal, config) {
16675
16886
  running = wavTrack(id, slicePath);
16676
16887
  continue;
16677
16888
  }
16678
- const foldedPath = join15(scratchDir, `${id}.wav`);
16889
+ const foldedPath = join16(scratchDir, `${id}.wav`);
16679
16890
  const folded = await mixGroupMembersFlat(
16680
16891
  [running, wavTrack(`${id}-slice`, slicePath)],
16681
16892
  foldedPath,
@@ -16683,8 +16894,8 @@ async function sumInSlices(tracks, scratchDir, totalDuration, signal, config) {
16683
16894
  signal,
16684
16895
  config
16685
16896
  );
16686
- rmSync9(running.srcPath, { force: true });
16687
- rmSync9(slicePath, { force: true });
16897
+ removeScratch(running.srcPath);
16898
+ removeScratch(slicePath);
16688
16899
  if (!folded.success) return folded;
16689
16900
  running = wavTrack(id, foldedPath);
16690
16901
  }
@@ -16696,14 +16907,14 @@ async function mixGroupMembers(memberTracks, outputPath, totalDuration, signal,
16696
16907
  return mixGroupMembersFlat(memberTracks, outputPath, totalDuration, signal, config);
16697
16908
  }
16698
16909
  mkdirSync7(dirname7(outputPath), { recursive: true });
16699
- const scratchDir = mkdtempSync8(join15(dirname7(outputPath), ".mix-batches-"));
16910
+ const scratchDir = mkdtempSync9(join16(dirname7(outputPath), ".mix-batches-"));
16700
16911
  try {
16701
16912
  const summed = await sumInSlices(memberTracks, scratchDir, totalDuration, signal, config);
16702
16913
  if (!summed.success) return summed;
16703
- renameWithRetry(summed.track.srcPath, outputPath);
16914
+ renameWithRetry(summed.track.srcPath, outputPath, { copyFallback: true });
16704
16915
  return { success: true, degradedAutomation: summed.degradedAutomation };
16705
16916
  } finally {
16706
- rmSync9(scratchDir, { recursive: true, force: true });
16917
+ removeScratch(scratchDir);
16707
16918
  }
16708
16919
  }
16709
16920
  async function mixAudioTracks(tracks, outputPath, totalDuration, signal, config) {
@@ -16711,7 +16922,7 @@ async function mixAudioTracks(tracks, outputPath, totalDuration, signal, config)
16711
16922
  return mixAudioTracksFlat(tracks, outputPath, totalDuration, signal, config);
16712
16923
  }
16713
16924
  mkdirSync7(dirname7(outputPath), { recursive: true });
16714
- const scratchDir = mkdtempSync8(join15(dirname7(outputPath), ".mix-batches-"));
16925
+ const scratchDir = mkdtempSync9(join16(dirname7(outputPath), ".mix-batches-"));
16715
16926
  try {
16716
16927
  const summed = await sumInSlices(tracks, scratchDir, totalDuration, signal, config);
16717
16928
  if (!summed.success) {
@@ -16737,16 +16948,16 @@ async function mixAudioTracks(tracks, outputPath, totalDuration, signal, config)
16737
16948
  error: summed.degradedAutomation ? "Volume automation exceeded this ffmpeg build's expression limits; rendered at base volume" : mixed.error
16738
16949
  } : mixed;
16739
16950
  } finally {
16740
- rmSync9(scratchDir, { recursive: true, force: true });
16951
+ removeScratch(scratchDir);
16741
16952
  }
16742
16953
  }
16743
16954
  async function mixThroughFloatSum(tracks, masterChain, outputPath, workDir, totalDuration, signal, config) {
16744
- const sumPath = join15(workDir, "master-sum.wav");
16955
+ const sumPath = join16(workDir, "master-sum.wav");
16745
16956
  const mixStart = Date.now();
16746
16957
  const sum = await mixAudioTracks(tracks, sumPath, totalDuration, signal, config);
16747
16958
  if (!sum.success) return { ...sum, outputPath };
16748
16959
  const masterStart = Date.now();
16749
- const encoderInput = masterChain ? (await applyAudioFxChain(sumPath, masterChain, join15(workDir, "master-fx.wav"), {
16960
+ const encoderInput = masterChain ? (await applyAudioFxChain(sumPath, masterChain, join16(workDir, "master-fx.wav"), {
16750
16961
  trackId: "master",
16751
16962
  signal
16752
16963
  })).path : sumPath;
@@ -16770,7 +16981,8 @@ async function mixThroughFloatSum(tracks, masterChain, outputPath, workDir, tota
16770
16981
  failures: [failure]
16771
16982
  };
16772
16983
  }
16773
- if (config?.keepEncoderInputAt) renameWithRetry(encoderInput, config.keepEncoderInputAt);
16984
+ if (config?.keepEncoderInputAt)
16985
+ renameWithRetry(encoderInput, config.keepEncoderInputAt, { copyFallback: true });
16774
16986
  return {
16775
16987
  ...sum,
16776
16988
  outputPath,
@@ -16890,7 +17102,7 @@ async function processCompositionAudio(elements, baseDir, workDir, outputPath, t
16890
17102
  }
16891
17103
  let audioSrcPath = srcPath;
16892
17104
  if (element.type === "video") {
16893
- const extractedPath = join15(workDir, `${element.id}-extracted.wav`);
17105
+ const extractedPath = join16(workDir, `${element.id}-extracted.wav`);
16894
17106
  const extractResult = await extractAudioSegment(
16895
17107
  srcPath,
16896
17108
  extractedPath,
@@ -16918,7 +17130,7 @@ async function processCompositionAudio(elements, baseDir, workDir, outputPath, t
16918
17130
  }
16919
17131
  audioSrcPath = extractedPath;
16920
17132
  } else {
16921
- const trimmedPath = join15(workDir, `${element.id}-trimmed.wav`);
17133
+ const trimmedPath = join16(workDir, `${element.id}-trimmed.wav`);
16922
17134
  const prepResult = await extractAudioSegment(
16923
17135
  srcPath,
16924
17136
  trimmedPath,
@@ -16970,7 +17182,7 @@ async function processCompositionAudio(elements, baseDir, workDir, outputPath, t
16970
17182
  const fxResult = await applyAudioFxChain(
16971
17183
  audioSrcPath,
16972
17184
  chain,
16973
- join15(workDir, `${element.id}-fx.wav`),
17185
+ join16(workDir, `${element.id}-fx.wav`),
16974
17186
  {
16975
17187
  trackId: element.id,
16976
17188
  signal: effectiveSignal,
@@ -17023,7 +17235,7 @@ async function processCompositionAudio(elements, baseDir, workDir, outputPath, t
17023
17235
  ).catch((err) => {
17024
17236
  internalController.abort();
17025
17237
  try {
17026
- rmSync9(workDir, { recursive: true, force: true });
17238
+ rmSync8(workDir, { recursive: true, force: true });
17027
17239
  } catch {
17028
17240
  }
17029
17241
  throw err;
@@ -17048,7 +17260,7 @@ async function processCompositionAudio(elements, baseDir, workDir, outputPath, t
17048
17260
  });
17049
17261
  const removeWorkDir = () => {
17050
17262
  try {
17051
- rmSync9(workDir, { recursive: true, force: true });
17263
+ rmSync8(workDir, { recursive: true, force: true });
17052
17264
  } catch {
17053
17265
  }
17054
17266
  };
@@ -17093,7 +17305,7 @@ async function processCompositionAudio(elements, baseDir, workDir, outputPath, t
17093
17305
  const meta = groupMeta.get(groupId);
17094
17306
  if (!meta) continue;
17095
17307
  const pathId = safePathSegment(groupId, groupIndex);
17096
- const groupWavPath = join15(workDir, `group-${pathId}.wav`);
17308
+ const groupWavPath = join16(workDir, `group-${pathId}.wav`);
17097
17309
  try {
17098
17310
  const subMix = await mixGroupMembers(
17099
17311
  memberTracks,
@@ -17126,7 +17338,7 @@ async function processCompositionAudio(elements, baseDir, workDir, outputPath, t
17126
17338
  const fxResult = await applyAudioFxChain(
17127
17339
  groupSrcPath,
17128
17340
  chain,
17129
- join15(workDir, `group-${pathId}-fx.wav`),
17341
+ join16(workDir, `group-${pathId}-fx.wav`),
17130
17342
  {
17131
17343
  trackId: groupId,
17132
17344
  signal: effectiveSignal,
@@ -17207,22 +17419,22 @@ async function processCompositionAudio(elements, baseDir, workDir, outputPath, t
17207
17419
  // ../engine/src/services/parallelCoordinator.ts
17208
17420
  import { cpus as cpus3, freemem } from "os";
17209
17421
  import { existsSync as existsSync12, mkdirSync as mkdirSync8, readdirSync as readdirSync6 } from "fs";
17210
- import { copyFile, readFile as readFile2 } from "fs/promises";
17211
- import { join as join17 } from "path";
17422
+ import { copyFile as copyFile2, readFile as readFile2 } from "fs/promises";
17423
+ import { join as join18 } from "path";
17212
17424
  import { getHeapStatistics } from "v8";
17213
17425
 
17214
17426
  // ../engine/src/utils/psnr.ts
17215
17427
  import { execFile as execFile4 } from "child_process";
17216
17428
  import { mkdtemp, rm, writeFile } from "fs/promises";
17217
- import { tmpdir as tmpdir5 } from "os";
17218
- import { join as join16 } from "path";
17429
+ import { tmpdir as tmpdir6 } from "os";
17430
+ import { join as join17 } from "path";
17219
17431
  import { promisify as promisify3 } from "util";
17220
17432
  async function psnrDb(a, b) {
17221
17433
  const execFileP = promisify3(execFile4);
17222
- const dir = await mkdtemp(join16(tmpdir5(), "hf-de-verify-"));
17434
+ const dir = await mkdtemp(join17(tmpdir6(), "hf-de-verify-"));
17223
17435
  try {
17224
- const pa = join16(dir, "a.jpg");
17225
- const pb = join16(dir, "b.jpg");
17436
+ const pa = join17(dir, "a.jpg");
17437
+ const pb = join17(dir, "b.jpg");
17226
17438
  await Promise.all([writeFile(pa, a), writeFile(pb, b)]);
17227
17439
  const { stderr } = await execFileP(
17228
17440
  getFfmpegBinary(),
@@ -17446,7 +17658,7 @@ function distributeFrames(totalFrames, workerCount, workDir, rangeStart = 0) {
17446
17658
  workerId: i,
17447
17659
  startFrame,
17448
17660
  endFrame,
17449
- outputDir: join17(workDir, `worker-${i}`),
17661
+ outputDir: join18(workDir, `worker-${i}`),
17450
17662
  outputFrameOffset: rangeStart
17451
17663
  });
17452
17664
  }
@@ -17460,7 +17672,7 @@ function distributeFramesInterleaved(totalFrames, workerCount, workDir, rangeSta
17460
17672
  startFrame: rangeStart + i,
17461
17673
  endFrame: rangeStart + totalFrames,
17462
17674
  frameStride: workerCount,
17463
- outputDir: join17(workDir, `worker-${i}`),
17675
+ outputDir: join18(workDir, `worker-${i}`),
17464
17676
  outputFrameOffset: rangeStart
17465
17677
  });
17466
17678
  }
@@ -17513,18 +17725,20 @@ function resolveParallelWorkerTimeoutMs(enabled) {
17513
17725
  const parsed = raw ? Number(raw) : Number.NaN;
17514
17726
  return Number.isFinite(parsed) && parsed > 0 ? parsed : 3e4;
17515
17727
  }
17516
- async function captureFrameRange(session, task, captureOptions, signal, onFrameCaptured, onFrameBuffer, phaseTimeoutMs, diagnosticFor, onWorkerPhase) {
17728
+ async function captureFrameRange(session, task, captureOptions, signal, onFrameCaptured, onFrameBuffer, phaseTimeoutMs, diagnosticFor, onWorkerPhase, onWorkerOperation) {
17517
17729
  let framesCaptured = 0;
17518
17730
  const outputOffset = task.outputFrameOffset ?? 0;
17519
17731
  const stride = task.frameStride ?? 1;
17520
17732
  const runCaptureOperation = (phase, frameIndex, operation) => {
17521
- const diagnostic = diagnosticFor(phase, frameIndex);
17733
+ const diagnostic = { ...diagnosticFor(phase, frameIndex), readStep: () => session.captureStep };
17522
17734
  if (framesCaptured === 0) onWorkerPhase?.(diagnostic);
17735
+ onWorkerOperation?.(diagnostic);
17523
17736
  return withParallelWorkerDeadline(operation(), diagnostic, phaseTimeoutMs, signal);
17524
17737
  };
17525
17738
  const awaitEncode = (frameIndex, encodeResult) => {
17526
17739
  const diagnostic = diagnosticFor("frame_encode", frameIndex);
17527
17740
  if (framesCaptured === 0) onWorkerPhase?.(diagnostic);
17741
+ onWorkerOperation?.(diagnostic);
17528
17742
  return withParallelWorkerDeadline(encodeResult, diagnostic, phaseTimeoutMs, signal);
17529
17743
  };
17530
17744
  if (onFrameBuffer && session.workerEncodeEnabled) {
@@ -17664,13 +17878,13 @@ async function verifyDiskDrawElementSamples(session, task, streaming) {
17664
17878
  for (const idx of selectVerifySampleIndicesForTask(truths.keys(), task)) {
17665
17879
  const truth = truths.get(idx);
17666
17880
  if (!truth) continue;
17667
- const framePath = join17(task.outputDir, `frame_${String(idx - offset).padStart(6, "0")}.${ext}`);
17881
+ const framePath = join18(task.outputDir, `frame_${String(idx - offset).padStart(6, "0")}.${ext}`);
17668
17882
  const db = await psnrForDiskSample(framePath, truth, task.workerId, idx);
17669
17883
  if (db === null) continue;
17670
17884
  assertDiskSampleAboveFloor(db, verifyMinDb, idx, task.workerId);
17671
17885
  }
17672
17886
  }
17673
- async function executeWorkerTask(task, serverUrl, captureOptions, createBeforeCaptureHook, signal, onFrameCaptured, onFrameBuffer, config, parallel, onFailure, onWorkerPhase) {
17887
+ async function executeWorkerTask(task, serverUrl, captureOptions, createBeforeCaptureHook, signal, onFrameCaptured, onFrameBuffer, config, parallel, onFailure, onWorkerPhase, onWorkerOperation, gate) {
17674
17888
  const startTime = Date.now();
17675
17889
  let framesCaptured = 0;
17676
17890
  if (!existsSync12(task.outputDir)) mkdirSync8(task.outputDir, { recursive: true });
@@ -17728,6 +17942,7 @@ async function executeWorkerTask(task, serverUrl, captureOptions, createBeforeCa
17728
17942
  await assertSwiftShader(activeSession.page, readWebGlVendorInfoFromCanvas);
17729
17943
  }
17730
17944
  await initializeSession(activeSession);
17945
+ if (gate) await (task.workerId === 0 ? gate.verify(activeSession) : gate.wait());
17731
17946
  });
17732
17947
  canvasDrawElement = activeSession.captureMode === "drawelement";
17733
17948
  gpuBackend = activeSession.gpuRenderer ?? "unknown";
@@ -17743,7 +17958,8 @@ async function executeWorkerTask(task, serverUrl, captureOptions, createBeforeCa
17743
17958
  onFrameBuffer,
17744
17959
  phaseTimeoutMs,
17745
17960
  diagnosticFor,
17746
- onWorkerPhase
17961
+ onWorkerPhase,
17962
+ onWorkerOperation
17747
17963
  );
17748
17964
  await verifyDiskDrawElementSamples(activeSession, task, Boolean(onFrameBuffer));
17749
17965
  perf = getCapturePerfSummary(activeSession);
@@ -17758,6 +17974,7 @@ async function executeWorkerTask(task, serverUrl, captureOptions, createBeforeCa
17758
17974
  pageErrorLines: pageErrorLinesOf(activeSession)
17759
17975
  };
17760
17976
  } catch (error) {
17977
+ if (task.workerId === 0) gate?.fail(error);
17761
17978
  const diagnostics = session ? selectWorkerDiagnostics(session.browserConsoleBuffer) : [];
17762
17979
  const workerDiagnostic = {
17763
17980
  workerId: task.workerId,
@@ -17799,6 +18016,24 @@ function isPoolFatalWorkerFailure(failure, streaming) {
17799
18016
  if (streaming) return failure.kind !== "cancelled";
17800
18017
  return isFatalCaptureFailure(failure);
17801
18018
  }
18019
+ function createFirstSessionGate(verify) {
18020
+ let fail;
18021
+ let pass;
18022
+ const settled = new Promise((resolve2, reject) => {
18023
+ pass = resolve2;
18024
+ fail = reject;
18025
+ });
18026
+ settled.catch(() => {
18027
+ });
18028
+ return {
18029
+ verify: (session) => verify(session).then(pass, (error) => {
18030
+ fail(error);
18031
+ throw error;
18032
+ }),
18033
+ wait: () => settled,
18034
+ fail
18035
+ };
18036
+ }
17802
18037
  function pageErrorLinesOf(session) {
17803
18038
  return session.browserConsoleBuffer.filter((line) => line.includes("PAGEERROR"));
17804
18039
  }
@@ -17870,6 +18105,7 @@ async function executeParallelCapture(serverUrl, workDir, tasks, captureOptions,
17870
18105
  hooks
17871
18106
  });
17872
18107
  const onFailure = failureHandler.onFailure;
18108
+ const gate = hooks?.verifyFirstSession && createFirstSessionGate(hooks.verifyFirstSession);
17873
18109
  const results = await Promise.all(
17874
18110
  tasks.map(
17875
18111
  (task) => executeWorkerTask(
@@ -17883,7 +18119,9 @@ async function executeParallelCapture(serverUrl, workDir, tasks, captureOptions,
17883
18119
  config,
17884
18120
  parallel,
17885
18121
  onFailure,
17886
- onWorkerPhase
18122
+ onWorkerPhase,
18123
+ hooks?.onWorkerOperation,
18124
+ gate
17887
18125
  )
17888
18126
  )
17889
18127
  );
@@ -17913,12 +18151,12 @@ async function mergeWorkerFrames(workDir, tasks, outputDir) {
17913
18151
  }
17914
18152
  const files = readdirSync6(task.outputDir).filter((f) => f.startsWith("frame_") && (f.endsWith(".jpg") || f.endsWith(".png"))).sort();
17915
18153
  const copyTasks = files.map(async (file) => {
17916
- const sourcePath = join17(task.outputDir, file);
17917
- const targetPath = join17(outputDir, file);
18154
+ const sourcePath = join18(task.outputDir, file);
18155
+ const targetPath = join18(outputDir, file);
17918
18156
  try {
17919
18157
  await renameWithRetryAsync(sourcePath, targetPath);
17920
18158
  } catch {
17921
- await copyFile(sourcePath, targetPath);
18159
+ await copyFile2(sourcePath, targetPath);
17922
18160
  }
17923
18161
  });
17924
18162
  await Promise.all(copyTasks);
@@ -17939,7 +18177,7 @@ function getSystemResources() {
17939
18177
  import { Hono } from "hono";
17940
18178
  import { serve } from "@hono/node-server";
17941
18179
  import { readFileSync as readFileSync8, openSync as openSync5, fstatSync, closeSync as closeSync5, statSync as statSync8, constants } from "fs";
17942
- import { join as join18, extname as extname3 } from "path";
18180
+ import { join as join19, extname as extname3 } from "path";
17943
18181
  var MIME_TYPES = {
17944
18182
  ".html": "text/html; charset=utf-8",
17945
18183
  ".css": "text/css; charset=utf-8",
@@ -17986,10 +18224,10 @@ function readRegularFile(filePath) {
17986
18224
  }
17987
18225
  }
17988
18226
  function resolveContainedPaths(projectDir, compiledDir, relativePath) {
17989
- const projectPath = join18(projectDir, relativePath);
18227
+ const projectPath = join19(projectDir, relativePath);
17990
18228
  if (!isWithinProjectRoot(projectDir, projectPath)) return null;
17991
18229
  if (!compiledDir) return { projectPath, compiledPath: null };
17992
- const compiledPath = join18(compiledDir, relativePath);
18230
+ const compiledPath = join19(compiledDir, relativePath);
17993
18231
  if (!isWithinProjectRoot(compiledDir, compiledPath)) return null;
17994
18232
  return { projectPath, compiledPath };
17995
18233
  }
@@ -18370,6 +18608,7 @@ export {
18370
18608
  applyConcreteGpuScreenshotClamp,
18371
18609
  SDR_RGB_TO_BT709_FILTER,
18372
18610
  SDR_RGB_TO_TAGGED_BT709_FILTER,
18611
+ explainChromeLaunchFailure,
18373
18612
  BrowserLeasePool,
18374
18613
  setHostHandlesSigint,
18375
18614
  resolveHeadlessShellPath,
@@ -18489,6 +18728,8 @@ export {
18489
18728
  readRenderProvenance,
18490
18729
  ENCODER_PRESETS,
18491
18730
  getEncoderPreset,
18731
+ keyframeIntervalToGopSize,
18732
+ appendRateCapArgs,
18492
18733
  buildEncoderArgs,
18493
18734
  encodeFramesFromDir,
18494
18735
  buildConcatArgs,
@@ -18512,6 +18753,8 @@ export {
18512
18753
  fetchPublicHttpsText,
18513
18754
  downloadToTemp,
18514
18755
  isHttpUrl,
18756
+ removeScratch,
18757
+ collectScratchLeftovers,
18515
18758
  renameWithRetry,
18516
18759
  renameWithRetryAsync,
18517
18760
  directorySizeBytes,