hyperframes 0.8.222 → 0.8.224

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 (264) hide show
  1. package/dist/{add-6MPLIWVP.js → add-JEPKJ2F4.js} +15 -15
  2. package/dist/{agentPromptGenerator-X7SQPCXZ.js → agentPromptGenerator-ZBNWLX5D.js} +7 -7
  3. package/dist/{animatedGifPrep-ESOJ4FQ7.js → animatedGifPrep-43LLMTN5.js} +7 -7
  4. package/dist/api.d.ts +5 -3
  5. package/dist/api.js +33 -22
  6. package/dist/{asset-Y735VQV6.js → asset-M6SH6PUW.js} +5 -5
  7. package/dist/{assetCataloger-AOJAUEZW.js → assetCataloger-BLQ7UVJ5.js} +8 -8
  8. package/dist/{audio-VMMCGPOV.js → audio-J3QREJK4.js} +150 -1158
  9. package/dist/{auth-BD5NHYRA.js → auth-7TRCBCKA.js} +5 -5
  10. package/dist/{autoUpdate-VTMNHOAJ.js → autoUpdate-WTFSYLTK.js} +4 -4
  11. package/dist/{backgroundChecks-SUDYQZSW.js → backgroundChecks-YZW7AMMJ.js} +5 -5
  12. package/dist/backgroundChecksWorker.js +5 -5
  13. package/dist/{batchRender-4NR7RMT7.js → batchRender-LDZ6NO2X.js} +11 -11
  14. package/dist/{beats-PKEHQHBY.js → beats-JWUADKHV.js} +14 -14
  15. package/dist/{benchmark-K55DDFHG.js → benchmark-QOQZ7UGD.js} +13 -13
  16. package/dist/billing-3GVNEE56.js +86 -0
  17. package/dist/{browser-G2WFWJJ3.js → browser-4HNCSPUR.js} +8 -8
  18. package/dist/{bundleWithLocalizedFonts-MNG2UVH3.js → bundleWithLocalizedFonts-GTKHB45M.js} +2 -2
  19. package/dist/{capture-24PIC3TZ.js → capture-5OYZNIOR.js} +31 -31
  20. package/dist/{capture-U3EEAPI6.js → capture-XSRWYHAM.js} +7 -7
  21. package/dist/{captureCompositionFrame-KL4V6ORD.js → captureCompositionFrame-4F7PPQKB.js} +17 -17
  22. package/dist/{captureTimeout-RIMG6IYH.js → captureTimeout-7Y2RUBCU.js} +3 -1
  23. package/dist/{catalog-J3BU4TFW.js → catalog-4FVQSID5.js} +16 -16
  24. package/dist/{catch-up-LDGNMEGL.js → catch-up-KQVK2QZC.js} +8 -8
  25. package/dist/{check-J6HG6EKE.js → check-3YHLB6FM.js} +47 -46
  26. package/dist/{checkAudio-MAX7JUYG.js → checkAudio-7ZSZVBSJ.js} +15 -15
  27. package/dist/{checkBrowser-3W74WJ26.js → checkBrowser-VX5CHNQS.js} +40 -39
  28. package/dist/{chunk-L55LAERP.js → chunk-2KDHJCH2.js} +2 -2
  29. package/dist/{chunk-CVY6OIKN.js → chunk-2M6B2JKZ.js} +73 -39
  30. package/dist/{chunk-OROHGC7W.js → chunk-2QQO3J3B.js} +7 -7
  31. package/dist/chunk-2WVQ3CCN.js +113 -0
  32. package/dist/{chunk-RRPO44PE.js → chunk-34GAW4GO.js} +5 -5
  33. package/dist/{chunk-WWT6ETQA.js → chunk-35NDLXHZ.js} +50 -55
  34. package/dist/{chunk-YHL4CVTF.js → chunk-3NHCTTLP.js} +15 -15
  35. package/dist/chunk-3ZDOAVZM.js +570 -0
  36. package/dist/{chunk-6ZLDIMPL.js → chunk-4H4DR36N.js} +2 -2
  37. package/dist/{chunk-IB7UYGXR.js → chunk-4ZAOAPWP.js} +17 -11
  38. package/dist/{chunk-GOWU3NCE.js → chunk-52B3AOIV.js} +1 -1
  39. package/dist/{chunk-F6QV5N3A.js → chunk-53JEHQBW.js} +2 -2
  40. package/dist/{chunk-YEKJOA47.js → chunk-53TKUWDX.js} +3 -3
  41. package/dist/{chunk-6MUI2H6P.js → chunk-54Q3H2UQ.js} +5 -2
  42. package/dist/chunk-5KAGTSLY.js +205 -0
  43. package/dist/{chunk-5ZBMHUY2.js → chunk-5LOZWO2M.js} +1 -1
  44. package/dist/{chunk-DSHFKKSZ.js → chunk-5N5FYE5K.js} +2 -2
  45. package/dist/{chunk-ZBNK6X5O.js → chunk-652ERUZD.js} +2 -2
  46. package/dist/{chunk-DP5LF7GF.js → chunk-66W5IWLO.js} +12 -0
  47. package/dist/{chunk-JQWITWVC.js → chunk-6QIYQ43G.js} +2 -2
  48. package/dist/chunk-6UWSEXQ3.js +5030 -0
  49. package/dist/{chunk-35JKCWYI.js → chunk-7HSV5SJ4.js} +3 -3
  50. package/dist/{chunk-3RXZZIDQ.js → chunk-7RTPHNOO.js} +2 -2
  51. package/dist/{chunk-6CFBFWLF.js → chunk-A25SCSOK.js} +1 -1
  52. package/dist/{chunk-SJGE5I5F.js → chunk-ADVVQX4I.js} +1 -1
  53. package/dist/{chunk-GHEYGMKD.js → chunk-AMQFGICP.js} +1 -1
  54. package/dist/chunk-BAXL3U3T.js +312 -0
  55. package/dist/{chunk-YSTBSLWY.js → chunk-BEMGUGGJ.js} +1 -1
  56. package/dist/chunk-BTK3T4HJ.js +250 -0
  57. package/dist/{chunk-UBDO4EHA.js → chunk-C5JKRCSG.js} +1 -1
  58. package/dist/{chunk-ZLXWRYOO.js → chunk-CGX4EOGT.js} +3 -3
  59. package/dist/{chunk-ZPTNLDOB.js → chunk-D4M37ATV.js} +2 -2
  60. package/dist/chunk-DY7PQLIE.js +248 -0
  61. package/dist/{chunk-DNTPNSH5.js → chunk-E2ZY4GWH.js} +5 -5
  62. package/dist/{chunk-QYRMR45H.js → chunk-E47ZWDMH.js} +1 -1
  63. package/dist/{chunk-EGJ4UECR.js → chunk-EHZESMRB.js} +8 -2
  64. package/dist/{chunk-VJVVWYP6.js → chunk-EQFDOQTG.js} +1 -1
  65. package/dist/{chunk-42Q3VX34.js → chunk-F34GYYXO.js} +5 -5
  66. package/dist/{chunk-7IH3RSSG.js → chunk-F3CTUCFD.js} +12 -12
  67. package/dist/chunk-F7T57BZZ.js +95 -0
  68. package/dist/{chunk-BDZSH6P3.js → chunk-FJ3KUOUZ.js} +1 -1
  69. package/dist/{chunk-7KBS6ZLB.js → chunk-FPR57WRR.js} +2 -2
  70. package/dist/{chunk-BPIY5LB3.js → chunk-G45NYKSM.js} +39 -4
  71. package/dist/{chunk-AXVTL7B6.js → chunk-GE4ABM5K.js} +2 -2
  72. package/dist/{chunk-HQDHMAUI.js → chunk-GLTSINRP.js} +1 -1
  73. package/dist/chunk-GQ2QER6M.js +70 -0
  74. package/dist/{chunk-Y7IV5MAK.js → chunk-H6APAFKE.js} +2 -2
  75. package/dist/{chunk-5GSEM63G.js → chunk-HANNA5JJ.js} +1 -1
  76. package/dist/{chunk-RIGSGNDQ.js → chunk-HDPW7THH.js} +30 -21
  77. package/dist/{chunk-L37AZWB2.js → chunk-HIPW4JXL.js} +3 -3
  78. package/dist/{chunk-VQMHDS2V.js → chunk-HT3D5AKG.js} +52 -12
  79. package/dist/{chunk-K5UCRKUK.js → chunk-IORJ42GY.js} +2 -2
  80. package/dist/{chunk-OAXWHPNS.js → chunk-IYYQRNIZ.js} +1 -1
  81. package/dist/{chunk-G675S644.js → chunk-J7FVF73D.js} +33 -31
  82. package/dist/{chunk-S2HWGG5O.js → chunk-JHOPRAJN.js} +1 -1
  83. package/dist/{chunk-WJYFJGYT.js → chunk-JIF347PW.js} +3 -3
  84. package/dist/{chunk-XHD7RKEZ.js → chunk-JK2KNL6F.js} +2 -2
  85. package/dist/{chunk-CZOC7WY7.js → chunk-JKLWWGE6.js} +1 -1
  86. package/dist/{chunk-SKCS4SUZ.js → chunk-JMP52GTN.js} +44 -19
  87. package/dist/chunk-JUF43Q7Q.js +59 -0
  88. package/dist/chunk-K3QT232E.js +71 -0
  89. package/dist/chunk-KEDN4LSV.js +1048 -0
  90. package/dist/{chunk-G2EY3MVW.js → chunk-L4ULTWCD.js} +1 -1
  91. package/dist/{chunk-7D2LTSNV.js → chunk-LRS4FV5W.js} +3 -3
  92. package/dist/{chunk-VMRQDPFL.js → chunk-M336YVCP.js} +1 -1
  93. package/dist/{chunk-6W3DY5BP.js → chunk-MA5AQK7T.js} +2 -2
  94. package/dist/{chunk-EQGKUPBJ.js → chunk-MCDNAIFF.js} +1 -1
  95. package/dist/{chunk-EOUKB53E.js → chunk-MOXNAVCW.js} +1 -1
  96. package/dist/{chunk-AIXH3V5A.js → chunk-NFUR6NNT.js} +20 -5
  97. package/dist/{chunk-AN4USOFT.js → chunk-NI35PAVN.js} +2 -2
  98. package/dist/{chunk-E5IIR67Q.js → chunk-O2VKGYSK.js} +1 -1
  99. package/dist/chunk-ODJ2WBZX.js +288 -0
  100. package/dist/{chunk-52VXA3SC.js → chunk-OZMZFJDW.js} +1 -1
  101. package/dist/{chunk-EE7YWKDY.js → chunk-PKMAWQUI.js} +4 -4
  102. package/dist/{chunk-D6LGD472.js → chunk-POOLZTMZ.js} +6 -4
  103. package/dist/chunk-QK6ZNEBW.js +46 -0
  104. package/dist/{chunk-NUE44RN2.js → chunk-QOI46C6F.js} +17 -4
  105. package/dist/{chunk-MESSJFK3.js → chunk-QOYZ3U6G.js} +39 -29
  106. package/dist/{chunk-ZAJQFY5Q.js → chunk-QU5OYMTB.js} +15 -2
  107. package/dist/{chunk-HOTXWVVP.js → chunk-R2C5EON5.js} +2 -6
  108. package/dist/{chunk-FMKI7ZLM.js → chunk-RR5QE7DB.js} +2 -2
  109. package/dist/{chunk-OQLYKDL5.js → chunk-RU7KMDFL.js} +1 -1
  110. package/dist/{chunk-ONMTNYGR.js → chunk-RXJUMVCA.js} +1 -1
  111. package/dist/chunk-RZ6CXJ56.js +24 -0
  112. package/dist/{chunk-GODT7QDZ.js → chunk-SGMCQAYU.js} +3 -3
  113. package/dist/{chunk-QOZPWIYV.js → chunk-THL3N377.js} +19 -16
  114. package/dist/{chunk-IGBOFU2Y.js → chunk-UCPEABYK.js} +2 -2
  115. package/dist/{chunk-AOHG22HQ.js → chunk-UZ5AWZCA.js} +6 -6
  116. package/dist/{chunk-4VEXJTUT.js → chunk-VCJE7IMY.js} +2 -2
  117. package/dist/{chunk-Z5VQBRU2.js → chunk-VPMHRLJH.js} +3 -3
  118. package/dist/{chunk-FT3CNACL.js → chunk-VXRBPWVW.js} +144 -41
  119. package/dist/{chunk-537WSYHU.js → chunk-W7MJPKBJ.js} +1 -1
  120. package/dist/{chunk-26AQTUU4.js → chunk-WJD3GVAA.js} +1 -1
  121. package/dist/{chunk-DS372VSV.js → chunk-WW7Z2W73.js} +2 -2
  122. package/dist/{chunk-DC26QLB7.js → chunk-X5BSSPC2.js} +1 -1
  123. package/dist/{chunk-DIXTEVWQ.js → chunk-Y5HVDK7X.js} +3 -3
  124. package/dist/{chunk-EHSBBBR2.js → chunk-YGGZ23BB.js} +2 -0
  125. package/dist/{chunk-NHXGFQWQ.js → chunk-Z7GIHPAZ.js} +1 -1
  126. package/dist/{chunk-XC3BGWCJ.js → chunk-ZFQSXMX6.js} +1 -1
  127. package/dist/{chunk-P5M3AXEP.js → chunk-ZGQC6IU7.js} +1 -1
  128. package/dist/{chunk-KEY2VA65.js → chunk-ZLZXGJ63.js} +6 -20
  129. package/dist/{clean-K6IM3LC4.js → clean-SXEI6FT4.js} +24 -24
  130. package/dist/cli.js +73 -63
  131. package/dist/{cloud-OV7EA4BJ.js → cloud-SKN6FWAZ.js} +4 -4
  132. package/dist/{cloudrun-ZEMODIOP.js → cloudrun-RHPVVXCR.js} +9 -9
  133. package/dist/{compare-MJZ3D3HA.js → compare-RTXF2NSK.js} +36 -36
  134. package/dist/{compiler-6KKETX77.js → compiler-SKRY6FPA.js} +4 -4
  135. package/dist/{component-EVXMYIP3.js → component-2NPF5PA6.js} +6 -6
  136. package/dist/{compositions-PZ7FQ7WN.js → compositions-AZRVHGBT.js} +17 -17
  137. package/dist/curve-QSFEGBUH.js +329 -0
  138. package/dist/cuts-6AWEJH2H.js +123 -0
  139. package/dist/{delete-DL3XA4QV.js → delete-NOHFVICL.js} +9 -9
  140. package/dist/{deploy-VEYP3IP5.js → deploy-UFRADJOA.js} +10 -10
  141. package/dist/describeProject-F43LI3YQ.js +56 -0
  142. package/dist/{destroy-BQ5R7LUF.js → destroy-IQLGADZM.js} +6 -6
  143. package/dist/diff-3WS6NMSE.js +1825 -0
  144. package/dist/{dist-SHMQOKMF.js → dist-24QQO5IL.js} +2 -2
  145. package/dist/{dist-M77KFAYW.js → dist-YEYUGCOR.js} +2 -2
  146. package/dist/{docs-VAF5NM5B.js → docs-IB3KETC6.js} +1 -1
  147. package/dist/{doctor-JM2WHH7Y.js → doctor-F4VJYQXC.js} +13 -13
  148. package/dist/energy-BN3QD6Y7.js +134 -0
  149. package/dist/events-5W7ETFWR.js +221 -0
  150. package/dist/{events-GW5I5RCG.js → events-PZH4C7VA.js} +5 -5
  151. package/dist/{events-S7KVBRSL.js → events-YJ3XSIPL.js} +6 -6
  152. package/dist/extract-S34DWGAD.js +309 -0
  153. package/dist/face-3SCJADG4.js +171 -0
  154. package/dist/{feedback-7OR5FVTX.js → feedback-3K6NSKIC.js} +16 -16
  155. package/dist/{ffmpeg-A7CSIX3U.js → ffmpeg-2RBDDMHU.js} +7 -7
  156. package/dist/{figma-444HKFX5.js → figma-NWAJYMAI.js} +3 -3
  157. package/dist/fontLocalizeCli.js +10 -10
  158. package/dist/frames-6UARLPLK.js +352 -0
  159. package/dist/generate-KBVWFVXN.js +74 -0
  160. package/dist/{get-6UTF3225.js → get-SEZZMLQ3.js} +8 -8
  161. package/dist/{gpuPolicy-ORPUS5Z2.js → gpuPolicy-VIZAJ3GY.js} +7 -7
  162. package/dist/{grade-compare-UCTAYN3B.js → grade-compare-PMAK4PJD.js} +40 -37
  163. package/dist/{heifImagePrep-ED6V6RFN.js → heifImagePrep-6NYIR7WN.js} +8 -8
  164. package/dist/{help-HZR32XWP.js → help-4UPSHWI2.js} +7 -1
  165. package/dist/{history-TQ56MZIA.js → history-VNAZEQDE.js} +11 -11
  166. package/dist/hyperframe.manifest.json +1 -1
  167. package/dist/hyperframe.runtime.iife.js +70 -70
  168. package/dist/hyperframes-player.global.js +3 -3
  169. package/dist/index-gen-OPMQ5WSN.js +61 -0
  170. package/dist/{info-RPIIP7RN.js → info-OREET5PM.js} +11 -11
  171. package/dist/{init-ONAWKHFW.js → init-K7AEJBAL.js} +33 -32
  172. package/dist/{inspect-A75PYOWJ.js → inspect-STME5DNY.js} +37 -36
  173. package/dist/{installer-ISMCCFBZ.js → installer-NQA4KXRP.js} +4 -4
  174. package/dist/{keyframes-2I75DP3O.js → keyframes-JQWZ235Q.js} +10 -10
  175. package/dist/{lambda-4QIHGPGJ.js → lambda-RJNLW2EO.js} +21 -21
  176. package/dist/{layout-GW7WE7RT.js → layout-MTZWBPNZ.js} +37 -36
  177. package/dist/{lint-OWP72OZQ.js → lint-AQWTSL75.js} +12 -12
  178. package/dist/{lintProject-XYQ5L7RQ.js → lintProject-6H64SX3V.js} +2 -2
  179. package/dist/{list-WVK7ZCPW.js → list-ZEBZ5DB5.js} +9 -9
  180. package/dist/{localPage-IQWHN7BH.js → localPage-CQ3H4N2N.js} +7 -7
  181. package/dist/{login-Q5CNHYWU.js → login-VHCZHENV.js} +17 -11
  182. package/dist/{logout-6VFJ7WMW.js → logout-LHTQV2BZ.js} +3 -3
  183. package/dist/look-25TSRPSV.js +180 -0
  184. package/dist/{manager-JCYVNEWH.js → manager-57SX7D5G.js} +9 -8
  185. package/dist/manifest-QSJYVERU.js +49 -0
  186. package/dist/measure-Y2R3G5OJ.js +46 -0
  187. package/dist/{media-treatment-M5IUP7H4.js → media-treatment-3G2IVS64.js} +20 -20
  188. package/dist/{media-use-ZNTB7W6N.js → media-use-LUAOZJNV.js} +10 -6
  189. package/dist/{models-CFXKDYZ3.js → models-NT56FKRG.js} +15 -15
  190. package/dist/{motionShot-CWUEI4ZM.js → motionShot-P4NTFKYS.js} +20 -20
  191. package/dist/{normalize-QJVXFMWO.js → normalize-MBNGRVQA.js} +2 -1
  192. package/dist/{normalize-audio-FASY33LR.js → normalize-audio-2DUTZ6QK.js} +12 -12
  193. package/dist/{open-KOVVESYN.js → open-OATYOOR7.js} +15 -15
  194. package/dist/{parakeetRunner-E4IP5SL4.js → parakeetRunner-UASHW3A4.js} +13 -12
  195. package/dist/{pipeline-C6EZVV43.js → pipeline-GGAYP5Q6.js} +11 -11
  196. package/dist/{play-MZJI6SMH.js → play-GHXBJS3T.js} +28 -28
  197. package/dist/{policies-J5BWAZHM.js → policies-EERREOZJ.js} +6 -4
  198. package/dist/{preflight-K4SPUWXP.js → preflight-6VOP3IOI.js} +8 -8
  199. package/dist/{present-7L7ZTG7F.js → present-M7UYHVEZ.js} +23 -23
  200. package/dist/{preview-QGDVMR3X.js → preview-YWT5WA3W.js} +26 -26
  201. package/dist/probe-CQAGZJLP.js +178 -0
  202. package/dist/{producer-EJPNNY3E.js → producer-OU2BCMLY.js} +1 -1
  203. package/dist/{progress-X3QFO3FE.js → progress-STSH2JRY.js} +2 -2
  204. package/dist/{projectConfig-EEF6OPXO.js → projectConfig-UI4NZDN7.js} +6 -6
  205. package/dist/{prompts-VAO7RDKX.js → prompts-ZEVFT7US.js} +2 -2
  206. package/dist/{publication-5KF44AKQ.js → publication-VPJZQCLA.js} +2 -2
  207. package/dist/{publish-SSKWZ5TE.js → publish-7RA2MK2M.js} +18 -18
  208. package/dist/{refresh-I6ITGHKL.js → refresh-AM2ULRRV.js} +3 -3
  209. package/dist/{remove-background-PCL6I5SZ.js → remove-background-A5KJUH6W.js} +14 -14
  210. package/dist/{render-UPRWOGLS.js → render-EMW4I6C6.js} +45 -45
  211. package/dist/{render-DH4UA7KW.js → render-IYV73CG6.js} +10 -10
  212. package/dist/{render-DRWQ6F37.js → render-Z5IS4AUP.js} +39 -39
  213. package/dist/{render-batch-EBW5WHB5.js → render-batch-IN2ZXPS7.js} +10 -10
  214. package/dist/renderSetupWorker.js +2 -2
  215. package/dist/{resolver-ZSZXNRFP.js → resolver-DIXFK5ZR.js} +4 -4
  216. package/dist/run-MCVU7AZX.js +31 -0
  217. package/dist/{sam-QA7JT7IM.js → sam-EGFXZF56.js} +2 -2
  218. package/dist/{screenshotCapture-4THETOMD.js → screenshotCapture-RUDON2HB.js} +2 -2
  219. package/dist/{sherpa-IKVUCBOW.js → sherpa-SAY3I7PK.js} +12 -11
  220. package/dist/{sites-MTLVMYJ6.js → sites-EAGXQOKI.js} +2 -2
  221. package/dist/skills/hyperframes-cli/SKILL.md +4 -4
  222. package/dist/skills/hyperframes-cli/references/cloud.md +3 -1
  223. package/dist/skills/hyperframes-cli/references/preview-render.md +1 -1
  224. package/dist/skills/media-use/SKILL.md +20 -21
  225. package/dist/skills/media-use/audio/scripts/lib/heygen.mjs +26 -1
  226. package/dist/skills/media-use/audio/scripts/lib/heygen.test.mjs +33 -0
  227. package/dist/skills/media-use/references/heygen.md +58 -0
  228. package/dist/skills/media-use/references/operations.md +9 -6
  229. package/dist/skills/media-use/references/setup-providers.md +11 -12
  230. package/dist/skills/media-use/scripts/lib/index-gen.d.mts +1 -0
  231. package/dist/skills/media-use/scripts/lib/manifest.d.mts +21 -0
  232. package/dist/{skills-ZREHX3TU.js → skills-YWQ5XKH6.js} +9 -9
  233. package/dist/{skillsUpdateCheck-PPJ5NGAL.js → skillsUpdateCheck-ST5ZFEET.js} +5 -5
  234. package/dist/{snapshot-KPFLZNEL.js → snapshot-57YYYE5J.js} +43 -42
  235. package/dist/{src-QRV3466B.js → src-7MEBCSTP.js} +9 -9
  236. package/dist/{src-EPOGDJTT.js → src-LNSJHD25.js} +10 -6
  237. package/dist/{state-6QHNNHDA.js → state-W3AS6O2J.js} +2 -2
  238. package/dist/{staticProjectServer-ERKLMZVM.js → staticProjectServer-TTJSAB2Q.js} +19 -19
  239. package/dist/{status-4AAPTTRW.js → status-FGXBUX2T.js} +36 -11
  240. package/dist/studio/assets/hyperframes-player-Bzcd9O2g.js +478 -0
  241. package/dist/studio/assets/{index-C8VIUiGz.js → index-CZI-XmnO.js} +119 -119
  242. package/dist/studio/assets/{index-CVPNbydK.js → index-LW6kxYVF.js} +1 -1
  243. package/dist/studio/index.html +1 -1
  244. package/dist/{studio-api-7WFZIIPL.js → studio-api-57E36S5N.js} +15 -15
  245. package/dist/{studioServer-3XZTLI26.js → studioServer-2AIRUNBA.js} +55 -55
  246. package/dist/sync-52GUXEYZ.js +115 -0
  247. package/dist/{telemetry-BMLI4TMC.js → telemetry-RVY6RSCD.js} +6 -6
  248. package/dist/{telemetry-QHYJJAJU.js → telemetry-T73TKZOL.js} +1 -1
  249. package/dist/{timeline-EDCDO2ZR.js → timeline-MMZF4AX3.js} +31 -27
  250. package/dist/{tokens-2ZFLFO3K.js → tokens-WGWCYFTY.js} +5 -5
  251. package/dist/{transcribe-Y2LPBT7I.js → transcribe-6BF5FFPV.js} +39 -22
  252. package/dist/{transcribe-3WMH62HH.js → transcribe-YYDHXRQW.js} +11 -10
  253. package/dist/{tts-BVTJEP72.js → tts-ZLNNIS6W.js} +5 -5
  254. package/dist/{updateCheck-5LFZGC3P.js → updateCheck-AAR5LLUF.js} +4 -4
  255. package/dist/{upgrade-X7QVSEKP.js → upgrade-Y7CIRL4B.js} +5 -5
  256. package/dist/{urlDownloader-TYD6ROKL.js → urlDownloader-KZOD7EWX.js} +6 -6
  257. package/dist/{validate-26KQ5VX7.js → validate-K3PHAA2E.js} +30 -30
  258. package/dist/{video-BPKLZIJK.js → video-Z6EBVCAT.js} +9 -9
  259. package/dist/warmCheck.js +47 -46
  260. package/package.json +1 -1
  261. package/dist/chunk-LL3VMDAC.js +0 -5013
  262. package/dist/studio/assets/hyperframes-player-Dka6e1BG.js +0 -478
  263. package/dist/{chunk-NOH32H42.js → chunk-HBAUU3IK.js} +124 -124
  264. package/dist/{synthesize-4JC74JW5.js → synthesize-DIT2SR3D.js} +5 -5
@@ -4,69 +4,63 @@ 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
+ DEFAULT_CAPABILITIES,
9
+ analyzeTargets,
10
+ previewTarget,
11
+ runFile,
12
+ serviceAccess,
13
+ serviceFailure
14
+ } from "./chunk-KEDN4LSV.js";
7
15
  import {
8
16
  uploadAssetViaDirectUpload
9
17
  } from "./chunk-CE7EQUBV.js";
10
18
  import {
11
19
  HyperframesCloudClient
12
20
  } from "./chunk-6A45RKAK.js";
13
- import {
14
- describeProject
15
- } from "./chunk-42Q3VX34.js";
16
- import "./chunk-LLMSX6V6.js";
17
21
  import {
18
22
  PITCH_RATE,
19
- STEADY_BEAT_CONFIDENCE,
20
23
  bandFramesOf,
21
- envelope,
22
- localBeatEvidence,
23
24
  loudness,
24
25
  medianInterval,
25
26
  pitchTrack,
26
- rhythm,
27
- runLadder,
28
- signalDuration,
29
- signalProvider,
30
- silence,
31
- snapper,
32
- tempoOf
33
- } from "./chunk-NOH32H42.js";
27
+ rhythm
28
+ } from "./chunk-HBAUU3IK.js";
29
+ import {
30
+ describeProject
31
+ } from "./chunk-F34GYYXO.js";
32
+ import "./chunk-LLMSX6V6.js";
34
33
  import {
35
34
  ensureDOMParser
36
35
  } from "./chunk-ZBAF6L74.js";
37
- import {
38
- refreshIfNeeded,
39
- resolveCloudBaseUrl
40
- } from "./chunk-YSTBSLWY.js";
41
- import {
42
- buildAuthHeaders,
43
- tryResolveCredential
44
- } from "./chunk-MESSJFK3.js";
45
36
  import {
46
37
  downloadToFile
47
38
  } from "./chunk-NO6F7CLR.js";
39
+ import "./chunk-BEMGUGGJ.js";
40
+ import "./chunk-QOYZ3U6G.js";
48
41
  import {
49
42
  decodeAudio,
50
43
  probeAudio
51
44
  } from "./chunk-SWC3QIEH.js";
52
45
  import {
53
46
  loadTranscript
54
- } from "./chunk-6MUI2H6P.js";
47
+ } from "./chunk-54Q3H2UQ.js";
55
48
  import {
56
49
  resolveProject
57
- } from "./chunk-Z5VQBRU2.js";
50
+ } from "./chunk-VPMHRLJH.js";
58
51
  import "./chunk-AW3XJY4S.js";
59
- import "./chunk-DC26QLB7.js";
60
- import "./chunk-5ZBMHUY2.js";
52
+ import "./chunk-X5BSSPC2.js";
53
+ import "./chunk-5LOZWO2M.js";
54
+ import "./chunk-EHZESMRB.js";
61
55
  import "./chunk-A4ZTSQLW.js";
62
- import "./chunk-AN4USOFT.js";
63
- import "./chunk-NUE44RN2.js";
56
+ import "./chunk-NI35PAVN.js";
57
+ import "./chunk-QOI46C6F.js";
64
58
  import "./chunk-PXVQOMKL.js";
65
- import "./chunk-EQGKUPBJ.js";
59
+ import "./chunk-MCDNAIFF.js";
66
60
  import "./chunk-VLA6UJGH.js";
67
61
  import {
68
62
  assertKnownFlags
69
- } from "./chunk-XC3BGWCJ.js";
63
+ } from "./chunk-ZFQSXMX6.js";
70
64
  import {
71
65
  defineCommand
72
66
  } from "./chunk-DL4OD7IA.js";
@@ -74,15 +68,15 @@ import "./chunk-S3S4TGEH.js";
74
68
  import "./chunk-WYKRGEDD.js";
75
69
  import "./chunk-54HJ63Q2.js";
76
70
  import "./chunk-2GICKZ3I.js";
77
- import "./chunk-AIXH3V5A.js";
71
+ import "./chunk-NFUR6NNT.js";
78
72
  import "./chunk-Z5J67X44.js";
79
73
  import "./chunk-5S7W3TUO.js";
80
74
  import "./chunk-D3MUHMFG.js";
81
- import "./chunk-3RXZZIDQ.js";
75
+ import "./chunk-7RTPHNOO.js";
82
76
  import "./chunk-YWRUQ7XZ.js";
83
- import "./chunk-BDZSH6P3.js";
77
+ import "./chunk-FJ3KUOUZ.js";
84
78
  import "./chunk-MEJH7VEA.js";
85
- import "./chunk-LL3VMDAC.js";
79
+ import "./chunk-6UWSEXQ3.js";
86
80
  import "./chunk-VC76R6W2.js";
87
81
  import "./chunk-OFQWTKPW.js";
88
82
  import "./chunk-RQVDTPGD.js";
@@ -92,14 +86,14 @@ import "./chunk-FXMKHHPO.js";
92
86
  import "./chunk-LAGZGKKN.js";
93
87
  import "./chunk-K4MJX7SR.js";
94
88
  import "./chunk-WE42NVH7.js";
95
- import "./chunk-VQMHDS2V.js";
96
- import "./chunk-CZGHFATT.js";
89
+ import "./chunk-HT3D5AKG.js";
97
90
  import {
98
91
  findFfBinary
99
92
  } from "./chunk-HYRPH6LL.js";
100
93
  import {
101
94
  resolveAuthoredAssetFile
102
95
  } from "./chunk-AKMY4QVI.js";
96
+ import "./chunk-CZGHFATT.js";
103
97
  import "./chunk-C2KEGBR3.js";
104
98
  import "./chunk-T5ELONXY.js";
105
99
  import "./chunk-FR7YBU3H.js";
@@ -111,17 +105,17 @@ import "./chunk-WC4MTXGN.js";
111
105
  import "./chunk-FBN2M2HK.js";
112
106
  import {
113
107
  withMeta
114
- } from "./chunk-L55LAERP.js";
108
+ } from "./chunk-2KDHJCH2.js";
115
109
  import "./chunk-BR2JQQC5.js";
116
110
  import "./chunk-BLBMPEBX.js";
117
111
  import "./chunk-ISN5GRYI.js";
118
- import "./chunk-SJGE5I5F.js";
112
+ import "./chunk-ADVVQX4I.js";
119
113
  import {
120
114
  CliUsageError
121
- } from "./chunk-DP5LF7GF.js";
115
+ } from "./chunk-66W5IWLO.js";
122
116
  import "./chunk-J3RXEDR2.js";
123
117
  import "./chunk-QBXDU24O.js";
124
- import "./chunk-6W3DY5BP.js";
118
+ import "./chunk-MA5AQK7T.js";
125
119
  import "./chunk-E63BDV4Z.js";
126
120
  import "./chunk-G7VEYUZ2.js";
127
121
  import "./chunk-XT6MXC7A.js";
@@ -129,665 +123,11 @@ import "./chunk-7KDQAD2W.js";
129
123
  import "./chunk-M2WBOQ2Q.js";
130
124
 
131
125
  // src/commands/audio.ts
132
- import { join as join8, resolve as resolve2 } from "path";
133
-
134
- // src/audio/analysis/providers/api.ts
135
- import { randomUUID } from "crypto";
136
-
137
- // src/audio/analysis/providers/shared.ts
138
- import { execFile } from "child_process";
139
- import { mkdtemp, rm, writeFile } from "fs/promises";
140
- import { tmpdir } from "os";
141
- import { join } from "path";
142
- import { promisify } from "util";
143
- var runFile = promisify(execFile);
144
- var unavailable = (reason) => ({ ok: false, reason });
145
- var AVAILABLE = { ok: true };
146
- function encodeWav(signal) {
147
- const channels = signal.channels.length;
148
- const frames = signal.channels[0]?.length ?? 0;
149
- const data = frames * channels * 2;
150
- const wav = Buffer.alloc(44 + data);
151
- wav.write("RIFF", 0);
152
- wav.writeUInt32LE(36 + data, 4);
153
- wav.write("WAVEfmt ", 8);
154
- wav.writeUInt32LE(16, 16);
155
- wav.writeUInt16LE(1, 20);
156
- wav.writeUInt16LE(channels, 22);
157
- wav.writeUInt32LE(signal.sampleRate, 24);
158
- wav.writeUInt32LE(signal.sampleRate * channels * 2, 28);
159
- wav.writeUInt16LE(channels * 2, 32);
160
- wav.writeUInt16LE(16, 34);
161
- wav.write("data", 36);
162
- wav.writeUInt32LE(data, 40);
163
- let offset = 44;
164
- for (let i = 0; i < frames; i++)
165
- for (const channel of signal.channels) {
166
- const sample = Math.max(-1, Math.min(1, channel[i]));
167
- wav.writeInt16LE(Math.round(sample * 32767), offset);
168
- offset += 2;
169
- }
170
- return wav;
171
- }
172
- async function withWavFile(signal, use) {
173
- const dir = await mkdtemp(join(tmpdir(), "hf-audio-"));
174
- try {
175
- const path = join(dir, "audio.wav");
176
- await writeFile(path, encodeWav(signal));
177
- return await use(path);
178
- } finally {
179
- await rm(dir, { recursive: true, force: true });
180
- }
181
- }
182
- function perSignal(compute) {
183
- const answers = /* @__PURE__ */ new WeakMap();
184
- return (signal) => {
185
- let answer = answers.get(signal);
186
- if (!answer) answers.set(signal, answer = compute(signal));
187
- return answer;
188
- };
189
- }
190
- function downbeatsWithMeter(beats, downbeats) {
191
- const bar = medianInterval(downbeats);
192
- const beat = medianInterval(beats);
193
- const meter = bar && beat ? Math.round(bar / beat) : null;
194
- return { times: downbeats, meter: meter && meter > 0 ? meter : null };
195
- }
196
- var round = (t) => Math.round(t * 1e3) / 1e3;
197
- var rounded = (times) => times.map(round);
198
- var NO_HEYGEN_CREDENTIAL = "no HeyGen credential: set HEYGEN_API_KEY or run `hyperframes auth login --api-key`";
199
- async function heygenHeaders() {
200
- try {
201
- const credential = await tryResolveCredential();
202
- return credential ? buildAuthHeaders(await refreshIfNeeded(credential)) : NO_HEYGEN_CREDENTIAL;
203
- } catch (error) {
204
- return error instanceof Error ? error.message : String(error);
205
- }
206
- }
207
- async function serviceAccess(env, path, defaultMs) {
208
- const timeout = Number(process.env[env.timeout]);
209
- const timeoutMs = timeout > 0 ? timeout : defaultMs;
210
- const url = process.env[env.url]?.trim();
211
- const key = process.env[env.key]?.trim();
212
- if (url === "") return `${env.url} is empty, which turns this service off`;
213
- if (key)
214
- return {
215
- url: url || `${resolveCloudBaseUrl()}${path}`,
216
- headers: { "x-api-key": key },
217
- timeoutMs
218
- };
219
- if (url) return `${env.url} is set but ${env.key} is not`;
220
- const headers = await heygenHeaders();
221
- if (typeof headers === "string") return headers;
222
- return { url: `${resolveCloudBaseUrl()}${path}`, headers, timeoutMs };
223
- }
224
- function errorMessageIn(text) {
225
- try {
226
- return JSON.parse(text).error?.message;
227
- } catch {
228
- return void 0;
229
- }
230
- }
231
- async function serviceFailure(response, service) {
232
- const text = await response.text().catch(() => "");
233
- const detail = errorMessageIn(text) ?? text.slice(0, 200);
234
- return new Error(`${service} answered ${response.status}${detail ? `: ${detail}` : ""}`);
235
- }
236
-
237
- // src/audio/analysis/providers/api.ts
238
- var URL_ENV = "HYPERFRAMES_AUDIO_API_URL";
239
- var KEY_ENV = "HYPERFRAMES_AUDIO_API_KEY";
240
- var TIMEOUT_ENV = "HYPERFRAMES_AUDIO_API_TIMEOUT_MS";
241
- var DEFAULT_TIMEOUT_MS = 12e4;
242
- var UPLOAD_RATE = 16e3;
243
- var SINC_ZEROS = 16;
244
- var ROLLOFF = 0.9;
245
- var SINC_STEPS = 512;
246
- var HANN_SINC = Float32Array.from({ length: SINC_ZEROS * SINC_STEPS + 2 }, (_, k) => {
247
- const x = k / SINC_STEPS;
248
- if (x >= SINC_ZEROS) return 0;
249
- const sinc = x === 0 ? 1 : Math.sin(Math.PI * x) / (Math.PI * x);
250
- return sinc * (0.5 + 0.5 * Math.cos(Math.PI * x / SINC_ZEROS));
251
- });
252
- function resample(input, from, to) {
253
- if (from === to) return input;
254
- const step = from / to;
255
- const scale = Math.min(1, to / from) * ROLLOFF;
256
- const reach = SINC_ZEROS / scale;
257
- const output = new Float32Array(Math.round(input.length / step));
258
- for (let i = 0; i < output.length; i++) {
259
- const center = i * step;
260
- const last = Math.min(input.length - 1, Math.floor(center + reach));
261
- let sum = 0;
262
- let weights = 0;
263
- for (let n = Math.max(0, Math.ceil(center - reach)); n <= last; n++) {
264
- const at = Math.abs(n - center) * scale * SINC_STEPS;
265
- const k = Math.floor(at);
266
- const weight = HANN_SINC[k] + (at - k) * (HANN_SINC[k + 1] - HANN_SINC[k]);
267
- sum += input[n] * weight;
268
- weights += weight;
269
- }
270
- output[i] = weights ? sum / weights : 0;
271
- }
272
- return output;
273
- }
274
- function monoInput(channels) {
275
- const mono = new Float32Array(channels[0]?.length ?? 0);
276
- let loudest2 = mono;
277
- let loudestEnergy = 0;
278
- for (const channel of channels) {
279
- let energy = 0;
280
- for (let i = 0; i < mono.length; i++) {
281
- const value = channel[i];
282
- mono[i] += value / channels.length;
283
- energy += value * value;
284
- }
285
- if (energy > loudestEnergy) {
286
- loudest2 = channel;
287
- loudestEnergy = energy;
288
- }
289
- }
290
- const monoEnergy = mono.reduce((energy, value) => energy + value * value, 0);
291
- return monoEnergy < loudestEnergy * 0.1 ? loudest2 : mono;
292
- }
293
- function uploaded(signal) {
294
- return {
295
- sampleRate: UPLOAD_RATE,
296
- channels: [resample(monoInput(signal.channels), signal.sampleRate, UPLOAD_RATE)]
297
- };
298
- }
299
- var askedTogether = (capability) => capability === "beats" || capability === "downbeats" ? ["beats", "downbeats"] : [capability];
300
- var access = () => serviceAccess(
301
- { url: URL_ENV, key: KEY_ENV, timeout: TIMEOUT_ENV },
302
- "/v3/audio/analysis",
303
- DEFAULT_TIMEOUT_MS
304
- );
305
- async function granted() {
306
- const found = await access();
307
- if (typeof found === "string") throw new Error(found);
308
- return found;
309
- }
310
- var isNumberList = (value) => Array.isArray(value) && value.every((t) => typeof t === "number" && Number.isFinite(t));
311
- function checked(capability, body) {
312
- const value = body[capability];
313
- if (!value || typeof value !== "object")
314
- throw new Error(`the service did not answer ${capability}`);
315
- const valid = {
316
- beats: () => isNumberList(value.times),
317
- downbeats: () => isNumberList(value.times),
318
- sections: () => Array.isArray(value.spans) && value.spans.every((s3) => isNumberList([s3.start, s3.end])),
319
- describe: () => Array.isArray(value.tags) && value.tags.every(
320
- (t) => typeof t.label === "string" && typeof t.score === "number"
321
- )
322
- }[capability];
323
- if (!valid())
324
- throw new Error(`the service answered ${capability} in a shape this CLI cannot read`);
325
- }
326
- var uploadedAsset = perSignal(async (analyzed) => {
327
- const { url, headers, timeoutMs } = await granted();
328
- const deadline = AbortSignal.timeout(timeoutMs);
329
- const boundedFetch = (input, init) => fetch(input, {
330
- ...init,
331
- redirect: "error",
332
- signal: deadline
333
- });
334
- const client = new HyperframesCloudClient({
335
- baseUrl: new URL(url).origin,
336
- getAuthHeaders: () => headers,
337
- fetchImpl: boundedFetch
338
- });
339
- const asset = await uploadAssetViaDirectUpload({
340
- client,
341
- bytes: new Uint8Array(encodeWav(uploaded(analyzed))),
342
- filename: "audio.wav",
343
- contentType: "audio/wav",
344
- idempotencyKey: randomUUID(),
345
- fetchImpl: boundedFetch
346
- });
347
- return asset.asset_id;
348
- });
349
- async function ask(analyzed, capabilities2) {
350
- const { url, headers, timeoutMs } = await granted();
351
- const request = {
352
- version: 1,
353
- capabilities: capabilities2,
354
- audio: { type: "asset_id", asset_id: await uploadedAsset(analyzed) }
355
- };
356
- const response = await fetch(url, {
357
- method: "POST",
358
- redirect: "error",
359
- headers: {
360
- ...headers,
361
- "idempotency-key": randomUUID(),
362
- "content-type": "application/json"
363
- },
364
- body: JSON.stringify(request),
365
- signal: AbortSignal.timeout(timeoutMs)
366
- });
367
- if (!response.ok) throw await serviceFailure(response, "the service");
368
- const body = await response.json();
369
- return body?.data ?? body ?? {};
370
- }
371
- var requests = /* @__PURE__ */ new Map();
372
- function answerFor(signal, capability) {
373
- const together = askedTogether(capability);
374
- const key = together.join(",");
375
- let request = requests.get(key);
376
- if (!request) requests.set(key, request = perSignal((s3) => ask(s3, together)));
377
- return request(signal);
378
- }
379
- function beatSnapper(signal) {
380
- const measured3 = rhythm(signal).beats.times;
381
- return snapper(measured3, (medianInterval(measured3) ?? 0) / 4, "signal beats");
382
- }
383
- function snappedSections(signal, body) {
384
- const onBeat2 = beatSnapper(signal);
385
- const end = (signal.channels[0]?.length ?? 0) / signal.sampleRate;
386
- const move = (t) => t <= 0 || t >= end ? t : onBeat2.snap(t);
387
- const spans = body.sections.spans.map((s3) => ({
388
- ...s3,
389
- start: rounded([move(s3.start)])[0],
390
- end: rounded([move(s3.end)])[0]
391
- }));
392
- return { spans, snap: onBeat2.report() };
393
- }
394
- function measured(capability, signal, body) {
395
- const value = capability === "beats" ? { times: rounded(body.beats.times) } : capability === "downbeats" ? { times: rounded(body.downbeats.times), meter: body.downbeats.meter ?? null } : capability === "sections" ? snappedSections(signal, body) : body.describe;
396
- return body.source ? { ...value, source: body.source } : value;
397
- }
398
- var API_CAPABILITIES = ["beats", "downbeats", "sections", "describe"];
399
- var apiProvider = {
400
- id: "api",
401
- local: false,
402
- capabilities: API_CAPABILITIES,
403
- async available() {
404
- const found = await access();
405
- return typeof found === "string" ? unavailable(found) : AVAILABLE;
406
- },
407
- async analyze(capability, signal) {
408
- const asked = capability;
409
- const body = await answerFor(signal, asked);
410
- checked(asked, body);
411
- return measured(asked, signal, body);
412
- }
413
- };
414
-
415
- // src/audio/analysis/providers/apple.ts
416
- import { createHash } from "crypto";
417
- import { existsSync } from "fs";
418
- import { mkdir, rename, writeFile as writeFile2 } from "fs/promises";
419
- import { homedir } from "os";
420
- import { join as join2 } from "path";
421
- var SOUND_ANALYSIS = "/System/Library/Frameworks/SoundAnalysis.framework";
422
- var MUSIC_UNDERSTANDING_MACOS = 27;
423
- var SOUND_TAGGER = `
424
- import Foundation
425
- import SoundAnalysis
426
-
427
- final class Collector: NSObject, SNResultsObserving {
428
- var sums: [String: Double] = [:]
429
- var windows = 0
430
- var failure: Error?
431
- func request(_ request: SNRequest, didProduce result: SNResult) {
432
- guard let result = result as? SNClassificationResult else { return }
433
- windows += 1
434
- for c in result.classifications { sums[c.identifier, default: 0] += c.confidence }
435
- }
436
- func request(_ request: SNRequest, didFailWithError error: Error) { failure = error }
437
- }
438
-
439
- do {
440
- let analyzer = try SNAudioFileAnalyzer(url: URL(fileURLWithPath: CommandLine.arguments[1]))
441
- let collector = Collector()
442
- try analyzer.add(try SNClassifySoundRequest(classifierIdentifier: .version1), withObserver: collector)
443
- analyzer.analyze()
444
- if let failure = collector.failure { throw failure }
445
- let count = Double(max(1, collector.windows))
446
- var tags: [[String: Any]] = []
447
- for (label, sum) in collector.sums.sorted(by: { $0.value > $1.value }).prefix(10) {
448
- let score: Double = sum / count
449
- if score >= 0.01 { tags.append(["label": label, "score": (score * 1000).rounded() / 1000]) }
450
- }
451
- let json = try JSONSerialization.data(withJSONObject: ["tags": tags, "windows": collector.windows])
452
- FileHandle.standardOutput.write(json)
453
- } catch {
454
- FileHandle.standardError.write(Data("\\(error)".utf8))
455
- exit(1)
456
- }
457
- `;
458
- var CLASSIFIER_WINDOW_SECONDS = 3;
459
- function atLeastOneWindow(signal) {
460
- const length = Math.ceil(CLASSIFIER_WINDOW_SECONDS * signal.sampleRate);
461
- if ((signal.channels[0]?.length ?? 0) >= length) return signal;
462
- return {
463
- ...signal,
464
- channels: signal.channels.map((channel) => {
465
- const padded = new Float32Array(length);
466
- padded.set(channel);
467
- return padded;
468
- })
469
- };
470
- }
471
- var helperDir = () => join2(homedir(), ".cache", "hyperframes", "audio-helpers");
472
- function helperPath(name, source) {
473
- const hash = createHash("sha256").update(source).digest("hex").slice(0, 12);
474
- return join2(helperDir(), `${name}-${hash}`);
475
- }
476
- async function hasSwiftCompiler() {
477
- try {
478
- await runFile("xcrun", ["--find", "swiftc"], { timeout: 3e4 });
479
- return true;
480
- } catch {
481
- return false;
482
- }
483
- }
484
- var firstLine = (error) => (error.stderr || String(error)).trim().split("\n")[0];
485
- function swiftcArgs(source, output) {
486
- return [
487
- "--sdk",
488
- "macosx",
489
- "swiftc",
490
- "-O",
491
- "-swift-version",
492
- "5",
493
- "-module-cache-path",
494
- join2(helperDir(), "module-cache"),
495
- source,
496
- "-o",
497
- output
498
- ];
499
- }
500
- var builds = /* @__PURE__ */ new Map();
501
- function compiled(name, source) {
502
- const binary = helperPath(name, source);
503
- if (existsSync(binary)) return Promise.resolve(binary);
504
- let build = builds.get(binary);
505
- if (!build) {
506
- build = (async () => {
507
- await mkdir(helperDir(), { recursive: true });
508
- const file = `${binary}.swift`;
509
- await writeFile2(file, source);
510
- const args = swiftcArgs(file, `${binary}.tmp`);
511
- await runFile("xcrun", args, { timeout: 5 * 6e4 }).catch((error) => {
512
- throw new Error(`could not build the ${name} helper: ${firstLine(error)}`);
513
- });
514
- await rename(`${binary}.tmp`, binary);
515
- return binary;
516
- })();
517
- builds.set(binary, build);
518
- }
519
- return build;
520
- }
521
- async function macosMajor() {
522
- if (process.platform !== "darwin") return null;
523
- const { stdout } = await runFile("sw_vers", ["-productVersion"], { timeout: 1e4 });
524
- return Number.parseInt(stdout, 10) || null;
525
- }
526
- var appleSoundProvider = {
527
- id: "apple-sound",
528
- local: true,
529
- capabilities: ["describe"],
530
- async available() {
531
- if (process.platform !== "darwin") return unavailable("macOS only");
532
- if (!existsSync(SOUND_ANALYSIS))
533
- return unavailable("SoundAnalysis.framework is not on this Mac");
534
- if (existsSync(helperPath("apple-sound", SOUND_TAGGER))) return AVAILABLE;
535
- if (!await hasSwiftCompiler()) return unavailable("no Swift compiler to build the helper");
536
- return AVAILABLE;
537
- },
538
- async analyze(_capability, signal) {
539
- const helper = await compiled("apple-sound", SOUND_TAGGER);
540
- const { stdout } = await withWavFile(
541
- atLeastOneWindow(signal),
542
- (wav) => runFile(helper, [wav], { timeout: 5 * 6e4, maxBuffer: 8 * 1024 * 1024 })
543
- );
544
- const { tags } = JSON.parse(stdout);
545
- return {
546
- tags: tags.map((t) => ({ label: t.label, score: Math.round(t.score * 1e3) / 1e3 }))
547
- };
548
- }
549
- };
550
- var appleMuProvider = {
551
- id: "apple-mu",
552
- local: true,
553
- capabilities: ["beats", "downbeats", "sections"],
554
- async available() {
555
- const major = await macosMajor();
556
- if (major === null) return unavailable("macOS only");
557
- if (major < MUSIC_UNDERSTANDING_MACOS)
558
- return unavailable(
559
- `Music Understanding needs macOS ${MUSIC_UNDERSTANDING_MACOS}; this Mac runs ${major}`
560
- );
561
- return unavailable("no Music Understanding helper yet: it needs the macOS 27 SDK to build");
562
- },
563
- analyze() {
564
- return Promise.reject(new Error("Music Understanding is not available"));
565
- }
566
- };
567
-
568
- // src/audio/analysis/providers/beatThis.ts
569
- import { existsSync as existsSync2 } from "fs";
570
- import { homedir as homedir2 } from "os";
571
- import { join as join3 } from "path";
572
- var PYTHON_ENV = "HYPERFRAMES_BEAT_THIS_PYTHON";
573
- var CHECKPOINT_ENV = "HYPERFRAMES_BEAT_THIS_CHECKPOINT";
574
- function checkpointPath() {
575
- const configured = process.env[CHECKPOINT_ENV]?.trim();
576
- if (configured) return configured;
577
- const torchHome = process.env.TORCH_HOME ?? join3(homedir2(), ".cache", "torch");
578
- return join3(torchHome, "hub", "checkpoints", "beat_this-small0.ckpt");
579
- }
580
- var FIND_PACKAGE = "import importlib.util,sys; sys.exit(importlib.util.find_spec('beat_this') is None)";
581
- var TRACK = `
582
- import json, sys
583
- from beat_this.inference import File2Beats
584
- beats, downbeats = File2Beats(checkpoint_path=sys.argv[2], device="cpu", dbn=False)(sys.argv[1])
585
- print(json.dumps({"beats": [float(t) for t in beats], "downbeats": [float(t) for t in downbeats]}))
586
- `;
587
- var installed = /* @__PURE__ */ new Map();
588
- function hasPackage(python) {
589
- let found = installed.get(python);
590
- if (!found) {
591
- found = runFile(python, ["-c", FIND_PACKAGE], { timeout: 3e4, windowsHide: true }).then(
592
- () => true,
593
- () => false
594
- );
595
- installed.set(python, found);
596
- }
597
- return found;
598
- }
599
- var track = perSignal(
600
- (signal) => withWavFile(signal, async (wav) => {
601
- const python = process.env[PYTHON_ENV].trim();
602
- const { stdout } = await runFile(python, ["-c", TRACK, wav, checkpointPath()], {
603
- maxBuffer: 64 * 1024 * 1024,
604
- timeout: 10 * 6e4,
605
- windowsHide: true
606
- });
607
- const answer = JSON.parse(stdout.trim().split("\n").pop());
608
- return { beats: rounded(answer.beats), downbeats: rounded(answer.downbeats) };
609
- })
610
- );
611
- var beatThisProvider = {
612
- id: "beat-this",
613
- local: true,
614
- capabilities: ["beats", "downbeats"],
615
- async available() {
616
- const python = process.env[PYTHON_ENV]?.trim();
617
- if (!python) return unavailable(`${PYTHON_ENV} is not set`);
618
- if (!existsSync2(python)) return unavailable(`${PYTHON_ENV} names no file`);
619
- if (!existsSync2(checkpointPath()))
620
- return unavailable(`no Beat This! weights at ${checkpointPath()}`);
621
- if (!await hasPackage(python)) return unavailable(`beat_this is not installed for ${python}`);
622
- return AVAILABLE;
623
- },
624
- async analyze(capability, signal) {
625
- const { beats, downbeats } = await track(signal);
626
- return capability === "beats" ? { times: beats } : downbeatsWithMeter(beats, downbeats);
627
- }
628
- };
629
-
630
- // src/audio/analysis/fileTime.ts
631
- var round2 = (t) => Math.round(t * 1e3) / 1e3;
632
- function withSnap(value, at) {
633
- return value.snap ? { ...value, snap: { ...value.snap, unsnapped: value.snap.unsnapped.map(at) } } : value;
634
- }
635
- var SHIFTS = {
636
- moments: (m, at) => Object.fromEntries(Object.entries(m).map(([k, t]) => [k, at(t)])),
637
- onsets: (o, at) => ({ ...o, events: o.events.map((e) => ({ ...e, t: at(e.t) })) }),
638
- silence: (spans, at) => spans.map((s3) => ({ start: at(s3.start), end: at(s3.end) })),
639
- loudness: (l, at) => ({
640
- ...l,
641
- clipping: {
642
- ...l.clipping,
643
- firstAt: l.clipping.firstAt === null ? null : at(l.clipping.firstAt)
644
- }
645
- }),
646
- envelope: (e, _at, offset) => ({ startsAt: round2(offset), ...e }),
647
- beats: (b, at) => withSnap({ ...b, times: b.times.map(at) }, at),
648
- downbeats: (b, at) => withSnap({ ...b, times: b.times.map(at) }, at),
649
- bpm: (tempo, at) => ({
650
- ...tempo,
651
- curve: tempo.curve.map((p) => ({ ...p, t: at(p.t) }))
652
- }),
653
- sections: (s3, at) => withSnap(
654
- {
655
- ...s3,
656
- spans: s3.spans.map((span) => ({ ...span, start: at(span.start), end: at(span.end) }))
657
- },
658
- at
659
- )
660
- };
661
- function shiftedTimes(capability, value, offset) {
662
- if (value === null || typeof value !== "object") return value;
663
- const shift = SHIFTS[capability];
664
- return shift ? shift(value, (t) => round2(t + offset), offset) : value;
665
- }
666
-
667
- // src/audio/analysis/analyze.ts
668
- var DEFAULT_CAPABILITIES = [
669
- "kind",
670
- "moments",
671
- "onsets",
672
- "loudness",
673
- "silence",
674
- "envelope"
675
- ];
676
- function audioAnalysisProviders() {
677
- return [apiProvider, appleMuProvider, beatThisProvider, appleSoundProvider, signalProvider];
678
- }
679
- function envelopeHopMs(seconds, asked) {
680
- if (asked !== void 0) return asked;
681
- return Math.max(5, Math.ceil(seconds * 1e3 / 2e3));
682
- }
683
- var round3 = (t) => Math.round(t * 1e3) / 1e3;
684
- function within(value, from, to) {
685
- if (!value || typeof value !== "object" || !("events" in value)) return value;
686
- const onsets = value;
687
- return { ...onsets, events: onsets.events.filter((e) => e.t >= from && e.t < to) };
688
- }
689
- function frame(signal, context) {
690
- const before = context?.before ?? 0;
691
- const skip = Math.round(before * signal.sampleRate);
692
- const length = signal.channels[0]?.length ?? 0;
693
- const end = Math.max(skip, length - Math.round((context?.after ?? 0) * signal.sampleRate));
694
- const cut = skip > 0 || end < length;
695
- const windowed = cut ? { ...signal, channels: signal.channels.map((c) => c.subarray(skip, end)) } : signal;
696
- return { windowed, before, end: end / signal.sampleRate, cut };
697
- }
698
- function optionsFor(capability, request, seconds) {
699
- const options = { ...request.options?.[capability] };
700
- if (capability === "envelope")
701
- options.hopMs = envelopeHopMs(seconds, options.hopMs);
702
- return options;
703
- }
704
- async function analyzeSignal(signal, request, providers = audioAnalysisProviders()) {
705
- const quality = request.quality ?? "local";
706
- const { beats, bpm } = request.provider ?? {};
707
- if (beats && bpm && beats !== bpm) throw new Error("beats and bpm must use the same provider");
708
- const beatProvider = beats ?? bpm;
709
- const framing = frame(signal, request.context);
710
- const analysis = {
711
- analyzed: round3(signalDuration(framing.windowed)),
712
- values: {},
713
- provenance: {},
714
- ladder: {},
715
- warnings: []
716
- };
717
- const ladders = /* @__PURE__ */ new Map();
718
- const ladderFor = (capability) => {
719
- let result = ladders.get(capability);
720
- if (!result) {
721
- const withContext = capability === "onsets" && framing.cut;
722
- const input = withContext ? signal : framing.windowed;
723
- result = runLadder(capability, input, providers, {
724
- quality,
725
- provider: capability === "beats" ? beatProvider : request.provider?.[capability],
726
- options: optionsFor(capability, request, analysis.analyzed)
727
- }).then((answer) => settled(capability, answer, input));
728
- ladders.set(capability, result);
729
- }
730
- return result;
731
- };
732
- for (const capability of request.capabilities) {
733
- const withContext = capability === "onsets" && framing.cut;
734
- const result = capability === "bpm" ? tempoFromBeats(await ladderFor("beats")) : await ladderFor(capability);
735
- const value = withContext ? within(result.value, framing.before, framing.end) : result.value;
736
- const offset = (request.fileOffset ?? 0) - (withContext ? framing.before : 0);
737
- analysis.values[capability] = shiftedTimes(capability, value, offset);
738
- analysis.provenance[capability] = result.provenance;
739
- analysis.ladder[capability] = result.steps;
740
- const said = new Set(analysis.warnings);
741
- analysis.warnings.push(...result.warnings.filter((w) => !said.has(w)));
742
- }
743
- analysis.warnings.push(...serviceHint(quality, analysis, request.capabilities));
744
- return analysis;
745
- }
746
- function serviceHint(quality, analysis, capabilities2) {
747
- const leftToService = (capability) => analysis.values[capability] == null && (analysis.ladder[capability] ?? []).some((s3) => s3.outcome === "excluded");
748
- return quality === "local" && capabilities2.some(leftToService) ? ["a service could have answered what is missing: --quality best uploads the audio to HeyGen"] : [];
749
- }
750
- var DIGITAL_SILENCE_DB = -80;
751
- var HEARD_LIFT = 1.5;
752
- var roundTime = (t) => Math.round(t * 1e3) / 1e3;
753
- function settled(capability, result, signal) {
754
- if (capability !== "beats" && capability !== "downbeats") return result;
755
- const value = result.value;
756
- if (!value?.times) return result;
757
- const beat = beatOf(capability, value, signal);
758
- const onSignal = result.provenance === "signal" ? value : snappedToSignal(value, signal, beat);
759
- const quiet = silence(signal, { thresholdDb: DIGITAL_SILENCE_DB });
760
- const evidence = localBeatEvidence(
761
- signal,
762
- onSignal.times,
763
- capability === "downbeats" ? beat : void 0
764
- );
765
- const unheard = onSignal.times.map(
766
- (t, i) => quiet.some((span) => t >= span.start && t < span.end) || evidence[i].confidence < STEADY_BEAT_CONFIDENCE && evidence[i].lift < HEARD_LIFT
767
- );
768
- return { ...result, value: { ...onSignal, unheard } };
769
- }
770
- function beatOf(capability, value, signal) {
771
- const interval = medianInterval(value.times);
772
- const own = capability === "beats" ? interval : interval && value.meter ? interval / value.meter : null;
773
- return own ?? medianInterval(rhythm(signal).beats.times) ?? 0;
774
- }
775
- function snappedToSignal(value, signal, beat) {
776
- const onBeat2 = snapper(rhythm(signal).beats.times, beat / 4, "signal beats");
777
- return {
778
- ...value,
779
- times: value.times.map((t) => roundTime(onBeat2.snap(t))),
780
- snap: onBeat2.report()
781
- };
782
- }
783
- function tempoFromBeats(beats) {
784
- const times = beats.value?.times;
785
- return { ...beats, value: times ? tempoOf(times) : null };
786
- }
126
+ import { join as join4, resolve as resolve2 } from "path";
787
127
 
788
128
  // src/audio/analysis/targets.ts
789
- import { dirname, join as join4, resolve } from "path";
790
- var round4 = (t) => Math.round(t * 1e3) / 1e3;
129
+ import { dirname, join, resolve } from "path";
130
+ var round = (t) => Math.round(t * 1e3) / 1e3;
791
131
  function placementOf(row) {
792
132
  return {
793
133
  start: row.absStart,
@@ -799,12 +139,12 @@ function placementOf(row) {
799
139
  };
800
140
  }
801
141
  function filmTime(placement, fileTime2) {
802
- return round4(placement.start + (fileTime2 - placement.mediaStart) / placement.playbackRate);
142
+ return round(placement.start + (fileTime2 - placement.mediaStart) / placement.playbackRate);
803
143
  }
804
144
  function fileTime(placement, filmTime2) {
805
- return round4(placement.mediaStart + (filmTime2 - placement.start) * placement.playbackRate);
145
+ return round(placement.mediaStart + (filmTime2 - placement.start) * placement.playbackRate);
806
146
  }
807
- var soundingRows = (timeline) => timeline.tracks.filter((track2) => track2.kind === "audio" || track2.kind === "video").flatMap((track2) => track2.rows).filter((row) => row.src && row.volume !== 0 && /^(audio|video)$/.test(row.kind)).sort((a, b) => a.absStart - b.absStart);
147
+ var soundingRows = (timeline) => timeline.tracks.filter((track) => track.kind === "audio" || track.kind === "video").flatMap((track) => track.rows).filter((row) => row.src && row.volume !== 0 && /^(audio|video)$/.test(row.kind)).sort((a, b) => a.absStart - b.absStart);
808
148
  function matches(row, query) {
809
149
  switch (query.by) {
810
150
  case "all":
@@ -821,25 +161,25 @@ function targetOf(projectDir, row, query) {
821
161
  const from = query.by === "range" ? Math.max(placement.start, query.start) : placement.start;
822
162
  const to = query.by === "range" ? Math.min(placement.end, query.end) : placement.end;
823
163
  return {
824
- path: resolveAuthoredAssetFile(projectDir, row.file, row.src) ?? resolve(dirname(join4(projectDir, row.file)), row.src),
164
+ path: resolveAuthoredAssetFile(projectDir, row.file, row.src) ?? resolve(dirname(join(projectDir, row.file)), row.src),
825
165
  file: row.src,
826
166
  ref: row.ref || null,
827
167
  kind: row.kind,
828
168
  placement,
829
169
  window: {
830
170
  from: fileTime(placement, from),
831
- seconds: round4((to - from) * placement.playbackRate)
171
+ seconds: round((to - from) * placement.playbackRate)
832
172
  },
833
173
  clip: {
834
174
  from: placement.mediaStart,
835
- seconds: round4((placement.end - placement.start) * placement.playbackRate)
175
+ seconds: round((placement.end - placement.start) * placement.playbackRate)
836
176
  }
837
177
  };
838
178
  }
839
179
  function filmTargets(projectDir, timeline, query) {
840
180
  if (query.by === "element") {
841
181
  const id = query.ref.startsWith("#") ? query.ref.slice(1) : null;
842
- const found = timeline.tracks.flatMap((track2) => track2.rows).filter((row2) => row2.ref === query.ref || id !== null && row2.id === id);
182
+ const found = timeline.tracks.flatMap((track) => track.rows).filter((row2) => row2.ref === query.ref || id !== null && row2.id === id);
843
183
  if (found.length !== 1)
844
184
  throw new Error(
845
185
  `${query.ref} ${found.length ? `matches ${found.length} clips` : "was not found"}; use a ref from hyperframes timeline`
@@ -857,8 +197,8 @@ var BARS = "\u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588";
857
197
  var SPARK_WIDTH = 48;
858
198
  var ONSETS_SHOWN = 12;
859
199
  var s = (t) => t.toFixed(3);
860
- function sparkline(envelope2, width = SPARK_WIDTH) {
861
- const { values } = envelope2;
200
+ function sparkline(envelope, width = SPARK_WIDTH) {
201
+ const { values } = envelope;
862
202
  if (values.length === 0) return "";
863
203
  const per = Math.max(1, Math.ceil(values.length / width));
864
204
  const slices = [];
@@ -885,8 +225,8 @@ function loudnessLine(loudness2, at) {
885
225
  const clip = count && firstAt !== null ? `, clips ${count}\xD7 from ${at(firstAt)}` : "";
886
226
  return ` loudness ${lufs2}, true peak ${loudness2.truePeakDb} dBTP${clip}`;
887
227
  }
888
- function silenceLine(silence2, at) {
889
- return silence2.length ? ` silent ${silence2.map((g) => `${at(g.start)}\u2013${at(g.end)}`).join(" ")}` : null;
228
+ function silenceLine(silence, at) {
229
+ return silence.length ? ` silent ${silence.map((g) => `${at(g.start)}\u2013${at(g.end)}`).join(" ")}` : null;
890
230
  }
891
231
  function snapNote(snap) {
892
232
  if (!snap) return "";
@@ -927,7 +267,7 @@ var LINES = [
927
267
  ["onsets", hitsLine],
928
268
  ["loudness", loudnessLine],
929
269
  ["silence", silenceLine],
930
- ["envelope", (envelope2) => ` ${sparkline(envelope2)}`],
270
+ ["envelope", (envelope) => ` ${sparkline(envelope)}`],
931
271
  ["describe", describeLine],
932
272
  ["bpm", tempoLine],
933
273
  ["beats", beatsLine],
@@ -957,365 +297,17 @@ function formatReport(report) {
957
297
  return report.items.map((item) => formatItem(item).join("\n")).join("\n\n");
958
298
  }
959
299
 
960
- // src/audio/analysis/run.ts
961
- import { existsSync as existsSync3 } from "fs";
962
-
963
- // src/audio/analysis/kindCache.ts
964
- import { createHash as createHash2, randomUUID as randomUUID2 } from "crypto";
965
- import { mkdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
966
- import { dirname as dirname2, join as join5 } from "path";
967
- var CACHE_VERSION = 1;
968
- var record = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
969
- var finite = (value) => typeof value === "number" && Number.isFinite(value);
970
- var probability = (value) => finite(value) && value >= 0 && value <= 1;
971
- function isKindFeatures(value) {
972
- return record(value) && finite(value.duration) && value.duration >= 0 && [value.regularity, value.syllables, value.sustain].every(probability) && (value.voiced === void 0 || probability(value.voiced));
973
- }
974
- function isKindGuess(value) {
975
- return record(value) && typeof value.value === "string" && ["sfx", "music", "voice", "mixed"].includes(value.value) && probability(value.confidence) && isKindFeatures(value.features);
976
- }
977
- function kindSourceIdentity(path) {
978
- const { size, mtimeMs, ctimeMs, ino } = statSync(path);
979
- return JSON.stringify({ size, mtimeMs, ctimeMs, ino });
980
- }
981
- function kindCacheFile(dir, target, request, sampleRate, source = kindSourceIdentity(target.path)) {
982
- const key = JSON.stringify({
983
- version: CACHE_VERSION,
984
- path: target.path,
985
- source,
986
- clip: target.clip,
987
- sampleRate,
988
- quality: request.quality,
989
- provider: request.provider?.kind,
990
- options: request.options?.kind
991
- });
992
- return join5(dir, `${createHash2("sha256").update(key).digest("hex")}.json`);
993
- }
994
- function readKindCache(file) {
995
- if (file === null) return null;
996
- let value;
997
- try {
998
- value = JSON.parse(readFileSync(file, "utf8"));
999
- } catch {
1000
- return null;
1001
- }
1002
- if (!isKindGuess(value)) return null;
1003
- return {
1004
- analyzed: value.features.duration,
1005
- values: { kind: value },
1006
- provenance: { kind: "signal" },
1007
- ladder: { kind: [{ provider: "signal", outcome: "answered" }] },
1008
- warnings: []
1009
- };
1010
- }
1011
- function writeKindCache(file, value) {
1012
- const temporary = `${file}.${randomUUID2()}.tmp`;
1013
- try {
1014
- mkdirSync(dirname2(file), { recursive: true });
1015
- writeFileSync(temporary, JSON.stringify(value));
1016
- renameSync(temporary, file);
1017
- return null;
1018
- } catch {
1019
- return "kind could not be cached; another query will analyze the clip again";
1020
- } finally {
1021
- try {
1022
- rmSync(temporary, { force: true });
1023
- } catch {
1024
- }
1025
- }
1026
- }
1027
- function cacheKindAnalysis(file, analysis) {
1028
- if (analysis.provenance.kind !== "signal" || analysis.warnings.length || !isKindGuess(analysis.values.kind))
1029
- return;
1030
- const warning = writeKindCache(file, analysis.values.kind);
1031
- if (warning) analysis.warnings.push(warning);
1032
- }
1033
-
1034
- // src/audio/analysis/run.ts
1035
- var round5 = (t) => Math.round(t * 1e3) / 1e3;
1036
- var EDGE_CONTEXT_SECONDS = 0.1;
1037
- var KIND_SAMPLE_RATE = 16e3;
1038
- var KIND_DECODE_BYTES = 256 * 1024 * 1024;
1039
- var RHYTHM_SAMPLE_RATE = 22050;
1040
- var RHYTHM = ["beats", "downbeats", "bpm", "sections"];
1041
- async function previewTarget(path, file, at, mediaStart = 0) {
1042
- if (at === null) return { path, file, ref: null, kind: "file", placement: null };
1043
- const stream = existsSync3(path) ? await probeAudio(path) : null;
1044
- if (stream && mediaStart >= stream.duration)
1045
- throw new Error(
1046
- `skipping ${mediaStart} s leaves nothing of ${file}, which is ${round5(stream.duration)} s long`
1047
- );
1048
- const length = stream ? stream.duration - mediaStart : 0;
1049
- return {
1050
- path,
1051
- file,
1052
- ref: null,
1053
- kind: "file",
1054
- placement: {
1055
- start: at,
1056
- end: round5(at + length),
1057
- dataStart: at,
1058
- mediaStart,
1059
- playbackRate: 1,
1060
- volume: 1
1061
- },
1062
- window: { from: mediaStart, seconds: length }
1063
- };
1064
- }
1065
- var emptyItem = (target) => ({
1066
- file: target.file,
1067
- ref: target.ref,
1068
- element: target.kind === "file" ? null : target.kind,
1069
- placement: target.placement,
1070
- timebase: "file",
1071
- window: null,
1072
- duration: null,
1073
- sampleRate: null,
1074
- channels: null,
1075
- provenance: {},
1076
- warnings: []
1077
- });
1078
- function unreadable(target) {
1079
- if (/^[a-z][a-z\d+.-]*:\/\//i.test(target.file)) return "remote sources are not analyzed";
1080
- if (!existsSync3(target.path)) return "file not found";
1081
- return null;
1082
- }
1083
- function decodeSpan(target, stream) {
1084
- const from = target.window?.from ?? 0;
1085
- const seconds = target.window?.seconds ?? stream.duration - from;
1086
- const before = Math.min(from, EDGE_CONTEXT_SECONDS);
1087
- const after = Math.max(0, Math.min(EDGE_CONTEXT_SECONDS, stream.duration - from - seconds));
1088
- return {
1089
- from,
1090
- read: { from: from - before, seconds: seconds + before + after },
1091
- context: { before, after }
1092
- };
1093
- }
1094
- var loudest = (signal) => envelope(signal, { hopMs: 10, scale: "linear" }).values.reduce(
1095
- (max, value) => Math.max(max, value),
1096
- 0
1097
- );
1098
- function retained(signal, before, after) {
1099
- const skip = Math.round(before * signal.sampleRate);
1100
- const length = signal.channels[0]?.length ?? 0;
1101
- const end = Math.max(skip, length - Math.round(after * signal.sampleRate));
1102
- if (!skip && end >= length) return signal;
1103
- return { ...signal, channels: signal.channels.map((channel) => channel.subarray(skip, end)) };
1104
- }
1105
- async function skippedPeak(target, kept, stream) {
1106
- const skipped = target.kind === "file" ? target.window?.from ?? 0 : 0;
1107
- if (skipped <= 0) return [];
1108
- const head = await decodeAudio(target.path, { from: 0, seconds: skipped }, stream);
1109
- if (!head || loudest(head.signal) <= loudest(kept)) return [];
1110
- return [
1111
- `the loudest part of ${target.file} is in the first ${round5(skipped)} s, which is skipped`
1112
- ];
1113
- }
1114
- function coversPart({ window, clip }) {
1115
- return !!window && !!clip && (window.from > clip.from || window.from + window.seconds < clip.from + clip.seconds);
1116
- }
1117
- function clipKindRate(target, stream) {
1118
- const seconds = Math.min(target.clip.seconds, Math.max(0, stream.duration - target.clip.from));
1119
- const bytes = seconds * stream.sampleRate * stream.channels * 4;
1120
- return bytes <= KIND_DECODE_BYTES ? stream.sampleRate : Math.min(stream.sampleRate, KIND_SAMPLE_RATE);
1121
- }
1122
- async function clipKindSignal(target, stream, sampleRate, windowSignal, purpose = "kind") {
1123
- if (windowSignal) return windowSignal;
1124
- const seconds = Math.min(target.clip.seconds, Math.max(0, stream.duration - target.clip.from));
1125
- if (seconds * sampleRate * stream.channels * 4 > KIND_DECODE_BYTES)
1126
- throw new Error(`whole clip exceeds the ${purpose} analysis decode limit`);
1127
- return (await decodeAudio(target.path, target.clip, stream, { sampleRate }))?.signal;
1128
- }
1129
- async function clipKind(target, request, stream, cache, windowSignal) {
1130
- const sampleRate = windowSignal ? stream.sampleRate : clipKindRate(target, stream);
1131
- const file = cache ? kindCacheFile(cache.dir, target, request, sampleRate, cache.identity) : null;
1132
- const cached = readKindCache(file);
1133
- if (cached) return cached;
1134
- const signal = await clipKindSignal(target, stream, sampleRate, windowSignal);
1135
- if (!signal) return null;
1136
- const analysis = await analyzeSignal(signal, {
1137
- ...request,
1138
- capabilities: ["kind"],
1139
- fileOffset: target.clip.from,
1140
- context: windowSignal ? request.context : void 0
1141
- });
1142
- if (file && cache && file === kindCacheFile(cache.dir, target, request, sampleRate))
1143
- cacheKindAnalysis(file, analysis);
1144
- return analysis;
1145
- }
1146
- async function wholeClipKind(target, signal, request, stream, cache) {
1147
- try {
1148
- const kind = await clipKind(
1149
- target,
1150
- request,
1151
- stream,
1152
- cache,
1153
- coversPart(target) ? void 0 : signal
1154
- );
1155
- if (!kind) throw new Error("no audio stream");
1156
- return kind;
1157
- } catch (error) {
1158
- const kind = await analyzeSignal(signal, { ...request, capabilities: ["kind"] });
1159
- kind.warnings.push(
1160
- `kind uses only the selected range: could not analyze the whole clip (${firstLine2(error)})`
1161
- );
1162
- return kind;
1163
- }
1164
- }
1165
- var firstLine2 = (error) => error instanceof Error ? error.message.split("\n")[0] : String(error);
1166
- var between = (from, to) => (t) => t >= from && t < to;
1167
- function beatsBetween(value, from, to) {
1168
- const keep = value.times.map(between(from, to));
1169
- return {
1170
- ...value,
1171
- times: value.times.filter((_, i) => keep[i]),
1172
- unheard: value.unheard.filter((_, i) => keep[i])
1173
- };
1174
- }
1175
- var PULSE_BEATS = 2;
1176
- var heardTimes = (beats) => beats.times.filter((_, i) => !beats.unheard[i]);
1177
- var CUTS = {
1178
- beats: (_value, { beats, pulse }) => pulse ? beats : { times: [], unheard: [], confidence: 0, reason: "no steady beat" },
1179
- downbeats: (value, { from, to, pulse }) => pulse ? beatsBetween(value, from, to) : { times: [], unheard: [], meter: null, confidence: "low" },
1180
- bpm: (value, { from, to, beats, pulse }) => pulse && beats ? {
1181
- value: tempoOf(heardTimes(beats)).value,
1182
- curve: value.curve.filter((point) => between(from, to)(point.t))
1183
- } : { value: null, curve: [] },
1184
- sections: (value, { from, to }) => {
1185
- const sections = value;
1186
- return { ...sections, spans: sections.spans.filter((s3) => s3.end > from && s3.start < to) };
1187
- }
1188
- };
1189
- var beatsIn = (values, from, to) => values.beats ? beatsBetween(values.beats, from, to) : null;
1190
- var pulseIn = (beats) => !!beats && heardTimes(beats).length >= Math.max(PULSE_BEATS, beats.times.length / 2);
1191
- function rhythmBetween(values, asked, from, to) {
1192
- const beats = beatsIn(values, from, to);
1193
- const window = { from, to, beats, pulse: pulseIn(beats) };
1194
- return Object.fromEntries(
1195
- asked.map((capability) => {
1196
- const value = values[capability];
1197
- return [capability, value == null ? value : CUTS[capability]?.(value, window) ?? value];
1198
- })
1199
- );
1200
- }
1201
- async function wholeClipRhythm(target, signal, request, stream) {
1202
- const asked = request.capabilities.filter((capability) => RHYTHM.includes(capability));
1203
- try {
1204
- const rate = Math.min(stream.sampleRate, RHYTHM_SAMPLE_RATE);
1205
- const clip = await clipKindSignal(target, stream, rate, void 0, "rhythm");
1206
- if (!clip) throw new Error("no audio stream");
1207
- const needsBeats = asked.some((c) => c === "bpm" || c === "downbeats");
1208
- const measure = needsBeats && !asked.includes("beats") ? [...asked, "beats"] : asked;
1209
- const whole = await analyzeSignal(clip, {
1210
- ...request,
1211
- capabilities: measure,
1212
- fileOffset: target.clip.from,
1213
- context: void 0
1214
- });
1215
- const from = request.fileOffset ?? 0;
1216
- const to = from + target.window.seconds;
1217
- const cut = rhythmBetween(whole.values, asked, from, to);
1218
- const beatAnswers = asked.filter((capability) => capability !== "sections");
1219
- if (!beatAnswers.length || pulseIn(beatsIn(whole.values, from, to)))
1220
- return { ...whole, values: cut };
1221
- const own = await analyzeSignal(signal, { ...request, capabilities: beatAnswers });
1222
- return {
1223
- ...own,
1224
- values: { ...cut, ...own.values },
1225
- provenance: { ...whole.provenance, ...own.provenance },
1226
- ladder: { ...whole.ladder, ...own.ladder },
1227
- warnings: [.../* @__PURE__ */ new Set([...whole.warnings, ...own.warnings])]
1228
- };
1229
- } catch (error) {
1230
- const rhythm2 = await analyzeSignal(signal, { ...request, capabilities: asked });
1231
- rhythm2.warnings.push(
1232
- `beats, bars and sections use only the selected range: could not analyze the whole clip (${firstLine2(error)})`
1233
- );
1234
- return rhythm2;
1235
- }
1236
- }
1237
- async function analyzeWindow(target, signal, request, stream, cache) {
1238
- const kindApart = request.capabilities.includes("kind") && target.clip !== void 0;
1239
- const rhythmApart = coversPart(target) && request.capabilities.some((capability) => RHYTHM.includes(capability));
1240
- if (!kindApart && !rhythmApart) return analyzeSignal(signal, request);
1241
- const apart = (capability) => kindApart && capability === "kind" || rhythmApart && RHYTHM.includes(capability);
1242
- const parts = [
1243
- await analyzeSignal(signal, {
1244
- ...request,
1245
- capabilities: request.capabilities.filter((capability) => !apart(capability))
1246
- }),
1247
- ...kindApart ? [await wholeClipKind(target, signal, request, stream, cache)] : [],
1248
- ...rhythmApart ? [await wholeClipRhythm(target, signal, request, stream)] : []
1249
- ];
1250
- const [window] = parts;
1251
- return {
1252
- ...window,
1253
- values: Object.assign({}, ...parts.map((part) => part.values)),
1254
- provenance: Object.assign({}, ...parts.map((part) => part.provenance)),
1255
- ladder: Object.assign({}, ...parts.map((part) => part.ladder)),
1256
- warnings: [...new Set(parts.flatMap((part) => part.warnings))]
1257
- };
1258
- }
1259
- async function analyzeTarget(target, request, full, cacheDir) {
1260
- const item = emptyItem(target);
1261
- const problem = unreadable(target);
1262
- if (problem) return { ...item, error: problem };
1263
- const stream = await probeAudio(target.path);
1264
- if (!stream) return { ...item, error: "no audio stream" };
1265
- const cache = cacheDir ? { dir: cacheDir, identity: kindSourceIdentity(target.path) } : void 0;
1266
- const { from, read: read2, context } = decodeSpan(target, stream);
1267
- const decoded = await decodeAudio(target.path, read2, stream);
1268
- if (!decoded) return { ...item, error: "no audio stream" };
1269
- const analysis = await analyzeWindow(
1270
- target,
1271
- decoded.signal,
1272
- { ...request, fileOffset: from, context },
1273
- stream,
1274
- cache
1275
- );
1276
- return {
1277
- ...item,
1278
- window: { from: round5(from), to: round5(from + analysis.analyzed) },
1279
- duration: round5(stream.duration),
1280
- sampleRate: stream.sampleRate,
1281
- channels: stream.channels,
1282
- ...analysis.values,
1283
- provenance: analysis.provenance,
1284
- ...full ? { ladder: analysis.ladder } : {},
1285
- warnings: [
1286
- ...analysis.warnings,
1287
- ...await skippedPeak(
1288
- target,
1289
- retained(decoded.signal, context.before, context.after),
1290
- stream
1291
- )
1292
- ]
1293
- };
1294
- }
1295
- async function analyzeTargets(targets, request, full = false, cacheDir) {
1296
- const items = [];
1297
- for (const target of targets) {
1298
- try {
1299
- items.push(await analyzeTarget(target, request, full, cacheDir));
1300
- } catch (error) {
1301
- const reason = error instanceof Error ? error.message.split("\n")[0] : String(error);
1302
- items.push({ ...emptyItem(target), error: `could not read: ${reason}` });
1303
- }
1304
- }
1305
- return { version: 1, items };
1306
- }
1307
-
1308
300
  // src/audio/read/pitch.ts
1309
- function within2(track2, start, end) {
301
+ function within(track, start, end) {
1310
302
  let lo = 0;
1311
- let hi = track2.length;
303
+ let hi = track.length;
1312
304
  while (lo < hi) {
1313
305
  const mid = lo + hi >> 1;
1314
- if (track2[mid].t < start) lo = mid + 1;
306
+ if (track[mid].t < start) lo = mid + 1;
1315
307
  else hi = mid;
1316
308
  }
1317
309
  const out = [];
1318
- for (let i = lo; i < track2.length && track2[i].t < end; i++) out.push(track2[i].hz);
310
+ for (let i = lo; i < track.length && track[i].t < end; i++) out.push(track[i].hz);
1319
311
  return out;
1320
312
  }
1321
313
  var semitones = (a, b) => 12 * Math.log2(a / b);
@@ -1480,16 +472,16 @@ function formatRead(analysis, range) {
1480
472
  }
1481
473
 
1482
474
  // src/audio/read/read.ts
1483
- import { createHash as createHash3 } from "crypto";
475
+ import { createHash } from "crypto";
1484
476
  import {
1485
477
  createReadStream,
1486
- existsSync as existsSync5,
1487
- mkdirSync as mkdirSync3,
1488
- readFileSync as readFileSync3,
1489
- renameSync as renameSync2,
1490
- writeFileSync as writeFileSync3
478
+ existsSync as existsSync2,
479
+ mkdirSync as mkdirSync2,
480
+ readFileSync as readFileSync2,
481
+ renameSync,
482
+ writeFileSync as writeFileSync2
1491
483
  } from "fs";
1492
- import { basename, extname, join as join7 } from "path";
484
+ import { basename, extname, join as join3 } from "path";
1493
485
 
1494
486
  // src/audio/read/signal.ts
1495
487
  var READ_RATE = 22050;
@@ -1510,7 +502,7 @@ var asSignal = (samples, sampleRate = READ_RATE) => ({
1510
502
  function mixed(tracks) {
1511
503
  const length = Math.max(0, ...tracks.map((t) => t.length));
1512
504
  const sum = new Float32Array(length);
1513
- for (const track2 of tracks) for (let i = 0; i < track2.length; i++) sum[i] += track2[i];
505
+ for (const track of tracks) for (let i = 0; i < track.length; i++) sum[i] += track[i];
1514
506
  return sum;
1515
507
  }
1516
508
  function levels(samples, sampleRate, hop, window = hop * 2) {
@@ -1545,7 +537,7 @@ function quantile(values, q) {
1545
537
  return sorted[Math.min(sorted.length - 1, Math.max(0, Math.floor(q * (sorted.length - 1))))];
1546
538
  }
1547
539
  var median = (values) => quantile(values, 0.5);
1548
- var round6 = (n, places = 2) => {
540
+ var round2 = (n, places = 2) => {
1549
541
  const k = 10 ** places;
1550
542
  return Math.round(n * k) / k;
1551
543
  };
@@ -1593,16 +585,16 @@ function floors(db) {
1593
585
  return out;
1594
586
  }
1595
587
  var BLOCK = 1e-3;
1596
- function refined(samples, sampleRate, frame2, floorDb) {
588
+ function refined(samples, sampleRate, frame, floorDb) {
1597
589
  const block = Math.max(1, Math.round(BLOCK * sampleRate));
1598
- const from = Math.max(0, Math.round((frame2 - 2) * HOP * sampleRate));
1599
- const to = Math.min(samples.length, Math.round((frame2 + 2) * HOP * sampleRate));
590
+ const from = Math.max(0, Math.round((frame - 2) * HOP * sampleRate));
591
+ const to = Math.min(samples.length, Math.round((frame + 2) * HOP * sampleRate));
1600
592
  for (let a = from; a + block <= to; a += block) {
1601
593
  let power = 0;
1602
594
  for (let i = a; i < a + block; i++) power += samples[i] ** 2;
1603
595
  if (10 * Math.log10(power / block + 1e-12) >= floorDb + RISE_DB / 2) return a / sampleRate;
1604
596
  }
1605
- return frame2 * HOP;
597
+ return frame * HOP;
1606
598
  }
1607
599
  function onsetOf(db, f, base2, from) {
1608
600
  let onset = f;
@@ -1785,7 +777,7 @@ function foundIn({ samples: source, heldBy = [] }, input, mixDb) {
1785
777
  return { ...f, ...kindOf(f, power), print: printOf(power) };
1786
778
  });
1787
779
  }
1788
- function measured2(input, mixDb) {
780
+ function measured(input, mixDb) {
1789
781
  const all = input.sources.flatMap((source) => foundIn(source, input, mixDb)).sort((a, b) => a.t - b.t);
1790
782
  const out = [];
1791
783
  for (const sound of all) {
@@ -1835,20 +827,20 @@ function drumGroups(members, beats) {
1835
827
  }
1836
828
  function effectOf(m, group, kind, levels2) {
1837
829
  return {
1838
- t: round6(m.t),
1839
- end: round6(m.end),
830
+ t: round2(m.t),
831
+ end: round2(m.end),
1840
832
  kind,
1841
833
  group,
1842
834
  band: m.band,
1843
835
  attackMs: Math.round((m.peak - m.t) * 1e3),
1844
- tail: round6(m.end - m.peak),
836
+ tail: round2(m.end - m.peak),
1845
837
  ...levels2,
1846
838
  count: 1
1847
839
  };
1848
840
  }
1849
841
  function findEffects(input) {
1850
842
  const mixDb = levels(input.mix, input.sampleRate, HOP);
1851
- const sounds = measured2(input, mixDb);
843
+ const sounds = measured(input, mixDb);
1852
844
  const members = /* @__PURE__ */ new Map();
1853
845
  for (const m of sounds) members.set(m.group, [...members.get(m.group) ?? [], m]);
1854
846
  const drums = drumGroups(members, input.beats);
@@ -1866,7 +858,7 @@ function findEffects(input) {
1866
858
  const group = names.get(m.group);
1867
859
  const previous = events[events.length - 1];
1868
860
  if (previous?.group === group && m.t - previous.end <= TRAIN_GAP) {
1869
- previous.end = round6(m.end);
861
+ previous.end = round2(m.end);
1870
862
  previous.count++;
1871
863
  } else
1872
864
  events.push(effectOf(m, group, kindOfGroup.get(group) ?? m.kind, levelsOf(input, mixDb, m)));
@@ -1955,10 +947,10 @@ function runs(db) {
1955
947
  const merged = candidates(quiet, 0, db.length).flatMap(
1956
948
  (span) => span.quiet && !holdsUp(db, span) ? silencesIn(db, span) : [span]
1957
949
  );
1958
- const settled2 = joined(merged, (s3) => !s3.quiet && s3.end - s3.start < SHORTEST_SEGMENT);
950
+ const settled = joined(merged, (s3) => !s3.quiet && s3.end - s3.start < SHORTEST_SEGMENT);
1959
951
  return {
1960
- segments: settled2.filter((s3) => !s3.quiet),
1961
- breaks: settled2.filter((s3) => s3.quiet && s3.start > 0 && s3.end < db.length * HOP2)
952
+ segments: settled.filter((s3) => !s3.quiet),
953
+ breaks: settled.filter((s3) => s3.quiet && s3.start > 0 && s3.end < db.length * HOP2)
1962
954
  };
1963
955
  }
1964
956
  function soundShare(fine, run) {
@@ -2063,7 +1055,7 @@ function fadeFrom(db, run) {
2063
1055
  const last = db[b - 1] ?? body;
2064
1056
  if (body - last < FADE_DB) return null;
2065
1057
  for (let f = Math.max(a, b - FADE_WINDOW / HOP2); f < b; f++)
2066
- if (db[f] < body - 3) return round6(f * HOP2, 1);
1058
+ if (db[f] < body - 3) return round2(f * HOP2, 1);
2067
1059
  return null;
2068
1060
  }
2069
1061
  var leading = (mix) => Object.entries(mix).filter(([, share]) => share >= LEADING_SHARE).sort((a, b) => b[1] - a[1]).map(([name]) => name);
@@ -2080,7 +1072,7 @@ function newPiece(id, heard) {
2080
1072
  id,
2081
1073
  instruments: leading(heard.mix),
2082
1074
  bpm: heard.bpm,
2083
- firstAt: round6(heard.run.start),
1075
+ firstAt: round2(heard.run.start),
2084
1076
  print: heard.print,
2085
1077
  mix: heard.mix
2086
1078
  };
@@ -2101,7 +1093,7 @@ function energyCurve(melodic, sampleRate, duration, musical) {
2101
1093
  ) / (end - start);
2102
1094
  energy.push({
2103
1095
  start,
2104
- end: Math.min(round6(end), round6(duration, 3)),
1096
+ end: Math.min(round2(end), round2(duration, 3)),
2105
1097
  db: power > 0 ? Math.round(10 * Math.log10(power)) : -120
2106
1098
  });
2107
1099
  }
@@ -2135,8 +1127,8 @@ function readMusic(input) {
2135
1127
  };
2136
1128
  if (!isMusic(heard)) {
2137
1129
  ambience.push({
2138
- start: round6(run.start),
2139
- end: Math.min(round6(run.end), round6(duration, 3)),
1130
+ start: round2(run.start),
1131
+ end: Math.min(round2(run.end), round2(duration, 3)),
2140
1132
  db: Math.round(10 * Math.log10(Math.max(1e-12, energyOf(melodic, input.sampleRate, run))))
2141
1133
  });
2142
1134
  continue;
@@ -2152,8 +1144,8 @@ function readMusic(input) {
2152
1144
  entry = previous ? "new" : "start";
2153
1145
  }
2154
1146
  segments.push({
2155
- start: round6(run.start),
2156
- end: Math.min(round6(run.end), round6(duration, 3)),
1147
+ start: round2(run.start),
1148
+ end: Math.min(round2(run.end), round2(duration, 3)),
2157
1149
  piece: piece.id,
2158
1150
  entry,
2159
1151
  bpm: heard.bpm,
@@ -2164,7 +1156,7 @@ function readMusic(input) {
2164
1156
  music: {
2165
1157
  segments,
2166
1158
  pieces: pieces.map(({ print: _print, mix: _mix, ...piece }) => piece),
2167
- breaks: breaks.filter((b) => liesBetweenMusic(found, b, musical)).map((b) => ({ start: round6(b.start), end: round6(b.end) })),
1159
+ breaks: breaks.filter((b) => liesBetweenMusic(found, b, musical)).map((b) => ({ start: round2(b.start), end: round2(b.end) })),
2168
1160
  energy: energyCurve(melodic, input.sampleRate, duration, musical)
2169
1161
  },
2170
1162
  ambience,
@@ -2173,33 +1165,33 @@ function readMusic(input) {
2173
1165
  }
2174
1166
 
2175
1167
  // src/audio/read/stems.ts
2176
- import { randomUUID as randomUUID3 } from "crypto";
2177
- import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync2, statSync as statSync2, writeFileSync as writeFileSync2 } from "fs";
2178
- import { mkdtemp as mkdtemp2, rm as rm2 } from "fs/promises";
2179
- import { tmpdir as tmpdir2 } from "os";
2180
- import { join as join6 } from "path";
1168
+ import { randomUUID } from "crypto";
1169
+ import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "fs";
1170
+ import { mkdtemp, rm } from "fs/promises";
1171
+ import { tmpdir } from "os";
1172
+ import { join as join2 } from "path";
2181
1173
  import { setTimeout as sleep } from "timers/promises";
2182
- var URL_ENV2 = "HYPERFRAMES_AUDIO_STEMS_URL";
2183
- var KEY_ENV2 = "HYPERFRAMES_AUDIO_API_KEY";
2184
- var TIMEOUT_ENV2 = "HYPERFRAMES_AUDIO_STEMS_TIMEOUT_MS";
2185
- var DEFAULT_TIMEOUT_MS2 = 30 * 6e4;
1174
+ var URL_ENV = "HYPERFRAMES_AUDIO_STEMS_URL";
1175
+ var KEY_ENV = "HYPERFRAMES_AUDIO_API_KEY";
1176
+ var TIMEOUT_ENV = "HYPERFRAMES_AUDIO_STEMS_TIMEOUT_MS";
1177
+ var DEFAULT_TIMEOUT_MS = 30 * 6e4;
2186
1178
  var RETRY_MS = 5e3;
2187
1179
  var DONE = "stems.json";
2188
1180
  var STEM_NAMES = ["vocals", "drums", "bass", "guitar", "piano", "other"];
2189
1181
  var VOICE_STEM = "vocals";
2190
1182
  var DRUM_STEM = "drums";
2191
1183
  var stemsAccess = () => serviceAccess(
2192
- { url: URL_ENV2, key: KEY_ENV2, timeout: TIMEOUT_ENV2 },
1184
+ { url: URL_ENV, key: KEY_ENV, timeout: TIMEOUT_ENV },
2193
1185
  "/v3/audio/stems",
2194
- DEFAULT_TIMEOUT_MS2
1186
+ DEFAULT_TIMEOUT_MS
2195
1187
  );
2196
1188
  function cachedStems(dir) {
2197
- const done = join6(dir, DONE);
2198
- if (!existsSync4(done)) return null;
2199
- const names = JSON.parse(readFileSync2(done, "utf8"));
1189
+ const done = join2(dir, DONE);
1190
+ if (!existsSync(done)) return null;
1191
+ const names = JSON.parse(readFileSync(done, "utf8"));
2200
1192
  if (!STEM_NAMES.every((name) => typeof names[name] === "string")) return null;
2201
- const paths = Object.fromEntries(STEM_NAMES.map((name) => [name, join6(dir, names[name])]));
2202
- return Object.values(paths).every((p) => existsSync4(p)) ? paths : null;
1193
+ const paths = Object.fromEntries(STEM_NAMES.map((name) => [name, join2(dir, names[name])]));
1194
+ return Object.values(paths).every((p) => existsSync(p)) ? paths : null;
2203
1195
  }
2204
1196
  var StillRunning = class extends Error {
2205
1197
  };
@@ -2223,7 +1215,7 @@ async function encoded(path, dir, signal) {
2223
1215
  if (!ffmpeg) throw new Error("ffmpeg is required to separate stems; run: npx hyperframes doctor");
2224
1216
  const audio = await probeAudio(path);
2225
1217
  if (!audio) throw new Error("the recording has no audio track ffmpeg can decode");
2226
- const out = join6(dir, "upload.mp3");
1218
+ const out = join2(dir, "upload.mp3");
2227
1219
  await runFile(
2228
1220
  ffmpeg,
2229
1221
  [
@@ -2246,7 +1238,7 @@ async function separated(url, request, signal) {
2246
1238
  }
2247
1239
  async function fetchStems(path, dir, { url, headers, timeoutMs }) {
2248
1240
  const signal = AbortSignal.timeout(timeoutMs);
2249
- const scratch = await mkdtemp2(join6(tmpdir2(), "hf-stems-"));
1241
+ const scratch = await mkdtemp(join2(tmpdir(), "hf-stems-"));
2250
1242
  try {
2251
1243
  const mp3 = await encoded(path, scratch, signal);
2252
1244
  const client = new HyperframesCloudClient({
@@ -2257,10 +1249,10 @@ async function fetchStems(path, dir, { url, headers, timeoutMs }) {
2257
1249
  const asset = await uploadAssetViaDirectUpload({
2258
1250
  client,
2259
1251
  path: mp3,
2260
- size: statSync2(mp3).size,
1252
+ size: statSync(mp3).size,
2261
1253
  filename: "audio.mp3",
2262
1254
  contentType: "audio/mpeg",
2263
- idempotencyKey: randomUUID3(),
1255
+ idempotencyKey: randomUUID(),
2264
1256
  signal
2265
1257
  });
2266
1258
  const current = await separated(
@@ -2270,7 +1262,7 @@ async function fetchStems(path, dir, { url, headers, timeoutMs }) {
2270
1262
  redirect: "error",
2271
1263
  headers: {
2272
1264
  ...headers,
2273
- "idempotency-key": randomUUID3(),
1265
+ "idempotency-key": randomUUID(),
2274
1266
  "content-type": "application/json"
2275
1267
  },
2276
1268
  body: JSON.stringify({ version: 1, audio: { type: "asset_id", asset_id: asset.asset_id } })
@@ -2287,19 +1279,19 @@ async function fetchStems(path, dir, { url, headers, timeoutMs }) {
2287
1279
  throw new Error(
2288
1280
  `the stems service returned an incomplete separation: missing ${missing.join(", ")}`
2289
1281
  );
2290
- mkdirSync2(dir, { recursive: true });
1282
+ mkdirSync(dir, { recursive: true });
2291
1283
  const names = {};
2292
1284
  for (const name of STEM_NAMES) {
2293
1285
  const stem = stems.find((candidate) => candidate.name === name);
2294
1286
  if (!stem) continue;
2295
1287
  const file = `${name}.audio`;
2296
- await downloadToFile(stem.url, join6(dir, file), { signal });
1288
+ await downloadToFile(stem.url, join2(dir, file), { signal });
2297
1289
  names[name] = file;
2298
1290
  }
2299
- writeFileSync2(join6(dir, DONE), JSON.stringify(names));
1291
+ writeFileSync(join2(dir, DONE), JSON.stringify(names));
2300
1292
  return cachedStems(dir);
2301
1293
  } finally {
2302
- await rm2(scratch, { recursive: true, force: true });
1294
+ await rm(scratch, { recursive: true, force: true });
2303
1295
  }
2304
1296
  }
2305
1297
 
@@ -2342,32 +1334,32 @@ function sentenceGroups(words) {
2342
1334
  });
2343
1335
  return groups;
2344
1336
  }
2345
- function ending(track2, start, end) {
1337
+ function ending(track, start, end) {
2346
1338
  const split = start + (end - start) * 0.7;
2347
- const body = within2(track2, start, split);
2348
- const tail = within2(track2, split, end);
1339
+ const body = within(track, start, split);
1340
+ const tail = within(track, split, end);
2349
1341
  if (body.length < MIN_PITCH_FRAMES || tail.length < 2) return null;
2350
1342
  const shift = semitones(median(tail), median(body));
2351
1343
  if (shift >= ENDING_SEMITONES) return "rising";
2352
1344
  if (shift <= -ENDING_SEMITONES) return "falling";
2353
1345
  return "level";
2354
1346
  }
2355
- function pitchOf(track2, start, end) {
2356
- const hz = within2(track2, start, end);
1347
+ function pitchOf(track, start, end) {
1348
+ const hz = within(track, start, end);
2357
1349
  return hz.length >= MIN_PITCH_FRAMES ? Math.round(median(hz)) : null;
2358
1350
  }
2359
- function summary(sentences, pauses, track2) {
1351
+ function summary(sentences, pauses, track) {
2360
1352
  const timed = sentences.filter((s3) => s3.rate !== null);
2361
1353
  const seconds = timed.reduce((n, s3) => n + (s3.end - s3.start), 0);
2362
- const meanRate = seconds ? round6(timed.reduce((n, s3) => n + s3.rate * (s3.end - s3.start), 0) / seconds, 1) : null;
1354
+ const meanRate = seconds ? round2(timed.reduce((n, s3) => n + s3.rate * (s3.end - s3.start), 0) / seconds, 1) : null;
2363
1355
  return {
2364
1356
  sentences,
2365
1357
  pauses,
2366
1358
  meanRate,
2367
- medianPitchHz: track2.length ? Math.round(median(track2.map((p) => p.hz))) : null
1359
+ medianPitchHz: track.length ? Math.round(median(track.map((p) => p.hz))) : null
2368
1360
  };
2369
1361
  }
2370
- function voiceFromWords(words, track2, levelOf) {
1362
+ function voiceFromWords(words, track, levelOf) {
2371
1363
  const ordered = words.filter((w) => w.end > w.start).sort((a, b) => a.start - b.start);
2372
1364
  const unit = rateUnit(ordered);
2373
1365
  const sentences = sentenceGroups(ordered).map((group) => {
@@ -2375,12 +1367,12 @@ function voiceFromWords(words, track2, levelOf) {
2375
1367
  const end = group[group.length - 1].end;
2376
1368
  const count = spoken(group, unit);
2377
1369
  return {
2378
- start: round6(start),
2379
- end: round6(end),
1370
+ start: round2(start),
1371
+ end: round2(end),
2380
1372
  text: joined2(group, unit),
2381
- rate: count && end > start ? round6(count / (end - start), 1) : null,
2382
- pitchHz: pitchOf(track2, start, end),
2383
- ending: ending(track2, start, end),
1373
+ rate: count && end > start ? round2(count / (end - start), 1) : null,
1374
+ pitchHz: pitchOf(track, start, end),
1375
+ ending: ending(track, start, end),
2384
1376
  againstMusic: null
2385
1377
  };
2386
1378
  });
@@ -2388,15 +1380,15 @@ function voiceFromWords(words, track2, levelOf) {
2388
1380
  for (let i = 1; i < ordered.length; i++) {
2389
1381
  const gap = ordered[i].start - ordered[i - 1].end;
2390
1382
  if (gap >= PAUSE_SECONDS) {
2391
- const span = { start: round6(ordered[i - 1].end), end: round6(ordered[i].start) };
1383
+ const span = { start: round2(ordered[i - 1].end), end: round2(ordered[i].start) };
2392
1384
  pauses.push({ ...span, recordingDb: Math.round(levelOf(span)) });
2393
1385
  }
2394
1386
  }
2395
- return { source: "transcript", unit, ...summary(sentences, pauses, track2) };
1387
+ return { source: "transcript", unit, ...summary(sentences, pauses, track) };
2396
1388
  }
2397
1389
  var ACTIVITY_HOP = 0.05;
2398
1390
  var SHORTEST_SPEECH = 0.3;
2399
- function voiceFromActivity(vocals, sampleRate, track2, levelOf) {
1391
+ function voiceFromActivity(vocals, sampleRate, track, levelOf) {
2400
1392
  const db = levels(vocals, sampleRate, ACTIVITY_HOP);
2401
1393
  const threshold = Math.max(-45, quantile(db, 0.9) - 30);
2402
1394
  const spans = [];
@@ -2421,41 +1413,41 @@ function voiceFromActivity(vocals, sampleRate, track2, levelOf) {
2421
1413
  spans.push({ start, end: quietSince ?? end });
2422
1414
  const sentences = spans.map(
2423
1415
  (s3) => ({
2424
- start: round6(s3.start),
2425
- end: round6(s3.end),
1416
+ start: round2(s3.start),
1417
+ end: round2(s3.end),
2426
1418
  text: null,
2427
1419
  rate: null,
2428
- pitchHz: pitchOf(track2, s3.start, s3.end),
2429
- ending: ending(track2, s3.start, s3.end),
1420
+ pitchHz: pitchOf(track, s3.start, s3.end),
1421
+ ending: ending(track, s3.start, s3.end),
2430
1422
  againstMusic: null
2431
1423
  })
2432
1424
  );
2433
1425
  const pauses = spans.slice(1).map((s3, i) => {
2434
- const span = { start: round6(spans[i].end), end: round6(s3.start) };
1426
+ const span = { start: round2(spans[i].end), end: round2(s3.start) };
2435
1427
  return { ...span, recordingDb: Math.round(levelOf(span)) };
2436
1428
  });
2437
- return { source: "activity", unit: "chars", ...summary(sentences, pauses, track2) };
1429
+ return { source: "activity", unit: "chars", ...summary(sentences, pauses, track) };
2438
1430
  }
2439
1431
 
2440
1432
  // src/audio/read/read.ts
2441
1433
  async function sha256(path) {
2442
- const hash = createHash3("sha256");
1434
+ const hash = createHash("sha256");
2443
1435
  for await (const chunk of createReadStream(path)) hash.update(chunk);
2444
1436
  return hash.digest("hex");
2445
1437
  }
2446
1438
  function transcriptFor(path, given) {
2447
1439
  if (given) return given;
2448
1440
  const sidecar = `${path}.transcript.json`;
2449
- return existsSync5(sidecar) ? sidecar : null;
1441
+ return existsSync2(sidecar) ? sidecar : null;
2450
1442
  }
2451
1443
  function wordsOf(transcript) {
2452
1444
  return loadTranscript(transcript).words.map(({ text, start, end }) => ({ text, start, end }));
2453
1445
  }
2454
- var fingerprint = (path) => path ? createHash3("sha256").update(readFileSync3(path)).digest("hex").slice(0, 16) : "none";
1446
+ var fingerprint = (path) => path ? createHash("sha256").update(readFileSync2(path)).digest("hex").slice(0, 16) : "none";
2455
1447
  function writeAtomic(path, content) {
2456
1448
  const temporary = `${path}.${process.pid}.tmp`;
2457
- writeFileSync3(temporary, content);
2458
- renameSync2(temporary, path);
1449
+ writeFileSync2(temporary, content);
1450
+ renameSync(temporary, path);
2459
1451
  }
2460
1452
  async function stemsFor(path, dir, quality, warnings) {
2461
1453
  const cached = cachedStems(dir);
@@ -2466,13 +1458,13 @@ async function stemsFor(path, dir, quality, warnings) {
2466
1458
  );
2467
1459
  return null;
2468
1460
  }
2469
- const access2 = await stemsAccess();
2470
- if (typeof access2 === "string") {
2471
- warnings.push(`not separated into stems: ${access2}`);
1461
+ const access = await stemsAccess();
1462
+ if (typeof access === "string") {
1463
+ warnings.push(`not separated into stems: ${access}`);
2472
1464
  return null;
2473
1465
  }
2474
1466
  try {
2475
- return await fetchStems(path, dir, access2);
1467
+ return await fetchStems(path, dir, access);
2476
1468
  } catch (error) {
2477
1469
  warnings.push(`not separated into stems: ${error instanceof Error ? error.message : error}`);
2478
1470
  return null;
@@ -2554,7 +1546,7 @@ async function analyze(path, file, sha, transcript, stemDir, quality) {
2554
1546
  const words = transcript ? wordsOf(transcript) : [];
2555
1547
  const voicePath = stemPaths?.[VOICE_STEM] ?? path;
2556
1548
  const voiceSamples = await decodeMono(voicePath);
2557
- const about = base(file, sha, round6(voiceSamples.length / READ_RATE, 3), stemPaths, transcript);
1549
+ const about = base(file, sha, round2(voiceSamples.length / READ_RATE, 3), stemPaths, transcript);
2558
1550
  if (!stemPaths && !words.length) {
2559
1551
  warnings.push(
2560
1552
  `no transcript and no stems: voice and effects are not read, because the mix alone does not tell speech from music; ${transcribeHint(file)}`
@@ -2597,12 +1589,12 @@ async function readAudio(path, file, options) {
2597
1589
  const transcript = transcriptFor(path, options.transcript);
2598
1590
  const transcriptKey = fingerprint(transcript);
2599
1591
  const stem = `${basename(file, extname(file)).replace(/[^\w.-]/g, "_")}-${sha.slice(0, 12)}`;
2600
- mkdirSync3(options.cacheDir, { recursive: true });
2601
- const jsonPath = join7(options.cacheDir, `${stem}.json`);
2602
- const textPath = join7(options.cacheDir, `${stem}.txt`);
2603
- const stemDir = join7(options.cacheDir, "stems", sha.slice(0, 12));
2604
- if (existsSync5(jsonPath) && existsSync5(textPath)) {
2605
- const entry = JSON.parse(readFileSync3(jsonPath, "utf8"));
1592
+ mkdirSync2(options.cacheDir, { recursive: true });
1593
+ const jsonPath = join3(options.cacheDir, `${stem}.json`);
1594
+ const textPath = join3(options.cacheDir, `${stem}.txt`);
1595
+ const stemDir = join3(options.cacheDir, "stems", sha.slice(0, 12));
1596
+ if (existsSync2(jsonPath) && existsSync2(textPath)) {
1597
+ const entry = JSON.parse(readFileSync2(jsonPath, "utf8"));
2606
1598
  const stemsNowPossible = entry.analysis.separation === "mix" && quality === "best" && (cachedStems(stemDir) !== null || typeof await stemsAccess() !== "string");
2607
1599
  if ((entry.analysis.separation !== "stems" || cachedStems(stemDir) !== null) && entry.analysis.version === READ_VERSION && entry.transcriptKey === transcriptKey && !stemsNowPossible)
2608
1600
  return { analysis: entry.analysis, textPath, jsonPath, cached: true };
@@ -2743,7 +1735,7 @@ async function read(files, flags) {
2743
1735
  const quality = readQuality(files, flags);
2744
1736
  const range = pair("range", flags.range);
2745
1737
  const result = await readAudio(resolve2(process.cwd(), files[0]), files[0], {
2746
- cacheDir: join8(resolve2(flags.dir ?? process.cwd()), ".hyperframes", "read-audio"),
1738
+ cacheDir: join4(resolve2(flags.dir ?? process.cwd()), ".hyperframes", "read-audio"),
2747
1739
  transcript: flags.transcript ? resolve2(process.cwd(), flags.transcript) : void 0,
2748
1740
  quality
2749
1741
  });
@@ -2833,7 +1825,7 @@ var audio_default = defineCommand({
2833
1825
  targets,
2834
1826
  analyzeRequest(flags),
2835
1827
  Boolean(args.full),
2836
- join8(resolve2(flags.dir ?? process.cwd()), ".hyperframes", "audio-kind")
1828
+ join4(resolve2(flags.dir ?? process.cwd()), ".hyperframes", "audio-kind")
2837
1829
  );
2838
1830
  console.log(args.json ? JSON.stringify(withMeta(report)) : formatReport(report));
2839
1831
  }