@stacksjs/stx 0.2.453 → 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 (224) 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/native/runtime/native-host.d.ts +1 -0
  145. package/dist/native/runtime/native-host.js +63 -12
  146. package/dist/native/runtime/shared-screen.js +11 -2
  147. package/dist/offline/app-service-worker.d.ts +4 -1
  148. package/dist/offline/app-service-worker.js +62 -27
  149. package/dist/process.js +4 -0
  150. package/dist/pwa.js +3 -3
  151. package/dist/source-signature.d.ts +5 -2
  152. package/dist/source-signature.js +7 -0
  153. package/dist/ssg.js +8 -8
  154. package/dist/store-loader.js +2 -1
  155. package/dist/utils.js +27 -15
  156. package/package.json +5 -5
  157. package/dist/chunk-14x69rt4.js +0 -2
  158. package/dist/chunk-1kmd0g1k.js +0 -3
  159. package/dist/chunk-3wezvz6m.js +0 -2
  160. package/dist/chunk-5402rpwg.js +0 -2
  161. package/dist/chunk-58ymq1h4.js +0 -2
  162. package/dist/chunk-5rtbs8zv.js +0 -2
  163. package/dist/chunk-5tx1wqns.js +0 -2
  164. package/dist/chunk-6fw3rfcj.js +0 -2
  165. package/dist/chunk-6nfecsbt.js +0 -2
  166. package/dist/chunk-6sw7sxh2.js +0 -17
  167. package/dist/chunk-7qbv0xh6.js +0 -2
  168. package/dist/chunk-7vdsd9rn.js +0 -2
  169. package/dist/chunk-8gk34047.js +0 -2
  170. package/dist/chunk-8nsfkr5n.js +0 -2
  171. package/dist/chunk-90562q79.js +0 -3
  172. package/dist/chunk-a1dggchm.js +0 -2
  173. package/dist/chunk-a1kv42kp.js +0 -2
  174. package/dist/chunk-a5695s8k.js +0 -2
  175. package/dist/chunk-avjgetkh.js +0 -2
  176. package/dist/chunk-bcgth8qf.js +0 -2
  177. package/dist/chunk-bemksdz5.js +0 -33
  178. package/dist/chunk-br3ktpyq.js +0 -2
  179. package/dist/chunk-by1s70jp.js +0 -2
  180. package/dist/chunk-cwc3p6p7.js +0 -2
  181. package/dist/chunk-e593pr1r.js +0 -2
  182. package/dist/chunk-e8y69gg0.js +0 -2
  183. package/dist/chunk-eam7eann.js +0 -2
  184. package/dist/chunk-ej7m406s.js +0 -2
  185. package/dist/chunk-es85mgdw.js +0 -2
  186. package/dist/chunk-fa5x9zbk.js +0 -2
  187. package/dist/chunk-fkrzsk74.js +0 -2
  188. package/dist/chunk-fm3k5v8s.js +0 -2
  189. package/dist/chunk-fmc9fj4a.js +0 -2
  190. package/dist/chunk-fn863yek.js +0 -2
  191. package/dist/chunk-fv30avp2.js +0 -2
  192. package/dist/chunk-gpmk4s4f.js +0 -2
  193. package/dist/chunk-hd64hz1n.js +0 -2
  194. package/dist/chunk-hd75916k.js +0 -4
  195. package/dist/chunk-hz6a476h.js +0 -2
  196. package/dist/chunk-j7zywbq0.js +0 -4
  197. package/dist/chunk-jjm3754f.js +0 -2
  198. package/dist/chunk-ktk30f6d.js +0 -2
  199. package/dist/chunk-m3f50p6c.js +0 -2
  200. package/dist/chunk-m90a5dpn.js +0 -2
  201. package/dist/chunk-mmp7x8f0.js +0 -2
  202. package/dist/chunk-nqcg2bf0.js +0 -2
  203. package/dist/chunk-nrp8qg9j.js +0 -2831
  204. package/dist/chunk-ns7e951g.js +0 -2
  205. package/dist/chunk-nycvwnty.js +0 -2
  206. package/dist/chunk-p9shre7t.js +0 -2
  207. package/dist/chunk-pe9hxhrb.js +0 -2
  208. package/dist/chunk-ph6xg67j.js +0 -11
  209. package/dist/chunk-qewxfhex.js +0 -2
  210. package/dist/chunk-qfrg8mnf.js +0 -2
  211. package/dist/chunk-rmnhy5az.js +0 -2
  212. package/dist/chunk-t6m5wmpy.js +0 -2
  213. package/dist/chunk-v404gvm0.js +0 -2
  214. package/dist/chunk-vgvsefz8.js +0 -2
  215. package/dist/chunk-w9k7pvre.js +0 -2
  216. package/dist/chunk-wf09xg7j.js +0 -2
  217. package/dist/chunk-wgqt5pnv.js +0 -2
  218. package/dist/chunk-wr3h8dmt.js +0 -2
  219. package/dist/chunk-wtqjfar3.js +0 -2
  220. package/dist/chunk-x1xncm97.js +0 -2
  221. package/dist/chunk-yd50awqp.js +0 -3
  222. package/dist/chunk-ykxd78b2.js +0 -2
  223. package/dist/chunk-yqsza22w.js +0 -3
  224. 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");
@@ -34,4 +34,5 @@ export declare interface NativeHost {
34
34
  flush: () => void
35
35
  dispatch: (handlerId: string, payload?: unknown) => void
36
36
  pending: () => number
37
+ snapshot: (root: NativeNode) => STXNode
37
38
  }
@@ -78,7 +78,7 @@ export function createNativeHost(options) {
78
78
  }
79
79
  }
80
80
  function recordOf(node) {
81
- let record = records.get(node.__stxId);
81
+ let record = records.get(node.__stxId) ?? revive(node);
82
82
  if (!record) {
83
83
  record = { type: "View", props: {}, style: {}, baseStyle: {}, classes: "", events: {}, children: [], visible: !0, materialized: !0 };
84
84
  records.set(node.__stxId, record);
@@ -100,9 +100,29 @@ export function createNativeHost(options) {
100
100
  const record = descriptorOf(node);
101
101
  if (!record)
102
102
  return;
103
- Object.values(record.events).forEach((handlerId) => handlers.delete(handlerId));
103
+ for (const handlerId of Object.values(record.events)) {
104
+ const handler = handlers.get(handlerId);
105
+ if (!handler)
106
+ continue;
107
+ (record.parkedHandlers ??= new Map).set(handlerId, handler);
108
+ handlers.delete(handlerId);
109
+ }
104
110
  record.children.forEach(releaseHandlers);
105
111
  }
112
+ function revive(node) {
113
+ const retained = node, record = retained.__stxDetachedRecord;
114
+ if (!record)
115
+ return;
116
+ delete retained.__stxDetachedRecord;
117
+ record.materialized = !1;
118
+ if (record.parkedHandlers) {
119
+ for (const [handlerId, handler] of record.parkedHandlers)
120
+ handlers.set(handlerId, handler);
121
+ record.parkedHandlers = void 0;
122
+ }
123
+ records.set(node.__stxId, record);
124
+ return record;
125
+ }
106
126
  function materialize(node) {
107
127
  const record = recordOf(node);
108
128
  if (record.materialized || node.__stxAnchor !== void 0)
@@ -116,6 +136,7 @@ export function createNativeHost(options) {
116
136
  type: record.type,
117
137
  props: { ...record.props },
118
138
  style: { ...record.style },
139
+ ...Object.keys(record.events).length ? { events: { ...record.events } } : {},
119
140
  ...record.text === void 0 ? {} : { children: [record.text] }
120
141
  }
121
142
  });
@@ -254,10 +275,30 @@ export function createNativeHost(options) {
254
275
  },
255
276
  pending: () => queue.length,
256
277
  flush,
278
+ snapshot(root) {
279
+ queue = [];
280
+ const describe = (node) => {
281
+ const record = recordOf(node);
282
+ if (!record.materialized)
283
+ record.style = resolveStyle(record);
284
+ record.materialized = !0;
285
+ const children = record.children.filter((child) => child.__stxAnchor === void 0).map(describe);
286
+ return {
287
+ id: node.__stxId,
288
+ type: record.type,
289
+ props: { ...record.props },
290
+ style: { ...record.style },
291
+ events: { ...record.events },
292
+ children: record.text === void 0 ? children : [record.text]
293
+ };
294
+ };
295
+ return describe(root);
296
+ },
257
297
  setText(node, value) {
258
- const text = value == null ? "" : String(value);
259
- recordOf(node).text = text;
260
- emit({ op: "updateNode", id: node.__stxId, patch: { children: [text] } });
298
+ const text = value == null ? "" : String(value), record = recordOf(node);
299
+ record.text = text;
300
+ if (record.materialized)
301
+ emit({ op: "updateNode", id: node.__stxId, patch: { children: [text] } });
261
302
  },
262
303
  setAttribute(node, name, value) {
263
304
  if (name === "class" || name === "className") {
@@ -270,7 +311,8 @@ export function createNativeHost(options) {
270
311
  recordOf(node).props[prop] = value;
271
312
  if (recordOf(node).type === "Icon" && prop === "name")
272
313
  this.setAttribute(node, "symbol", resolveIconName(String(value ?? "")).symbol);
273
- emit({ op: "updateNode", id: node.__stxId, patch: { props: { [prop]: value } } });
314
+ if (recordOf(node).materialized)
315
+ emit({ op: "updateNode", id: node.__stxId, patch: { props: { [prop]: value } } });
274
316
  },
275
317
  removeAttribute(node, name) {
276
318
  if (name === "class" || name === "className") {
@@ -279,7 +321,8 @@ export function createNativeHost(options) {
279
321
  }
280
322
  const prop = nativePropName(name);
281
323
  delete recordOf(node).props[prop];
282
- emit({ op: "updateNode", id: node.__stxId, patch: { props: { [prop]: null } } });
324
+ if (recordOf(node).materialized)
325
+ emit({ op: "updateNode", id: node.__stxId, patch: { props: { [prop]: null } } });
283
326
  },
284
327
  setStyle(node, value) {
285
328
  if (typeof value !== "object" || value === null || Array.isArray(value))
@@ -287,13 +330,16 @@ export function createNativeHost(options) {
287
330
  const style = value;
288
331
  Object.assign(recordOf(node).baseStyle, style);
289
332
  Object.assign(recordOf(node).style, style);
290
- emit({ op: "updateNode", id: node.__stxId, patch: { style } });
333
+ if (recordOf(node).materialized)
334
+ emit({ op: "updateNode", id: node.__stxId, patch: { style } });
291
335
  },
292
336
  listen(node, event, handler) {
293
337
  const id = nextId("h"), nativeEvent = NATIVE_EVENT_NAMES[event.toLowerCase()] ?? event;
294
338
  handlers.set(id, handler);
295
- recordOf(node).events[nativeEvent] = id;
296
- emit({ op: "updateNode", id: node.__stxId, patch: { events: { [nativeEvent]: id } } });
339
+ const record = recordOf(node);
340
+ record.events[nativeEvent] = id;
341
+ if (record.materialized)
342
+ emit({ op: "updateNode", id: node.__stxId, patch: { events: { [nativeEvent]: id } } });
297
343
  },
298
344
  dispatch(handlerId, payload) {
299
345
  handlers.get(handlerId)?.(payload);
@@ -311,7 +357,8 @@ export function createNativeHost(options) {
311
357
  const record = recordOf(node), was = record.visible;
312
358
  record.visible = visible;
313
359
  record.baseStyle.display = visible ? "flex" : "none";
314
- emit({ op: "updateNode", id: node.__stxId, patch: { style: { display: visible ? "flex" : "none" } } });
360
+ if (record.materialized)
361
+ emit({ op: "updateNode", id: node.__stxId, patch: { style: { display: visible ? "flex" : "none" } } });
315
362
  return was;
316
363
  },
317
364
  anchor(label) {
@@ -372,11 +419,15 @@ export function createNativeHost(options) {
372
419
  if (node.__stxAnchor !== void 0 || !record.materialized)
373
420
  return;
374
421
  materialize(node);
422
+ let nativeIndex = 0;
423
+ for (let i = 0;i < index; i++)
424
+ if (record.children[i].__stxAnchor === void 0)
425
+ nativeIndex++;
375
426
  emit({
376
427
  op: existing === -1 ? "insertChild" : "moveChild",
377
428
  parentId: parent.__stxId,
378
429
  childId: node.__stxId,
379
- index
430
+ index: nativeIndex
380
431
  });
381
432
  },
382
433
  descendants: collectDescendants,
@@ -3,7 +3,7 @@ import { materializeNativeBindingTree } from "./binding-tree.js";
3
3
  import { installCraftBridge } from "./craft-bridge.js";
4
4
  import { createNativeHost } from "./native-host.js";
5
5
  export function prepareSharedNativeScreen(document, manifest, bridge, options = {}) {
6
- let revision = 0;
6
+ let revision = 0, generation = 0;
7
7
  const protocol = new STXBridge;
8
8
  protocol.initialize(bridge);
9
9
  installCraftBridge(protocol, bridge, globalThis, options);
@@ -14,7 +14,7 @@ export function prepareSharedNativeScreen(document, manifest, bridge, options =
14
14
  revision++;
15
15
  protocol.mutate({
16
16
  version: 1,
17
- batchId: `mutation_${revision}`,
17
+ batchId: `mutation_${generation}_${revision}`,
18
18
  baseRevision,
19
19
  revision,
20
20
  operations
@@ -30,6 +30,15 @@ export function prepareSharedNativeScreen(document, manifest, bridge, options =
30
30
  });
31
31
  const tree = materializeNativeBindingTree(document, manifest, host);
32
32
  let dispose = null;
33
+ protocol.on("MUTATION_ERROR", (message) => {
34
+ const payload = message.payload ?? {}, batch = String(payload.batchId ?? "");
35
+ if (batch && !batch.startsWith(`mutation_${generation}_`))
36
+ return;
37
+ console.error(`[stx native] the screen refused ${batch || "a mutation batch"} (${payload.code ?? "error"}: ${payload.message ?? ""}); redrawing it`);
38
+ generation++;
39
+ revision = 0;
40
+ protocol.render(host.snapshot(tree.root));
41
+ });
33
42
  protocol.on("EVENT", (message) => {
34
43
  const handlerId = message.payload?.handlerId ?? message.payload?.handlerName;
35
44
  if (typeof handlerId === "string")
@@ -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
  }