hyperframes 0.8.200 → 0.8.202

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 (194) hide show
  1. package/dist/{add-MFJDOJHQ.js → add-YC7QXNDO.js} +14 -17
  2. package/dist/{animatedGifPrep-WBZ2VVP6.js → animatedGifPrep-SFHFVFFE.js} +8 -11
  3. package/dist/api.js +16 -19
  4. package/dist/{asset-PTAQLOR6.js → asset-5E5BQ6BR.js} +2 -2
  5. package/dist/{assetCataloger-N3UGZ2RC.js → assetCataloger-F6YSU3H6.js} +8 -11
  6. package/dist/{audio-CPHWRLC4.js → audio-UZKBYVZ5.js} +33 -31
  7. package/dist/{auth-ZWOJIYK7.js → auth-5DWW5DMO.js} +2 -2
  8. package/dist/{autoUpdate-DO74673A.js → autoUpdate-D6HTQGOE.js} +2 -2
  9. package/dist/{backgroundChecks-HOAN7YB6.js → backgroundChecks-FW4MBBK2.js} +3 -3
  10. package/dist/backgroundChecksWorker.js +3 -3
  11. package/dist/{batchRender-AZFHTPSV.js → batchRender-DXD5THWY.js} +5 -7
  12. package/dist/{beats-JRMM6JQQ.js → beats-WRF4CRL7.js} +32 -23
  13. package/dist/{benchmark-2PEQUV7H.js → benchmark-NDCR2AAG.js} +11 -13
  14. package/dist/{browser-2D6IHFO6.js → browser-KSG6M66G.js} +5 -5
  15. package/dist/{bundleWithLocalizedFonts-ERB43NFP.js → bundleWithLocalizedFonts-GJ2UYZ6E.js} +2 -2
  16. package/dist/{capture-3ODEX55X.js → capture-DTF47QX3.js} +2 -2
  17. package/dist/{capture-WNC2DWF7.js → capture-FRVDEVPB.js} +15 -17
  18. package/dist/{captureCompositionFrame-JXXTHR7J.js → captureCompositionFrame-IC3MEOJR.js} +13 -16
  19. package/dist/{catalog-MHTRTKSY.js → catalog-TX3BMPOA.js} +14 -17
  20. package/dist/{catch-up-XNDRKMKL.js → catch-up-YMVIJI2W.js} +5 -5
  21. package/dist/{check-7IB355TM.js → check-2LBOZR6Z.js} +40 -43
  22. package/dist/{checkBrowser-E3ZCTAGY.js → checkBrowser-56C73ZNX.js} +34 -37
  23. package/dist/{chunk-Q5IJYX7X.js → chunk-24PUQCZO.js} +2 -2
  24. package/dist/{chunk-MMQ52NIZ.js → chunk-2BGOB2QK.js} +500 -17
  25. package/dist/{chunk-BIZPUWBG.js → chunk-3HTXEXQ6.js} +1 -1
  26. package/dist/{chunk-4VZAIVZQ.js → chunk-4OPDZMV6.js} +1 -1
  27. package/dist/{chunk-57Y5X4VU.js → chunk-5KPZ4QAS.js} +10 -12
  28. package/dist/{chunk-2LKHE32Z.js → chunk-73BGPSUW.js} +5 -5
  29. package/dist/{chunk-UUFY6A7I.js → chunk-75KIZWAD.js} +131 -92
  30. package/dist/{chunk-OE7AUN6G.js → chunk-7J4GQHSG.js} +82 -34
  31. package/dist/{chunk-4UPGPCMB.js → chunk-7KGCJQGS.js} +1 -1
  32. package/dist/{chunk-7NWSVRFE.js → chunk-ABTBAQDB.js} +1 -1
  33. package/dist/{chunk-OYVVDYM6.js → chunk-ANH7DV34.js} +10 -10
  34. package/dist/{chunk-NC3TVM27.js → chunk-AQLRXGNN.js} +6 -6
  35. package/dist/{chunk-63S4VUOL.js → chunk-AQVLMH5C.js} +1 -1
  36. package/dist/{chunk-QP4UWICL.js → chunk-B22YBW5W.js} +2 -2
  37. package/dist/{chunk-7WV27W7R.js → chunk-B2OUZUY5.js} +2 -2
  38. package/dist/chunk-B7CYKBXQ.js +36 -0
  39. package/dist/{chunk-7LRVGYKZ.js → chunk-BIV4FVEN.js} +16 -3
  40. package/dist/{chunk-WAG4AX5C.js → chunk-BU6XD7H2.js} +1 -1
  41. package/dist/{chunk-HBRPELT6.js → chunk-BUIJG2BQ.js} +3 -3
  42. package/dist/{chunk-DRTUJVLE.js → chunk-CL6ZTNQH.js} +326 -91
  43. package/dist/{chunk-3XXSRN36.js → chunk-COHU6S2X.js} +2 -2
  44. package/dist/{chunk-IC6BO4GU.js → chunk-CV32PRH3.js} +65 -21
  45. package/dist/{chunk-BERGVZKN.js → chunk-CXTXB2LZ.js} +1 -1
  46. package/dist/{chunk-OMXXJSCK.js → chunk-DMZ3SCCU.js} +108 -20
  47. package/dist/{chunk-QYQY5ACN.js → chunk-DYDFCX4L.js} +1 -1
  48. package/dist/{chunk-XOTUPVIF.js → chunk-E3F5L6AB.js} +38 -1
  49. package/dist/{chunk-63JJFXAD.js → chunk-EPZXTQOO.js} +6 -6
  50. package/dist/{chunk-VHBBV5DH.js → chunk-ERUINDRT.js} +62 -25
  51. package/dist/{chunk-FTD5QXGF.js → chunk-FWS2ZWV6.js} +2 -2
  52. package/dist/{chunk-5CTORVUM.js → chunk-GHROWWUN.js} +32 -1
  53. package/dist/{chunk-3YGSZSEN.js → chunk-GZCACSED.js} +1 -1
  54. package/dist/{chunk-32V3VHMK.js → chunk-I64A5P5H.js} +6 -43
  55. package/dist/{chunk-HXHSGDU6.js → chunk-IB6ICAI7.js} +60 -34
  56. package/dist/{chunk-D35MPIGJ.js → chunk-IKX2UHEM.js} +15 -15
  57. package/dist/{chunk-6JR2XUEE.js → chunk-IXXVS2Z4.js} +1 -1
  58. package/dist/{chunk-HN6TP4D2.js → chunk-J3CZK6PI.js} +1 -1
  59. package/dist/{chunk-ZFBET3PD.js → chunk-JCS7WFRM.js} +1 -1
  60. package/dist/{chunk-PFFR4NQV.js → chunk-JNBHYUEU.js} +8 -10
  61. package/dist/{chunk-FTUKOLLB.js → chunk-KFJMWPZT.js} +1 -1
  62. package/dist/{chunk-I6A2B3IJ.js → chunk-L5IKISP2.js} +3 -3
  63. package/dist/{chunk-G7RKSAKS.js → chunk-LEQU6P6H.js} +28 -6
  64. package/dist/{chunk-FMTJ4I6I.js → chunk-LMRTEJYY.js} +1 -1
  65. package/dist/{chunk-FZ3R5XOH.js → chunk-MO4VKSFT.js} +1 -1
  66. package/dist/{chunk-KPUTRG54.js → chunk-MS4BAXOQ.js} +2 -2
  67. package/dist/{chunk-KVFSXCN6.js → chunk-NT3L4IMM.js} +1 -1
  68. package/dist/{chunk-VFLBOKDI.js → chunk-NZEASM7M.js} +3 -3
  69. package/dist/{chunk-7D7V3UDI.js → chunk-OJDOYHPQ.js} +2 -2
  70. package/dist/chunk-PH5PJY5Z.js +39 -0
  71. package/dist/{chunk-GYSPF5ZT.js → chunk-PI256PSW.js} +27 -21
  72. package/dist/{chunk-JBQNDHRT.js → chunk-PLL6VC4F.js} +1 -1
  73. package/dist/{chunk-TOC6E65N.js → chunk-PYS6IKKM.js} +2 -2
  74. package/dist/{chunk-57GN6KWT.js → chunk-PZIWSVMO.js} +11 -1
  75. package/dist/{chunk-QDK7XCOB.js → chunk-QB4K2EWI.js} +1 -1
  76. package/dist/{chunk-IW4LKYDY.js → chunk-QDEZ7LRH.js} +3 -3
  77. package/dist/{chunk-I4VEFPZE.js → chunk-QGB5DECO.js} +1 -1
  78. package/dist/{chunk-BQA3X7TI.js → chunk-QSFWGZG6.js} +4 -6
  79. package/dist/chunk-QTGKDF7D.js +3983 -0
  80. package/dist/{chunk-QXPZGDTI.js → chunk-QXQ74PYD.js} +3 -3
  81. package/dist/{chunk-DY53XJ3P.js → chunk-QZTFCWG7.js} +1 -1
  82. package/dist/{chunk-ML4IULLQ.js → chunk-REFMKHRE.js} +10 -10
  83. package/dist/{chunk-H2X4TQVK.js → chunk-REUZB3HL.js} +7 -7
  84. package/dist/{chunk-ISN6BAZX.js → chunk-RFZJGC6V.js} +1 -1
  85. package/dist/{chunk-TDF2O2RM.js → chunk-RNLJJDGE.js} +2 -2
  86. package/dist/{chunk-5ULL3P6S.js → chunk-SQNPFWFM.js} +2 -2
  87. package/dist/{chunk-733CEBPF.js → chunk-TOFL5P27.js} +5 -5
  88. package/dist/{chunk-GR2G5L2O.js → chunk-UI7YYCN2.js} +3 -3
  89. package/dist/{chunk-TUVNQA5B.js → chunk-UMGDRGF5.js} +3 -3
  90. package/dist/{chunk-XV7ZNBVY.js → chunk-V6MTGX7B.js} +3 -3
  91. package/dist/{chunk-TTFHBTXQ.js → chunk-VOKI2HSE.js} +1 -1
  92. package/dist/{chunk-ACH5ZR7X.js → chunk-WAXBJLV6.js} +3 -3
  93. package/dist/{chunk-PGDWNIOK.js → chunk-XDMZY3H7.js} +57 -5
  94. package/dist/{chunk-VLVQQJOX.js → chunk-Z4PSJSDF.js} +22 -3
  95. package/dist/{clean-BOYUTBAU.js → clean-LFPT6GNS.js} +21 -24
  96. package/dist/cli.js +54 -54
  97. package/dist/{cloud-3O2MEZO4.js → cloud-XX5XB277.js} +4 -4
  98. package/dist/{cloudrun-MCTN22O6.js → cloudrun-ANWC6QGV.js} +7 -9
  99. package/dist/{compare-A57RHCPB.js → compare-CISKXIRF.js} +31 -34
  100. package/dist/{compiler-LVNWLZCX.js → compiler-XYZMBTYR.js} +6 -10
  101. package/dist/{component-MIJC3LWO.js → component-D4JJIDOC.js} +3 -3
  102. package/dist/{compositions-OUNZAEC3.js → compositions-UGRTLUBT.js} +13 -16
  103. package/dist/{delete-X6Q3S3SL.js → delete-TPH7N5PK.js} +2 -2
  104. package/dist/{deploy-XXMIXGUF.js → deploy-ZUXLAVVX.js} +72 -20
  105. package/dist/{deterministicFonts-RMA7GDJC.js → deterministicFonts-NQ6KL66D.js} +2 -2
  106. package/dist/{dist-ONHJ6ZDA.js → dist-TFHABY7N.js} +2 -4
  107. package/dist/{dist-2UO4RVFN.js → dist-UXLDRI4D.js} +30 -16
  108. package/dist/{doctor-ASSDEPCO.js → doctor-LVOS4EDV.js} +14 -17
  109. package/dist/{dotEnv-64S3VKGH.js → dotEnv-RPHCAUBZ.js} +1 -1
  110. package/dist/{events-DVWSV3TQ.js → events-FIWA6UBT.js} +4 -4
  111. package/dist/{events-4ULC5VUK.js → events-UHIKJIWA.js} +3 -3
  112. package/dist/{feedback-OB3NJPNF.js → feedback-SPOCVRKJ.js} +10 -12
  113. package/dist/{ffmpeg-JH3JXES2.js → ffmpeg-7SDXE5P5.js} +8 -11
  114. package/dist/{figma-GV4OGXC2.js → figma-ONGILUUE.js} +3 -3
  115. package/dist/fontLocalizeCli.js +11 -14
  116. package/dist/{get-FLMCUJGR.js → get-W7ADZ5XS.js} +2 -2
  117. package/dist/{gpuPolicy-RZ2OUY4M.js → gpuPolicy-GETTDB3G.js} +8 -11
  118. package/dist/{grade-compare-O62JAOA7.js → grade-compare-YIIQJNL3.js} +32 -35
  119. package/dist/{help-6POZ4GNV.js → help-HSKEDFT6.js} +1 -1
  120. package/dist/{history-72ZIF5WR.js → history-JS6QALDS.js} +8 -8
  121. package/dist/hyperframe.manifest.json +1 -1
  122. package/dist/hyperframe.runtime.iife.js +65 -64
  123. package/dist/hyperframes-player.global.js +3 -3
  124. package/dist/{info-GGIFZ5CT.js → info-BIIA6M7Q.js} +10 -12
  125. package/dist/{init-QYRN6HG2.js → init-TGDKBWUY.js} +29 -32
  126. package/dist/{inspect-KSL4YVIU.js → inspect-MVMUFUHY.js} +32 -35
  127. package/dist/{installer-ENQCLSJQ.js → installer-HITNNXHY.js} +6 -9
  128. package/dist/{keyframes-6PNLGKOO.js → keyframes-XJ7DUUBW.js} +7 -7
  129. package/dist/{lambda-3RFOOJV6.js → lambda-4C7APDR5.js} +24 -14
  130. package/dist/{layout-3XFC6N3L.js → layout-O3LEAM7S.js} +32 -35
  131. package/dist/{lint-5XGLCTV5.js → lint-72FKMBD2.js} +9 -11
  132. package/dist/{lintProject-FKPKSU6M.js → lintProject-Q36Y3AHA.js} +2 -4
  133. package/dist/{list-B76BTLOM.js → list-YUK5VA2D.js} +2 -2
  134. package/dist/{login-MNXS7GEL.js → login-TXBDKLOH.js} +4 -4
  135. package/dist/{manager-QZZVJV7Z.js → manager-APB2JLSH.js} +9 -12
  136. package/dist/{manager-BWU4U7DV.js → manager-F34TSFV6.js} +2 -2
  137. package/dist/{media-treatment-J3OWRCBF.js → media-treatment-GMP4JL46.js} +66 -42
  138. package/dist/{models-MCDUTV54.js → models-DW22WMQ5.js} +12 -15
  139. package/dist/{motionShot-RWEH3VWI.js → motionShot-UQJVQT76.js} +17 -20
  140. package/dist/{normalize-audio-N7VRZODX.js → normalize-audio-4KYSZBWI.js} +44 -26
  141. package/dist/{open-ROUFAVKD.js → open-HNYN6VM2.js} +14 -17
  142. package/dist/{parakeetRunner-PTVV5M44.js → parakeetRunner-SJ2QW77R.js} +13 -16
  143. package/dist/{pipeline-HN5KMORF.js → pipeline-MG2W6NIW.js} +9 -12
  144. package/dist/{play-AO7AF4Y4.js → play-ZQ6RNKIE.js} +23 -26
  145. package/dist/{preflight-ARNDDFGX.js → preflight-HSQEJNA2.js} +11 -14
  146. package/dist/{present-FBPKUC5R.js → present-7M3W5E3Q.js} +19 -22
  147. package/dist/{preview-35X5G426.js → preview-TT5Z6JK6.js} +20 -23
  148. package/dist/{producer-FVGPLR5E.js → producer-B2Y4IKZS.js} +1 -1
  149. package/dist/{projectConfig-SRUJLOHL.js → projectConfig-VZVY6ZZP.js} +8 -11
  150. package/dist/{publication-XH2BRL3V.js → publication-SRAYE6LT.js} +4 -6
  151. package/dist/{publish-RI4ZQZNT.js → publish-3QMV3Q7B.js} +11 -14
  152. package/dist/{remove-background-J22P5JFW.js → remove-background-5GA2S5OI.js} +10 -13
  153. package/dist/{render-2EZQT4IS.js → render-LN24E3OI.js} +37 -33
  154. package/dist/{render-UXYZN6D2.js → render-W3VX647V.js} +17 -17
  155. package/dist/{render-IJUKJILU.js → render-WRLXYVSQ.js} +34 -37
  156. package/dist/{render-batch-X34UZ442.js → render-batch-C73ELOQ7.js} +17 -17
  157. package/dist/renderSetupWorker.js +4 -6
  158. package/dist/{resolver-UUEIRLMY.js → resolver-ALD2ZELQ.js} +6 -8
  159. package/dist/{sherpa-FI4VNAFT.js → sherpa-AHD5UPU3.js} +12 -15
  160. package/dist/skills/hyperframes/references/runtimes.md +26 -0
  161. package/dist/skills/hyperframes-cli/references/lambda.md +1 -0
  162. package/dist/skills/media-use/references/mixing.md +1 -1
  163. package/dist/skills/media-use/scripts/lib/grade-analyzer.mjs +38 -26
  164. package/dist/{skills-LGKXQFW7.js → skills-WYJGVMR5.js} +6 -6
  165. package/dist/{skillsUpdateCheck-NDPKSX3H.js → skillsUpdateCheck-OHEGRQ2N.js} +3 -3
  166. package/dist/{snapshot-JM6427YW.js → snapshot-S6CGQACZ.js} +94 -61
  167. package/dist/{src-WEECPY6E.js → src-DAW4JYSR.js} +11 -10
  168. package/dist/{src-26NBARTO.js → src-I6WD5SMQ.js} +10 -13
  169. package/dist/{staticProjectServer-I5WGMJOV.js → staticProjectServer-3BFEACQ6.js} +19 -22
  170. package/dist/{status-SCCC7A6N.js → status-LR7VXITS.js} +1 -1
  171. package/dist/studio/assets/{hyperframes-player-LmRUJE8q.js → hyperframes-player-DnrkDR-_.js} +1 -1
  172. package/dist/studio/assets/{index-BmTWk8xf.js → index-BhFxhBMA.js} +162 -162
  173. package/dist/studio/assets/{index-CKNiEwbW.js → index-WFQeAouT.js} +1 -1
  174. package/dist/studio/index.html +1 -1
  175. package/dist/{studio-api-N774Q4NO.js → studio-api-2O6R4CM5.js} +12 -15
  176. package/dist/{studioServer-KZIM5UBJ.js → studioServer-6ZSAJBVY.js} +53 -56
  177. package/dist/{system-HV7PYIXE.js → system-YD4AW5ZX.js} +1 -1
  178. package/dist/{telemetry-JIETM7WP.js → telemetry-WFLPGSUG.js} +4 -4
  179. package/dist/{timeline-JJ6JG7GQ.js → timeline-BZJH266Q.js} +23 -25
  180. package/dist/{tokens-VOIMSCGX.js → tokens-5TX42ZMQ.js} +2 -2
  181. package/dist/{transcribe-2V23EQHD.js → transcribe-IEYR46HB.js} +18 -21
  182. package/dist/{transcribe-7BDHDQVP.js → transcribe-WPFFLNTS.js} +11 -14
  183. package/dist/{updateCheck-7B7L3UWO.js → updateCheck-TESZGKRJ.js} +2 -2
  184. package/dist/{upgrade-TUA2QZTY.js → upgrade-3EW4MYS7.js} +2 -2
  185. package/dist/{urlDownloader-CGV6EYL7.js → urlDownloader-JULHEBLS.js} +7 -10
  186. package/dist/{validate-JLCXEI2U.js → validate-RSJPGXUZ.js} +26 -29
  187. package/dist/{video-TI3EOA2D.js → video-TW4TSAM4.js} +8 -11
  188. package/dist/warmCheck.js +40 -43
  189. package/package.json +1 -1
  190. package/dist/chunk-BSQ7XANM.js +0 -210
  191. package/dist/chunk-PKZ7RK5N.js +0 -281
  192. package/dist/chunk-PW22CDII.js +0 -3901
  193. package/dist/chunk-RFQ6BIRL.js +0 -40
  194. package/dist/chunk-X7HBSTCZ.js +0 -53
@@ -87,6 +87,15 @@ async function decodeAudio(file, window = {}, probed, format = {}) {
87
87
  return { signal: { sampleRate: info.sampleRate, channels }, stream: info };
88
88
  }
89
89
 
90
+ // ../core/dist/audioSteps.js
91
+ function finish(steps) {
92
+ for (; ; ) {
93
+ const next = steps.next();
94
+ if (next.done)
95
+ return next.value;
96
+ }
97
+ }
98
+
90
99
  // ../core/dist/audioResample.js
91
100
  var ZERO_CROSSINGS = 8;
92
101
  var STEPS_PER_CROSSING = 256;
@@ -106,7 +115,8 @@ function kernelAt(x) {
106
115
  const frac = at - i;
107
116
  return KERNEL[i] * (1 - frac) + KERNEL[i + 1] * frac;
108
117
  }
109
- function resample(samples, from, to) {
118
+ var SAMPLES_PER_STEP = 4096;
119
+ function* resampleSteps(samples, from, to) {
110
120
  if (from === to)
111
121
  return samples;
112
122
  const ratio = to / from;
@@ -114,6 +124,8 @@ function resample(samples, from, to) {
114
124
  const reach = ZERO_CROSSINGS / scale;
115
125
  const out = new Float32Array(Math.floor(samples.length * ratio));
116
126
  for (let n = 0; n < out.length; n++) {
127
+ if (n % SAMPLES_PER_STEP === 0)
128
+ yield;
117
129
  const t = n / ratio;
118
130
  const last = Math.min(samples.length - 1, Math.floor(t + reach));
119
131
  let sum = 0;
@@ -199,7 +211,7 @@ function addFramePower(samples, center, window, edges, into) {
199
211
  into[b] += power / (size * size * (end - edges[b]));
200
212
  }
201
213
  }
202
- function bandPower(channels) {
214
+ function* bandPower(channels) {
203
215
  const window = hann(FRAME_SIZE);
204
216
  const edges = bandEdges();
205
217
  const hop = ANALYSIS_RATE / FRAMES_PER_SECOND;
@@ -209,6 +221,7 @@ function bandPower(channels) {
209
221
  for (const channel of channels)
210
222
  addFramePower(channel, Math.round(f * hop), window, edges, power);
211
223
  bands.push(power.map((p) => Math.log1p(1e9 * p / channels.length)));
224
+ yield;
212
225
  }
213
226
  return bands;
214
227
  }
@@ -218,7 +231,7 @@ var PITCH_CLASS = Array.from({ length: CHROMA_SIZE / 2 }, (_, bin) => {
218
231
  return -1;
219
232
  return ((Math.round(12 * Math.log2(hz / 440)) + 9) % 12 + 12) % 12;
220
233
  });
221
- function chromaFrames(channels) {
234
+ function* chromaFrames(channels) {
222
235
  const window = hann(CHROMA_SIZE);
223
236
  const hop = ANALYSIS_RATE / CHROMA_FPS;
224
237
  const re = new Float64Array(CHROMA_SIZE);
@@ -240,15 +253,18 @@ function chromaFrames(channels) {
240
253
  });
241
254
  }
242
255
  frames.push(chroma);
256
+ yield;
243
257
  }
244
258
  return frames;
245
259
  }
246
- function bandFrames(signal) {
247
- const channels = signal.channels.map((c) => resample(c, signal.sampleRate, ANALYSIS_RATE));
260
+ function* bandFrames(signal) {
261
+ const channels = [];
262
+ for (const c of signal.channels)
263
+ channels.push(yield* resampleSteps(c, signal.sampleRate, ANALYSIS_RATE));
248
264
  return {
249
265
  fps: FRAMES_PER_SECOND,
250
- bands: bandPower(channels),
251
- chroma: chromaFrames(channels),
266
+ bands: yield* bandPower(channels),
267
+ chroma: yield* chromaFrames(channels),
252
268
  chromaFps: CHROMA_FPS
253
269
  };
254
270
  }
@@ -329,7 +345,7 @@ function smoothed(curve, period) {
329
345
  return sum;
330
346
  });
331
347
  }
332
- function cumulativeScore(local, periodAt) {
348
+ function* cumulativeScore(local, periodAt) {
333
349
  const score = new Float64Array(local.length);
334
350
  const back = new Int32Array(local.length).fill(-1);
335
351
  for (let i = 0; i < local.length; i++) {
@@ -343,6 +359,7 @@ function cumulativeScore(local, periodAt) {
343
359
  }
344
360
  score[i] = local[i] + Math.max(0, best);
345
361
  back[i] = best > 0 ? from : -1;
362
+ yield;
346
363
  }
347
364
  return { score, back };
348
365
  }
@@ -370,7 +387,7 @@ function trimmed(beats, local) {
370
387
  return beats.slice(first, end);
371
388
  }
372
389
  var LOCAL_WINDOW_SECONDS = 8;
373
- function localPeriods(curve, fps, period) {
390
+ function* localPeriods(curve, fps, period) {
374
391
  const window = Math.round(LOCAL_WINDOW_SECONDS * fps);
375
392
  const hop = Math.round(fps);
376
393
  const range = {
@@ -383,6 +400,7 @@ function localPeriods(curve, fps, period) {
383
400
  const end = Math.min(curve.length, start + window);
384
401
  periods.push(beatPeriod(curve.subarray(start, end), fps, range).period);
385
402
  centres.push((start + end) / 2);
403
+ yield;
386
404
  }
387
405
  const median = periods.map((_, i) => {
388
406
  const near = periods.slice(Math.max(0, i - 2), i + 3).sort((a, b) => a - b);
@@ -400,9 +418,10 @@ function interpolate(xs, ys, x) {
400
418
  }
401
419
  return ys[ys.length - 1];
402
420
  }
403
- function beatFrames(curve, fps, period) {
421
+ function* beatFrames(curve, fps, period) {
404
422
  const local = smoothed(curve, period);
405
- const { score, back } = cumulativeScore(local, localPeriods(curve, fps, period));
423
+ const periodAt = yield* localPeriods(curve, fps, period);
424
+ const { score, back } = yield* cumulativeScore(local, periodAt);
406
425
  const beats = [];
407
426
  for (let i = lastBeat(score); i >= 0; i = back[i])
408
427
  beats.push(i);
@@ -484,14 +503,16 @@ var noRhythm = (confidence, reason = "no steady beat") => ({
484
503
  var SHORTEST_SECONDS = 6;
485
504
  var STEADY_BEAT_CONFIDENCE = 0.15;
486
505
  var beatConfidence = (clarity, lift) => round(Math.max(0, Math.min(1, clarity)) * Math.max(0, Math.min(1, lift / 3)));
487
- function rhythmOf(frames) {
506
+ function* rhythmOf(frames) {
488
507
  const curves = onsetCurves(frames);
508
+ yield;
489
509
  const { period, clarity } = beatPeriod(curves.broad, curves.fps);
510
+ yield;
490
511
  if (curves.broad.length < SHORTEST_SECONDS * curves.fps)
491
512
  return noRhythm(0, "too short for a steady beat");
492
513
  if (!curves.broad.some((v) => v > 0) || curves.broad.length < 2 * period)
493
514
  return noRhythm(0);
494
- const { frames: beatList, local } = beatFrames(curves.broad, curves.fps, period);
515
+ const { frames: beatList, local } = yield* beatFrames(curves.broad, curves.fps, period);
495
516
  const confidence = beatConfidence(clarity, onsetLift(beatList, local));
496
517
  if (beatList.length < 4 || confidence < STEADY_BEAT_CONFIDENCE)
497
518
  return noRhythm(confidence);
@@ -521,16 +542,22 @@ function tempoOf(times) {
521
542
  return { value: bpm(interval), curve };
522
543
  }
523
544
  var measured = /* @__PURE__ */ new WeakMap();
524
- function bandFramesOf(signal) {
545
+ function* measuredSteps(signal) {
525
546
  let entry = measured.get(signal);
526
547
  if (!entry)
527
- measured.set(signal, entry = { frames: bandFrames(signal) });
528
- return entry.frames;
548
+ measured.set(signal, entry = { frames: yield* bandFrames(signal) });
549
+ return entry;
550
+ }
551
+ function bandFramesOf(signal) {
552
+ return finish(measuredSteps(signal)).frames;
529
553
  }
530
554
  function rhythm(signal) {
531
- const frames = bandFramesOf(signal);
532
- const entry = measured.get(signal);
533
- return entry.rhythm ??= rhythmOf(frames);
555
+ return finish(rhythmSteps(signal));
556
+ }
557
+ function* rhythmSteps(signal) {
558
+ const entry = yield* measuredSteps(signal);
559
+ entry.rhythm ??= yield* rhythmOf(entry.frames);
560
+ return entry.rhythm;
534
561
  }
535
562
 
536
563
  // ../core/dist/audioAnalysisLadder.js
@@ -749,18 +776,26 @@ function sections(signal, options = {}) {
749
776
  var DB_FLOOR = -120;
750
777
  var signalDuration = (signal) => (signal.channels[0]?.length ?? 0) / signal.sampleRate;
751
778
  function energyMix(signal) {
779
+ return finish(energyMixSteps(signal));
780
+ }
781
+ var MIX_SAMPLES_PER_STEP = 65536;
782
+ function* energyMixSteps(signal) {
752
783
  const [first, ...rest] = signal.channels;
753
784
  if (!first)
754
785
  return new Float32Array(0);
755
786
  if (!rest.length)
756
787
  return first;
757
788
  const mixed = new Float32Array(first.length);
758
- for (const channel of signal.channels)
759
- for (let i = 0; i < mixed.length; i++)
760
- mixed[i] += channel[i] * channel[i];
761
789
  const scale = 1 / signal.channels.length;
762
- for (let i = 0; i < mixed.length; i++)
763
- mixed[i] = Math.sqrt(mixed[i] * scale);
790
+ for (let start = 0; start < mixed.length; start += MIX_SAMPLES_PER_STEP) {
791
+ const end = Math.min(mixed.length, start + MIX_SAMPLES_PER_STEP);
792
+ for (const channel of signal.channels)
793
+ for (let i = start; i < end; i++)
794
+ mixed[i] += channel[i] * channel[i];
795
+ for (let i = start; i < end; i++)
796
+ mixed[i] = Math.sqrt(mixed[i] * scale);
797
+ yield;
798
+ }
764
799
  return mixed;
765
800
  }
766
801
  var toDb = (amplitude) => amplitude > 0 ? Math.max(DB_FLOOR, 20 * Math.log10(amplitude)) : DB_FLOOR;
@@ -1173,14 +1208,16 @@ var signalProvider = {
1173
1208
  };
1174
1209
 
1175
1210
  export {
1211
+ finish,
1176
1212
  medianInterval,
1177
1213
  tempoOf,
1178
1214
  bandFramesOf,
1179
1215
  rhythm,
1216
+ rhythmSteps,
1180
1217
  snapper,
1181
1218
  runLadder,
1182
1219
  signalDuration,
1183
- energyMix,
1220
+ energyMixSteps,
1184
1221
  envelope,
1185
1222
  signalProvider,
1186
1223
  probeAudio,
@@ -19,10 +19,10 @@ import {
19
19
  import {
20
20
  formatVariableValidationIssue,
21
21
  validateVariables
22
- } from "./chunk-G7RKSAKS.js";
22
+ } from "./chunk-LEQU6P6H.js";
23
23
  import {
24
24
  extractCompositionMetadata
25
- } from "./chunk-XOTUPVIF.js";
25
+ } from "./chunk-E3F5L6AB.js";
26
26
 
27
27
  // src/utils/variables.ts
28
28
  import { readFileSync } from "fs";
@@ -38,9 +38,40 @@ function entryOf(rawLine) {
38
38
  if (eq < 1) return null;
39
39
  return [line.slice(0, eq).trim(), valueOf(line.slice(eq + 1).trim())];
40
40
  }
41
+ function openQuoteOf(trimmedLine) {
42
+ const eq = trimmedLine.indexOf("=");
43
+ if (eq < 1) return null;
44
+ const valueStart = trimmedLine.slice(eq + 1).trim();
45
+ const quote = valueStart.charAt(0);
46
+ if (quote !== '"' && quote !== "'") return null;
47
+ return valueStart.indexOf(quote, 1) < 0 ? quote : null;
48
+ }
49
+ function closingLineIndex(rawLines, from, quote) {
50
+ for (let j = from; j < rawLines.length; j++) {
51
+ if ((rawLines[j] ?? "").includes(quote)) return j;
52
+ }
53
+ return -1;
54
+ }
55
+ function logicalLines(content) {
56
+ const rawLines = content.split("\n").map((line) => line.replace(/\r$/, ""));
57
+ const lines = [];
58
+ for (let i = 0; i < rawLines.length; i++) {
59
+ const line = rawLines[i] ?? "";
60
+ const trimmed = line.trim();
61
+ const quote = trimmed && !trimmed.startsWith("#") ? openQuoteOf(trimmed) : null;
62
+ const end = quote === null ? -1 : closingLineIndex(rawLines, i + 1, quote);
63
+ if (end === -1) {
64
+ lines.push(line);
65
+ continue;
66
+ }
67
+ lines.push(rawLines.slice(i, end + 1).join("\n"));
68
+ i = end;
69
+ }
70
+ return lines;
71
+ }
41
72
  function applyDotEnv(content, env, allowedKeys) {
42
73
  const allowed = allowedKeys === void 0 ? void 0 : new Set(allowedKeys);
43
- for (const entry of content.split("\n").map(entryOf)) {
74
+ for (const entry of logicalLines(content).map(entryOf)) {
44
75
  if (!entry) continue;
45
76
  const [key, value] = entry;
46
77
  if (key && key.toUpperCase() !== FEEDBACK_EMAIL_ENV && (allowed === void 0 || allowed.has(key)) && !(key in env))
@@ -17,7 +17,7 @@ import {
17
17
  } from "./chunk-ISN5GRYI.js";
18
18
  import {
19
19
  VERSION
20
- } from "./chunk-KPUTRG54.js";
20
+ } from "./chunk-MS4BAXOQ.js";
21
21
 
22
22
  // src/utils/updateCheck.ts
23
23
  import { existsSync, readFileSync } from "fs";
@@ -35,11 +35,12 @@ import {
35
35
  parseHostVariableValues,
36
36
  planCompositionAssembly,
37
37
  readDeclaredDefaults,
38
+ rewriteSrcsetUrls,
38
39
  shouldClampResolvedMediaDuration,
39
40
  stripEmbeddedRuntimeScripts,
40
41
  styleElementsFor,
41
42
  warnUnknownEnumValues
42
- } from "./chunk-PW22CDII.js";
43
+ } from "./chunk-QTGKDF7D.js";
43
44
  import {
44
45
  cssVariableName
45
46
  } from "./chunk-VC76R6W2.js";
@@ -49,24 +50,22 @@ import {
49
50
  } from "./chunk-OFQWTKPW.js";
50
51
  import {
51
52
  lintHyperframeHtml
52
- } from "./chunk-IC6BO4GU.js";
53
- import {
54
- checkSubCompositionUsability,
55
- resolveSubCompositionContent
56
- } from "./chunk-MMQ52NIZ.js";
53
+ } from "./chunk-CV32PRH3.js";
57
54
  import {
58
55
  CSS_URL_RE,
56
+ checkSubCompositionUsability,
59
57
  decodeCssEscapes,
60
58
  decodeWellFormedEscapes,
61
59
  decodedUrlPath,
62
60
  encodeUrlPath,
63
61
  isNonRelativeUrl,
62
+ resolveSubCompositionContent,
64
63
  rewriteAssetPath,
65
64
  rewriteAssetPaths,
66
65
  rewriteCssAssetUrls,
67
66
  rewriteInlineStyleAssetUrls,
68
67
  splitUrlSuffix
69
- } from "./chunk-BSQ7XANM.js";
68
+ } from "./chunk-2BGOB2QK.js";
70
69
  import {
71
70
  parseHTML
72
71
  } from "./chunk-SDYDNHEE.js";
@@ -2320,42 +2319,6 @@ function rebaseRelativePath(urlValue, fromDir, toDir) {
2320
2319
  const rebased = encodeUrlPath(relative(resolve2(toDir), absolutePath).split(sep).join("/"));
2321
2320
  return appendSuffixToUrl(rebased, suffix);
2322
2321
  }
2323
- function rewriteSrcsetUrls(srcset, rewriteUrl) {
2324
- const parts = [];
2325
- let position = 0;
2326
- let written = 0;
2327
- while (position < srcset.length) {
2328
- while (position < srcset.length && /[ \t\n\r\f,]/.test(srcset.charAt(position)))
2329
- position++;
2330
- const start = position;
2331
- while (position < srcset.length && !/[ \t\n\r\f]/.test(srcset.charAt(position)))
2332
- position++;
2333
- let end = position;
2334
- while (end > start && srcset.charAt(end - 1) === ",")
2335
- end--;
2336
- if (end > start) {
2337
- const url = srcset.slice(start, end);
2338
- const rewritten = rewriteUrl(url);
2339
- if (rewritten !== url) {
2340
- parts.push(srcset.slice(written, start), rewritten);
2341
- written = end;
2342
- }
2343
- }
2344
- if (end < position)
2345
- continue;
2346
- let inParens = false;
2347
- while (position < srcset.length) {
2348
- const char = srcset.charAt(position++);
2349
- if (char === "(")
2350
- inParens = true;
2351
- else if (char === ")")
2352
- inParens = false;
2353
- else if (char === "," && !inParens)
2354
- break;
2355
- }
2356
- }
2357
- return parts.length > 0 ? parts.join("") + srcset.slice(written) : srcset;
2358
- }
2359
2322
  function rebaseColorGradingLutPath(value, fromDir, toDir) {
2360
2323
  if (!value.trim().startsWith("{"))
2361
2324
  return value;
@@ -19,11 +19,11 @@ import {
19
19
  splitElementInHtml,
20
20
  unwrapElementsFromHtml,
21
21
  wrapElementsInHtml
22
- } from "./chunk-PFFR4NQV.js";
22
+ } from "./chunk-JNBHYUEU.js";
23
23
  import {
24
24
  MEDIA_LINK_ATTR,
25
25
  relinkSplitHalves
26
- } from "./chunk-6JR2XUEE.js";
26
+ } from "./chunk-IXXVS2Z4.js";
27
27
  import {
28
28
  DEFAULT_TARGET_LUFS,
29
29
  absoluteLoudnessPlan,
@@ -32,7 +32,7 @@ import {
32
32
  requestedProjectPath,
33
33
  requiredFfmpeg,
34
34
  resolveLocalAudioPath
35
- } from "./chunk-QXPZGDTI.js";
35
+ } from "./chunk-QXQ74PYD.js";
36
36
  import {
37
37
  HistoryBusyError,
38
38
  MAX_WINDOW_IDLE_MS,
@@ -46,7 +46,7 @@ import {
46
46
  resolveProjectAndSignature,
47
47
  resolveProjectSignature,
48
48
  settledFileTag
49
- } from "./chunk-PGDWNIOK.js";
49
+ } from "./chunk-XDMZY3H7.js";
50
50
  import {
51
51
  PROXY_PARAMS_VERSION,
52
52
  PROXY_PENDING_RETRY_AFTER_SECONDS,
@@ -65,10 +65,10 @@ import {
65
65
  recordProxyRequest,
66
66
  resolveProxy,
67
67
  resolveProxyVariantRequest,
68
- scanProjectMediaCodecMap,
68
+ scanProjectMedia,
69
69
  shouldPrewarmProxy,
70
70
  waitForProxy
71
- } from "./chunk-DRTUJVLE.js";
71
+ } from "./chunk-CL6ZTNQH.js";
72
72
  import {
73
73
  STUDIO_MOTION_PATH,
74
74
  createStudioMotionRenderBodyScript,
@@ -104,6 +104,7 @@ import {
104
104
  import {
105
105
  GSAP_BASE_URL_META,
106
106
  PREVIEW_PROXY_BOX_PARAM,
107
+ PREVIEW_PROXY_LIGHT_PARAM,
107
108
  formatPreviewProxyBox,
108
109
  formatRenderOutputTimestamp,
109
110
  gsapCdnDist,
@@ -112,12 +113,12 @@ import {
112
113
  normalizeGsapLocalRoot,
113
114
  parseFps,
114
115
  parsePreviewProxyBox
115
- } from "./chunk-G7RKSAKS.js";
116
+ } from "./chunk-LEQU6P6H.js";
116
117
  import {
117
118
  addScenePartsManifest,
118
119
  ensureHfIds,
119
120
  stampHfIdsInPlace
120
- } from "./chunk-32V3VHMK.js";
121
+ } from "./chunk-I64A5P5H.js";
121
122
  import {
122
123
  AFTER_FONTS_SCRIPT_TYPE,
123
124
  RUNTIME_BOOTSTRAP_ATTR,
@@ -131,7 +132,7 @@ import {
131
132
  resolveRateSpec,
132
133
  sourceTimeAt,
133
134
  stripEmbeddedRuntimeScripts
134
- } from "./chunk-PW22CDII.js";
135
+ } from "./chunk-QTGKDF7D.js";
135
136
  import {
136
137
  HTML_ATTRIBUTE_ENTITIES,
137
138
  MagicString,
@@ -139,7 +140,7 @@ import {
139
140
  decodeAuthoredAttribute,
140
141
  scanHtmlOpeningTags,
141
142
  unrollComputedTimeline
142
- } from "./chunk-XOTUPVIF.js";
143
+ } from "./chunk-E3F5L6AB.js";
143
144
  import {
144
145
  ProjectRootMissingError,
145
146
  folderGone,
@@ -156,9 +157,6 @@ import {
156
157
  isWithinProjectRoot,
157
158
  readProjectFile
158
159
  } from "./chunk-6BNTGNGD.js";
159
- import {
160
- sameInstant
161
- } from "./chunk-MMQ52NIZ.js";
162
160
  import {
163
161
  decodeCssEscapes,
164
162
  decodeWellFormedEscapes,
@@ -167,8 +165,9 @@ import {
167
165
  readMediaOffsetSeconds,
168
166
  rewriteAssetPaths,
169
167
  rewriteCssAssetUrls,
170
- rewriteInlineStyleAssetUrls
171
- } from "./chunk-BSQ7XANM.js";
168
+ rewriteInlineStyleAssetUrls,
169
+ sameInstant
170
+ } from "./chunk-2BGOB2QK.js";
172
171
  import {
173
172
  parseHTML
174
173
  } from "./chunk-SDYDNHEE.js";
@@ -308,7 +307,7 @@ function clearElementScreenshotIsolation() {
308
307
  page.__hfThumbnailFaded = [];
309
308
  }
310
309
 
311
- // ../studio-server/dist/chunk-ZCCJNXS7.js
310
+ // ../studio-server/dist/chunk-2MJKVMZU.js
312
311
  import { resolve } from "path";
313
312
  function isAutoProxyEnabled(adapter) {
314
313
  return adapter.autoProxy !== false;
@@ -321,17 +320,15 @@ function proxyEtagSalt(raw, box) {
321
320
  return `:proxy:${raw}:${PROXY_PARAMS_VERSION}${box ? `:${formatPreviewProxyBox(box)}` : ""}`;
322
321
  }
323
322
  async function injectMediaCodecMapIntoHtml(html, projectDir, htmlSources, probeCache, prewarm = true, signal, box) {
324
- let map;
323
+ let scan;
325
324
  try {
326
- map = await scanProjectMediaCodecMap(
327
- projectDir,
328
- htmlSources,
329
- probeCache ? { cache: probeCache } : {}
330
- );
325
+ scan = await scanProjectMedia(projectDir, htmlSources, probeCache ? { cache: probeCache } : {});
331
326
  } catch {
332
327
  return html;
333
328
  }
334
- if (Object.keys(map).length === 0) return html;
329
+ const { codecMap: map, sourceFacts } = scan;
330
+ const hasMap = Object.keys(map).length > 0;
331
+ if (!hasMap && Object.keys(sourceFacts).length === 0) return html;
335
332
  for (const [rootRelativePathname, facts] of Object.entries(map)) {
336
333
  if (!prewarm || !shouldPrewarmProxy(facts)) continue;
337
334
  recordProxyPrewarm();
@@ -344,8 +341,12 @@ async function injectMediaCodecMapIntoHtml(html, projectDir, htmlSources, probeC
344
341
  ).catch(() => {
345
342
  });
346
343
  }
347
- const json = JSON.stringify(map).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
348
- const tag = `<script data-hf-media-codec-map>window.__HF_MEDIA_CODEC_MAP__=${json};</script>`;
344
+ const safeJson = (value) => JSON.stringify(value).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
345
+ const assignments = [
346
+ ...hasMap ? [`window.__HF_MEDIA_CODEC_MAP__=${safeJson(map)};`] : [],
347
+ `window.__HF_MEDIA_SOURCE_FACTS__=${safeJson(sourceFacts)};`
348
+ ];
349
+ const tag = `<script data-hf-media-codec-map>${assignments.join("")}</script>`;
349
350
  return insertBeforeCloseTag(html, "head", `${tag}
350
351
  `) ?? `${tag}
351
352
  ${html}`;
@@ -5544,7 +5545,7 @@ async function prepareGsapMutationScript(c, res, firstMutation) {
5544
5545
  let block = extractGsapScriptBlock(html);
5545
5546
  if (!block && (firstMutation.type === "add" || firstMutation.type === "add-with-keyframes")) {
5546
5547
  const compId = html.match(/data-composition-id="([^"]+)"/)?.[1] ?? "main";
5547
- const { GSAP_CDN } = await import("./dist-2UO4RVFN.js");
5548
+ const { GSAP_CDN } = await import("./dist-UXLDRI4D.js");
5548
5549
  const bootstrap = [
5549
5550
  `<script src="${GSAP_CDN}"></script>`,
5550
5551
  "<script>",
@@ -7864,7 +7865,8 @@ ${etag}`;
7864
7865
  const proxyParam = c.req.query("hf-proxy");
7865
7866
  const boxParam = c.req.query(PREVIEW_PROXY_BOX_PARAM);
7866
7867
  const proxyBox = boxParam === void 0 ? void 0 : parsePreviewProxyBox(boxParam);
7867
- if (proxyBox === null || proxyBox && proxyParam === void 0) {
7868
+ const lightRequested = c.req.query(PREVIEW_PROXY_LIGHT_PARAM) !== void 0;
7869
+ if (proxyBox === null || proxyBox && proxyParam === void 0 || lightRequested && !proxyBox) {
7868
7870
  return c.text("not found", 404);
7869
7871
  }
7870
7872
  let proxyVariant;
@@ -7873,7 +7875,7 @@ ${etag}`;
7873
7875
  return c.text("not found", 404);
7874
7876
  }
7875
7877
  const facts = await probeAssetCodec(file, void 0, mediaCodecProbeCache);
7876
- const eligibility = decideMediaProxyEligibility(facts);
7878
+ const eligibility = decideMediaProxyEligibility(facts, lightRequested ? proxyBox : void 0);
7877
7879
  if (!eligibility.eligible) {
7878
7880
  return c.text(`media proxy unavailable: ${eligibility.reason}`, 422);
7879
7881
  }
@@ -9908,8 +9910,25 @@ function registerHistoryRoutes(api, adapter) {
9908
9910
  })
9909
9911
  );
9910
9912
  }
9913
+ function previewErrorPage(status) {
9914
+ const message = `The preview page could not be loaded (HTTP ${status}).`;
9915
+ return `<!doctype html><meta charset="utf-8"><script>window.${STUDIO_PREVIEW_ERRORS}=[${JSON.stringify(message)}]</script><p>${message}</p>`;
9916
+ }
9917
+ async function answerRefusedFrameWithPage(c, next) {
9918
+ await next();
9919
+ if (c.req.header("sec-fetch-dest") !== "iframe" || c.res.status < 400) return;
9920
+ const headers = new Headers(c.res.headers);
9921
+ headers.set("content-type", "text/html; charset=utf-8");
9922
+ headers.delete("content-length");
9923
+ c.res = new Response(previewErrorPage(c.res.status), {
9924
+ status: c.res.status,
9925
+ headers
9926
+ });
9927
+ }
9911
9928
  function createStudioApi(adapter) {
9912
9929
  const api = new Hono();
9930
+ api.use("/projects/:id/preview/*", answerRefusedFrameWithPage);
9931
+ api.use("/projects/:id/preview", answerRefusedFrameWithPage);
9913
9932
  api.use(async function answerProjectDirMissingAfterErrorHandlers(c, next) {
9914
9933
  const hostHeaders = new Headers(c.res.headers);
9915
9934
  await next();
@@ -9956,13 +9975,14 @@ function createStudioApi(adapter) {
9956
9975
  registerHistoryRoutes(api, adapter);
9957
9976
  return api;
9958
9977
  }
9959
- function duplicateElementInHtml(source, target, newId, at) {
9978
+ function duplicateElementInHtml(source, target, newId, at, fallbackDuration = 0) {
9960
9979
  const { document: document2, wrappedFragment } = parseSourceDocument(source);
9961
9980
  const element = findTargetElement(document2, target);
9962
9981
  if (!element || !element.parentElement) return { html: source, matched: false, newId: null };
9963
- const duration = numericAttribute(element, "data-duration");
9982
+ const duration = element.hasAttribute("data-duration") ? numericAttribute(element, "data-duration") : fallbackDuration;
9983
+ const start = numericAttribute(element, "data-start");
9964
9984
  const track = numericAttribute(element, "data-track-index") ?? 0;
9965
- if (duration === null || numericAttribute(element, "data-start") === null) {
9985
+ if (duration === null || start === null) {
9966
9986
  return { html: source, matched: false, newId: null };
9967
9987
  }
9968
9988
  const uniqueId = nextUniqueId(document2, newId);
@@ -9972,13 +9992,13 @@ function duplicateElementInHtml(source, target, newId, at) {
9972
9992
  clone.setAttribute("id", uniqueId);
9973
9993
  dedupeClonedCompositionId(document2, clone);
9974
9994
  stripStableIds(clone);
9975
- clone.setAttribute("data-start", String(at));
9995
+ moveElementStart(clone, start, at);
9976
9996
  element.parentElement.insertBefore(clone, element.nextSibling);
9977
9997
  const html = wrappedFragment ? document2.body.innerHTML || "" : document2.toString();
9978
9998
  return { html: ensureHfIds(html), matched: true, newId: uniqueId };
9979
9999
  }
9980
10000
  function rippleElements(document2, element, at, duration, track) {
9981
- for (const candidate of Array.from(document2.querySelectorAll("[data-start][data-duration]"))) {
10001
+ for (const candidate of Array.from(document2.querySelectorAll("[data-start]"))) {
9982
10002
  if (candidate === element || candidate.getAttribute("data-track-index") !== String(track)) {
9983
10003
  continue;
9984
10004
  }
@@ -9986,9 +10006,15 @@ function rippleElements(document2, element, at, duration, track) {
9986
10006
  if (start === null) continue;
9987
10007
  const metInsertionPoint = sameInstant(start, at);
9988
10008
  if (start < at && !metInsertionPoint) continue;
9989
- candidate.setAttribute("data-start", String((metInsertionPoint ? at : start) + duration));
10009
+ moveElementStart(candidate, start, (metInsertionPoint ? at : start) + duration);
9990
10010
  }
9991
10011
  }
10012
+ function moveElementStart(element, start, nextStart) {
10013
+ element.setAttribute("data-start", String(nextStart));
10014
+ if (!element.hasAttribute("data-end")) return;
10015
+ const end = numericAttribute(element, "data-end");
10016
+ if (end !== null) element.setAttribute("data-end", String(end + (nextStart - start)));
10017
+ }
9992
10018
  function stripStableIds(element) {
9993
10019
  element.removeAttribute("data-hf-id");
9994
10020
  for (const child of Array.from(element.querySelectorAll("[data-hf-id]"))) {