framefields 2.2.0-beta.2 → 2.2.0-beta.4

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 (261) hide show
  1. package/dist/audio/index.d.mts +4 -4
  2. package/dist/audio/index.mjs +10 -10
  3. package/dist/{audio-1QquqDJs.d.mts → audio-BvYmTu5T.d.mts} +3 -3
  4. package/dist/{audio-1QquqDJs.d.mts.map → audio-BvYmTu5T.d.mts.map} +1 -1
  5. package/dist/{audio-BYqbtdH8.mjs → audio-DMUr01vS.mjs} +3 -3
  6. package/dist/{audio-BYqbtdH8.mjs.map → audio-DMUr01vS.mjs.map} +1 -1
  7. package/dist/{dist-BLbXEC6V.mjs → dist-CT___nEU.mjs} +3 -5
  8. package/dist/dist-CT___nEU.mjs.map +1 -0
  9. package/dist/{dist-DQlYw4eG.mjs → dist-cjxDXQdx.mjs} +49 -48
  10. package/dist/dist-cjxDXQdx.mjs.map +1 -0
  11. package/dist/effects/index.d.mts +4 -4
  12. package/dist/effects/index.mjs +35 -35
  13. package/dist/{effects-DgpPr38s.mjs → effects-C06-AOge.mjs} +2 -2
  14. package/dist/{effects-DgpPr38s.mjs.map → effects-C06-AOge.mjs.map} +1 -1
  15. package/dist/fonts/index.mjs +2 -2
  16. package/dist/{fonts-DakFEiDw.mjs → fonts-C0UuLQvr.mjs} +2 -2
  17. package/dist/{fonts-DakFEiDw.mjs.map → fonts-C0UuLQvr.mjs.map} +1 -1
  18. package/dist/{gpu-AbcLcr1f.mjs → gpu-Du7GpVFW.mjs} +2 -2
  19. package/dist/{gpu-AbcLcr1f.mjs.map → gpu-Du7GpVFW.mjs.map} +1 -1
  20. package/dist/{index--1jnkoBj.d.mts → index-B-oUlLoO.d.mts} +7 -1
  21. package/dist/index-B-oUlLoO.d.mts.map +1 -0
  22. package/dist/{index-CaZfxDXx.d.mts → index-CdyE1tst.d.mts} +3 -3
  23. package/dist/{index-CaZfxDXx.d.mts.map → index-CdyE1tst.d.mts.map} +1 -1
  24. package/dist/{index-HyzpJrHe.d.mts → index-CwbszPDG.d.mts} +5 -5
  25. package/dist/index-CwbszPDG.d.mts.map +1 -0
  26. package/dist/{index-BqzHDFkU.d.mts → index-D-Iek5sq.d.mts} +3 -3
  27. package/dist/{index-BqzHDFkU.d.mts.map → index-D-Iek5sq.d.mts.map} +1 -1
  28. package/dist/{index-D6_KcajH.d.mts → index-DXfp_T-3.d.mts} +2 -2
  29. package/dist/{index-D6_KcajH.d.mts.map → index-DXfp_T-3.d.mts.map} +1 -1
  30. package/dist/{index-DgJIBC_N.d.mts → index-XdQPNJnq.d.mts} +3 -3
  31. package/dist/index-XdQPNJnq.d.mts.map +1 -0
  32. package/dist/index.d.mts +63 -63
  33. package/dist/index.d.mts.map +1 -1
  34. package/dist/index.mjs +49 -49
  35. package/dist/preview/index.d.mts +2 -2
  36. package/dist/preview/index.mjs +10 -10
  37. package/dist/{preview-BXu7FyvN.mjs → preview-M0TsUzC6.mjs} +2 -2
  38. package/dist/{preview-BXu7FyvN.mjs.map → preview-M0TsUzC6.mjs.map} +1 -1
  39. package/dist/preview-engine/audio.mjs +1 -1
  40. package/dist/preview-engine/chunk-2SJ4BBMT.mjs +1 -0
  41. package/dist/preview-engine/{chunk-N4OG2BHX.mjs → chunk-3T4LB4ZH.mjs} +1 -1
  42. package/dist/preview-engine/{chunk-FJH5A2PV.mjs → chunk-7B5S5D4N.mjs} +1 -1
  43. package/dist/preview-engine/{chunk-2W4BMOAZ.mjs → chunk-G4K6TLNA.mjs} +1 -1
  44. package/dist/preview-engine/{chunk-6RSP766E.mjs → chunk-HVCAOHNI.mjs} +1 -1
  45. package/dist/preview-engine/{chunk-5MSAA3DL.mjs → chunk-KBO6EX3M.mjs} +1 -1
  46. package/dist/preview-engine/{chunk-AKMCLVJ6.mjs → chunk-LQBDZSQD.mjs} +1 -1
  47. package/dist/preview-engine/chunk-NECOKNHA.mjs +174 -0
  48. package/dist/preview-engine/chunk-NIRW77QA.mjs +58 -0
  49. package/dist/preview-engine/{chunk-MOW55DX2.mjs → chunk-QXCY2ATH.mjs} +1 -1
  50. package/dist/preview-engine/chunk-XN56POGE.mjs +1 -0
  51. package/dist/preview-engine/{chunk-3NXJVSZY.mjs → chunk-ZTHWCQ2A.mjs} +2 -2
  52. package/dist/preview-engine/effects.mjs +1 -1
  53. package/dist/preview-engine/fonts.mjs +1 -1
  54. package/dist/preview-engine/framefields.mjs +1 -1
  55. package/dist/preview-engine/player.mjs +5 -5
  56. package/dist/preview-engine/{renderers-UHYNEWQD.mjs → renderers-3SRG77SC.mjs} +1 -1
  57. package/dist/preview-engine/{renderers-NYK2NDZJ.mjs → renderers-VFV5QWO3.mjs} +1 -1
  58. package/dist/preview-engine/{renderers-OZYUGZG7.mjs → renderers-VUL4HBX3.mjs} +2 -2
  59. package/dist/preview-engine/signals.mjs +1 -1
  60. package/dist/{program-Cc_2_YXn.mjs → program-DzknMiY0.mjs} +2 -2
  61. package/dist/{program-Cc_2_YXn.mjs.map → program-DzknMiY0.mjs.map} +1 -1
  62. package/dist/renderer/index.d.mts +2 -2
  63. package/dist/renderer/index.mjs +2 -2
  64. package/dist/renderer--IDyGdqT.mjs +5 -0
  65. package/dist/{renderer-CZ9gHx-4.mjs → renderer-0gY4IQhM.mjs} +2 -2
  66. package/dist/{renderer-CZ9gHx-4.mjs.map → renderer-0gY4IQhM.mjs.map} +1 -1
  67. package/dist/renderer-17K4tjid.mjs +5 -0
  68. package/dist/{renderer-Dqdega0-.mjs → renderer-1vhaKMeg.mjs} +56 -55
  69. package/dist/{renderer-Dqdega0-.mjs.map → renderer-1vhaKMeg.mjs.map} +1 -1
  70. package/dist/{renderer-Bfrwo_It.mjs → renderer-57ATc_mQ.mjs} +2 -2
  71. package/dist/{renderer-Bfrwo_It.mjs.map → renderer-57ATc_mQ.mjs.map} +1 -1
  72. package/dist/{renderer-CSfLMXN8.mjs → renderer-AF884a7T.mjs} +3 -3
  73. package/dist/{renderer-CSfLMXN8.mjs.map → renderer-AF884a7T.mjs.map} +1 -1
  74. package/dist/renderer-Ab9Ttn_m.mjs +5 -0
  75. package/dist/renderer-B-roDBBo.mjs +5 -0
  76. package/dist/renderer-B03uwoUX.mjs +5 -0
  77. package/dist/renderer-B3BI_7YJ.mjs +5 -0
  78. package/dist/{renderer-B4cnT3ce.mjs → renderer-BC8XOVl5.mjs} +3 -3
  79. package/dist/{renderer-B4cnT3ce.mjs.map → renderer-BC8XOVl5.mjs.map} +1 -1
  80. package/dist/renderer-BGD4lQ74.mjs +5 -0
  81. package/dist/renderer-BHXhYfeC.mjs +5 -0
  82. package/dist/{renderer-ClWgdN2v.mjs → renderer-BHskWZNG.mjs} +2 -2
  83. package/dist/{renderer-C4UqxwcT.mjs → renderer-BNqwn0gZ.mjs} +2 -2
  84. package/dist/{renderer-C4UqxwcT.mjs.map → renderer-BNqwn0gZ.mjs.map} +1 -1
  85. package/dist/renderer-BRsTIMFa.mjs +5 -0
  86. package/dist/{renderer-BO-7bYa5.d.mts → renderer-BT-_EoXw.d.mts} +2 -2
  87. package/dist/{renderer-BO-7bYa5.d.mts.map → renderer-BT-_EoXw.d.mts.map} +1 -1
  88. package/dist/{renderer-CB87_0vL.mjs → renderer-BbdZ0YHR.mjs} +3 -3
  89. package/dist/{renderer-CB87_0vL.mjs.map → renderer-BbdZ0YHR.mjs.map} +1 -1
  90. package/dist/{renderer-sHDPBywo.mjs → renderer-BeIUgp1r.mjs} +2 -2
  91. package/dist/{renderer-sHDPBywo.mjs.map → renderer-BeIUgp1r.mjs.map} +1 -1
  92. package/dist/{renderer-FgcNOe1R.mjs → renderer-Beg7FLt2.mjs} +5 -5
  93. package/dist/{renderer-FgcNOe1R.mjs.map → renderer-Beg7FLt2.mjs.map} +1 -1
  94. package/dist/{renderer-Cv1wmjhA.mjs → renderer-BerD3T-X.mjs} +2 -2
  95. package/dist/{renderer-Cv1wmjhA.mjs.map → renderer-BerD3T-X.mjs.map} +1 -1
  96. package/dist/{renderer-CK0u3Psf.mjs → renderer-BiwIh_w4.mjs} +3 -3
  97. package/dist/{renderer-CK0u3Psf.mjs.map → renderer-BiwIh_w4.mjs.map} +1 -1
  98. package/dist/renderer-BjMTtYZw.mjs +5 -0
  99. package/dist/{renderer-dwTzrQ2G.mjs → renderer-BmGPTWwV.mjs} +3 -3
  100. package/dist/{renderer-dwTzrQ2G.mjs.map → renderer-BmGPTWwV.mjs.map} +1 -1
  101. package/dist/{renderer-DfSRmz7q.mjs → renderer-Bn2eQE-t.mjs} +3 -3
  102. package/dist/{renderer-DfSRmz7q.mjs.map → renderer-Bn2eQE-t.mjs.map} +1 -1
  103. package/dist/renderer-BoCh3Yts.mjs +5 -0
  104. package/dist/renderer-BqPbR8c4.mjs +5 -0
  105. package/dist/{renderer-BPMywsr4.mjs → renderer-Br6KyRO_.mjs} +3 -3
  106. package/dist/{renderer-BPMywsr4.mjs.map → renderer-Br6KyRO_.mjs.map} +1 -1
  107. package/dist/{renderer-DU3216cx.mjs → renderer-BteUC_7n.mjs} +3 -3
  108. package/dist/{renderer-DU3216cx.mjs.map → renderer-BteUC_7n.mjs.map} +1 -1
  109. package/dist/{renderer-DwCg5pXn.mjs → renderer-Bvx56GR6.mjs} +2 -2
  110. package/dist/{renderer-DwCg5pXn.mjs.map → renderer-Bvx56GR6.mjs.map} +1 -1
  111. package/dist/renderer-Bxa4SDm9.mjs +3 -0
  112. package/dist/{renderer-4GYrnTfw.mjs → renderer-BzDjy1_x.mjs} +2 -2
  113. package/dist/{renderer-4GYrnTfw.mjs.map → renderer-BzDjy1_x.mjs.map} +1 -1
  114. package/dist/renderer-C4Da2I1-.mjs +5 -0
  115. package/dist/{renderer-CD38wGmN.mjs → renderer-C6md3msE.mjs} +2 -2
  116. package/dist/{renderer-CD38wGmN.mjs.map → renderer-C6md3msE.mjs.map} +1 -1
  117. package/dist/{renderer-CHkqgIOL.mjs → renderer-C8uKdelk.mjs} +2 -2
  118. package/dist/{renderer-CHkqgIOL.mjs.map → renderer-C8uKdelk.mjs.map} +1 -1
  119. package/dist/renderer-C93X6dgl.mjs +5 -0
  120. package/dist/{renderer-CqT2vxa4.mjs → renderer-CE7fwGgw.mjs} +29 -12
  121. package/dist/renderer-CE7fwGgw.mjs.map +1 -0
  122. package/dist/{renderer-CciB_sav.mjs → renderer-CJB9nU1x.mjs} +3 -3
  123. package/dist/{renderer-CciB_sav.mjs.map → renderer-CJB9nU1x.mjs.map} +1 -1
  124. package/dist/renderer-CMAwFfGx.mjs +6 -0
  125. package/dist/{renderer-CPW9o3Lc.mjs → renderer-CMT4QcpV.mjs} +3 -3
  126. package/dist/{renderer-CPW9o3Lc.mjs.map → renderer-CMT4QcpV.mjs.map} +1 -1
  127. package/dist/renderer-CRXeSuX2.mjs +5 -0
  128. package/dist/renderer-CSp6WYBN.mjs +5 -0
  129. package/dist/renderer-CUXX7HTL.mjs +5 -0
  130. package/dist/renderer-CUgThpka.mjs +5 -0
  131. package/dist/{renderer-BKd2nRnO.mjs → renderer-CWBHVCvA.mjs} +2 -2
  132. package/dist/{renderer-BKd2nRnO.mjs.map → renderer-CWBHVCvA.mjs.map} +1 -1
  133. package/dist/{renderer-B5PFBOjv.mjs → renderer-Cce2fgpX.mjs} +3 -3
  134. package/dist/{renderer-B5PFBOjv.mjs.map → renderer-Cce2fgpX.mjs.map} +1 -1
  135. package/dist/renderer-CeVtufiT.mjs +5 -0
  136. package/dist/{renderer-egZPy7vq.mjs → renderer-CebB0v1y.mjs} +2 -2
  137. package/dist/{renderer-egZPy7vq.mjs.map → renderer-CebB0v1y.mjs.map} +1 -1
  138. package/dist/renderer-CespkZUk.mjs +5 -0
  139. package/dist/{renderer-Dyh8c41v.mjs → renderer-CeyAgJnw.mjs} +2 -2
  140. package/dist/{renderer-CGZqCmf2.mjs → renderer-CrABA3lB.mjs} +2 -2
  141. package/dist/{renderer-CGZqCmf2.mjs.map → renderer-CrABA3lB.mjs.map} +1 -1
  142. package/dist/{renderer-DU6i7shO.mjs → renderer-CuVPo-wP.mjs} +2 -2
  143. package/dist/{renderer-DU6i7shO.mjs.map → renderer-CuVPo-wP.mjs.map} +1 -1
  144. package/dist/{renderer-DEQ09sg7.mjs → renderer-CursFKUf.mjs} +2 -2
  145. package/dist/{renderer-DEQ09sg7.mjs.map → renderer-CursFKUf.mjs.map} +1 -1
  146. package/dist/{renderer-DT3QVVht.mjs → renderer-D-vRKssW.mjs} +2 -2
  147. package/dist/{renderer-DT3QVVht.mjs.map → renderer-D-vRKssW.mjs.map} +1 -1
  148. package/dist/{renderer-DqhZTIiC.mjs → renderer-D1Cm21eq.mjs} +2 -2
  149. package/dist/{renderer-DqhZTIiC.mjs.map → renderer-D1Cm21eq.mjs.map} +1 -1
  150. package/dist/renderer-D1l47xhL.mjs +5 -0
  151. package/dist/{renderer-PbJk25JW.mjs → renderer-D8thCpS7.mjs} +3 -3
  152. package/dist/{renderer-PbJk25JW.mjs.map → renderer-D8thCpS7.mjs.map} +1 -1
  153. package/dist/{renderer-BNcsS03m.mjs → renderer-DD8napek.mjs} +2 -2
  154. package/dist/{renderer-BNcsS03m.mjs.map → renderer-DD8napek.mjs.map} +1 -1
  155. package/dist/renderer-DDuG18J8.mjs +5 -0
  156. package/dist/{renderer-gwV6hyYm.mjs → renderer-DEuIwr-t.mjs} +2 -2
  157. package/dist/{renderer-gwV6hyYm.mjs.map → renderer-DEuIwr-t.mjs.map} +1 -1
  158. package/dist/renderer-DFhrFSMn.mjs +5 -0
  159. package/dist/{renderer-DlqDnh-8.mjs → renderer-DHGTzype.mjs} +2 -2
  160. package/dist/{renderer-DlqDnh-8.mjs.map → renderer-DHGTzype.mjs.map} +1 -1
  161. package/dist/{renderer-DkGODUgE.mjs → renderer-DJfFc-XW.mjs} +3 -3
  162. package/dist/{renderer-DkGODUgE.mjs.map → renderer-DJfFc-XW.mjs.map} +1 -1
  163. package/dist/renderer-DO48vQ7Y.mjs +5 -0
  164. package/dist/renderer-DTC39B_n.mjs +5 -0
  165. package/dist/{renderer-L7UTxwZT.mjs → renderer-DXqIslFk.mjs} +2 -2
  166. package/dist/{renderer-L7UTxwZT.mjs.map → renderer-DXqIslFk.mjs.map} +1 -1
  167. package/dist/{renderer-C2eBC0FB.mjs → renderer-DZXbgVMK.mjs} +3 -3
  168. package/dist/{renderer-C2eBC0FB.mjs.map → renderer-DZXbgVMK.mjs.map} +1 -1
  169. package/dist/{renderer-Cxh7j423.mjs → renderer-Db3JIF1K.mjs} +3 -3
  170. package/dist/{renderer-Cxh7j423.mjs.map → renderer-Db3JIF1K.mjs.map} +1 -1
  171. package/dist/renderer-DbyU3hNF.mjs +5 -0
  172. package/dist/renderer-DftVpmfu.mjs +5 -0
  173. package/dist/renderer-Dj5jm63K.mjs +5 -0
  174. package/dist/renderer-Dju57ZaF.mjs +5 -0
  175. package/dist/renderer-Dn8TQCw7.mjs +5 -0
  176. package/dist/{renderer-C6u-XrH-.mjs → renderer-DpW_LxLO.mjs} +3 -3
  177. package/dist/{renderer-C6u-XrH-.mjs.map → renderer-DpW_LxLO.mjs.map} +1 -1
  178. package/dist/{renderer-CSoyJ8GH.mjs → renderer-DqdhsSwS.mjs} +2 -2
  179. package/dist/{renderer-CSoyJ8GH.mjs.map → renderer-DqdhsSwS.mjs.map} +1 -1
  180. package/dist/{renderer-2DjggBBS.mjs → renderer-DtgMsjyL.mjs} +2 -2
  181. package/dist/{renderer-2DjggBBS.mjs.map → renderer-DtgMsjyL.mjs.map} +1 -1
  182. package/dist/{renderer-DppnY7RT.mjs → renderer-DupsdRIw.mjs} +3 -3
  183. package/dist/{renderer-DppnY7RT.mjs.map → renderer-DupsdRIw.mjs.map} +1 -1
  184. package/dist/{renderer-BN0CzoG_.mjs → renderer-DvFaC_-7.mjs} +2 -2
  185. package/dist/{renderer-BN0CzoG_.mjs.map → renderer-DvFaC_-7.mjs.map} +1 -1
  186. package/dist/renderer-ETF46K0D.mjs +5 -0
  187. package/dist/{renderer-dj3f8cMg.mjs → renderer-EemDpvv3.mjs} +3 -3
  188. package/dist/{renderer-dj3f8cMg.mjs.map → renderer-EemDpvv3.mjs.map} +1 -1
  189. package/dist/{renderer-n2kYIGtb.mjs → renderer-KnCcN_Nz.mjs} +2 -2
  190. package/dist/{renderer-n2kYIGtb.mjs.map → renderer-KnCcN_Nz.mjs.map} +1 -1
  191. package/dist/{renderer-scbJx-Dx.mjs → renderer-PKQNH21k.mjs} +2 -2
  192. package/dist/{renderer-CO4theVJ.mjs → renderer-YbaCzPcG.mjs} +2 -2
  193. package/dist/{renderer-BhxQzrHF.mjs → renderer-aArb4RwJ.mjs} +2 -2
  194. package/dist/{renderer-BhxQzrHF.mjs.map → renderer-aArb4RwJ.mjs.map} +1 -1
  195. package/dist/renderer-azYzWGC3.mjs +5 -0
  196. package/dist/renderer-dxNoRW59.mjs +5 -0
  197. package/dist/renderer-fdfelx_I.mjs +5 -0
  198. package/dist/{renderer-BEzUirF0.mjs → renderer-id8TbKBY.mjs} +2 -2
  199. package/dist/{renderer-BEzUirF0.mjs.map → renderer-id8TbKBY.mjs.map} +1 -1
  200. package/dist/{renderer-Dnm_SVy6.mjs → renderer-jYxN4mHn.mjs} +3 -3
  201. package/dist/{renderer-Dnm_SVy6.mjs.map → renderer-jYxN4mHn.mjs.map} +1 -1
  202. package/dist/{renderer-lXmtdrdI.mjs → renderer-jqByPgkD.mjs} +2 -2
  203. package/dist/{renderer-lXmtdrdI.mjs.map → renderer-jqByPgkD.mjs.map} +1 -1
  204. package/dist/{renderer-DRpIQFAK.mjs → renderer-p_C_T9Kn.mjs} +2 -2
  205. package/dist/{renderer-DRpIQFAK.mjs.map → renderer-p_C_T9Kn.mjs.map} +1 -1
  206. package/dist/renderer-snwEKwMw.mjs +5 -0
  207. package/dist/{renderer-D0enmulV.mjs → renderer-u8ynJtAC.mjs} +2 -2
  208. package/dist/{renderer-D0enmulV.mjs.map → renderer-u8ynJtAC.mjs.map} +1 -1
  209. package/dist/{renderers-CP8CFWDs-B8HIr3kj.mjs → renderers-CP8CFWDs-BA-4l6By.mjs} +2 -2
  210. package/dist/{renderers-CP8CFWDs-B8HIr3kj.mjs.map → renderers-CP8CFWDs-BA-4l6By.mjs.map} +1 -1
  211. package/dist/signals/index.d.mts +5 -5
  212. package/dist/signals/index.mjs +4 -4
  213. package/package.json +58 -58
  214. package/dist/dist-BLbXEC6V.mjs.map +0 -1
  215. package/dist/dist-DQlYw4eG.mjs.map +0 -1
  216. package/dist/index--1jnkoBj.d.mts.map +0 -1
  217. package/dist/index-DgJIBC_N.d.mts.map +0 -1
  218. package/dist/index-HyzpJrHe.d.mts.map +0 -1
  219. package/dist/preview-engine/chunk-4VOHF3FF.mjs +0 -1
  220. package/dist/preview-engine/chunk-ATLWPS6N.mjs +0 -1
  221. package/dist/preview-engine/chunk-HCZCEOV5.mjs +0 -174
  222. package/dist/preview-engine/chunk-HYBAPT6I.mjs +0 -1
  223. package/dist/preview-engine/chunk-XETMNJVV.mjs +0 -58
  224. package/dist/renderer-9ETXaINw.mjs +0 -5
  225. package/dist/renderer-B3MVDN_e.mjs +0 -5
  226. package/dist/renderer-B6iUuWcx.mjs +0 -6
  227. package/dist/renderer-B8IdU-7S.mjs +0 -5
  228. package/dist/renderer-BEGJCxuL.mjs +0 -5
  229. package/dist/renderer-BLAkNFx7.mjs +0 -5
  230. package/dist/renderer-BVNhv2ft.mjs +0 -5
  231. package/dist/renderer-BaXTEIe0.mjs +0 -5
  232. package/dist/renderer-BjeA7s36.mjs +0 -5
  233. package/dist/renderer-BkV_xpMb.mjs +0 -3
  234. package/dist/renderer-BtGNxEay.mjs +0 -5
  235. package/dist/renderer-BvZg2RJG.mjs +0 -5
  236. package/dist/renderer-CLW6tUUn.mjs +0 -5
  237. package/dist/renderer-CS-ojgJk.mjs +0 -5
  238. package/dist/renderer-CUQtKECw.mjs +0 -5
  239. package/dist/renderer-CV-l8wMq.mjs +0 -5
  240. package/dist/renderer-CV7_ALA5.mjs +0 -5
  241. package/dist/renderer-CVR6T6Lp.mjs +0 -5
  242. package/dist/renderer-CqT2vxa4.mjs.map +0 -1
  243. package/dist/renderer-CtUF95UW.mjs +0 -5
  244. package/dist/renderer-D8ymQoTB.mjs +0 -5
  245. package/dist/renderer-D9x3UE1Y.mjs +0 -5
  246. package/dist/renderer-DAEXqa2Q.mjs +0 -5
  247. package/dist/renderer-DDhU9Goq.mjs +0 -5
  248. package/dist/renderer-DcCKath2.mjs +0 -5
  249. package/dist/renderer-DiBphLzn.mjs +0 -5
  250. package/dist/renderer-Diq9Z7gZ.mjs +0 -5
  251. package/dist/renderer-DjZiO7iA.mjs +0 -5
  252. package/dist/renderer-Dtj6o-74.mjs +0 -5
  253. package/dist/renderer-Duaam6bJ.mjs +0 -5
  254. package/dist/renderer-FHqZe3K1.mjs +0 -5
  255. package/dist/renderer-FTKfOejk.mjs +0 -5
  256. package/dist/renderer-LmbkN82X.mjs +0 -5
  257. package/dist/renderer-SDspl6p-.mjs +0 -5
  258. package/dist/renderer-SWVUDypd.mjs +0 -5
  259. package/dist/renderer-WhpTBwDM.mjs +0 -5
  260. package/dist/renderer-WrpQEVdv.mjs +0 -5
  261. package/dist/renderer-r4ney0FZ.mjs +0 -5
@@ -1 +1 @@
1
- {"version":3,"file":"renderer-Dqdega0-.mjs","names":["resolve","resolve","HeadlessWebGPURenderer","fs","fs"],"sources":["../../renderer/dist/bootstrap-mediabunny--TDh3Bij.mjs","../../renderer/dist/headless-webgpu-renderer-BTo2uZHD.mjs","../../renderer/dist/index.mjs","../src/renderer/framegrid.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\nimport { preloadCompositionFonts } from \"@framefields/renderers\";\nimport pino from \"pino\";\nimport * as webcodecs from \"@napi-rs/webcodecs\";\nimport { VideoFrame } from \"@napi-rs/webcodecs\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport { audioRegistry, registerWebGPURenderer } from \"@framefields/node-sdk\";\nimport { registerMediabunnyServer } from \"@mediabunny/server\";\n\n//#region src/logger.ts\nconst rendererLogger = pino({\n\tlevel: typeof process !== \"undefined\" && process.env?.LOG_LEVEL || \"info\",\n\ttimestamp: pino.stdTimeFunctions.isoTime,\n\tbase: { component: \"renderer\" }\n});\n\n//#endregion\n//#region src/asset-preloader.ts\n/**\n* Preloads only the fonts (and emoji) a VirtualMediaData tree's text uses, so\n* typography renders correctly on Node.js without loading its media. Shared\n* with the browser preview; emoji need a font set with\n* `FontManager.registerEmojiFont()`.\n*/\nasync function preloadFonts(media, device = null) {\n\tif (!media) return;\n\tawait preloadCompositionFonts(media, device, (err, what) => rendererLogger.error(err, `[HeadlessMediaRenderer] Failed to preload ${what}`));\n}\n\n//#endregion\n//#region src/dma-staging-ring.ts\n/**\n* Pipelined Asynchronous DMA Staging Ring for WebGPU.\n*\n* Implements double-buffered (or N-buffered) GPU staging buffers to overlap\n* GPU render passes with asynchronous DMA host transfers and WebCodecs hardware encoding.\n* Eliminates GPU stalls by allowing Frame i+1 to execute on the GPU while Frame i\n* is asynchronously mapped and consumed by the hardware video encoder.\n*/\nvar DmaStagingRing = class {\n\twidth;\n\theight;\n\tcapacity;\n\tbytesPerRow;\n\tunpaddedBytesPerRow;\n\tbufferSize;\n\tformat;\n\tdevice;\n\tslots;\n\tisDestroyed = false;\n\tconstructor(device, options) {\n\t\tthis.device = device;\n\t\tthis.width = options.width;\n\t\tthis.height = options.height;\n\t\tthis.capacity = Math.max(2, options.capacity ?? 2);\n\t\tthis.format = options.format ?? \"rgba8unorm\";\n\t\tthis.unpaddedBytesPerRow = this.width * 4;\n\t\tconst rowAlignment = 256;\n\t\tthis.bytesPerRow = Math.ceil(this.unpaddedBytesPerRow / rowAlignment) * rowAlignment;\n\t\tthis.bufferSize = this.bytesPerRow * this.height;\n\t\tthis.slots = [];\n\t\tfor (let i = 0; i < this.capacity; i++) {\n\t\t\tconst buffer = device.createBuffer({\n\t\t\t\tsize: this.bufferSize,\n\t\t\t\tusage: GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST\n\t\t\t});\n\t\t\tthis.slots.push({\n\t\t\t\tindex: i,\n\t\t\t\tbuffer,\n\t\t\t\tstatus: \"idle\",\n\t\t\t\tinFlightFrame: null,\n\t\t\t\tmapPromise: null\n\t\t\t});\n\t\t}\n\t}\n\t/**\n\t* Prepares the staging buffer slot for writing by ensuring any prior mapping\n\t* from a previous cycle has been completed and unmapped.\n\t*/\n\tasync prepareSlot(frameIndex) {\n\t\tthis.checkDestroyed();\n\t\tconst slot = this.slots[frameIndex % this.capacity];\n\t\tif (!slot) return;\n\t\tif (slot.status === \"mapping\" && slot.mapPromise) await slot.mapPromise;\n\t\tif (slot.status === \"mapped\") {\n\t\t\tslot.buffer.unmap();\n\t\t\tslot.status = \"idle\";\n\t\t\tslot.inFlightFrame = null;\n\t\t\tslot.mapPromise = null;\n\t\t}\n\t}\n\t/**\n\t* Records a GPU-to-buffer DMA copy command into the provided command encoder.\n\t*/\n\tstageTexture(encoder, texture, frameIndex) {\n\t\tthis.checkDestroyed();\n\t\tconst slot = this.slots[frameIndex % this.capacity];\n\t\tif (!slot) throw new Error(`Invalid slot index for frame ${frameIndex}`);\n\t\tif (slot.status === \"mapped\" || slot.status === \"mapping\") throw new Error(`Staging buffer slot ${slot.index} is busy (status: ${slot.status}) for frame ${frameIndex}. Call prepareSlot() before staging.`);\n\t\tencoder.copyTextureToBuffer({ texture }, {\n\t\t\tbuffer: slot.buffer,\n\t\t\tbytesPerRow: this.bytesPerRow\n\t\t}, [this.width, this.height]);\n\t\tslot.status = \"rendering\";\n\t\tslot.inFlightFrame = frameIndex;\n\t}\n\t/**\n\t* Initiates asynchronous DMA mapping on the slot for the specified frame.\n\t* Must be called immediately after submitting the command encoder to the device queue.\n\t*/\n\tscheduleMap(frameIndex) {\n\t\tthis.checkDestroyed();\n\t\tconst slot = this.slots[frameIndex % this.capacity];\n\t\tif (!slot) throw new Error(`Invalid slot index for frame ${frameIndex}`);\n\t\tslot.status = \"mapping\";\n\t\tconst mapPromise = slot.buffer.mapAsync(GPUMapMode.READ).then(() => {\n\t\t\tslot.status = \"mapped\";\n\t\t});\n\t\tslot.mapPromise = mapPromise;\n\t\treturn mapPromise;\n\t}\n\t/**\n\t* Awaits asynchronous mapping and extracts pixels into a tightly packed Uint8Array.\n\t* The slot remains in the \"mapped\" state until releaseFrame() is called.\n\t*/\n\tasync readFramePixels(frameIndex) {\n\t\tthis.checkDestroyed();\n\t\tconst slot = this.slots[frameIndex % this.capacity];\n\t\tif (!slot) throw new Error(`Invalid slot index for frame ${frameIndex}`);\n\t\tif (slot.mapPromise) await slot.mapPromise;\n\t\tif (slot.status !== \"mapped\") throw new Error(`Staging slot ${slot.index} is not mapped (status: ${slot.status}) for frame ${frameIndex}`);\n\t\tconst mappedRange = slot.buffer.getMappedRange();\n\t\tconst sourceView = new Uint8Array(mappedRange);\n\t\tconst output = new Uint8Array(this.unpaddedBytesPerRow * this.height);\n\t\tif (this.bytesPerRow === this.unpaddedBytesPerRow) output.set(sourceView);\n\t\telse for (let y = 0; y < this.height; y++) {\n\t\t\tconst srcOffset = y * this.bytesPerRow;\n\t\t\tconst dstOffset = y * this.unpaddedBytesPerRow;\n\t\t\toutput.set(sourceView.subarray(srcOffset, srcOffset + this.unpaddedBytesPerRow), dstOffset);\n\t\t}\n\t\treturn output;\n\t}\n\t/**\n\t* Awaits asynchronous mapping, extracts pixels, and immediately unmaps the staging buffer,\n\t* returning the slot to \"idle\" state so it can be reused immediately.\n\t*/\n\tasync readAndReleaseFrame(frameIndex) {\n\t\tconst pixels = await this.readFramePixels(frameIndex);\n\t\tthis.releaseFrame(frameIndex);\n\t\treturn pixels;\n\t}\n\t/**\n\t* Directly reads the mapped staging buffer into a WebCodecs VideoFrame,\n\t* bypassing redundant intermediate JS allocations when row pitches align,\n\t* and immediately unmaps the buffer.\n\t*/\n\tasync readFrameToVideoFrame(frameIndex, timestampUs, colorSpace, inspect) {\n\t\tthis.checkDestroyed();\n\t\tconst slot = this.slots[frameIndex % this.capacity];\n\t\tif (!slot) throw new Error(`Invalid slot index for frame ${frameIndex}`);\n\t\tif (slot.mapPromise) await slot.mapPromise;\n\t\tif (slot.status !== \"mapped\") throw new Error(`Staging slot ${slot.index} is not mapped (status: ${slot.status}) for frame ${frameIndex}`);\n\t\tconst mappedRange = slot.buffer.getMappedRange();\n\t\tconst sourceView = new Uint8Array(mappedRange);\n\t\tlet pixelData;\n\t\tif (this.bytesPerRow === this.unpaddedBytesPerRow) pixelData = sourceView;\n\t\telse {\n\t\t\tpixelData = new Uint8Array(this.unpaddedBytesPerRow * this.height);\n\t\t\tfor (let y = 0; y < this.height; y++) {\n\t\t\t\tconst srcOffset = y * this.bytesPerRow;\n\t\t\t\tconst dstOffset = y * this.unpaddedBytesPerRow;\n\t\t\t\tpixelData.set(sourceView.subarray(srcOffset, srcOffset + this.unpaddedBytesPerRow), dstOffset);\n\t\t\t}\n\t\t}\n\t\tinspect?.(pixelData);\n\t\tconst vf = new VideoFrame(pixelData, {\n\t\t\tformat: \"RGBA\",\n\t\t\tcodedWidth: this.width,\n\t\t\tcodedHeight: this.height,\n\t\t\ttimestamp: timestampUs,\n\t\t\tcolorSpace: {\n\t\t\t\tprimaries: colorSpace?.primaries ?? \"bt709\",\n\t\t\t\ttransfer: colorSpace?.transfer ?? \"bt709\",\n\t\t\t\tmatrix: colorSpace?.matrix ?? \"bt709\",\n\t\t\t\tfullRange: colorSpace?.fullRange ?? false\n\t\t\t}\n\t\t});\n\t\tthis.releaseFrame(frameIndex);\n\t\treturn vf;\n\t}\n\t/**\n\t* Unmaps the staging buffer for the specified frame and marks the slot idle.\n\t*/\n\treleaseFrame(frameIndex) {\n\t\tconst slot = this.slots[frameIndex % this.capacity];\n\t\tif (!slot) return;\n\t\tif (slot.status === \"mapped\") {\n\t\t\ttry {\n\t\t\t\tslot.buffer.unmap();\n\t\t\t} catch (_) {}\n\t\t\tslot.status = \"idle\";\n\t\t\tslot.inFlightFrame = null;\n\t\t\tslot.mapPromise = null;\n\t\t}\n\t}\n\t/**\n\t* Returns current status info for each slot in the ring.\n\t*/\n\tgetSlotInfos() {\n\t\treturn this.slots.map((slot) => ({\n\t\t\tindex: slot.index,\n\t\t\tstatus: slot.status,\n\t\t\tinFlightFrame: slot.inFlightFrame\n\t\t}));\n\t}\n\t/**\n\t* Destroys all staging buffers and releases resources.\n\t*/\n\tdestroy() {\n\t\tif (this.isDestroyed) return;\n\t\tthis.isDestroyed = true;\n\t\tfor (const slot of this.slots) {\n\t\t\tif (slot.status === \"mapped\") try {\n\t\t\t\tslot.buffer.unmap();\n\t\t\t} catch (_) {}\n\t\t\tslot.status = \"idle\";\n\t\t\tslot.inFlightFrame = null;\n\t\t\tslot.mapPromise = null;\n\t\t}\n\t\tthis.slots.length = 0;\n\t}\n\tcheckDestroyed() {\n\t\tif (this.isDestroyed) throw new Error(\"DmaStagingRing has been destroyed\");\n\t}\n};\n\n//#endregion\n//#region src/generated/node-renderers.ts\nconst BUILTIN_NODE_RENDERERS = [\n\t{\n\t\tpackageName: \"@framefields/node-lut\",\n\t\tops: [\"ApplyLUT\"],\n\t\tload: () => import(\"@framefields/node-lut/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-audio-compressor\",\n\t\tops: [\"AudioCompressor\"],\n\t\tload: () => import(\"@framefields/node-audio-compressor/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-audio-delay\",\n\t\tops: [\"AudioDelay\"],\n\t\tload: () => import(\"@framefields/node-audio-delay/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-audio-fade\",\n\t\tops: [\"AudioFade\"],\n\t\tload: () => import(\"@framefields/node-audio-fade/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-audio-noise-gate\",\n\t\tops: [\"AudioNoiseGate\"],\n\t\tload: () => import(\"@framefields/node-audio-noise-gate/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-audio-parametric-eq\",\n\t\tops: [\"AudioParametricEq\"],\n\t\tload: () => import(\"@framefields/node-audio-parametric-eq/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-audio-reverb\",\n\t\tops: [\"AudioReverb\"],\n\t\tload: () => import(\"@framefields/node-audio-reverb/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-audio-signal-extractor\",\n\t\tops: [\"AudioSignalExtractor\"],\n\t\tload: () => import(\"@framefields/node-audio-signal-extractor/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-blur\",\n\t\tops: [\"Blur\"],\n\t\tload: () => import(\"@framefields/node-blur/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-camera-parallax-3d\",\n\t\tops: [\"CameraParallax3D\"],\n\t\tload: () => import(\"@framefields/node-camera-parallax-3d/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-canvas-generator\",\n\t\tops: [\"CanvasGenerator\"],\n\t\tload: () => import(\"@framefields/node-canvas-generator/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-channel-merger\",\n\t\tops: [\"ChannelMerger\"],\n\t\tload: () => import(\"@framefields/node-channel-merger/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-channel-splitter\",\n\t\tops: [\"ChannelSplitter\"],\n\t\tload: () => import(\"@framefields/node-channel-splitter/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-color-balance\",\n\t\tops: [\"ColorBalance\"],\n\t\tload: () => import(\"@framefields/node-color-balance/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-colorkey\",\n\t\tops: [\"ColorKey\"],\n\t\tload: () => import(\"@framefields/node-colorkey/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-compositor\",\n\t\tops: [\"Compositor\"],\n\t\tload: () => import(\"@framefields/node-compositor/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-corner-pin\",\n\t\tops: [\"CornerPin\"],\n\t\tload: () => import(\"@framefields/node-corner-pin/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-crop\",\n\t\tops: [\"Crop\"],\n\t\tload: () => import(\"@framefields/node-crop/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-curves\",\n\t\tops: [\"Curves\"],\n\t\tload: () => import(\"@framefields/node-curves/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-deflicker\",\n\t\tops: [\"TemporalDeflicker\", \"Deflicker\"],\n\t\tload: () => import(\"@framefields/node-deflicker/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-displacement-map\",\n\t\tops: [\"DisplacementMap\"],\n\t\tload: () => import(\"@framefields/node-displacement-map/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-extract-frame\",\n\t\tops: [\"ExtractFrame\"],\n\t\tload: () => import(\"@framefields/node-extract-frame/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-extract-lut\",\n\t\tops: [\"ExtractLUT\"],\n\t\tload: () => import(\"@framefields/node-extract-lut/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-film-grain\",\n\t\tops: [\"FilmGrain\"],\n\t\tload: () => import(\"@framefields/node-film-grain/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-flip\",\n\t\tops: [\"Flip\"],\n\t\tload: () => import(\"@framefields/node-flip/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-gradient-map\",\n\t\tops: [\"GradientMap\"],\n\t\tload: () => import(\"@framefields/node-gradient-map/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-halftone-screen\",\n\t\tops: [\"HalftoneScreen\"],\n\t\tload: () => import(\"@framefields/node-halftone-screen/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-high-pass\",\n\t\tops: [\"HighPass\"],\n\t\tload: () => import(\"@framefields/node-high-pass/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-kenburns\",\n\t\tops: [\"KenBurns\"],\n\t\tload: () => import(\"@framefields/node-kenburns/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-layer-style\",\n\t\tops: [\"LayerStyle\"],\n\t\tload: () => import(\"@framefields/node-layer-style/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-levels\",\n\t\tops: [\"Levels\"],\n\t\tload: () => import(\"@framefields/node-levels/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-liquify\",\n\t\tops: [\"Liquify\"],\n\t\tload: () => import(\"@framefields/node-liquify/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-mask-math\",\n\t\tops: [\"MaskMath\"],\n\t\tload: () => import(\"@framefields/node-mask-math/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-mesh-warp\",\n\t\tops: [\"MeshWarp\"],\n\t\tload: () => import(\"@framefields/node-mesh-warp/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-modulate\",\n\t\tops: [\"Modulate\"],\n\t\tload: () => import(\"@framefields/node-modulate/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-noise-generator\",\n\t\tops: [\"NoiseGenerator\"],\n\t\tload: () => import(\"@framefields/node-noise-generator/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-paint\",\n\t\tops: [\"Paint\"],\n\t\tload: () => import(\"@framefields/node-paint/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-patch-heal\",\n\t\tops: [\"PatchHeal\"],\n\t\tload: () => import(\"@framefields/node-patch-heal/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-refine-edge\",\n\t\tops: [\"RefineEdge\"],\n\t\tload: () => import(\"@framefields/node-refine-edge/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-refraction-caustics\",\n\t\tops: [\"RefractionCaustics3D\"],\n\t\tload: () => import(\"@framefields/node-refraction-caustics/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-relight-3d\",\n\t\tops: [\"Relight3D\"],\n\t\tload: () => import(\"@framefields/node-relight-3d/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-resizer-scaler\",\n\t\tops: [\"ResizerScaler\"],\n\t\tload: () => import(\"@framefields/node-resizer-scaler/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-rotate\",\n\t\tops: [\"Rotate\"],\n\t\tload: () => import(\"@framefields/node-rotate/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-selective-color\",\n\t\tops: [\"SelectiveColor\"],\n\t\tload: () => import(\"@framefields/node-selective-color/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-shadows-highlights\",\n\t\tops: [\"ShadowsHighlights\"],\n\t\tload: () => import(\"@framefields/node-shadows-highlights/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-shape-generator\",\n\t\tops: [\"ShapeGenerator\"],\n\t\tload: () => import(\"@framefields/node-shape-generator/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-signal-gate\",\n\t\tops: [\"SignalGate\"],\n\t\tload: () => import(\"@framefields/node-signal-gate/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-stereo-panning\",\n\t\tops: [\"StereoPanning\"],\n\t\tload: () => import(\"@framefields/node-stereo-panning/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-tile-offset\",\n\t\tops: [\"TileOffset\"],\n\t\tload: () => import(\"@framefields/node-tile-offset/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-unsharp-mask\",\n\t\tops: [\"UnsharpMask\"],\n\t\tload: () => import(\"@framefields/node-unsharp-mask/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-vignette\",\n\t\tops: [\"Vignette\"],\n\t\tload: () => import(\"@framefields/node-vignette/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-vision\",\n\t\tops: [\"Vision\"],\n\t\tload: () => import(\"@framefields/node-vision/renderer\")\n\t}\n];\n\n//#endregion\n//#region src/node-manifest.ts\n/**\n* The `framefields` block of a node package's `package.json`.\n*\n* This is the single declaration of a node's op: renderer discovery, the\n* effects generator (`scripts/generate-effects.ts`) and the skill catalog all\n* read it from here. There is deliberately no fallback that derives an op from\n* the package name. See `spec/sync-node.md` §5.1.\n*/\nconst NODE_KINDS = [\n\t\"effect\",\n\t\"audio\",\n\t\"source\",\n\t\"signal\",\n\t\"utility\"\n];\nconst IDENTIFIER = /^[A-Za-z][A-Za-z0-9]*$/;\nvar NodeManifestError = class extends Error {\n\tconstructor(problems) {\n\t\tsuper(`Invalid node manifest(s):\\n${problems.map((p) => ` - ${p}`).join(\"\\n\")}`);\n\t\tthis.problems = problems;\n\t\tthis.name = \"NodeManifestError\";\n\t}\n};\nfunction isRecord(value) {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n/**\n* Validates one parsed `package.json`. Returns the manifest, or the list of\n* problems that make it unusable. Never throws.\n*/\nfunction parseNodeManifest(pkg, dir, nodePath = dir) {\n\tconst problems = [];\n\tif (!isRecord(pkg)) return { problems: [`${dir}: package.json is not an object`] };\n\tconst block = pkg.framefields;\n\tif (!isRecord(block)) return { problems: [`${dir}: package.json has no \"framefields\" block (expected { \"type\": \"<Op>\", \"kind\": \"<kind>\" })`] };\n\tconst { type, kind, aliases, schema, className, factory, custom } = block;\n\tif (typeof type !== \"string\" || !IDENTIFIER.test(type)) problems.push(`${dir}: framefields.type must be an op identifier`);\n\tif (typeof kind !== \"string\" || !NODE_KINDS.includes(kind)) problems.push(`${dir}: framefields.kind must be one of ${NODE_KINDS.join(\", \")}`);\n\tif (aliases !== void 0 && !(Array.isArray(aliases) && aliases.every((a) => typeof a === \"string\" && IDENTIFIER.test(a)))) problems.push(`${dir}: framefields.aliases must be an array of op identifiers`);\n\tfor (const [key, value] of Object.entries({\n\t\tschema,\n\t\tclassName,\n\t\tfactory\n\t})) if (value !== void 0 && (typeof value !== \"string\" || !IDENTIFIER.test(value))) problems.push(`${dir}: framefields.${key} must be an identifier`);\n\tif (custom !== void 0 && typeof custom !== \"boolean\") problems.push(`${dir}: framefields.custom must be a boolean`);\n\tif (problems.length > 0) return { problems };\n\tconst exportsField = isRecord(pkg.exports) ? pkg.exports[\"./renderer\"] : null;\n\tconst legacy = isRecord(pkg.gatewai) ? pkg.gatewai : {};\n\treturn {\n\t\tproblems,\n\t\tmanifest: {\n\t\t\tdir,\n\t\t\tpath: nodePath,\n\t\t\tpackageName: typeof pkg.name === \"string\" ? pkg.name : dir,\n\t\t\ttype,\n\t\t\tkind,\n\t\t\taliases: aliases ?? [],\n\t\t\tschema,\n\t\t\tclassName,\n\t\t\tfactory,\n\t\t\tcustom: custom === true,\n\t\t\tenabled: legacy.enabled !== false,\n\t\t\trendererExports: isRecord(exportsField) ? exportsField : void 0\n\t\t}\n\t};\n}\n/**\n* Reads every `nodes/node-*` package and returns its manifest, sorted by\n* directory name. Throws a single {@link NodeManifestError} listing every\n* problem: a missing or malformed block, or an op/alias claimed twice.\n*/\nfunction loadNodeManifests(nodesDir) {\n\tconst problems = [];\n\tconst manifests = [];\n\tconst dirs = fs.readdirSync(nodesDir).filter((d) => d.startsWith(\"node-\") && fs.existsSync(path.join(nodesDir, d, \"package.json\"))).sort();\n\tfor (const dir of dirs) {\n\t\tconst nodePath = path.join(nodesDir, dir);\n\t\tlet pkg;\n\t\ttry {\n\t\t\tpkg = JSON.parse(fs.readFileSync(path.join(nodePath, \"package.json\"), \"utf-8\"));\n\t\t} catch (err) {\n\t\t\tproblems.push(`${dir}: package.json is not valid JSON (${String(err)})`);\n\t\t\tcontinue;\n\t\t}\n\t\tconst parsed = parseNodeManifest(pkg, dir, nodePath);\n\t\tproblems.push(...parsed.problems);\n\t\tif (parsed.manifest) manifests.push(parsed.manifest);\n\t}\n\tconst owners = /* @__PURE__ */ new Map();\n\tfor (const manifest of manifests) for (const op of [manifest.type, ...manifest.aliases]) {\n\t\tconst owner = owners.get(op);\n\t\tif (owner) problems.push(`${manifest.dir}: op \"${op}\" is already declared by ${owner}`);\n\t\telse owners.set(op, manifest.dir);\n\t}\n\tif (problems.length > 0) throw new NodeManifestError(problems);\n\treturn manifests;\n}\n\n//#endregion\n//#region src/dynamic-node-discovery.ts\nlet __filename = \"\";\nlet __dirname = \"\";\nif (typeof process !== \"undefined\" && !!process.versions?.node) {\n\t__filename = fileURLToPath(import.meta.url);\n\t__dirname = path.dirname(__filename);\n}\n/** Locates the workspace `nodes/` directory by climbing up from this file. */\nfunction findNodesDir(startDir = __dirname) {\n\tlet nodesDir = path.resolve(startDir, \"../../../nodes\");\n\tlet currentDir = startDir;\n\twhile (true) {\n\t\tif (fs.existsSync(nodesDir)) {\n\t\t\tif (fs.readdirSync(nodesDir).some((d) => d.startsWith(\"node-\") && fs.existsSync(path.join(nodesDir, d, \"package.json\")))) return nodesDir;\n\t\t}\n\t\tconst parentDir = path.dirname(currentDir);\n\t\tif (parentDir === currentDir) return null;\n\t\tcurrentDir = parentDir;\n\t\tnodesDir = path.resolve(currentDir, \"nodes\");\n\t}\n}\n/**\n* Picks the renderer entry file: development source in dev/vitest, otherwise\n* the bundled dist, falling back to source when dist has not been built.\n*/\nfunction resolveRendererEntry(nodePath, rendererExports) {\n\tconst exists = (rel) => !!rel && fs.existsSync(path.join(nodePath, rel));\n\tif ((process.env.NODE_ENV !== \"production\" || Boolean(process.env.VITEST)) && exists(rendererExports.development)) return rendererExports.development;\n\tconst bundled = rendererExports.import || rendererExports.default;\n\tif (exists(bundled)) return bundled;\n\tif (exists(rendererExports.development)) return rendererExports.development;\n}\nasync function registerNode(manifest) {\n\tif (!manifest.rendererExports) return;\n\tconst entry = resolveRendererEntry(manifest.path, manifest.rendererExports);\n\tif (!entry) return;\n\tconst mod = await import(pathToFileURL(path.join(manifest.path, entry)).href);\n\tregisterPlugin([manifest.type, ...manifest.aliases], mod?.default);\n}\nfunction registerPlugin(ops, rendererPlugin) {\n\tif (!rendererPlugin) return;\n\tif (rendererPlugin.WebGPURenderer) for (const op of ops) registerWebGPURenderer(op, rendererPlugin.WebGPURenderer);\n\tif (rendererPlugin.audioProcessor) for (const op of ops) audioRegistry.register(op, rendererPlugin.audioProcessor);\n}\n/**\n* Registers the renderers bundled with this package. They are imported by\n* package name, so they resolve from `node_modules` (or the published bundle)\n* and never depend on a `nodes/` directory on disk.\n*/\nasync function registerBuiltinNodeRenderers() {\n\tconst failed = [];\n\tawait Promise.all(BUILTIN_NODE_RENDERERS.map(async ({ packageName, ops, load }) => {\n\t\ttry {\n\t\t\tregisterPlugin(ops, (await load()).default);\n\t\t} catch (err) {\n\t\t\tfailed.push(packageName);\n\t\t\tconsole.error(`[HeadlessWebGPURenderer] Failed to load renderer ${packageName}:`, err);\n\t\t}\n\t}));\n\tif (failed.length === BUILTIN_NODE_RENDERERS.length) throw new Error(\"[HeadlessWebGPURenderer] No built-in node renderers could be loaded.\");\n}\n/**\n* Registers the built-in node renderers, then any extra nodes found in the\n* directory named by `FRAMEFIELDS_NODES_DIR` (local node development). A node in\n* that directory overrides the built-in renderer for the same op.\n*/\nasync function discoverAndRegisterNodeRenderers() {\n\tif (typeof process === \"undefined\" || !process.versions?.node) return;\n\tawait registerBuiltinNodeRenderers();\n\tconst extraDir = process.env.FRAMEFIELDS_NODES_DIR;\n\tif (!extraDir) return;\n\tconst nodesDir = path.resolve(extraDir);\n\tif (!fs.existsSync(nodesDir)) {\n\t\tconsole.warn(`[HeadlessWebGPURenderer] FRAMEFIELDS_NODES_DIR does not exist: ${nodesDir}`);\n\t\treturn;\n\t}\n\trendererLogger.debug(`[HeadlessWebGPURenderer] Discovering node renderers in: ${nodesDir}`);\n\tconst manifests = loadNodeManifests(nodesDir);\n\tfor (const manifest of manifests) {\n\t\tif (!manifest.enabled) continue;\n\t\ttry {\n\t\t\tawait registerNode(manifest);\n\t\t} catch (err) {\n\t\t\tconsole.error(`[HeadlessWebGPURenderer] Failed to discover renderer for node ${manifest.dir}:`, err);\n\t\t}\n\t}\n}\n\n//#endregion\n//#region src/video-encoders.ts\nlet nodeAv;\n/**\n* node-av as @mediabunny/server loads it, with software encoders as the\n* default. The patch and the HardwareContext instances returned to the server\n* must come from that exact module instance, so the file is resolved from the\n* server package and imported natively (a `require()` can be routed through\n* a loader such as tsx and produce a second copy).\n*/\nfunction loadNodeAv() {\n\tnodeAv ??= (async () => {\n\t\tconst av = await import(pathToFileURL(createRequire(createRequire(import.meta.url).resolve(\"@mediabunny/server\")).resolve(\"node-av\")).href);\n\t\tpreferSoftwareEncoders(av);\n\t\treturn av;\n\t})();\n\treturn nodeAv;\n}\n/**\n* Software encoders to use per codec, best first. @mediabunny/server takes\n* `Codec.findEncoder(id)` as its software encoder, which returns whichever\n* encoder FFmpeg registered first. In node-av's linux-arm64 build that is a\n* hardware encoder (h264_rkmpp, hevc_rkmpp), which fails without Rockchip\n* hardware.\n*/\nconst SOFTWARE_ENCODERS = {\n\tAV_CODEC_ID_H264: [\"libx264\", \"libopenh264\"],\n\tAV_CODEC_ID_HEVC: [\"libx265\"],\n\tAV_CODEC_ID_VP8: [\"libvpx\"],\n\tAV_CODEC_ID_VP9: [\"libvpx-vp9\"],\n\tAV_CODEC_ID_AV1: [\n\t\t\"libsvtav1\",\n\t\t\"libaom-av1\",\n\t\t\"libdav1d\"\n\t]\n};\nlet patched = false;\n/** Makes `Codec.findEncoder` return a software encoder when one exists. */\nfunction preferSoftwareEncoders(av) {\n\tif (patched) return;\n\tpatched = true;\n\tconst byId = /* @__PURE__ */ new Map();\n\tfor (const [constant, names] of Object.entries(SOFTWARE_ENCODERS)) {\n\t\tconst id = av[constant];\n\t\tif (typeof id === \"number\") byId.set(id, names);\n\t}\n\tconst findEncoder = av.Codec.findEncoder.bind(av.Codec);\n\tav.Codec.findEncoder = ((id) => {\n\t\tfor (const name of byId.get(id) ?? []) {\n\t\t\tconst codec = av.Codec.findEncoderByName(name);\n\t\t\tif (codec) return codec;\n\t\t}\n\t\treturn findEncoder(id);\n\t});\n}\n/**\n* Opens the encoder with the settings @mediabunny/server uses and encodes one\n* frame. A hardware encoder can be compiled in and still be unusable: no such\n* hardware (rkmpp on a non-Rockchip board), or a GPU without an encoder block\n* (NVIDIA A100/H100 have no NVENC).\n*/\nasync function encoderWorks(av, codec) {\n\tconst ctx = new av.CodecContext();\n\tconst frame = new av.Frame();\n\tconst packet = new av.Packet();\n\ttry {\n\t\tctx.allocContext3(codec);\n\t\tconst formats = codec.pixelFormats;\n\t\tconst pixelFormat = !formats || formats.includes(av.AV_PIX_FMT_YUV420P) ? av.AV_PIX_FMT_YUV420P : formats[0];\n\t\tctx.width = 256;\n\t\tctx.height = 256;\n\t\tctx.pixelFormat = pixelFormat;\n\t\tctx.timeBase = new av.Rational(1, 1e6);\n\t\tctx.framerate = new av.Rational(30, 1);\n\t\tctx.gopSize = 60;\n\t\tctx.bitRate = 1000000n;\n\t\tif (await ctx.open2() < 0) return false;\n\t\tframe.alloc();\n\t\tframe.format = pixelFormat;\n\t\tframe.width = 256;\n\t\tframe.height = 256;\n\t\tif (frame.getBuffer() < 0) return false;\n\t\tframe.pts = 0n;\n\t\tpacket.alloc();\n\t\tif (await ctx.sendFrame(frame) < 0) return false;\n\t\tif (await ctx.sendFrame(null) < 0) return false;\n\t\tfor (;;) {\n\t\t\tconst ret = await ctx.receivePacket(packet);\n\t\t\tif (ret >= 0) return true;\n\t\t\tif (ret !== av.AVERROR_EAGAIN) return false;\n\t\t}\n\t} catch {\n\t\treturn false;\n\t} finally {\n\t\tpacket.free();\n\t\tframe.free();\n\t\tctx.freeContext();\n\t}\n}\n/** True when the env turns hardware video encoding/decoding off. */\nfunction hardwareDisabled() {\n\tconst value = process.env.FRAMEFIELDS_HW_CODECS?.toLowerCase();\n\treturn value === \"0\" || value === \"off\" || value === \"false\";\n}\n/**\n* Returns the `hardwareContext` option for registerMediabunnyServer: the\n* platform's hardware context for codecs whose hardware encoder actually\n* works (NVENC, VideoToolbox, ...), and null otherwise, so that codec is\n* encoded in software. Each codec is tested once per process.\n*\n* The server calls this before it picks any encoder (unless the encoder is\n* created with \"prefer-software\"), so the software default is patched in by\n* then.\n*/\nfunction hardwareContextResolver(forceSoftware) {\n\tlet hw;\n\tconst verdicts = /* @__PURE__ */ new Map();\n\tconst resolve = async (codecId) => {\n\t\tconst av = await loadNodeAv();\n\t\tif (forceSoftware || hardwareDisabled()) return null;\n\t\tif (hw === void 0) hw = av.HardwareContext.auto();\n\t\tif (!hw) return null;\n\t\tconst encoder = hw.getEncoderCodec(codecId);\n\t\tif (!encoder) return hw;\n\t\tif (await encoderWorks(av, encoder)) {\n\t\t\trendererLogger.info({\n\t\t\t\tencoder: encoder.name,\n\t\t\t\tdevice: hw.deviceTypeName\n\t\t\t}, \"[video-encoders] Using hardware video encoder\");\n\t\t\treturn hw;\n\t\t}\n\t\trendererLogger.warn({\n\t\t\tencoder: encoder.name,\n\t\t\tdevice: hw.deviceTypeName\n\t\t}, \"[video-encoders] Hardware video encoder unusable; encoding in software\");\n\t\treturn null;\n\t};\n\treturn (codecId) => {\n\t\tlet verdict = verdicts.get(codecId);\n\t\tif (!verdict) {\n\t\t\tverdict = resolve(codecId).catch(async (err) => {\n\t\t\t\tawait loadNodeAv();\n\t\t\t\trendererLogger.warn({ err: err instanceof Error ? err.message : String(err) }, \"[video-encoders] Hardware probe failed; encoding in software\");\n\t\t\t\treturn null;\n\t\t\t});\n\t\t\tverdicts.set(codecId, verdict);\n\t\t}\n\t\treturn verdict;\n\t};\n}\n/**\n* Options for registerMediabunnyServer: hardware video codecs when they work,\n* software (libx264, libx265, libvpx, SVT-AV1) otherwise. `forceSoftware`\n* keeps every codec in software (used on AMD). Create encoders with\n* \"prefer-hardware\" so this decides; \"prefer-software\" skips it.\n*/\nfunction videoCodecServerOptions(forceSoftware) {\n\treturn { hardwareContext: hardwareContextResolver(forceSoftware) };\n}\n\n//#endregion\n//#region src/bootstrap-mediabunny.ts\nconst isAMD = () => {\n\tif (process.platform !== \"linux\") return false;\n\ttry {\n\t\tif (fs.existsSync(\"/sys/module/amdgpu\") || fs.existsSync(\"/dev/kfd\")) return true;\n\t\tconst drmDir = \"/sys/class/drm\";\n\t\tif (fs.existsSync(drmDir)) {\n\t\t\tconst files = fs.readdirSync(drmDir);\n\t\t\tfor (const file of files) {\n\t\t\t\tconst vendorPath = `${drmDir}/${file}/device/vendor`;\n\t\t\t\tif (fs.existsSync(vendorPath)) {\n\t\t\t\t\tif (fs.readFileSync(vendorPath, \"utf8\").trim() === \"0x1002\") return true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} catch {}\n\treturn false;\n};\nconst bootstrapMediabunny = () => {\n\tregisterMediabunnyServer(videoCodecServerOptions(isAMD()));\n\tfor (const key of Object.keys(webcodecs)) if (typeof globalThis[key] === \"undefined\") globalThis[key] = webcodecs[key];\n};\n\n//#endregion\nexport { NodeManifestError as a, DmaStagingRing as c, NODE_KINDS as i, preloadFonts as l, discoverAndRegisterNodeRenderers as n, loadNodeManifests as o, findNodesDir as r, parseNodeManifest as s, bootstrapMediabunny as t, rendererLogger as u };\n//# sourceMappingURL=bootstrap-mediabunny--TDh3Bij.mjs.map","import { c as DmaStagingRing, l as preloadFonts, n as discoverAndRegisterNodeRenderers, t as bootstrapMediabunny, u as rendererLogger } from \"./bootstrap-mediabunny--TDh3Bij.mjs\";\nimport path from \"node:path\";\nimport { exec, spawn } from \"node:child_process\";\nimport { randomUUID } from \"node:crypto\";\nimport fs from \"node:fs/promises\";\nimport os from \"node:os\";\nimport { compositionStateStore, drawCompositionTree, mixAudioTracks } from \"@framefields/compositions\";\nimport { getMediaType, takeRenderDiagnostics, updateClockSignals } from \"@framefields/core\";\nimport { NodeSurfaceProvider, SlugFontCache, WebGPUAudioProcessor, clearAllVideoCache, ensureDevice, getRenderer2D, initHeadlessWebGPU, inputStore, lutStore, mediaDecoderCache, shaderStore, textureCache } from \"@framefields/webgpu-renderers\";\nimport { AudioSample, AudioSampleSource, FilePathTarget, Mp3OutputFormat, Mp4OutputFormat, Output, QUALITY_HIGH, QUALITY_LOW, QUALITY_VERY_HIGH, QUALITY_VERY_LOW, VideoSample, VideoSampleSource, WebMOutputFormat } from \"mediabunny\";\nimport sharp from \"sharp\";\nimport { Canvas, Image } from \"skia-canvas\";\n\n//#region src/video-qa.ts\nconst DEFAULTS = {\n\tblackPixelThreshold: .1,\n\tblackFrameRatio: .98,\n\tminBlackSec: .5,\n\tminFrozenSec: 2,\n\tsilenceDbfs: -60,\n\tminSilenceSec: 2,\n\tlufsTolerance: 1\n};\nconst SAMPLE_STEP = 4;\nconst FROZEN_DIFF = .25;\n/** Measures frames handed to it in order, as RGBA bytes. */\nvar FrameInspector = class {\n\tblackLuma;\n\tblackRatio;\n\tblack = [];\n\tsameAsPrevious = [];\n\tlumaSum = 0;\n\tprevious = null;\n\tconstructor(options = {}) {\n\t\tthis.blackLuma = (options.blackPixelThreshold ?? DEFAULTS.blackPixelThreshold) * 255;\n\t\tthis.blackRatio = options.blackFrameRatio ?? DEFAULTS.blackFrameRatio;\n\t}\n\tget frameCount() {\n\t\treturn this.black.length;\n\t}\n\tinspect(rgba, width, height) {\n\t\tconst cols = Math.ceil(width / SAMPLE_STEP);\n\t\tconst rows = Math.ceil(height / SAMPLE_STEP);\n\t\tconst luma = new Uint8Array(cols * rows);\n\t\tlet blackCount = 0;\n\t\tlet sum = 0;\n\t\tlet k = 0;\n\t\tfor (let y = 0; y < height; y += SAMPLE_STEP) {\n\t\t\tlet p = y * width * 4;\n\t\t\tfor (let x = 0; x < width; x += SAMPLE_STEP, p += SAMPLE_STEP * 4) {\n\t\t\t\tconst l = .2126 * rgba[p] + .7152 * rgba[p + 1] + .0722 * rgba[p + 2];\n\t\t\t\tluma[k++] = l;\n\t\t\t\tsum += l;\n\t\t\t\tif (l <= this.blackLuma) blackCount++;\n\t\t\t}\n\t\t}\n\t\tconst n = luma.length;\n\t\tthis.lumaSum += sum / n / 255;\n\t\tthis.black.push(blackCount / n >= this.blackRatio);\n\t\tlet same = false;\n\t\tif (this.previous && this.previous.length === n) {\n\t\t\tlet diff = 0;\n\t\t\tfor (let i = 0; i < n; i++) diff += Math.abs(luma[i] - this.previous[i]);\n\t\t\tsame = diff / n < FROZEN_DIFF;\n\t\t}\n\t\tthis.sameAsPrevious.push(same);\n\t\tthis.previous = luma;\n\t}\n\tstats(expectedFrames, encodedFrames, fps, width, height, options = {}) {\n\t\tconst minBlack = Math.max(1, Math.round((options.minBlackSec ?? DEFAULTS.minBlackSec) * fps));\n\t\tconst minFrozen = Math.max(2, Math.round((options.minFrozenSec ?? DEFAULTS.minFrozenSec) * fps));\n\t\tconst blackSegments = runs(this.black, minBlack).map(([a, b]) => ({\n\t\t\tstartSec: a / fps,\n\t\t\tendSec: b / fps\n\t\t}));\n\t\tconst frozenSegments = runs(this.sameAsPrevious, minFrozen - 1).map(([a, b]) => ({\n\t\t\tstartSec: (a - 1) / fps,\n\t\t\tendSec: b / fps\n\t\t}));\n\t\treturn {\n\t\t\texpectedFrames,\n\t\t\tencodedFrames,\n\t\t\tfps,\n\t\t\twidth,\n\t\t\theight,\n\t\t\tmeanLuma: this.frameCount > 0 ? this.lumaSum / this.frameCount : 0,\n\t\t\tblackSegments,\n\t\t\tfrozenSegments\n\t\t};\n\t}\n};\n/** [start, end) index ranges where flags hold for at least minLength in a row. */\nfunction runs(flags, minLength) {\n\tconst out = [];\n\tlet start = -1;\n\tfor (let i = 0; i <= flags.length; i++) if (i < flags.length && flags[i]) {\n\t\tif (start < 0) start = i;\n\t} else if (start >= 0) {\n\t\tif (i - start >= minLength) out.push([start, i]);\n\t\tstart = -1;\n\t}\n\treturn out;\n}\nconst toDb = (power) => power > 0 ? 10 * Math.log10(power) : -Infinity;\n/** Measures a mixed audio track (one Float32Array per channel). */\nfunction analyzeAudio(channels, sampleRate, options = {}) {\n\tconst length = channels[0]?.length ?? 0;\n\tlet peak = 0;\n\tlet sumSquares = 0;\n\tlet clipped = 0;\n\tfor (const ch of channels) for (let i = 0; i < length; i++) {\n\t\tconst v = Math.abs(ch[i]);\n\t\tif (v > peak) peak = v;\n\t\tif (v >= .9999) clipped++;\n\t\tsumSquares += v * v;\n\t}\n\tconst total = length * Math.max(1, channels.length);\n\tconst silenceDbfs = options.silenceDbfs ?? DEFAULTS.silenceDbfs;\n\tconst window = Math.max(1, Math.round(sampleRate * .1));\n\tconst silent = [];\n\tfor (let start = 0; start < length; start += window) {\n\t\tconst end = Math.min(length, start + window);\n\t\tlet s = 0;\n\t\tfor (const ch of channels) for (let i = start; i < end; i++) s += ch[i] * ch[i];\n\t\tsilent.push(toDb(s / ((end - start) * channels.length)) < silenceDbfs);\n\t}\n\tconst silentSegments = runs(silent, Math.max(1, Math.round((options.minSilenceSec ?? DEFAULTS.minSilenceSec) / .1))).map(([a, b]) => ({\n\t\tstartSec: a * window / sampleRate,\n\t\tendSec: Math.min(length, b * window) / sampleRate\n\t}));\n\tconst peakDbfs = 20 * Math.log10(Math.max(peak, 1e-12));\n\treturn {\n\t\tsampleRate,\n\t\tchannels: channels.length,\n\t\tdurationSec: length / sampleRate,\n\t\tpeakDbfs,\n\t\trmsDbfs: toDb(sumSquares / Math.max(1, total)),\n\t\tintegratedLufs: peakDbfs < silenceDbfs ? null : integratedLoudness(channels, sampleRate),\n\t\tclippedSamples: clipped,\n\t\tsilentSegments\n\t};\n}\n/** BS.1770 K-weighting stage 1: +4 dB high shelf around 1.5 kHz (the head). */\nfunction highShelf(sampleRate) {\n\tconst A = 10 ** (4 / 40);\n\tconst w0 = 2 * Math.PI * 1500 / sampleRate;\n\tconst cos = Math.cos(w0);\n\tconst alpha = Math.sin(w0) / (2 / Math.SQRT2);\n\tconst sq = 2 * Math.sqrt(A) * alpha;\n\tconst a0 = A + 1 - (A - 1) * cos + sq;\n\treturn {\n\t\tb0: A * (A + 1 + (A - 1) * cos + sq) / a0,\n\t\tb1: -2 * A * (A - 1 + (A + 1) * cos) / a0,\n\t\tb2: A * (A + 1 + (A - 1) * cos - sq) / a0,\n\t\ta1: 2 * (A - 1 - (A + 1) * cos) / a0,\n\t\ta2: (A + 1 - (A - 1) * cos - sq) / a0\n\t};\n}\n/** BS.1770 K-weighting stage 2: 38 Hz high pass, Q 0.5 (the RLB curve). */\nfunction highPass(sampleRate) {\n\tconst w0 = 2 * Math.PI * 38 / sampleRate;\n\tconst cos = Math.cos(w0);\n\tconst alpha = Math.sin(w0) / (2 * .5);\n\tconst a0 = 1 + alpha;\n\treturn {\n\t\tb0: (1 + cos) / 2 / a0,\n\t\tb1: -(1 + cos) / a0,\n\t\tb2: (1 + cos) / 2 / a0,\n\t\ta1: -2 * cos / a0,\n\t\ta2: (1 - alpha) / a0\n\t};\n}\nfunction filter(input, f) {\n\tconst out = new Float32Array(input.length);\n\tlet x1 = 0;\n\tlet x2 = 0;\n\tlet y1 = 0;\n\tlet y2 = 0;\n\tfor (let i = 0; i < input.length; i++) {\n\t\tconst x = input[i];\n\t\tconst y = f.b0 * x + f.b1 * x1 + f.b2 * x2 - f.a1 * y1 - f.a2 * y2;\n\t\tout[i] = y;\n\t\tx2 = x1;\n\t\tx1 = x;\n\t\ty2 = y1;\n\t\ty1 = y;\n\t}\n\treturn out;\n}\n/**\n* ITU-R BS.1770-4 integrated loudness (LUFS): K-weighted mean square in\n* 400 ms blocks with 75% overlap, gated at -70 LUFS and then at 10 LU below\n* the mean of what passed. Channels weigh 1 (stereo and mono layouts).\n*/\nfunction integratedLoudness(channels, sampleRate) {\n\tconst shelf = highShelf(sampleRate);\n\tconst hp = highPass(sampleRate);\n\tconst weighted = channels.map((ch) => filter(filter(ch, shelf), hp));\n\tconst length = weighted[0]?.length ?? 0;\n\tconst block = Math.round(.4 * sampleRate);\n\tconst hop = Math.round(.1 * sampleRate);\n\tif (length < block) return null;\n\tconst blockPower = [];\n\tfor (let start = 0; start + block <= length; start += hop) {\n\t\tlet power = 0;\n\t\tfor (const ch of weighted) {\n\t\t\tlet s = 0;\n\t\t\tfor (let i = start; i < start + block; i++) s += ch[i] * ch[i];\n\t\t\tpower += s / block;\n\t\t}\n\t\tblockPower.push(power);\n\t}\n\tconst lufs = (power) => -.691 + toDb(power);\n\tconst mean = (xs) => xs.reduce((a, b) => a + b, 0) / xs.length;\n\tconst absolute = blockPower.filter((p) => lufs(p) > -70);\n\tif (absolute.length === 0) return null;\n\tconst relativeGate = lufs(mean(absolute)) - 10;\n\tconst gated = absolute.filter((p) => lufs(p) > relativeGate);\n\treturn gated.length > 0 ? lufs(mean(gated)) : null;\n}\n/** Turn measurements and document diagnostics into a report with issues. */\nfunction buildQaReport(parts) {\n\tconst { video, audio, options = {} } = parts;\n\tconst issues = [];\n\tconst at = (s) => `${s.startSec.toFixed(2)}–${s.endSec.toFixed(2)} s`;\n\tif (video) {\n\t\tif (video.encodedFrames !== video.expectedFrames) issues.push({\n\t\t\tseverity: \"error\",\n\t\t\tcode: \"frames_missing\",\n\t\t\tmessage: `${video.encodedFrames} of ${video.expectedFrames} frames were encoded`\n\t\t});\n\t\tfor (const s of video.blackSegments) issues.push({\n\t\t\tseverity: \"warning\",\n\t\t\tcode: \"black_frames\",\n\t\t\tmessage: `Black frames at ${at(s)}`,\n\t\t\t...s\n\t\t});\n\t\tfor (const s of video.frozenSegments) issues.push({\n\t\t\tseverity: \"info\",\n\t\t\tcode: \"frozen_video\",\n\t\t\tmessage: `Picture does not change at ${at(s)}`,\n\t\t\t...s\n\t\t});\n\t}\n\tif (audio) if (audio.integratedLufs === null) issues.push({\n\t\tseverity: \"info\",\n\t\tcode: \"audio_silent\",\n\t\tmessage: \"The audio track is silent\"\n\t});\n\telse {\n\t\tif (audio.clippedSamples > 0) issues.push({\n\t\t\tseverity: \"warning\",\n\t\t\tcode: \"audio_clipping\",\n\t\t\tmessage: `${audio.clippedSamples} audio sample(s) at or beyond full scale (peak ${audio.peakDbfs.toFixed(1)} dBFS)`\n\t\t});\n\t\tfor (const s of audio.silentSegments) issues.push({\n\t\t\tseverity: \"info\",\n\t\t\tcode: \"audio_silence\",\n\t\t\tmessage: `Silence at ${at(s)}`,\n\t\t\t...s\n\t\t});\n\t\tif (options.targetLufs !== void 0) {\n\t\t\tconst off = audio.integratedLufs - options.targetLufs;\n\t\t\tconst tolerance = options.lufsTolerance ?? DEFAULTS.lufsTolerance;\n\t\t\tif (Math.abs(off) > tolerance) issues.push({\n\t\t\t\tseverity: \"warning\",\n\t\t\t\tcode: \"loudness_off_target\",\n\t\t\t\tmessage: `Integrated loudness ${audio.integratedLufs.toFixed(1)} LUFS is ${Math.abs(off).toFixed(1)} LU ${off > 0 ? \"above\" : \"below\"} the ${options.targetLufs} LUFS target`\n\t\t\t});\n\t\t}\n\t}\n\tfor (const d of parts.diagnostics ?? []) issues.push({\n\t\tseverity: d.severity,\n\t\tcode: d.code,\n\t\tmessage: d.message,\n\t\t...d.layerId !== void 0 && { layerId: d.layerId }\n\t});\n\treturn {\n\t\tpassed: !issues.some((i) => i.severity !== \"info\"),\n\t\t...video && { video },\n\t\t...audio && { audio },\n\t\tissues\n\t};\n}\n/** A short human- and agent-readable summary of a report. */\nfunction formatQaReport(report) {\n\tconst lines = [`QA ${report.passed ? \"passed\" : \"FAILED\"}`];\n\tconst v = report.video;\n\tif (v) lines.push(` video: ${v.encodedFrames}/${v.expectedFrames} frames, ${v.width}x${v.height} @ ${v.fps} fps, mean luma ${v.meanLuma.toFixed(2)}`);\n\tconst a = report.audio;\n\tif (a) {\n\t\tconst lufs = a.integratedLufs === null ? \"silent\" : `${a.integratedLufs.toFixed(1)} LUFS`;\n\t\tlines.push(` audio: ${a.durationSec.toFixed(2)} s, ${lufs}, peak ${a.peakDbfs.toFixed(1)} dBFS, rms ${a.rmsDbfs.toFixed(1)} dBFS`);\n\t}\n\tfor (const i of report.issues) lines.push(` ${i.severity.padEnd(7)} ${i.code}: ${i.message}`);\n\treturn lines.join(\"\\n\");\n}\n\n//#endregion\n//#region src/zero-copy-webcodecs-pipeline.ts\n/**\n* High-performance hardware video encoding pipeline integrating WebGPU textures with WebCodecs.\n*\n* Provides:\n* 1. Direct hardware acceleration when running with WebCodecs / OffscreenCanvas.\n* 2. Pipelined asynchronous double-buffered DMA staging ring for headless Node.js (Dawn native),\n* allowing GPU Frame i+1 rendering to overlap concurrently with Frame i hardware encoding.\n*/\nvar ZeroCopyWebCodecsPipeline = class {\n\twidth;\n\theight;\n\tfps;\n\tringCapacity;\n\tdevice;\n\tvideoSource;\n\tstagingRing;\n\tcolorSpace;\n\tdirectCanvasSource;\n\tonFrame;\n\tinFlightFrames = [];\n\tcycleStartTimes = /* @__PURE__ */ new Map();\n\ttotalFramesEnqueued = 0;\n\ttotalFramesEncoded = 0;\n\ttotalGpuSubmitTimeMs = 0;\n\ttotalEncodeTimeMs = 0;\n\ttotalCycleTimeMs = 0;\n\tmaxCycleTimeMs = 0;\n\tminCycleTimeMs = Number.POSITIVE_INFINITY;\n\tpipelineStartTime = 0;\n\tconstructor(device, options) {\n\t\tthis.device = device;\n\t\tthis.width = options.width;\n\t\tthis.height = options.height;\n\t\tthis.fps = options.fps;\n\t\tthis.videoSource = options.videoSource;\n\t\tthis.ringCapacity = Math.max(2, options.ringCapacity ?? 2);\n\t\tthis.colorSpace = options.colorSpace;\n\t\tthis.directCanvasSource = options.directCanvasSource;\n\t\tthis.onFrame = options.onFrame;\n\t\tthis.stagingRing = new DmaStagingRing(device, {\n\t\t\twidth: this.width,\n\t\t\theight: this.height,\n\t\t\tcapacity: this.ringCapacity\n\t\t});\n\t\tthis.pipelineStartTime = performance.now();\n\t}\n\t/**\n\t* Returns true if direct zero-copy from an OffscreenCanvas or texture is active.\n\t*/\n\tcanDirectZeroCopy() {\n\t\treturn this.directCanvasSource !== void 0 && this.directCanvasSource !== null;\n\t}\n\t/**\n\t* Enqueues a rendered GPU texture frame into the pipeline.\n\t*\n\t* Uses double-buffered DMA staging: if the staging ring has reached capacity,\n\t* the oldest in-flight frame is asynchronously consumed and added to the video encoder\n\t* before staging the new frame, guaranteeing constant bounded VRAM usage and zero GPU stalls.\n\t*/\n\tasync enqueueFrame(frameIndex, targetTexture, encoder) {\n\t\tconst cycleStartTime = performance.now();\n\t\tif (this.inFlightFrames.length >= this.ringCapacity) {\n\t\t\tconst oldestFrame = this.inFlightFrames.shift();\n\t\t\tif (oldestFrame !== void 0) await this.consumeAndEncode(oldestFrame);\n\t\t}\n\t\tif (this.canDirectZeroCopy()) {\n\t\t\tconst gpuStart = performance.now();\n\t\t\tthis.device.queue.submit([encoder.finish()]);\n\t\t\tthis.totalGpuSubmitTimeMs += performance.now() - gpuStart;\n\t\t\tthis.cycleStartTimes.set(frameIndex, cycleStartTime);\n\t\t\tthis.totalFramesEnqueued++;\n\t\t\tawait this.consumeAndEncode(frameIndex);\n\t\t} else {\n\t\t\tawait this.stagingRing.prepareSlot(frameIndex);\n\t\t\tthis.stagingRing.stageTexture(encoder, targetTexture, frameIndex);\n\t\t\tconst gpuStart = performance.now();\n\t\t\tthis.device.queue.submit([encoder.finish()]);\n\t\t\tthis.totalGpuSubmitTimeMs += performance.now() - gpuStart;\n\t\t\tthis.stagingRing.scheduleMap(frameIndex);\n\t\t\tthis.inFlightFrames.push(frameIndex);\n\t\t\tthis.cycleStartTimes.set(frameIndex, cycleStartTime);\n\t\t\tthis.totalFramesEnqueued++;\n\t\t}\n\t}\n\t/**\n\t* Drains all remaining in-flight frames in the pipeline, ensuring every enqueued\n\t* frame has been encoded and added to the video sample source.\n\t*/\n\tasync drain() {\n\t\twhile (this.inFlightFrames.length > 0) {\n\t\t\tconst frameIndex = this.inFlightFrames.shift();\n\t\t\tif (frameIndex !== void 0) await this.consumeAndEncode(frameIndex);\n\t\t}\n\t}\n\t/**\n\t* Returns runtime throughput, latency, and pipeline statistics.\n\t*/\n\tgetStats() {\n\t\tconst totalElapsedMs = performance.now() - this.pipelineStartTime;\n\t\tconst throughputFps = totalElapsedMs > 0 ? this.totalFramesEncoded / totalElapsedMs * 1e3 : 0;\n\t\tconst avgSubmit = this.totalFramesEnqueued > 0 ? this.totalGpuSubmitTimeMs / this.totalFramesEnqueued : 0;\n\t\tconst avgEncode = this.totalFramesEncoded > 0 ? this.totalEncodeTimeMs / this.totalFramesEncoded : 0;\n\t\tconst avgCycle = this.totalFramesEncoded > 0 ? this.totalCycleTimeMs / this.totalFramesEncoded : 0;\n\t\treturn {\n\t\t\ttotalFramesEnqueued: this.totalFramesEnqueued,\n\t\t\ttotalFramesEncoded: this.totalFramesEncoded,\n\t\t\taverageGpuSubmitTimeMs: avgSubmit,\n\t\t\taverageEncodeTimeMs: avgEncode,\n\t\t\taverageCycleTimeMs: avgCycle,\n\t\t\tmaxCycleTimeMs: this.maxCycleTimeMs,\n\t\t\tminCycleTimeMs: Number.isFinite(this.minCycleTimeMs) ? this.minCycleTimeMs : 0,\n\t\t\tthroughputFps,\n\t\t\tringCapacity: this.ringCapacity,\n\t\t\tisDirectZeroCopy: this.canDirectZeroCopy()\n\t\t};\n\t}\n\t/**\n\t* Destroys the pipeline and releases all staging buffers.\n\t*/\n\tdestroy() {\n\t\tthis.inFlightFrames.length = 0;\n\t\tthis.cycleStartTimes.clear();\n\t\tthis.stagingRing.destroy();\n\t}\n\tasync consumeAndEncode(frameIndex) {\n\t\tconst encodeStart = performance.now();\n\t\tconst timestampUs = frameIndex / this.fps * 1e6;\n\t\tif (this.canDirectZeroCopy()) {\n\t\t\tconst sample = new VideoSample(this.directCanvasSource, {\n\t\t\t\tduration: 1 / this.fps,\n\t\t\t\ttimestamp: frameIndex / this.fps\n\t\t\t});\n\t\t\ttry {\n\t\t\t\tawait this.videoSource.add(sample);\n\t\t\t} finally {\n\t\t\t\tsample.close();\n\t\t\t}\n\t\t} else {\n\t\t\tconst onFrame = this.onFrame;\n\t\t\tconst vf = await this.stagingRing.readFrameToVideoFrame(frameIndex, timestampUs, this.colorSpace, onFrame && ((rgba) => onFrame(rgba, frameIndex)));\n\t\t\ttry {\n\t\t\t\tconst sample = new VideoSample(vf, {\n\t\t\t\t\tduration: 1 / this.fps,\n\t\t\t\t\ttimestamp: frameIndex / this.fps\n\t\t\t\t});\n\t\t\t\ttry {\n\t\t\t\t\tawait this.videoSource.add(sample);\n\t\t\t\t} finally {\n\t\t\t\t\tsample.close();\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tvf.close();\n\t\t\t}\n\t\t}\n\t\tconst now = performance.now();\n\t\tthis.totalEncodeTimeMs += now - encodeStart;\n\t\tthis.totalFramesEncoded++;\n\t\tconst cycleStart = this.cycleStartTimes.get(frameIndex);\n\t\tif (cycleStart !== void 0) {\n\t\t\tconst cycleDuration = now - cycleStart;\n\t\t\tthis.cycleStartTimes.delete(frameIndex);\n\t\t\tthis.totalCycleTimeMs += cycleDuration;\n\t\t\tif (cycleDuration > this.maxCycleTimeMs) this.maxCycleTimeMs = cycleDuration;\n\t\t\tif (cycleDuration < this.minCycleTimeMs) this.minCycleTimeMs = cycleDuration;\n\t\t}\n\t}\n};\n\n//#endregion\n//#region src/headless-webgpu-renderer.ts\nglobalThis[Symbol.for(\"framefields.vision.backend\")] = (info) => {\n\trendererLogger.info(info, info.backend === \"webgpu\" ? \"[vision] Inference on the GPU (WebGPU)\" : `[vision] Inference on the ${info.backend.toUpperCase()}`);\n};\nasync function convertMp4ToGif(inputMp4Path, outputGifPath) {\n\treturn new Promise((resolve, reject) => {\n\t\tconst ffmpeg = spawn(\"ffmpeg\", [\n\t\t\t\"-i\",\n\t\t\tinputMp4Path,\n\t\t\t\"-vf\",\n\t\t\t\"split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse\",\n\t\t\t\"-y\",\n\t\t\toutputGifPath\n\t\t]);\n\t\tlet errorOutput = \"\";\n\t\tffmpeg.stderr.on(\"data\", (data) => {\n\t\t\terrorOutput += data.toString();\n\t\t});\n\t\tffmpeg.on(\"close\", async (code) => {\n\t\t\tif (code === 0) resolve();\n\t\t\telse {\n\t\t\t\trendererLogger.error({\n\t\t\t\t\tcode,\n\t\t\t\t\terr: errorOutput\n\t\t\t\t}, \"[convertMp4ToGif] ffmpeg conversion failed\");\n\t\t\t\treject(/* @__PURE__ */ new Error(`ffmpeg exited with code ${code}: ${errorOutput}`));\n\t\t\t}\n\t\t});\n\t\tffmpeg.on(\"error\", (err) => {\n\t\t\trendererLogger.error({ err }, \"[convertMp4ToGif] ffmpeg spawn error\");\n\t\t\treject(err);\n\t\t});\n\t});\n}\nbootstrapMediabunny();\nconst globalObj = globalThis;\nif (typeof globalThis !== \"undefined\") {\n\tglobalObj.__IS_HEADLESS_RENDERER__ = true;\n\tglobalObj.__GATEWAI_DELAYS__ ??= /* @__PURE__ */ new Set();\n}\nif (typeof globalThis.requestAnimationFrame === \"undefined\") {\n\tglobalObj.requestAnimationFrame = (cb) => setTimeout(cb, 0);\n\tglobalObj.cancelAnimationFrame = (id) => clearTimeout(id);\n}\nconst dummyDomElement = {\n\tclientWidth: 1920,\n\tclientHeight: 1080,\n\tgetBoundingClientRect: () => ({\n\t\tx: 0,\n\t\ty: 0,\n\t\tleft: 0,\n\t\ttop: 0,\n\t\tright: 1920,\n\t\tbottom: 1080,\n\t\twidth: 1920,\n\t\theight: 1080\n\t}),\n\tstyle: {},\n\tappendChild: () => {},\n\tremoveChild: () => {},\n\taddEventListener: () => {},\n\tremoveEventListener: () => {},\n\tgetAttribute: () => null\n};\nif (typeof globalThis.OffscreenCanvas === \"undefined\") globalObj.OffscreenCanvas = Canvas;\nif (typeof globalThis.HTMLCanvasElement === \"undefined\") globalObj.HTMLCanvasElement = Canvas;\nif (typeof globalThis.Image === \"undefined\") globalObj.Image = Image;\nif (typeof globalThis.window === \"undefined\") globalObj.window = globalThis;\nif (!globalThis.location) globalObj.location = new URL(\"http://localhost\");\nif (typeof globalThis.IntersectionObserver === \"undefined\") globalObj.IntersectionObserver = class IntersectionObserver {\n\tobserve() {}\n\tunobserve() {}\n\tdisconnect() {}\n};\nif (typeof globalThis.document === \"undefined\") globalObj.document = {\n\tcreateElement: (tag) => {\n\t\tif (tag === \"canvas\") return new Canvas(1, 1);\n\t\treturn { ...dummyDomElement };\n\t},\n\tgetElementsByTagName: () => [],\n\tdocumentElement: dummyDomElement,\n\tbody: dummyDomElement\n};\nelse {\n\tconst docObj = globalThis.document;\n\tif (typeof docObj.getElementsByTagName === \"undefined\") docObj.getElementsByTagName = () => [];\n\tdocObj.documentElement ??= dummyDomElement;\n\tdocObj.body ??= dummyDomElement;\n}\nconst skiaProto = Canvas.prototype;\nif (typeof skiaProto.getBoundingClientRect === \"undefined\") skiaProto.getBoundingClientRect = function() {\n\tconst width = this.width || 512;\n\tconst height = this.height || 512;\n\treturn {\n\t\tx: 0,\n\t\ty: 0,\n\t\tleft: 0,\n\t\ttop: 0,\n\t\tright: width,\n\t\tbottom: height,\n\t\twidth,\n\t\theight\n\t};\n};\nif (!(\"style\" in skiaProto)) Object.defineProperty(skiaProto, \"style\", {\n\tget() {\n\t\tthis._style ??= {};\n\t\treturn this._style;\n\t},\n\tconfigurable: true\n});\nif (!(\"clientWidth\" in skiaProto)) Object.defineProperty(skiaProto, \"clientWidth\", {\n\tget() {\n\t\treturn this.width || 512;\n\t},\n\tconfigurable: true\n});\nif (!(\"clientHeight\" in skiaProto)) Object.defineProperty(skiaProto, \"clientHeight\", {\n\tget() {\n\t\treturn this.height || 512;\n\t},\n\tconfigurable: true\n});\nif (!(\"parentElement\" in skiaProto)) Object.defineProperty(skiaProto, \"parentElement\", {\n\tget() {\n\t\treturn dummyDomElement;\n\t},\n\tconfigurable: true\n});\nif (typeof skiaProto.addEventListener === \"undefined\") skiaProto.addEventListener = () => {};\nif (typeof skiaProto.removeEventListener === \"undefined\") skiaProto.removeEventListener = () => {};\nif (typeof skiaProto.getAttribute === \"undefined\") skiaProto.getAttribute = () => null;\nconst CPU_COUNT = os.cpus().length;\nconst TOTAL_WORKER_BUDGET = Math.max(1, CPU_COUNT - 3);\nconst MAX_CONCURRENT_RENDERS = Math.max(1, Math.min(3, Math.floor(TOTAL_WORKER_BUDGET / 3)));\nconst QUEUE_TIMEOUT_MS = 120 * 6e4;\nvar RenderSemaphore = class {\n\t_running = 0;\n\t_max;\n\t_queue = [];\n\tconstructor(max) {\n\t\tthis._max = max;\n\t}\n\tacquire(timeoutMs = QUEUE_TIMEOUT_MS) {\n\t\tif (this._running < this._max) {\n\t\t\tthis._running++;\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setTimeout(() => {\n\t\t\t\tconst idx = this._queue.findIndex((e) => e.resolve === resolve);\n\t\t\t\tif (idx !== -1) this._queue.splice(idx, 1);\n\t\t\t\treject(/* @__PURE__ */ new Error(`Render queue timeout after ${timeoutMs}ms (${this._queue.length} queued, ${this._running}/${this._max} active)`));\n\t\t\t}, timeoutMs);\n\t\t\tthis._queue.push({\n\t\t\t\tresolve,\n\t\t\t\treject,\n\t\t\t\ttimer\n\t\t\t});\n\t\t});\n\t}\n\trelease() {\n\t\tif (this._queue.length > 0) {\n\t\t\tconst next = this._queue.shift();\n\t\t\tclearTimeout(next.timer);\n\t\t\tnext.resolve();\n\t\t} else this._running--;\n\t}\n\tget stats() {\n\t\treturn {\n\t\t\tactive: this._running,\n\t\t\tqueued: this._queue.length,\n\t\t\tmax: this._max\n\t\t};\n\t}\n};\nconst renderSemaphore = new RenderSemaphore(MAX_CONCURRENT_RENDERS);\nfunction toEvenDimension(n) {\n\tconst v = Math.round(n);\n\treturn v % 2 === 0 ? v : v + 1;\n}\nfunction resolveQuality(quality) {\n\tswitch (quality) {\n\t\tcase \"very_low\": return QUALITY_VERY_LOW;\n\t\tcase \"low\": return QUALITY_LOW;\n\t\tcase \"high\": return QUALITY_HIGH;\n\t\tcase \"very_high\": return QUALITY_VERY_HIGH;\n\t\tdefault: return QUALITY_VERY_HIGH;\n\t}\n}\nlet cachedVramUsage = \"N/A\";\nlet vramProbeInFlight = false;\nfunction refreshVramUsage() {\n\tif (vramProbeInFlight) return;\n\tvramProbeInFlight = true;\n\texec(\"nvidia-smi --query-gpu=memory.used,memory.total --format=csv,noheader,nounits\", {\n\t\tencoding: \"utf-8\",\n\t\ttimeout: 2e3\n\t}, (err, stdout) => {\n\t\tvramProbeInFlight = false;\n\t\tif (err || !stdout) return;\n\t\tconst [used, total] = stdout.trim().split(\",\").map((s) => s.trim());\n\t\tif (used && total) cachedVramUsage = `${used}MB / ${total}MB`;\n\t});\n}\nfunction getVramUsage() {\n\treturn cachedVramUsage;\n}\nconst DEFAULT_RING_CAPACITY = 2;\nconst MIN_RING_CAPACITY = 2;\nconst MAX_RING_CAPACITY = 8;\nfunction resolveRingCapacity(explicit) {\n\tconst fromEnv = Number(process.env.FRAMEFIELDS_RING_CAPACITY);\n\tconst requested = explicit ?? (Number.isFinite(fromEnv) && fromEnv > 0 ? fromEnv : NaN);\n\tif (!Number.isFinite(requested) || requested <= 0) return DEFAULT_RING_CAPACITY;\n\treturn Math.max(MIN_RING_CAPACITY, Math.min(MAX_RING_CAPACITY, Math.floor(requested)));\n}\nvar NodeSurfacePool = class {\n\tidle = [];\n\tmaxIdle = 2;\n\tacquire(device, width, height) {\n\t\tconst index = this.idle.findIndex((entry) => entry.device === device && entry.surface.width === width && entry.surface.height === height);\n\t\tif (index >= 0) {\n\t\t\tconst [entry] = this.idle.splice(index, 1);\n\t\t\tif (entry) return entry.surface;\n\t\t}\n\t\tfor (let i = this.idle.length - 1; i >= 0; i--) {\n\t\t\tconst entry = this.idle[i];\n\t\t\tif (entry && entry.device !== device) {\n\t\t\t\tthis.idle.splice(i, 1);\n\t\t\t\ttry {\n\t\t\t\t\tentry.surface.destroy();\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t}\n\t\treturn new NodeSurfaceProvider(device, width, height);\n\t}\n\trelease(device, surface) {\n\t\tif (this.idle.length >= this.maxIdle) {\n\t\t\ttry {\n\t\t\t\tsurface.destroy();\n\t\t\t} catch {}\n\t\t\treturn;\n\t\t}\n\t\tthis.idle.push({\n\t\t\tdevice,\n\t\t\tsurface\n\t\t});\n\t}\n\tdestroy() {\n\t\tfor (const entry of this.idle.splice(0)) try {\n\t\t\tentry.surface.destroy();\n\t\t} catch {}\n\t}\n};\nconst nodeSurfacePool = new NodeSurfacePool();\nfunction formatLutAsCube(lut) {\n\tconst lines = [\n\t\t\"# Created by Gatewai\",\n\t\tlut.type === \"3D\" ? `LUT_3D_SIZE ${lut.size}` : `LUT_1D_SIZE ${lut.size}`,\n\t\t\"\"\n\t];\n\tfor (const p of lut.points) lines.push(`${p[0].toFixed(6)} ${p[1].toFixed(6)} ${p[2].toFixed(6)}`);\n\treturn lines.join(\"\\n\");\n}\nvar HeadlessWebGPURenderer = class HeadlessWebGPURenderer {\n\tstatic isInitialized = false;\n\tstatic initPromise = null;\n\tstatic initFailureCount = 0;\n\tstatic MAX_INIT_FAILURES = 3;\n\tstatic nextRetryAt = 0;\n\tstatic initialize() {\n\t\tif (HeadlessWebGPURenderer.isInitialized) return Promise.resolve();\n\t\tif (HeadlessWebGPURenderer.initFailureCount >= HeadlessWebGPURenderer.MAX_INIT_FAILURES) return Promise.reject(/* @__PURE__ */ new Error(\"GPU initialization permanently failed — circuit breaker open\"));\n\t\tif (Date.now() < HeadlessWebGPURenderer.nextRetryAt) return Promise.reject(/* @__PURE__ */ new Error(\"GPU initialization in backoff period\"));\n\t\tif (HeadlessWebGPURenderer.initPromise) return HeadlessWebGPURenderer.initPromise;\n\t\tHeadlessWebGPURenderer.initPromise = (async () => {\n\t\t\ttry {\n\t\t\t\trendererLogger.debug(\"[HeadlessWebGPURenderer] Initializing headless WebGPU…\");\n\t\t\t\tawait initHeadlessWebGPU();\n\t\t\t\trendererLogger.debug(\"[HeadlessWebGPURenderer] Scanning node renderers…\");\n\t\t\t\tawait discoverAndRegisterNodeRenderers();\n\t\t\t\tHeadlessWebGPURenderer.isInitialized = true;\n\t\t\t\tHeadlessWebGPURenderer.initPromise = null;\n\t\t\t\tHeadlessWebGPURenderer.initFailureCount = 0;\n\t\t\t\tHeadlessWebGPURenderer.nextRetryAt = 0;\n\t\t\t\trendererLogger.debug(\"[HeadlessWebGPURenderer] Initialization complete.\");\n\t\t\t} catch (error) {\n\t\t\t\tHeadlessWebGPURenderer.initFailureCount++;\n\t\t\t\tHeadlessWebGPURenderer.nextRetryAt = Date.now() + 5e3 * 2 ** HeadlessWebGPURenderer.initFailureCount;\n\t\t\t\tHeadlessWebGPURenderer.initPromise = null;\n\t\t\t\trendererLogger.error({\n\t\t\t\t\terr: error instanceof Error ? error.message : String(error),\n\t\t\t\t\tfailureCount: HeadlessWebGPURenderer.initFailureCount,\n\t\t\t\t\tnextRetryAt: new Date(HeadlessWebGPURenderer.nextRetryAt).toISOString()\n\t\t\t\t}, \"[HeadlessWebGPURenderer] Initialization failed\");\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})();\n\t\treturn HeadlessWebGPURenderer.initPromise;\n\t}\n\tasync renderImage(virtualMedia, frame = 0, fps = 24, options = {}) {\n\t\tawait HeadlessWebGPURenderer.initialize();\n\t\tconst width = toEvenDimension(virtualMedia.metadata.width ?? 0);\n\t\tconst height = toEvenDimension(virtualMedia.metadata.height ?? 0);\n\t\tif (!width || !height) throw new Error(`Invalid dimensions: ${width}x${height}`);\n\t\tconst renderId = options.renderId ?? `img-${randomUUID()}`;\n\t\trendererLogger.debug({\n\t\t\trenderId,\n\t\t\tframe,\n\t\t\t...renderSemaphore.stats\n\t\t}, \"[HeadlessWebGPURenderer] Acquiring slot for image render\");\n\t\tawait renderSemaphore.acquire();\n\t\tlet surface;\n\t\tlet renderer;\n\t\tconst device = await ensureDevice();\n\t\ttry {\n\t\t\tawait preloadFonts(virtualMedia, device);\n\t\t\tsurface = nodeSurfacePool.acquire(device, width, height);\n\t\t\trenderer = getRenderer2D(device, surface.colorFormat);\n\t\t\tconst ctx = {\n\t\t\t\tdevice,\n\t\t\t\trenderer,\n\t\t\t\tsurface\n\t\t\t};\n\t\t\tupdateClockSignals(frame, fps, virtualMedia.metadata.durationMs ?? void 0);\n\t\t\tif (frame === 0 || lutStore.hasPending(device) || SlugFontCache.hasPending()) {\n\t\t\t\tconst preEncoder = device.createCommandEncoder();\n\t\t\t\tconst dummyTex = renderer.getTemporaryTexture(width, height);\n\t\t\t\tconst dummyView = dummyTex.createView();\n\t\t\t\trenderer.beginFrame(preEncoder, dummyView, {\n\t\t\t\t\tr: 0,\n\t\t\t\t\tg: 0,\n\t\t\t\t\tb: 0,\n\t\t\t\t\ta: 0\n\t\t\t\t}, width, height, \"clear\").end();\n\t\t\t\tawait drawCompositionTree(ctx, preEncoder, dummyView, dummyTex, width, height, virtualMedia, {\n\t\t\t\t\tframe,\n\t\t\t\t\tcompositionFrame: frame,\n\t\t\t\t\tfps,\n\t\t\t\t\tisHeadless: true,\n\t\t\t\t\trenderId,\n\t\t\t\t\tvirtualMedia,\n\t\t\t\t\tcontainerWidth: width,\n\t\t\t\t\tcontainerHeight: height,\n\t\t\t\t\tisVideoMode: virtualMedia.operation?.dataType === \"Video\"\n\t\t\t\t});\n\t\t\t\tdevice.queue.submit([preEncoder.finish()]);\n\t\t\t\tawait lutStore.awaitAllPending(device);\n\t\t\t}\n\t\t\tcompositionStateStore.setState(renderId, frame, fps, true);\n\t\t\tconst encoder = device.createCommandEncoder();\n\t\t\tconst targetView = surface.getCurrentTextureView();\n\t\t\tconst targetTexture = surface.getCurrentTexture();\n\t\t\trenderer.beginFrame(encoder, targetView, {\n\t\t\t\tr: 0,\n\t\t\t\tg: 0,\n\t\t\t\tb: 0,\n\t\t\t\ta: 0\n\t\t\t}, width, height, \"clear\").end();\n\t\t\tawait drawCompositionTree(ctx, encoder, targetView, targetTexture, width, height, virtualMedia, {\n\t\t\t\tframe,\n\t\t\t\tcompositionFrame: frame,\n\t\t\t\tfps,\n\t\t\t\tisHeadless: true,\n\t\t\t\trenderId,\n\t\t\t\tvirtualMedia,\n\t\t\t\tcontainerWidth: width,\n\t\t\t\tcontainerHeight: height,\n\t\t\t\tisVideoMode: virtualMedia.operation?.dataType === \"Video\"\n\t\t\t});\n\t\t\tdevice.queue.submit([encoder.finish()]);\n\t\t\tconst pixels = await surface.readPixels();\n\t\t\tconst pixelsArr = new Uint8Array(pixels.buffer, pixels.byteOffset, pixels.byteLength);\n\t\t\tif (options.format === \"rgba\") return Buffer.from(pixelsArr);\n\t\t\treturn await sharp(Buffer.from(pixelsArr), { raw: {\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t\tchannels: 4\n\t\t\t} }).png().toBuffer();\n\t\t} finally {\n\t\t\ttry {\n\t\t\t\tclearAllVideoCache();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tshaderStore.clear(renderId);\n\t\t\t} catch {}\n\t\t\tif (surface) nodeSurfacePool.release(device, surface);\n\t\t\ttry {\n\t\t\t\ttextureCache.destroy();\n\t\t\t} catch {}\n\t\t\trenderSemaphore.release();\n\t\t\trendererLogger.debug({\n\t\t\t\trenderId,\n\t\t\t\t...renderSemaphore.stats\n\t\t\t}, \"[HeadlessWebGPURenderer] Image render slot released\");\n\t\t}\n\t}\n\t/**\n\t* Renders a single frame to a PNG buffer at a specified timestamp in milliseconds or frame index.\n\t*/\n\tasync renderFrame(source, options = {}) {\n\t\tconst vm = typeof source === \"object\" && source !== null && \"toVirtualMedia\" in source ? source.toVirtualMedia() : source;\n\t\tconst fps = options.fps ?? (vm.metadata?.fps || 30);\n\t\tconst frame = options.atMs !== void 0 ? Math.round(options.atMs / 1e3 * fps) : options.frame ?? 0;\n\t\treturn this.renderImage(vm, frame, fps, {\n\t\t\trenderId: options.renderId,\n\t\t\tformat: options.format\n\t\t});\n\t}\n\t/**\n\t* Mixes the composition's full audio timeline (clips, effects, synthesized\n\t* tracks) to stereo PCM, exactly as `renderVideo` muxes it.\n\t*/\n\tasync renderAudio(virtualMedia, options = {}) {\n\t\tawait HeadlessWebGPURenderer.initialize();\n\t\tconst fps = options.fps ?? (virtualMedia.metadata?.fps || 30);\n\t\tawait renderSemaphore.acquire();\n\t\ttry {\n\t\t\tconst device = await ensureDevice();\n\t\t\treturn await mixAudioTracks(virtualMedia, fps, options.sampleRate ?? 48e3, device, `aud-${randomUUID()}`);\n\t\t} finally {\n\t\t\trenderSemaphore.release();\n\t\t}\n\t}\n\tasync renderLut(virtualMedia, frame = 0, fps = 24) {\n\t\tawait HeadlessWebGPURenderer.initialize();\n\t\tconst width = 32;\n\t\tconst height = 32;\n\t\tconst renderId = `lut-${randomUUID()}`;\n\t\trendererLogger.debug({\n\t\t\trenderId,\n\t\t\tframe,\n\t\t\t...renderSemaphore.stats\n\t\t}, \"[HeadlessWebGPURenderer] Acquiring slot for LUT render\");\n\t\tawait renderSemaphore.acquire();\n\t\tlet surface;\n\t\tlet renderer;\n\t\tconst device = await ensureDevice();\n\t\tlet lutData = null;\n\t\tconst lutSub = lutStore.onChange((key) => {\n\t\t\tconst raw = lutStore.getRawData(key);\n\t\t\tif (raw) lutData = raw;\n\t\t});\n\t\ttry {\n\t\t\tawait preloadFonts(virtualMedia, device);\n\t\t\tsurface = new NodeSurfaceProvider(device, width, height);\n\t\t\trenderer = getRenderer2D(device, surface.colorFormat);\n\t\t\tconst ctx = {\n\t\t\t\tdevice,\n\t\t\t\trenderer,\n\t\t\t\tsurface\n\t\t\t};\n\t\t\tif (frame === 0 || lutStore.hasPending(device) || SlugFontCache.hasPending()) {\n\t\t\t\tconst preEncoder = device.createCommandEncoder();\n\t\t\t\tconst dummyTex = renderer.getTemporaryTexture(width, height);\n\t\t\t\tconst dummyView = dummyTex.createView();\n\t\t\t\trenderer.beginFrame(preEncoder, dummyView, {\n\t\t\t\t\tr: 0,\n\t\t\t\t\tg: 0,\n\t\t\t\t\tb: 0,\n\t\t\t\t\ta: 0\n\t\t\t\t}, width, height, \"clear\").end();\n\t\t\t\tawait drawCompositionTree(ctx, preEncoder, dummyView, dummyTex, width, height, virtualMedia, {\n\t\t\t\t\tframe,\n\t\t\t\t\tcompositionFrame: frame,\n\t\t\t\t\tfps,\n\t\t\t\t\tisHeadless: true,\n\t\t\t\t\trenderId,\n\t\t\t\t\tvirtualMedia,\n\t\t\t\t\tcontainerWidth: width,\n\t\t\t\t\tcontainerHeight: height,\n\t\t\t\t\tisVideoMode: virtualMedia.operation?.dataType === \"Video\"\n\t\t\t\t});\n\t\t\t\tdevice.queue.submit([preEncoder.finish()]);\n\t\t\t\tawait lutStore.awaitAllPending(device);\n\t\t\t}\n\t\t\tcompositionStateStore.setState(renderId, frame, fps, true);\n\t\t\tconst encoder = device.createCommandEncoder();\n\t\t\tconst targetView = surface.getCurrentTextureView();\n\t\t\tconst targetTexture = surface.getCurrentTexture();\n\t\t\trenderer.beginFrame(encoder, targetView, {\n\t\t\t\tr: 0,\n\t\t\t\tg: 0,\n\t\t\t\tb: 0,\n\t\t\t\ta: 0\n\t\t\t}, width, height, \"clear\").end();\n\t\t\tawait drawCompositionTree(ctx, encoder, targetView, targetTexture, width, height, virtualMedia, {\n\t\t\t\tframe,\n\t\t\t\tcompositionFrame: frame,\n\t\t\t\tfps,\n\t\t\t\tisHeadless: true,\n\t\t\t\trenderId,\n\t\t\t\tvirtualMedia,\n\t\t\t\tcontainerWidth: width,\n\t\t\t\tcontainerHeight: height,\n\t\t\t\tisVideoMode: virtualMedia.operation?.dataType === \"Video\"\n\t\t\t});\n\t\t\tdevice.queue.submit([encoder.finish()]);\n\t\t\tawait lutStore.awaitAllPending(device);\n\t\t\tif (!lutData) lutData = lutStore.getAnyRawData();\n\t\t\tif (!lutData) throw new Error(\"No LUT data generated during rendering\");\n\t\t\tconst cubeContent = formatLutAsCube(lutData);\n\t\t\treturn Buffer.from(cubeContent, \"utf-8\");\n\t\t} finally {\n\t\t\ttry {\n\t\t\t\tlutSub();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tmediaDecoderCache.destroy();\n\t\t\t\tclearAllVideoCache();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tshaderStore.clear(renderId);\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tsurface?.destroy();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\ttextureCache.destroy();\n\t\t\t} catch {}\n\t\t\trenderSemaphore.release();\n\t\t\trendererLogger.debug({\n\t\t\t\trenderId,\n\t\t\t\t...renderSemaphore.stats\n\t\t\t}, \"[HeadlessWebGPURenderer] LUT render slot released\");\n\t\t}\n\t}\n\tasync resolveMediaDuration(virtualMedia, fps) {\n\t\tlet maxDurationMs = 0;\n\t\tconst queue = [virtualMedia];\n\t\tconst sources = /* @__PURE__ */ new Set();\n\t\twhile (queue.length > 0) {\n\t\t\tconst current = queue.shift();\n\t\t\tif (current.metadata?.durationMs && current.metadata.durationMs > maxDurationMs) maxDurationMs = current.metadata.durationMs;\n\t\t\tconst op = current.operation;\n\t\t\tif (op) {\n\t\t\t\tif (typeof op.source === \"string\") sources.add(op.source);\n\t\t\t\tif (typeof op.url === \"string\") sources.add(op.url);\n\t\t\t\tif (typeof op.inputHandleId === \"string\") sources.add(op.inputHandleId);\n\t\t\t\tif (Array.isArray(op.layout)) for (const node of op.layout) {\n\t\t\t\t\tif (node.inputHandleId) sources.add(node.inputHandleId);\n\t\t\t\t\tif (node.src) sources.add(node.src);\n\t\t\t\t\tif (typeof node.durationFrames === \"number\") {\n\t\t\t\t\t\tconst durMs = ((typeof node.startFrame === \"number\" ? node.startFrame : 0) + node.durationFrames) / fps * 1e3;\n\t\t\t\t\t\tif (durMs > maxDurationMs) maxDurationMs = durMs;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (current.children) queue.push(...current.children);\n\t\t}\n\t\tfor (const src of sources) try {\n\t\t\tconst sec = await (await inputStore.acquire(src)).computeDuration();\n\t\t\tif (Number.isFinite(sec) && sec > 0) {\n\t\t\t\tconst ms = Math.round(sec * 1e3);\n\t\t\t\tif (ms > maxDurationMs) maxDurationMs = ms;\n\t\t\t}\n\t\t} catch (_) {}\n\t\treturn maxDurationMs > 0 ? maxDurationMs : 1e3;\n\t}\n\tasync renderVideo(virtualMedia, options) {\n\t\tawait HeadlessWebGPURenderer.initialize();\n\t\tconst codecOption = options?.codec ?? \"h264\";\n\t\tconst isMp3 = codecOption === \"mp3\";\n\t\tconst isWebM = codecOption === \"vp8\" || codecOption === \"vp9\" || codecOption === \"opus\";\n\t\tconst mediaType = getMediaType(virtualMedia);\n\t\tconst isLut = mediaType === \"LUT\" || virtualMedia.operation?.dataType === \"LUT\";\n\t\tconst isAudioOnly = isMp3 || codecOption === \"aac\" || codecOption === \"opus\" || mediaType === \"Audio\";\n\t\tconst fps = virtualMedia.metadata.fps ?? (isAudioOnly || isLut ? 24 : void 0);\n\t\tif (!fps) {\n\t\t\tconst dataType = mediaType ?? virtualMedia.dataType ?? \"Unknown\";\n\t\t\tconst op = virtualMedia.operation?.op ?? virtualMedia.op ?? \"Unknown\";\n\t\t\tthrow new Error(`FPS is missing from virtualMedia metadata (dataType: \"${dataType}\", operation: \"${op}\")`);\n\t\t}\n\t\tconst width = toEvenDimension(virtualMedia.metadata.width ?? (isAudioOnly ? 1280 : 0));\n\t\tconst height = toEvenDimension(virtualMedia.metadata.height ?? (isAudioOnly ? 720 : 0));\n\t\tif (!width || !height) throw new Error(`Invalid dimensions: ${width}x${height}`);\n\t\tlet durationMs = virtualMedia.metadata.durationMs;\n\t\tif (!durationMs || durationMs <= 0) {\n\t\t\tdurationMs = await this.resolveMediaDuration(virtualMedia, fps);\n\t\t\tvirtualMedia.metadata.durationMs = durationMs;\n\t\t}\n\t\tconst totalFrames = Math.max(1, Math.round(durationMs / 1e3 * fps));\n\t\tconst renderId = `vid-${randomUUID()}`;\n\t\tconst qaOptions = options?.qa === true ? {} : options?.qa ? options.qa : void 0;\n\t\tconst inspector = qaOptions ? new FrameInspector(qaOptions) : void 0;\n\t\tlet videoQa;\n\t\tlet audioQa;\n\t\tconst videoCodec = codecOption === \"vp9\" ? \"vp9\" : codecOption === \"vp8\" ? \"vp8\" : \"avc\";\n\t\tconst audioCodec = options?.audioCodec ?? (isMp3 ? \"mp3\" : isWebM ? \"opus\" : \"aac\");\n\t\tconst quality = resolveQuality(options?.quality);\n\t\trendererLogger.debug({\n\t\t\trenderId,\n\t\t\ttotalFrames,\n\t\t\tfps,\n\t\t\twidth,\n\t\t\theight,\n\t\t\tcodec: codecOption,\n\t\t\t...renderSemaphore.stats\n\t\t}, \"[HeadlessWebGPURenderer] Acquiring slot for video render (inline)\");\n\t\tawait renderSemaphore.acquire();\n\t\tlet lastCpuUsage = process.cpuUsage();\n\t\tlet lastCpuTime = process.hrtime.bigint();\n\t\tconst getCpuUsage = () => {\n\t\t\tconst curCpuUsage = process.cpuUsage();\n\t\t\tconst curCpuTime = process.hrtime.bigint();\n\t\t\tconst userDiff = curCpuUsage.user - lastCpuUsage.user;\n\t\t\tconst sysDiff = curCpuUsage.system - lastCpuUsage.system;\n\t\t\tconst timeDiff = Number(curCpuTime - lastCpuTime) / 1e3;\n\t\t\tlastCpuUsage = curCpuUsage;\n\t\t\tlastCpuTime = curCpuTime;\n\t\t\tif (timeDiff === 0) return \"0.0%\";\n\t\t\tconst cpus = os.cpus().length || 1;\n\t\t\treturn `${((userDiff + sysDiff) / timeDiff * 100 / cpus).toFixed(1)}%`;\n\t\t};\n\t\tconst getRamUsage = () => {\n\t\t\tconst mem = process.memoryUsage();\n\t\t\tconst freeMem = os.freemem();\n\t\t\tconst totalMem = os.totalmem();\n\t\t\tconst usedMem = totalMem - freeMem;\n\t\t\tconst heapUsedMb = Math.round(mem.heapUsed / 1024 / 1024);\n\t\t\tconst heapTotalMb = Math.round(mem.heapTotal / 1024 / 1024);\n\t\t\treturn `Process: ${Math.round(mem.rss / 1024 / 1024)}MB RSS (${heapUsedMb}MB/${heapTotalMb}MB Heap), System: ${Math.round(usedMem / 1024 / 1024)}MB/${Math.round(totalMem / 1024 / 1024)}MB`;\n\t\t};\n\t\tlet statsInterval;\n\t\tif (process.env.NODE_ENV === \"production\") statsInterval = setInterval(() => {\n\t\t\trefreshVramUsage();\n\t\t\trendererLogger.info({\n\t\t\t\trenderId,\n\t\t\t\tcpu: getCpuUsage(),\n\t\t\t\tram: getRamUsage(),\n\t\t\t\tvram: getVramUsage(),\n\t\t\t\trenderQueue: renderSemaphore.stats\n\t\t\t}, \"[HeadlessWebGPURenderer] Performance Stats\");\n\t\t}, 5e3);\n\t\tconst tempDir = os.tmpdir();\n\t\tconst extension = isMp3 ? \"mp3\" : isWebM ? \"webm\" : \"mp4\";\n\t\tconst tempFilePath = path.join(tempDir, `render-${renderId}.${extension}`);\n\t\tconst tempGifPath = path.join(tempDir, `render-${renderId}.gif`);\n\t\tconst target = new FilePathTarget(tempFilePath);\n\t\tconst output = new Output({\n\t\t\tformat: isMp3 ? new Mp3OutputFormat() : isWebM ? new WebMOutputFormat() : new Mp4OutputFormat(),\n\t\t\ttarget\n\t\t});\n\t\tlet videoSource;\n\t\tif (!isAudioOnly) {\n\t\t\tvideoSource = new VideoSampleSource({\n\t\t\t\tcodec: videoCodec,\n\t\t\t\tbitrate: quality,\n\t\t\t\tlatencyMode: \"realtime\",\n\t\t\t\thardwareAcceleration: \"prefer-hardware\"\n\t\t\t});\n\t\t\toutput.addVideoTrack(videoSource);\n\t\t}\n\t\tconst audioSource = new AudioSampleSource({\n\t\t\tcodec: audioCodec,\n\t\t\tbitrate: quality\n\t\t});\n\t\toutput.addAudioTrack(audioSource);\n\t\tlet outputStarted = false;\n\t\tlet outputFinalized = false;\n\t\tconst device = await ensureDevice();\n\t\tlet surface;\n\t\tlet renderer;\n\t\tlet pipeline;\n\t\ttry {\n\t\t\tawait output.start();\n\t\t\toutputStarted = true;\n\t\t\tawait preloadFonts(virtualMedia, device);\n\t\t\tif (!isAudioOnly && videoSource) {\n\t\t\t\tsurface = new NodeSurfaceProvider(device, width, height);\n\t\t\t\trenderer = getRenderer2D(device, surface.colorFormat);\n\t\t\t\tpipeline = new ZeroCopyWebCodecsPipeline(device, {\n\t\t\t\t\twidth,\n\t\t\t\t\theight,\n\t\t\t\t\tfps,\n\t\t\t\t\tvideoSource,\n\t\t\t\t\tringCapacity: resolveRingCapacity(options?.ringCapacity),\n\t\t\t\t\tonFrame: inspector ? (rgba) => inspector.inspect(rgba, width, height) : void 0\n\t\t\t\t});\n\t\t\t\tconst ctx = surface && renderer ? {\n\t\t\t\t\tdevice,\n\t\t\t\t\trenderer,\n\t\t\t\t\tsurface\n\t\t\t\t} : null;\n\t\t\t\tconst prePass = async (frame) => {\n\t\t\t\t\tif (!ctx || !renderer) return;\n\t\t\t\t\tconst preEncoder = device.createCommandEncoder();\n\t\t\t\t\tconst dummyTex = renderer.getTemporaryTexture(width, height);\n\t\t\t\t\tconst dummyView = dummyTex.createView();\n\t\t\t\t\trenderer.beginFrame(preEncoder, dummyView, {\n\t\t\t\t\t\tr: 0,\n\t\t\t\t\t\tg: 0,\n\t\t\t\t\t\tb: 0,\n\t\t\t\t\t\ta: 0\n\t\t\t\t\t}, width, height, \"clear\").end();\n\t\t\t\t\tawait drawCompositionTree(ctx, preEncoder, dummyView, dummyTex, width, height, virtualMedia, {\n\t\t\t\t\t\tframe,\n\t\t\t\t\t\tcompositionFrame: frame,\n\t\t\t\t\t\tfps,\n\t\t\t\t\t\tisHeadless: true,\n\t\t\t\t\t\trenderId,\n\t\t\t\t\t\tvirtualMedia,\n\t\t\t\t\t\tcontainerWidth: width,\n\t\t\t\t\t\tcontainerHeight: height,\n\t\t\t\t\t\tisVideoMode: virtualMedia.operation?.dataType === \"Video\"\n\t\t\t\t\t});\n\t\t\t\t\tdevice.queue.submit([preEncoder.finish()]);\n\t\t\t\t\tawait lutStore.awaitAllPending(device);\n\t\t\t\t};\n\t\t\t\tawait prePass(0);\n\t\t\t\tfor (let i = 0; i < totalFrames; i++) {\n\t\t\t\t\toptions?.signal?.throwIfAborted();\n\t\t\t\t\tif (i % 10 === 0) rendererLogger.info({\n\t\t\t\t\t\trenderId,\n\t\t\t\t\t\tframe: i,\n\t\t\t\t\t\ttotalFrames\n\t\t\t\t\t}, `[HeadlessWebGPURenderer] Rendering frame ${i}/${totalFrames}`);\n\t\t\t\t\tif (ctx && surface && renderer && pipeline) {\n\t\t\t\t\t\tif (i > 0 && (lutStore.hasPending(device) || SlugFontCache.hasPending())) {\n\t\t\t\t\t\t\tupdateClockSignals(i, fps, durationMs);\n\t\t\t\t\t\t\tawait prePass(i);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcompositionStateStore.setState(renderId, i, fps, true);\n\t\t\t\t\t\tupdateClockSignals(i, fps, durationMs);\n\t\t\t\t\t\tconst encoder = device.createCommandEncoder();\n\t\t\t\t\t\tconst targetView = surface.getCurrentTextureView();\n\t\t\t\t\t\tconst targetTexture = surface.getCurrentTexture();\n\t\t\t\t\t\trenderer.beginFrame(encoder, targetView, {\n\t\t\t\t\t\t\tr: 0,\n\t\t\t\t\t\t\tg: 0,\n\t\t\t\t\t\t\tb: 0,\n\t\t\t\t\t\t\ta: 0\n\t\t\t\t\t\t}, width, height, \"clear\").end();\n\t\t\t\t\t\tawait drawCompositionTree(ctx, encoder, targetView, targetTexture, width, height, virtualMedia, {\n\t\t\t\t\t\t\tframe: i,\n\t\t\t\t\t\t\tcompositionFrame: i,\n\t\t\t\t\t\t\tfps,\n\t\t\t\t\t\t\tisHeadless: true,\n\t\t\t\t\t\t\trenderId,\n\t\t\t\t\t\t\tvirtualMedia,\n\t\t\t\t\t\t\tcontainerWidth: width,\n\t\t\t\t\t\t\tcontainerHeight: height,\n\t\t\t\t\t\t\tisVideoMode: virtualMedia.operation?.dataType === \"Video\"\n\t\t\t\t\t\t});\n\t\t\t\t\t\tawait pipeline.enqueueFrame(i, targetTexture, encoder);\n\t\t\t\t\t\toptions?.onProgress?.({\n\t\t\t\t\t\t\tphase: \"render\",\n\t\t\t\t\t\t\tframe: i + 1,\n\t\t\t\t\t\t\ttotalFrames\n\t\t\t\t\t\t});\n\t\t\t\t\t} else throw new Error(\"Invalid render context state\");\n\t\t\t\t}\n\t\t\t\tif (pipeline) {\n\t\t\t\t\tawait pipeline.drain();\n\t\t\t\t\tconst pipelineStats = pipeline.getStats();\n\t\t\t\t\tif (inspector && qaOptions) videoQa = inspector.stats(totalFrames, pipelineStats.totalFramesEncoded, fps, width, height, qaOptions);\n\t\t\t\t\trendererLogger.debug({\n\t\t\t\t\t\trenderId,\n\t\t\t\t\t\ttotalFrames,\n\t\t\t\t\t\t...pipelineStats\n\t\t\t\t\t}, `[HeadlessWebGPURenderer] All frames rendered and encoded (avg cycle: ${pipelineStats.averageCycleTimeMs.toFixed(2)}ms, throughput: ${pipelineStats.throughputFps.toFixed(1)} fps)`);\n\t\t\t\t}\n\t\t\t}\n\t\t\toptions?.signal?.throwIfAborted();\n\t\t\toptions?.onProgress?.({\n\t\t\t\tphase: \"audio\",\n\t\t\t\tframe: totalFrames,\n\t\t\t\ttotalFrames\n\t\t\t});\n\t\t\tconst { channels, sampleRate } = await mixAudioTracks(virtualMedia, fps, 48e3, device, renderId);\n\t\t\tconst numChannels = channels.length;\n\t\t\tif (numChannels === 0) throw new Error(\"mixAudioTracks returned no channels\");\n\t\t\tif (qaOptions) audioQa = analyzeAudio(channels, sampleRate, qaOptions);\n\t\t\tconst totalSamples = channels[0].length;\n\t\t\tconst chunkSize = Math.round(.1 * sampleRate);\n\t\t\tfor (let offset = 0; offset < totalSamples; offset += chunkSize) {\n\t\t\t\tconst currentChunk = Math.min(chunkSize, totalSamples - offset);\n\t\t\t\tconst interleaved = new Float32Array(currentChunk * numChannels);\n\t\t\t\tfor (let i = 0; i < currentChunk; i++) for (let ch = 0; ch < numChannels; ch++) interleaved[i * numChannels + ch] = channels[ch]?.[offset + i] ?? 0;\n\t\t\t\tconst sample = new AudioSample({\n\t\t\t\t\tdata: interleaved,\n\t\t\t\t\tformat: \"f32\",\n\t\t\t\t\tnumberOfChannels: numChannels,\n\t\t\t\t\tsampleRate,\n\t\t\t\t\ttimestamp: offset / sampleRate\n\t\t\t\t});\n\t\t\t\ttry {\n\t\t\t\t\tawait audioSource.add(sample);\n\t\t\t\t} finally {\n\t\t\t\t\tsample.close();\n\t\t\t\t}\n\t\t\t}\n\t\t\toptions?.signal?.throwIfAborted();\n\t\t\tawait output.finalize();\n\t\t\toutputFinalized = true;\n\t\t\tconst qa = qaOptions ? buildQaReport({\n\t\t\t\tvideo: videoQa,\n\t\t\t\taudio: audioQa,\n\t\t\t\tdiagnostics: takeRenderDiagnostics(renderId),\n\t\t\t\toptions: qaOptions\n\t\t\t}) : void 0;\n\t\t\tconst cleanup = async () => {\n\t\t\t\ttry {\n\t\t\t\t\tawait fs.unlink(tempFilePath).catch(() => {});\n\t\t\t\t\tif (codecOption === \"gif\") await fs.unlink(tempGifPath).catch(() => {});\n\t\t\t\t} catch {}\n\t\t\t};\n\t\t\tif (codecOption === \"gif\") {\n\t\t\t\trendererLogger.debug(\"[HeadlessWebGPURenderer] Converting rendered MP4 to high-quality GIF...\");\n\t\t\t\tawait convertMp4ToGif(tempFilePath, tempGifPath);\n\t\t\t\treturn {\n\t\t\t\t\tfilePath: tempGifPath,\n\t\t\t\t\tcleanup,\n\t\t\t\t\t...qa && { qa }\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tfilePath: tempFilePath,\n\t\t\t\tcleanup,\n\t\t\t\t...qa && { qa }\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tif (outputStarted && !outputFinalized) try {\n\t\t\t\tawait output.finalize();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tawait fs.unlink(tempFilePath).catch(() => {});\n\t\t\t\tif (codecOption === \"gif\") await fs.unlink(tempGifPath).catch(() => {});\n\t\t\t} catch {}\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tif (statsInterval) clearInterval(statsInterval);\n\t\t\ttry {\n\t\t\t\trenderer?.destroy();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tpipeline?.destroy();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tsurface?.destroy();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tmediaDecoderCache.destroy();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tclearAllVideoCache();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\ttextureCache.destroy();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tWebGPUAudioProcessor.clearCache(renderId);\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tshaderStore.clear(renderId);\n\t\t\t} catch {}\n\t\t\ttakeRenderDiagnostics(renderId);\n\t\t\trenderSemaphore.release();\n\t\t\trendererLogger.debug({\n\t\t\t\trenderId,\n\t\t\t\t...renderSemaphore.stats\n\t\t\t}, \"[HeadlessWebGPURenderer] Video render slot released\");\n\t\t}\n\t}\n};\nconst HeadlessMediaRenderer = HeadlessWebGPURenderer;\n\n//#endregion\nexport { FrameInspector as a, formatQaReport as c, ZeroCopyWebCodecsPipeline as i, integratedLoudness as l, HeadlessWebGPURenderer as n, analyzeAudio as o, renderSemaphore as r, buildQaReport as s, HeadlessMediaRenderer as t };\n//# sourceMappingURL=headless-webgpu-renderer-BTo2uZHD.mjs.map","import { a as NodeManifestError, c as DmaStagingRing, i as NODE_KINDS, l as preloadFonts, n as discoverAndRegisterNodeRenderers, o as loadNodeManifests, r as findNodesDir, s as parseNodeManifest, u as rendererLogger } from \"./bootstrap-mediabunny--TDh3Bij.mjs\";\nimport { a as FrameInspector, c as formatQaReport, i as ZeroCopyWebCodecsPipeline, l as integratedLoudness, n as HeadlessWebGPURenderer, o as analyzeAudio, r as renderSemaphore, s as buildQaReport, t as HeadlessMediaRenderer } from \"./headless-webgpu-renderer-BTo2uZHD.mjs\";\nimport { SlugFontCache, clearAllVideoCache, inputStore, lutStore, mediaDecoderCache, textureCache } from \"@framefields/webgpu-renderers\";\n\n//#region src/job-reset.ts\n/**\n* Drops every cache keyed by a file path or URL: media inputs and decoders,\n* textures, LUTs and fonts. A long-lived worker calls this between jobs,\n* because the next checkout may hold different bytes at the same path. The\n* GPU device and compiled pipelines stay warm.\n*/\nfunction resetRenderCaches() {\n\tclearAllVideoCache();\n\tmediaDecoderCache.destroy();\n\ttextureCache.destroy();\n\tinputStore.clear();\n\tlutStore.destroy();\n\tSlugFontCache.destroy();\n}\n\n//#endregion\nexport { DmaStagingRing, FrameInspector, HeadlessMediaRenderer, HeadlessWebGPURenderer, NODE_KINDS, NodeManifestError, ZeroCopyWebCodecsPipeline, analyzeAudio, buildQaReport, discoverAndRegisterNodeRenderers, findNodesDir, formatQaReport, integratedLoudness, loadNodeManifests, parseNodeManifest, preloadFonts, renderSemaphore, rendererLogger, resetRenderCaches };\n//# sourceMappingURL=index.mjs.map","import fs from \"node:fs/promises\";\nimport type { VirtualMediaData } from \"@framefields/core\";\nimport { Canvas, loadImage } from \"skia-canvas\";\nimport { HeadlessMediaRenderer } from \"./index.js\";\n\nexport interface FrameSamplePoint {\n\tframe: number;\n\ttimeMs: number;\n}\n\nexport interface FrameGridOptions {\n\t/**\n\t * Start frame index for sampling (inclusive). Defaults to 0.\n\t */\n\tstartFrame?: number;\n\n\t/**\n\t * End frame index for sampling (inclusive). Defaults to startFrame + 30.\n\t */\n\tendFrame?: number;\n\n\t/**\n\t * Step interval between sampled frames. Must be >= 1. Defaults to 5.\n\t */\n\tstepFrames?: number;\n\n\t/**\n\t * Explicit list of frame indices to sample. Overrides startFrame/endFrame/stepFrames.\n\t */\n\tframes?: number[];\n\n\t/**\n\t * Start time in milliseconds (alternative to startFrame).\n\t */\n\tstartMs?: number;\n\n\t/**\n\t * End time in milliseconds (alternative to endFrame).\n\t */\n\tendMs?: number;\n\n\t/**\n\t * Step interval in milliseconds (alternative to stepFrames).\n\t */\n\tstepMs?: number;\n\n\t/**\n\t * Explicit list of timestamps in milliseconds to sample.\n\t */\n\ttimesMs?: number[];\n\n\t/**\n\t * Frames per second override. If omitted, reads from media/composition metadata or defaults to 24.\n\t */\n\tfps?: number;\n\n\t/**\n\t * Number of columns in the grid. If omitted, calculated automatically to preserve balance.\n\t */\n\tcolumns?: number;\n\n\t/**\n\t * Width in pixels for each individual thumbnail cell.\n\t * Clamped to [120, 960]. Defaults to 320.\n\t */\n\tcellWidth?: number;\n\n\t/**\n\t * Explicit height for each cell. If omitted, computed from aspect ratio.\n\t */\n\tcellHeight?: number;\n\n\t/**\n\t * Gap in pixels between cells. Defaults to 12.\n\t */\n\tgap?: number;\n\n\t/**\n\t * Outer padding in pixels around the grid. Defaults to 16.\n\t */\n\tpadding?: number;\n\n\t/**\n\t * Background color for the grid canvas. Defaults to \"#090a0f\".\n\t */\n\tbackgroundColor?: string;\n\n\t/**\n\t * Whether to render frame number & millisecond badges on each cell. Defaults to true.\n\t */\n\tshowLabels?: boolean;\n\n\t/**\n\t * Whether to render the metadata header banner at the top of the grid. Defaults to true.\n\t */\n\tshowHeader?: boolean;\n\n\t/**\n\t * Custom header title text.\n\t */\n\theaderText?: string;\n\n\t/**\n\t * Optional file path to write the generated grid image directly to disk.\n\t */\n\toutputPath?: string;\n\n\t/**\n\t * Safety limit for total sampled frames to prevent memory exhaustion or oversized images.\n\t * Defaults to 64. Hard maximum is 120.\n\t */\n\tmaxFrames?: number;\n\n\t/**\n\t * Maximum allowed width for the generated image canvas. Defaults to 4096.\n\t */\n\tmaxGridWidth?: number;\n\n\t/**\n\t * Maximum allowed height for the generated image canvas. Defaults to 4096.\n\t */\n\tmaxGridHeight?: number;\n\n\t/**\n\t * Optional shared HeadlessMediaRenderer instance.\n\t */\n\trenderer?: HeadlessMediaRenderer;\n}\n\n/**\n * Resolves and validates the list of sample points from the provided options.\n */\nexport function resolveSamplePoints(\n\toptions: FrameGridOptions,\n\tdefaultFps = 24,\n\tdurationMs?: number,\n): { samples: FrameSamplePoint[]; fps: number } {\n\tconst fps = options.fps ?? defaultFps;\n\tif (fps <= 0) {\n\t\tthrow new Error(`[FrameGrid] Invalid fps: ${fps}. Must be > 0.`);\n\t}\n\n\tconst samples: FrameSamplePoint[] = [];\n\n\tif (Array.isArray(options.frames) && options.frames.length > 0) {\n\t\tfor (const f of options.frames) {\n\t\t\tif (typeof f !== \"number\" || f < 0 || !Number.isFinite(f)) {\n\t\t\t\tthrow new Error(`[FrameGrid] Invalid frame index in frames list: ${f}`);\n\t\t\t}\n\t\t\tsamples.push({\n\t\t\t\tframe: Math.round(f),\n\t\t\t\ttimeMs: Math.round((f / fps) * 1000),\n\t\t\t});\n\t\t}\n\t} else if (Array.isArray(options.timesMs) && options.timesMs.length > 0) {\n\t\tfor (const ms of options.timesMs) {\n\t\t\tif (typeof ms !== \"number\" || ms < 0 || !Number.isFinite(ms)) {\n\t\t\t\tthrow new Error(`[FrameGrid] Invalid timestamp in timesMs list: ${ms}`);\n\t\t\t}\n\t\t\tsamples.push({\n\t\t\t\tframe: Math.round((ms / 1000) * fps),\n\t\t\t\ttimeMs: Math.round(ms),\n\t\t\t});\n\t\t}\n\t} else if (\n\t\toptions.startMs !== undefined ||\n\t\toptions.endMs !== undefined ||\n\t\toptions.stepMs !== undefined\n\t) {\n\t\tconst startMs = options.startMs ?? 0;\n\t\tconst endMs = options.endMs ?? durationMs ?? startMs + 1000;\n\t\tconst stepMs = options.stepMs ?? Math.round((5 / fps) * 1000);\n\n\t\tif (startMs < 0 || endMs < startMs) {\n\t\t\tthrow new Error(\n\t\t\t\t`[FrameGrid] Invalid millisecond range: startMs=${startMs}, endMs=${endMs}. startMs must be <= endMs.`,\n\t\t\t);\n\t\t}\n\t\tif (stepMs <= 0) {\n\t\t\tthrow new Error(`[FrameGrid] Invalid stepMs: ${stepMs}. Must be > 0.`);\n\t\t}\n\n\t\tfor (let ms = startMs; ms <= endMs; ms += stepMs) {\n\t\t\tsamples.push({\n\t\t\t\tframe: Math.round((ms / 1000) * fps),\n\t\t\t\ttimeMs: Math.round(ms),\n\t\t\t});\n\t\t}\n\t} else {\n\t\tconst startFrame = options.startFrame ?? 0;\n\t\tconst endFrame =\n\t\t\toptions.endFrame ??\n\t\t\t(durationMs\n\t\t\t\t? Math.min(startFrame + 30, Math.floor((durationMs / 1000) * fps))\n\t\t\t\t: startFrame + 30);\n\t\tconst stepFrames = options.stepFrames ?? 5;\n\n\t\tif (startFrame < 0 || endFrame < startFrame) {\n\t\t\tthrow new Error(\n\t\t\t\t`[FrameGrid] Invalid frame range: startFrame=${startFrame}, endFrame=${endFrame}. startFrame must be <= endFrame.`,\n\t\t\t);\n\t\t}\n\t\tif (stepFrames <= 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`[FrameGrid] Invalid stepFrames: ${stepFrames}. Must be > 0.`,\n\t\t\t);\n\t\t}\n\n\t\tfor (let f = startFrame; f <= endFrame; f += stepFrames) {\n\t\t\tsamples.push({\n\t\t\t\tframe: Math.round(f),\n\t\t\t\ttimeMs: Math.round((f / fps) * 1000),\n\t\t\t});\n\t\t}\n\t}\n\n\tconst maxFramesLimit = Math.min(options.maxFrames ?? 64, 120);\n\tif (samples.length > maxFramesLimit) {\n\t\tthrow new Error(\n\t\t\t`[FrameGrid] Requested ${samples.length} frames exceeds the safety threshold of ${maxFramesLimit}. ` +\n\t\t\t\t`Increase stepFrames/stepMs or narrow the start/end range to prevent oversized images.`,\n\t\t);\n\t}\n\n\tif (samples.length === 0) {\n\t\tthrow new Error(\"[FrameGrid] Zero frames were resolved for sampling.\");\n\t}\n\n\treturn { samples, fps };\n}\n\n/**\n * Computes grid layout dimensions, ensuring resulting canvas does not exceed size limits.\n */\nexport function computeGridLayout(\n\tnumSamples: number,\n\taspectRatio: number,\n\toptions: FrameGridOptions,\n): {\n\tcolumns: number;\n\trows: number;\n\tcellWidth: number;\n\tcellHeight: number;\n\ttotalWidth: number;\n\ttotalHeight: number;\n\theaderHeight: number;\n\tgap: number;\n\tpadding: number;\n} {\n\tconst gap = options.gap ?? 12;\n\tconst padding = options.padding ?? 16;\n\tconst showHeader = options.showHeader ?? true;\n\tconst headerHeight = showHeader ? 54 : 0;\n\tconst maxGridWidth = options.maxGridWidth ?? 4096;\n\tconst maxGridHeight = options.maxGridHeight ?? 4096;\n\n\tlet columns = options.columns;\n\tif (!columns || columns <= 0) {\n\t\tif (numSamples <= 4) columns = numSamples;\n\t\telse if (numSamples <= 9) columns = 3;\n\t\telse if (numSamples <= 16) columns = 4;\n\t\telse if (numSamples <= 25) columns = 5;\n\t\telse columns = 6;\n\t}\n\tcolumns = Math.min(columns, numSamples);\n\tconst rows = Math.ceil(numSamples / columns);\n\n\tlet cellWidth = Math.max(120, Math.min(options.cellWidth ?? 320, 960));\n\tlet cellHeight =\n\t\toptions.cellHeight ??\n\t\tMath.round(cellWidth / (aspectRatio > 0 ? aspectRatio : 16 / 9));\n\n\tlet totalWidth = columns * cellWidth + (columns - 1) * gap + padding * 2;\n\tlet totalHeight =\n\t\trows * cellHeight + (rows - 1) * gap + padding * 2 + headerHeight;\n\n\t// Downscale thumbnail size if the unconstrained canvas exceeds max dimensions\n\tif (totalWidth > maxGridWidth || totalHeight > maxGridHeight) {\n\t\tconst scaleFactor = Math.min(\n\t\t\t(maxGridWidth - (columns - 1) * gap - padding * 2) /\n\t\t\t\t(columns * cellWidth),\n\t\t\t(maxGridHeight - (rows - 1) * gap - padding * 2 - headerHeight) /\n\t\t\t\t(rows * cellHeight),\n\t\t);\n\n\t\tif (scaleFactor < 0.25) {\n\t\t\tthrow new Error(\n\t\t\t\t`[FrameGrid] Cannot fit ${numSamples} cells (${columns}x${rows}) into max dimensions ` +\n\t\t\t\t\t`[${maxGridWidth}x${maxGridHeight}]. Reduce cell count or decrease cellWidth.`,\n\t\t\t);\n\t\t}\n\n\t\tcellWidth = Math.max(100, Math.floor(cellWidth * scaleFactor));\n\t\tcellHeight = Math.round(\n\t\t\tcellWidth / (aspectRatio > 0 ? aspectRatio : 16 / 9),\n\t\t);\n\n\t\ttotalWidth = columns * cellWidth + (columns - 1) * gap + padding * 2;\n\t\ttotalHeight =\n\t\t\trows * cellHeight + (rows - 1) * gap + padding * 2 + headerHeight;\n\t}\n\n\treturn {\n\t\tcolumns,\n\t\trows,\n\t\tcellWidth,\n\t\tcellHeight,\n\t\ttotalWidth,\n\t\ttotalHeight,\n\t\theaderHeight,\n\t\tgap,\n\t\tpadding,\n\t};\n}\n\nexport type FrameGridRenderable = {\n\ttoVirtualMedia(): VirtualMediaData;\n\trenderFrame(options: {\n\t\tframe?: number;\n\t\tatMs?: number;\n\t\tfps?: number;\n\t\trenderer?: HeadlessMediaRenderer;\n\t}): Promise<Buffer>;\n\tfps?: number;\n\tdurationMs?: number;\n\twidth?: number;\n\theight?: number;\n};\n\n/**\n * Renders a sequence of frames from a Composition or Media pipeline into a unified image grid (contact sheet).\n * Ideal for visual inspection of kinetic motion, transitions, easing, and layout stability.\n */\nexport async function renderFrameGrid(\n\ttarget: FrameGridRenderable,\n\toptions: FrameGridOptions = {},\n): Promise<Buffer> {\n\tconst defaultFps = target.fps ?? 24;\n\tconst durationMs = target.durationMs;\n\tconst { samples, fps } = resolveSamplePoints(options, defaultFps, durationMs);\n\n\tconst compWidth = target.width ?? 1920;\n\tconst compHeight = target.height ?? 1080;\n\tconst aspectRatio =\n\t\tcompWidth > 0 && compHeight > 0 ? compWidth / compHeight : 16 / 9;\n\n\tconst layout = computeGridLayout(samples.length, aspectRatio, options);\n\tconst renderer = options.renderer ?? new HeadlessMediaRenderer();\n\n\t// Render each frame sequentially to manage GPU resources cleanly\n\tconst frameBuffers: Buffer[] = [];\n\tfor (const sample of samples) {\n\t\tconst buf = await target.renderFrame({\n\t\t\tframe: sample.frame,\n\t\t\tatMs: sample.timeMs,\n\t\t\tfps,\n\t\t\trenderer,\n\t\t});\n\t\tframeBuffers.push(buf);\n\t}\n\n\t// Composite into a single grid canvas using skia-canvas\n\tconst canvas = new Canvas(layout.totalWidth, layout.totalHeight);\n\tconst ctx = canvas.getContext(\"2d\");\n\n\t// Fill background\n\tctx.fillStyle = options.backgroundColor ?? \"#090a0f\";\n\tctx.fillRect(0, 0, layout.totalWidth, layout.totalHeight);\n\n\t// Header banner\n\tif (options.showHeader !== false && layout.headerHeight > 0) {\n\t\tconst title =\n\t\t\toptions.headerText ??\n\t\t\t`FrameGrid Conformance Review | Frames ${samples[0].frame}–${samples[samples.length - 1].frame} (Count: ${samples.length})`;\n\t\tconst subtitle = `${compWidth}×${compHeight} @ ${fps} FPS | Cell: ${layout.cellWidth}×${layout.cellHeight}px | Step: ${\n\t\t\toptions.stepFrames\n\t\t\t\t? `${options.stepFrames}f`\n\t\t\t\t: options.stepMs\n\t\t\t\t\t? `${options.stepMs}ms`\n\t\t\t\t\t: \"Custom\"\n\t\t}`;\n\n\t\tctx.fillStyle = \"#f8fafc\";\n\t\tctx.font = \"bold 15px sans-serif\";\n\t\tctx.fillText(title, layout.padding, layout.padding + 18);\n\n\t\tctx.fillStyle = \"#94a3b8\";\n\t\tctx.font = \"12px sans-serif\";\n\t\tctx.fillText(subtitle, layout.padding, layout.padding + 36);\n\n\t\t// Subtle divider line\n\t\tctx.strokeStyle = \"#1e2433\";\n\t\tctx.lineWidth = 1;\n\t\tctx.beginPath();\n\t\tctx.moveTo(layout.padding, layout.padding + 46);\n\t\tctx.lineTo(layout.totalWidth - layout.padding, layout.padding + 46);\n\t\tctx.stroke();\n\t}\n\n\tconst showLabels = options.showLabels ?? true;\n\n\t// Draw each sampled cell\n\tfor (let i = 0; i < samples.length; i++) {\n\t\tconst sample = samples[i];\n\t\tconst col = i % layout.columns;\n\t\tconst row = Math.floor(i / layout.columns);\n\n\t\tconst x = layout.padding + col * (layout.cellWidth + layout.gap);\n\t\tconst y =\n\t\t\tlayout.padding +\n\t\t\tlayout.headerHeight +\n\t\t\trow * (layout.cellHeight + layout.gap);\n\n\t\tconst img = await loadImage(frameBuffers[i]);\n\t\tctx.drawImage(img, x, y, layout.cellWidth, layout.cellHeight);\n\n\t\t// Subtle cell border\n\t\tctx.strokeStyle = \"#262b3d\";\n\t\tctx.lineWidth = 1;\n\t\tctx.strokeRect(x, y, layout.cellWidth, layout.cellHeight);\n\n\t\t// Sleek metadata pill badge\n\t\tif (showLabels) {\n\t\t\tconst label = `F:${sample.frame} • ${sample.timeMs}ms`;\n\n\t\t\tctx.font = \"bold 11px sans-serif\";\n\t\t\tconst textWidth = ctx.measureText(label).width;\n\t\t\tconst badgeW = textWidth + 14;\n\t\t\tconst badgeH = 20;\n\t\t\tconst badgeX = x + 6;\n\t\t\tconst badgeY = y + 6;\n\n\t\t\t// Badge backdrop\n\t\t\tctx.fillStyle = \"#090a0fee\";\n\t\t\tctx.beginPath();\n\t\t\tctx.roundRect(badgeX, badgeY, badgeW, badgeH, 4);\n\t\t\tctx.fill();\n\n\t\t\t// Badge border\n\t\t\tctx.strokeStyle = \"#6366f155\";\n\t\t\tctx.lineWidth = 1;\n\t\t\tctx.stroke();\n\n\t\t\t// Badge text\n\t\t\tctx.fillStyle = \"#e2e8f0\";\n\t\t\tctx.fillText(label, badgeX + 7, badgeY + 14);\n\t\t}\n\t}\n\n\tconst gridBuffer = await canvas.toBuffer(\"png\");\n\n\tif (options.outputPath) {\n\t\tawait fs.writeFile(options.outputPath, gridBuffer);\n\t}\n\n\treturn gridBuffer;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAYA,MAAM,iBAAiB,KAAK;CAC3B,OAAO,OAAO,YAAY,eAAe,QAAQ,KAAK,aAAa;CACnE,WAAW,KAAK,iBAAiB;CACjC,MAAM,EAAE,WAAW,YAAY;CAC/B,CAAC;;;;;;;AAUF,eAAe,aAAa,OAAO,SAAS,MAAM;AACjD,KAAI,CAAC,MAAO;AACZ,OAAM,wBAAwB,OAAO,SAAS,KAAK,SAAS,eAAe,MAAM,KAAK,6CAA6C,OAAO,CAAC;;;;;;;;;;AAa5I,IAAI,iBAAiB,MAAM;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,cAAc;CACd,YAAY,QAAQ,SAAS;AAC5B,OAAK,SAAS;AACd,OAAK,QAAQ,QAAQ;AACrB,OAAK,SAAS,QAAQ;AACtB,OAAK,WAAW,KAAK,IAAI,GAAG,QAAQ,YAAY,EAAE;AAClD,OAAK,SAAS,QAAQ,UAAU;AAChC,OAAK,sBAAsB,KAAK,QAAQ;EACxC,MAAM,eAAe;AACrB,OAAK,cAAc,KAAK,KAAK,KAAK,sBAAsB,aAAa,GAAG;AACxE,OAAK,aAAa,KAAK,cAAc,KAAK;AAC1C,OAAK,QAAQ,EAAE;AACf,OAAK,IAAI,IAAI,GAAG,IAAI,KAAK,UAAU,KAAK;GACvC,MAAM,SAAS,OAAO,aAAa;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AAO;GAEX,MAAM,SADY,IAAI,YAAY,MAAM,CAAC,QACd;GAC3B,MAAM,SAAS;GACf,MAAM,SAAS,IAAI;GACnB,MAAM,SAAS,IAAI;AAGnB,OAAI,YAAY;AAChB,OAAI,WAAW;AACf,OAAI,UAAU,QAAQ,QAAQ,QAAQ,QAAQ,EAAE;AAChD,OAAI,MAAM;AAGV,OAAI,cAAc;AAClB,OAAI,YAAY;AAChB,OAAI,QAAQ;AAGZ,OAAI,YAAY;AAChB,OAAI,SAAS,OAAO,SAAS,GAAG,SAAS,GAAG;;;CAI9C,MAAM,aAAa,MAAM,OAAO,SAAS,MAAM;AAE/C,KAAI,QAAQ,WACX,OAAMC,KAAG,UAAU,QAAQ,YAAY,WAAW;AAGnD,QAAO"}
1
+ {"version":3,"file":"renderer-1vhaKMeg.mjs","names":["resolve","resolve","HeadlessWebGPURenderer","fs","fs"],"sources":["../../renderer/dist/bootstrap-mediabunny--TDh3Bij.mjs","../../renderer/dist/headless-webgpu-renderer-BTo2uZHD.mjs","../../renderer/dist/index.mjs","../src/renderer/framegrid.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\nimport { preloadCompositionFonts } from \"@framefields/renderers\";\nimport pino from \"pino\";\nimport * as webcodecs from \"@napi-rs/webcodecs\";\nimport { VideoFrame } from \"@napi-rs/webcodecs\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport { audioRegistry, registerWebGPURenderer } from \"@framefields/node-sdk\";\nimport { registerMediabunnyServer } from \"@mediabunny/server\";\n\n//#region src/logger.ts\nconst rendererLogger = pino({\n\tlevel: typeof process !== \"undefined\" && process.env?.LOG_LEVEL || \"info\",\n\ttimestamp: pino.stdTimeFunctions.isoTime,\n\tbase: { component: \"renderer\" }\n});\n\n//#endregion\n//#region src/asset-preloader.ts\n/**\n* Preloads only the fonts (and emoji) a VirtualMediaData tree's text uses, so\n* typography renders correctly on Node.js without loading its media. Shared\n* with the browser preview; emoji need a font set with\n* `FontManager.registerEmojiFont()`.\n*/\nasync function preloadFonts(media, device = null) {\n\tif (!media) return;\n\tawait preloadCompositionFonts(media, device, (err, what) => rendererLogger.error(err, `[HeadlessMediaRenderer] Failed to preload ${what}`));\n}\n\n//#endregion\n//#region src/dma-staging-ring.ts\n/**\n* Pipelined Asynchronous DMA Staging Ring for WebGPU.\n*\n* Implements double-buffered (or N-buffered) GPU staging buffers to overlap\n* GPU render passes with asynchronous DMA host transfers and WebCodecs hardware encoding.\n* Eliminates GPU stalls by allowing Frame i+1 to execute on the GPU while Frame i\n* is asynchronously mapped and consumed by the hardware video encoder.\n*/\nvar DmaStagingRing = class {\n\twidth;\n\theight;\n\tcapacity;\n\tbytesPerRow;\n\tunpaddedBytesPerRow;\n\tbufferSize;\n\tformat;\n\tdevice;\n\tslots;\n\tisDestroyed = false;\n\tconstructor(device, options) {\n\t\tthis.device = device;\n\t\tthis.width = options.width;\n\t\tthis.height = options.height;\n\t\tthis.capacity = Math.max(2, options.capacity ?? 2);\n\t\tthis.format = options.format ?? \"rgba8unorm\";\n\t\tthis.unpaddedBytesPerRow = this.width * 4;\n\t\tconst rowAlignment = 256;\n\t\tthis.bytesPerRow = Math.ceil(this.unpaddedBytesPerRow / rowAlignment) * rowAlignment;\n\t\tthis.bufferSize = this.bytesPerRow * this.height;\n\t\tthis.slots = [];\n\t\tfor (let i = 0; i < this.capacity; i++) {\n\t\t\tconst buffer = device.createBuffer({\n\t\t\t\tsize: this.bufferSize,\n\t\t\t\tusage: GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST\n\t\t\t});\n\t\t\tthis.slots.push({\n\t\t\t\tindex: i,\n\t\t\t\tbuffer,\n\t\t\t\tstatus: \"idle\",\n\t\t\t\tinFlightFrame: null,\n\t\t\t\tmapPromise: null\n\t\t\t});\n\t\t}\n\t}\n\t/**\n\t* Prepares the staging buffer slot for writing by ensuring any prior mapping\n\t* from a previous cycle has been completed and unmapped.\n\t*/\n\tasync prepareSlot(frameIndex) {\n\t\tthis.checkDestroyed();\n\t\tconst slot = this.slots[frameIndex % this.capacity];\n\t\tif (!slot) return;\n\t\tif (slot.status === \"mapping\" && slot.mapPromise) await slot.mapPromise;\n\t\tif (slot.status === \"mapped\") {\n\t\t\tslot.buffer.unmap();\n\t\t\tslot.status = \"idle\";\n\t\t\tslot.inFlightFrame = null;\n\t\t\tslot.mapPromise = null;\n\t\t}\n\t}\n\t/**\n\t* Records a GPU-to-buffer DMA copy command into the provided command encoder.\n\t*/\n\tstageTexture(encoder, texture, frameIndex) {\n\t\tthis.checkDestroyed();\n\t\tconst slot = this.slots[frameIndex % this.capacity];\n\t\tif (!slot) throw new Error(`Invalid slot index for frame ${frameIndex}`);\n\t\tif (slot.status === \"mapped\" || slot.status === \"mapping\") throw new Error(`Staging buffer slot ${slot.index} is busy (status: ${slot.status}) for frame ${frameIndex}. Call prepareSlot() before staging.`);\n\t\tencoder.copyTextureToBuffer({ texture }, {\n\t\t\tbuffer: slot.buffer,\n\t\t\tbytesPerRow: this.bytesPerRow\n\t\t}, [this.width, this.height]);\n\t\tslot.status = \"rendering\";\n\t\tslot.inFlightFrame = frameIndex;\n\t}\n\t/**\n\t* Initiates asynchronous DMA mapping on the slot for the specified frame.\n\t* Must be called immediately after submitting the command encoder to the device queue.\n\t*/\n\tscheduleMap(frameIndex) {\n\t\tthis.checkDestroyed();\n\t\tconst slot = this.slots[frameIndex % this.capacity];\n\t\tif (!slot) throw new Error(`Invalid slot index for frame ${frameIndex}`);\n\t\tslot.status = \"mapping\";\n\t\tconst mapPromise = slot.buffer.mapAsync(GPUMapMode.READ).then(() => {\n\t\t\tslot.status = \"mapped\";\n\t\t});\n\t\tslot.mapPromise = mapPromise;\n\t\treturn mapPromise;\n\t}\n\t/**\n\t* Awaits asynchronous mapping and extracts pixels into a tightly packed Uint8Array.\n\t* The slot remains in the \"mapped\" state until releaseFrame() is called.\n\t*/\n\tasync readFramePixels(frameIndex) {\n\t\tthis.checkDestroyed();\n\t\tconst slot = this.slots[frameIndex % this.capacity];\n\t\tif (!slot) throw new Error(`Invalid slot index for frame ${frameIndex}`);\n\t\tif (slot.mapPromise) await slot.mapPromise;\n\t\tif (slot.status !== \"mapped\") throw new Error(`Staging slot ${slot.index} is not mapped (status: ${slot.status}) for frame ${frameIndex}`);\n\t\tconst mappedRange = slot.buffer.getMappedRange();\n\t\tconst sourceView = new Uint8Array(mappedRange);\n\t\tconst output = new Uint8Array(this.unpaddedBytesPerRow * this.height);\n\t\tif (this.bytesPerRow === this.unpaddedBytesPerRow) output.set(sourceView);\n\t\telse for (let y = 0; y < this.height; y++) {\n\t\t\tconst srcOffset = y * this.bytesPerRow;\n\t\t\tconst dstOffset = y * this.unpaddedBytesPerRow;\n\t\t\toutput.set(sourceView.subarray(srcOffset, srcOffset + this.unpaddedBytesPerRow), dstOffset);\n\t\t}\n\t\treturn output;\n\t}\n\t/**\n\t* Awaits asynchronous mapping, extracts pixels, and immediately unmaps the staging buffer,\n\t* returning the slot to \"idle\" state so it can be reused immediately.\n\t*/\n\tasync readAndReleaseFrame(frameIndex) {\n\t\tconst pixels = await this.readFramePixels(frameIndex);\n\t\tthis.releaseFrame(frameIndex);\n\t\treturn pixels;\n\t}\n\t/**\n\t* Directly reads the mapped staging buffer into a WebCodecs VideoFrame,\n\t* bypassing redundant intermediate JS allocations when row pitches align,\n\t* and immediately unmaps the buffer.\n\t*/\n\tasync readFrameToVideoFrame(frameIndex, timestampUs, colorSpace, inspect) {\n\t\tthis.checkDestroyed();\n\t\tconst slot = this.slots[frameIndex % this.capacity];\n\t\tif (!slot) throw new Error(`Invalid slot index for frame ${frameIndex}`);\n\t\tif (slot.mapPromise) await slot.mapPromise;\n\t\tif (slot.status !== \"mapped\") throw new Error(`Staging slot ${slot.index} is not mapped (status: ${slot.status}) for frame ${frameIndex}`);\n\t\tconst mappedRange = slot.buffer.getMappedRange();\n\t\tconst sourceView = new Uint8Array(mappedRange);\n\t\tlet pixelData;\n\t\tif (this.bytesPerRow === this.unpaddedBytesPerRow) pixelData = sourceView;\n\t\telse {\n\t\t\tpixelData = new Uint8Array(this.unpaddedBytesPerRow * this.height);\n\t\t\tfor (let y = 0; y < this.height; y++) {\n\t\t\t\tconst srcOffset = y * this.bytesPerRow;\n\t\t\t\tconst dstOffset = y * this.unpaddedBytesPerRow;\n\t\t\t\tpixelData.set(sourceView.subarray(srcOffset, srcOffset + this.unpaddedBytesPerRow), dstOffset);\n\t\t\t}\n\t\t}\n\t\tinspect?.(pixelData);\n\t\tconst vf = new VideoFrame(pixelData, {\n\t\t\tformat: \"RGBA\",\n\t\t\tcodedWidth: this.width,\n\t\t\tcodedHeight: this.height,\n\t\t\ttimestamp: timestampUs,\n\t\t\tcolorSpace: {\n\t\t\t\tprimaries: colorSpace?.primaries ?? \"bt709\",\n\t\t\t\ttransfer: colorSpace?.transfer ?? \"bt709\",\n\t\t\t\tmatrix: colorSpace?.matrix ?? \"bt709\",\n\t\t\t\tfullRange: colorSpace?.fullRange ?? false\n\t\t\t}\n\t\t});\n\t\tthis.releaseFrame(frameIndex);\n\t\treturn vf;\n\t}\n\t/**\n\t* Unmaps the staging buffer for the specified frame and marks the slot idle.\n\t*/\n\treleaseFrame(frameIndex) {\n\t\tconst slot = this.slots[frameIndex % this.capacity];\n\t\tif (!slot) return;\n\t\tif (slot.status === \"mapped\") {\n\t\t\ttry {\n\t\t\t\tslot.buffer.unmap();\n\t\t\t} catch (_) {}\n\t\t\tslot.status = \"idle\";\n\t\t\tslot.inFlightFrame = null;\n\t\t\tslot.mapPromise = null;\n\t\t}\n\t}\n\t/**\n\t* Returns current status info for each slot in the ring.\n\t*/\n\tgetSlotInfos() {\n\t\treturn this.slots.map((slot) => ({\n\t\t\tindex: slot.index,\n\t\t\tstatus: slot.status,\n\t\t\tinFlightFrame: slot.inFlightFrame\n\t\t}));\n\t}\n\t/**\n\t* Destroys all staging buffers and releases resources.\n\t*/\n\tdestroy() {\n\t\tif (this.isDestroyed) return;\n\t\tthis.isDestroyed = true;\n\t\tfor (const slot of this.slots) {\n\t\t\tif (slot.status === \"mapped\") try {\n\t\t\t\tslot.buffer.unmap();\n\t\t\t} catch (_) {}\n\t\t\tslot.status = \"idle\";\n\t\t\tslot.inFlightFrame = null;\n\t\t\tslot.mapPromise = null;\n\t\t}\n\t\tthis.slots.length = 0;\n\t}\n\tcheckDestroyed() {\n\t\tif (this.isDestroyed) throw new Error(\"DmaStagingRing has been destroyed\");\n\t}\n};\n\n//#endregion\n//#region src/generated/node-renderers.ts\nconst BUILTIN_NODE_RENDERERS = [\n\t{\n\t\tpackageName: \"@framefields/node-lut\",\n\t\tops: [\"ApplyLUT\"],\n\t\tload: () => import(\"@framefields/node-lut/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-audio-compressor\",\n\t\tops: [\"AudioCompressor\"],\n\t\tload: () => import(\"@framefields/node-audio-compressor/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-audio-delay\",\n\t\tops: [\"AudioDelay\"],\n\t\tload: () => import(\"@framefields/node-audio-delay/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-audio-fade\",\n\t\tops: [\"AudioFade\"],\n\t\tload: () => import(\"@framefields/node-audio-fade/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-audio-noise-gate\",\n\t\tops: [\"AudioNoiseGate\"],\n\t\tload: () => import(\"@framefields/node-audio-noise-gate/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-audio-parametric-eq\",\n\t\tops: [\"AudioParametricEq\"],\n\t\tload: () => import(\"@framefields/node-audio-parametric-eq/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-audio-reverb\",\n\t\tops: [\"AudioReverb\"],\n\t\tload: () => import(\"@framefields/node-audio-reverb/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-audio-signal-extractor\",\n\t\tops: [\"AudioSignalExtractor\"],\n\t\tload: () => import(\"@framefields/node-audio-signal-extractor/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-blur\",\n\t\tops: [\"Blur\"],\n\t\tload: () => import(\"@framefields/node-blur/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-camera-parallax-3d\",\n\t\tops: [\"CameraParallax3D\"],\n\t\tload: () => import(\"@framefields/node-camera-parallax-3d/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-canvas-generator\",\n\t\tops: [\"CanvasGenerator\"],\n\t\tload: () => import(\"@framefields/node-canvas-generator/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-channel-merger\",\n\t\tops: [\"ChannelMerger\"],\n\t\tload: () => import(\"@framefields/node-channel-merger/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-channel-splitter\",\n\t\tops: [\"ChannelSplitter\"],\n\t\tload: () => import(\"@framefields/node-channel-splitter/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-color-balance\",\n\t\tops: [\"ColorBalance\"],\n\t\tload: () => import(\"@framefields/node-color-balance/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-colorkey\",\n\t\tops: [\"ColorKey\"],\n\t\tload: () => import(\"@framefields/node-colorkey/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-compositor\",\n\t\tops: [\"Compositor\"],\n\t\tload: () => import(\"@framefields/node-compositor/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-corner-pin\",\n\t\tops: [\"CornerPin\"],\n\t\tload: () => import(\"@framefields/node-corner-pin/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-crop\",\n\t\tops: [\"Crop\"],\n\t\tload: () => import(\"@framefields/node-crop/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-curves\",\n\t\tops: [\"Curves\"],\n\t\tload: () => import(\"@framefields/node-curves/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-deflicker\",\n\t\tops: [\"TemporalDeflicker\", \"Deflicker\"],\n\t\tload: () => import(\"@framefields/node-deflicker/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-displacement-map\",\n\t\tops: [\"DisplacementMap\"],\n\t\tload: () => import(\"@framefields/node-displacement-map/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-extract-frame\",\n\t\tops: [\"ExtractFrame\"],\n\t\tload: () => import(\"@framefields/node-extract-frame/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-extract-lut\",\n\t\tops: [\"ExtractLUT\"],\n\t\tload: () => import(\"@framefields/node-extract-lut/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-film-grain\",\n\t\tops: [\"FilmGrain\"],\n\t\tload: () => import(\"@framefields/node-film-grain/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-flip\",\n\t\tops: [\"Flip\"],\n\t\tload: () => import(\"@framefields/node-flip/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-gradient-map\",\n\t\tops: [\"GradientMap\"],\n\t\tload: () => import(\"@framefields/node-gradient-map/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-halftone-screen\",\n\t\tops: [\"HalftoneScreen\"],\n\t\tload: () => import(\"@framefields/node-halftone-screen/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-high-pass\",\n\t\tops: [\"HighPass\"],\n\t\tload: () => import(\"@framefields/node-high-pass/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-kenburns\",\n\t\tops: [\"KenBurns\"],\n\t\tload: () => import(\"@framefields/node-kenburns/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-layer-style\",\n\t\tops: [\"LayerStyle\"],\n\t\tload: () => import(\"@framefields/node-layer-style/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-levels\",\n\t\tops: [\"Levels\"],\n\t\tload: () => import(\"@framefields/node-levels/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-liquify\",\n\t\tops: [\"Liquify\"],\n\t\tload: () => import(\"@framefields/node-liquify/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-mask-math\",\n\t\tops: [\"MaskMath\"],\n\t\tload: () => import(\"@framefields/node-mask-math/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-mesh-warp\",\n\t\tops: [\"MeshWarp\"],\n\t\tload: () => import(\"@framefields/node-mesh-warp/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-modulate\",\n\t\tops: [\"Modulate\"],\n\t\tload: () => import(\"@framefields/node-modulate/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-noise-generator\",\n\t\tops: [\"NoiseGenerator\"],\n\t\tload: () => import(\"@framefields/node-noise-generator/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-paint\",\n\t\tops: [\"Paint\"],\n\t\tload: () => import(\"@framefields/node-paint/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-patch-heal\",\n\t\tops: [\"PatchHeal\"],\n\t\tload: () => import(\"@framefields/node-patch-heal/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-refine-edge\",\n\t\tops: [\"RefineEdge\"],\n\t\tload: () => import(\"@framefields/node-refine-edge/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-refraction-caustics\",\n\t\tops: [\"RefractionCaustics3D\"],\n\t\tload: () => import(\"@framefields/node-refraction-caustics/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-relight-3d\",\n\t\tops: [\"Relight3D\"],\n\t\tload: () => import(\"@framefields/node-relight-3d/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-resizer-scaler\",\n\t\tops: [\"ResizerScaler\"],\n\t\tload: () => import(\"@framefields/node-resizer-scaler/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-rotate\",\n\t\tops: [\"Rotate\"],\n\t\tload: () => import(\"@framefields/node-rotate/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-selective-color\",\n\t\tops: [\"SelectiveColor\"],\n\t\tload: () => import(\"@framefields/node-selective-color/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-shadows-highlights\",\n\t\tops: [\"ShadowsHighlights\"],\n\t\tload: () => import(\"@framefields/node-shadows-highlights/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-shape-generator\",\n\t\tops: [\"ShapeGenerator\"],\n\t\tload: () => import(\"@framefields/node-shape-generator/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-signal-gate\",\n\t\tops: [\"SignalGate\"],\n\t\tload: () => import(\"@framefields/node-signal-gate/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-stereo-panning\",\n\t\tops: [\"StereoPanning\"],\n\t\tload: () => import(\"@framefields/node-stereo-panning/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-tile-offset\",\n\t\tops: [\"TileOffset\"],\n\t\tload: () => import(\"@framefields/node-tile-offset/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-unsharp-mask\",\n\t\tops: [\"UnsharpMask\"],\n\t\tload: () => import(\"@framefields/node-unsharp-mask/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-vignette\",\n\t\tops: [\"Vignette\"],\n\t\tload: () => import(\"@framefields/node-vignette/renderer\")\n\t},\n\t{\n\t\tpackageName: \"@framefields/node-vision\",\n\t\tops: [\"Vision\"],\n\t\tload: () => import(\"@framefields/node-vision/renderer\")\n\t}\n];\n\n//#endregion\n//#region src/node-manifest.ts\n/**\n* The `framefields` block of a node package's `package.json`.\n*\n* This is the single declaration of a node's op: renderer discovery, the\n* effects generator (`scripts/generate-effects.ts`) and the skill catalog all\n* read it from here. There is deliberately no fallback that derives an op from\n* the package name. See `spec/sync-node.md` §5.1.\n*/\nconst NODE_KINDS = [\n\t\"effect\",\n\t\"audio\",\n\t\"source\",\n\t\"signal\",\n\t\"utility\"\n];\nconst IDENTIFIER = /^[A-Za-z][A-Za-z0-9]*$/;\nvar NodeManifestError = class extends Error {\n\tconstructor(problems) {\n\t\tsuper(`Invalid node manifest(s):\\n${problems.map((p) => ` - ${p}`).join(\"\\n\")}`);\n\t\tthis.problems = problems;\n\t\tthis.name = \"NodeManifestError\";\n\t}\n};\nfunction isRecord(value) {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n/**\n* Validates one parsed `package.json`. Returns the manifest, or the list of\n* problems that make it unusable. Never throws.\n*/\nfunction parseNodeManifest(pkg, dir, nodePath = dir) {\n\tconst problems = [];\n\tif (!isRecord(pkg)) return { problems: [`${dir}: package.json is not an object`] };\n\tconst block = pkg.framefields;\n\tif (!isRecord(block)) return { problems: [`${dir}: package.json has no \"framefields\" block (expected { \"type\": \"<Op>\", \"kind\": \"<kind>\" })`] };\n\tconst { type, kind, aliases, schema, className, factory, custom } = block;\n\tif (typeof type !== \"string\" || !IDENTIFIER.test(type)) problems.push(`${dir}: framefields.type must be an op identifier`);\n\tif (typeof kind !== \"string\" || !NODE_KINDS.includes(kind)) problems.push(`${dir}: framefields.kind must be one of ${NODE_KINDS.join(\", \")}`);\n\tif (aliases !== void 0 && !(Array.isArray(aliases) && aliases.every((a) => typeof a === \"string\" && IDENTIFIER.test(a)))) problems.push(`${dir}: framefields.aliases must be an array of op identifiers`);\n\tfor (const [key, value] of Object.entries({\n\t\tschema,\n\t\tclassName,\n\t\tfactory\n\t})) if (value !== void 0 && (typeof value !== \"string\" || !IDENTIFIER.test(value))) problems.push(`${dir}: framefields.${key} must be an identifier`);\n\tif (custom !== void 0 && typeof custom !== \"boolean\") problems.push(`${dir}: framefields.custom must be a boolean`);\n\tif (problems.length > 0) return { problems };\n\tconst exportsField = isRecord(pkg.exports) ? pkg.exports[\"./renderer\"] : null;\n\tconst legacy = isRecord(pkg.gatewai) ? pkg.gatewai : {};\n\treturn {\n\t\tproblems,\n\t\tmanifest: {\n\t\t\tdir,\n\t\t\tpath: nodePath,\n\t\t\tpackageName: typeof pkg.name === \"string\" ? pkg.name : dir,\n\t\t\ttype,\n\t\t\tkind,\n\t\t\taliases: aliases ?? [],\n\t\t\tschema,\n\t\t\tclassName,\n\t\t\tfactory,\n\t\t\tcustom: custom === true,\n\t\t\tenabled: legacy.enabled !== false,\n\t\t\trendererExports: isRecord(exportsField) ? exportsField : void 0\n\t\t}\n\t};\n}\n/**\n* Reads every `nodes/node-*` package and returns its manifest, sorted by\n* directory name. Throws a single {@link NodeManifestError} listing every\n* problem: a missing or malformed block, or an op/alias claimed twice.\n*/\nfunction loadNodeManifests(nodesDir) {\n\tconst problems = [];\n\tconst manifests = [];\n\tconst dirs = fs.readdirSync(nodesDir).filter((d) => d.startsWith(\"node-\") && fs.existsSync(path.join(nodesDir, d, \"package.json\"))).sort();\n\tfor (const dir of dirs) {\n\t\tconst nodePath = path.join(nodesDir, dir);\n\t\tlet pkg;\n\t\ttry {\n\t\t\tpkg = JSON.parse(fs.readFileSync(path.join(nodePath, \"package.json\"), \"utf-8\"));\n\t\t} catch (err) {\n\t\t\tproblems.push(`${dir}: package.json is not valid JSON (${String(err)})`);\n\t\t\tcontinue;\n\t\t}\n\t\tconst parsed = parseNodeManifest(pkg, dir, nodePath);\n\t\tproblems.push(...parsed.problems);\n\t\tif (parsed.manifest) manifests.push(parsed.manifest);\n\t}\n\tconst owners = /* @__PURE__ */ new Map();\n\tfor (const manifest of manifests) for (const op of [manifest.type, ...manifest.aliases]) {\n\t\tconst owner = owners.get(op);\n\t\tif (owner) problems.push(`${manifest.dir}: op \"${op}\" is already declared by ${owner}`);\n\t\telse owners.set(op, manifest.dir);\n\t}\n\tif (problems.length > 0) throw new NodeManifestError(problems);\n\treturn manifests;\n}\n\n//#endregion\n//#region src/dynamic-node-discovery.ts\nlet __filename = \"\";\nlet __dirname = \"\";\nif (typeof process !== \"undefined\" && !!process.versions?.node) {\n\t__filename = fileURLToPath(import.meta.url);\n\t__dirname = path.dirname(__filename);\n}\n/** Locates the workspace `nodes/` directory by climbing up from this file. */\nfunction findNodesDir(startDir = __dirname) {\n\tlet nodesDir = path.resolve(startDir, \"../../../nodes\");\n\tlet currentDir = startDir;\n\twhile (true) {\n\t\tif (fs.existsSync(nodesDir)) {\n\t\t\tif (fs.readdirSync(nodesDir).some((d) => d.startsWith(\"node-\") && fs.existsSync(path.join(nodesDir, d, \"package.json\")))) return nodesDir;\n\t\t}\n\t\tconst parentDir = path.dirname(currentDir);\n\t\tif (parentDir === currentDir) return null;\n\t\tcurrentDir = parentDir;\n\t\tnodesDir = path.resolve(currentDir, \"nodes\");\n\t}\n}\n/**\n* Picks the renderer entry file: development source in dev/vitest, otherwise\n* the bundled dist, falling back to source when dist has not been built.\n*/\nfunction resolveRendererEntry(nodePath, rendererExports) {\n\tconst exists = (rel) => !!rel && fs.existsSync(path.join(nodePath, rel));\n\tif ((process.env.NODE_ENV !== \"production\" || Boolean(process.env.VITEST)) && exists(rendererExports.development)) return rendererExports.development;\n\tconst bundled = rendererExports.import || rendererExports.default;\n\tif (exists(bundled)) return bundled;\n\tif (exists(rendererExports.development)) return rendererExports.development;\n}\nasync function registerNode(manifest) {\n\tif (!manifest.rendererExports) return;\n\tconst entry = resolveRendererEntry(manifest.path, manifest.rendererExports);\n\tif (!entry) return;\n\tconst mod = await import(pathToFileURL(path.join(manifest.path, entry)).href);\n\tregisterPlugin([manifest.type, ...manifest.aliases], mod?.default);\n}\nfunction registerPlugin(ops, rendererPlugin) {\n\tif (!rendererPlugin) return;\n\tif (rendererPlugin.WebGPURenderer) for (const op of ops) registerWebGPURenderer(op, rendererPlugin.WebGPURenderer);\n\tif (rendererPlugin.audioProcessor) for (const op of ops) audioRegistry.register(op, rendererPlugin.audioProcessor);\n}\n/**\n* Registers the renderers bundled with this package. They are imported by\n* package name, so they resolve from `node_modules` (or the published bundle)\n* and never depend on a `nodes/` directory on disk.\n*/\nasync function registerBuiltinNodeRenderers() {\n\tconst failed = [];\n\tawait Promise.all(BUILTIN_NODE_RENDERERS.map(async ({ packageName, ops, load }) => {\n\t\ttry {\n\t\t\tregisterPlugin(ops, (await load()).default);\n\t\t} catch (err) {\n\t\t\tfailed.push(packageName);\n\t\t\tconsole.error(`[HeadlessWebGPURenderer] Failed to load renderer ${packageName}:`, err);\n\t\t}\n\t}));\n\tif (failed.length === BUILTIN_NODE_RENDERERS.length) throw new Error(\"[HeadlessWebGPURenderer] No built-in node renderers could be loaded.\");\n}\n/**\n* Registers the built-in node renderers, then any extra nodes found in the\n* directory named by `FRAMEFIELDS_NODES_DIR` (local node development). A node in\n* that directory overrides the built-in renderer for the same op.\n*/\nasync function discoverAndRegisterNodeRenderers() {\n\tif (typeof process === \"undefined\" || !process.versions?.node) return;\n\tawait registerBuiltinNodeRenderers();\n\tconst extraDir = process.env.FRAMEFIELDS_NODES_DIR;\n\tif (!extraDir) return;\n\tconst nodesDir = path.resolve(extraDir);\n\tif (!fs.existsSync(nodesDir)) {\n\t\tconsole.warn(`[HeadlessWebGPURenderer] FRAMEFIELDS_NODES_DIR does not exist: ${nodesDir}`);\n\t\treturn;\n\t}\n\trendererLogger.debug(`[HeadlessWebGPURenderer] Discovering node renderers in: ${nodesDir}`);\n\tconst manifests = loadNodeManifests(nodesDir);\n\tfor (const manifest of manifests) {\n\t\tif (!manifest.enabled) continue;\n\t\ttry {\n\t\t\tawait registerNode(manifest);\n\t\t} catch (err) {\n\t\t\tconsole.error(`[HeadlessWebGPURenderer] Failed to discover renderer for node ${manifest.dir}:`, err);\n\t\t}\n\t}\n}\n\n//#endregion\n//#region src/video-encoders.ts\nlet nodeAv;\n/**\n* node-av as @mediabunny/server loads it, with software encoders as the\n* default. The patch and the HardwareContext instances returned to the server\n* must come from that exact module instance, so the file is resolved from the\n* server package and imported natively (a `require()` can be routed through\n* a loader such as tsx and produce a second copy).\n*/\nfunction loadNodeAv() {\n\tnodeAv ??= (async () => {\n\t\tconst av = await import(pathToFileURL(createRequire(createRequire(import.meta.url).resolve(\"@mediabunny/server\")).resolve(\"node-av\")).href);\n\t\tpreferSoftwareEncoders(av);\n\t\treturn av;\n\t})();\n\treturn nodeAv;\n}\n/**\n* Software encoders to use per codec, best first. @mediabunny/server takes\n* `Codec.findEncoder(id)` as its software encoder, which returns whichever\n* encoder FFmpeg registered first. In node-av's linux-arm64 build that is a\n* hardware encoder (h264_rkmpp, hevc_rkmpp), which fails without Rockchip\n* hardware.\n*/\nconst SOFTWARE_ENCODERS = {\n\tAV_CODEC_ID_H264: [\"libx264\", \"libopenh264\"],\n\tAV_CODEC_ID_HEVC: [\"libx265\"],\n\tAV_CODEC_ID_VP8: [\"libvpx\"],\n\tAV_CODEC_ID_VP9: [\"libvpx-vp9\"],\n\tAV_CODEC_ID_AV1: [\n\t\t\"libsvtav1\",\n\t\t\"libaom-av1\",\n\t\t\"libdav1d\"\n\t]\n};\nlet patched = false;\n/** Makes `Codec.findEncoder` return a software encoder when one exists. */\nfunction preferSoftwareEncoders(av) {\n\tif (patched) return;\n\tpatched = true;\n\tconst byId = /* @__PURE__ */ new Map();\n\tfor (const [constant, names] of Object.entries(SOFTWARE_ENCODERS)) {\n\t\tconst id = av[constant];\n\t\tif (typeof id === \"number\") byId.set(id, names);\n\t}\n\tconst findEncoder = av.Codec.findEncoder.bind(av.Codec);\n\tav.Codec.findEncoder = ((id) => {\n\t\tfor (const name of byId.get(id) ?? []) {\n\t\t\tconst codec = av.Codec.findEncoderByName(name);\n\t\t\tif (codec) return codec;\n\t\t}\n\t\treturn findEncoder(id);\n\t});\n}\n/**\n* Opens the encoder with the settings @mediabunny/server uses and encodes one\n* frame. A hardware encoder can be compiled in and still be unusable: no such\n* hardware (rkmpp on a non-Rockchip board), or a GPU without an encoder block\n* (NVIDIA A100/H100 have no NVENC).\n*/\nasync function encoderWorks(av, codec) {\n\tconst ctx = new av.CodecContext();\n\tconst frame = new av.Frame();\n\tconst packet = new av.Packet();\n\ttry {\n\t\tctx.allocContext3(codec);\n\t\tconst formats = codec.pixelFormats;\n\t\tconst pixelFormat = !formats || formats.includes(av.AV_PIX_FMT_YUV420P) ? av.AV_PIX_FMT_YUV420P : formats[0];\n\t\tctx.width = 256;\n\t\tctx.height = 256;\n\t\tctx.pixelFormat = pixelFormat;\n\t\tctx.timeBase = new av.Rational(1, 1e6);\n\t\tctx.framerate = new av.Rational(30, 1);\n\t\tctx.gopSize = 60;\n\t\tctx.bitRate = 1000000n;\n\t\tif (await ctx.open2() < 0) return false;\n\t\tframe.alloc();\n\t\tframe.format = pixelFormat;\n\t\tframe.width = 256;\n\t\tframe.height = 256;\n\t\tif (frame.getBuffer() < 0) return false;\n\t\tframe.pts = 0n;\n\t\tpacket.alloc();\n\t\tif (await ctx.sendFrame(frame) < 0) return false;\n\t\tif (await ctx.sendFrame(null) < 0) return false;\n\t\tfor (;;) {\n\t\t\tconst ret = await ctx.receivePacket(packet);\n\t\t\tif (ret >= 0) return true;\n\t\t\tif (ret !== av.AVERROR_EAGAIN) return false;\n\t\t}\n\t} catch {\n\t\treturn false;\n\t} finally {\n\t\tpacket.free();\n\t\tframe.free();\n\t\tctx.freeContext();\n\t}\n}\n/** True when the env turns hardware video encoding/decoding off. */\nfunction hardwareDisabled() {\n\tconst value = process.env.FRAMEFIELDS_HW_CODECS?.toLowerCase();\n\treturn value === \"0\" || value === \"off\" || value === \"false\";\n}\n/**\n* Returns the `hardwareContext` option for registerMediabunnyServer: the\n* platform's hardware context for codecs whose hardware encoder actually\n* works (NVENC, VideoToolbox, ...), and null otherwise, so that codec is\n* encoded in software. Each codec is tested once per process.\n*\n* The server calls this before it picks any encoder (unless the encoder is\n* created with \"prefer-software\"), so the software default is patched in by\n* then.\n*/\nfunction hardwareContextResolver(forceSoftware) {\n\tlet hw;\n\tconst verdicts = /* @__PURE__ */ new Map();\n\tconst resolve = async (codecId) => {\n\t\tconst av = await loadNodeAv();\n\t\tif (forceSoftware || hardwareDisabled()) return null;\n\t\tif (hw === void 0) hw = av.HardwareContext.auto();\n\t\tif (!hw) return null;\n\t\tconst encoder = hw.getEncoderCodec(codecId);\n\t\tif (!encoder) return hw;\n\t\tif (await encoderWorks(av, encoder)) {\n\t\t\trendererLogger.info({\n\t\t\t\tencoder: encoder.name,\n\t\t\t\tdevice: hw.deviceTypeName\n\t\t\t}, \"[video-encoders] Using hardware video encoder\");\n\t\t\treturn hw;\n\t\t}\n\t\trendererLogger.warn({\n\t\t\tencoder: encoder.name,\n\t\t\tdevice: hw.deviceTypeName\n\t\t}, \"[video-encoders] Hardware video encoder unusable; encoding in software\");\n\t\treturn null;\n\t};\n\treturn (codecId) => {\n\t\tlet verdict = verdicts.get(codecId);\n\t\tif (!verdict) {\n\t\t\tverdict = resolve(codecId).catch(async (err) => {\n\t\t\t\tawait loadNodeAv();\n\t\t\t\trendererLogger.warn({ err: err instanceof Error ? err.message : String(err) }, \"[video-encoders] Hardware probe failed; encoding in software\");\n\t\t\t\treturn null;\n\t\t\t});\n\t\t\tverdicts.set(codecId, verdict);\n\t\t}\n\t\treturn verdict;\n\t};\n}\n/**\n* Options for registerMediabunnyServer: hardware video codecs when they work,\n* software (libx264, libx265, libvpx, SVT-AV1) otherwise. `forceSoftware`\n* keeps every codec in software (used on AMD). Create encoders with\n* \"prefer-hardware\" so this decides; \"prefer-software\" skips it.\n*/\nfunction videoCodecServerOptions(forceSoftware) {\n\treturn { hardwareContext: hardwareContextResolver(forceSoftware) };\n}\n\n//#endregion\n//#region src/bootstrap-mediabunny.ts\nconst isAMD = () => {\n\tif (process.platform !== \"linux\") return false;\n\ttry {\n\t\tif (fs.existsSync(\"/sys/module/amdgpu\") || fs.existsSync(\"/dev/kfd\")) return true;\n\t\tconst drmDir = \"/sys/class/drm\";\n\t\tif (fs.existsSync(drmDir)) {\n\t\t\tconst files = fs.readdirSync(drmDir);\n\t\t\tfor (const file of files) {\n\t\t\t\tconst vendorPath = `${drmDir}/${file}/device/vendor`;\n\t\t\t\tif (fs.existsSync(vendorPath)) {\n\t\t\t\t\tif (fs.readFileSync(vendorPath, \"utf8\").trim() === \"0x1002\") return true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} catch {}\n\treturn false;\n};\nconst bootstrapMediabunny = () => {\n\tregisterMediabunnyServer(videoCodecServerOptions(isAMD()));\n\tfor (const key of Object.keys(webcodecs)) if (typeof globalThis[key] === \"undefined\") globalThis[key] = webcodecs[key];\n};\n\n//#endregion\nexport { NodeManifestError as a, DmaStagingRing as c, NODE_KINDS as i, preloadFonts as l, discoverAndRegisterNodeRenderers as n, loadNodeManifests as o, findNodesDir as r, parseNodeManifest as s, bootstrapMediabunny as t, rendererLogger as u };\n//# sourceMappingURL=bootstrap-mediabunny--TDh3Bij.mjs.map","import { c as DmaStagingRing, l as preloadFonts, n as discoverAndRegisterNodeRenderers, t as bootstrapMediabunny, u as rendererLogger } from \"./bootstrap-mediabunny--TDh3Bij.mjs\";\nimport path from \"node:path\";\nimport { exec, spawn } from \"node:child_process\";\nimport { randomUUID } from \"node:crypto\";\nimport fs from \"node:fs/promises\";\nimport os from \"node:os\";\nimport { compositionStateStore, drawCompositionTree, mixAudioTracks } from \"@framefields/compositions\";\nimport { getMediaType, takeRenderDiagnostics, updateClockSignals } from \"@framefields/core\";\nimport { NodeSurfaceProvider, SlugFontCache, WebGPUAudioProcessor, clearAllVideoCache, ensureDevice, getRenderer2D, initHeadlessWebGPU, inputStore, lutStore, mediaDecoderCache, shaderStore, textureCache } from \"@framefields/webgpu-renderers\";\nimport { AudioSample, AudioSampleSource, FilePathTarget, Mp3OutputFormat, Mp4OutputFormat, Output, QUALITY_HIGH, QUALITY_LOW, QUALITY_VERY_HIGH, QUALITY_VERY_LOW, VideoSample, VideoSampleSource, WebMOutputFormat } from \"mediabunny\";\nimport sharp from \"sharp\";\nimport { Canvas, Image } from \"skia-canvas\";\n\n//#region src/video-qa.ts\nconst DEFAULTS = {\n\tblackPixelThreshold: .1,\n\tblackFrameRatio: .98,\n\tminBlackSec: .5,\n\tminFrozenSec: 2,\n\tsilenceDbfs: -60,\n\tminSilenceSec: 2,\n\tlufsTolerance: 1\n};\nconst SAMPLE_STEP = 4;\nconst FROZEN_DIFF = .25;\n/** Measures frames handed to it in order, as RGBA bytes. */\nvar FrameInspector = class {\n\tblackLuma;\n\tblackRatio;\n\tblack = [];\n\tsameAsPrevious = [];\n\tlumaSum = 0;\n\tprevious = null;\n\tconstructor(options = {}) {\n\t\tthis.blackLuma = (options.blackPixelThreshold ?? DEFAULTS.blackPixelThreshold) * 255;\n\t\tthis.blackRatio = options.blackFrameRatio ?? DEFAULTS.blackFrameRatio;\n\t}\n\tget frameCount() {\n\t\treturn this.black.length;\n\t}\n\tinspect(rgba, width, height) {\n\t\tconst cols = Math.ceil(width / SAMPLE_STEP);\n\t\tconst rows = Math.ceil(height / SAMPLE_STEP);\n\t\tconst luma = new Uint8Array(cols * rows);\n\t\tlet blackCount = 0;\n\t\tlet sum = 0;\n\t\tlet k = 0;\n\t\tfor (let y = 0; y < height; y += SAMPLE_STEP) {\n\t\t\tlet p = y * width * 4;\n\t\t\tfor (let x = 0; x < width; x += SAMPLE_STEP, p += SAMPLE_STEP * 4) {\n\t\t\t\tconst l = .2126 * rgba[p] + .7152 * rgba[p + 1] + .0722 * rgba[p + 2];\n\t\t\t\tluma[k++] = l;\n\t\t\t\tsum += l;\n\t\t\t\tif (l <= this.blackLuma) blackCount++;\n\t\t\t}\n\t\t}\n\t\tconst n = luma.length;\n\t\tthis.lumaSum += sum / n / 255;\n\t\tthis.black.push(blackCount / n >= this.blackRatio);\n\t\tlet same = false;\n\t\tif (this.previous && this.previous.length === n) {\n\t\t\tlet diff = 0;\n\t\t\tfor (let i = 0; i < n; i++) diff += Math.abs(luma[i] - this.previous[i]);\n\t\t\tsame = diff / n < FROZEN_DIFF;\n\t\t}\n\t\tthis.sameAsPrevious.push(same);\n\t\tthis.previous = luma;\n\t}\n\tstats(expectedFrames, encodedFrames, fps, width, height, options = {}) {\n\t\tconst minBlack = Math.max(1, Math.round((options.minBlackSec ?? DEFAULTS.minBlackSec) * fps));\n\t\tconst minFrozen = Math.max(2, Math.round((options.minFrozenSec ?? DEFAULTS.minFrozenSec) * fps));\n\t\tconst blackSegments = runs(this.black, minBlack).map(([a, b]) => ({\n\t\t\tstartSec: a / fps,\n\t\t\tendSec: b / fps\n\t\t}));\n\t\tconst frozenSegments = runs(this.sameAsPrevious, minFrozen - 1).map(([a, b]) => ({\n\t\t\tstartSec: (a - 1) / fps,\n\t\t\tendSec: b / fps\n\t\t}));\n\t\treturn {\n\t\t\texpectedFrames,\n\t\t\tencodedFrames,\n\t\t\tfps,\n\t\t\twidth,\n\t\t\theight,\n\t\t\tmeanLuma: this.frameCount > 0 ? this.lumaSum / this.frameCount : 0,\n\t\t\tblackSegments,\n\t\t\tfrozenSegments\n\t\t};\n\t}\n};\n/** [start, end) index ranges where flags hold for at least minLength in a row. */\nfunction runs(flags, minLength) {\n\tconst out = [];\n\tlet start = -1;\n\tfor (let i = 0; i <= flags.length; i++) if (i < flags.length && flags[i]) {\n\t\tif (start < 0) start = i;\n\t} else if (start >= 0) {\n\t\tif (i - start >= minLength) out.push([start, i]);\n\t\tstart = -1;\n\t}\n\treturn out;\n}\nconst toDb = (power) => power > 0 ? 10 * Math.log10(power) : -Infinity;\n/** Measures a mixed audio track (one Float32Array per channel). */\nfunction analyzeAudio(channels, sampleRate, options = {}) {\n\tconst length = channels[0]?.length ?? 0;\n\tlet peak = 0;\n\tlet sumSquares = 0;\n\tlet clipped = 0;\n\tfor (const ch of channels) for (let i = 0; i < length; i++) {\n\t\tconst v = Math.abs(ch[i]);\n\t\tif (v > peak) peak = v;\n\t\tif (v >= .9999) clipped++;\n\t\tsumSquares += v * v;\n\t}\n\tconst total = length * Math.max(1, channels.length);\n\tconst silenceDbfs = options.silenceDbfs ?? DEFAULTS.silenceDbfs;\n\tconst window = Math.max(1, Math.round(sampleRate * .1));\n\tconst silent = [];\n\tfor (let start = 0; start < length; start += window) {\n\t\tconst end = Math.min(length, start + window);\n\t\tlet s = 0;\n\t\tfor (const ch of channels) for (let i = start; i < end; i++) s += ch[i] * ch[i];\n\t\tsilent.push(toDb(s / ((end - start) * channels.length)) < silenceDbfs);\n\t}\n\tconst silentSegments = runs(silent, Math.max(1, Math.round((options.minSilenceSec ?? DEFAULTS.minSilenceSec) / .1))).map(([a, b]) => ({\n\t\tstartSec: a * window / sampleRate,\n\t\tendSec: Math.min(length, b * window) / sampleRate\n\t}));\n\tconst peakDbfs = 20 * Math.log10(Math.max(peak, 1e-12));\n\treturn {\n\t\tsampleRate,\n\t\tchannels: channels.length,\n\t\tdurationSec: length / sampleRate,\n\t\tpeakDbfs,\n\t\trmsDbfs: toDb(sumSquares / Math.max(1, total)),\n\t\tintegratedLufs: peakDbfs < silenceDbfs ? null : integratedLoudness(channels, sampleRate),\n\t\tclippedSamples: clipped,\n\t\tsilentSegments\n\t};\n}\n/** BS.1770 K-weighting stage 1: +4 dB high shelf around 1.5 kHz (the head). */\nfunction highShelf(sampleRate) {\n\tconst A = 10 ** (4 / 40);\n\tconst w0 = 2 * Math.PI * 1500 / sampleRate;\n\tconst cos = Math.cos(w0);\n\tconst alpha = Math.sin(w0) / (2 / Math.SQRT2);\n\tconst sq = 2 * Math.sqrt(A) * alpha;\n\tconst a0 = A + 1 - (A - 1) * cos + sq;\n\treturn {\n\t\tb0: A * (A + 1 + (A - 1) * cos + sq) / a0,\n\t\tb1: -2 * A * (A - 1 + (A + 1) * cos) / a0,\n\t\tb2: A * (A + 1 + (A - 1) * cos - sq) / a0,\n\t\ta1: 2 * (A - 1 - (A + 1) * cos) / a0,\n\t\ta2: (A + 1 - (A - 1) * cos - sq) / a0\n\t};\n}\n/** BS.1770 K-weighting stage 2: 38 Hz high pass, Q 0.5 (the RLB curve). */\nfunction highPass(sampleRate) {\n\tconst w0 = 2 * Math.PI * 38 / sampleRate;\n\tconst cos = Math.cos(w0);\n\tconst alpha = Math.sin(w0) / (2 * .5);\n\tconst a0 = 1 + alpha;\n\treturn {\n\t\tb0: (1 + cos) / 2 / a0,\n\t\tb1: -(1 + cos) / a0,\n\t\tb2: (1 + cos) / 2 / a0,\n\t\ta1: -2 * cos / a0,\n\t\ta2: (1 - alpha) / a0\n\t};\n}\nfunction filter(input, f) {\n\tconst out = new Float32Array(input.length);\n\tlet x1 = 0;\n\tlet x2 = 0;\n\tlet y1 = 0;\n\tlet y2 = 0;\n\tfor (let i = 0; i < input.length; i++) {\n\t\tconst x = input[i];\n\t\tconst y = f.b0 * x + f.b1 * x1 + f.b2 * x2 - f.a1 * y1 - f.a2 * y2;\n\t\tout[i] = y;\n\t\tx2 = x1;\n\t\tx1 = x;\n\t\ty2 = y1;\n\t\ty1 = y;\n\t}\n\treturn out;\n}\n/**\n* ITU-R BS.1770-4 integrated loudness (LUFS): K-weighted mean square in\n* 400 ms blocks with 75% overlap, gated at -70 LUFS and then at 10 LU below\n* the mean of what passed. Channels weigh 1 (stereo and mono layouts).\n*/\nfunction integratedLoudness(channels, sampleRate) {\n\tconst shelf = highShelf(sampleRate);\n\tconst hp = highPass(sampleRate);\n\tconst weighted = channels.map((ch) => filter(filter(ch, shelf), hp));\n\tconst length = weighted[0]?.length ?? 0;\n\tconst block = Math.round(.4 * sampleRate);\n\tconst hop = Math.round(.1 * sampleRate);\n\tif (length < block) return null;\n\tconst blockPower = [];\n\tfor (let start = 0; start + block <= length; start += hop) {\n\t\tlet power = 0;\n\t\tfor (const ch of weighted) {\n\t\t\tlet s = 0;\n\t\t\tfor (let i = start; i < start + block; i++) s += ch[i] * ch[i];\n\t\t\tpower += s / block;\n\t\t}\n\t\tblockPower.push(power);\n\t}\n\tconst lufs = (power) => -.691 + toDb(power);\n\tconst mean = (xs) => xs.reduce((a, b) => a + b, 0) / xs.length;\n\tconst absolute = blockPower.filter((p) => lufs(p) > -70);\n\tif (absolute.length === 0) return null;\n\tconst relativeGate = lufs(mean(absolute)) - 10;\n\tconst gated = absolute.filter((p) => lufs(p) > relativeGate);\n\treturn gated.length > 0 ? lufs(mean(gated)) : null;\n}\n/** Turn measurements and document diagnostics into a report with issues. */\nfunction buildQaReport(parts) {\n\tconst { video, audio, options = {} } = parts;\n\tconst issues = [];\n\tconst at = (s) => `${s.startSec.toFixed(2)}–${s.endSec.toFixed(2)} s`;\n\tif (video) {\n\t\tif (video.encodedFrames !== video.expectedFrames) issues.push({\n\t\t\tseverity: \"error\",\n\t\t\tcode: \"frames_missing\",\n\t\t\tmessage: `${video.encodedFrames} of ${video.expectedFrames} frames were encoded`\n\t\t});\n\t\tfor (const s of video.blackSegments) issues.push({\n\t\t\tseverity: \"warning\",\n\t\t\tcode: \"black_frames\",\n\t\t\tmessage: `Black frames at ${at(s)}`,\n\t\t\t...s\n\t\t});\n\t\tfor (const s of video.frozenSegments) issues.push({\n\t\t\tseverity: \"info\",\n\t\t\tcode: \"frozen_video\",\n\t\t\tmessage: `Picture does not change at ${at(s)}`,\n\t\t\t...s\n\t\t});\n\t}\n\tif (audio) if (audio.integratedLufs === null) issues.push({\n\t\tseverity: \"info\",\n\t\tcode: \"audio_silent\",\n\t\tmessage: \"The audio track is silent\"\n\t});\n\telse {\n\t\tif (audio.clippedSamples > 0) issues.push({\n\t\t\tseverity: \"warning\",\n\t\t\tcode: \"audio_clipping\",\n\t\t\tmessage: `${audio.clippedSamples} audio sample(s) at or beyond full scale (peak ${audio.peakDbfs.toFixed(1)} dBFS)`\n\t\t});\n\t\tfor (const s of audio.silentSegments) issues.push({\n\t\t\tseverity: \"info\",\n\t\t\tcode: \"audio_silence\",\n\t\t\tmessage: `Silence at ${at(s)}`,\n\t\t\t...s\n\t\t});\n\t\tif (options.targetLufs !== void 0) {\n\t\t\tconst off = audio.integratedLufs - options.targetLufs;\n\t\t\tconst tolerance = options.lufsTolerance ?? DEFAULTS.lufsTolerance;\n\t\t\tif (Math.abs(off) > tolerance) issues.push({\n\t\t\t\tseverity: \"warning\",\n\t\t\t\tcode: \"loudness_off_target\",\n\t\t\t\tmessage: `Integrated loudness ${audio.integratedLufs.toFixed(1)} LUFS is ${Math.abs(off).toFixed(1)} LU ${off > 0 ? \"above\" : \"below\"} the ${options.targetLufs} LUFS target`\n\t\t\t});\n\t\t}\n\t}\n\tfor (const d of parts.diagnostics ?? []) issues.push({\n\t\tseverity: d.severity,\n\t\tcode: d.code,\n\t\tmessage: d.message,\n\t\t...d.layerId !== void 0 && { layerId: d.layerId }\n\t});\n\treturn {\n\t\tpassed: !issues.some((i) => i.severity !== \"info\"),\n\t\t...video && { video },\n\t\t...audio && { audio },\n\t\tissues\n\t};\n}\n/** A short human- and agent-readable summary of a report. */\nfunction formatQaReport(report) {\n\tconst lines = [`QA ${report.passed ? \"passed\" : \"FAILED\"}`];\n\tconst v = report.video;\n\tif (v) lines.push(` video: ${v.encodedFrames}/${v.expectedFrames} frames, ${v.width}x${v.height} @ ${v.fps} fps, mean luma ${v.meanLuma.toFixed(2)}`);\n\tconst a = report.audio;\n\tif (a) {\n\t\tconst lufs = a.integratedLufs === null ? \"silent\" : `${a.integratedLufs.toFixed(1)} LUFS`;\n\t\tlines.push(` audio: ${a.durationSec.toFixed(2)} s, ${lufs}, peak ${a.peakDbfs.toFixed(1)} dBFS, rms ${a.rmsDbfs.toFixed(1)} dBFS`);\n\t}\n\tfor (const i of report.issues) lines.push(` ${i.severity.padEnd(7)} ${i.code}: ${i.message}`);\n\treturn lines.join(\"\\n\");\n}\n\n//#endregion\n//#region src/zero-copy-webcodecs-pipeline.ts\n/**\n* High-performance hardware video encoding pipeline integrating WebGPU textures with WebCodecs.\n*\n* Provides:\n* 1. Direct hardware acceleration when running with WebCodecs / OffscreenCanvas.\n* 2. Pipelined asynchronous double-buffered DMA staging ring for headless Node.js (Dawn native),\n* allowing GPU Frame i+1 rendering to overlap concurrently with Frame i hardware encoding.\n*/\nvar ZeroCopyWebCodecsPipeline = class {\n\twidth;\n\theight;\n\tfps;\n\tringCapacity;\n\tdevice;\n\tvideoSource;\n\tstagingRing;\n\tcolorSpace;\n\tdirectCanvasSource;\n\tonFrame;\n\tinFlightFrames = [];\n\tcycleStartTimes = /* @__PURE__ */ new Map();\n\ttotalFramesEnqueued = 0;\n\ttotalFramesEncoded = 0;\n\ttotalGpuSubmitTimeMs = 0;\n\ttotalEncodeTimeMs = 0;\n\ttotalCycleTimeMs = 0;\n\tmaxCycleTimeMs = 0;\n\tminCycleTimeMs = Number.POSITIVE_INFINITY;\n\tpipelineStartTime = 0;\n\tconstructor(device, options) {\n\t\tthis.device = device;\n\t\tthis.width = options.width;\n\t\tthis.height = options.height;\n\t\tthis.fps = options.fps;\n\t\tthis.videoSource = options.videoSource;\n\t\tthis.ringCapacity = Math.max(2, options.ringCapacity ?? 2);\n\t\tthis.colorSpace = options.colorSpace;\n\t\tthis.directCanvasSource = options.directCanvasSource;\n\t\tthis.onFrame = options.onFrame;\n\t\tthis.stagingRing = new DmaStagingRing(device, {\n\t\t\twidth: this.width,\n\t\t\theight: this.height,\n\t\t\tcapacity: this.ringCapacity\n\t\t});\n\t\tthis.pipelineStartTime = performance.now();\n\t}\n\t/**\n\t* Returns true if direct zero-copy from an OffscreenCanvas or texture is active.\n\t*/\n\tcanDirectZeroCopy() {\n\t\treturn this.directCanvasSource !== void 0 && this.directCanvasSource !== null;\n\t}\n\t/**\n\t* Enqueues a rendered GPU texture frame into the pipeline.\n\t*\n\t* Uses double-buffered DMA staging: if the staging ring has reached capacity,\n\t* the oldest in-flight frame is asynchronously consumed and added to the video encoder\n\t* before staging the new frame, guaranteeing constant bounded VRAM usage and zero GPU stalls.\n\t*/\n\tasync enqueueFrame(frameIndex, targetTexture, encoder) {\n\t\tconst cycleStartTime = performance.now();\n\t\tif (this.inFlightFrames.length >= this.ringCapacity) {\n\t\t\tconst oldestFrame = this.inFlightFrames.shift();\n\t\t\tif (oldestFrame !== void 0) await this.consumeAndEncode(oldestFrame);\n\t\t}\n\t\tif (this.canDirectZeroCopy()) {\n\t\t\tconst gpuStart = performance.now();\n\t\t\tthis.device.queue.submit([encoder.finish()]);\n\t\t\tthis.totalGpuSubmitTimeMs += performance.now() - gpuStart;\n\t\t\tthis.cycleStartTimes.set(frameIndex, cycleStartTime);\n\t\t\tthis.totalFramesEnqueued++;\n\t\t\tawait this.consumeAndEncode(frameIndex);\n\t\t} else {\n\t\t\tawait this.stagingRing.prepareSlot(frameIndex);\n\t\t\tthis.stagingRing.stageTexture(encoder, targetTexture, frameIndex);\n\t\t\tconst gpuStart = performance.now();\n\t\t\tthis.device.queue.submit([encoder.finish()]);\n\t\t\tthis.totalGpuSubmitTimeMs += performance.now() - gpuStart;\n\t\t\tthis.stagingRing.scheduleMap(frameIndex);\n\t\t\tthis.inFlightFrames.push(frameIndex);\n\t\t\tthis.cycleStartTimes.set(frameIndex, cycleStartTime);\n\t\t\tthis.totalFramesEnqueued++;\n\t\t}\n\t}\n\t/**\n\t* Drains all remaining in-flight frames in the pipeline, ensuring every enqueued\n\t* frame has been encoded and added to the video sample source.\n\t*/\n\tasync drain() {\n\t\twhile (this.inFlightFrames.length > 0) {\n\t\t\tconst frameIndex = this.inFlightFrames.shift();\n\t\t\tif (frameIndex !== void 0) await this.consumeAndEncode(frameIndex);\n\t\t}\n\t}\n\t/**\n\t* Returns runtime throughput, latency, and pipeline statistics.\n\t*/\n\tgetStats() {\n\t\tconst totalElapsedMs = performance.now() - this.pipelineStartTime;\n\t\tconst throughputFps = totalElapsedMs > 0 ? this.totalFramesEncoded / totalElapsedMs * 1e3 : 0;\n\t\tconst avgSubmit = this.totalFramesEnqueued > 0 ? this.totalGpuSubmitTimeMs / this.totalFramesEnqueued : 0;\n\t\tconst avgEncode = this.totalFramesEncoded > 0 ? this.totalEncodeTimeMs / this.totalFramesEncoded : 0;\n\t\tconst avgCycle = this.totalFramesEncoded > 0 ? this.totalCycleTimeMs / this.totalFramesEncoded : 0;\n\t\treturn {\n\t\t\ttotalFramesEnqueued: this.totalFramesEnqueued,\n\t\t\ttotalFramesEncoded: this.totalFramesEncoded,\n\t\t\taverageGpuSubmitTimeMs: avgSubmit,\n\t\t\taverageEncodeTimeMs: avgEncode,\n\t\t\taverageCycleTimeMs: avgCycle,\n\t\t\tmaxCycleTimeMs: this.maxCycleTimeMs,\n\t\t\tminCycleTimeMs: Number.isFinite(this.minCycleTimeMs) ? this.minCycleTimeMs : 0,\n\t\t\tthroughputFps,\n\t\t\tringCapacity: this.ringCapacity,\n\t\t\tisDirectZeroCopy: this.canDirectZeroCopy()\n\t\t};\n\t}\n\t/**\n\t* Destroys the pipeline and releases all staging buffers.\n\t*/\n\tdestroy() {\n\t\tthis.inFlightFrames.length = 0;\n\t\tthis.cycleStartTimes.clear();\n\t\tthis.stagingRing.destroy();\n\t}\n\tasync consumeAndEncode(frameIndex) {\n\t\tconst encodeStart = performance.now();\n\t\tconst timestampUs = frameIndex / this.fps * 1e6;\n\t\tif (this.canDirectZeroCopy()) {\n\t\t\tconst sample = new VideoSample(this.directCanvasSource, {\n\t\t\t\tduration: 1 / this.fps,\n\t\t\t\ttimestamp: frameIndex / this.fps\n\t\t\t});\n\t\t\ttry {\n\t\t\t\tawait this.videoSource.add(sample);\n\t\t\t} finally {\n\t\t\t\tsample.close();\n\t\t\t}\n\t\t} else {\n\t\t\tconst onFrame = this.onFrame;\n\t\t\tconst vf = await this.stagingRing.readFrameToVideoFrame(frameIndex, timestampUs, this.colorSpace, onFrame && ((rgba) => onFrame(rgba, frameIndex)));\n\t\t\ttry {\n\t\t\t\tconst sample = new VideoSample(vf, {\n\t\t\t\t\tduration: 1 / this.fps,\n\t\t\t\t\ttimestamp: frameIndex / this.fps\n\t\t\t\t});\n\t\t\t\ttry {\n\t\t\t\t\tawait this.videoSource.add(sample);\n\t\t\t\t} finally {\n\t\t\t\t\tsample.close();\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tvf.close();\n\t\t\t}\n\t\t}\n\t\tconst now = performance.now();\n\t\tthis.totalEncodeTimeMs += now - encodeStart;\n\t\tthis.totalFramesEncoded++;\n\t\tconst cycleStart = this.cycleStartTimes.get(frameIndex);\n\t\tif (cycleStart !== void 0) {\n\t\t\tconst cycleDuration = now - cycleStart;\n\t\t\tthis.cycleStartTimes.delete(frameIndex);\n\t\t\tthis.totalCycleTimeMs += cycleDuration;\n\t\t\tif (cycleDuration > this.maxCycleTimeMs) this.maxCycleTimeMs = cycleDuration;\n\t\t\tif (cycleDuration < this.minCycleTimeMs) this.minCycleTimeMs = cycleDuration;\n\t\t}\n\t}\n};\n\n//#endregion\n//#region src/headless-webgpu-renderer.ts\nglobalThis[Symbol.for(\"framefields.vision.backend\")] = (info) => {\n\trendererLogger.info(info, info.backend === \"webgpu\" ? \"[vision] Inference on the GPU (WebGPU)\" : `[vision] Inference on the ${info.backend.toUpperCase()}`);\n};\nasync function convertMp4ToGif(inputMp4Path, outputGifPath) {\n\treturn new Promise((resolve, reject) => {\n\t\tconst ffmpeg = spawn(\"ffmpeg\", [\n\t\t\t\"-i\",\n\t\t\tinputMp4Path,\n\t\t\t\"-vf\",\n\t\t\t\"split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse\",\n\t\t\t\"-y\",\n\t\t\toutputGifPath\n\t\t]);\n\t\tlet errorOutput = \"\";\n\t\tffmpeg.stderr.on(\"data\", (data) => {\n\t\t\terrorOutput += data.toString();\n\t\t});\n\t\tffmpeg.on(\"close\", async (code) => {\n\t\t\tif (code === 0) resolve();\n\t\t\telse {\n\t\t\t\trendererLogger.error({\n\t\t\t\t\tcode,\n\t\t\t\t\terr: errorOutput\n\t\t\t\t}, \"[convertMp4ToGif] ffmpeg conversion failed\");\n\t\t\t\treject(/* @__PURE__ */ new Error(`ffmpeg exited with code ${code}: ${errorOutput}`));\n\t\t\t}\n\t\t});\n\t\tffmpeg.on(\"error\", (err) => {\n\t\t\trendererLogger.error({ err }, \"[convertMp4ToGif] ffmpeg spawn error\");\n\t\t\treject(err);\n\t\t});\n\t});\n}\nbootstrapMediabunny();\nconst globalObj = globalThis;\nif (typeof globalThis !== \"undefined\") {\n\tglobalObj.__IS_HEADLESS_RENDERER__ = true;\n\tglobalObj.__GATEWAI_DELAYS__ ??= /* @__PURE__ */ new Set();\n}\nif (typeof globalThis.requestAnimationFrame === \"undefined\") {\n\tglobalObj.requestAnimationFrame = (cb) => setTimeout(cb, 0);\n\tglobalObj.cancelAnimationFrame = (id) => clearTimeout(id);\n}\nconst dummyDomElement = {\n\tclientWidth: 1920,\n\tclientHeight: 1080,\n\tgetBoundingClientRect: () => ({\n\t\tx: 0,\n\t\ty: 0,\n\t\tleft: 0,\n\t\ttop: 0,\n\t\tright: 1920,\n\t\tbottom: 1080,\n\t\twidth: 1920,\n\t\theight: 1080\n\t}),\n\tstyle: {},\n\tappendChild: () => {},\n\tremoveChild: () => {},\n\taddEventListener: () => {},\n\tremoveEventListener: () => {},\n\tgetAttribute: () => null\n};\nif (typeof globalThis.OffscreenCanvas === \"undefined\") globalObj.OffscreenCanvas = Canvas;\nif (typeof globalThis.HTMLCanvasElement === \"undefined\") globalObj.HTMLCanvasElement = Canvas;\nif (typeof globalThis.Image === \"undefined\") globalObj.Image = Image;\nif (typeof globalThis.window === \"undefined\") globalObj.window = globalThis;\nif (!globalThis.location) globalObj.location = new URL(\"http://localhost\");\nif (typeof globalThis.IntersectionObserver === \"undefined\") globalObj.IntersectionObserver = class IntersectionObserver {\n\tobserve() {}\n\tunobserve() {}\n\tdisconnect() {}\n};\nif (typeof globalThis.document === \"undefined\") globalObj.document = {\n\tcreateElement: (tag) => {\n\t\tif (tag === \"canvas\") return new Canvas(1, 1);\n\t\treturn { ...dummyDomElement };\n\t},\n\tgetElementsByTagName: () => [],\n\tdocumentElement: dummyDomElement,\n\tbody: dummyDomElement\n};\nelse {\n\tconst docObj = globalThis.document;\n\tif (typeof docObj.getElementsByTagName === \"undefined\") docObj.getElementsByTagName = () => [];\n\tdocObj.documentElement ??= dummyDomElement;\n\tdocObj.body ??= dummyDomElement;\n}\nconst skiaProto = Canvas.prototype;\nif (typeof skiaProto.getBoundingClientRect === \"undefined\") skiaProto.getBoundingClientRect = function() {\n\tconst width = this.width || 512;\n\tconst height = this.height || 512;\n\treturn {\n\t\tx: 0,\n\t\ty: 0,\n\t\tleft: 0,\n\t\ttop: 0,\n\t\tright: width,\n\t\tbottom: height,\n\t\twidth,\n\t\theight\n\t};\n};\nif (!(\"style\" in skiaProto)) Object.defineProperty(skiaProto, \"style\", {\n\tget() {\n\t\tthis._style ??= {};\n\t\treturn this._style;\n\t},\n\tconfigurable: true\n});\nif (!(\"clientWidth\" in skiaProto)) Object.defineProperty(skiaProto, \"clientWidth\", {\n\tget() {\n\t\treturn this.width || 512;\n\t},\n\tconfigurable: true\n});\nif (!(\"clientHeight\" in skiaProto)) Object.defineProperty(skiaProto, \"clientHeight\", {\n\tget() {\n\t\treturn this.height || 512;\n\t},\n\tconfigurable: true\n});\nif (!(\"parentElement\" in skiaProto)) Object.defineProperty(skiaProto, \"parentElement\", {\n\tget() {\n\t\treturn dummyDomElement;\n\t},\n\tconfigurable: true\n});\nif (typeof skiaProto.addEventListener === \"undefined\") skiaProto.addEventListener = () => {};\nif (typeof skiaProto.removeEventListener === \"undefined\") skiaProto.removeEventListener = () => {};\nif (typeof skiaProto.getAttribute === \"undefined\") skiaProto.getAttribute = () => null;\nconst CPU_COUNT = os.cpus().length;\nconst TOTAL_WORKER_BUDGET = Math.max(1, CPU_COUNT - 3);\nconst MAX_CONCURRENT_RENDERS = Math.max(1, Math.min(3, Math.floor(TOTAL_WORKER_BUDGET / 3)));\nconst QUEUE_TIMEOUT_MS = 120 * 6e4;\nvar RenderSemaphore = class {\n\t_running = 0;\n\t_max;\n\t_queue = [];\n\tconstructor(max) {\n\t\tthis._max = max;\n\t}\n\tacquire(timeoutMs = QUEUE_TIMEOUT_MS) {\n\t\tif (this._running < this._max) {\n\t\t\tthis._running++;\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setTimeout(() => {\n\t\t\t\tconst idx = this._queue.findIndex((e) => e.resolve === resolve);\n\t\t\t\tif (idx !== -1) this._queue.splice(idx, 1);\n\t\t\t\treject(/* @__PURE__ */ new Error(`Render queue timeout after ${timeoutMs}ms (${this._queue.length} queued, ${this._running}/${this._max} active)`));\n\t\t\t}, timeoutMs);\n\t\t\tthis._queue.push({\n\t\t\t\tresolve,\n\t\t\t\treject,\n\t\t\t\ttimer\n\t\t\t});\n\t\t});\n\t}\n\trelease() {\n\t\tif (this._queue.length > 0) {\n\t\t\tconst next = this._queue.shift();\n\t\t\tclearTimeout(next.timer);\n\t\t\tnext.resolve();\n\t\t} else this._running--;\n\t}\n\tget stats() {\n\t\treturn {\n\t\t\tactive: this._running,\n\t\t\tqueued: this._queue.length,\n\t\t\tmax: this._max\n\t\t};\n\t}\n};\nconst renderSemaphore = new RenderSemaphore(MAX_CONCURRENT_RENDERS);\nfunction toEvenDimension(n) {\n\tconst v = Math.round(n);\n\treturn v % 2 === 0 ? v : v + 1;\n}\nfunction resolveQuality(quality) {\n\tswitch (quality) {\n\t\tcase \"very_low\": return QUALITY_VERY_LOW;\n\t\tcase \"low\": return QUALITY_LOW;\n\t\tcase \"high\": return QUALITY_HIGH;\n\t\tcase \"very_high\": return QUALITY_VERY_HIGH;\n\t\tdefault: return QUALITY_VERY_HIGH;\n\t}\n}\nlet cachedVramUsage = \"N/A\";\nlet vramProbeInFlight = false;\nfunction refreshVramUsage() {\n\tif (vramProbeInFlight) return;\n\tvramProbeInFlight = true;\n\texec(\"nvidia-smi --query-gpu=memory.used,memory.total --format=csv,noheader,nounits\", {\n\t\tencoding: \"utf-8\",\n\t\ttimeout: 2e3\n\t}, (err, stdout) => {\n\t\tvramProbeInFlight = false;\n\t\tif (err || !stdout) return;\n\t\tconst [used, total] = stdout.trim().split(\",\").map((s) => s.trim());\n\t\tif (used && total) cachedVramUsage = `${used}MB / ${total}MB`;\n\t});\n}\nfunction getVramUsage() {\n\treturn cachedVramUsage;\n}\nconst DEFAULT_RING_CAPACITY = 2;\nconst MIN_RING_CAPACITY = 2;\nconst MAX_RING_CAPACITY = 8;\nfunction resolveRingCapacity(explicit) {\n\tconst fromEnv = Number(process.env.FRAMEFIELDS_RING_CAPACITY);\n\tconst requested = explicit ?? (Number.isFinite(fromEnv) && fromEnv > 0 ? fromEnv : NaN);\n\tif (!Number.isFinite(requested) || requested <= 0) return DEFAULT_RING_CAPACITY;\n\treturn Math.max(MIN_RING_CAPACITY, Math.min(MAX_RING_CAPACITY, Math.floor(requested)));\n}\nvar NodeSurfacePool = class {\n\tidle = [];\n\tmaxIdle = 2;\n\tacquire(device, width, height) {\n\t\tconst index = this.idle.findIndex((entry) => entry.device === device && entry.surface.width === width && entry.surface.height === height);\n\t\tif (index >= 0) {\n\t\t\tconst [entry] = this.idle.splice(index, 1);\n\t\t\tif (entry) return entry.surface;\n\t\t}\n\t\tfor (let i = this.idle.length - 1; i >= 0; i--) {\n\t\t\tconst entry = this.idle[i];\n\t\t\tif (entry && entry.device !== device) {\n\t\t\t\tthis.idle.splice(i, 1);\n\t\t\t\ttry {\n\t\t\t\t\tentry.surface.destroy();\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t}\n\t\treturn new NodeSurfaceProvider(device, width, height);\n\t}\n\trelease(device, surface) {\n\t\tif (this.idle.length >= this.maxIdle) {\n\t\t\ttry {\n\t\t\t\tsurface.destroy();\n\t\t\t} catch {}\n\t\t\treturn;\n\t\t}\n\t\tthis.idle.push({\n\t\t\tdevice,\n\t\t\tsurface\n\t\t});\n\t}\n\tdestroy() {\n\t\tfor (const entry of this.idle.splice(0)) try {\n\t\t\tentry.surface.destroy();\n\t\t} catch {}\n\t}\n};\nconst nodeSurfacePool = new NodeSurfacePool();\nfunction formatLutAsCube(lut) {\n\tconst lines = [\n\t\t\"# Created by Gatewai\",\n\t\tlut.type === \"3D\" ? `LUT_3D_SIZE ${lut.size}` : `LUT_1D_SIZE ${lut.size}`,\n\t\t\"\"\n\t];\n\tfor (const p of lut.points) lines.push(`${p[0].toFixed(6)} ${p[1].toFixed(6)} ${p[2].toFixed(6)}`);\n\treturn lines.join(\"\\n\");\n}\nvar HeadlessWebGPURenderer = class HeadlessWebGPURenderer {\n\tstatic isInitialized = false;\n\tstatic initPromise = null;\n\tstatic initFailureCount = 0;\n\tstatic MAX_INIT_FAILURES = 3;\n\tstatic nextRetryAt = 0;\n\tstatic initialize() {\n\t\tif (HeadlessWebGPURenderer.isInitialized) return Promise.resolve();\n\t\tif (HeadlessWebGPURenderer.initFailureCount >= HeadlessWebGPURenderer.MAX_INIT_FAILURES) return Promise.reject(/* @__PURE__ */ new Error(\"GPU initialization permanently failed — circuit breaker open\"));\n\t\tif (Date.now() < HeadlessWebGPURenderer.nextRetryAt) return Promise.reject(/* @__PURE__ */ new Error(\"GPU initialization in backoff period\"));\n\t\tif (HeadlessWebGPURenderer.initPromise) return HeadlessWebGPURenderer.initPromise;\n\t\tHeadlessWebGPURenderer.initPromise = (async () => {\n\t\t\ttry {\n\t\t\t\trendererLogger.debug(\"[HeadlessWebGPURenderer] Initializing headless WebGPU…\");\n\t\t\t\tawait initHeadlessWebGPU();\n\t\t\t\trendererLogger.debug(\"[HeadlessWebGPURenderer] Scanning node renderers…\");\n\t\t\t\tawait discoverAndRegisterNodeRenderers();\n\t\t\t\tHeadlessWebGPURenderer.isInitialized = true;\n\t\t\t\tHeadlessWebGPURenderer.initPromise = null;\n\t\t\t\tHeadlessWebGPURenderer.initFailureCount = 0;\n\t\t\t\tHeadlessWebGPURenderer.nextRetryAt = 0;\n\t\t\t\trendererLogger.debug(\"[HeadlessWebGPURenderer] Initialization complete.\");\n\t\t\t} catch (error) {\n\t\t\t\tHeadlessWebGPURenderer.initFailureCount++;\n\t\t\t\tHeadlessWebGPURenderer.nextRetryAt = Date.now() + 5e3 * 2 ** HeadlessWebGPURenderer.initFailureCount;\n\t\t\t\tHeadlessWebGPURenderer.initPromise = null;\n\t\t\t\trendererLogger.error({\n\t\t\t\t\terr: error instanceof Error ? error.message : String(error),\n\t\t\t\t\tfailureCount: HeadlessWebGPURenderer.initFailureCount,\n\t\t\t\t\tnextRetryAt: new Date(HeadlessWebGPURenderer.nextRetryAt).toISOString()\n\t\t\t\t}, \"[HeadlessWebGPURenderer] Initialization failed\");\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})();\n\t\treturn HeadlessWebGPURenderer.initPromise;\n\t}\n\tasync renderImage(virtualMedia, frame = 0, fps = 24, options = {}) {\n\t\tawait HeadlessWebGPURenderer.initialize();\n\t\tconst width = toEvenDimension(virtualMedia.metadata.width ?? 0);\n\t\tconst height = toEvenDimension(virtualMedia.metadata.height ?? 0);\n\t\tif (!width || !height) throw new Error(`Invalid dimensions: ${width}x${height}`);\n\t\tconst renderId = options.renderId ?? `img-${randomUUID()}`;\n\t\trendererLogger.debug({\n\t\t\trenderId,\n\t\t\tframe,\n\t\t\t...renderSemaphore.stats\n\t\t}, \"[HeadlessWebGPURenderer] Acquiring slot for image render\");\n\t\tawait renderSemaphore.acquire();\n\t\tlet surface;\n\t\tlet renderer;\n\t\tconst device = await ensureDevice();\n\t\ttry {\n\t\t\tawait preloadFonts(virtualMedia, device);\n\t\t\tsurface = nodeSurfacePool.acquire(device, width, height);\n\t\t\trenderer = getRenderer2D(device, surface.colorFormat);\n\t\t\tconst ctx = {\n\t\t\t\tdevice,\n\t\t\t\trenderer,\n\t\t\t\tsurface\n\t\t\t};\n\t\t\tupdateClockSignals(frame, fps, virtualMedia.metadata.durationMs ?? void 0);\n\t\t\tif (frame === 0 || lutStore.hasPending(device) || SlugFontCache.hasPending()) {\n\t\t\t\tconst preEncoder = device.createCommandEncoder();\n\t\t\t\tconst dummyTex = renderer.getTemporaryTexture(width, height);\n\t\t\t\tconst dummyView = dummyTex.createView();\n\t\t\t\trenderer.beginFrame(preEncoder, dummyView, {\n\t\t\t\t\tr: 0,\n\t\t\t\t\tg: 0,\n\t\t\t\t\tb: 0,\n\t\t\t\t\ta: 0\n\t\t\t\t}, width, height, \"clear\").end();\n\t\t\t\tawait drawCompositionTree(ctx, preEncoder, dummyView, dummyTex, width, height, virtualMedia, {\n\t\t\t\t\tframe,\n\t\t\t\t\tcompositionFrame: frame,\n\t\t\t\t\tfps,\n\t\t\t\t\tisHeadless: true,\n\t\t\t\t\trenderId,\n\t\t\t\t\tvirtualMedia,\n\t\t\t\t\tcontainerWidth: width,\n\t\t\t\t\tcontainerHeight: height,\n\t\t\t\t\tisVideoMode: virtualMedia.operation?.dataType === \"Video\"\n\t\t\t\t});\n\t\t\t\tdevice.queue.submit([preEncoder.finish()]);\n\t\t\t\tawait lutStore.awaitAllPending(device);\n\t\t\t}\n\t\t\tcompositionStateStore.setState(renderId, frame, fps, true);\n\t\t\tconst encoder = device.createCommandEncoder();\n\t\t\tconst targetView = surface.getCurrentTextureView();\n\t\t\tconst targetTexture = surface.getCurrentTexture();\n\t\t\trenderer.beginFrame(encoder, targetView, {\n\t\t\t\tr: 0,\n\t\t\t\tg: 0,\n\t\t\t\tb: 0,\n\t\t\t\ta: 0\n\t\t\t}, width, height, \"clear\").end();\n\t\t\tawait drawCompositionTree(ctx, encoder, targetView, targetTexture, width, height, virtualMedia, {\n\t\t\t\tframe,\n\t\t\t\tcompositionFrame: frame,\n\t\t\t\tfps,\n\t\t\t\tisHeadless: true,\n\t\t\t\trenderId,\n\t\t\t\tvirtualMedia,\n\t\t\t\tcontainerWidth: width,\n\t\t\t\tcontainerHeight: height,\n\t\t\t\tisVideoMode: virtualMedia.operation?.dataType === \"Video\"\n\t\t\t});\n\t\t\tdevice.queue.submit([encoder.finish()]);\n\t\t\tconst pixels = await surface.readPixels();\n\t\t\tconst pixelsArr = new Uint8Array(pixels.buffer, pixels.byteOffset, pixels.byteLength);\n\t\t\tif (options.format === \"rgba\") return Buffer.from(pixelsArr);\n\t\t\treturn await sharp(Buffer.from(pixelsArr), { raw: {\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t\tchannels: 4\n\t\t\t} }).png().toBuffer();\n\t\t} finally {\n\t\t\ttry {\n\t\t\t\tclearAllVideoCache();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tshaderStore.clear(renderId);\n\t\t\t} catch {}\n\t\t\tif (surface) nodeSurfacePool.release(device, surface);\n\t\t\ttry {\n\t\t\t\ttextureCache.destroy();\n\t\t\t} catch {}\n\t\t\trenderSemaphore.release();\n\t\t\trendererLogger.debug({\n\t\t\t\trenderId,\n\t\t\t\t...renderSemaphore.stats\n\t\t\t}, \"[HeadlessWebGPURenderer] Image render slot released\");\n\t\t}\n\t}\n\t/**\n\t* Renders a single frame to a PNG buffer at a specified timestamp in milliseconds or frame index.\n\t*/\n\tasync renderFrame(source, options = {}) {\n\t\tconst vm = typeof source === \"object\" && source !== null && \"toVirtualMedia\" in source ? source.toVirtualMedia() : source;\n\t\tconst fps = options.fps ?? (vm.metadata?.fps || 30);\n\t\tconst frame = options.atMs !== void 0 ? Math.round(options.atMs / 1e3 * fps) : options.frame ?? 0;\n\t\treturn this.renderImage(vm, frame, fps, {\n\t\t\trenderId: options.renderId,\n\t\t\tformat: options.format\n\t\t});\n\t}\n\t/**\n\t* Mixes the composition's full audio timeline (clips, effects, synthesized\n\t* tracks) to stereo PCM, exactly as `renderVideo` muxes it.\n\t*/\n\tasync renderAudio(virtualMedia, options = {}) {\n\t\tawait HeadlessWebGPURenderer.initialize();\n\t\tconst fps = options.fps ?? (virtualMedia.metadata?.fps || 30);\n\t\tawait renderSemaphore.acquire();\n\t\ttry {\n\t\t\tconst device = await ensureDevice();\n\t\t\treturn await mixAudioTracks(virtualMedia, fps, options.sampleRate ?? 48e3, device, `aud-${randomUUID()}`);\n\t\t} finally {\n\t\t\trenderSemaphore.release();\n\t\t}\n\t}\n\tasync renderLut(virtualMedia, frame = 0, fps = 24) {\n\t\tawait HeadlessWebGPURenderer.initialize();\n\t\tconst width = 32;\n\t\tconst height = 32;\n\t\tconst renderId = `lut-${randomUUID()}`;\n\t\trendererLogger.debug({\n\t\t\trenderId,\n\t\t\tframe,\n\t\t\t...renderSemaphore.stats\n\t\t}, \"[HeadlessWebGPURenderer] Acquiring slot for LUT render\");\n\t\tawait renderSemaphore.acquire();\n\t\tlet surface;\n\t\tlet renderer;\n\t\tconst device = await ensureDevice();\n\t\tlet lutData = null;\n\t\tconst lutSub = lutStore.onChange((key) => {\n\t\t\tconst raw = lutStore.getRawData(key);\n\t\t\tif (raw) lutData = raw;\n\t\t});\n\t\ttry {\n\t\t\tawait preloadFonts(virtualMedia, device);\n\t\t\tsurface = new NodeSurfaceProvider(device, width, height);\n\t\t\trenderer = getRenderer2D(device, surface.colorFormat);\n\t\t\tconst ctx = {\n\t\t\t\tdevice,\n\t\t\t\trenderer,\n\t\t\t\tsurface\n\t\t\t};\n\t\t\tif (frame === 0 || lutStore.hasPending(device) || SlugFontCache.hasPending()) {\n\t\t\t\tconst preEncoder = device.createCommandEncoder();\n\t\t\t\tconst dummyTex = renderer.getTemporaryTexture(width, height);\n\t\t\t\tconst dummyView = dummyTex.createView();\n\t\t\t\trenderer.beginFrame(preEncoder, dummyView, {\n\t\t\t\t\tr: 0,\n\t\t\t\t\tg: 0,\n\t\t\t\t\tb: 0,\n\t\t\t\t\ta: 0\n\t\t\t\t}, width, height, \"clear\").end();\n\t\t\t\tawait drawCompositionTree(ctx, preEncoder, dummyView, dummyTex, width, height, virtualMedia, {\n\t\t\t\t\tframe,\n\t\t\t\t\tcompositionFrame: frame,\n\t\t\t\t\tfps,\n\t\t\t\t\tisHeadless: true,\n\t\t\t\t\trenderId,\n\t\t\t\t\tvirtualMedia,\n\t\t\t\t\tcontainerWidth: width,\n\t\t\t\t\tcontainerHeight: height,\n\t\t\t\t\tisVideoMode: virtualMedia.operation?.dataType === \"Video\"\n\t\t\t\t});\n\t\t\t\tdevice.queue.submit([preEncoder.finish()]);\n\t\t\t\tawait lutStore.awaitAllPending(device);\n\t\t\t}\n\t\t\tcompositionStateStore.setState(renderId, frame, fps, true);\n\t\t\tconst encoder = device.createCommandEncoder();\n\t\t\tconst targetView = surface.getCurrentTextureView();\n\t\t\tconst targetTexture = surface.getCurrentTexture();\n\t\t\trenderer.beginFrame(encoder, targetView, {\n\t\t\t\tr: 0,\n\t\t\t\tg: 0,\n\t\t\t\tb: 0,\n\t\t\t\ta: 0\n\t\t\t}, width, height, \"clear\").end();\n\t\t\tawait drawCompositionTree(ctx, encoder, targetView, targetTexture, width, height, virtualMedia, {\n\t\t\t\tframe,\n\t\t\t\tcompositionFrame: frame,\n\t\t\t\tfps,\n\t\t\t\tisHeadless: true,\n\t\t\t\trenderId,\n\t\t\t\tvirtualMedia,\n\t\t\t\tcontainerWidth: width,\n\t\t\t\tcontainerHeight: height,\n\t\t\t\tisVideoMode: virtualMedia.operation?.dataType === \"Video\"\n\t\t\t});\n\t\t\tdevice.queue.submit([encoder.finish()]);\n\t\t\tawait lutStore.awaitAllPending(device);\n\t\t\tif (!lutData) lutData = lutStore.getAnyRawData();\n\t\t\tif (!lutData) throw new Error(\"No LUT data generated during rendering\");\n\t\t\tconst cubeContent = formatLutAsCube(lutData);\n\t\t\treturn Buffer.from(cubeContent, \"utf-8\");\n\t\t} finally {\n\t\t\ttry {\n\t\t\t\tlutSub();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tmediaDecoderCache.destroy();\n\t\t\t\tclearAllVideoCache();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tshaderStore.clear(renderId);\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tsurface?.destroy();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\ttextureCache.destroy();\n\t\t\t} catch {}\n\t\t\trenderSemaphore.release();\n\t\t\trendererLogger.debug({\n\t\t\t\trenderId,\n\t\t\t\t...renderSemaphore.stats\n\t\t\t}, \"[HeadlessWebGPURenderer] LUT render slot released\");\n\t\t}\n\t}\n\tasync resolveMediaDuration(virtualMedia, fps) {\n\t\tlet maxDurationMs = 0;\n\t\tconst queue = [virtualMedia];\n\t\tconst sources = /* @__PURE__ */ new Set();\n\t\twhile (queue.length > 0) {\n\t\t\tconst current = queue.shift();\n\t\t\tif (current.metadata?.durationMs && current.metadata.durationMs > maxDurationMs) maxDurationMs = current.metadata.durationMs;\n\t\t\tconst op = current.operation;\n\t\t\tif (op) {\n\t\t\t\tif (typeof op.source === \"string\") sources.add(op.source);\n\t\t\t\tif (typeof op.url === \"string\") sources.add(op.url);\n\t\t\t\tif (typeof op.inputHandleId === \"string\") sources.add(op.inputHandleId);\n\t\t\t\tif (Array.isArray(op.layout)) for (const node of op.layout) {\n\t\t\t\t\tif (node.inputHandleId) sources.add(node.inputHandleId);\n\t\t\t\t\tif (node.src) sources.add(node.src);\n\t\t\t\t\tif (typeof node.durationFrames === \"number\") {\n\t\t\t\t\t\tconst durMs = ((typeof node.startFrame === \"number\" ? node.startFrame : 0) + node.durationFrames) / fps * 1e3;\n\t\t\t\t\t\tif (durMs > maxDurationMs) maxDurationMs = durMs;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (current.children) queue.push(...current.children);\n\t\t}\n\t\tfor (const src of sources) try {\n\t\t\tconst sec = await (await inputStore.acquire(src)).computeDuration();\n\t\t\tif (Number.isFinite(sec) && sec > 0) {\n\t\t\t\tconst ms = Math.round(sec * 1e3);\n\t\t\t\tif (ms > maxDurationMs) maxDurationMs = ms;\n\t\t\t}\n\t\t} catch (_) {}\n\t\treturn maxDurationMs > 0 ? maxDurationMs : 1e3;\n\t}\n\tasync renderVideo(virtualMedia, options) {\n\t\tawait HeadlessWebGPURenderer.initialize();\n\t\tconst codecOption = options?.codec ?? \"h264\";\n\t\tconst isMp3 = codecOption === \"mp3\";\n\t\tconst isWebM = codecOption === \"vp8\" || codecOption === \"vp9\" || codecOption === \"opus\";\n\t\tconst mediaType = getMediaType(virtualMedia);\n\t\tconst isLut = mediaType === \"LUT\" || virtualMedia.operation?.dataType === \"LUT\";\n\t\tconst isAudioOnly = isMp3 || codecOption === \"aac\" || codecOption === \"opus\" || mediaType === \"Audio\";\n\t\tconst fps = virtualMedia.metadata.fps ?? (isAudioOnly || isLut ? 24 : void 0);\n\t\tif (!fps) {\n\t\t\tconst dataType = mediaType ?? virtualMedia.dataType ?? \"Unknown\";\n\t\t\tconst op = virtualMedia.operation?.op ?? virtualMedia.op ?? \"Unknown\";\n\t\t\tthrow new Error(`FPS is missing from virtualMedia metadata (dataType: \"${dataType}\", operation: \"${op}\")`);\n\t\t}\n\t\tconst width = toEvenDimension(virtualMedia.metadata.width ?? (isAudioOnly ? 1280 : 0));\n\t\tconst height = toEvenDimension(virtualMedia.metadata.height ?? (isAudioOnly ? 720 : 0));\n\t\tif (!width || !height) throw new Error(`Invalid dimensions: ${width}x${height}`);\n\t\tlet durationMs = virtualMedia.metadata.durationMs;\n\t\tif (!durationMs || durationMs <= 0) {\n\t\t\tdurationMs = await this.resolveMediaDuration(virtualMedia, fps);\n\t\t\tvirtualMedia.metadata.durationMs = durationMs;\n\t\t}\n\t\tconst totalFrames = Math.max(1, Math.round(durationMs / 1e3 * fps));\n\t\tconst renderId = `vid-${randomUUID()}`;\n\t\tconst qaOptions = options?.qa === true ? {} : options?.qa ? options.qa : void 0;\n\t\tconst inspector = qaOptions ? new FrameInspector(qaOptions) : void 0;\n\t\tlet videoQa;\n\t\tlet audioQa;\n\t\tconst videoCodec = codecOption === \"vp9\" ? \"vp9\" : codecOption === \"vp8\" ? \"vp8\" : \"avc\";\n\t\tconst audioCodec = options?.audioCodec ?? (isMp3 ? \"mp3\" : isWebM ? \"opus\" : \"aac\");\n\t\tconst quality = resolveQuality(options?.quality);\n\t\trendererLogger.debug({\n\t\t\trenderId,\n\t\t\ttotalFrames,\n\t\t\tfps,\n\t\t\twidth,\n\t\t\theight,\n\t\t\tcodec: codecOption,\n\t\t\t...renderSemaphore.stats\n\t\t}, \"[HeadlessWebGPURenderer] Acquiring slot for video render (inline)\");\n\t\tawait renderSemaphore.acquire();\n\t\tlet lastCpuUsage = process.cpuUsage();\n\t\tlet lastCpuTime = process.hrtime.bigint();\n\t\tconst getCpuUsage = () => {\n\t\t\tconst curCpuUsage = process.cpuUsage();\n\t\t\tconst curCpuTime = process.hrtime.bigint();\n\t\t\tconst userDiff = curCpuUsage.user - lastCpuUsage.user;\n\t\t\tconst sysDiff = curCpuUsage.system - lastCpuUsage.system;\n\t\t\tconst timeDiff = Number(curCpuTime - lastCpuTime) / 1e3;\n\t\t\tlastCpuUsage = curCpuUsage;\n\t\t\tlastCpuTime = curCpuTime;\n\t\t\tif (timeDiff === 0) return \"0.0%\";\n\t\t\tconst cpus = os.cpus().length || 1;\n\t\t\treturn `${((userDiff + sysDiff) / timeDiff * 100 / cpus).toFixed(1)}%`;\n\t\t};\n\t\tconst getRamUsage = () => {\n\t\t\tconst mem = process.memoryUsage();\n\t\t\tconst freeMem = os.freemem();\n\t\t\tconst totalMem = os.totalmem();\n\t\t\tconst usedMem = totalMem - freeMem;\n\t\t\tconst heapUsedMb = Math.round(mem.heapUsed / 1024 / 1024);\n\t\t\tconst heapTotalMb = Math.round(mem.heapTotal / 1024 / 1024);\n\t\t\treturn `Process: ${Math.round(mem.rss / 1024 / 1024)}MB RSS (${heapUsedMb}MB/${heapTotalMb}MB Heap), System: ${Math.round(usedMem / 1024 / 1024)}MB/${Math.round(totalMem / 1024 / 1024)}MB`;\n\t\t};\n\t\tlet statsInterval;\n\t\tif (process.env.NODE_ENV === \"production\") statsInterval = setInterval(() => {\n\t\t\trefreshVramUsage();\n\t\t\trendererLogger.info({\n\t\t\t\trenderId,\n\t\t\t\tcpu: getCpuUsage(),\n\t\t\t\tram: getRamUsage(),\n\t\t\t\tvram: getVramUsage(),\n\t\t\t\trenderQueue: renderSemaphore.stats\n\t\t\t}, \"[HeadlessWebGPURenderer] Performance Stats\");\n\t\t}, 5e3);\n\t\tconst tempDir = os.tmpdir();\n\t\tconst extension = isMp3 ? \"mp3\" : isWebM ? \"webm\" : \"mp4\";\n\t\tconst tempFilePath = path.join(tempDir, `render-${renderId}.${extension}`);\n\t\tconst tempGifPath = path.join(tempDir, `render-${renderId}.gif`);\n\t\tconst target = new FilePathTarget(tempFilePath);\n\t\tconst output = new Output({\n\t\t\tformat: isMp3 ? new Mp3OutputFormat() : isWebM ? new WebMOutputFormat() : new Mp4OutputFormat(),\n\t\t\ttarget\n\t\t});\n\t\tlet videoSource;\n\t\tif (!isAudioOnly) {\n\t\t\tvideoSource = new VideoSampleSource({\n\t\t\t\tcodec: videoCodec,\n\t\t\t\tbitrate: quality,\n\t\t\t\tlatencyMode: \"realtime\",\n\t\t\t\thardwareAcceleration: \"prefer-hardware\"\n\t\t\t});\n\t\t\toutput.addVideoTrack(videoSource);\n\t\t}\n\t\tconst audioSource = new AudioSampleSource({\n\t\t\tcodec: audioCodec,\n\t\t\tbitrate: quality\n\t\t});\n\t\toutput.addAudioTrack(audioSource);\n\t\tlet outputStarted = false;\n\t\tlet outputFinalized = false;\n\t\tconst device = await ensureDevice();\n\t\tlet surface;\n\t\tlet renderer;\n\t\tlet pipeline;\n\t\ttry {\n\t\t\tawait output.start();\n\t\t\toutputStarted = true;\n\t\t\tawait preloadFonts(virtualMedia, device);\n\t\t\tif (!isAudioOnly && videoSource) {\n\t\t\t\tsurface = new NodeSurfaceProvider(device, width, height);\n\t\t\t\trenderer = getRenderer2D(device, surface.colorFormat);\n\t\t\t\tpipeline = new ZeroCopyWebCodecsPipeline(device, {\n\t\t\t\t\twidth,\n\t\t\t\t\theight,\n\t\t\t\t\tfps,\n\t\t\t\t\tvideoSource,\n\t\t\t\t\tringCapacity: resolveRingCapacity(options?.ringCapacity),\n\t\t\t\t\tonFrame: inspector ? (rgba) => inspector.inspect(rgba, width, height) : void 0\n\t\t\t\t});\n\t\t\t\tconst ctx = surface && renderer ? {\n\t\t\t\t\tdevice,\n\t\t\t\t\trenderer,\n\t\t\t\t\tsurface\n\t\t\t\t} : null;\n\t\t\t\tconst prePass = async (frame) => {\n\t\t\t\t\tif (!ctx || !renderer) return;\n\t\t\t\t\tconst preEncoder = device.createCommandEncoder();\n\t\t\t\t\tconst dummyTex = renderer.getTemporaryTexture(width, height);\n\t\t\t\t\tconst dummyView = dummyTex.createView();\n\t\t\t\t\trenderer.beginFrame(preEncoder, dummyView, {\n\t\t\t\t\t\tr: 0,\n\t\t\t\t\t\tg: 0,\n\t\t\t\t\t\tb: 0,\n\t\t\t\t\t\ta: 0\n\t\t\t\t\t}, width, height, \"clear\").end();\n\t\t\t\t\tawait drawCompositionTree(ctx, preEncoder, dummyView, dummyTex, width, height, virtualMedia, {\n\t\t\t\t\t\tframe,\n\t\t\t\t\t\tcompositionFrame: frame,\n\t\t\t\t\t\tfps,\n\t\t\t\t\t\tisHeadless: true,\n\t\t\t\t\t\trenderId,\n\t\t\t\t\t\tvirtualMedia,\n\t\t\t\t\t\tcontainerWidth: width,\n\t\t\t\t\t\tcontainerHeight: height,\n\t\t\t\t\t\tisVideoMode: virtualMedia.operation?.dataType === \"Video\"\n\t\t\t\t\t});\n\t\t\t\t\tdevice.queue.submit([preEncoder.finish()]);\n\t\t\t\t\tawait lutStore.awaitAllPending(device);\n\t\t\t\t};\n\t\t\t\tawait prePass(0);\n\t\t\t\tfor (let i = 0; i < totalFrames; i++) {\n\t\t\t\t\toptions?.signal?.throwIfAborted();\n\t\t\t\t\tif (i % 10 === 0) rendererLogger.info({\n\t\t\t\t\t\trenderId,\n\t\t\t\t\t\tframe: i,\n\t\t\t\t\t\ttotalFrames\n\t\t\t\t\t}, `[HeadlessWebGPURenderer] Rendering frame ${i}/${totalFrames}`);\n\t\t\t\t\tif (ctx && surface && renderer && pipeline) {\n\t\t\t\t\t\tif (i > 0 && (lutStore.hasPending(device) || SlugFontCache.hasPending())) {\n\t\t\t\t\t\t\tupdateClockSignals(i, fps, durationMs);\n\t\t\t\t\t\t\tawait prePass(i);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcompositionStateStore.setState(renderId, i, fps, true);\n\t\t\t\t\t\tupdateClockSignals(i, fps, durationMs);\n\t\t\t\t\t\tconst encoder = device.createCommandEncoder();\n\t\t\t\t\t\tconst targetView = surface.getCurrentTextureView();\n\t\t\t\t\t\tconst targetTexture = surface.getCurrentTexture();\n\t\t\t\t\t\trenderer.beginFrame(encoder, targetView, {\n\t\t\t\t\t\t\tr: 0,\n\t\t\t\t\t\t\tg: 0,\n\t\t\t\t\t\t\tb: 0,\n\t\t\t\t\t\t\ta: 0\n\t\t\t\t\t\t}, width, height, \"clear\").end();\n\t\t\t\t\t\tawait drawCompositionTree(ctx, encoder, targetView, targetTexture, width, height, virtualMedia, {\n\t\t\t\t\t\t\tframe: i,\n\t\t\t\t\t\t\tcompositionFrame: i,\n\t\t\t\t\t\t\tfps,\n\t\t\t\t\t\t\tisHeadless: true,\n\t\t\t\t\t\t\trenderId,\n\t\t\t\t\t\t\tvirtualMedia,\n\t\t\t\t\t\t\tcontainerWidth: width,\n\t\t\t\t\t\t\tcontainerHeight: height,\n\t\t\t\t\t\t\tisVideoMode: virtualMedia.operation?.dataType === \"Video\"\n\t\t\t\t\t\t});\n\t\t\t\t\t\tawait pipeline.enqueueFrame(i, targetTexture, encoder);\n\t\t\t\t\t\toptions?.onProgress?.({\n\t\t\t\t\t\t\tphase: \"render\",\n\t\t\t\t\t\t\tframe: i + 1,\n\t\t\t\t\t\t\ttotalFrames\n\t\t\t\t\t\t});\n\t\t\t\t\t} else throw new Error(\"Invalid render context state\");\n\t\t\t\t}\n\t\t\t\tif (pipeline) {\n\t\t\t\t\tawait pipeline.drain();\n\t\t\t\t\tconst pipelineStats = pipeline.getStats();\n\t\t\t\t\tif (inspector && qaOptions) videoQa = inspector.stats(totalFrames, pipelineStats.totalFramesEncoded, fps, width, height, qaOptions);\n\t\t\t\t\trendererLogger.debug({\n\t\t\t\t\t\trenderId,\n\t\t\t\t\t\ttotalFrames,\n\t\t\t\t\t\t...pipelineStats\n\t\t\t\t\t}, `[HeadlessWebGPURenderer] All frames rendered and encoded (avg cycle: ${pipelineStats.averageCycleTimeMs.toFixed(2)}ms, throughput: ${pipelineStats.throughputFps.toFixed(1)} fps)`);\n\t\t\t\t}\n\t\t\t}\n\t\t\toptions?.signal?.throwIfAborted();\n\t\t\toptions?.onProgress?.({\n\t\t\t\tphase: \"audio\",\n\t\t\t\tframe: totalFrames,\n\t\t\t\ttotalFrames\n\t\t\t});\n\t\t\tconst { channels, sampleRate } = await mixAudioTracks(virtualMedia, fps, 48e3, device, renderId);\n\t\t\tconst numChannels = channels.length;\n\t\t\tif (numChannels === 0) throw new Error(\"mixAudioTracks returned no channels\");\n\t\t\tif (qaOptions) audioQa = analyzeAudio(channels, sampleRate, qaOptions);\n\t\t\tconst totalSamples = channels[0].length;\n\t\t\tconst chunkSize = Math.round(.1 * sampleRate);\n\t\t\tfor (let offset = 0; offset < totalSamples; offset += chunkSize) {\n\t\t\t\tconst currentChunk = Math.min(chunkSize, totalSamples - offset);\n\t\t\t\tconst interleaved = new Float32Array(currentChunk * numChannels);\n\t\t\t\tfor (let i = 0; i < currentChunk; i++) for (let ch = 0; ch < numChannels; ch++) interleaved[i * numChannels + ch] = channels[ch]?.[offset + i] ?? 0;\n\t\t\t\tconst sample = new AudioSample({\n\t\t\t\t\tdata: interleaved,\n\t\t\t\t\tformat: \"f32\",\n\t\t\t\t\tnumberOfChannels: numChannels,\n\t\t\t\t\tsampleRate,\n\t\t\t\t\ttimestamp: offset / sampleRate\n\t\t\t\t});\n\t\t\t\ttry {\n\t\t\t\t\tawait audioSource.add(sample);\n\t\t\t\t} finally {\n\t\t\t\t\tsample.close();\n\t\t\t\t}\n\t\t\t}\n\t\t\toptions?.signal?.throwIfAborted();\n\t\t\tawait output.finalize();\n\t\t\toutputFinalized = true;\n\t\t\tconst qa = qaOptions ? buildQaReport({\n\t\t\t\tvideo: videoQa,\n\t\t\t\taudio: audioQa,\n\t\t\t\tdiagnostics: takeRenderDiagnostics(renderId),\n\t\t\t\toptions: qaOptions\n\t\t\t}) : void 0;\n\t\t\tconst cleanup = async () => {\n\t\t\t\ttry {\n\t\t\t\t\tawait fs.unlink(tempFilePath).catch(() => {});\n\t\t\t\t\tif (codecOption === \"gif\") await fs.unlink(tempGifPath).catch(() => {});\n\t\t\t\t} catch {}\n\t\t\t};\n\t\t\tif (codecOption === \"gif\") {\n\t\t\t\trendererLogger.debug(\"[HeadlessWebGPURenderer] Converting rendered MP4 to high-quality GIF...\");\n\t\t\t\tawait convertMp4ToGif(tempFilePath, tempGifPath);\n\t\t\t\treturn {\n\t\t\t\t\tfilePath: tempGifPath,\n\t\t\t\t\tcleanup,\n\t\t\t\t\t...qa && { qa }\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tfilePath: tempFilePath,\n\t\t\t\tcleanup,\n\t\t\t\t...qa && { qa }\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tif (outputStarted && !outputFinalized) try {\n\t\t\t\tawait output.finalize();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tawait fs.unlink(tempFilePath).catch(() => {});\n\t\t\t\tif (codecOption === \"gif\") await fs.unlink(tempGifPath).catch(() => {});\n\t\t\t} catch {}\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tif (statsInterval) clearInterval(statsInterval);\n\t\t\ttry {\n\t\t\t\trenderer?.destroy();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tpipeline?.destroy();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tsurface?.destroy();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tmediaDecoderCache.destroy();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tclearAllVideoCache();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\ttextureCache.destroy();\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tWebGPUAudioProcessor.clearCache(renderId);\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tshaderStore.clear(renderId);\n\t\t\t} catch {}\n\t\t\ttakeRenderDiagnostics(renderId);\n\t\t\trenderSemaphore.release();\n\t\t\trendererLogger.debug({\n\t\t\t\trenderId,\n\t\t\t\t...renderSemaphore.stats\n\t\t\t}, \"[HeadlessWebGPURenderer] Video render slot released\");\n\t\t}\n\t}\n};\nconst HeadlessMediaRenderer = HeadlessWebGPURenderer;\n\n//#endregion\nexport { FrameInspector as a, formatQaReport as c, ZeroCopyWebCodecsPipeline as i, integratedLoudness as l, HeadlessWebGPURenderer as n, analyzeAudio as o, renderSemaphore as r, buildQaReport as s, HeadlessMediaRenderer as t };\n//# sourceMappingURL=headless-webgpu-renderer-BTo2uZHD.mjs.map","import { a as NodeManifestError, c as DmaStagingRing, i as NODE_KINDS, l as preloadFonts, n as discoverAndRegisterNodeRenderers, o as loadNodeManifests, r as findNodesDir, s as parseNodeManifest, u as rendererLogger } from \"./bootstrap-mediabunny--TDh3Bij.mjs\";\nimport { a as FrameInspector, c as formatQaReport, i as ZeroCopyWebCodecsPipeline, l as integratedLoudness, n as HeadlessWebGPURenderer, o as analyzeAudio, r as renderSemaphore, s as buildQaReport, t as HeadlessMediaRenderer } from \"./headless-webgpu-renderer-BTo2uZHD.mjs\";\nimport { SlugFontCache, clearAllVideoCache, clearHeadlessFonts, inputStore, lutStore, mediaDecoderCache, textureCache } from \"@framefields/webgpu-renderers\";\n\n//#region src/job-reset.ts\n/**\n* Drops every cache keyed by a file path or URL: media inputs and decoders,\n* textures, LUTs, fonts and downloaded font files. A long-lived worker calls this between jobs,\n* because the next checkout may hold different bytes at the same path. The\n* GPU device and compiled pipelines stay warm.\n*/\nfunction resetRenderCaches() {\n\tclearAllVideoCache();\n\tmediaDecoderCache.destroy();\n\ttextureCache.destroy();\n\tinputStore.clear();\n\tlutStore.destroy();\n\tSlugFontCache.destroy();\n\tclearHeadlessFonts();\n}\n\n//#endregion\nexport { DmaStagingRing, FrameInspector, HeadlessMediaRenderer, HeadlessWebGPURenderer, NODE_KINDS, NodeManifestError, ZeroCopyWebCodecsPipeline, analyzeAudio, buildQaReport, discoverAndRegisterNodeRenderers, findNodesDir, formatQaReport, integratedLoudness, loadNodeManifests, parseNodeManifest, preloadFonts, renderSemaphore, rendererLogger, resetRenderCaches };\n//# sourceMappingURL=index.mjs.map","import fs from \"node:fs/promises\";\nimport type { VirtualMediaData } from \"@framefields/core\";\nimport { Canvas, loadImage } from \"skia-canvas\";\nimport { HeadlessMediaRenderer } from \"./index.js\";\n\nexport interface FrameSamplePoint {\n\tframe: number;\n\ttimeMs: number;\n}\n\nexport interface FrameGridOptions {\n\t/**\n\t * Start frame index for sampling (inclusive). Defaults to 0.\n\t */\n\tstartFrame?: number;\n\n\t/**\n\t * End frame index for sampling (inclusive). Defaults to startFrame + 30.\n\t */\n\tendFrame?: number;\n\n\t/**\n\t * Step interval between sampled frames. Must be >= 1. Defaults to 5.\n\t */\n\tstepFrames?: number;\n\n\t/**\n\t * Explicit list of frame indices to sample. Overrides startFrame/endFrame/stepFrames.\n\t */\n\tframes?: number[];\n\n\t/**\n\t * Start time in milliseconds (alternative to startFrame).\n\t */\n\tstartMs?: number;\n\n\t/**\n\t * End time in milliseconds (alternative to endFrame).\n\t */\n\tendMs?: number;\n\n\t/**\n\t * Step interval in milliseconds (alternative to stepFrames).\n\t */\n\tstepMs?: number;\n\n\t/**\n\t * Explicit list of timestamps in milliseconds to sample.\n\t */\n\ttimesMs?: number[];\n\n\t/**\n\t * Frames per second override. If omitted, reads from media/composition metadata or defaults to 24.\n\t */\n\tfps?: number;\n\n\t/**\n\t * Number of columns in the grid. If omitted, calculated automatically to preserve balance.\n\t */\n\tcolumns?: number;\n\n\t/**\n\t * Width in pixels for each individual thumbnail cell.\n\t * Clamped to [120, 960]. Defaults to 320.\n\t */\n\tcellWidth?: number;\n\n\t/**\n\t * Explicit height for each cell. If omitted, computed from aspect ratio.\n\t */\n\tcellHeight?: number;\n\n\t/**\n\t * Gap in pixels between cells. Defaults to 12.\n\t */\n\tgap?: number;\n\n\t/**\n\t * Outer padding in pixels around the grid. Defaults to 16.\n\t */\n\tpadding?: number;\n\n\t/**\n\t * Background color for the grid canvas. Defaults to \"#090a0f\".\n\t */\n\tbackgroundColor?: string;\n\n\t/**\n\t * Whether to render frame number & millisecond badges on each cell. Defaults to true.\n\t */\n\tshowLabels?: boolean;\n\n\t/**\n\t * Whether to render the metadata header banner at the top of the grid. Defaults to true.\n\t */\n\tshowHeader?: boolean;\n\n\t/**\n\t * Custom header title text.\n\t */\n\theaderText?: string;\n\n\t/**\n\t * Optional file path to write the generated grid image directly to disk.\n\t */\n\toutputPath?: string;\n\n\t/**\n\t * Safety limit for total sampled frames to prevent memory exhaustion or oversized images.\n\t * Defaults to 64. Hard maximum is 120.\n\t */\n\tmaxFrames?: number;\n\n\t/**\n\t * Maximum allowed width for the generated image canvas. Defaults to 4096.\n\t */\n\tmaxGridWidth?: number;\n\n\t/**\n\t * Maximum allowed height for the generated image canvas. Defaults to 4096.\n\t */\n\tmaxGridHeight?: number;\n\n\t/**\n\t * Optional shared HeadlessMediaRenderer instance.\n\t */\n\trenderer?: HeadlessMediaRenderer;\n}\n\n/**\n * Resolves and validates the list of sample points from the provided options.\n */\nexport function resolveSamplePoints(\n\toptions: FrameGridOptions,\n\tdefaultFps = 24,\n\tdurationMs?: number,\n): { samples: FrameSamplePoint[]; fps: number } {\n\tconst fps = options.fps ?? defaultFps;\n\tif (fps <= 0) {\n\t\tthrow new Error(`[FrameGrid] Invalid fps: ${fps}. Must be > 0.`);\n\t}\n\n\tconst samples: FrameSamplePoint[] = [];\n\n\tif (Array.isArray(options.frames) && options.frames.length > 0) {\n\t\tfor (const f of options.frames) {\n\t\t\tif (typeof f !== \"number\" || f < 0 || !Number.isFinite(f)) {\n\t\t\t\tthrow new Error(`[FrameGrid] Invalid frame index in frames list: ${f}`);\n\t\t\t}\n\t\t\tsamples.push({\n\t\t\t\tframe: Math.round(f),\n\t\t\t\ttimeMs: Math.round((f / fps) * 1000),\n\t\t\t});\n\t\t}\n\t} else if (Array.isArray(options.timesMs) && options.timesMs.length > 0) {\n\t\tfor (const ms of options.timesMs) {\n\t\t\tif (typeof ms !== \"number\" || ms < 0 || !Number.isFinite(ms)) {\n\t\t\t\tthrow new Error(`[FrameGrid] Invalid timestamp in timesMs list: ${ms}`);\n\t\t\t}\n\t\t\tsamples.push({\n\t\t\t\tframe: Math.round((ms / 1000) * fps),\n\t\t\t\ttimeMs: Math.round(ms),\n\t\t\t});\n\t\t}\n\t} else if (\n\t\toptions.startMs !== undefined ||\n\t\toptions.endMs !== undefined ||\n\t\toptions.stepMs !== undefined\n\t) {\n\t\tconst startMs = options.startMs ?? 0;\n\t\tconst endMs = options.endMs ?? durationMs ?? startMs + 1000;\n\t\tconst stepMs = options.stepMs ?? Math.round((5 / fps) * 1000);\n\n\t\tif (startMs < 0 || endMs < startMs) {\n\t\t\tthrow new Error(\n\t\t\t\t`[FrameGrid] Invalid millisecond range: startMs=${startMs}, endMs=${endMs}. startMs must be <= endMs.`,\n\t\t\t);\n\t\t}\n\t\tif (stepMs <= 0) {\n\t\t\tthrow new Error(`[FrameGrid] Invalid stepMs: ${stepMs}. Must be > 0.`);\n\t\t}\n\n\t\tfor (let ms = startMs; ms <= endMs; ms += stepMs) {\n\t\t\tsamples.push({\n\t\t\t\tframe: Math.round((ms / 1000) * fps),\n\t\t\t\ttimeMs: Math.round(ms),\n\t\t\t});\n\t\t}\n\t} else {\n\t\tconst startFrame = options.startFrame ?? 0;\n\t\tconst endFrame =\n\t\t\toptions.endFrame ??\n\t\t\t(durationMs\n\t\t\t\t? Math.min(startFrame + 30, Math.floor((durationMs / 1000) * fps))\n\t\t\t\t: startFrame + 30);\n\t\tconst stepFrames = options.stepFrames ?? 5;\n\n\t\tif (startFrame < 0 || endFrame < startFrame) {\n\t\t\tthrow new Error(\n\t\t\t\t`[FrameGrid] Invalid frame range: startFrame=${startFrame}, endFrame=${endFrame}. startFrame must be <= endFrame.`,\n\t\t\t);\n\t\t}\n\t\tif (stepFrames <= 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`[FrameGrid] Invalid stepFrames: ${stepFrames}. Must be > 0.`,\n\t\t\t);\n\t\t}\n\n\t\tfor (let f = startFrame; f <= endFrame; f += stepFrames) {\n\t\t\tsamples.push({\n\t\t\t\tframe: Math.round(f),\n\t\t\t\ttimeMs: Math.round((f / fps) * 1000),\n\t\t\t});\n\t\t}\n\t}\n\n\tconst maxFramesLimit = Math.min(options.maxFrames ?? 64, 120);\n\tif (samples.length > maxFramesLimit) {\n\t\tthrow new Error(\n\t\t\t`[FrameGrid] Requested ${samples.length} frames exceeds the safety threshold of ${maxFramesLimit}. ` +\n\t\t\t\t`Increase stepFrames/stepMs or narrow the start/end range to prevent oversized images.`,\n\t\t);\n\t}\n\n\tif (samples.length === 0) {\n\t\tthrow new Error(\"[FrameGrid] Zero frames were resolved for sampling.\");\n\t}\n\n\treturn { samples, fps };\n}\n\n/**\n * Computes grid layout dimensions, ensuring resulting canvas does not exceed size limits.\n */\nexport function computeGridLayout(\n\tnumSamples: number,\n\taspectRatio: number,\n\toptions: FrameGridOptions,\n): {\n\tcolumns: number;\n\trows: number;\n\tcellWidth: number;\n\tcellHeight: number;\n\ttotalWidth: number;\n\ttotalHeight: number;\n\theaderHeight: number;\n\tgap: number;\n\tpadding: number;\n} {\n\tconst gap = options.gap ?? 12;\n\tconst padding = options.padding ?? 16;\n\tconst showHeader = options.showHeader ?? true;\n\tconst headerHeight = showHeader ? 54 : 0;\n\tconst maxGridWidth = options.maxGridWidth ?? 4096;\n\tconst maxGridHeight = options.maxGridHeight ?? 4096;\n\n\tlet columns = options.columns;\n\tif (!columns || columns <= 0) {\n\t\tif (numSamples <= 4) columns = numSamples;\n\t\telse if (numSamples <= 9) columns = 3;\n\t\telse if (numSamples <= 16) columns = 4;\n\t\telse if (numSamples <= 25) columns = 5;\n\t\telse columns = 6;\n\t}\n\tcolumns = Math.min(columns, numSamples);\n\tconst rows = Math.ceil(numSamples / columns);\n\n\tlet cellWidth = Math.max(120, Math.min(options.cellWidth ?? 320, 960));\n\tlet cellHeight =\n\t\toptions.cellHeight ??\n\t\tMath.round(cellWidth / (aspectRatio > 0 ? aspectRatio : 16 / 9));\n\n\tlet totalWidth = columns * cellWidth + (columns - 1) * gap + padding * 2;\n\tlet totalHeight =\n\t\trows * cellHeight + (rows - 1) * gap + padding * 2 + headerHeight;\n\n\t// Downscale thumbnail size if the unconstrained canvas exceeds max dimensions\n\tif (totalWidth > maxGridWidth || totalHeight > maxGridHeight) {\n\t\tconst scaleFactor = Math.min(\n\t\t\t(maxGridWidth - (columns - 1) * gap - padding * 2) /\n\t\t\t\t(columns * cellWidth),\n\t\t\t(maxGridHeight - (rows - 1) * gap - padding * 2 - headerHeight) /\n\t\t\t\t(rows * cellHeight),\n\t\t);\n\n\t\tif (scaleFactor < 0.25) {\n\t\t\tthrow new Error(\n\t\t\t\t`[FrameGrid] Cannot fit ${numSamples} cells (${columns}x${rows}) into max dimensions ` +\n\t\t\t\t\t`[${maxGridWidth}x${maxGridHeight}]. Reduce cell count or decrease cellWidth.`,\n\t\t\t);\n\t\t}\n\n\t\tcellWidth = Math.max(100, Math.floor(cellWidth * scaleFactor));\n\t\tcellHeight = Math.round(\n\t\t\tcellWidth / (aspectRatio > 0 ? aspectRatio : 16 / 9),\n\t\t);\n\n\t\ttotalWidth = columns * cellWidth + (columns - 1) * gap + padding * 2;\n\t\ttotalHeight =\n\t\t\trows * cellHeight + (rows - 1) * gap + padding * 2 + headerHeight;\n\t}\n\n\treturn {\n\t\tcolumns,\n\t\trows,\n\t\tcellWidth,\n\t\tcellHeight,\n\t\ttotalWidth,\n\t\ttotalHeight,\n\t\theaderHeight,\n\t\tgap,\n\t\tpadding,\n\t};\n}\n\nexport type FrameGridRenderable = {\n\ttoVirtualMedia(): VirtualMediaData;\n\trenderFrame(options: {\n\t\tframe?: number;\n\t\tatMs?: number;\n\t\tfps?: number;\n\t\trenderer?: HeadlessMediaRenderer;\n\t}): Promise<Buffer>;\n\tfps?: number;\n\tdurationMs?: number;\n\twidth?: number;\n\theight?: number;\n};\n\n/**\n * Renders a sequence of frames from a Composition or Media pipeline into a unified image grid (contact sheet).\n * Ideal for visual inspection of kinetic motion, transitions, easing, and layout stability.\n */\nexport async function renderFrameGrid(\n\ttarget: FrameGridRenderable,\n\toptions: FrameGridOptions = {},\n): Promise<Buffer> {\n\tconst defaultFps = target.fps ?? 24;\n\tconst durationMs = target.durationMs;\n\tconst { samples, fps } = resolveSamplePoints(options, defaultFps, durationMs);\n\n\tconst compWidth = target.width ?? 1920;\n\tconst compHeight = target.height ?? 1080;\n\tconst aspectRatio =\n\t\tcompWidth > 0 && compHeight > 0 ? compWidth / compHeight : 16 / 9;\n\n\tconst layout = computeGridLayout(samples.length, aspectRatio, options);\n\tconst renderer = options.renderer ?? new HeadlessMediaRenderer();\n\n\t// Render each frame sequentially to manage GPU resources cleanly\n\tconst frameBuffers: Buffer[] = [];\n\tfor (const sample of samples) {\n\t\tconst buf = await target.renderFrame({\n\t\t\tframe: sample.frame,\n\t\t\tatMs: sample.timeMs,\n\t\t\tfps,\n\t\t\trenderer,\n\t\t});\n\t\tframeBuffers.push(buf);\n\t}\n\n\t// Composite into a single grid canvas using skia-canvas\n\tconst canvas = new Canvas(layout.totalWidth, layout.totalHeight);\n\tconst ctx = canvas.getContext(\"2d\");\n\n\t// Fill background\n\tctx.fillStyle = options.backgroundColor ?? \"#090a0f\";\n\tctx.fillRect(0, 0, layout.totalWidth, layout.totalHeight);\n\n\t// Header banner\n\tif (options.showHeader !== false && layout.headerHeight > 0) {\n\t\tconst title =\n\t\t\toptions.headerText ??\n\t\t\t`FrameGrid Conformance Review | Frames ${samples[0].frame}–${samples[samples.length - 1].frame} (Count: ${samples.length})`;\n\t\tconst subtitle = `${compWidth}×${compHeight} @ ${fps} FPS | Cell: ${layout.cellWidth}×${layout.cellHeight}px | Step: ${\n\t\t\toptions.stepFrames\n\t\t\t\t? `${options.stepFrames}f`\n\t\t\t\t: options.stepMs\n\t\t\t\t\t? `${options.stepMs}ms`\n\t\t\t\t\t: \"Custom\"\n\t\t}`;\n\n\t\tctx.fillStyle = \"#f8fafc\";\n\t\tctx.font = \"bold 15px sans-serif\";\n\t\tctx.fillText(title, layout.padding, layout.padding + 18);\n\n\t\tctx.fillStyle = \"#94a3b8\";\n\t\tctx.font = \"12px sans-serif\";\n\t\tctx.fillText(subtitle, layout.padding, layout.padding + 36);\n\n\t\t// Subtle divider line\n\t\tctx.strokeStyle = \"#1e2433\";\n\t\tctx.lineWidth = 1;\n\t\tctx.beginPath();\n\t\tctx.moveTo(layout.padding, layout.padding + 46);\n\t\tctx.lineTo(layout.totalWidth - layout.padding, layout.padding + 46);\n\t\tctx.stroke();\n\t}\n\n\tconst showLabels = options.showLabels ?? true;\n\n\t// Draw each sampled cell\n\tfor (let i = 0; i < samples.length; i++) {\n\t\tconst sample = samples[i];\n\t\tconst col = i % layout.columns;\n\t\tconst row = Math.floor(i / layout.columns);\n\n\t\tconst x = layout.padding + col * (layout.cellWidth + layout.gap);\n\t\tconst y =\n\t\t\tlayout.padding +\n\t\t\tlayout.headerHeight +\n\t\t\trow * (layout.cellHeight + layout.gap);\n\n\t\tconst img = await loadImage(frameBuffers[i]);\n\t\tctx.drawImage(img, x, y, layout.cellWidth, layout.cellHeight);\n\n\t\t// Subtle cell border\n\t\tctx.strokeStyle = \"#262b3d\";\n\t\tctx.lineWidth = 1;\n\t\tctx.strokeRect(x, y, layout.cellWidth, layout.cellHeight);\n\n\t\t// Sleek metadata pill badge\n\t\tif (showLabels) {\n\t\t\tconst label = `F:${sample.frame} • ${sample.timeMs}ms`;\n\n\t\t\tctx.font = \"bold 11px sans-serif\";\n\t\t\tconst textWidth = ctx.measureText(label).width;\n\t\t\tconst badgeW = textWidth + 14;\n\t\t\tconst badgeH = 20;\n\t\t\tconst badgeX = x + 6;\n\t\t\tconst badgeY = y + 6;\n\n\t\t\t// Badge backdrop\n\t\t\tctx.fillStyle = \"#090a0fee\";\n\t\t\tctx.beginPath();\n\t\t\tctx.roundRect(badgeX, badgeY, badgeW, badgeH, 4);\n\t\t\tctx.fill();\n\n\t\t\t// Badge border\n\t\t\tctx.strokeStyle = \"#6366f155\";\n\t\t\tctx.lineWidth = 1;\n\t\t\tctx.stroke();\n\n\t\t\t// Badge text\n\t\t\tctx.fillStyle = \"#e2e8f0\";\n\t\t\tctx.fillText(label, badgeX + 7, badgeY + 14);\n\t\t}\n\t}\n\n\tconst gridBuffer = await canvas.toBuffer(\"png\");\n\n\tif (options.outputPath) {\n\t\tawait fs.writeFile(options.outputPath, gridBuffer);\n\t}\n\n\treturn gridBuffer;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAYA,MAAM,iBAAiB,KAAK;CAC3B,OAAO,OAAO,YAAY,eAAe,QAAQ,KAAK,aAAa;CACnE,WAAW,KAAK,iBAAiB;CACjC,MAAM,EAAE,WAAW,YAAY;CAC/B,CAAC;;;;;;;AAUF,eAAe,aAAa,OAAO,SAAS,MAAM;AACjD,KAAI,CAAC,MAAO;AACZ,OAAM,wBAAwB,OAAO,SAAS,KAAK,SAAS,eAAe,MAAM,KAAK,6CAA6C,OAAO,CAAC;;;;;;;;;;AAa5I,IAAI,iBAAiB,MAAM;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,cAAc;CACd,YAAY,QAAQ,SAAS;AAC5B,OAAK,SAAS;AACd,OAAK,QAAQ,QAAQ;AACrB,OAAK,SAAS,QAAQ;AACtB,OAAK,WAAW,KAAK,IAAI,GAAG,QAAQ,YAAY,EAAE;AAClD,OAAK,SAAS,QAAQ,UAAU;AAChC,OAAK,sBAAsB,KAAK,QAAQ;EACxC,MAAM,eAAe;AACrB,OAAK,cAAc,KAAK,KAAK,KAAK,sBAAsB,aAAa,GAAG;AACxE,OAAK,aAAa,KAAK,cAAc,KAAK;AAC1C,OAAK,QAAQ,EAAE;AACf,OAAK,IAAI,IAAI,GAAG,IAAI,KAAK,UAAU,KAAK;GACvC,MAAM,SAAS,OAAO,aAAa;IAClC,MAAM,KAAK;IACX,OAAO,eAAe,WAAW,eAAe;IAChD,CAAC;AACF,QAAK,MAAM,KAAK;IACf,OAAO;IACP;IACA,QAAQ;IACR,eAAe;IACf,YAAY;IACZ,CAAC;;;;;;;CAOJ,MAAM,YAAY,YAAY;AAC7B,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