@stacksjs/stx 0.2.413 → 0.2.415

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 (346) hide show
  1. package/dist/appearance-bootstrap.js +1 -1
  2. package/dist/binding-manifest.d.ts +1 -1
  3. package/dist/builtins/image-delivery.js +19 -11
  4. package/dist/bundle-analyzer.js +20 -20
  5. package/dist/chunk-020xyn9q.js +3 -0
  6. package/dist/chunk-04jhmfbz.js +2 -0
  7. package/dist/chunk-0pnj3zt2.js +2 -0
  8. package/dist/{chunk-bwjxk1dw.js → chunk-0zaess6f.js} +29 -29
  9. package/dist/chunk-1098mas0.js +2 -0
  10. package/dist/chunk-169n1vpx.js +12 -0
  11. package/dist/chunk-18vmfkcc.js +2 -0
  12. package/dist/chunk-1b6t12hd.js +2 -0
  13. package/dist/chunk-1xdzcy9d.js +14 -0
  14. package/dist/chunk-1zs30k3y.js +2 -0
  15. package/dist/chunk-2ce7f416.js +2 -0
  16. package/dist/chunk-340a824p.js +2 -0
  17. package/dist/chunk-393341w7.js +2 -0
  18. package/dist/chunk-39g1134q.js +2 -0
  19. package/dist/chunk-3efw27as.js +2785 -0
  20. package/dist/chunk-3kthfs03.js +3 -0
  21. package/dist/chunk-3qn1wcdg.js +2 -0
  22. package/dist/chunk-3s2vnqcf.js +2 -0
  23. package/dist/chunk-42wbs8vq.js +17 -0
  24. package/dist/chunk-4bjravgk.js +2 -0
  25. package/dist/chunk-5gsxpaqk.js +2 -0
  26. package/dist/{chunk-bwsxym3d.js → chunk-5qns2sdz.js} +17 -17
  27. package/dist/chunk-6cfa3g0r.js +2 -0
  28. package/dist/{chunk-bjar18jd.js → chunk-6h38kkjf.js} +46 -52
  29. package/dist/chunk-6hc5vz20.js +3 -0
  30. package/dist/chunk-6q6g76vg.js +499 -0
  31. package/dist/chunk-74j18qk0.js +930 -0
  32. package/dist/chunk-752hw7cd.js +4 -0
  33. package/dist/{chunk-kgd8kchy.js → chunk-765e1s44.js} +11 -76
  34. package/dist/chunk-7gkv67ky.js +4 -0
  35. package/dist/chunk-7z2ra0yf.js +2 -0
  36. package/dist/chunk-8eqrwj1k.js +20 -0
  37. package/dist/chunk-8nhshfz6.js +5 -0
  38. package/dist/chunk-92ps1xpk.js +2 -0
  39. package/dist/chunk-96k8s808.js +3 -0
  40. package/dist/chunk-9amp82bx.js +7 -0
  41. package/dist/chunk-9g27ybyr.js +3 -0
  42. package/dist/chunk-9p9qkbtg.js +3 -0
  43. package/dist/{chunk-xq1acw1r.js → chunk-9pt8fd2n.js} +13 -13
  44. package/dist/{chunk-24zher49.js → chunk-9vrja6vp.js} +4 -4
  45. package/dist/chunk-9xrbve19.js +2 -0
  46. package/dist/chunk-a688m6js.js +3 -0
  47. package/dist/chunk-ak1cgcah.js +5 -0
  48. package/dist/{chunk-4m7ajama.js → chunk-amd6ey3t.js} +14 -14
  49. package/dist/chunk-amtr3rmf.js +11 -0
  50. package/dist/chunk-atws6p5s.js +2 -0
  51. package/dist/chunk-b84h16er.js +61 -0
  52. package/dist/chunk-b98be3yp.js +32 -0
  53. package/dist/{chunk-hx998w7n.js → chunk-bay9s6rs.js} +13 -13
  54. package/dist/chunk-ce1sejr3.js +3 -0
  55. package/dist/chunk-cg8hg6cs.js +3 -0
  56. package/dist/{chunk-4f9zyfdw.js → chunk-czxt605c.js} +4 -5
  57. package/dist/chunk-dd8cja4h.js +2 -0
  58. package/dist/chunk-dgdm3hy3.js +2 -0
  59. package/dist/chunk-e9hs7kk6.js +12 -0
  60. package/dist/chunk-eed4fwps.js +3 -0
  61. package/dist/chunk-ej9j6k1q.js +3 -0
  62. package/dist/chunk-et0rr8c7.js +3 -0
  63. package/dist/chunk-f1sxycmv.js +2 -0
  64. package/dist/chunk-f46qsp4m.js +4 -0
  65. package/dist/chunk-fbcv4fes.js +2 -0
  66. package/dist/{chunk-bjcsc6wx.js → chunk-fh1qrp68.js} +21 -21
  67. package/dist/chunk-fjs0a8h7.js +2 -0
  68. package/dist/chunk-fpfzm238.js +2 -0
  69. package/dist/chunk-fr2txj8q.js +829 -0
  70. package/dist/{chunk-xssw417m.js → chunk-ft4p6d28.js} +14 -14
  71. package/dist/chunk-fyzajkrx.js +2 -0
  72. package/dist/chunk-fzapbw9p.js +3 -0
  73. package/dist/chunk-g03s93qr.js +3 -0
  74. package/dist/chunk-g186znp9.js +33 -0
  75. package/dist/chunk-gawrg4gb.js +216 -0
  76. package/dist/chunk-gc1drn2p.js +2 -0
  77. package/dist/chunk-gea5hf0v.js +2 -0
  78. package/dist/chunk-gqv3ta5d.js +2 -0
  79. package/dist/chunk-h6kp2m9r.js +2 -0
  80. package/dist/chunk-h6zsqb9r.js +3 -0
  81. package/dist/{chunk-2snqdnk9.js → chunk-h85hrwkq.js} +13 -13
  82. package/dist/chunk-hbxz85wy.js +2 -0
  83. package/dist/chunk-hepd9qgx.js +6 -0
  84. package/dist/chunk-hhnw2sn3.js +2 -0
  85. package/dist/chunk-hjg3ndgh.js +2 -0
  86. package/dist/chunk-hk1mj4tz.js +2 -0
  87. package/dist/{chunk-smcj3442.js → chunk-hkrmcbwy.js} +79 -79
  88. package/dist/chunk-hn9pkyv8.js +2 -0
  89. package/dist/chunk-hpgr4qgp.js +2 -0
  90. package/dist/chunk-hrbbbtbn.js +2 -0
  91. package/dist/chunk-j03revz2.js +8 -0
  92. package/dist/chunk-j9qcrwbg.js +2 -0
  93. package/dist/chunk-jk4njz0w.js +2 -0
  94. package/dist/chunk-jmabeqfq.js +2 -0
  95. package/dist/chunk-jnkrn913.js +4 -0
  96. package/dist/chunk-jp10q90g.js +2 -0
  97. package/dist/chunk-jt0n43mk.js +2 -0
  98. package/dist/chunk-kjbv8a3m.js +2 -0
  99. package/dist/chunk-m1vdghnx.js +2 -0
  100. package/dist/chunk-m4sk62wb.js +5 -0
  101. package/dist/chunk-md8rqn48.js +30 -0
  102. package/dist/chunk-mp6hy8g4.js +2 -0
  103. package/dist/chunk-nc8my58s.js +2 -0
  104. package/dist/chunk-ngc2wke4.js +3 -0
  105. package/dist/chunk-nn2vstke.js +2 -0
  106. package/dist/chunk-nppdrf0x.js +2 -0
  107. package/dist/chunk-p2v2a68k.js +2 -0
  108. package/dist/chunk-pazfr1a1.js +2 -0
  109. package/dist/{chunk-qn5srnj3.js → chunk-pbh4smw3.js} +16 -16
  110. package/dist/chunk-pdb5fw3r.js +2 -0
  111. package/dist/chunk-pdt69hpb.js +2 -0
  112. package/dist/chunk-pgzvyrv6.js +29 -0
  113. package/dist/chunk-px7fvbj6.js +3 -0
  114. package/dist/chunk-q6vrb2pe.js +2 -0
  115. package/dist/chunk-q7qchkvk.js +2 -0
  116. package/dist/chunk-q9bdh4s5.js +8 -0
  117. package/dist/chunk-qghxz7jm.js +194 -0
  118. package/dist/chunk-r3f9jcf7.js +5 -0
  119. package/dist/chunk-re8b5r9x.js +3 -0
  120. package/dist/chunk-s5xezjps.js +3 -0
  121. package/dist/chunk-sd321bn3.js +2 -0
  122. package/dist/chunk-shr559s7.js +3 -0
  123. package/dist/chunk-t4hzprsm.js +3 -0
  124. package/dist/chunk-t5pvq5mx.js +2 -0
  125. package/dist/{chunk-pv3d7sfn.js → chunk-t61vdbje.js} +89 -89
  126. package/dist/chunk-tafqyf2g.js +2033 -0
  127. package/dist/chunk-tfexmdkt.js +3 -0
  128. package/dist/chunk-thyt8ed8.js +6 -0
  129. package/dist/chunk-v91p6ekp.js +24 -0
  130. package/dist/chunk-vgvtnwxa.js +4 -0
  131. package/dist/chunk-w72qx0eb.js +2 -0
  132. package/dist/chunk-wfy1zq53.js +30 -0
  133. package/dist/chunk-wzx0164n.js +18 -0
  134. package/dist/chunk-x0q32ees.js +3 -0
  135. package/dist/chunk-xfp7k0v8.js +64 -0
  136. package/dist/chunk-xtvf6n6f.js +4 -0
  137. package/dist/chunk-xwzvfqcb.js +2 -0
  138. package/dist/chunk-y1cmjvk3.js +43 -0
  139. package/dist/chunk-y5310237.js +311 -0
  140. package/dist/chunk-ya0qecph.js +27 -0
  141. package/dist/chunk-yazk54jr.js +8 -0
  142. package/dist/chunk-ydjfar14.js +2 -0
  143. package/dist/chunk-ym95v4nc.js +3 -0
  144. package/dist/chunk-z0g9jvv0.js +40 -0
  145. package/dist/chunk-z23kaxq6.js +2 -0
  146. package/dist/chunk-z8xn5ta3.js +2 -0
  147. package/dist/{chunk-8sdhs0zk.js → chunk-zhxdpzga.js} +4 -4
  148. package/dist/cli.js +110 -110
  149. package/dist/craft-entry.js +7 -7
  150. package/dist/craft.js +7 -7
  151. package/dist/database.js +2 -2
  152. package/dist/image-optimization/component.js +4 -4
  153. package/dist/media/image/component.js +5 -5
  154. package/dist/media/protected/component.js +2 -2
  155. package/dist/media/video/index.js +4 -4
  156. package/dist/native/bridge/protocol.d.ts +325 -0
  157. package/dist/native/bridge/protocol.js +219 -0
  158. package/dist/native/cli.d.ts +24 -0
  159. package/dist/native/cli.js +52 -0
  160. package/dist/native/compiler/bundle.d.ts +41 -0
  161. package/dist/native/compiler/bundle.js +90 -0
  162. package/dist/native/compiler/client-script.d.ts +8 -0
  163. package/dist/native/compiler/client-script.js +31 -0
  164. package/dist/native/compiler/codegen.d.ts +10 -0
  165. package/dist/native/compiler/codegen.js +145 -0
  166. package/dist/native/compiler/headwind-to-style.d.ts +395 -0
  167. package/dist/native/compiler/headwind-to-style.js +1163 -0
  168. package/dist/native/compiler/html-to-ir.d.ts +41 -0
  169. package/dist/native/compiler/html-to-ir.js +411 -0
  170. package/dist/native/compiler/icons.d.ts +220 -0
  171. package/dist/native/compiler/icons.js +208 -0
  172. package/dist/native/compiler/ir.d.ts +234 -0
  173. package/dist/native/compiler/ir.js +15 -0
  174. package/dist/native/compiler/parser.d.ts +88 -0
  175. package/dist/native/compiler/parser.js +753 -0
  176. package/dist/native/compiler/render-screen.d.ts +26 -0
  177. package/dist/native/compiler/render-screen.js +31 -0
  178. package/dist/native/components/primitives.d.ts +291 -0
  179. package/dist/native/components/primitives.js +22 -0
  180. package/dist/native/hot-reload/client.d.ts +62 -0
  181. package/dist/native/hot-reload/client.js +324 -0
  182. package/dist/native/index.d.ts +90 -0
  183. package/dist/native/index.js +34 -0
  184. package/dist/native/primitives/ActivityIndicator.stx +5 -0
  185. package/dist/native/primitives/Button.stx +5 -0
  186. package/dist/native/primitives/DatePicker.stx +5 -0
  187. package/dist/native/primitives/FlatList.stx +5 -0
  188. package/dist/native/primitives/Image.stx +5 -0
  189. package/dist/native/primitives/ImageBackground.stx +5 -0
  190. package/dist/native/primitives/KeyboardAvoidingView.stx +5 -0
  191. package/dist/native/primitives/Modal.stx +5 -0
  192. package/dist/native/primitives/Picker.stx +5 -0
  193. package/dist/native/primitives/Pressable.stx +5 -0
  194. package/dist/native/primitives/RefreshControl.stx +5 -0
  195. package/dist/native/primitives/SafeAreaView.stx +5 -0
  196. package/dist/native/primitives/ScrollView.stx +5 -0
  197. package/dist/native/primitives/SectionList.stx +5 -0
  198. package/dist/native/primitives/Slider.stx +5 -0
  199. package/dist/native/primitives/StatusBar.stx +5 -0
  200. package/dist/native/primitives/Switch.stx +5 -0
  201. package/dist/native/primitives/Text.stx +5 -0
  202. package/dist/native/primitives/TextInput.stx +5 -0
  203. package/dist/native/primitives/TouchableHighlight.stx +5 -0
  204. package/dist/native/primitives/TouchableOpacity.stx +5 -0
  205. package/dist/native/primitives/View.stx +5 -0
  206. package/dist/native/runtime/craft.d.ts +75 -0
  207. package/dist/native/runtime/craft.js +0 -0
  208. package/dist/native/runtime/entry.d.ts +1 -0
  209. package/dist/native/runtime/entry.js +3 -0
  210. package/dist/native/runtime/index.d.ts +45 -0
  211. package/dist/native/runtime/index.js +165 -0
  212. package/dist/native/runtime/native-host.d.ts +33 -0
  213. package/dist/native/runtime/native-host.js +184 -0
  214. package/dist/native/runtime/screen.d.ts +43 -0
  215. package/dist/native/runtime/screen.js +808 -0
  216. package/dist/pwa/service-worker.js +1 -1
  217. package/dist/pwa/workbox.js +1 -1
  218. package/dist/pwa.js +8 -8
  219. package/dist/site-url.d.ts +1 -1
  220. package/dist/ssg.js +53 -53
  221. package/dist/visual-testing.js +42 -42
  222. package/dist/web-components/reactive-generator.js +2 -2
  223. package/package.json +9 -5
  224. package/dist/chunk-0btmm4m2.js +0 -147
  225. package/dist/chunk-0c2h69k2.js +0 -4
  226. package/dist/chunk-0d0qeqvv.js +0 -2
  227. package/dist/chunk-0psndabd.js +0 -2
  228. package/dist/chunk-0qv8yf53.js +0 -2
  229. package/dist/chunk-0vkxyvsd.js +0 -2
  230. package/dist/chunk-0we9nw1d.js +0 -3
  231. package/dist/chunk-0xqdmemy.js +0 -3
  232. package/dist/chunk-0y46fbkx.js +0 -3
  233. package/dist/chunk-158wqccn.js +0 -4422
  234. package/dist/chunk-1cyxbb8y.js +0 -16
  235. package/dist/chunk-1enwnh2a.js +0 -2
  236. package/dist/chunk-213pzm0d.js +0 -3
  237. package/dist/chunk-21hzqyja.js +0 -12
  238. package/dist/chunk-266t58b8.js +0 -5
  239. package/dist/chunk-27fgag95.js +0 -4
  240. package/dist/chunk-2a9n102n.js +0 -2
  241. package/dist/chunk-2eqzrczk.js +0 -2
  242. package/dist/chunk-2ke37m54.js +0 -14
  243. package/dist/chunk-35ds08e7.js +0 -3
  244. package/dist/chunk-3mtwkjcg.js +0 -2
  245. package/dist/chunk-4xr8zwkp.js +0 -2
  246. package/dist/chunk-58v77x2c.js +0 -2
  247. package/dist/chunk-5mhq8605.js +0 -2
  248. package/dist/chunk-5se8xt9e.js +0 -64
  249. package/dist/chunk-5zh0h080.js +0 -2
  250. package/dist/chunk-62435225.js +0 -2
  251. package/dist/chunk-6kdrncsx.js +0 -30
  252. package/dist/chunk-6n2rr3x7.js +0 -2
  253. package/dist/chunk-6xk87qf2.js +0 -30
  254. package/dist/chunk-72rwcbp6.js +0 -3
  255. package/dist/chunk-76w34xne.js +0 -3
  256. package/dist/chunk-7ekd7zj9.js +0 -2
  257. package/dist/chunk-7pr3wdd5.js +0 -3
  258. package/dist/chunk-7rxvafwc.js +0 -24
  259. package/dist/chunk-7tnwfa7w.js +0 -8
  260. package/dist/chunk-8c5je0wf.js +0 -2
  261. package/dist/chunk-8dz6nyvx.js +0 -2
  262. package/dist/chunk-98zj3fv2.js +0 -7
  263. package/dist/chunk-9e8t0twa.js +0 -3
  264. package/dist/chunk-9fqp72ze.js +0 -5
  265. package/dist/chunk-anydpa34.js +0 -3
  266. package/dist/chunk-ay6zjq8v.js +0 -3
  267. package/dist/chunk-az4v4ard.js +0 -3
  268. package/dist/chunk-ba5erggg.js +0 -2
  269. package/dist/chunk-bnagrdz6.js +0 -2
  270. package/dist/chunk-by8wghtf.js +0 -2
  271. package/dist/chunk-cd7h4q51.js +0 -2
  272. package/dist/chunk-cjmv8hgp.js +0 -33
  273. package/dist/chunk-cthf912y.js +0 -2
  274. package/dist/chunk-cxbpmwq5.js +0 -4
  275. package/dist/chunk-d3sy16qn.js +0 -2
  276. package/dist/chunk-dh6s7mrj.js +0 -1199
  277. package/dist/chunk-dm2nzg7a.js +0 -2
  278. package/dist/chunk-e2sgcnxc.js +0 -2
  279. package/dist/chunk-e3b7jj74.js +0 -2
  280. package/dist/chunk-ec4wq2sv.js +0 -6
  281. package/dist/chunk-ekzg97dn.js +0 -29
  282. package/dist/chunk-epjt342x.js +0 -2
  283. package/dist/chunk-eqe26g14.js +0 -18
  284. package/dist/chunk-ev0v1yma.js +0 -2
  285. package/dist/chunk-f53psr2y.js +0 -5
  286. package/dist/chunk-f8p69dsg.js +0 -3
  287. package/dist/chunk-f95drhdb.js +0 -194
  288. package/dist/chunk-ff5a6hvb.js +0 -17
  289. package/dist/chunk-fs5fy4h8.js +0 -2
  290. package/dist/chunk-fzsygce3.js +0 -2
  291. package/dist/chunk-g465x63k.js +0 -2
  292. package/dist/chunk-g708ekh1.js +0 -2
  293. package/dist/chunk-gcr9e83g.js +0 -11
  294. package/dist/chunk-gdmyrsr8.js +0 -4
  295. package/dist/chunk-gkms2ngq.js +0 -2
  296. package/dist/chunk-gnfywmgs.js +0 -7
  297. package/dist/chunk-hpf8kq7e.js +0 -2
  298. package/dist/chunk-j4x3faf8.js +0 -2
  299. package/dist/chunk-jkavtw9f.js +0 -2
  300. package/dist/chunk-kg1rdena.js +0 -3
  301. package/dist/chunk-km91wx0v.js +0 -2
  302. package/dist/chunk-kmsyvaex.js +0 -8
  303. package/dist/chunk-mrahwn5v.js +0 -8
  304. package/dist/chunk-nk3czvnk.js +0 -2
  305. package/dist/chunk-nmw4eewb.js +0 -2
  306. package/dist/chunk-nq5zxrk0.js +0 -4
  307. package/dist/chunk-ny67c03k.js +0 -3
  308. package/dist/chunk-p4wdxp2c.js +0 -2
  309. package/dist/chunk-pcxp4r9n.js +0 -3
  310. package/dist/chunk-pdyeaxc1.js +0 -2
  311. package/dist/chunk-pf06ded4.js +0 -2
  312. package/dist/chunk-pfs0gpzm.js +0 -2
  313. package/dist/chunk-pshdwq44.js +0 -2
  314. package/dist/chunk-pwgv84pn.js +0 -32
  315. package/dist/chunk-pwsnafp3.js +0 -4367
  316. package/dist/chunk-q9n5swx7.js +0 -3
  317. package/dist/chunk-qr346wnp.js +0 -2
  318. package/dist/chunk-r02hke04.js +0 -2
  319. package/dist/chunk-ranshpyc.js +0 -3
  320. package/dist/chunk-rn194bhp.js +0 -20
  321. package/dist/chunk-rn1hgyc8.js +0 -930
  322. package/dist/chunk-s7z5dp70.js +0 -43
  323. package/dist/chunk-s8jd13nb.js +0 -3
  324. package/dist/chunk-sn7exv0n.js +0 -2
  325. package/dist/chunk-t1tdjjht.js +0 -216
  326. package/dist/chunk-t6qx04s8.js +0 -499
  327. package/dist/chunk-t6y6gyps.js +0 -2
  328. package/dist/chunk-tjfs7cc3.js +0 -2
  329. package/dist/chunk-tkyrk66a.js +0 -3
  330. package/dist/chunk-tntv9hvq.js +0 -2
  331. package/dist/chunk-v3nwkveg.js +0 -12
  332. package/dist/chunk-vd4cb5xr.js +0 -2
  333. package/dist/chunk-vkhdce50.js +0 -2
  334. package/dist/chunk-w183av08.js +0 -2
  335. package/dist/chunk-w2m02njv.js +0 -2
  336. package/dist/chunk-wpjrcrs5.js +0 -2
  337. package/dist/chunk-wqmppf6b.js +0 -3
  338. package/dist/chunk-wtb9fxdy.js +0 -2
  339. package/dist/chunk-xmzygmcz.js +0 -3
  340. package/dist/chunk-xsng1mtq.js +0 -3
  341. package/dist/chunk-xxzefj4j.js +0 -2
  342. package/dist/chunk-yq8x8bxq.js +0 -47
  343. package/dist/chunk-ytma76qe.js +0 -3
  344. package/dist/chunk-yw1m115e.js +0 -2
  345. package/dist/chunk-z64a924m.js +0 -2
  346. package/dist/chunk-zcz9rs6p.js +0 -3
@@ -0,0 +1,499 @@
1
+ // @bun
2
+ import b from"fs";import z from"path";import{gzipSync as O}from"zlib";import{createHash as G}from"crypto";var I={".js":"js",".mjs":"js",".cjs":"js",".ts":"js",".jsx":"js",".tsx":"js",".css":"css",".scss":"css",".sass":"css",".less":"css",".html":"html",".htm":"html",".png":"image",".jpg":"image",".jpeg":"image",".gif":"image",".svg":"image",".webp":"image",".avif":"image",".ico":"image",".woff":"font",".woff2":"font",".ttf":"font",".eot":"font",".otf":"font"},E=[/node_modules/,/vendor/,/bower_components/,/\.min\./],F=[/index\.(js|ts|html)$/,/main\.(js|ts)$/,/app\.(js|ts)$/,/entry\.(js|ts)$/];async function w(t,n={}){let{includeSourceMaps:e=!1,parseImports:o=!0,detectDuplicates:a=!0,topModulesCount:r=20}=n;if(!b.existsSync(t))throw Error(`Build directory not found: ${t}`);if(!b.statSync(t).isDirectory())throw Error(`Not a directory: ${t}`);let s=await P(t,e),d=[],u=[];for(let h of s)try{let m=await L(h,t,o);d.push(m)}catch(m){u.push(`Failed to process ${h}: ${m}`)}let c=V(d,t),p=d.reduce((h,m)=>h+m.size,0),y=d.reduce((h,m)=>h+m.gzipSize,0),x=_(d),f=a?H(d):[],g=[...d].sort((h,m)=>m.size-h.size).slice(0,r);return{timestamp:Date.now(),buildDir:z.resolve(t),chunks:c,totalSize:p,totalGzipSize:y,moduleCount:d.length,duplicates:f,byType:x,largestModules:g,warnings:u}}async function P(t,n){let e=[];async function o(a){let r=await b.promises.readdir(a,{withFileTypes:!0});for(let i of r){let s=z.join(a,i.name);if(i.isDirectory()){if(!i.name.startsWith(".")&&i.name!=="node_modules")await o(s)}else if(i.isFile()){if(!n&&i.name.endsWith(".map"))continue;e.push(s)}}}return await o(t),e}async function L(t,n,e){let o=await b.promises.readFile(t),a=z.relative(n,t),r=z.extname(t).toLowerCase(),i=o.length,s=N(o),d=D(o,r),u=G("md5").update(o).digest("hex").slice(0,8),c=I[r]||"other",p=[];if(e&&c==="js")p.push(...A(o.toString("utf-8")));return{id:a,path:a,size:i,gzipSize:s,parsedSize:d,extension:r,type:c,imports:p,importedBy:[],hash:u}}function N(t){try{let n=O(t,{level:9}).length;return Math.min(n,t.length)}catch{return t.length}}function D(t,n){if(n.includes(".min.")||t.length<1000)return t.length;let o=I[n];if(o==="js")return Math.round(t.length*0.6);if(o==="css")return Math.round(t.length*0.7);return t.length}function A(t){let n=[],e=/import\s+(?:[\w*{}\s,]+\s+from\s+)?['"]([^'"]+)['"]/g,o;while((o=e.exec(t))!==null)n.push(o[1]);let a=/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;while((o=a.exec(t))!==null)n.push(o[1]);let r=/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;while((o=r.exec(t))!==null)n.push(o[1]);return[...new Set(n)]}function V(t,n){let e=new Map;for(let a of t){let r=a.path.split(z.sep),i;if(r.length===1)i=z.basename(a.path,a.extension);else i=r[0];let s=e.get(i)||[];s.push(a),e.set(i,s)}let o=[];for(let[a,r]of e){let i=r.reduce((c,p)=>c+p.size,0),s=r.reduce((c,p)=>c+p.gzipSize,0),d=r.some((c)=>F.some((p)=>p.test(c.path))),u=r.some((c)=>E.some((p)=>p.test(c.path)));o.push({name:a,files:r.map((c)=>c.path),modules:r,size:i,gzipSize:s,isEntry:d,isVendor:u})}return o.sort((a,r)=>r.size-a.size)}function _(t){let n={js:{count:0,size:0,gzipSize:0},css:{count:0,size:0,gzipSize:0},html:{count:0,size:0,gzipSize:0},image:{count:0,size:0,gzipSize:0},font:{count:0,size:0,gzipSize:0},other:{count:0,size:0,gzipSize:0}};for(let e of t)n[e.type].count++,n[e.type].size+=e.size,n[e.type].gzipSize+=e.gzipSize;return n}function H(t){let n=new Map;for(let o of t){let a=n.get(o.hash)||[];a.push(o),n.set(o.hash,a)}let e=[];for(let[,o]of n)if(o.length>1){let a=o[0];e.push({path:a.path,count:o.length,wastedBytes:a.size*(o.length-1),locations:o.map((r)=>r.path)})}return e.sort((o,a)=>a.wastedBytes-o.wastedBytes)}function l(t){if(t<1024)return`${t} B`;if(t<1048576)return`${(t/1024).toFixed(2)} KB`;return`${(t/1048576).toFixed(2)} MB`}function M(t){let n=t.match(/^([\d.]+)\s*(B|KB|MB|GB)?$/i);if(!n)return 0;let e=Number.parseFloat(n[1]);switch((n[2]||"B").toUpperCase()){case"KB":return e*1024;case"MB":return e*1024*1024;case"GB":return e*1024*1024*1024;default:return e}}function S(t,n){if(n===0)return"0%";return`${(t/n*100).toFixed(1)}%`}function T(t,n){switch(n.format){case"json":return J(t,n);case"markdown":return K(t,n);case"text":default:return W(t,n)}}function J(t,n){let e=v(t,n);return JSON.stringify({timestamp:t.timestamp,buildDir:t.buildDir,summary:{totalSize:t.totalSize,totalSizeFormatted:l(t.totalSize),totalGzipSize:t.totalGzipSize,totalGzipSizeFormatted:l(t.totalGzipSize),moduleCount:t.moduleCount,chunkCount:t.chunks.length,duplicateCount:t.duplicates.length},byType:Object.fromEntries(Object.entries(t.byType).map(([o,a])=>[o,{...a,sizeFormatted:l(a.size),gzipSizeFormatted:l(a.gzipSize)}])),chunks:t.chunks.map((o)=>({name:o.name,size:o.size,sizeFormatted:l(o.size),gzipSize:o.gzipSize,gzipSizeFormatted:l(o.gzipSize),moduleCount:o.modules.length,isEntry:o.isEntry,isVendor:o.isVendor})),largestModules:t.largestModules.slice(0,n.topModules||10).map((o)=>({path:o.path,size:o.size,sizeFormatted:l(o.size),gzipSize:o.gzipSize,gzipSizeFormatted:l(o.gzipSize),type:o.type})),duplicates:t.duplicates,analysis:e,warnings:t.warnings},null,2)}function W(t,n){let e=[],o=n.showGzip!==!1;if(e.push(""),e.push("Bundle Analysis Report"),e.push("\u2550".repeat(50)),e.push(""),e.push("Summary"),e.push("\u2500".repeat(50)),o)e.push(`Total Size: ${l(t.totalSize)} (${l(t.totalGzipSize)} gzip)`);else e.push(`Total Size: ${l(t.totalSize)}`);if(e.push(`Modules: ${t.moduleCount}`),e.push(`Chunks: ${t.chunks.length}`),t.duplicates.length>0)e.push(`Duplicates: ${t.duplicates.length}`);if(e.push(""),n.threshold&&t.totalSize>n.threshold)e.push(`\u26A0\uFE0F Bundle exceeds threshold of ${l(n.threshold)}!`),e.push("");e.push("Size by Type"),e.push("\u2500".repeat(50));let a=["js","css","html","image","font","other"];for(let i of a){let s=t.byType[i];if(s.count>0){let d=S(s.size,t.totalSize),u=o?` (${l(s.gzipSize)} gzip)`:"";e.push(` ${i.padEnd(8)} ${l(s.size).padStart(12)}${u} ${d.padStart(6)} (${s.count} files)`)}}e.push(""),e.push("Chunks"),e.push("\u2500".repeat(50));for(let i of t.chunks.slice(0,10)){let s=[];if(i.isEntry)s.push("entry");if(i.isVendor)s.push("vendor");let d=s.length>0?` [${s.join(", ")}]`:"",u=o?` (${l(i.gzipSize)} gzip)`:"";e.push(` ${i.name.padEnd(20)} ${l(i.size).padStart(12)}${u}${d}`)}if(t.chunks.length>10)e.push(` ... and ${t.chunks.length-10} more chunks`);e.push("");let r=n.topModules||10;e.push(`Largest Modules (Top ${r})`),e.push("\u2500".repeat(50));for(let i=0;i<Math.min(r,t.largestModules.length);i++){let s=t.largestModules[i],d=o?` (${l(s.gzipSize)} gzip)`:"";e.push(` ${(i+1).toString().padStart(2)}. ${s.path}`),e.push(` ${l(s.size)}${d}`)}if(e.push(""),t.duplicates.length>0){e.push("Duplicate Modules"),e.push("\u2500".repeat(50));for(let i of t.duplicates.slice(0,5))e.push(` ${i.path}`),e.push(` ${i.count} copies, wasting ${l(i.wastedBytes)}`);if(t.duplicates.length>5)e.push(` ... and ${t.duplicates.length-5} more duplicates`);e.push("")}if(n.recommendations!==!1){let i=v(t,n);if(i.recommendations.length>0){e.push("Recommendations"),e.push("\u2500".repeat(50));for(let s of i.recommendations.slice(0,5)){let d=s.impact==="high"?"\u26A1":s.impact==="medium"?"\uD83D\uDCCA":"\uD83D\uDCA1";e.push(` ${d} ${s.title}`),e.push(` ${s.description}`)}e.push("")}}if(t.warnings.length>0){e.push("Warnings"),e.push("\u2500".repeat(50));for(let i of t.warnings)e.push(` \u26A0\uFE0F ${i}`);e.push("")}return e.join(`
3
+ `)}function K(t,n){let e=[],o=n.showGzip!==!1;if(e.push("# Bundle Analysis Report"),e.push(""),e.push(`Generated: ${new Date(t.timestamp).toISOString()}`),e.push(""),e.push("## Summary"),e.push(""),e.push("| Metric | Value |"),e.push("|--------|-------|"),e.push(`| Total Size | ${l(t.totalSize)} |`),o)e.push(`| Gzip Size | ${l(t.totalGzipSize)} |`);e.push(`| Modules | ${t.moduleCount} |`),e.push(`| Chunks | ${t.chunks.length} |`),e.push(`| Duplicates | ${t.duplicates.length} |`),e.push(""),e.push("## Size by Type"),e.push(""),e.push("| Type | Size | Gzip | % | Files |"),e.push("|------|------|------|---|-------|");let a=["js","css","html","image","font","other"];for(let i of a){let s=t.byType[i];if(s.count>0)e.push(`| ${i} | ${l(s.size)} | ${l(s.gzipSize)} | ${S(s.size,t.totalSize)} | ${s.count} |`)}e.push(""),e.push("## Chunks"),e.push(""),e.push("| Name | Size | Gzip | Modules | Type |"),e.push("|------|------|------|---------|------|");for(let i of t.chunks.slice(0,15)){let s=i.isEntry?"Entry":i.isVendor?"Vendor":"-";e.push(`| ${i.name} | ${l(i.size)} | ${l(i.gzipSize)} | ${i.modules.length} | ${s} |`)}e.push("");let r=n.topModules||10;e.push(`## Largest Modules (Top ${r})`),e.push(""),e.push("| # | Path | Size | Gzip |"),e.push("|---|------|------|------|");for(let i=0;i<Math.min(r,t.largestModules.length);i++){let s=t.largestModules[i];e.push(`| ${i+1} | \`${s.path}\` | ${l(s.size)} | ${l(s.gzipSize)} |`)}if(e.push(""),t.duplicates.length>0){e.push("## Duplicates"),e.push(""),e.push("| Path | Copies | Wasted |"),e.push("|------|--------|--------|");for(let i of t.duplicates.slice(0,10))e.push(`| \`${i.path}\` | ${i.count} | ${l(i.wastedBytes)} |`);e.push("")}if(n.recommendations!==!1){let i=v(t,n);if(i.recommendations.length>0){e.push("## Recommendations"),e.push("");for(let s of i.recommendations)e.push(`### ${s.title}`),e.push(""),e.push(s.description),e.push(""),e.push(`- **Impact:** ${s.impact}`),e.push(`- **Effort:** ${s.effort}`),e.push("")}}return e.join(`
4
+ `)}function v(t,n){let e=[],o=[];if(n.threshold&&t.totalSize>n.threshold)e.push({severity:"error",message:`Bundle size (${l(t.totalSize)}) exceeds threshold (${l(n.threshold)})`});if(t.totalSize>1048576)e.push({severity:"warning",message:`Bundle is over 1MB (${l(t.totalSize)})`,details:"Large bundles can significantly impact load time"});if(t.duplicates.length>0){let s=t.duplicates.reduce((d,u)=>d+u.wastedBytes,0);e.push({severity:"warning",message:`${t.duplicates.length} duplicate modules found, wasting ${l(s)}`}),o.push({title:"Remove Duplicate Modules",description:"Consider using import aliases or ensuring consistent package versions to eliminate duplicates.",impact:"medium",effort:"low"})}if(t.byType.js.size/t.totalSize>0.8&&t.totalSize>512000)o.push({title:"Code Splitting",description:"Over 80% of your bundle is JavaScript. Consider splitting code by route or feature.",impact:"high",effort:"medium"});let r=t.largestModules.filter((s)=>s.size>102400);if(r.length>0){e.push({severity:"info",message:`${r.length} modules are over 100KB`});for(let s of r){if(s.path.includes("lodash")&&!s.path.includes("lodash-es"))o.push({title:"Use lodash-es instead of lodash",description:"lodash-es supports tree-shaking and can significantly reduce bundle size.",impact:"high",effort:"low"});if(s.path.includes("moment"))o.push({title:"Replace moment.js",description:"Consider using date-fns or dayjs for smaller date handling libraries.",impact:"high",effort:"medium"})}}if(t.byType.image.size>512000)o.push({title:"Optimize Images",description:`Images account for ${l(t.byType.image.size)}. Consider using WebP/AVIF formats and responsive images.`,impact:"high",effort:"low"});let i=100;if(t.totalSize>1048576)i-=20;else if(t.totalSize>512000)i-=10;if(i-=Math.min(20,t.duplicates.length*2),i-=Math.min(15,r.length*3),n.threshold&&t.totalSize>n.threshold)i-=25;return{score:Math.max(0,i),issues:e,recommendations:o}}var U={default:{js:"#f7df1e",css:"#264de4",html:"#e34c26",image:"#4caf50",font:"#9c27b0",other:"#607d8b",vendor:"#ff5722"},pastel:{js:"#fff3b0",css:"#b0d4ff",html:"#ffb0b0",image:"#b0ffb0",font:"#e0b0ff",other:"#d0d0d0",vendor:"#ffcfb0"},monochrome:{js:"#333333",css:"#555555",html:"#777777",image:"#999999",font:"#bbbbbb",other:"#dddddd",vendor:"#444444"}};function B(t,n={}){let{title:e="Bundle Analysis",gzip:o=!0,colorScheme:a="default"}=n,r=U[a],i=Y(t),s=JSON.stringify(i);return`<!DOCTYPE html>
5
+ <html lang="en">
6
+ <head>
7
+ <meta charset="UTF-8">
8
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
9
+ <title>${R(e)}</title>
10
+ <style>
11
+ * {
12
+ box-sizing: border-box;
13
+ margin: 0;
14
+ padding: 0;
15
+ }
16
+
17
+ body {
18
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
19
+ background: #1a1a2e;
20
+ color: #eee;
21
+ min-height: 100vh;
22
+ }
23
+
24
+ .header {
25
+ background: #16213e;
26
+ padding: 1rem 2rem;
27
+ display: flex;
28
+ justify-content: space-between;
29
+ align-items: center;
30
+ border-bottom: 1px solid #0f3460;
31
+ }
32
+
33
+ .header h1 {
34
+ font-size: 1.5rem;
35
+ font-weight: 500;
36
+ }
37
+
38
+ .stats {
39
+ display: flex;
40
+ gap: 2rem;
41
+ }
42
+
43
+ .stat {
44
+ text-align: center;
45
+ }
46
+
47
+ .stat-value {
48
+ font-size: 1.25rem;
49
+ font-weight: bold;
50
+ color: #e94560;
51
+ }
52
+
53
+ .stat-label {
54
+ font-size: 0.75rem;
55
+ color: #888;
56
+ text-transform: uppercase;
57
+ }
58
+
59
+ .controls {
60
+ background: #16213e;
61
+ padding: 0.75rem 2rem;
62
+ display: flex;
63
+ gap: 1rem;
64
+ align-items: center;
65
+ border-bottom: 1px solid #0f3460;
66
+ }
67
+
68
+ .controls label {
69
+ display: flex;
70
+ align-items: center;
71
+ gap: 0.5rem;
72
+ cursor: pointer;
73
+ }
74
+
75
+ .controls input[type="checkbox"] {
76
+ width: 1rem;
77
+ height: 1rem;
78
+ }
79
+
80
+ .search-box {
81
+ flex: 1;
82
+ max-width: 300px;
83
+ }
84
+
85
+ .search-box input {
86
+ width: 100%;
87
+ padding: 0.5rem 1rem;
88
+ border: 1px solid #0f3460;
89
+ border-radius: 4px;
90
+ background: #1a1a2e;
91
+ color: #eee;
92
+ font-size: 0.875rem;
93
+ }
94
+
95
+ .search-box input:focus {
96
+ outline: none;
97
+ border-color: #e94560;
98
+ }
99
+
100
+ .breadcrumb {
101
+ background: #16213e;
102
+ padding: 0.5rem 2rem;
103
+ display: flex;
104
+ gap: 0.5rem;
105
+ align-items: center;
106
+ font-size: 0.875rem;
107
+ border-bottom: 1px solid #0f3460;
108
+ }
109
+
110
+ .breadcrumb-item {
111
+ color: #888;
112
+ cursor: pointer;
113
+ }
114
+
115
+ .breadcrumb-item:hover {
116
+ color: #e94560;
117
+ }
118
+
119
+ .breadcrumb-item.active {
120
+ color: #eee;
121
+ cursor: default;
122
+ }
123
+
124
+ .breadcrumb-sep {
125
+ color: #444;
126
+ }
127
+
128
+ #treemap {
129
+ width: 100%;
130
+ height: calc(100vh - 180px);
131
+ min-height: 400px;
132
+ }
133
+
134
+ .tooltip {
135
+ position: fixed;
136
+ background: #16213e;
137
+ border: 1px solid #0f3460;
138
+ border-radius: 4px;
139
+ padding: 0.75rem 1rem;
140
+ pointer-events: none;
141
+ z-index: 1000;
142
+ max-width: 400px;
143
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
144
+ }
145
+
146
+ .tooltip-title {
147
+ font-weight: bold;
148
+ margin-bottom: 0.5rem;
149
+ word-break: break-all;
150
+ }
151
+
152
+ .tooltip-row {
153
+ display: flex;
154
+ justify-content: space-between;
155
+ gap: 2rem;
156
+ font-size: 0.875rem;
157
+ color: #888;
158
+ }
159
+
160
+ .tooltip-row span:last-child {
161
+ color: #eee;
162
+ font-weight: 500;
163
+ }
164
+
165
+ .legend {
166
+ position: fixed;
167
+ bottom: 1rem;
168
+ right: 1rem;
169
+ background: #16213e;
170
+ border: 1px solid #0f3460;
171
+ border-radius: 4px;
172
+ padding: 0.75rem 1rem;
173
+ }
174
+
175
+ .legend-title {
176
+ font-size: 0.75rem;
177
+ color: #888;
178
+ margin-bottom: 0.5rem;
179
+ text-transform: uppercase;
180
+ }
181
+
182
+ .legend-item {
183
+ display: flex;
184
+ align-items: center;
185
+ gap: 0.5rem;
186
+ font-size: 0.75rem;
187
+ margin-bottom: 0.25rem;
188
+ }
189
+
190
+ .legend-color {
191
+ width: 12px;
192
+ height: 12px;
193
+ border-radius: 2px;
194
+ }
195
+
196
+ .node {
197
+ cursor: pointer;
198
+ transition: opacity 0.2s;
199
+ }
200
+
201
+ .node:hover {
202
+ opacity: 0.8;
203
+ }
204
+
205
+ .node-label {
206
+ font-size: 11px;
207
+ fill: #000;
208
+ pointer-events: none;
209
+ text-anchor: middle;
210
+ }
211
+ </style>
212
+ </head>
213
+ <body>
214
+ <div class="header">
215
+ <h1>${R(e)}</h1>
216
+ <div class="stats">
217
+ <div class="stat">
218
+ <div class="stat-value" id="total-size">${l(t.totalSize)}</div>
219
+ <div class="stat-label">Total Size</div>
220
+ </div>
221
+ <div class="stat">
222
+ <div class="stat-value" id="gzip-size">${l(t.totalGzipSize)}</div>
223
+ <div class="stat-label">Gzip Size</div>
224
+ </div>
225
+ <div class="stat">
226
+ <div class="stat-value">${t.moduleCount}</div>
227
+ <div class="stat-label">Modules</div>
228
+ </div>
229
+ <div class="stat">
230
+ <div class="stat-value">${t.chunks.length}</div>
231
+ <div class="stat-label">Chunks</div>
232
+ </div>
233
+ </div>
234
+ </div>
235
+
236
+ <div class="controls">
237
+ <div class="search-box">
238
+ <input type="text" id="search" placeholder="Search modules...">
239
+ </div>
240
+ <label>
241
+ <input type="checkbox" id="show-gzip" ${o?"checked":""}>
242
+ Show Gzip Size
243
+ </label>
244
+ </div>
245
+
246
+ <div class="breadcrumb" id="breadcrumb">
247
+ <span class="breadcrumb-item active">root</span>
248
+ </div>
249
+
250
+ <div id="treemap"></div>
251
+
252
+ <div class="tooltip" id="tooltip" style="display: none;"></div>
253
+
254
+ <div class="legend">
255
+ <div class="legend-title">File Types</div>
256
+ <div class="legend-item">
257
+ <div class="legend-color" style="background: ${r.js}"></div>
258
+ <span>JavaScript</span>
259
+ </div>
260
+ <div class="legend-item">
261
+ <div class="legend-color" style="background: ${r.css}"></div>
262
+ <span>CSS</span>
263
+ </div>
264
+ <div class="legend-item">
265
+ <div class="legend-color" style="background: ${r.html}"></div>
266
+ <span>HTML</span>
267
+ </div>
268
+ <div class="legend-item">
269
+ <div class="legend-color" style="background: ${r.image}"></div>
270
+ <span>Images</span>
271
+ </div>
272
+ <div class="legend-item">
273
+ <div class="legend-color" style="background: ${r.font}"></div>
274
+ <span>Fonts</span>
275
+ </div>
276
+ <div class="legend-item">
277
+ <div class="legend-color" style="background: ${r.other}"></div>
278
+ <span>Other</span>
279
+ </div>
280
+ </div>
281
+
282
+ <script src="https://d3js.org/d3.v7.min.js"></script>
283
+ <script>
284
+ const data = ${s};
285
+ const colors = ${JSON.stringify(r)};
286
+
287
+ let showGzip = ${o};
288
+ let currentRoot = data;
289
+ let searchTerm = '';
290
+
291
+ const container = document.getElementById('treemap');
292
+ const tooltip = document.getElementById('tooltip');
293
+ const breadcrumb = document.getElementById('breadcrumb');
294
+ const searchInput = document.getElementById('search');
295
+ const showGzipCheckbox = document.getElementById('show-gzip');
296
+
297
+ function formatSize(bytes) {
298
+ if (bytes < 1024) return bytes + ' B';
299
+ if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(2) + ' KB';
300
+ return (bytes / (1024 * 1024)).toFixed(2) + ' MB';
301
+ }
302
+
303
+ function getColor(d) {
304
+ if (d.data.type) {
305
+ return colors[d.data.type] || colors.other;
306
+ }
307
+ if (d.data.name.includes('node_modules') || d.data.name.includes('vendor')) {
308
+ return colors.vendor;
309
+ }
310
+ return colors.other;
311
+ }
312
+
313
+ function getSizeValue(d) {
314
+ return showGzip ? d.data.gzipSize : d.data.size;
315
+ }
316
+
317
+ function render() {
318
+ container.innerHTML = '';
319
+
320
+ const width = container.clientWidth;
321
+ const height = container.clientHeight;
322
+
323
+ const hierarchy = d3.hierarchy(currentRoot)
324
+ .sum(d => {
325
+ if (searchTerm && d.name && !d.name.toLowerCase().includes(searchTerm.toLowerCase())) {
326
+ return 0;
327
+ }
328
+ return d.children ? 0 : getSizeValue({ data: d });
329
+ })
330
+ .sort((a, b) => getSizeValue(b) - getSizeValue(a));
331
+
332
+ const treemap = d3.treemap()
333
+ .size([width, height])
334
+ .paddingOuter(3)
335
+ .paddingTop(19)
336
+ .paddingInner(1)
337
+ .round(true);
338
+
339
+ const root = treemap(hierarchy);
340
+
341
+ const svg = d3.select(container)
342
+ .append('svg')
343
+ .attr('width', width)
344
+ .attr('height', height);
345
+
346
+ const node = svg.selectAll('g')
347
+ .data(root.descendants().filter(d => d.depth > 0))
348
+ .join('g')
349
+ .attr('transform', d => \`translate(\${d.x0},\${d.y0})\`);
350
+
351
+ node.append('rect')
352
+ .attr('class', 'node')
353
+ .attr('width', d => Math.max(0, d.x1 - d.x0))
354
+ .attr('height', d => Math.max(0, d.y1 - d.y0))
355
+ .attr('fill', d => getColor(d))
356
+ .attr('stroke', '#1a1a2e')
357
+ .attr('stroke-width', 1)
358
+ .on('click', (event, d) => {
359
+ if (d.children) {
360
+ zoomIn(d.data);
361
+ }
362
+ })
363
+ .on('mouseover', (event, d) => showTooltip(event, d))
364
+ .on('mousemove', (event) => moveTooltip(event))
365
+ .on('mouseout', hideTooltip);
366
+
367
+ node.append('text')
368
+ .attr('class', 'node-label')
369
+ .attr('x', d => (d.x1 - d.x0) / 2)
370
+ .attr('y', d => (d.y1 - d.y0) / 2 + 4)
371
+ .text(d => {
372
+ const width = d.x1 - d.x0;
373
+ const height = d.y1 - d.y0;
374
+ if (width < 40 || height < 20) return '';
375
+ const name = d.data.name;
376
+ const maxLen = Math.floor(width / 7);
377
+ return name.length > maxLen ? name.slice(0, maxLen - 2) + '..' : name;
378
+ });
379
+
380
+ // Group headers
381
+ node.filter(d => d.children)
382
+ .append('text')
383
+ .attr('x', 4)
384
+ .attr('y', 14)
385
+ .attr('fill', '#000')
386
+ .attr('font-size', '12px')
387
+ .attr('font-weight', 'bold')
388
+ .text(d => {
389
+ const width = d.x1 - d.x0;
390
+ const name = d.data.name;
391
+ const maxLen = Math.floor(width / 7);
392
+ return name.length > maxLen ? name.slice(0, maxLen - 2) + '..' : name;
393
+ });
394
+ }
395
+
396
+ function showTooltip(event, d) {
397
+ const size = d.data.size || d.value;
398
+ const gzipSize = d.data.gzipSize || Math.round(size * 0.3);
399
+ const path = d.data.path || d.data.name;
400
+
401
+ tooltip.innerHTML = \`
402
+ <div class="tooltip-title">\${path}</div>
403
+ <div class="tooltip-row">
404
+ <span>Size</span>
405
+ <span>\${formatSize(size)}</span>
406
+ </div>
407
+ <div class="tooltip-row">
408
+ <span>Gzip</span>
409
+ <span>\${formatSize(gzipSize)}</span>
410
+ </div>
411
+ \${d.data.type ? \`<div class="tooltip-row"><span>Type</span><span>\${d.data.type}</span></div>\` : ''}
412
+ \${d.children ? \`<div class="tooltip-row"><span>Children</span><span>\${d.children.length}</span></div>\` : ''}
413
+ \`;
414
+ tooltip.style.display = 'block';
415
+ moveTooltip(event);
416
+ }
417
+
418
+ function moveTooltip(event) {
419
+ const x = event.clientX + 10;
420
+ const y = event.clientY + 10;
421
+ tooltip.style.left = x + 'px';
422
+ tooltip.style.top = y + 'px';
423
+ }
424
+
425
+ function hideTooltip() {
426
+ tooltip.style.display = 'none';
427
+ }
428
+
429
+ function zoomIn(node) {
430
+ currentRoot = node;
431
+ updateBreadcrumb();
432
+ render();
433
+ }
434
+
435
+ function zoomOut(index) {
436
+ let node = data;
437
+ const parts = getBreadcrumbParts();
438
+ for (let i = 1; i <= index; i++) {
439
+ const child = node.children?.find(c => c.name === parts[i]);
440
+ if (child) node = child;
441
+ }
442
+ currentRoot = node;
443
+ updateBreadcrumb();
444
+ render();
445
+ }
446
+
447
+ function getBreadcrumbParts() {
448
+ const parts = ['root'];
449
+ let node = currentRoot;
450
+ const path = [];
451
+
452
+ function findPath(current, target, currentPath) {
453
+ if (current === target) {
454
+ path.push(...currentPath);
455
+ return true;
456
+ }
457
+ if (current.children) {
458
+ for (const child of current.children) {
459
+ if (findPath(child, target, [...currentPath, child.name])) {
460
+ return true;
461
+ }
462
+ }
463
+ }
464
+ return false;
465
+ }
466
+
467
+ if (currentRoot !== data) {
468
+ findPath(data, currentRoot, []);
469
+ parts.push(...path);
470
+ }
471
+
472
+ return parts;
473
+ }
474
+
475
+ function updateBreadcrumb() {
476
+ const parts = getBreadcrumbParts();
477
+ breadcrumb.innerHTML = parts.map((part, i) => {
478
+ const isLast = i === parts.length - 1;
479
+ const sep = i > 0 ? '<span class="breadcrumb-sep">/</span>' : '';
480
+ return \`\${sep}<span class="breadcrumb-item \${isLast ? 'active' : ''}" onclick="zoomOut(\${i})">\${part}</span>\`;
481
+ }).join('');
482
+ }
483
+
484
+ searchInput.addEventListener('input', (e) => {
485
+ searchTerm = e.target.value;
486
+ render();
487
+ });
488
+
489
+ showGzipCheckbox.addEventListener('change', (e) => {
490
+ showGzip = e.target.checked;
491
+ render();
492
+ });
493
+
494
+ window.addEventListener('resize', render);
495
+
496
+ render();
497
+ </script>
498
+ </body>
499
+ </html>`}function Y(t){let n={name:"root",size:t.totalSize,gzipSize:t.totalGzipSize,children:[]};for(let e of t.chunks){let o={name:e.name,size:e.size,gzipSize:e.gzipSize,children:[]};for(let a of e.modules)q(o,a);n.children.push(o)}return n}function q(t,n){let e=n.path.split("/"),o=t;for(let r=0;r<e.length-1;r++){let i=e[r],s=o.children?.find((d)=>d.name===i);if(!s){if(s={name:i,size:0,gzipSize:0,children:[]},!o.children)o.children=[];o.children.push(s)}o=s}let a=e[e.length-1];if(!o.children)o.children=[];o.children.push({name:a,path:n.path,size:n.size,gzipSize:n.gzipSize,type:n.type}),X(t,n.size,n.gzipSize)}function X(t,n,e){}function R(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function k(t){let n=process.platform,e=n==="darwin"?"open":n==="win32"?"start":"xdg-open";Bun.spawn([e,t],{stdio:["ignore","ignore","ignore"]})}import j from"fs";import C from"path";async function ge(t={}){let{directory:n="dist",output:e,format:o="html",open:a=!0,gzip:r=!0,threshold:i,recommendations:s=!0,topModules:d=20,parseImports:u=!0}=t,p=await w(n,{parseImports:u,detectDuplicates:!0,topModulesCount:d}),y=i?typeof i==="string"?M(i):i:void 0,x=y?p.totalSize>y:!1,f,g;if(o==="html"){let h={title:`Bundle Analysis - ${C.basename(C.resolve(n))}`,gzip:r};if(f=B(p,h),g=e||C.join(n,"bundle-report.html"),await j.promises.writeFile(g,f),a)k(g)}else if(f=T(p,{format:o,threshold:y,recommendations:s,topModules:d,showGzip:r}),e)g=e,await j.promises.writeFile(g,f);return{stats:p,report:f,outputPath:g,exceedsThreshold:x}}export{ge as analyze,l as formatBytes};