@stacksjs/stx 0.2.413 → 0.2.414

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 (345) hide show
  1. package/dist/appearance-bootstrap.js +1 -1
  2. package/dist/binding-manifest.d.ts +1 -1
  3. package/dist/bundle-analyzer.js +20 -20
  4. package/dist/chunk-020xyn9q.js +3 -0
  5. package/dist/chunk-04jhmfbz.js +2 -0
  6. package/dist/chunk-10957mcb.js +2 -0
  7. package/dist/chunk-1098mas0.js +2 -0
  8. package/dist/chunk-169n1vpx.js +12 -0
  9. package/dist/chunk-1b6t12hd.js +2 -0
  10. package/dist/chunk-1chw8xsw.js +2 -0
  11. package/dist/chunk-1xdzcy9d.js +14 -0
  12. package/dist/chunk-2ce7f416.js +2 -0
  13. package/dist/chunk-2gr351s0.js +7 -0
  14. package/dist/chunk-2mkcjw08.js +2 -0
  15. package/dist/chunk-2v8wztd5.js +2 -0
  16. package/dist/chunk-340a824p.js +2 -0
  17. package/dist/chunk-39g1134q.js +2 -0
  18. package/dist/chunk-3c74vag1.js +2 -0
  19. package/dist/chunk-3kthfs03.js +3 -0
  20. package/dist/chunk-3qn1wcdg.js +2 -0
  21. package/dist/chunk-3s2vnqcf.js +2 -0
  22. package/dist/chunk-48bwk47q.js +2 -0
  23. package/dist/chunk-4bjravgk.js +2 -0
  24. package/dist/chunk-4jjme6a5.js +2 -0
  25. package/dist/chunk-5g3y8kym.js +2 -0
  26. package/dist/chunk-5gsxpaqk.js +2 -0
  27. package/dist/{chunk-bwsxym3d.js → chunk-5qns2sdz.js} +17 -17
  28. package/dist/chunk-69mc2np8.js +2785 -0
  29. package/dist/chunk-6cfa3g0r.js +2 -0
  30. package/dist/{chunk-bjar18jd.js → chunk-6h38kkjf.js} +46 -52
  31. package/dist/chunk-6hc5vz20.js +3 -0
  32. package/dist/chunk-6q6g76vg.js +499 -0
  33. package/dist/{chunk-bwjxk1dw.js → chunk-6sgswrqw.js} +29 -29
  34. package/dist/chunk-6y8hnymb.js +2 -0
  35. package/dist/chunk-74j18qk0.js +930 -0
  36. package/dist/chunk-752hw7cd.js +4 -0
  37. package/dist/{chunk-kgd8kchy.js → chunk-765e1s44.js} +11 -76
  38. package/dist/chunk-7gkv67ky.js +4 -0
  39. package/dist/chunk-7z2ra0yf.js +2 -0
  40. package/dist/chunk-866n724v.js +2 -0
  41. package/dist/chunk-8nhshfz6.js +5 -0
  42. package/dist/chunk-92ps1xpk.js +2 -0
  43. package/dist/chunk-9g27ybyr.js +3 -0
  44. package/dist/{chunk-xq1acw1r.js → chunk-9pt8fd2n.js} +13 -13
  45. package/dist/{chunk-24zher49.js → chunk-9vrja6vp.js} +4 -4
  46. package/dist/chunk-9xrbve19.js +2 -0
  47. package/dist/chunk-a688m6js.js +3 -0
  48. package/dist/chunk-afhxw2t8.js +2 -0
  49. package/dist/chunk-ak1cgcah.js +5 -0
  50. package/dist/{chunk-4m7ajama.js → chunk-amd6ey3t.js} +14 -14
  51. package/dist/chunk-apg16xcn.js +2 -0
  52. package/dist/chunk-b52s5z0c.js +2 -0
  53. package/dist/chunk-b84h16er.js +61 -0
  54. package/dist/{chunk-hx998w7n.js → chunk-bay9s6rs.js} +13 -13
  55. package/dist/chunk-bmt7w2pk.js +2 -0
  56. package/dist/chunk-btmhj5t7.js +2 -0
  57. package/dist/chunk-ce1sejr3.js +3 -0
  58. package/dist/chunk-cg8hg6cs.js +3 -0
  59. package/dist/{chunk-4f9zyfdw.js → chunk-czxt605c.js} +4 -5
  60. package/dist/chunk-d44b9ktb.js +4 -0
  61. package/dist/chunk-daz5aqcf.js +24 -0
  62. package/dist/chunk-dgdm3hy3.js +2 -0
  63. package/dist/chunk-dvgv8nry.js +11 -0
  64. package/dist/chunk-dx7n22ed.js +2 -0
  65. package/dist/chunk-e57rhf65.js +3 -0
  66. package/dist/chunk-eed4fwps.js +3 -0
  67. package/dist/chunk-ej9j6k1q.js +3 -0
  68. package/dist/chunk-et0rr8c7.js +3 -0
  69. package/dist/chunk-f46qsp4m.js +4 -0
  70. package/dist/chunk-f6az0xj5.js +2 -0
  71. package/dist/{chunk-bjcsc6wx.js → chunk-fh1qrp68.js} +21 -21
  72. package/dist/chunk-fjs0a8h7.js +2 -0
  73. package/dist/chunk-fr2txj8q.js +829 -0
  74. package/dist/{chunk-xssw417m.js → chunk-ft4p6d28.js} +14 -14
  75. package/dist/chunk-fyzajkrx.js +2 -0
  76. package/dist/chunk-fzapbw9p.js +3 -0
  77. package/dist/chunk-g578mcb0.js +194 -0
  78. package/dist/chunk-gawrg4gb.js +216 -0
  79. package/dist/chunk-gw07qmjk.js +2 -0
  80. package/dist/chunk-h0atqq82.js +32 -0
  81. package/dist/chunk-h6zsqb9r.js +3 -0
  82. package/dist/{chunk-2snqdnk9.js → chunk-h85hrwkq.js} +13 -13
  83. package/dist/chunk-hbxz85wy.js +2 -0
  84. package/dist/chunk-hjg3ndgh.js +2 -0
  85. package/dist/chunk-hkxsewzk.js +2 -0
  86. package/dist/chunk-hrbbbtbn.js +2 -0
  87. package/dist/chunk-j03revz2.js +8 -0
  88. package/dist/chunk-j9qcrwbg.js +2 -0
  89. package/dist/chunk-jk4njz0w.js +2 -0
  90. package/dist/chunk-jmabeqfq.js +2 -0
  91. package/dist/chunk-jt0n43mk.js +2 -0
  92. package/dist/chunk-kjbv8a3m.js +2 -0
  93. package/dist/chunk-m1vdghnx.js +2 -0
  94. package/dist/chunk-m4sk62wb.js +5 -0
  95. package/dist/chunk-md8rqn48.js +30 -0
  96. package/dist/chunk-mepdnezf.js +17 -0
  97. package/dist/chunk-mhq0pjws.js +2 -0
  98. package/dist/chunk-mp6hy8g4.js +2 -0
  99. package/dist/chunk-ngc2wke4.js +3 -0
  100. package/dist/chunk-nn2vstke.js +2 -0
  101. package/dist/chunk-p2v2a68k.js +2 -0
  102. package/dist/{chunk-qn5srnj3.js → chunk-pbh4smw3.js} +16 -16
  103. package/dist/chunk-pdt69hpb.js +2 -0
  104. package/dist/chunk-pgzvyrv6.js +29 -0
  105. package/dist/chunk-pj1wg7jg.js +2 -0
  106. package/dist/chunk-pqxzp1bb.js +3 -0
  107. package/dist/chunk-px7fvbj6.js +3 -0
  108. package/dist/chunk-q4c06e8x.js +20 -0
  109. package/dist/chunk-q6vrb2pe.js +2 -0
  110. package/dist/chunk-q7qchkvk.js +2 -0
  111. package/dist/chunk-q9bdh4s5.js +8 -0
  112. package/dist/chunk-qet5gc6s.js +2033 -0
  113. package/dist/chunk-qz519eyp.js +2 -0
  114. package/dist/chunk-r3f9jcf7.js +5 -0
  115. package/dist/chunk-rs4v4fha.js +4 -0
  116. package/dist/chunk-s2x4wcrz.js +2 -0
  117. package/dist/chunk-s5xezjps.js +3 -0
  118. package/dist/chunk-scezfp0w.js +30 -0
  119. package/dist/chunk-sd321bn3.js +2 -0
  120. package/dist/{chunk-smcj3442.js → chunk-sd47dzs0.js} +79 -79
  121. package/dist/chunk-se7mwqd1.js +2 -0
  122. package/dist/chunk-shr559s7.js +3 -0
  123. package/dist/chunk-syaw6b75.js +2 -0
  124. package/dist/chunk-t4hzprsm.js +3 -0
  125. package/dist/{chunk-pv3d7sfn.js → chunk-t61vdbje.js} +89 -89
  126. package/dist/chunk-tfexmdkt.js +3 -0
  127. package/dist/chunk-thyt8ed8.js +6 -0
  128. package/dist/chunk-v091jft4.js +12 -0
  129. package/dist/chunk-v4vaqxrf.js +33 -0
  130. package/dist/chunk-vgvtnwxa.js +4 -0
  131. package/dist/chunk-x0q32ees.js +3 -0
  132. package/dist/chunk-x5bpeb4a.js +2 -0
  133. package/dist/chunk-x72tv2cg.js +3 -0
  134. package/dist/chunk-xfp7k0v8.js +64 -0
  135. package/dist/chunk-xtdw3692.js +6 -0
  136. package/dist/chunk-y1cmjvk3.js +43 -0
  137. package/dist/chunk-y5310237.js +311 -0
  138. package/dist/chunk-ya0qecph.js +27 -0
  139. package/dist/chunk-yazk54jr.js +8 -0
  140. package/dist/chunk-ydjfar14.js +2 -0
  141. package/dist/chunk-ym95v4nc.js +3 -0
  142. package/dist/chunk-ynvdvbat.js +18 -0
  143. package/dist/chunk-yvx1ap9b.js +3 -0
  144. package/dist/chunk-z0g9jvv0.js +40 -0
  145. package/dist/chunk-z6d0jmjb.js +2 -0
  146. package/dist/{chunk-8sdhs0zk.js → chunk-zhxdpzga.js} +4 -4
  147. package/dist/cli.js +110 -110
  148. package/dist/craft-entry.js +7 -7
  149. package/dist/craft.js +7 -7
  150. package/dist/database.js +2 -2
  151. package/dist/image-optimization/component.js +4 -4
  152. package/dist/media/image/component.js +5 -5
  153. package/dist/media/protected/component.js +2 -2
  154. package/dist/media/video/index.js +4 -4
  155. package/dist/native/bridge/protocol.d.ts +325 -0
  156. package/dist/native/bridge/protocol.js +219 -0
  157. package/dist/native/cli.d.ts +24 -0
  158. package/dist/native/cli.js +52 -0
  159. package/dist/native/compiler/bundle.d.ts +41 -0
  160. package/dist/native/compiler/bundle.js +90 -0
  161. package/dist/native/compiler/client-script.d.ts +8 -0
  162. package/dist/native/compiler/client-script.js +31 -0
  163. package/dist/native/compiler/codegen.d.ts +10 -0
  164. package/dist/native/compiler/codegen.js +145 -0
  165. package/dist/native/compiler/headwind-to-style.d.ts +395 -0
  166. package/dist/native/compiler/headwind-to-style.js +1163 -0
  167. package/dist/native/compiler/html-to-ir.d.ts +41 -0
  168. package/dist/native/compiler/html-to-ir.js +411 -0
  169. package/dist/native/compiler/icons.d.ts +220 -0
  170. package/dist/native/compiler/icons.js +208 -0
  171. package/dist/native/compiler/ir.d.ts +234 -0
  172. package/dist/native/compiler/ir.js +15 -0
  173. package/dist/native/compiler/parser.d.ts +88 -0
  174. package/dist/native/compiler/parser.js +753 -0
  175. package/dist/native/compiler/render-screen.d.ts +26 -0
  176. package/dist/native/compiler/render-screen.js +31 -0
  177. package/dist/native/components/primitives.d.ts +291 -0
  178. package/dist/native/components/primitives.js +22 -0
  179. package/dist/native/hot-reload/client.d.ts +62 -0
  180. package/dist/native/hot-reload/client.js +324 -0
  181. package/dist/native/index.d.ts +90 -0
  182. package/dist/native/index.js +34 -0
  183. package/dist/native/primitives/ActivityIndicator.stx +5 -0
  184. package/dist/native/primitives/Button.stx +5 -0
  185. package/dist/native/primitives/DatePicker.stx +5 -0
  186. package/dist/native/primitives/FlatList.stx +5 -0
  187. package/dist/native/primitives/Image.stx +5 -0
  188. package/dist/native/primitives/ImageBackground.stx +5 -0
  189. package/dist/native/primitives/KeyboardAvoidingView.stx +5 -0
  190. package/dist/native/primitives/Modal.stx +5 -0
  191. package/dist/native/primitives/Picker.stx +5 -0
  192. package/dist/native/primitives/Pressable.stx +5 -0
  193. package/dist/native/primitives/RefreshControl.stx +5 -0
  194. package/dist/native/primitives/SafeAreaView.stx +5 -0
  195. package/dist/native/primitives/ScrollView.stx +5 -0
  196. package/dist/native/primitives/SectionList.stx +5 -0
  197. package/dist/native/primitives/Slider.stx +5 -0
  198. package/dist/native/primitives/StatusBar.stx +5 -0
  199. package/dist/native/primitives/Switch.stx +5 -0
  200. package/dist/native/primitives/Text.stx +5 -0
  201. package/dist/native/primitives/TextInput.stx +5 -0
  202. package/dist/native/primitives/TouchableHighlight.stx +5 -0
  203. package/dist/native/primitives/TouchableOpacity.stx +5 -0
  204. package/dist/native/primitives/View.stx +5 -0
  205. package/dist/native/runtime/craft.d.ts +75 -0
  206. package/dist/native/runtime/craft.js +0 -0
  207. package/dist/native/runtime/entry.d.ts +1 -0
  208. package/dist/native/runtime/entry.js +3 -0
  209. package/dist/native/runtime/index.d.ts +45 -0
  210. package/dist/native/runtime/index.js +165 -0
  211. package/dist/native/runtime/native-host.d.ts +33 -0
  212. package/dist/native/runtime/native-host.js +184 -0
  213. package/dist/native/runtime/screen.d.ts +43 -0
  214. package/dist/native/runtime/screen.js +808 -0
  215. package/dist/pwa/service-worker.js +1 -1
  216. package/dist/pwa/workbox.js +1 -1
  217. package/dist/pwa.js +8 -8
  218. package/dist/site-url.d.ts +1 -1
  219. package/dist/ssg.js +53 -53
  220. package/dist/visual-testing.js +42 -42
  221. package/dist/web-components/reactive-generator.js +2 -2
  222. package/package.json +9 -5
  223. package/dist/chunk-0btmm4m2.js +0 -147
  224. package/dist/chunk-0c2h69k2.js +0 -4
  225. package/dist/chunk-0d0qeqvv.js +0 -2
  226. package/dist/chunk-0psndabd.js +0 -2
  227. package/dist/chunk-0qv8yf53.js +0 -2
  228. package/dist/chunk-0vkxyvsd.js +0 -2
  229. package/dist/chunk-0we9nw1d.js +0 -3
  230. package/dist/chunk-0xqdmemy.js +0 -3
  231. package/dist/chunk-0y46fbkx.js +0 -3
  232. package/dist/chunk-158wqccn.js +0 -4422
  233. package/dist/chunk-1cyxbb8y.js +0 -16
  234. package/dist/chunk-1enwnh2a.js +0 -2
  235. package/dist/chunk-213pzm0d.js +0 -3
  236. package/dist/chunk-21hzqyja.js +0 -12
  237. package/dist/chunk-266t58b8.js +0 -5
  238. package/dist/chunk-27fgag95.js +0 -4
  239. package/dist/chunk-2a9n102n.js +0 -2
  240. package/dist/chunk-2eqzrczk.js +0 -2
  241. package/dist/chunk-2ke37m54.js +0 -14
  242. package/dist/chunk-35ds08e7.js +0 -3
  243. package/dist/chunk-3mtwkjcg.js +0 -2
  244. package/dist/chunk-4xr8zwkp.js +0 -2
  245. package/dist/chunk-58v77x2c.js +0 -2
  246. package/dist/chunk-5mhq8605.js +0 -2
  247. package/dist/chunk-5se8xt9e.js +0 -64
  248. package/dist/chunk-5zh0h080.js +0 -2
  249. package/dist/chunk-62435225.js +0 -2
  250. package/dist/chunk-6kdrncsx.js +0 -30
  251. package/dist/chunk-6n2rr3x7.js +0 -2
  252. package/dist/chunk-6xk87qf2.js +0 -30
  253. package/dist/chunk-72rwcbp6.js +0 -3
  254. package/dist/chunk-76w34xne.js +0 -3
  255. package/dist/chunk-7ekd7zj9.js +0 -2
  256. package/dist/chunk-7pr3wdd5.js +0 -3
  257. package/dist/chunk-7rxvafwc.js +0 -24
  258. package/dist/chunk-7tnwfa7w.js +0 -8
  259. package/dist/chunk-8c5je0wf.js +0 -2
  260. package/dist/chunk-8dz6nyvx.js +0 -2
  261. package/dist/chunk-98zj3fv2.js +0 -7
  262. package/dist/chunk-9e8t0twa.js +0 -3
  263. package/dist/chunk-9fqp72ze.js +0 -5
  264. package/dist/chunk-anydpa34.js +0 -3
  265. package/dist/chunk-ay6zjq8v.js +0 -3
  266. package/dist/chunk-az4v4ard.js +0 -3
  267. package/dist/chunk-ba5erggg.js +0 -2
  268. package/dist/chunk-bnagrdz6.js +0 -2
  269. package/dist/chunk-by8wghtf.js +0 -2
  270. package/dist/chunk-cd7h4q51.js +0 -2
  271. package/dist/chunk-cjmv8hgp.js +0 -33
  272. package/dist/chunk-cthf912y.js +0 -2
  273. package/dist/chunk-cxbpmwq5.js +0 -4
  274. package/dist/chunk-d3sy16qn.js +0 -2
  275. package/dist/chunk-dh6s7mrj.js +0 -1199
  276. package/dist/chunk-dm2nzg7a.js +0 -2
  277. package/dist/chunk-e2sgcnxc.js +0 -2
  278. package/dist/chunk-e3b7jj74.js +0 -2
  279. package/dist/chunk-ec4wq2sv.js +0 -6
  280. package/dist/chunk-ekzg97dn.js +0 -29
  281. package/dist/chunk-epjt342x.js +0 -2
  282. package/dist/chunk-eqe26g14.js +0 -18
  283. package/dist/chunk-ev0v1yma.js +0 -2
  284. package/dist/chunk-f53psr2y.js +0 -5
  285. package/dist/chunk-f8p69dsg.js +0 -3
  286. package/dist/chunk-f95drhdb.js +0 -194
  287. package/dist/chunk-ff5a6hvb.js +0 -17
  288. package/dist/chunk-fs5fy4h8.js +0 -2
  289. package/dist/chunk-fzsygce3.js +0 -2
  290. package/dist/chunk-g465x63k.js +0 -2
  291. package/dist/chunk-g708ekh1.js +0 -2
  292. package/dist/chunk-gcr9e83g.js +0 -11
  293. package/dist/chunk-gdmyrsr8.js +0 -4
  294. package/dist/chunk-gkms2ngq.js +0 -2
  295. package/dist/chunk-gnfywmgs.js +0 -7
  296. package/dist/chunk-hpf8kq7e.js +0 -2
  297. package/dist/chunk-j4x3faf8.js +0 -2
  298. package/dist/chunk-jkavtw9f.js +0 -2
  299. package/dist/chunk-kg1rdena.js +0 -3
  300. package/dist/chunk-km91wx0v.js +0 -2
  301. package/dist/chunk-kmsyvaex.js +0 -8
  302. package/dist/chunk-mrahwn5v.js +0 -8
  303. package/dist/chunk-nk3czvnk.js +0 -2
  304. package/dist/chunk-nmw4eewb.js +0 -2
  305. package/dist/chunk-nq5zxrk0.js +0 -4
  306. package/dist/chunk-ny67c03k.js +0 -3
  307. package/dist/chunk-p4wdxp2c.js +0 -2
  308. package/dist/chunk-pcxp4r9n.js +0 -3
  309. package/dist/chunk-pdyeaxc1.js +0 -2
  310. package/dist/chunk-pf06ded4.js +0 -2
  311. package/dist/chunk-pfs0gpzm.js +0 -2
  312. package/dist/chunk-pshdwq44.js +0 -2
  313. package/dist/chunk-pwgv84pn.js +0 -32
  314. package/dist/chunk-pwsnafp3.js +0 -4367
  315. package/dist/chunk-q9n5swx7.js +0 -3
  316. package/dist/chunk-qr346wnp.js +0 -2
  317. package/dist/chunk-r02hke04.js +0 -2
  318. package/dist/chunk-ranshpyc.js +0 -3
  319. package/dist/chunk-rn194bhp.js +0 -20
  320. package/dist/chunk-rn1hgyc8.js +0 -930
  321. package/dist/chunk-s7z5dp70.js +0 -43
  322. package/dist/chunk-s8jd13nb.js +0 -3
  323. package/dist/chunk-sn7exv0n.js +0 -2
  324. package/dist/chunk-t1tdjjht.js +0 -216
  325. package/dist/chunk-t6qx04s8.js +0 -499
  326. package/dist/chunk-t6y6gyps.js +0 -2
  327. package/dist/chunk-tjfs7cc3.js +0 -2
  328. package/dist/chunk-tkyrk66a.js +0 -3
  329. package/dist/chunk-tntv9hvq.js +0 -2
  330. package/dist/chunk-v3nwkveg.js +0 -12
  331. package/dist/chunk-vd4cb5xr.js +0 -2
  332. package/dist/chunk-vkhdce50.js +0 -2
  333. package/dist/chunk-w183av08.js +0 -2
  334. package/dist/chunk-w2m02njv.js +0 -2
  335. package/dist/chunk-wpjrcrs5.js +0 -2
  336. package/dist/chunk-wqmppf6b.js +0 -3
  337. package/dist/chunk-wtb9fxdy.js +0 -2
  338. package/dist/chunk-xmzygmcz.js +0 -3
  339. package/dist/chunk-xsng1mtq.js +0 -3
  340. package/dist/chunk-xxzefj4j.js +0 -2
  341. package/dist/chunk-yq8x8bxq.js +0 -47
  342. package/dist/chunk-ytma76qe.js +0 -3
  343. package/dist/chunk-yw1m115e.js +0 -2
  344. package/dist/chunk-z64a924m.js +0 -2
  345. package/dist/chunk-zcz9rs6p.js +0 -3
@@ -1,1199 +0,0 @@
1
- // @bun
2
- import{dx as S,gx as i}from"./chunk-kg1rdena.js";import{hx as v,ix as k,jx as G}from"./chunk-ay6zjq8v.js";import A from"fs";import B from"path";function u(j){let q=0;for(let K=0;K<j.length;K++){let Q=j[K];q=(q<<5)-q+Q,q=q&q}return Math.abs(q).toString(16).padStart(8,"0")}function f(j,q){let K=B.basename(j);for(let Q of q)if(Q.startsWith("*.")){let Y=Q.slice(1);if(K.endsWith(Y))return!0}else if(Q.includes("*")){let Y=new RegExp(`^${Q.replace(/\*/g,".*")}$`);if(Y.test(K)||Y.test(j))return!0}else if(K===Q||j.includes(Q))return!0;return!1}function g(j,q,K){let Q=B.extname(j).toLowerCase(),Y=h[Q],X=(K.maxFileSizeKB||500)*1024;if(q>X)return!1;if(K.exclude&&f(j,K.exclude))return!1;if(K.include&&K.include.length>0){for(let Z of K.include)if(Z.startsWith("*.")){if(j.endsWith(Z.slice(1)))return!0}else if(j.includes(Z))return!0}if(Y&&K[Y]===!0)return!0;if(!Y)return!1;return!1}function T(j,q,K,Q){let Y=A.readdirSync(j,{withFileTypes:!0});for(let X of Y){let Z=B.join(j,X.name);if(X.isDirectory()){if(["node_modules",".git",".stx"].includes(X.name))continue;T(Z,q,K,Q)}else if(X.isFile()){let O=A.statSync(Z),_=B.relative(q,Z);if(g(_,O.size,K)){let $=A.readFileSync(Z),L=u($),V=`/${_.replace(/\\/g,"/")}`;Q.push({url:V,revision:L,size:O.size})}}}}function U(j,q){let K=q.pwa?.precache,Q=[];if(!K?.enabled)return{entries:[],totalSize:0,fileCount:0};if(!A.existsSync(j))return{entries:[],totalSize:0,fileCount:0};T(j,j,K,Q),Q.sort((X,Z)=>X.url.localeCompare(Z.url));let Y=Q.reduce((X,Z)=>X+Z.size,0);return{entries:Q,totalSize:Y,fileCount:Q.length}}function J(j){if(j.entries.length===0)return"[]";return`[
3
- ${j.entries.map((K)=>` { url: '${K.url}', revision: '${K.revision}' }`).join(`,
4
- `)}
5
- ]`}function E(j){if(j<1024)return`${j} B`;if(j<1048576)return`${(j/1024).toFixed(1)} KB`;return`${(j/1048576).toFixed(2)} MB`}var h;var F=G(()=>{h={".html":"includeHtml",".htm":"includeHtml",".js":"includeJs",".mjs":"includeJs",".css":"includeCss",".png":"includeImages",".jpg":"includeImages",".jpeg":"includeImages",".gif":"includeImages",".webp":"includeImages",".svg":"includeImages",".ico":"includeImages",".woff":"includeFonts",".woff2":"includeFonts",".ttf":"includeFonts",".eot":"includeFonts",".otf":"includeFonts"}});function c(j){let q={"cache-first":{className:"CacheFirst",importFrom:"workbox-strategies"},"network-first":{className:"NetworkFirst",importFrom:"workbox-strategies"},"stale-while-revalidate":{className:"StaleWhileRevalidate",importFrom:"workbox-strategies"},"network-only":{className:"NetworkOnly",importFrom:"workbox-strategies"},"cache-only":{className:"CacheOnly",importFrom:"workbox-strategies"}};return q[j]||q["network-first"]}function R(j){return c(j).className}function M(j){let q=j.pwa;if(!q?.enabled)return"";let K=q.routes||[],Q=q.cacheStorage,Y=[];for(let X of K){let Z=R(X.strategy),O=[];if(X.maxAgeSeconds||X.maxEntries||Q?.maxEntries){let $=X.maxEntries||Q?.maxEntries||100,L=X.maxAgeSeconds||(Q?.maxAge?Q.maxAge*24*60*60:void 0);O.push(`new ExpirationPlugin({
6
- maxEntries: ${$},
7
- ${L?`maxAgeSeconds: ${L},`:""}
8
- purgeOnQuotaError: true,
9
- })`)}if(X.strategy==="network-first"||X.strategy==="stale-while-revalidate")O.push(`new CacheableResponsePlugin({
10
- statuses: [0, 200],
11
- })`);let _=p(X.pattern);Y.push(`
12
- // ${X.pattern}
13
- registerRoute(
14
- ${_},
15
- new ${Z}({
16
- cacheName: '${X.cacheName||s(X.pattern)}',
17
- ${O.length>0?`plugins: [
18
- ${O.join(`,
19
- `)}
20
- ],`:""}
21
- })
22
- );`)}return Y.join(`
23
- `)}function p(j){if(j.startsWith("*.")){let q=j.slice(2);return`({ request }) => request.destination === '${a(q)}'`}if(j.endsWith("/**"))return`({ url }) => url.pathname.startsWith('${j.slice(0,-3)}')`;if(j.endsWith("/*")){let q=j.slice(0,-2);return`({ url }) => url.pathname.startsWith('${q}') && !url.pathname.slice(${q.length+1}).includes('/')`}if(j.includes("*")&&!j.startsWith("*")){let[q,K]=j.split("*");return`({ url }) => url.pathname.startsWith('${q}') && url.pathname.endsWith('${K}')`}if(j==="/"||!j.includes("*"))return`({ url }) => url.pathname === '${j}'`;return`new RegExp('${r(j).replace(/\\\*/g,".*")}')`}function a(j){return{js:"script",mjs:"script",css:"style",html:"document",htm:"document",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"}[j.toLowerCase()]||"empty"}function s(j){return"stx-"+j.replace(/[^\w]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").toLowerCase().slice(0,30)+"-cache"}function r(j){return j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var W=()=>{};var x={};k(x,{isWorkboxEnabled:()=>D,getServiceWorkerGenerator:()=>jj,generateWorkboxServiceWorker:()=>b,generateWorkboxConfig:()=>P});function P(j,q){let K=j.pwa;if(!K?.enabled)return{mode:"generate",modules:[],skipWaiting:!0,clientsClaim:!0};let Q=K.serviceWorker||{},Y=K.routes||[],X=[{name:"workbox-precaching",exports:["precacheAndRoute","cleanupOutdatedCaches"]},{name:"workbox-routing",exports:["registerRoute","NavigationRoute","setDefaultHandler"]}],Z=new Set;for(let $ of Y)Z.add(R($.strategy));if(Z.size>0)X.push({name:"workbox-strategies",exports:Array.from(Z)});if(Y.some(($)=>$.maxAgeSeconds||$.maxEntries)||K.cacheStorage)X.push({name:"workbox-expiration",exports:["ExpirationPlugin"]});if(Y.some(($)=>$.strategy==="network-first"||$.strategy==="stale-while-revalidate"))X.push({name:"workbox-cacheable-response",exports:["CacheableResponsePlugin"]});if(K.backgroundSync?.enabled)X.push({name:"workbox-background-sync",exports:["BackgroundSyncPlugin","Queue"]});if(Q.navigationPreload)X.push({name:"workbox-navigation-preload",exports:["enable"]});let _=q?U(q,j):void 0;return{mode:"generate",modules:X,precacheManifest:_?.entries,skipWaiting:Q.skipWaiting??!0,clientsClaim:Q.clientsClaim??!0,offlineFallback:K.offline?.enabled?"/offline.html":void 0,navigationPreload:Q.navigationPreload??!1,cacheVersion:Q.cacheVersion||"1.0.0"}}function b(j,q){let K=j.pwa;if(!K?.enabled)return"";let Q=P(j,q),Y=K.serviceWorker||{},X=K.push,Z=K.backgroundSync,O=q?U(q,j):null,_=O?J(O):"[]",$=n(Q.modules),L=M(j);return`/**
24
- * Service Worker - Generated by stx with Workbox
25
- * Cache Version: ${Q.cacheVersion}
26
- *
27
- * This service worker uses Google's Workbox library for robust caching.
28
- * https://developers.google.com/web/tools/workbox
29
- *
30
- * Features:
31
- * - Precaching with automatic revision management
32
- * - Runtime caching with multiple strategies
33
- * - Offline fallback support
34
- * - Push notifications: ${X?.enabled?"enabled":"disabled"}
35
- * - Background sync: ${Z?.enabled?"enabled":"disabled"}
36
- */
37
-
38
- // Import Workbox modules from CDN
39
- importScripts('https://storage.googleapis.com/workbox-cdn/releases/7.0.0/workbox-sw.js');
40
-
41
- // Disable Workbox logging in production. Through isProduction() rather than
42
- // off process.env.NODE_ENV: this is inside a template literal, so the
43
- // comparison is evaluated when the service worker is GENERATED -- and the
44
- // build's transpiler folds that particular read to a constant, so every
45
- // published copy of stx emitted "debug: true" and no app could turn Workbox's
46
- // logging off in production however it set NODE_ENV (see ../env.ts).
47
- workbox.setConfig({ debug: ${!S()} });
48
-
49
- // Extract modules from workbox global
50
- ${$}
51
-
52
- const CACHE_VERSION = '${Q.cacheVersion}';
53
- const OFFLINE_PAGE = '${Q.offlineFallback||"/offline.html"}';
54
-
55
- // ============================================================================
56
- // Precaching
57
- // ============================================================================
58
-
59
- // Clean up outdated caches from previous versions
60
- cleanupOutdatedCaches();
61
-
62
- // Precache static assets
63
- // The manifest is injected during build or defined below
64
- const PRECACHE_MANIFEST = ${_};
65
-
66
- // Add essential assets
67
- PRECACHE_MANIFEST.push(
68
- { url: '/', revision: CACHE_VERSION },
69
- { url: '/manifest.json', revision: CACHE_VERSION },
70
- ${Q.offlineFallback?`{ url: '${Q.offlineFallback}', revision: CACHE_VERSION },`:""}
71
- );
72
-
73
- // Precache and route all manifest entries
74
- precacheAndRoute(PRECACHE_MANIFEST);
75
-
76
- // ============================================================================
77
- // Navigation Preload
78
- // ============================================================================
79
-
80
- ${Q.navigationPreload?`// Enable navigation preload for faster page loads
81
- enable();`:"// Navigation preload disabled"}
82
-
83
- // ============================================================================
84
- // Runtime Caching
85
- // ============================================================================
86
-
87
- ${L}
88
-
89
- // ============================================================================
90
- // Offline Fallback
91
- // ============================================================================
92
-
93
- ${Q.offlineFallback?`
94
- // Set up offline fallback for navigation requests
95
- const navigationRoute = new NavigationRoute(
96
- new NetworkFirst({
97
- cacheName: 'stx-pages-cache',
98
- plugins: [
99
- new CacheableResponsePlugin({ statuses: [0, 200] }),
100
- ],
101
- }),
102
- {
103
- // Return offline page when navigation fails
104
- async allowedHandler(request) {
105
- try {
106
- const response = await this.handle(request);
107
- return response;
108
- }
109
- catch (error) {
110
- const cache = await caches.open('stx-offline-cache');
111
- return cache.match(OFFLINE_PAGE) || new Response('You are offline', {
112
- status: 503,
113
- statusText: 'Service Unavailable',
114
- });
115
- }
116
- },
117
- }
118
- );
119
- registerRoute(navigationRoute);
120
- `:"// No offline fallback configured"}
121
-
122
- // Default handler for unmatched requests
123
- setDefaultHandler(new NetworkFirst({
124
- cacheName: 'stx-default-cache',
125
- plugins: [
126
- new CacheableResponsePlugin({ statuses: [0, 200] }),
127
- new ExpirationPlugin({ maxEntries: 100, maxAgeSeconds: 60 * 60 * 24 }), // 1 day
128
- ],
129
- }));
130
-
131
- // ============================================================================
132
- // Service Worker Lifecycle
133
- // ============================================================================
134
-
135
- ${Q.skipWaiting?`// Skip waiting - activate immediately
136
- self.skipWaiting();`:"// Manual skipWaiting - user must trigger update"}
137
-
138
- ${Q.clientsClaim?`// Claim clients - take control immediately
139
- self.addEventListener('activate', () => {
140
- self.clients.claim();
141
- });`:"// Manual clients claim"}
142
-
143
- // ============================================================================
144
- // Message Handling
145
- // ============================================================================
146
-
147
- self.addEventListener('message', (event) => {
148
- const { type, payload } = event.data || {};
149
-
150
- switch (type) {
151
- case 'SKIP_WAITING':
152
- self.skipWaiting();
153
- break;
154
-
155
- case 'GET_VERSION':
156
- event.source?.postMessage({ type: 'VERSION', payload: CACHE_VERSION });
157
- break;
158
-
159
- case 'CACHE_URLS':
160
- if (Array.isArray(payload)) {
161
- event.waitUntil(
162
- caches.open('stx-dynamic-cache').then(cache => cache.addAll(payload))
163
- );
164
- }
165
- break;
166
-
167
- case 'CLEAR_CACHE':
168
- event.waitUntil(
169
- caches.keys().then(names =>
170
- Promise.all(names.map(name => caches.delete(name)))
171
- )
172
- );
173
- break;
174
- }
175
- });
176
-
177
- ${X?.enabled?e(X):"// Push notifications disabled"}
178
-
179
- ${Z?.enabled?t(Z):"// Background sync disabled"}
180
-
181
- console.log('[Workbox SW] Service Worker loaded - Version:', CACHE_VERSION);
182
- `}function n(j){let q=[];for(let K of j){let Q=K.name.replace("workbox-","");q.push(`const { ${K.exports.join(", ")} } = workbox.${o(Q)};`)}return q.join(`
183
- `)}function o(j){return j.replace(/-([a-z])/g,(q,K)=>K.toUpperCase())}function e(j){return`
184
- // ============================================================================
185
- // Push Notifications
186
- // ============================================================================
187
-
188
- const PUSH_CONFIG = {
189
- defaultIcon: '${j?.defaultIcon||"/pwa-icons/icon-192x192.png"}',
190
- defaultBadge: '${j?.defaultBadge||"/pwa-icons/icon-72x72.png"}',
191
- };
192
-
193
- self.addEventListener('push', (event) => {
194
- console.log('[Workbox SW] Push notification received');
195
-
196
- let data = {
197
- title: 'Notification',
198
- body: 'You have a new notification',
199
- icon: PUSH_CONFIG.defaultIcon,
200
- badge: PUSH_CONFIG.defaultBadge,
201
- };
202
-
203
- if (event.data) {
204
- try {
205
- const payload = event.data.json();
206
- data = { ...data, ...payload };
207
- }
208
- catch {
209
- data.body = event.data.text();
210
- }
211
- }
212
-
213
- const options = {
214
- body: data.body,
215
- icon: data.icon || PUSH_CONFIG.defaultIcon,
216
- badge: data.badge || PUSH_CONFIG.defaultBadge,
217
- vibrate: data.vibrate || [100, 50, 100],
218
- data: {
219
- url: data.url || '/',
220
- ...data.data,
221
- },
222
- actions: data.actions || [],
223
- tag: data.tag,
224
- renotify: data.renotify || false,
225
- requireInteraction: data.requireInteraction || false,
226
- };
227
-
228
- event.waitUntil(
229
- self.registration.showNotification(data.title, options)
230
- );
231
- });
232
-
233
- self.addEventListener('notificationclick', (event) => {
234
- console.log('[Workbox SW] Notification clicked');
235
- event.notification.close();
236
-
237
- const url = event.notification.data?.url || '/';
238
-
239
- event.waitUntil(
240
- clients.matchAll({ type: 'window', includeUncontrolled: true }).then(windowClients => {
241
- for (const client of windowClients) {
242
- if (client.url === url && 'focus' in client) {
243
- return client.focus();
244
- }
245
- }
246
- if (clients.openWindow) {
247
- return clients.openWindow(url);
248
- }
249
- })
250
- );
251
- });
252
- `}function t(j){return`
253
- // ============================================================================
254
- // Background Sync
255
- // ============================================================================
256
-
257
- const syncQueue = new Queue('${j?.queueName||"stx-sync-queue"}', {
258
- maxRetentionTime: ${j?.maxRetentionMinutes||1440}, // minutes
259
- onSync: async ({ queue }) => {
260
- let entry;
261
- while ((entry = await queue.shiftRequest())) {
262
- try {
263
- await fetch(entry.request.clone());
264
- console.log('[Workbox SW] Sync succeeded:', entry.request.url);
265
-
266
- // Notify clients
267
- const allClients = await self.clients.matchAll();
268
- allClients.forEach(client => {
269
- client.postMessage({
270
- type: 'SYNC_COMPLETE',
271
- url: entry.request.url,
272
- success: true,
273
- });
274
- });
275
- }
276
- catch (error) {
277
- console.log('[Workbox SW] Sync failed, re-queuing:', entry.request.url);
278
- await queue.unshiftRequest(entry);
279
- throw error;
280
- }
281
- }
282
- },
283
- });
284
-
285
- // Register routes that should use background sync
286
- ${j?.endpoints?.map((q)=>`
287
- registerRoute(
288
- ({ url }) => url.pathname.startsWith('${q}'),
289
- new NetworkOnly({
290
- plugins: [
291
- new BackgroundSyncPlugin('${j?.queueName||"stx-sync-queue"}', {
292
- maxRetentionTime: ${j?.maxRetentionMinutes||1440},
293
- }),
294
- ],
295
- }),
296
- 'POST'
297
- );`).join(`
298
- `)||"// No background sync endpoints configured"}
299
-
300
- // Handle form sync messages
301
- self.addEventListener('message', (event) => {
302
- if (event.data?.type === 'REGISTER_FORM_SYNC') {
303
- const { action, method, data } = event.data.payload;
304
-
305
- const request = new Request(action, {
306
- method: method || 'POST',
307
- headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
308
- body: new URLSearchParams(data).toString(),
309
- });
310
-
311
- event.waitUntil(syncQueue.pushRequest({ request }));
312
- }
313
- });
314
- `}function D(j){return j.pwa?.enabled===!0&&j.pwa?.serviceWorker?.useWorkbox===!0}function jj(j){if(D(j))return b;let{generateServiceWorker:q}=(H(),v(w));return q}var d=G(()=>{i();W();F()});var w={};k(w,{isWorkboxEnabled:()=>C,getServiceWorkerFileName:()=>z,generateServiceWorkerAuto:()=>Qj,generateServiceWorker:()=>y});function y(j,q){let K=j.pwa;if(!K?.enabled)return"";let Q=K.serviceWorker||{},Y=K.routes||[],X=Q.cacheVersion||"1.0.0",Z=K.offline,O=Z?.page?"/offline.html":"/offline.html",_=K.push,$=K.backgroundSync,L=K.cacheStorage,V=q?U(q,j):null,m=V?J(V):"[]",l=["/","/manifest.json",...Z?.enabled?[O]:[],...Z?.precacheAssets||[]];return`/**
315
- * Service Worker - Auto-generated by stx
316
- * Cache Version: ${X}
317
- *
318
- * This service worker implements configurable caching strategies:
319
- * - cache-first: Serve from cache, fall back to network
320
- * - network-first: Try network, fall back to cache
321
- * - stale-while-revalidate: Serve cached, update in background
322
- * - network-only: Always fetch from network
323
- * - cache-only: Only serve from cache
324
- *
325
- * Additional features:
326
- * - Push notifications: ${_?.enabled?"enabled":"disabled"}
327
- * - Background sync: ${$?.enabled?"enabled":"disabled"}
328
- * - Cache limits: ${L?.maxSize?`${E(L.maxSize*1024*1024)}`:"unlimited"}
329
- */
330
-
331
- const CACHE_VERSION = '${X}';
332
- const CACHE_NAME = 'stx-pwa-v' + CACHE_VERSION;
333
- const OFFLINE_PAGE = '${O}';
334
-
335
- // Assets to precache on install
336
- const PRECACHE_ASSETS = ${JSON.stringify(l,null,2)};
337
-
338
- // Auto-generated precache manifest from build output
339
- const BUILD_PRECACHE_MANIFEST = ${m};
340
-
341
- // Route caching strategies
342
- const ROUTE_STRATEGIES = ${JSON.stringify(Y,null,2)};
343
-
344
- // Routes to exclude from caching
345
- const EXCLUDED_ROUTES = ${JSON.stringify(Q.excludeRoutes||[],null,2)};
346
-
347
- // Cache storage configuration
348
- const CACHE_CONFIG = {
349
- maxSize: ${L?.maxSize||0} * 1024 * 1024, // Convert MB to bytes
350
- maxAge: ${L?.maxAge||0} * 24 * 60 * 60 * 1000, // Convert days to ms
351
- maxEntries: ${L?.maxEntries||0},
352
- purgeStrategy: '${L?.purgeStrategy||"lru"}',
353
- };
354
-
355
- // Background sync configuration
356
- const SYNC_CONFIG = {
357
- enabled: ${$?.enabled||!1},
358
- queueName: '${$?.queueName||"stx-sync-queue"}',
359
- maxRetries: ${$?.maxRetries||3},
360
- minInterval: ${$?.minInterval||1000},
361
- };
362
-
363
- // Push notification configuration
364
- const PUSH_CONFIG = {
365
- enabled: ${_?.enabled||!1},
366
- defaultIcon: '${_?.defaultIcon||"/pwa-icons/icon-192x192.png"}',
367
- defaultBadge: '${_?.defaultBadge||"/pwa-icons/icon-72x72.png"}',
368
- };
369
-
370
- /**
371
- * Install event - precache essential assets
372
- */
373
- self.addEventListener('install', (event) => {
374
- console.log('[SW] Installing service worker...');
375
- ${Q.skipWaiting?"self.skipWaiting();":""}
376
-
377
- event.waitUntil(
378
- caches.open(CACHE_NAME).then(async (cache) => {
379
- // Combine manual precache assets with auto-generated manifest
380
- const allAssets = [...PRECACHE_ASSETS];
381
-
382
- // Add build precache manifest entries
383
- for (const entry of BUILD_PRECACHE_MANIFEST) {
384
- if (!allAssets.includes(entry.url)) {
385
- allAssets.push(entry.url);
386
- }
387
- }
388
-
389
- console.log('[SW] Precaching assets:', allAssets.length);
390
-
391
- // Cache assets one by one to handle failures gracefully
392
- const results = await Promise.allSettled(
393
- allAssets.map(async (url) => {
394
- try {
395
- const response = await fetch(url);
396
- if (response.ok) {
397
- await cache.put(url, response);
398
- return { url, success: true };
399
- }
400
- return { url, success: false, reason: response.status };
401
- }
402
- catch (error) {
403
- return { url, success: false, reason: error.message };
404
- }
405
- })
406
- );
407
-
408
- const failed = results.filter(r => r.status === 'rejected' || (r.status === 'fulfilled' && !r.value.success));
409
- if (failed.length > 0) {
410
- console.warn('[SW] Failed to precache some assets:', failed.length);
411
- }
412
- })
413
- );
414
- });
415
-
416
- /**
417
- * Activate event - clean up old caches
418
- */
419
- self.addEventListener('activate', (event) => {
420
- console.log('[SW] Activating service worker...');
421
- ${Q.clientsClaim?"self.clients.claim();":""}
422
-
423
- event.waitUntil(
424
- (async () => {
425
- // Clean up old caches
426
- const cacheNames = await caches.keys();
427
- await Promise.all(
428
- cacheNames
429
- .filter((name) => name.startsWith('stx-pwa-') && name !== CACHE_NAME)
430
- .map((name) => {
431
- console.log('[SW] Deleting old cache:', name);
432
- return caches.delete(name);
433
- })
434
- );
435
-
436
- // Enforce cache storage limits
437
- if (CACHE_CONFIG.maxSize > 0 || CACHE_CONFIG.maxEntries > 0) {
438
- await enforceCacheLimits();
439
- }
440
- })()
441
- );
442
- });
443
-
444
- /**
445
- * Fetch event - apply caching strategies
446
- */
447
- self.addEventListener('fetch', (event) => {
448
- const { request } = event;
449
- const url = new URL(request.url);
450
-
451
- // Only handle GET requests
452
- if (request.method !== 'GET') {
453
- return;
454
- }
455
-
456
- // Skip cross-origin requests
457
- if (url.origin !== location.origin) {
458
- return;
459
- }
460
-
461
- // Skip excluded routes
462
- if (isExcludedRoute(url.pathname)) {
463
- return;
464
- }
465
-
466
- // Find matching strategy and apply
467
- const routeConfig = getRouteConfig(url.pathname);
468
- event.respondWith(applyStrategy(request, routeConfig));
469
- });
470
-
471
- /**
472
- * Message event - handle messages from main thread
473
- */
474
- self.addEventListener('message', (event) => {
475
- const { type, payload } = event.data || {};
476
-
477
- switch (type) {
478
- case 'SKIP_WAITING':
479
- console.log('[SW] Received SKIP_WAITING message');
480
- self.skipWaiting();
481
- break;
482
-
483
- case 'CACHE_URLS':
484
- if (Array.isArray(payload)) {
485
- event.waitUntil(
486
- caches.open(CACHE_NAME).then((cache) => cache.addAll(payload))
487
- );
488
- }
489
- break;
490
-
491
- case 'CLEAR_CACHE':
492
- event.waitUntil(
493
- caches.keys().then((names) =>
494
- Promise.all(names.map((name) => caches.delete(name)))
495
- )
496
- );
497
- break;
498
-
499
- case 'GET_CACHE_SIZE':
500
- event.waitUntil(
501
- getCacheSize().then((size) => {
502
- event.source?.postMessage({ type: 'CACHE_SIZE', payload: size });
503
- })
504
- );
505
- break;
506
- }
507
- });
508
-
509
- ${_?.enabled?qj():"// Push notifications disabled"}
510
-
511
- ${$?.enabled?Kj():"// Background sync disabled"}
512
-
513
- /**
514
- * Check if a route should be excluded from caching
515
- */
516
- function isExcludedRoute(pathname) {
517
- return EXCLUDED_ROUTES.some((pattern) => matchPattern(pathname, pattern));
518
- }
519
-
520
- /**
521
- * Match a path against a glob pattern
522
- * Supports: *.ext, /path/*, /path/**, exact matches
523
- */
524
- function matchPattern(path, pattern) {
525
- // Handle file extension patterns like *.js, *.css
526
- if (pattern.startsWith('*.')) {
527
- return path.endsWith(pattern.slice(1));
528
- }
529
-
530
- // Handle patterns ending with /**
531
- if (pattern.endsWith('/**')) {
532
- const prefix = pattern.slice(0, -3);
533
- return path.startsWith(prefix);
534
- }
535
-
536
- // Handle patterns ending with /*
537
- if (pattern.endsWith('/*')) {
538
- const prefix = pattern.slice(0, -2);
539
- if (!path.startsWith(prefix)) return false;
540
- const rest = path.slice(prefix.length);
541
- return rest.length > 0 && !rest.slice(1).includes('/');
542
- }
543
-
544
- // Handle patterns with * in the middle
545
- if (pattern.includes('*')) {
546
- const parts = pattern.split('*');
547
- if (parts.length === 2) {
548
- return path.startsWith(parts[0]) && path.endsWith(parts[1]);
549
- }
550
- }
551
-
552
- // Exact match
553
- return path === pattern;
554
- }
555
-
556
- /**
557
- * Get the cache configuration for a given path
558
- */
559
- function getRouteConfig(pathname) {
560
- for (const route of ROUTE_STRATEGIES) {
561
- if (matchPattern(pathname, route.pattern)) {
562
- return route;
563
- }
564
- }
565
- // Default to network-first for unmatched routes
566
- return { strategy: 'network-first' };
567
- }
568
-
569
- /**
570
- * Apply the appropriate caching strategy
571
- */
572
- async function applyStrategy(request, routeConfig) {
573
- const { strategy, cacheName, maxAgeSeconds, maxEntries } = routeConfig;
574
- const cache = await caches.open(cacheName || CACHE_NAME);
575
-
576
- switch (strategy) {
577
- case 'cache-first':
578
- return cacheFirst(request, cache, maxAgeSeconds);
579
-
580
- case 'network-first':
581
- return networkFirst(request, cache);
582
-
583
- case 'stale-while-revalidate':
584
- return staleWhileRevalidate(request, cache);
585
-
586
- case 'network-only':
587
- return networkOnly(request);
588
-
589
- case 'cache-only':
590
- return cacheOnly(request, cache);
591
-
592
- default:
593
- return networkFirst(request, cache);
594
- }
595
- }
596
-
597
- /**
598
- * Cache-first strategy
599
- * Serve from cache if available, otherwise fetch from network
600
- */
601
- async function cacheFirst(request, cache, maxAge) {
602
- const cached = await cache.match(request);
603
-
604
- if (cached) {
605
- // Check if cache is still valid (if maxAge is set)
606
- if (maxAge) {
607
- const cachedDate = cached.headers.get('sw-cache-date');
608
- if (cachedDate) {
609
- const age = (Date.now() - new Date(cachedDate).getTime()) / 1000;
610
- if (age > maxAge) {
611
- // Cache expired, fetch fresh
612
- return fetchAndCache(request, cache);
613
- }
614
- }
615
- }
616
- return cached;
617
- }
618
-
619
- return fetchAndCache(request, cache);
620
- }
621
-
622
- /**
623
- * Network-first strategy
624
- * Try network first, fall back to cache if offline
625
- */
626
- async function networkFirst(request, cache) {
627
- try {
628
- const response = await fetch(request);
629
- if (response.ok) {
630
- const cloned = response.clone();
631
- cache.put(request, cloned);
632
- }
633
- return response;
634
- }
635
- catch (error) {
636
- const cached = await cache.match(request);
637
- if (cached) {
638
- return cached;
639
- }
640
- return offlineResponse(request);
641
- }
642
- }
643
-
644
- /**
645
- * Stale-while-revalidate strategy
646
- * Serve cached immediately, update cache in background
647
- */
648
- async function staleWhileRevalidate(request, cache) {
649
- const cached = await cache.match(request);
650
-
651
- // Fetch in background to update cache
652
- const fetchPromise = fetch(request)
653
- .then((response) => {
654
- if (response.ok) {
655
- cache.put(request, response.clone());
656
- }
657
- return response;
658
- })
659
- .catch(() => null);
660
-
661
- // Return cached immediately if available, otherwise wait for fetch
662
- if (cached) {
663
- return cached;
664
- }
665
-
666
- const response = await fetchPromise;
667
- return response || offlineResponse(request);
668
- }
669
-
670
- /**
671
- * Network-only strategy
672
- * Always fetch from network, no caching
673
- */
674
- async function networkOnly(request) {
675
- try {
676
- return await fetch(request);
677
- }
678
- catch (error) {
679
- return offlineResponse(request);
680
- }
681
- }
682
-
683
- /**
684
- * Cache-only strategy
685
- * Only serve from cache, never fetch
686
- */
687
- async function cacheOnly(request, cache) {
688
- const cached = await cache.match(request);
689
- return cached || offlineResponse(request);
690
- }
691
-
692
- /**
693
- * Fetch and cache a request
694
- */
695
- async function fetchAndCache(request, cache) {
696
- try {
697
- const response = await fetch(request);
698
- if (response.ok) {
699
- // Add cache timestamp header
700
- const headers = new Headers(response.headers);
701
- headers.set('sw-cache-date', new Date().toISOString());
702
-
703
- const cachedResponse = new Response(response.clone().body, {
704
- status: response.status,
705
- statusText: response.statusText,
706
- headers,
707
- });
708
-
709
- cache.put(request, cachedResponse);
710
- }
711
- return response;
712
- }
713
- catch (error) {
714
- return offlineResponse(request);
715
- }
716
- }
717
-
718
- /**
719
- * Generate offline response
720
- */
721
- async function offlineResponse(request) {
722
- // For navigation requests, return offline page
723
- if (request.mode === 'navigate') {
724
- const cache = await caches.open(CACHE_NAME);
725
- const offlinePage = await cache.match(OFFLINE_PAGE);
726
- if (offlinePage) {
727
- return offlinePage;
728
- }
729
- }
730
-
731
- // Return a basic offline response
732
- return new Response('You are offline', {
733
- status: 503,
734
- statusText: 'Service Unavailable',
735
- headers: {
736
- 'Content-Type': 'text/plain',
737
- },
738
- });
739
- }
740
-
741
- /**
742
- * Get total cache size
743
- */
744
- async function getCacheSize() {
745
- let totalSize = 0;
746
- const cacheNames = await caches.keys();
747
-
748
- for (const cacheName of cacheNames) {
749
- const cache = await caches.open(cacheName);
750
- const keys = await cache.keys();
751
-
752
- for (const request of keys) {
753
- const response = await cache.match(request);
754
- if (response) {
755
- const blob = await response.clone().blob();
756
- totalSize += blob.size;
757
- }
758
- }
759
- }
760
-
761
- return totalSize;
762
- }
763
-
764
- /**
765
- * Enforce cache storage limits
766
- */
767
- async function enforceCacheLimits() {
768
- const cache = await caches.open(CACHE_NAME);
769
- const keys = await cache.keys();
770
-
771
- // Get cache entries with metadata
772
- const entries = [];
773
- for (const request of keys) {
774
- const response = await cache.match(request);
775
- if (response) {
776
- const blob = await response.clone().blob();
777
- const cachedDate = response.headers.get('sw-cache-date');
778
- entries.push({
779
- request,
780
- size: blob.size,
781
- date: cachedDate ? new Date(cachedDate) : new Date(),
782
- });
783
- }
784
- }
785
-
786
- // Check total size limit
787
- if (CACHE_CONFIG.maxSize > 0) {
788
- const totalSize = entries.reduce((sum, e) => sum + e.size, 0);
789
-
790
- if (totalSize > CACHE_CONFIG.maxSize) {
791
- console.log('[SW] Cache size exceeded, purging...');
792
- await purgeCache(entries, cache, CACHE_CONFIG.maxSize);
793
- }
794
- }
795
-
796
- // Check max entries limit
797
- if (CACHE_CONFIG.maxEntries > 0 && entries.length > CACHE_CONFIG.maxEntries) {
798
- console.log('[SW] Cache entries exceeded, purging...');
799
- await purgeByEntryCount(entries, cache, CACHE_CONFIG.maxEntries);
800
- }
801
-
802
- // Check max age limit
803
- if (CACHE_CONFIG.maxAge > 0) {
804
- const now = Date.now();
805
- const expiredEntries = entries.filter(e => (now - e.date.getTime()) > CACHE_CONFIG.maxAge);
806
-
807
- for (const entry of expiredEntries) {
808
- console.log('[SW] Removing expired cache entry:', entry.request.url);
809
- await cache.delete(entry.request);
810
- }
811
- }
812
- }
813
-
814
- /**
815
- * Purge cache to meet size limit
816
- */
817
- async function purgeCache(entries, cache, maxSize) {
818
- // Sort by purge strategy
819
- const sorted = [...entries];
820
-
821
- switch (CACHE_CONFIG.purgeStrategy) {
822
- case 'lru':
823
- // Least Recently Used - remove oldest first
824
- sorted.sort((a, b) => a.date.getTime() - b.date.getTime());
825
- break;
826
- case 'fifo':
827
- // First In First Out - same as lru for our purposes
828
- sorted.sort((a, b) => a.date.getTime() - b.date.getTime());
829
- break;
830
- case 'lfu':
831
- // Least Frequently Used - we don't track frequency, use size as proxy
832
- sorted.sort((a, b) => b.size - a.size);
833
- break;
834
- default:
835
- sorted.sort((a, b) => a.date.getTime() - b.date.getTime());
836
- }
837
-
838
- let currentSize = entries.reduce((sum, e) => sum + e.size, 0);
839
-
840
- for (const entry of sorted) {
841
- if (currentSize <= maxSize * 0.8) { // Keep 80% buffer
842
- break;
843
- }
844
-
845
- // Don't delete essential assets
846
- const url = entry.request.url;
847
- if (PRECACHE_ASSETS.some(asset => url.endsWith(asset))) {
848
- continue;
849
- }
850
-
851
- console.log('[SW] Purging cache entry:', url);
852
- await cache.delete(entry.request);
853
- currentSize -= entry.size;
854
- }
855
- }
856
-
857
- /**
858
- * Purge cache by entry count
859
- */
860
- async function purgeByEntryCount(entries, cache, maxEntries) {
861
- const sorted = [...entries].sort((a, b) => a.date.getTime() - b.date.getTime());
862
- const toRemove = sorted.slice(0, entries.length - maxEntries);
863
-
864
- for (const entry of toRemove) {
865
- // Don't delete essential assets
866
- const url = entry.request.url;
867
- if (PRECACHE_ASSETS.some(asset => url.endsWith(asset))) {
868
- continue;
869
- }
870
-
871
- await cache.delete(entry.request);
872
- }
873
- }
874
-
875
- console.log('[SW] Service Worker loaded - Version:', CACHE_VERSION);
876
- `}function qj(){return`
877
- /**
878
- * Push event - handle incoming push notifications
879
- */
880
- self.addEventListener('push', (event) => {
881
- console.log('[SW] Push notification received');
882
-
883
- let data = {
884
- title: 'Notification',
885
- body: 'You have a new notification',
886
- icon: PUSH_CONFIG.defaultIcon,
887
- badge: PUSH_CONFIG.defaultBadge,
888
- };
889
-
890
- if (event.data) {
891
- try {
892
- const payload = event.data.json();
893
- data = { ...data, ...payload };
894
- }
895
- catch {
896
- data.body = event.data.text();
897
- }
898
- }
899
-
900
- const options = {
901
- body: data.body,
902
- icon: data.icon || PUSH_CONFIG.defaultIcon,
903
- badge: data.badge || PUSH_CONFIG.defaultBadge,
904
- vibrate: data.vibrate || [100, 50, 100],
905
- data: {
906
- url: data.url || '/',
907
- ...data.data,
908
- },
909
- actions: data.actions || [],
910
- tag: data.tag,
911
- renotify: data.renotify || false,
912
- requireInteraction: data.requireInteraction || false,
913
- silent: data.silent || false,
914
- };
915
-
916
- event.waitUntil(
917
- self.registration.showNotification(data.title, options)
918
- );
919
- });
920
-
921
- /**
922
- * Notification click event - handle notification interactions
923
- */
924
- self.addEventListener('notificationclick', (event) => {
925
- console.log('[SW] Notification clicked:', event.action);
926
- event.notification.close();
927
-
928
- const url = event.notification.data?.url || '/';
929
-
930
- event.waitUntil(
931
- clients.matchAll({ type: 'window', includeUncontrolled: true }).then((windowClients) => {
932
- // Check if there's already a window open with this URL
933
- for (const client of windowClients) {
934
- if (client.url === url && 'focus' in client) {
935
- return client.focus();
936
- }
937
- }
938
- // Open a new window
939
- if (clients.openWindow) {
940
- return clients.openWindow(url);
941
- }
942
- })
943
- );
944
- });
945
-
946
- /**
947
- * Notification close event
948
- */
949
- self.addEventListener('notificationclose', (event) => {
950
- console.log('[SW] Notification closed');
951
-
952
- // Track notification dismissal if needed
953
- const data = event.notification.data;
954
- if (data?.trackDismiss) {
955
- // Could send analytics here
956
- }
957
- });
958
- `}function Kj(){return`
959
- /**
960
- * Background sync queue storage (IndexedDB)
961
- */
962
- const SYNC_STORE = 'stx-sync-store';
963
- let syncDb = null;
964
-
965
- async function getSyncDb() {
966
- if (syncDb) return syncDb;
967
-
968
- return new Promise((resolve, reject) => {
969
- const request = indexedDB.open(SYNC_STORE, 1);
970
-
971
- request.onerror = () => reject(request.error);
972
- request.onsuccess = () => {
973
- syncDb = request.result;
974
- resolve(syncDb);
975
- };
976
-
977
- request.onupgradeneeded = (event) => {
978
- const db = event.target.result;
979
- if (!db.objectStoreNames.contains('queue')) {
980
- db.createObjectStore('queue', { keyPath: 'id', autoIncrement: true });
981
- }
982
- };
983
- });
984
- }
985
-
986
- /**
987
- * Add request to sync queue
988
- */
989
- async function addToSyncQueue(request) {
990
- const db = await getSyncDb();
991
- const tx = db.transaction('queue', 'readwrite');
992
- const store = tx.objectStore('queue');
993
-
994
- const data = {
995
- url: request.url,
996
- method: request.method,
997
- headers: Object.fromEntries(request.headers.entries()),
998
- body: await request.clone().text(),
999
- timestamp: Date.now(),
1000
- retries: 0,
1001
- };
1002
-
1003
- return new Promise((resolve, reject) => {
1004
- const req = store.add(data);
1005
- req.onsuccess = () => resolve(req.result);
1006
- req.onerror = () => reject(req.error);
1007
- });
1008
- }
1009
-
1010
- /**
1011
- * Get all pending sync requests
1012
- */
1013
- async function getPendingSyncRequests() {
1014
- const db = await getSyncDb();
1015
- const tx = db.transaction('queue', 'readonly');
1016
- const store = tx.objectStore('queue');
1017
-
1018
- return new Promise((resolve, reject) => {
1019
- const req = store.getAll();
1020
- req.onsuccess = () => resolve(req.result);
1021
- req.onerror = () => reject(req.error);
1022
- });
1023
- }
1024
-
1025
- /**
1026
- * Remove request from sync queue
1027
- */
1028
- async function removeSyncRequest(id) {
1029
- const db = await getSyncDb();
1030
- const tx = db.transaction('queue', 'readwrite');
1031
- const store = tx.objectStore('queue');
1032
-
1033
- return new Promise((resolve, reject) => {
1034
- const req = store.delete(id);
1035
- req.onsuccess = () => resolve();
1036
- req.onerror = () => reject(req.error);
1037
- });
1038
- }
1039
-
1040
- /**
1041
- * Update sync request retry count
1042
- */
1043
- async function updateSyncRetries(id, retries) {
1044
- const db = await getSyncDb();
1045
- const tx = db.transaction('queue', 'readwrite');
1046
- const store = tx.objectStore('queue');
1047
-
1048
- const req = store.get(id);
1049
- req.onsuccess = () => {
1050
- const data = req.result;
1051
- if (data) {
1052
- data.retries = retries;
1053
- store.put(data);
1054
- }
1055
- };
1056
- }
1057
-
1058
- /**
1059
- * Sync event - process queued requests when online
1060
- */
1061
- self.addEventListener('sync', (event) => {
1062
- console.log('[SW] Sync event:', event.tag);
1063
-
1064
- if (event.tag === SYNC_CONFIG.queueName || event.tag === 'stx-form-sync') {
1065
- event.waitUntil(processBackgroundSync());
1066
- }
1067
- });
1068
-
1069
- /**
1070
- * Process all queued sync requests
1071
- */
1072
- async function processBackgroundSync() {
1073
- console.log('[SW] Processing background sync queue');
1074
-
1075
- const requests = await getPendingSyncRequests();
1076
- console.log('[SW] Pending sync requests:', requests.length);
1077
-
1078
- for (const request of requests) {
1079
- if (request.retries >= SYNC_CONFIG.maxRetries) {
1080
- console.log('[SW] Max retries reached, removing:', request.url);
1081
- await removeSyncRequest(request.id);
1082
- continue;
1083
- }
1084
-
1085
- try {
1086
- const response = await fetch(request.url, {
1087
- method: request.method,
1088
- headers: request.headers,
1089
- body: request.method !== 'GET' ? request.body : undefined,
1090
- });
1091
-
1092
- if (response.ok) {
1093
- console.log('[SW] Sync succeeded:', request.url);
1094
- await removeSyncRequest(request.id);
1095
-
1096
- // Notify clients of successful sync
1097
- const clients = await self.clients.matchAll();
1098
- clients.forEach(client => {
1099
- client.postMessage({
1100
- type: 'SYNC_COMPLETE',
1101
- url: request.url,
1102
- success: true,
1103
- });
1104
- });
1105
- }
1106
- else {
1107
- throw new Error('Response not ok: ' + response.status);
1108
- }
1109
- }
1110
- catch (error) {
1111
- console.log('[SW] Sync failed, will retry:', request.url, error.message);
1112
- await updateSyncRetries(request.id, request.retries + 1);
1113
- }
1114
- }
1115
- }
1116
-
1117
- /**
1118
- * Register a form for background sync
1119
- * Called from main thread via message
1120
- */
1121
- async function registerFormSync(formData) {
1122
- // Store form data in IndexedDB
1123
- await addToSyncQueue({
1124
- url: formData.action,
1125
- method: formData.method || 'POST',
1126
- headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
1127
- clone: () => ({ text: async () => new URLSearchParams(formData.data).toString() }),
1128
- });
1129
-
1130
- // Register for background sync
1131
- await self.registration.sync.register(SYNC_CONFIG.queueName);
1132
- }
1133
-
1134
- // Listen for form sync requests
1135
- self.addEventListener('message', (event) => {
1136
- if (event.data?.type === 'REGISTER_FORM_SYNC') {
1137
- event.waitUntil(registerFormSync(event.data.payload));
1138
- }
1139
- });
1140
- `}function z(j){return j.pwa?.serviceWorker?.fileName||"sw.js"}function C(j){return j.pwa?.enabled===!0&&j.pwa?.serviceWorker?.useWorkbox===!0}function Qj(j,q){if(!j.pwa?.enabled)return"";if(C(j)){let{generateWorkboxServiceWorker:K}=(d(),v(x));return K(j,q)}return y(j,q)}var H=G(()=>{F()});H();function I(j){let q=j.pwa;if(!q?.enabled)return"";let K=q.manifest,Q=q.icons?.outputDir?`/${q.icons.outputDir}`:"/pwa-icons",Y=z(j),X=`
1141
- <!-- stx PWA Meta Tags -->
1142
- <link rel="manifest" href="/manifest.json">
1143
- <meta name="theme-color" content="${N(K?.themeColor||"#000000")}">
1144
- <meta name="mobile-web-app-capable" content="yes">
1145
- <meta name="apple-mobile-web-app-capable" content="yes">
1146
- <meta name="apple-mobile-web-app-status-bar-style" content="default">
1147
- <meta name="apple-mobile-web-app-title" content="${N(K?.shortName||K?.name||"App")}">`;if(q.icons?.generateAppleIcons!==!1)X+=`
1148
- <link rel="apple-touch-icon" href="${Q}/apple-touch-icon.png">
1149
- <link rel="apple-touch-icon" sizes="120x120" href="${Q}/apple-touch-icon-120x120.png">
1150
- <link rel="apple-touch-icon" sizes="152x152" href="${Q}/apple-touch-icon-152x152.png">
1151
- <link rel="apple-touch-icon" sizes="167x167" href="${Q}/apple-touch-icon-167x167.png">
1152
- <link rel="apple-touch-icon" sizes="180x180" href="${Q}/apple-touch-icon-180x180.png">`;return X+=`
1153
- <link rel="icon" type="image/png" sizes="32x32" href="${Q}/favicon-32x32.png">
1154
- <link rel="icon" type="image/png" sizes="16x16" href="${Q}/favicon-16x16.png">
1155
- <link rel="icon" type="image/png" sizes="192x192" href="${Q}/icon-192x192.png">`,X+=`
1156
- <!-- stx Service Worker Registration -->
1157
- <script>
1158
- if ('serviceWorker' in navigator) {
1159
- window.addEventListener('load', function() {
1160
- navigator.serviceWorker.register('/${Y}')
1161
- .then(function(registration) {
1162
- console.log('[PWA] Service Worker registered:', registration.scope);
1163
-
1164
- // Check for updates
1165
- registration.addEventListener('updatefound', function() {
1166
- const newWorker = registration.installing;
1167
- if (newWorker) {
1168
- newWorker.addEventListener('statechange', function() {
1169
- if (newWorker.state === 'installed' && navigator.serviceWorker.controller) {
1170
- console.log('[PWA] New content available, refresh to update');
1171
- // Optionally dispatch a custom event for UI notification
1172
- window.dispatchEvent(new CustomEvent('pwa-update-available'));
1173
- }
1174
- });
1175
- }
1176
- });
1177
- })
1178
- .catch(function(error) {
1179
- console.error('[PWA] Service Worker registration failed:', error);
1180
- });
1181
- });
1182
- }
1183
- </script>
1184
- <!-- End stx PWA -->`,X}function Aj(j,q){let K=q.pwa;if(!K?.enabled||K.autoInject===!1)return j;if(j.includes("<!-- stx PWA Meta Tags -->"))return j;if(!j.includes("</head>")){let Y=j.lastIndexOf("</body>");if(Y!==-1){let X=I(q);return j.slice(0,Y)+X+`
1185
- `+j.slice(Y)}return j+I(q)}let Q=I(q);return j.replace("</head>",`${Q}
1186
- </head>`)}function Bj(j){if(!j.pwa?.enabled)return"";return`<script>
1187
- if ('serviceWorker' in navigator) {
1188
- window.addEventListener('load', function() {
1189
- navigator.serviceWorker.register('/${z(j)}')
1190
- .then(function(registration) {
1191
- console.log('[PWA] Service Worker registered:', registration.scope);
1192
- })
1193
- .catch(function(error) {
1194
- console.error('[PWA] Service Worker registration failed:', error);
1195
- });
1196
- });
1197
- }
1198
- </script>`}function Gj(){return'<link rel="manifest" href="/manifest.json">'}function Jj(j){return`<meta name="theme-color" content="${N(j)}">`}function N(j){return j.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}
1199
- export{U as Wk,J as Xk,E as Yk,F as Zk,y as _k,z as $k,C as al,Qj as bl,H as cl,I as dl,Aj as el,Bj as fl,Gj as gl,Jj as hl};