@stacksjs/stx 0.2.454 → 0.2.455

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 (221) hide show
  1. package/dist/app-service-worker.d.ts +4 -1
  2. package/dist/chunk-06gzq9xe.js +17 -0
  3. package/dist/{chunk-yx37nrgr.js → chunk-0trfbqa7.js} +4 -4
  4. package/dist/{chunk-8ah8npj3.js → chunk-0v5dpk7r.js} +1 -1
  5. package/dist/{chunk-z68rb7qp.js → chunk-0vae943t.js} +5 -5
  6. package/dist/chunk-143gpdxy.js +2 -0
  7. package/dist/{chunk-w8ek4fe8.js → chunk-1sdtg9np.js} +2 -2
  8. package/dist/chunk-1vgmzmsw.js +2 -0
  9. package/dist/{chunk-aem9hs8n.js → chunk-1vm403b2.js} +2 -2
  10. package/dist/{chunk-7mbx7dzg.js → chunk-2bdthb37.js} +2 -2
  11. package/dist/{chunk-149r1q6c.js → chunk-2cy956js.js} +2 -2
  12. package/dist/chunk-2hddf9pn.js +2 -0
  13. package/dist/chunk-2jxe6y8h.js +2 -0
  14. package/dist/chunk-32t5agpk.js +2 -0
  15. package/dist/chunk-3ar8gdyd.js +2 -0
  16. package/dist/{chunk-697zcjzg.js → chunk-3jc6pahv.js} +12 -12
  17. package/dist/chunk-3s2vnqcf.js +2 -0
  18. package/dist/{chunk-hhjff2r8.js → chunk-44msrx2e.js} +3 -3
  19. package/dist/{chunk-0tchj3ct.js → chunk-462jmw0a.js} +6 -6
  20. package/dist/chunk-4bd491yq.js +2 -0
  21. package/dist/{chunk-g8k5rsqq.js → chunk-4fa3jec9.js} +12 -12
  22. package/dist/chunk-4henqdjf.js +2 -0
  23. package/dist/chunk-4qv9me8f.js +2 -0
  24. package/dist/chunk-561yczfn.js +2 -0
  25. package/dist/chunk-58n62bxb.js +3 -0
  26. package/dist/chunk-5m8q7c5r.js +2 -0
  27. package/dist/{chunk-pkpmyr0x.js → chunk-5p56w2ke.js} +3 -3
  28. package/dist/chunk-5pjsc9zv.js +3 -0
  29. package/dist/{chunk-n9jn3qzw.js → chunk-5qns2sdz.js} +2 -2
  30. package/dist/{chunk-2428rqy1.js → chunk-5ryntw3w.js} +6 -6
  31. package/dist/chunk-68dsxv8z.js +2 -0
  32. package/dist/chunk-68txmj8d.js +2 -0
  33. package/dist/{chunk-45rfv3a5.js → chunk-6cp3afft.js} +2 -2
  34. package/dist/chunk-6nec76z0.js +2 -0
  35. package/dist/chunk-6qv189mb.js +2 -0
  36. package/dist/{chunk-dwp3knc4.js → chunk-6r2709dj.js} +3 -3
  37. package/dist/chunk-77hanm4y.js +2 -0
  38. package/dist/chunk-7tt84v1y.js +3 -0
  39. package/dist/chunk-8efg91ak.js +4 -0
  40. package/dist/chunk-8nd0f6z0.js +2 -0
  41. package/dist/{chunk-73h7qjgq.js → chunk-8xz8t9xp.js} +2 -2
  42. package/dist/{chunk-qbhbe9cw.js → chunk-9ac40ggt.js} +5 -5
  43. package/dist/chunk-9mtz7tyv.js +2 -0
  44. package/dist/chunk-9t50hw97.js +2 -0
  45. package/dist/chunk-9z22zs86.js +2 -0
  46. package/dist/chunk-a32kqsff.js +2 -0
  47. package/dist/{chunk-19h1j59a.js → chunk-ab56jdah.js} +1 -1
  48. package/dist/chunk-adjf8fvc.js +3 -0
  49. package/dist/{chunk-33xh91s8.js → chunk-am1hw771.js} +2 -2
  50. package/dist/chunk-bpzrfqvw.js +2 -0
  51. package/dist/{chunk-0xztxj98.js → chunk-bq2e9qf6.js} +3 -3
  52. package/dist/{chunk-hqywyyez.js → chunk-c491hsm1.js} +5 -5
  53. package/dist/chunk-czvkkrww.js +2 -0
  54. package/dist/{chunk-jn8tj4kn.js → chunk-d3mpxr3s.js} +4 -4
  55. package/dist/{chunk-849wf19d.js → chunk-dxxs52yw.js} +3 -3
  56. package/dist/chunk-e78ame3h.js +2 -0
  57. package/dist/chunk-ef0gstkd.js +2 -0
  58. package/dist/{chunk-zqzv5jy2.js → chunk-exgyf65a.js} +4 -4
  59. package/dist/{chunk-538h1sfc.js → chunk-f4c39nfh.js} +2 -2
  60. package/dist/{chunk-3nydw825.js → chunk-fen7zb1b.js} +8 -8
  61. package/dist/{chunk-s5drjm2j.js → chunk-gkqxnetc.js} +6 -6
  62. package/dist/{chunk-47jq9j1w.js → chunk-gyv7dcyx.js} +2 -2
  63. package/dist/{chunk-axydabse.js → chunk-h9e032kq.js} +3 -3
  64. package/dist/chunk-ha5z623e.js +2 -0
  65. package/dist/chunk-hehtgsrt.js +2 -0
  66. package/dist/{chunk-3pc22sve.js → chunk-hg7abc58.js} +6 -6
  67. package/dist/chunk-hjg3e338.js +2 -0
  68. package/dist/chunk-hqsgp9wy.js +2 -0
  69. package/dist/chunk-hqzq3a61.js +2 -0
  70. package/dist/chunk-hskrxdcc.js +2 -0
  71. package/dist/chunk-hvx3pc13.js +2 -0
  72. package/dist/{chunk-9zbjk8pg.js → chunk-jckvavdb.js} +8 -8
  73. package/dist/chunk-jdhs9w6h.js +2 -0
  74. package/dist/{chunk-4q366fhp.js → chunk-jpgma7e8.js} +5 -5
  75. package/dist/chunk-jtmfwhsy.js +11 -0
  76. package/dist/{chunk-dqr5n49p.js → chunk-jz7pvh7b.js} +2 -2
  77. package/dist/chunk-kcs71ks8.js +2 -0
  78. package/dist/chunk-kda62f5h.js +2 -0
  79. package/dist/{chunk-26wmppja.js → chunk-kppgyqwb.js} +1 -1
  80. package/dist/chunk-kwct777t.js +2831 -0
  81. package/dist/chunk-m7p98cmy.js +4 -0
  82. package/dist/chunk-mbapk9ka.js +2 -0
  83. package/dist/chunk-me5039d4.js +2 -0
  84. package/dist/{chunk-fmj4xvqm.js → chunk-mhpsz5m0.js} +5 -5
  85. package/dist/{chunk-b1q5sh7x.js → chunk-n1dyjhte.js} +3 -3
  86. package/dist/{chunk-mnz6bdp3.js → chunk-n866vbgj.js} +5 -5
  87. package/dist/chunk-n8hd5qap.js +2 -0
  88. package/dist/{chunk-s59r34p5.js → chunk-nmf12mx3.js} +4 -4
  89. package/dist/chunk-nqvb9094.js +2 -0
  90. package/dist/chunk-p4zeqzmr.js +2 -0
  91. package/dist/chunk-pcp5twev.js +2 -0
  92. package/dist/chunk-pe214qcn.js +2 -0
  93. package/dist/{chunk-4yyzje7d.js → chunk-pw34r8r5.js} +1 -1
  94. package/dist/{chunk-81v9crqy.js → chunk-q8ttp85g.js} +1 -1
  95. package/dist/chunk-q98v7bhs.js +2 -0
  96. package/dist/chunk-qhwvjsbx.js +2 -0
  97. package/dist/chunk-qrgr2h1n.js +2 -0
  98. package/dist/{chunk-5xj1df83.js → chunk-r6pax860.js} +7 -7
  99. package/dist/{chunk-rdq113p4.js → chunk-r80km6mn.js} +2 -2
  100. package/dist/{chunk-tehvry9a.js → chunk-rcr57c30.js} +10 -10
  101. package/dist/{chunk-8fj8sm1a.js → chunk-ree9weje.js} +2 -2
  102. package/dist/{chunk-x4ztj64h.js → chunk-rgwvqmhh.js} +2 -2
  103. package/dist/chunk-rsj5q7zm.js +2 -0
  104. package/dist/{chunk-tn85vr56.js → chunk-rvgvt161.js} +2 -2
  105. package/dist/chunk-rwx1s3b5.js +2 -0
  106. package/dist/chunk-rzmvsqc7.js +2 -0
  107. package/dist/{chunk-rbkna5rw.js → chunk-skgdg84c.js} +11 -11
  108. package/dist/{chunk-yfd0e7dr.js → chunk-tbjyp03h.js} +1 -1
  109. package/dist/chunk-tmn8hxm6.js +2 -0
  110. package/dist/{chunk-g2afpsw0.js → chunk-tpeyn7wr.js} +2 -2
  111. package/dist/{chunk-s6e8mmk1.js → chunk-tpvc8xnk.js} +6 -6
  112. package/dist/chunk-tr7dz5g5.js +2 -0
  113. package/dist/{chunk-5cyme1g0.js → chunk-v3yqeh15.js} +2 -2
  114. package/dist/{chunk-9ndzk9r4.js → chunk-vg7wfkt5.js} +3 -3
  115. package/dist/chunk-vrvnctex.js +2 -0
  116. package/dist/chunk-w00khg58.js +2 -0
  117. package/dist/chunk-w1h9ts86.js +2 -0
  118. package/dist/{chunk-afhkvj3k.js → chunk-w1zvh5y7.js} +2 -2
  119. package/dist/chunk-w62ettpr.js +2 -0
  120. package/dist/{chunk-b5wh10s9.js → chunk-xd71zy8q.js} +78 -78
  121. package/dist/chunk-xe90p9rp.js +2 -0
  122. package/dist/{chunk-56rk985x.js → chunk-y3cqh2jv.js} +3 -3
  123. package/dist/{chunk-0vbpcef6.js → chunk-z2daw0th.js} +4 -4
  124. package/dist/{chunk-nw8p8eg9.js → chunk-z3etxty5.js} +5 -5
  125. package/dist/{chunk-vraddzkf.js → chunk-z6tag2ng.js} +4 -4
  126. package/dist/{chunk-g3h7j2n7.js → chunk-z80d9dd2.js} +2 -2
  127. package/dist/chunk-z990jtmx.js +2 -0
  128. package/dist/chunk-zjp0v2ja.js +33 -0
  129. package/dist/{chunk-d1xbamr1.js → chunk-znj79hta.js} +2 -2
  130. package/dist/chunk-zrbpy3m5.js +2 -0
  131. package/dist/{chunk-jwpcck1b.js → chunk-zydg3wgt.js} +2 -2
  132. package/dist/cli.js +20 -20
  133. package/dist/client-script.d.ts +0 -21
  134. package/dist/client-script.js +21 -0
  135. package/dist/composable-loader.js +41 -17
  136. package/dist/compression.js +25 -6
  137. package/dist/craft-entry.js +2 -2
  138. package/dist/craft.js +2 -2
  139. package/dist/html-masking.js +36 -8
  140. package/dist/i18n.js +4 -3
  141. package/dist/includes.js +6 -2
  142. package/dist/misc-directives.d.ts +0 -10
  143. package/dist/misc-directives.js +12 -0
  144. package/dist/offline/app-service-worker.d.ts +4 -1
  145. package/dist/offline/app-service-worker.js +62 -27
  146. package/dist/process.js +4 -0
  147. package/dist/pwa.js +3 -3
  148. package/dist/source-signature.d.ts +5 -2
  149. package/dist/source-signature.js +7 -0
  150. package/dist/ssg.js +8 -8
  151. package/dist/store-loader.js +2 -1
  152. package/dist/utils.js +27 -15
  153. package/package.json +5 -5
  154. package/dist/chunk-14x69rt4.js +0 -2
  155. package/dist/chunk-1kmd0g1k.js +0 -3
  156. package/dist/chunk-3wezvz6m.js +0 -2
  157. package/dist/chunk-5402rpwg.js +0 -2
  158. package/dist/chunk-58ymq1h4.js +0 -2
  159. package/dist/chunk-5rtbs8zv.js +0 -2
  160. package/dist/chunk-5tx1wqns.js +0 -2
  161. package/dist/chunk-6fw3rfcj.js +0 -2
  162. package/dist/chunk-6nfecsbt.js +0 -2
  163. package/dist/chunk-6sw7sxh2.js +0 -17
  164. package/dist/chunk-7qbv0xh6.js +0 -2
  165. package/dist/chunk-7vdsd9rn.js +0 -2
  166. package/dist/chunk-8gk34047.js +0 -2
  167. package/dist/chunk-8nsfkr5n.js +0 -2
  168. package/dist/chunk-90562q79.js +0 -3
  169. package/dist/chunk-a1dggchm.js +0 -2
  170. package/dist/chunk-a1kv42kp.js +0 -2
  171. package/dist/chunk-a5695s8k.js +0 -2
  172. package/dist/chunk-avjgetkh.js +0 -2
  173. package/dist/chunk-bcgth8qf.js +0 -2
  174. package/dist/chunk-bemksdz5.js +0 -33
  175. package/dist/chunk-br3ktpyq.js +0 -2
  176. package/dist/chunk-by1s70jp.js +0 -2
  177. package/dist/chunk-cwc3p6p7.js +0 -2
  178. package/dist/chunk-e593pr1r.js +0 -2
  179. package/dist/chunk-e8y69gg0.js +0 -2
  180. package/dist/chunk-eam7eann.js +0 -2
  181. package/dist/chunk-ej7m406s.js +0 -2
  182. package/dist/chunk-es85mgdw.js +0 -2
  183. package/dist/chunk-fa5x9zbk.js +0 -2
  184. package/dist/chunk-fkrzsk74.js +0 -2
  185. package/dist/chunk-fm3k5v8s.js +0 -2
  186. package/dist/chunk-fmc9fj4a.js +0 -2
  187. package/dist/chunk-fn863yek.js +0 -2
  188. package/dist/chunk-fv30avp2.js +0 -2
  189. package/dist/chunk-gpmk4s4f.js +0 -2
  190. package/dist/chunk-hd64hz1n.js +0 -2
  191. package/dist/chunk-hd75916k.js +0 -4
  192. package/dist/chunk-hz6a476h.js +0 -2
  193. package/dist/chunk-j7zywbq0.js +0 -4
  194. package/dist/chunk-jjm3754f.js +0 -2
  195. package/dist/chunk-ktk30f6d.js +0 -2
  196. package/dist/chunk-m3f50p6c.js +0 -2
  197. package/dist/chunk-m90a5dpn.js +0 -2
  198. package/dist/chunk-mmp7x8f0.js +0 -2
  199. package/dist/chunk-nqcg2bf0.js +0 -2
  200. package/dist/chunk-nrp8qg9j.js +0 -2831
  201. package/dist/chunk-ns7e951g.js +0 -2
  202. package/dist/chunk-nycvwnty.js +0 -2
  203. package/dist/chunk-p9shre7t.js +0 -2
  204. package/dist/chunk-pe9hxhrb.js +0 -2
  205. package/dist/chunk-ph6xg67j.js +0 -11
  206. package/dist/chunk-qewxfhex.js +0 -2
  207. package/dist/chunk-qfrg8mnf.js +0 -2
  208. package/dist/chunk-rmnhy5az.js +0 -2
  209. package/dist/chunk-t6m5wmpy.js +0 -2
  210. package/dist/chunk-v404gvm0.js +0 -2
  211. package/dist/chunk-vgvsefz8.js +0 -2
  212. package/dist/chunk-w9k7pvre.js +0 -2
  213. package/dist/chunk-wf09xg7j.js +0 -2
  214. package/dist/chunk-wgqt5pnv.js +0 -2
  215. package/dist/chunk-wr3h8dmt.js +0 -2
  216. package/dist/chunk-wtqjfar3.js +0 -2
  217. package/dist/chunk-x1xncm97.js +0 -2
  218. package/dist/chunk-yd50awqp.js +0 -3
  219. package/dist/chunk-ykxd78b2.js +0 -2
  220. package/dist/chunk-yqsza22w.js +0 -3
  221. package/dist/chunk-zj80vrv6.js +0 -2
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import{jr,Co,$o}from"./chunk-hhjff2r8.js";import"./chunk-5xj1df83.js";import"./chunk-73h7qjgq.js";import"./chunk-s59r34p5.js";import"./chunk-afhkvj3k.js";import"./chunk-axydabse.js";import"./chunk-nrp8qg9j.js";import"./chunk-zqzv5jy2.js";import"./chunk-g8k5rsqq.js";import"./chunk-jwpcck1b.js";import"./chunk-aem9hs8n.js";import"./chunk-dqr5n49p.js";import"./chunk-yx37nrgr.js";import{au,yo,cu,lu,bo,Lr,wo,uu,vo,du,pu,xo,So,ko}from"./chunk-rbkna5rw.js";import"./chunk-vraddzkf.js";import"./chunk-0xztxj98.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
2
+ import{Br,$o,Eo}from"./chunk-44msrx2e.js";import"./chunk-r6pax860.js";import"./chunk-8xz8t9xp.js";import"./chunk-nmf12mx3.js";import"./chunk-w1zvh5y7.js";import"./chunk-h9e032kq.js";import"./chunk-kwct777t.js";import"./chunk-exgyf65a.js";import"./chunk-4fa3jec9.js";import"./chunk-zydg3wgt.js";import"./chunk-1vm403b2.js";import"./chunk-jz7pvh7b.js";import"./chunk-0trfbqa7.js";import{cu,bo,lu,uu,wo,jr,vo,du,xo,pu,fu,So,ko,Co}from"./chunk-skgdg84c.js";import"./chunk-z6tag2ng.js";import"./chunk-bq2e9qf6.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
3
3
  `),scripts:t.scripts.join(`
4
4
  `),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
5
5
  `),scripts:t.scripts.join(`
6
6
  `),hydrationData:i,metadata:{renderTime:s,cacheHit:!1,totalSize:a.length,componentCount:t.metadata.componentCount}}}function V(t,e){let n=[],r=[],a=[],i=new Map,s=[];return y(t.tree,(o,c)=>{if(o.type==="component"&&o.componentName){if(T(o.componentName))n.push(o.componentName)}if(o.type==="element"&&o.tag){let p=J(o);if(p)s.push(p);if(o.props){for(let[l,f]of Object.entries(o.props))if(l.startsWith("on")&&typeof f==="string"){let g=`handler_${i.size}`;i.set(g,f)}}}if(o.isStatic&&o.type==="element")r.push(b(o));else if(!o.isStatic&&o.type!=="text")a.push(o.tag||o.componentName||"unknown")}),{nativeComponents:n,staticHTML:r,dynamicParts:a,eventHandlers:i,nativeWidgets:s}}function Y(t,e={}){let n=R(t),r=P(n,e),a=new Map,i=[];return y(n.tree,(s)=>{if(s.type==="component"&&s.componentName){if(T(s.componentName)){i.push(s.componentName);let o=`<!--craft:${s.componentName}:${s.hydrationKey||"default"}-->`;a.set(s.hydrationKey||s.componentName,o)}}}),{staticHTML:r,dynamicPlaceholders:a,craftComponents:i}}function M(t){let e={type:"fragment",children:[]},n=e,r=[e],a=t,i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);while(a.length>0){let s=a.match(/^<(@?[\w-]+)([^>]*)>/);if(s){let[p,l,f]=s,g=z(f),u=l.startsWith("@craft-"),C=u?l:l.toLowerCase(),S={type:u?"component":"element",tag:C,props:g,children:[],componentName:u?C.slice(1):void 0,isStatic:!v(f),hydrationKey:F()};if(n.children=n.children||[],n.children.push(S),!i.has(C)&&!f.endsWith("/"))r.push(S),n=S;a=a.slice(p.length);continue}let o=a.match(/^<\/(@?[\w-]+)>/);if(o){let[p,l]=o,g=l.startsWith("@craft-")?l:l.toLowerCase();while(r.length>1){let u=r.pop();if(n=r[r.length-1],u.tag===g)break}a=a.slice(p.length);continue}let c=a.match(/^[^<]+/);if(c){let p=c[0];if(p.trim()){let l={type:"text",text:p,isStatic:!v(p)};n.children=n.children||[],n.children.push(l)}a=a.slice(p.length);continue}a=a.slice(1)}return e}function z(t){let e={},n=/([\w-:@]+)(?:=(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,r;while((r=n.exec(t))!==null){let[,a,i,s,o]=r,c=i??s??o??!0;e[a]=c}return e}function y(t,e,n=[]){if(e(t,n),t.children)t.children.forEach((r,a)=>{y(r,e,[...n,`${a}`])})}function h(t,e){switch(t.type){case"text":return x(t.text||"",e);case"element":case"component":{let n=t.tag||"div",r=N(t.props||{},e),a=(t.children||[]).map((i)=>h(i,e)).join("");if(!t.children||t.children.length===0){if(["input","br","hr","img","meta","link"].includes(n))return`<${n}${r} />`}return`<${n}${r}>${a}</${n}>`}case"fragment":return(t.children||[]).map((n)=>h(n,e)).join("");case"slot":return`<!--slot:${t.slotName||"default"}-->`;default:return""}}function b(t){if(t.type==="text")return t.text||"";let e=t.tag||"div",n=N(t.props||{},{});return`<${e}${n}></${e}>`}function N(t,e){let n=[];for(let[r,a]of Object.entries(t))if(a===!0)n.push(` ${r}`);else if(a!==!1&&a!==null&&a!==void 0){let i=x(String(a),e);n.push(` ${r}="${k(i)}"`)}return n.join("")}async function H(t,e){return h(t,e)}function P(t,e){let n=[];return y(t.tree,(r)=>{if(r.isStatic)n.push(h(r,e))}),n.join("")}function j(t,e,n){let r={templateId:e.id,context:n,dynamicParts:Array.from(e.dynamicParts.entries())},a=`
7
7
  <script data-craft-hydration>
8
8
  window.__CRAFT_HYDRATION__ = ${JSON.stringify(r)};
9
- </script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{au as CRAFT_BRIDGE_SCRIPT,Lr as CRAFT_COMPONENTS,uu as CRAFT_COMPONENT_RUNTIME,wo as CRAFT_COMPONENT_STYLES,jr as NATIVE_COMPONENTS,xo as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Co as compileToNative,$o as createHotReloadServer,yo as generateCraftBridgeScript,V as generateCraftOptimizations,ko as getAvailableFormats,So as getAvailableTargets,pu as getCraftComponents,G as getSSRCacheStats,bo as injectCraftBridge,cu as isCraftEnvironment,Y as prerenderForCraft,vo as processCraftComponents,lu as processCraftDirective,du as registerCraftComponent,Q as renderSSR};
9
+ </script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{cu as CRAFT_BRIDGE_SCRIPT,jr as CRAFT_COMPONENTS,du as CRAFT_COMPONENT_RUNTIME,vo as CRAFT_COMPONENT_STYLES,Br as NATIVE_COMPONENTS,So as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,$o as compileToNative,Eo as createHotReloadServer,bo as generateCraftBridgeScript,V as generateCraftOptimizations,Co as getAvailableFormats,ko as getAvailableTargets,fu as getCraftComponents,G as getSSRCacheStats,wo as injectCraftBridge,lu as isCraftEnvironment,Y as prerenderForCraft,xo as processCraftComponents,uu as processCraftDirective,pu as registerCraftComponent,Q as renderSSR};
package/dist/craft.js CHANGED
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import{jr,Co,$o}from"./chunk-hhjff2r8.js";import"./chunk-5xj1df83.js";import"./chunk-73h7qjgq.js";import"./chunk-s59r34p5.js";import"./chunk-afhkvj3k.js";import"./chunk-axydabse.js";import"./chunk-nrp8qg9j.js";import"./chunk-zqzv5jy2.js";import"./chunk-g8k5rsqq.js";import"./chunk-jwpcck1b.js";import"./chunk-aem9hs8n.js";import"./chunk-dqr5n49p.js";import"./chunk-yx37nrgr.js";import{au,yo,cu,lu,bo,Lr,wo,uu,vo,du,pu,xo,So,ko}from"./chunk-rbkna5rw.js";import"./chunk-vraddzkf.js";import"./chunk-0xztxj98.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
2
+ import{Br,$o,Eo}from"./chunk-44msrx2e.js";import"./chunk-r6pax860.js";import"./chunk-8xz8t9xp.js";import"./chunk-nmf12mx3.js";import"./chunk-w1zvh5y7.js";import"./chunk-h9e032kq.js";import"./chunk-kwct777t.js";import"./chunk-exgyf65a.js";import"./chunk-4fa3jec9.js";import"./chunk-zydg3wgt.js";import"./chunk-1vm403b2.js";import"./chunk-jz7pvh7b.js";import"./chunk-0trfbqa7.js";import{cu,bo,lu,uu,wo,jr,vo,du,xo,pu,fu,So,ko,Co}from"./chunk-skgdg84c.js";import"./chunk-z6tag2ng.js";import"./chunk-bq2e9qf6.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
3
3
  `),scripts:t.scripts.join(`
4
4
  `),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
5
5
  `),scripts:t.scripts.join(`
6
6
  `),hydrationData:i,metadata:{renderTime:s,cacheHit:!1,totalSize:a.length,componentCount:t.metadata.componentCount}}}function V(t,e){let n=[],r=[],a=[],i=new Map,s=[];return y(t.tree,(o,c)=>{if(o.type==="component"&&o.componentName){if(T(o.componentName))n.push(o.componentName)}if(o.type==="element"&&o.tag){let p=J(o);if(p)s.push(p);if(o.props){for(let[l,f]of Object.entries(o.props))if(l.startsWith("on")&&typeof f==="string"){let g=`handler_${i.size}`;i.set(g,f)}}}if(o.isStatic&&o.type==="element")r.push(b(o));else if(!o.isStatic&&o.type!=="text")a.push(o.tag||o.componentName||"unknown")}),{nativeComponents:n,staticHTML:r,dynamicParts:a,eventHandlers:i,nativeWidgets:s}}function Y(t,e={}){let n=R(t),r=P(n,e),a=new Map,i=[];return y(n.tree,(s)=>{if(s.type==="component"&&s.componentName){if(T(s.componentName)){i.push(s.componentName);let o=`<!--craft:${s.componentName}:${s.hydrationKey||"default"}-->`;a.set(s.hydrationKey||s.componentName,o)}}}),{staticHTML:r,dynamicPlaceholders:a,craftComponents:i}}function M(t){let e={type:"fragment",children:[]},n=e,r=[e],a=t,i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);while(a.length>0){let s=a.match(/^<(@?[\w-]+)([^>]*)>/);if(s){let[p,l,f]=s,g=z(f),u=l.startsWith("@craft-"),C=u?l:l.toLowerCase(),S={type:u?"component":"element",tag:C,props:g,children:[],componentName:u?C.slice(1):void 0,isStatic:!v(f),hydrationKey:F()};if(n.children=n.children||[],n.children.push(S),!i.has(C)&&!f.endsWith("/"))r.push(S),n=S;a=a.slice(p.length);continue}let o=a.match(/^<\/(@?[\w-]+)>/);if(o){let[p,l]=o,g=l.startsWith("@craft-")?l:l.toLowerCase();while(r.length>1){let u=r.pop();if(n=r[r.length-1],u.tag===g)break}a=a.slice(p.length);continue}let c=a.match(/^[^<]+/);if(c){let p=c[0];if(p.trim()){let l={type:"text",text:p,isStatic:!v(p)};n.children=n.children||[],n.children.push(l)}a=a.slice(p.length);continue}a=a.slice(1)}return e}function z(t){let e={},n=/([\w-:@]+)(?:=(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,r;while((r=n.exec(t))!==null){let[,a,i,s,o]=r,c=i??s??o??!0;e[a]=c}return e}function y(t,e,n=[]){if(e(t,n),t.children)t.children.forEach((r,a)=>{y(r,e,[...n,`${a}`])})}function h(t,e){switch(t.type){case"text":return x(t.text||"",e);case"element":case"component":{let n=t.tag||"div",r=N(t.props||{},e),a=(t.children||[]).map((i)=>h(i,e)).join("");if(!t.children||t.children.length===0){if(["input","br","hr","img","meta","link"].includes(n))return`<${n}${r} />`}return`<${n}${r}>${a}</${n}>`}case"fragment":return(t.children||[]).map((n)=>h(n,e)).join("");case"slot":return`<!--slot:${t.slotName||"default"}-->`;default:return""}}function b(t){if(t.type==="text")return t.text||"";let e=t.tag||"div",n=N(t.props||{},{});return`<${e}${n}></${e}>`}function N(t,e){let n=[];for(let[r,a]of Object.entries(t))if(a===!0)n.push(` ${r}`);else if(a!==!1&&a!==null&&a!==void 0){let i=x(String(a),e);n.push(` ${r}="${k(i)}"`)}return n.join("")}async function H(t,e){return h(t,e)}function P(t,e){let n=[];return y(t.tree,(r)=>{if(r.isStatic)n.push(h(r,e))}),n.join("")}function j(t,e,n){let r={templateId:e.id,context:n,dynamicParts:Array.from(e.dynamicParts.entries())},a=`
7
7
  <script data-craft-hydration>
8
8
  window.__CRAFT_HYDRATION__ = ${JSON.stringify(r)};
9
- </script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{au as CRAFT_BRIDGE_SCRIPT,Lr as CRAFT_COMPONENTS,uu as CRAFT_COMPONENT_RUNTIME,wo as CRAFT_COMPONENT_STYLES,jr as NATIVE_COMPONENTS,xo as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Co as compileToNative,$o as createHotReloadServer,yo as generateCraftBridgeScript,V as generateCraftOptimizations,ko as getAvailableFormats,So as getAvailableTargets,pu as getCraftComponents,G as getSSRCacheStats,bo as injectCraftBridge,cu as isCraftEnvironment,Y as prerenderForCraft,vo as processCraftComponents,lu as processCraftDirective,du as registerCraftComponent,Q as renderSSR};
9
+ </script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{cu as CRAFT_BRIDGE_SCRIPT,jr as CRAFT_COMPONENTS,du as CRAFT_COMPONENT_RUNTIME,vo as CRAFT_COMPONENT_STYLES,Br as NATIVE_COMPONENTS,So as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,$o as compileToNative,Eo as createHotReloadServer,bo as generateCraftBridgeScript,V as generateCraftOptimizations,Co as getAvailableFormats,ko as getAvailableTargets,fu as getCraftComponents,G as getSSRCacheStats,wo as injectCraftBridge,lu as isCraftEnvironment,Y as prerenderForCraft,xo as processCraftComponents,uu as processCraftDirective,pu as registerCraftComponent,Q as renderSSR};
@@ -133,16 +133,31 @@ export function evictOldest(cache, maxEntries) {
133
133
  cache.delete(oldest.value);
134
134
  }
135
135
  }
136
- const MASK_CACHE_MIN_BYTES = 65536, MASK_CACHE_MAX_ENTRIES = 12, maskCache = new Map;
136
+ const MASK_CACHE_MIN_BYTES = 1024, MASK_CACHE_MAX_CHARS = 16777216, maskCache = new Map;
137
+ let maskCacheChars = 0;
138
+ function rememberMask(key, entry) {
139
+ maskCache.set(key, entry);
140
+ maskCacheChars += key.length + entry.output.length;
141
+ for (const [oldest, kept] of maskCache) {
142
+ if (maskCacheChars <= MASK_CACHE_MAX_CHARS)
143
+ break;
144
+ maskCache.delete(oldest);
145
+ maskCacheChars -= oldest.length + kept.output.length;
146
+ }
147
+ }
137
148
  export function clearMaskCache() {
138
149
  maskCache.clear();
150
+ maskCacheChars = 0;
139
151
  }
140
152
  export function maskAtElementPosition(html, match, placeholder, cacheKey) {
141
153
  const cacheable = cacheKey !== void 0 && html.length >= MASK_CACHE_MIN_BYTES, key = cacheable ? `${cacheKey}\x00${html}` : "";
142
154
  if (cacheable) {
143
155
  const hit = maskCache.get(key);
144
- if (hit)
156
+ if (hit) {
157
+ maskCache.delete(key);
158
+ maskCache.set(key, hit);
145
159
  return { output: hit.output, tokens: hit.tokens.slice() };
160
+ }
146
161
  }
147
162
  const matches = scanAtElementPosition(html, match);
148
163
  if (matches.length === 0)
@@ -157,13 +172,23 @@ export function maskAtElementPosition(html, match, placeholder, cacheKey) {
157
172
  }
158
173
  output += html.slice(cursor);
159
174
  if (cacheable) {
160
- evictOldest(maskCache, MASK_CACHE_MAX_ENTRIES);
161
- maskCache.set(key, { output, tokens });
175
+ rememberMask(key, { output, tokens });
162
176
  return { output, tokens: tokens.slice() };
163
177
  }
164
178
  return { output, tokens };
165
179
  }
166
- const STASH_CACHE_MIN_BYTES = 65536, STASH_CACHE_MAX_ENTRIES = 4, stashCache = new Map;
180
+ const STASH_CACHE_MIN_BYTES = 1024, STASH_CACHE_MAX_CHARS = 16777216, stashCache = new Map;
181
+ let stashCacheChars = 0;
182
+ function rememberStash(html, entry) {
183
+ stashCache.set(html, entry);
184
+ stashCacheChars += html.length + entry.output.length;
185
+ for (const [oldest, kept] of stashCache) {
186
+ if (stashCacheChars <= STASH_CACHE_MAX_CHARS)
187
+ break;
188
+ stashCache.delete(oldest);
189
+ stashCacheChars -= oldest.length + kept.output.length;
190
+ }
191
+ }
167
192
  function stashResult(input, output, scripts) {
168
193
  return {
169
194
  output,
@@ -175,19 +200,22 @@ export function stashScriptElements(html) {
175
200
  const cacheable = html.length >= STASH_CACHE_MIN_BYTES;
176
201
  if (cacheable) {
177
202
  const hit = stashCache.get(html);
178
- if (hit)
203
+ if (hit) {
204
+ stashCache.delete(html);
205
+ stashCache.set(html, hit);
179
206
  return stashResult(html, hit.output, hit.scripts.slice());
207
+ }
180
208
  }
181
209
  const { output, tokens } = maskAtElementPosition(html, matchScriptElement, (_token, index) => `\x00STX_SCRIPT_${index}\x00`);
182
210
  if (cacheable) {
183
- evictOldest(stashCache, STASH_CACHE_MAX_ENTRIES);
184
- stashCache.set(html, { output, scripts: tokens });
211
+ rememberStash(html, { output, scripts: tokens });
185
212
  return stashResult(html, output, tokens.slice());
186
213
  }
187
214
  return stashResult(html, output, tokens);
188
215
  }
189
216
  export function clearStashCache() {
190
217
  stashCache.clear();
218
+ stashCacheChars = 0;
191
219
  }
192
220
  export function restoreStashedScripts(html, scripts) {
193
221
  if (scripts.length === 0)
package/dist/i18n.js CHANGED
@@ -170,9 +170,10 @@ async function loadTranslationInternal(locale, options) {
170
170
  sources: formatToSources(i18nConfig.format)
171
171
  }) : await loadTranslationFromFile(locale, i18nConfig, translationsDir);
172
172
  if (tree === void 0) {
173
- if (locale !== i18nConfig.defaultLocale)
174
- return loadTranslationInternal(i18nConfig.defaultLocale, options);
175
- return {};
173
+ const fallback = locale !== i18nConfig.defaultLocale ? await loadTranslationInternal(i18nConfig.defaultLocale, options) : {};
174
+ if (i18nConfig.cache)
175
+ translationsCache[locale] = { translations: fallback, loadedAt: Date.now(), locale };
176
+ return fallback;
176
177
  }
177
178
  const translations = tree;
178
179
  if (i18nConfig.cache)
package/dist/includes.js CHANGED
@@ -263,6 +263,10 @@ function addScopeToRootElement(html, scopeId) {
263
263
  return { html, mergedIntoExisting: null, stamped: !1, root: null };
264
264
  }
265
265
  let scopeIdCounter = 0;
266
+ function includeScopeId(includeFilePath, context) {
267
+ const name = path.basename(includeFilePath, ".stx").replace(/[^a-zA-Z0-9]/g, "_"), seq = context.__stx_scope_seq;
268
+ return seq ? `stx_scope_${name}_${++seq.n}_${seq.key}` : `stx_scope_${name}_${++scopeIdCounter}`;
269
+ }
266
270
  const warnedUnscopedSignalPartials = new Set;
267
271
  export function resetUnscopedSignalWarnings() {
268
272
  warnedUnscopedSignalPartials.clear();
@@ -658,7 +662,7 @@ export async function processIncludes(template, context, filePath, options, depe
658
662
  const isSignalScript = hasSignalApis(scriptContent);
659
663
  if (isSignalScript && !isServerScript) {
660
664
  declaresSignals = !0;
661
- signalScopeId = `stx_scope_${path.basename(includeFilePath, ".stx").replace(/[^a-zA-Z0-9]/g, "_")}_${++scopeIdCounter}`;
665
+ signalScopeId = includeScopeId(includeFilePath, context);
662
666
  const resolvedContent = transformStoreImports(scriptContent), transformedScript = transformScopedScript(resolvedContent, signalScopeId);
663
667
  preservedScript += `${vendorStyleTags}<script data-stx-scoped data-stx-run="always" data-stx-owner="${signalScopeId}">${transformedScript}</script>
664
668
  `;
@@ -674,7 +678,7 @@ export async function processIncludes(template, context, filePath, options, depe
674
678
  }
675
679
  if (!isServerScript && !isSignalScript) {
676
680
  const extraAttrs = scriptAttrs.replace(/\bclient\b/i, "").trim();
677
- signalScopeId = `stx_scope_${path.basename(includeFilePath, ".stx").replace(/[^a-zA-Z0-9]/g, "_")}_${++scopeIdCounter}`;
681
+ signalScopeId = includeScopeId(includeFilePath, context);
678
682
  const resolvedContent = transformStoreImports(scriptContent), wrapped = transformScopedScript(resolvedContent, signalScopeId);
679
683
  preservedScript += `${vendorStyleTags}<script data-stx-scoped data-stx-run="always" data-stx-owner="${signalScopeId}"${extraAttrs ? ` ${extraAttrs}` : ""}>${wrapped}</script>
680
684
  `;
@@ -43,15 +43,5 @@ export declare function processMemoDirective(template: string): string;
43
43
  export declare function processRefAttributes(template: string): string;
44
44
  /** Keep the caller of a projected ref explicit after slot content is flattened. */
45
45
  export declare function markProjectedRefs(template: string, receiver: string): string;
46
- /**
47
- * Add x-cloak to HTML elements whose own text contains an unresolved {{ }}
48
- * expression. Those were preserved for client-side evaluation (signals, loop
49
- * vars, etc.), and x-cloak hides them until the runtime binds and reveals them,
50
- * so the raw mustache never flashes.
51
- *
52
- * Only the element that actually holds the expression is stamped — see
53
- * `ownTextContainsMustache` for why that scoping is the fix rather than a refinement. An
54
- * element carrying `x-no-cloak` is left visible regardless.
55
- */
56
46
  export declare function addCloakToUnresolvedExpressions(html: string): string;
57
47
  export declare function addCloakToConditionalDirectives(html: string): string;
@@ -1,6 +1,7 @@
1
1
  import { errorLogger } from "./error-handling.js";
2
2
  import { mightContainOwnTextMustache, scanAtElementPosition } from "./html-masking.js";
3
3
  import { createSafeFunction, isExpressionSafe } from "./safe-evaluator.js";
4
+ import { contentKey, renderMemo } from "./render-memo.js";
4
5
  export function processJsonDirective(template, context) {
5
6
  let result = template;
6
7
  const jsonPat = /@json\s*\(/g;
@@ -274,7 +275,18 @@ function ownTextContainsMustache(html, contentStart) {
274
275
  }
275
276
  return !1;
276
277
  }
278
+ const cloakedByMarkup = renderMemo(256);
277
279
  export function addCloakToUnresolvedExpressions(html) {
280
+ if (html.length < 1024)
281
+ return addCloakToUnresolvedExpressionsUncached(html);
282
+ const key = contentKey(html), known = cloakedByMarkup.get(key);
283
+ if (known !== void 0)
284
+ return known;
285
+ const cloaked = addCloakToUnresolvedExpressionsUncached(html);
286
+ cloakedByMarkup.set(key, cloaked);
287
+ return cloaked;
288
+ }
289
+ function addCloakToUnresolvedExpressionsUncached(html) {
278
290
  if (html.length >= 32768 && !mightContainOwnTextMustache(html))
279
291
  return html;
280
292
  const tagStartRe = new RegExp(`<(${"div|span|p|h[1-6]|td|th|li|a|button|label|section|article|header|footer|main|nav|aside|dd|dt|figcaption|summary|caption|blockquote|pre|code|em|strong|small|sub|sup|time|mark|abbr|cite|q|s|u|b|i"})\\b`, "gi");
@@ -16,7 +16,10 @@
16
16
  * page stands in. The screens named in `pages` are fetched when the worker
17
17
  * installs, so they open offline even before they were visited, with the
18
18
  * stylesheets and scripts they link to. Kept per build: a fragment from
19
- * another build would make the router reload into nothing.
19
+ * another build would make the router reload into nothing. A kept copy
20
+ * whose module bundles (`/_stx/modules.<hash>.js`) are not kept too is not
21
+ * answered first, since a later server process cannot answer them and the
22
+ * page would never bind; it stands in only with no network at all.
20
23
  * - Dynamic screens named in `routes` (`/m/workout/:id`): one never opened is
21
24
  * answered offline with the route's kept page, its params swapped for the
22
25
  * ones asked for. For a page drawn on the device from the API, every value
@@ -588,6 +588,36 @@ function coldStartUpdate(request) {
588
588
  }).catch(function () { return false; });
589
589
  }
590
590
 
591
+ // Whether every module bundle a kept page links to is kept too.
592
+ //
593
+ // A page's registry, stores and composables are /_stx/modules.<hash>.js,
594
+ // answered by the server process that rendered the page, and only by it: a
595
+ // deploy starts a process that has never heard of the old hashes and answers
596
+ // them 404. A kept page whose bundles are not kept beside it is therefore one
597
+ // that may never bind -- opened cold, it showed its markup with every {{ }}
598
+ // empty and no button working, until a revalidation happened to replace it.
599
+ // Such a copy is not answered first: the network is, and the copy only stands
600
+ // in when there is no network at all, where it is the best there is.
601
+ // ignoreVary: a script was kept under the browser's own request, whose
602
+ // Accept-Encoding a lookup by URL does not carry.
603
+ var MODULE_BUNDLE = /\\/_stx\\/modules\\.[0-9a-f]{16}\\.js/g;
604
+ function bundlesKept(response) {
605
+ return response.clone().text().then(function (html) {
606
+ var urls = [];
607
+ var match;
608
+ MODULE_BUNDLE.lastIndex = 0;
609
+ while ((match = MODULE_BUNDLE.exec(html))) {
610
+ if (urls.indexOf(match[0]) === -1) urls.push(match[0]);
611
+ }
612
+ if (!urls.length) return true;
613
+ return caches.open(ASSETS).then(function (assets) {
614
+ return Promise.all(urls.map(function (url) { return assets.match(url, { ignoreVary: true }); }));
615
+ }).then(function (kept) {
616
+ return kept.every(Boolean);
617
+ });
618
+ }).catch(function () { return true; });
619
+ }
620
+
591
621
  function pageResponse(request, event) {
592
622
  var fragment = isFragment(request);
593
623
  var key = variantUrl(request.url, fragment);
@@ -597,34 +627,39 @@ function pageResponse(request, event) {
597
627
  var cache = opened[0];
598
628
  var networkFirst = opened[1] || wantsNetworkFirst(request, new URL(request.url).pathname);
599
629
  return cache.match(key).then(function (hit) {
600
- if (hit && !networkFirst) {
601
- keepAlive(event, revalidate(request, cache, keys, hit, 'page'));
602
- return hit;
603
- }
604
- var network = fetch(request).then(function (response) {
605
- if (keepable(response) || keepStaticPage(request, response)) keepAlive(event, store(cache, keys, response.clone()));
606
- return response;
607
- });
608
- // What stands in when the network is not there, or slow: the kept copy,
609
- // then a dynamic route's kept page, then the fallback screen.
610
- var standIn = function (offline) {
611
- if (hit) return Promise.resolve(hit);
612
- var route = dynamic ? cache.match(routeKey(dynamic.route, fragment)) : Promise.resolve(null);
613
- return route.then(function (kept) {
614
- if (kept) return withParams(kept, dynamic.params);
615
- if (!offline) return null;
616
- if (!S.fallback || fragment) return Response.error();
617
- return cache.match(variantUrl(S.fallback, false)).then(function (fallback) { return fallback ? markFallback(fallback) : Response.error(); });
630
+ return (hit && !networkFirst ? bundlesKept(hit) : Promise.resolve(false)).then(function (whole) {
631
+ if (whole) {
632
+ keepAlive(event, revalidate(request, cache, keys, hit, 'page'));
633
+ return hit;
634
+ }
635
+ // Kept, but without its module bundles: not shown while the network
636
+ // might answer (bundlesKept).
637
+ var partial = hit && !networkFirst;
638
+ var network = fetch(request).then(function (response) {
639
+ if (keepable(response) || keepStaticPage(request, response)) keepAlive(event, store(cache, keys, response.clone()));
640
+ return response;
618
641
  });
619
- };
620
- return withTimeout(network, S.timeout).catch(function () {
621
- return standIn(false).then(function (kept) {
622
- if (kept) {
623
- keepAlive(event, network);
624
- return kept;
625
- }
626
- // Slower than the timeout, nothing kept to show: wait for it rather than fail.
627
- return network.catch(function () { return standIn(true); });
642
+ // What stands in when the network is not there, or slow: the kept copy,
643
+ // then a dynamic route's kept page, then the fallback screen.
644
+ var standIn = function (offline) {
645
+ if (hit && (!partial || offline)) return Promise.resolve(hit);
646
+ var route = dynamic ? cache.match(routeKey(dynamic.route, fragment)) : Promise.resolve(null);
647
+ return route.then(function (kept) {
648
+ if (kept) return withParams(kept, dynamic.params);
649
+ if (!offline) return null;
650
+ if (!S.fallback || fragment) return Response.error();
651
+ return cache.match(variantUrl(S.fallback, false)).then(function (fallback) { return fallback ? markFallback(fallback) : Response.error(); });
652
+ });
653
+ };
654
+ return withTimeout(network, S.timeout).catch(function () {
655
+ return standIn(false).then(function (kept) {
656
+ if (kept) {
657
+ keepAlive(event, network);
658
+ return kept;
659
+ }
660
+ // Slower than the timeout, nothing kept to show: wait for it rather than fail.
661
+ return network.catch(function () { return standIn(true); });
662
+ });
628
663
  });
629
664
  });
630
665
  });
package/dist/process.js CHANGED
@@ -285,6 +285,10 @@ export async function processDirectives(template, context, filePath, options, de
285
285
  await prepareRuntimeConfig(context, filePath, options.runtimeConfig);
286
286
  if (isTopLevel) {
287
287
  initializeComponentClientFactories(context);
288
+ context.__stx_scope_seq ??= {
289
+ n: 0,
290
+ key: Bun.hash(String(context.__filename ?? filePath)).toString(36).slice(0, 6)
291
+ };
288
292
  context.__stx_head_injections = createHeadInjections();
289
293
  context.__stx_seo_staged = !1;
290
294
  }
package/dist/pwa.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{An,Ie,Do,Oa}from"./chunk-jn8tj4kn.js";import{Rn,Br,Pa,Ia,Da}from"./chunk-s6e8mmk1.js";import{Ao,Po,Io,Ra,Aa}from"./chunk-5cyme1g0.js";import{oe,pt,Fr}from"./chunk-9ndzk9r4.js";import{Nc,Lc,jc,Bc,lr,rd}from"./chunk-tn85vr56.js";import B from"fs";import w from"path";import O from"fs";import u from"path";var v=[72,96,128,144,152,192,384,512],S=[120,152,167,180],P=[16,32];async function M(n,t){let e={success:!0,generatedFiles:[],errors:[],warnings:[]},r=n.pwa?.icons;if(!r?.src)return e.errors.push("No source icon specified in pwa.icons.src"),e.success=!1,e;let o=u.isAbsolute(r.src)?r.src:u.resolve(process.cwd(),r.src);if(!await Bun.file(o).exists())return e.errors.push(`Source icon not found: ${o}`),e.success=!1,e;let a=u.resolve(t,r.outputDir||"pwa-icons");try{O.mkdirSync(a,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${a}`),e.success=!1,e}let s=r.sizes||v,l=r.generateWebP??!0,p=r.generateAppleIcons??!0;try{let c;try{c=await import("sharp")}catch{return e.errors.push(`sharp is not installed. Install it with: bun add sharp
3
- Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-wgqt5pnv.js"),o=await Bun.file(e).text();return await r(o,{},e,n,new Set)}catch(r){console.warn(`[PWA] Failed to process custom offline page: ${r}`)}else console.warn(`[PWA] Custom offline page not found: ${e}`)}return E(n)}function E(n){let t=n.pwa?.offline,e=n.pwa?.manifest,r=t?.fallbackTitle||"You are offline",o=t?.fallbackMessage||"Please check your internet connection and try again.",a=e?.themeColor||"#4f46e5",s=e?.shortName||e?.name||"App";return`<!DOCTYPE html>
2
+ import{Pn,Ie,Oo,Ma}from"./chunk-d3mpxr3s.js";import{An,Fr,Ia,Da,Oa}from"./chunk-tpvc8xnk.js";import{Po,Io,Do,Aa,Pa}from"./chunk-v3yqeh15.js";import{oe,ft,zr}from"./chunk-vg7wfkt5.js";import{Lc,jc,Bc,Fc,ur,sd}from"./chunk-rvgvt161.js";import B from"fs";import w from"path";import O from"fs";import u from"path";var v=[72,96,128,144,152,192,384,512],S=[120,152,167,180],P=[16,32];async function M(n,t){let e={success:!0,generatedFiles:[],errors:[],warnings:[]},r=n.pwa?.icons;if(!r?.src)return e.errors.push("No source icon specified in pwa.icons.src"),e.success=!1,e;let o=u.isAbsolute(r.src)?r.src:u.resolve(process.cwd(),r.src);if(!await Bun.file(o).exists())return e.errors.push(`Source icon not found: ${o}`),e.success=!1,e;let a=u.resolve(t,r.outputDir||"pwa-icons");try{O.mkdirSync(a,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${a}`),e.success=!1,e}let s=r.sizes||v,l=r.generateWebP??!0,p=r.generateAppleIcons??!0;try{let c;try{c=await import("sharp")}catch{return e.errors.push(`sharp is not installed. Install it with: bun add sharp
3
+ Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-bpzrfqvw.js"),o=await Bun.file(e).text();return await r(o,{},e,n,new Set)}catch(r){console.warn(`[PWA] Failed to process custom offline page: ${r}`)}else console.warn(`[PWA] Custom offline page not found: ${e}`)}return E(n)}function E(n){let t=n.pwa?.offline,e=n.pwa?.manifest,r=t?.fallbackTitle||"You are offline",o=t?.fallbackMessage||"Please check your internet connection and try again.",a=e?.themeColor||"#4f46e5",s=e?.shortName||e?.name||"App";return`<!DOCTYPE html>
4
4
  <html lang="en">
5
5
  <head>
6
6
  <meta charset="UTF-8">
@@ -233,4 +233,4 @@ Icon generation requires the sharp package for image processing.`),e.success=!1,
233
233
  }, 5000);
234
234
  </script>
235
235
  </body>
236
- </html>`}function b(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}async function re(n,t){let e={success:!0,files:{icons:[]},errors:[],warnings:[]},r=n.pwa;if(!r?.enabled)return e;try{B.mkdirSync(t,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${t}`),e.success=!1,e}try{let a=_(n);if(a){let s=w.join(t,"manifest.json");await Bun.write(s,a),e.files.manifest=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate manifest.json: ${s}`),e.success=!1}if(r.icons?.src)if(await I()){let s=await M(n,t);if(e.files.icons=s.generatedFiles,e.warnings.push(...s.warnings),!s.success)e.errors.push(...s.errors),e.success=!1}else e.warnings.push("sharp is not installed. Skipping icon generation. Install with: bun add sharp");if(r.offline?.enabled)try{let a=await F(n);if(a){let s=w.join(t,"offline.html");await Bun.write(s,a),e.files.offlinePage=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate offline page: ${s}`),e.success=!1}let o;if(r.precache?.enabled){let a=oe(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=An(n,t);if(a){let s=Ie(n),l=w.join(t,s);await Bun.write(l,a),e.files.serviceWorker=l}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate service worker: ${s}`),e.success=!1}return e}function ae(n,t){return Br(n,t)}function se(n){return n.pwa?.enabled===!0}export{S as APPLE_TOUCH_ICON_SIZES,v as DEFAULT_ICON_SIZES,P as FAVICON_SIZES,Po as auditBuildOutput,Ao as auditConfig,re as buildPwaAssets,Io as calculateAuditResult,Aa as formatAuditResult,Fr as formatSize,j as generateManifest,_ as generateManifestJson,Ia as generateManifestLink,F as generateOfflinePage,oe as generatePrecacheManifest,pt as generatePrecacheManifestJs,M as generatePwaIcons,Rn as generatePwaTags,An as generateServiceWorker,Oa as generateServiceWorkerAuto,Pa as generateSwRegistrationScript,Da as generateThemeColorMeta,N as getExpectedIconPaths,Ie as getServiceWorkerFileName,Br as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,Do as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,lr as pwaDirectives,Nc as pwaInstallDirective,jc as pwaOfflineDirective,Bc as pwaPushDirective,Lc as pwaUpdateDirective,rd as registerPwaDirectives,Ra as runPwaAudit,D as validateManifest};
236
+ </html>`}function b(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}async function re(n,t){let e={success:!0,files:{icons:[]},errors:[],warnings:[]},r=n.pwa;if(!r?.enabled)return e;try{B.mkdirSync(t,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${t}`),e.success=!1,e}try{let a=_(n);if(a){let s=w.join(t,"manifest.json");await Bun.write(s,a),e.files.manifest=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate manifest.json: ${s}`),e.success=!1}if(r.icons?.src)if(await I()){let s=await M(n,t);if(e.files.icons=s.generatedFiles,e.warnings.push(...s.warnings),!s.success)e.errors.push(...s.errors),e.success=!1}else e.warnings.push("sharp is not installed. Skipping icon generation. Install with: bun add sharp");if(r.offline?.enabled)try{let a=await F(n);if(a){let s=w.join(t,"offline.html");await Bun.write(s,a),e.files.offlinePage=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate offline page: ${s}`),e.success=!1}let o;if(r.precache?.enabled){let a=oe(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=Pn(n,t);if(a){let s=Ie(n),l=w.join(t,s);await Bun.write(l,a),e.files.serviceWorker=l}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate service worker: ${s}`),e.success=!1}return e}function ae(n,t){return Fr(n,t)}function se(n){return n.pwa?.enabled===!0}export{S as APPLE_TOUCH_ICON_SIZES,v as DEFAULT_ICON_SIZES,P as FAVICON_SIZES,Io as auditBuildOutput,Po as auditConfig,re as buildPwaAssets,Do as calculateAuditResult,Pa as formatAuditResult,zr as formatSize,j as generateManifest,_ as generateManifestJson,Da as generateManifestLink,F as generateOfflinePage,oe as generatePrecacheManifest,ft as generatePrecacheManifestJs,M as generatePwaIcons,An as generatePwaTags,Pn as generateServiceWorker,Ma as generateServiceWorkerAuto,Ia as generateSwRegistrationScript,Oa as generateThemeColorMeta,N as getExpectedIconPaths,Ie as getServiceWorkerFileName,Fr as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,Oo as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,ur as pwaDirectives,Lc as pwaInstallDirective,Bc as pwaOfflineDirective,Fc as pwaPushDirective,jc as pwaUpdateDirective,sd as registerPwaDirectives,Aa as runPwaAudit,D as validateManifest};
@@ -15,8 +15,9 @@
15
15
  * the worst a missed event costs is one stale request, not the rest of the
16
16
  * session.
17
17
  *
18
- * Statting a handful of files is nothing next to the `Bun.build` it guards, so
19
- * this runs on every call rather than being cached itself.
18
+ * Statting a handful of files is nothing next to the `Bun.build` it guards,
19
+ * but on every render of a page it is not nothing, so in production a
20
+ * signature is reused for a second (see `sourceSignature`).
20
21
  *
21
22
  * @module source-signature
22
23
  */
@@ -31,6 +32,8 @@
31
32
  * throwing — it is a difference from the last run either way.
32
33
  */
33
34
  export declare function sourceSignature(files: readonly string[]): string;
35
+ /** Forget recent signatures, so the next call stats again. */
36
+ export declare function clearSourceSignatures(): void;
34
37
  /** A memo entry that knows which sources it was built from. */
35
38
  export interface SignedCacheEntry<T> {
36
39
  signature: string;
@@ -1,5 +1,12 @@
1
1
  import fs from "node:fs";
2
2
  export function sourceSignature(files) {
3
+ return statSignature(files);
4
+ }
5
+ const SIGNATURE_TTL_MS = 1000, recentSignatures = new Map;
6
+ export function clearSourceSignatures() {
7
+ recentSignatures.clear();
8
+ }
9
+ function statSignature(files) {
3
10
  return [...files].sort().map((file) => {
4
11
  try {
5
12
  const stat = fs.statSync(file);