hyperframes 0.8.159 → 0.8.161

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 (176) hide show
  1. package/README.md +10 -0
  2. package/dist/{add-7UMRT6IJ.js → add-7U5TQGSQ.js} +11 -11
  3. package/dist/{animatedGifPrep-COFZMEVD.js → animatedGifPrep-YAJTDXB7.js} +6 -6
  4. package/dist/api.js +16 -16
  5. package/dist/{asset-N37XIJTB.js → asset-N3JO5LHY.js} +2 -2
  6. package/dist/{assetCataloger-ZOQ67MGR.js → assetCataloger-BIDQA34M.js} +2 -2
  7. package/dist/audio-QNPSENQR.js +1131 -0
  8. package/dist/{auth-GKFS2PL6.js → auth-HINUM4A7.js} +1 -1
  9. package/dist/{autoUpdate-V4PLREDQ.js → autoUpdate-AAMND4XK.js} +2 -2
  10. package/dist/{backgroundChecks-TVOKARY2.js → backgroundChecks-FXIEHPND.js} +3 -3
  11. package/dist/backgroundChecksWorker.js +3 -3
  12. package/dist/{batchRender-IARQXQHN.js → batchRender-C2JCG5EK.js} +3 -3
  13. package/dist/beats-UZNREIRU.js +239 -0
  14. package/dist/{benchmark-ZJYFRFYF.js → benchmark-YM3QXPH6.js} +8 -8
  15. package/dist/{browser-WRZOH4PD.js → browser-SD3T2XMH.js} +5 -5
  16. package/dist/{bundleWithLocalizedFonts-SFHKZZAX.js → bundleWithLocalizedFonts-SLBVWQ7O.js} +2 -2
  17. package/dist/{capture-LLLIHYEF.js → capture-GUO23PVN.js} +2 -2
  18. package/dist/{capture-KFYPMVTT.js → capture-M5ZAD3BI.js} +10 -10
  19. package/dist/{catalog-QO762U7V.js → catalog-6PF7KZAZ.js} +11 -11
  20. package/dist/{catch-up-MELHNTGB.js → catch-up-5LTQTD3X.js} +4 -4
  21. package/dist/{check-RX3LTKYB.js → check-NE2YXJR2.js} +130 -119
  22. package/dist/{checkBrowser-EUUMEILI.js → checkBrowser-XDTXDEYO.js} +33 -31
  23. package/dist/{chunk-YIJMVFEJ.js → chunk-22QHO26F.js} +1 -1
  24. package/dist/{chunk-7F3B5YYT.js → chunk-2742O5DO.js} +178 -23
  25. package/dist/{chunk-HEEN6X6O.js → chunk-2ZLYSXZC.js} +8 -8
  26. package/dist/{chunk-5RSV6DWB.js → chunk-4ID635FL.js} +1 -1
  27. package/dist/{chunk-ODE7HHNN.js → chunk-5YSHR4XC.js} +11 -9
  28. package/dist/chunk-6JR2XUEE.js +127 -0
  29. package/dist/{chunk-DLQQA25O.js → chunk-7ZKEOQ5N.js} +1 -1
  30. package/dist/{chunk-BB2SFTMY.js → chunk-A2DMF2Q6.js} +6 -5
  31. package/dist/{chunk-K5BMHQOU.js → chunk-AHNJMWMU.js} +14 -14
  32. package/dist/{chunk-IJ7JPX4W.js → chunk-AY2FEJDR.js} +3 -3
  33. package/dist/{chunk-MMYY4KV3.js → chunk-B5FZ2CQM.js} +1 -1
  34. package/dist/{chunk-IWOEAWIP.js → chunk-B7RUGHBT.js} +1 -1
  35. package/dist/{chunk-AFYZWHR7.js → chunk-CGOGEA62.js} +2 -2
  36. package/dist/{chunk-7RTTPSXG.js → chunk-D33YJZOH.js} +1 -1
  37. package/dist/{chunk-54DMWFQZ.js → chunk-D3ZWBHZP.js} +2 -15
  38. package/dist/{chunk-WWMFR4SH.js → chunk-DJZEIVAP.js} +3 -3
  39. package/dist/{chunk-EGJVFPUX.js → chunk-ERTJPFCH.js} +1 -1
  40. package/dist/{chunk-FEKRMXT6.js → chunk-EVRUR7DW.js} +1 -1
  41. package/dist/chunk-FFJ5TDRD.js +1181 -0
  42. package/dist/{chunk-BEW7RCCW.js → chunk-G5AZMSQP.js} +2 -2
  43. package/dist/{chunk-UK4KRTIX.js → chunk-G642IIVK.js} +2 -2
  44. package/dist/{chunk-AEQWF7PE.js → chunk-GG37I7B3.js} +1 -1
  45. package/dist/{chunk-A5RDOXZE.js → chunk-GIPNECWL.js} +17 -129
  46. package/dist/chunk-GJQHHAAX.js +336 -0
  47. package/dist/{chunk-4IKI2RYR.js → chunk-H4VXLZ6O.js} +10 -10
  48. package/dist/{chunk-NCVGBBWC.js → chunk-HM4PLNTX.js} +1 -1
  49. package/dist/{chunk-24N3BB5M.js → chunk-I6CVW5CA.js} +5 -5
  50. package/dist/{chunk-KEGTYA7V.js → chunk-IK3SOMZ4.js} +5 -3
  51. package/dist/{chunk-YITZFHRJ.js → chunk-IL6C7T5X.js} +1 -1
  52. package/dist/{chunk-6PIGOKTE.js → chunk-JGYHWVXQ.js} +339 -67
  53. package/dist/{chunk-HO3SITVT.js → chunk-KZPG4DXX.js} +1 -1
  54. package/dist/{chunk-INNBWSZK.js → chunk-LYIG2GZ5.js} +2 -2
  55. package/dist/{chunk-ESOAYGIT.js → chunk-MMV6IY6U.js} +2 -2
  56. package/dist/{chunk-4DEBDQD4.js → chunk-MP676E4B.js} +2 -2
  57. package/dist/{chunk-3W3MOLRL.js → chunk-N2NDDTYW.js} +2 -2
  58. package/dist/{chunk-GGDCBVXK.js → chunk-OMJA7JP6.js} +5 -5
  59. package/dist/{chunk-4D5RBIX6.js → chunk-ON2HYNGB.js} +10 -10
  60. package/dist/chunk-P47XYVEQ.js +3795 -0
  61. package/dist/{chunk-NIGOOCVS.js → chunk-P4QE7SSN.js} +1 -1
  62. package/dist/{chunk-AQXJC64X.js → chunk-PBNV5V5G.js} +1 -1
  63. package/dist/{chunk-2CEH75X3.js → chunk-PLEMSN3E.js} +2 -2
  64. package/dist/{chunk-DVAEX52Q.js → chunk-PPF65XAF.js} +1 -1
  65. package/dist/{chunk-5GPX4X4L.js → chunk-PYMYGIZ4.js} +2 -2
  66. package/dist/{chunk-7XEVZDKU.js → chunk-PZH7FTRZ.js} +7 -7
  67. package/dist/{chunk-V5J4XEBG.js → chunk-Q3TFX4OZ.js} +1 -1
  68. package/dist/{chunk-XSEGMQYA.js → chunk-QABAVWEX.js} +26 -3
  69. package/dist/{chunk-IKDBT5WT.js → chunk-RGYEL7QD.js} +3 -3
  70. package/dist/{chunk-76NO4ZRM.js → chunk-RTS7BGEC.js} +1 -1
  71. package/dist/{chunk-6TDZJ43G.js → chunk-SAS6XBY5.js} +1 -1
  72. package/dist/{chunk-H6BKVVU4.js → chunk-SB5DX6AD.js} +2 -2
  73. package/dist/{chunk-JZLFHF2M.js → chunk-TXG6W4X4.js} +3 -3
  74. package/dist/{chunk-EWAAH7AU.js → chunk-VYTGK5YA.js} +1 -1
  75. package/dist/{chunk-5HNZQSO4.js → chunk-WDUEIP22.js} +1 -1
  76. package/dist/{chunk-MTUC2Z32.js → chunk-WNXVPPMV.js} +2 -2
  77. package/dist/{chunk-SQHWDFTV.js → chunk-X3SCQP2A.js} +1 -1
  78. package/dist/{chunk-LBT4AMSF.js → chunk-XRKMITSS.js} +1 -1
  79. package/dist/{chunk-5O6I5ZV7.js → chunk-XTLV6UVP.js} +3 -3
  80. package/dist/{chunk-5YCFHCD4.js → chunk-XWWYGXJ5.js} +2 -2
  81. package/dist/{clean-RW7Z4XM6.js → clean-4Y4G3YV3.js} +18 -17
  82. package/dist/cli.js +54 -53
  83. package/dist/{cloud-EEOV7JKB.js → cloud-BWXJB2B7.js} +4 -4
  84. package/dist/{cloudrun-EZAXYVXG.js → cloudrun-BIQXBUDO.js} +3 -3
  85. package/dist/{compare-5UARQFXX.js → compare-OLLJBVNL.js} +25 -24
  86. package/dist/{compiler-THI7BXZU.js → compiler-57M6W5WY.js} +3 -3
  87. package/dist/{component-AYOFPL33.js → component-ULSAC45J.js} +3 -3
  88. package/dist/{compositions-XJNJBOMG.js → compositions-G2JTQBTJ.js} +10 -10
  89. package/dist/{delete-653AOR25.js → delete-BONV4XUI.js} +2 -2
  90. package/dist/{dist-DLR4X3KN.js → dist-4JFB3WAR.js} +2 -2
  91. package/dist/{dist-2VXSQLXO.js → dist-ROVMAL74.js} +1 -1
  92. package/dist/{doctor-WA6VRRE7.js → doctor-EMLC4VZ4.js} +12 -12
  93. package/dist/{events-XXBCP2I4.js → events-LF2J436R.js} +3 -3
  94. package/dist/{events-U5COLUWT.js → events-ZFGAA5UD.js} +2 -2
  95. package/dist/{feedback-DX6Q3LN7.js → feedback-WKCUQE6T.js} +6 -6
  96. package/dist/{ffmpeg-2ROTISBL.js → ffmpeg-7BYARPLM.js} +4 -2
  97. package/dist/{figma-LCQVLBXF.js → figma-VJKG252Z.js} +3 -3
  98. package/dist/fontLocalizeCli.js +8 -8
  99. package/dist/{get-UYNPFMHX.js → get-OINAGI2B.js} +2 -2
  100. package/dist/{gpuPolicy-YIW3HL3B.js → gpuPolicy-VGE3I5J4.js} +6 -6
  101. package/dist/{grade-compare-YQEYATJV.js → grade-compare-DY5VFXPK.js} +27 -26
  102. package/dist/{help-FDURC7WR.js → help-HHB7JRZA.js} +2 -1
  103. package/dist/{history-EU5UZLHT.js → history-D44JJBBC.js} +8 -7
  104. package/dist/hyperframe-runtime.js +55 -55
  105. package/dist/hyperframe.manifest.json +1 -1
  106. package/dist/hyperframe.runtime.iife.js +55 -55
  107. package/dist/hyperframes-player.global.js +3 -3
  108. package/dist/{info-7T6CK6CL.js → info-2WZLISAR.js} +7 -7
  109. package/dist/{init-KQYSKFVU.js → init-UYZS2WXQ.js} +28 -28
  110. package/dist/{inspect-HQBV7VHS.js → inspect-IEFCB4PT.js} +26 -25
  111. package/dist/{installer-OKKPQNKS.js → installer-T3STEB4U.js} +4 -4
  112. package/dist/{keyframes-SK74JHOA.js → keyframes-FS43QHM2.js} +6 -6
  113. package/dist/{lambda-S2N4VTRO.js → lambda-RAJA6ZNA.js} +4 -4
  114. package/dist/{layout-MTE5Y6DE.js → layout-AK2A7Q46.js} +26 -25
  115. package/dist/{lint-FJGGJYB7.js → lint-JRJUSZO7.js} +7 -7
  116. package/dist/{lintProject-JGHKRO5L.js → lintProject-BGDYHF3F.js} +1 -1
  117. package/dist/{list-MBPALK5U.js → list-BKKGPT7E.js} +2 -2
  118. package/dist/{login-HDN4T5E4.js → login-QJZTUDDO.js} +4 -4
  119. package/dist/{manager-JNJE54OQ.js → manager-B6MVBM2E.js} +3 -3
  120. package/dist/{manager-ZLJD3EAY.js → manager-HEUPD2YB.js} +2 -2
  121. package/dist/{media-treatment-IP34DXWN.js → media-treatment-473OM7G7.js} +12 -11
  122. package/dist/{models-W5TASRHD.js → models-OA4MXEYG.js} +12 -12
  123. package/dist/{motionShot-2WYEMOPJ.js → motionShot-C2YDYRNB.js} +16 -16
  124. package/dist/{normalize-audio-F4NQPXII.js → normalize-audio-M3KVTFTQ.js} +4 -4
  125. package/dist/{open-DRXNALDE.js → open-363TDMEP.js} +4 -4
  126. package/dist/{parakeetRunner-VISBF2EA.js → parakeetRunner-DBLHMD5T.js} +13 -13
  127. package/dist/{pipeline-A2XOVZOM.js → pipeline-FSY65OQ4.js} +8 -8
  128. package/dist/{play-W2QELQX7.js → play-2UB33EGB.js} +19 -18
  129. package/dist/{preflight-BH2XUQBS.js → preflight-G5KP7ZKA.js} +4 -4
  130. package/dist/{present-NHYRS4F4.js → present-F3ASSDJX.js} +15 -14
  131. package/dist/{preview-SMJVUPXE.js → preview-EF76WIHK.js} +18 -18
  132. package/dist/{producer-276O3CKW.js → producer-C5V2A3YL.js} +1 -1
  133. package/dist/{projectConfig-FXFUHFPZ.js → projectConfig-X2IEHCSK.js} +6 -6
  134. package/dist/{publication-SSQO6ECV.js → publication-JEANCWBW.js} +2 -2
  135. package/dist/{publish-UHDKDXZI.js → publish-VX5OH4ST.js} +8 -8
  136. package/dist/{remove-background-IG6U56HC.js → remove-background-IXCISD26.js} +9 -9
  137. package/dist/{render-6P5RSFS3.js → render-GL72Z2W2.js} +8 -8
  138. package/dist/{render-ZJPSLTKV.js → render-GUBYSVQD.js} +29 -28
  139. package/dist/{render-XQONIJEJ.js → render-ISUT7Q3X.js} +3 -3
  140. package/dist/{render-batch-MH3Z6IPT.js → render-batch-2C6RUP3F.js} +3 -3
  141. package/dist/renderSetupWorker.js +4 -4
  142. package/dist/{resolver-JMSGO2JF.js → resolver-KTNKZVIB.js} +4 -4
  143. package/dist/{sherpa-64JLV4YM.js → sherpa-GFRG3TMM.js} +12 -12
  144. package/dist/skills/hyperframes-cli/SKILL.md +5 -4
  145. package/dist/skills/hyperframes-cli/references/beats.md +2 -6
  146. package/dist/skills/hyperframes-cli/references/lint-validate-inspect.md +8 -0
  147. package/dist/skills/hyperframes-cli/references/upgrade-info-misc.md +1 -1
  148. package/dist/{skills-UXOL62PY.js → skills-7XI4DHLN.js} +5 -5
  149. package/dist/{skillsUpdateCheck-5Y6676K6.js → skillsUpdateCheck-34WOCMHV.js} +3 -3
  150. package/dist/{snapshot-SQBPCXOV.js → snapshot-SGTO2OQ4.js} +40 -30
  151. package/dist/{src-N42CT3YR.js → src-GPUDUKY6.js} +5 -5
  152. package/dist/{src-RQMK5INS.js → src-IMCQRH4P.js} +7 -7
  153. package/dist/{staticProjectServer-AQXVWMLU.js → staticProjectServer-4CQ3KDQK.js} +15 -14
  154. package/dist/studio/assets/{hyperframes-player-kqB1psAJ.js → hyperframes-player-C8VFb4NS.js} +1 -1
  155. package/dist/studio/assets/{index-X_d1b5vz.js → index-J8Bpbg6o.js} +118 -118
  156. package/dist/studio/assets/{index-BrViH8hj.js → index-RZnZPb-B.js} +1 -1
  157. package/dist/studio/index.html +1 -1
  158. package/dist/{studio-api-GY5D7RAP.js → studio-api-RYCDLEOR.js} +13 -8
  159. package/dist/{studioServer-O3VONODG.js → studioServer-VIIVGFZH.js} +45 -44
  160. package/dist/{telemetry-V2K5P7CI.js → telemetry-YKVYLJSB.js} +3 -3
  161. package/dist/{timeline-YU3YPLKB.js → timeline-LDRA7QZ3.js} +42 -347
  162. package/dist/{tokens-NPSSSG2A.js → tokens-ZAOFRU55.js} +2 -2
  163. package/dist/{transcribe-FNBDG24U.js → transcribe-CJXUHTAS.js} +17 -17
  164. package/dist/{transcribe-BXJNS3RZ.js → transcribe-FL6NGWHF.js} +11 -11
  165. package/dist/{updateCheck-MB3RHSVK.js → updateCheck-TIRFQBSI.js} +2 -2
  166. package/dist/{upgrade-5VNRUR37.js → upgrade-7R5G3MNO.js} +2 -2
  167. package/dist/{urlDownloader-WCT7FMLA.js → urlDownloader-KDJGLR2Y.js} +5 -5
  168. package/dist/{usage-EC3KFUIJ.js → usage-HG4WMM7A.js} +33 -5
  169. package/dist/{validate-UXSXRCE6.js → validate-VGEPWGQO.js} +20 -19
  170. package/dist/{video-NRNQBZMV.js → video-AHO4CDCK.js} +6 -6
  171. package/package.json +2 -3
  172. package/dist/beat-analyzer.global.js +0 -341
  173. package/dist/beats-FY4UDXBL.js +0 -322
  174. package/dist/chunk-TWBTXEDZ.js +0 -3795
  175. package/dist/lib-TPG2ZMAX.js +0 -128
  176. package/dist/studio/assets/index-C3AZLr-0.js +0 -1
@@ -1,322 +0,0 @@
1
- import { createRequire as __hf_createRequire } from "node:module";
2
- import { fileURLToPath as __hf_fileURLToPath } from "node:url";
3
- import { dirname as __hf_dirname } from "node:path";
4
- var require = __hf_createRequire(import.meta.url);
5
- var __filename = __hf_fileURLToPath(import.meta.url);
6
- var __dirname = __hf_dirname(__filename);
7
- import {
8
- launchManagedBrowser
9
- } from "./chunk-MMYY4KV3.js";
10
- import {
11
- resolveProject
12
- } from "./chunk-5HNZQSO4.js";
13
- import "./chunk-K2FLNJVB.js";
14
- import "./chunk-H6BKVVU4.js";
15
- import "./chunk-NCVGBBWC.js";
16
- import "./chunk-HO3SITVT.js";
17
- import "./chunk-VWG7OQKU.js";
18
- import "./chunk-QWQ6GQTI.js";
19
- import {
20
- defineCommand
21
- } from "./chunk-S3S4TGEH.js";
22
- import "./chunk-54HJ63Q2.js";
23
- import {
24
- failCommand
25
- } from "./chunk-PBN6GBJE.js";
26
- import {
27
- c
28
- } from "./chunk-ZTZA4UWZ.js";
29
- import "./chunk-K4WIOZFP.js";
30
- import "./chunk-XUXGIA7H.js";
31
- import "./chunk-WERLJGIC.js";
32
- import "./chunk-ISN5GRYI.js";
33
- import "./chunk-MTUC2Z32.js";
34
- import "./chunk-XT6MXC7A.js";
35
- import "./chunk-2CEH75X3.js";
36
- import "./chunk-INNBWSZK.js";
37
- import "./chunk-KCF6GHJP.js";
38
- import "./chunk-JYVGYKXG.js";
39
- import "./chunk-7KDQAD2W.js";
40
- import "./chunk-V5J4XEBG.js";
41
- import "./chunk-TWBTXEDZ.js";
42
- import "./chunk-VC76R6W2.js";
43
- import "./chunk-UJKQWGFF.js";
44
- import {
45
- decodeAuthoredAttribute,
46
- scanHtmlOpeningTags
47
- } from "./chunk-ALLKNYC3.js";
48
- import "./chunk-OFQWTKPW.js";
49
- import "./chunk-DPVXBVLL.js";
50
- import "./chunk-T76PLPD6.js";
51
- import "./chunk-FXMKHHPO.js";
52
- import "./chunk-RQVDTPGD.js";
53
- import "./chunk-TWWSYAKJ.js";
54
- import "./chunk-7F3B5YYT.js";
55
- import "./chunk-IWFLMU2N.js";
56
- import "./chunk-3VGU2SH7.js";
57
- import "./chunk-VAS6HQX3.js";
58
- import "./chunk-3RM2ETQT.js";
59
- import "./chunk-BSQ7XANM.js";
60
- import "./chunk-SDYDNHEE.js";
61
- import "./chunk-TYXH3EKP.js";
62
- import "./chunk-IXLUTE6N.js";
63
- import "./chunk-KNU5COPB.js";
64
- import "./chunk-KGPLIH7B.js";
65
- import "./chunk-3GXQPCJC.js";
66
- import "./chunk-M2WBOQ2Q.js";
67
-
68
- // src/commands/beats.ts
69
- import { existsSync as existsSync2, readFileSync as readFileSync2, mkdirSync, writeFileSync } from "fs";
70
- import { resolve, join as join2, dirname as dirname2 } from "path";
71
-
72
- // ../core/dist/beats/beatFile.js
73
- function audioRelPathForSrc(src) {
74
- if (!src)
75
- return null;
76
- if (/^(blob:|data:)/i.test(src))
77
- return null;
78
- let rel = null;
79
- const PREVIEW = "/preview/";
80
- const previewIdx = src.indexOf(PREVIEW);
81
- if (previewIdx !== -1) {
82
- let after = src.slice(previewIdx + PREVIEW.length);
83
- const queryOrHash = after.search(/[?#]/);
84
- if (queryOrHash !== -1)
85
- after = after.slice(0, queryOrHash);
86
- if (after.startsWith("comp/"))
87
- after = after.slice("comp/".length);
88
- rel = after ? decodeURIComponent(after) : null;
89
- }
90
- if (!rel) {
91
- try {
92
- rel = decodeURIComponent(new URL(src, "http://_").pathname);
93
- } catch {
94
- rel = src;
95
- }
96
- }
97
- if (!rel)
98
- return null;
99
- rel = rel.replace(/^\/+/, "");
100
- return rel || null;
101
- }
102
- function serializeBeats(times, strengths, audio) {
103
- const beats = times.map((t, i) => ({
104
- time: Math.round(t * 1e3) / 1e3,
105
- strength: Math.round((strengths[i] ?? 0.5) * 1e3) / 1e3
106
- }));
107
- const data = { version: 1, audio, beats };
108
- return `${JSON.stringify(data, null, 2)}
109
- `;
110
- }
111
- var MUSIC_ID_RE = /\b(music|bgm|soundtrack|background[-_]?music)\b/i;
112
- function attr(tag, name) {
113
- const attribute = tag.attributes.find((value) => value.name === name);
114
- return attribute?.kind === "value" ? decodeAuthoredAttribute(attribute.value) : null;
115
- }
116
- function isSoundingVideoTag(tag) {
117
- return attr(tag, "data-has-audio") === "true" && !tag.attributes.some((attribute) => attribute.name === "muted");
118
- }
119
- function isMusicSourceTag(tag) {
120
- return tag.closed && (tag.name === "audio" || tag.name === "video" && isSoundingVideoTag(tag));
121
- }
122
- function findMusicAudioSrc(html) {
123
- for (const tag of scanHtmlOpeningTags(html)) {
124
- if (!isMusicSourceTag(tag))
125
- continue;
126
- const src = attr(tag, "src");
127
- if (!src)
128
- continue;
129
- const role = attr(tag, "data-timeline-role");
130
- if (role) {
131
- if (role === "music")
132
- return src;
133
- continue;
134
- }
135
- const id = attr(tag, "id");
136
- if (id && MUSIC_ID_RE.test(id))
137
- return src;
138
- }
139
- return null;
140
- }
141
-
142
- // src/beats/headlessAnalyzer.ts
143
- import { existsSync, readFileSync } from "fs";
144
- import { createRequire } from "module";
145
- import { dirname, join } from "path";
146
- import { fileURLToPath } from "url";
147
- var require2 = createRequire(import.meta.url);
148
- var bundlePromise = null;
149
- function findPrebuiltBundle() {
150
- const here = dirname(fileURLToPath(import.meta.url));
151
- const candidates = [
152
- join(here, "beat-analyzer.global.js"),
153
- // dist root (tsup-bundled cli)
154
- join(here, "../beat-analyzer.global.js"),
155
- // dist/beats → dist
156
- join(here, "../dist/beat-analyzer.global.js")
157
- ];
158
- for (const p of candidates) {
159
- if (existsSync(p)) return p;
160
- }
161
- return null;
162
- }
163
- async function buildFromCoreSource() {
164
- const esbuild = await import("esbuild");
165
- const coreRoot = dirname(require2.resolve("@hyperframes/core/package.json"));
166
- const entry = join(coreRoot, "src/beats/beatDetection.ts");
167
- const result = await esbuild.build({
168
- stdin: {
169
- contents: `import { analyzeMusicFromBuffer } from ${JSON.stringify(entry)};
170
- globalThis.__hfAnalyze = analyzeMusicFromBuffer;`,
171
- resolveDir: coreRoot,
172
- loader: "ts"
173
- },
174
- bundle: true,
175
- format: "iife",
176
- platform: "browser",
177
- target: "es2020",
178
- write: false
179
- });
180
- const out = result.outputFiles?.[0];
181
- if (!out) throw new Error("Failed to bundle beat analyzer");
182
- return out.text;
183
- }
184
- function buildAnalyzerBundle() {
185
- if (bundlePromise) return bundlePromise;
186
- bundlePromise = (async () => {
187
- const prebuilt = findPrebuiltBundle();
188
- if (prebuilt) return readFileSync(prebuilt, "utf8");
189
- return buildFromCoreSource();
190
- })().catch((err) => {
191
- bundlePromise = null;
192
- throw err;
193
- });
194
- return bundlePromise;
195
- }
196
- var MAX_AUDIO_BYTES = 80 * 1024 * 1024;
197
- function inPageAnalyze(data) {
198
- const bin = atob(data);
199
- const bytes = new Uint8Array(bin.length);
200
- for (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i);
201
- const win = window;
202
- if (typeof win.__hfAnalyze !== "function") throw new Error("beat analyzer not loaded");
203
- const ctx = new (win.AudioContext || win.webkitAudioContext)();
204
- return ctx.decodeAudioData(bytes.buffer).then((buf) => win.__hfAnalyze(buf)).then((r) => ({
205
- beatTimes: r.beatTimes,
206
- beatStrengths: r.beatStrengths,
207
- bpm: r.bpm,
208
- bpmConfidence: r.bpmConfidence
209
- })).finally(() => ctx.close());
210
- }
211
- async function detectOnPage(page, bundle, b64) {
212
- const pageErrors = [];
213
- page.on("pageerror", (e) => {
214
- pageErrors.push(e.message);
215
- });
216
- page.on("console", (m) => {
217
- if (m.type() === "error") pageErrors.push(m.text());
218
- });
219
- await page.setContent("<!doctype html><html><body></body></html>");
220
- await page.addScriptTag({ content: bundle });
221
- try {
222
- return await page.evaluate(inPageAnalyze, b64);
223
- } catch (err) {
224
- const detail = pageErrors.length ? ` (${pageErrors.join("; ")})` : "";
225
- throw new Error(`${err instanceof Error ? err.message : String(err)}${detail}`);
226
- }
227
- }
228
- async function analyzeBeatsHeadless(audioBytes) {
229
- if (audioBytes.length > MAX_AUDIO_BYTES) {
230
- const mb = Math.round(audioBytes.length / 1e6);
231
- throw new Error(
232
- `Audio file too large for headless analysis (${mb}MB > ${MAX_AUDIO_BYTES / 1e6}MB).`
233
- );
234
- }
235
- const bundle = await buildAnalyzerBundle();
236
- const { ensureBrowser } = await import("./manager-ZLJD3EAY.js");
237
- const puppeteer = await import("puppeteer-core");
238
- const browser = await ensureBrowser();
239
- const chrome = await launchManagedBrowser(puppeteer.default, {
240
- headless: true,
241
- executablePath: browser.executablePath,
242
- args: ["--no-sandbox", "--disable-dev-shm-usage", "--autoplay-policy=no-user-gesture-required"]
243
- });
244
- try {
245
- const page = await chrome.newPage();
246
- return await detectOnPage(page, bundle, audioBytes.toString("base64"));
247
- } finally {
248
- await chrome.close();
249
- }
250
- }
251
-
252
- // src/commands/beats.ts
253
- var examples = [
254
- ["Generate the beat file for the current project", "hyperframes beats"],
255
- ["Generate for a specific directory", "hyperframes beats ./my-video"]
256
- ];
257
- function fail(message) {
258
- console.error(c.error(message));
259
- failCommand();
260
- }
261
- function resolveMusicTarget(project) {
262
- const src = findMusicAudioSrc(readFileSync2(project.indexPath, "utf-8"));
263
- if (!src) {
264
- fail(
265
- 'No music track found. Add data-timeline-role="music" to the <audio> element, or to a <video data-has-audio="true"> whose own sound is the music (or give it an id like music/bgm/soundtrack).'
266
- );
267
- }
268
- const rel = audioRelPathForSrc(src);
269
- if (!rel) fail(`Cannot derive a beat-file path for music src: ${src}`);
270
- const audioPath = resolve(project.dir, rel);
271
- if (!existsSync2(audioPath)) fail(`Audio file not found: ${rel}`);
272
- return { rel, audioPath };
273
- }
274
- async function detect(audioPath) {
275
- try {
276
- return await analyzeBeatsHeadless(readFileSync2(audioPath));
277
- } catch (err) {
278
- const msg = err instanceof Error ? err.message : String(err);
279
- const hint = /chrome|executable|browser|ENOENT/i.test(msg) ? "\nRun: npx hyperframes browser ensure" : "";
280
- fail(`Beat detection failed: ${msg}${hint}`);
281
- }
282
- }
283
- function report(file, result, json) {
284
- if (json) {
285
- console.log(
286
- JSON.stringify({ ok: true, file, count: result.beatTimes.length, bpm: result.bpm }, null, 2)
287
- );
288
- return;
289
- }
290
- console.log(
291
- c.success(
292
- `\u2713 Wrote ${result.beatTimes.length} beats \u2192 ${file} (bpm ${result.bpm ?? "?"}, ${result.bpmConfidence})`
293
- )
294
- );
295
- }
296
- var beats_default = defineCommand({
297
- meta: {
298
- name: "beats",
299
- description: "Detect beats in the music track (headless) and write beats/<audio>.json"
300
- },
301
- args: {
302
- dir: { type: "positional", description: "Project directory", required: false },
303
- json: { type: "boolean", description: "Output result as JSON", default: false }
304
- },
305
- async run({ args }) {
306
- const project = resolveProject(args.dir);
307
- const { rel, audioPath } = resolveMusicTarget(project);
308
- if (!args.json) console.log(c.dim(`Analyzing ${rel} in headless Chrome\u2026`));
309
- const result = await detect(audioPath);
310
- if (result.beatTimes.length === 0) {
311
- fail(`No beats detected in ${rel} \u2014 nothing written. (Track may be silent/ambient.)`);
312
- }
313
- const outPath = join2(project.dir, "beats", `${rel}.json`);
314
- mkdirSync(dirname2(outPath), { recursive: true });
315
- writeFileSync(outPath, serializeBeats(result.beatTimes, result.beatStrengths, rel));
316
- report(`beats/${rel}.json`, result, Boolean(args.json));
317
- }
318
- });
319
- export {
320
- beats_default as default,
321
- examples
322
- };