@stacksjs/stx 0.2.502 → 0.2.504

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 (167) hide show
  1. package/dist/chunk-0eptxhzy.js +2 -0
  2. package/dist/{chunk-4ssg2hn4.js → chunk-0gp4sj0v.js} +1 -1
  3. package/dist/chunk-0kj3qs23.js +2 -0
  4. package/dist/{chunk-m9nr12a1.js → chunk-0np4t9ka.js} +120 -120
  5. package/dist/{chunk-qmcmjdy7.js → chunk-133ggr0t.js} +7 -7
  6. package/dist/{chunk-8qdvhbv7.js → chunk-17fan751.js} +5 -5
  7. package/dist/chunk-18pxh9sv.js +2 -0
  8. package/dist/{chunk-b90y5phw.js → chunk-2242bx8y.js} +65 -65
  9. package/dist/{chunk-vs0ebfg5.js → chunk-2abv46yw.js} +1 -1
  10. package/dist/{chunk-7cbtcdqw.js → chunk-2etevws0.js} +2 -2
  11. package/dist/chunk-2h4bf7m4.js +2 -0
  12. package/dist/{chunk-z9fz5dby.js → chunk-2j04bc8c.js} +2 -2
  13. package/dist/chunk-37hm4er5.js +2 -0
  14. package/dist/{chunk-25m2wqsd.js → chunk-38mtn4ce.js} +3 -3
  15. package/dist/chunk-3c9t71pc.js +2 -0
  16. package/dist/{chunk-1mrn5s5z.js → chunk-3kxh9rsp.js} +1 -1
  17. package/dist/{chunk-vg9dyc4y.js → chunk-3y8ykqpx.js} +1 -1
  18. package/dist/{chunk-jwjggr91.js → chunk-3ynfz6h8.js} +2 -2
  19. package/dist/{chunk-0egg3666.js → chunk-49p5j9ab.js} +4 -4
  20. package/dist/{chunk-rhrv2j36.js → chunk-4hz4g5ym.js} +2 -2
  21. package/dist/{chunk-ckrpk6ak.js → chunk-5c1qesrs.js} +1 -1
  22. package/dist/{chunk-b77v56fz.js → chunk-5cyz97t4.js} +7 -7
  23. package/dist/{chunk-tdetcthb.js → chunk-5kq996qy.js} +1 -1
  24. package/dist/chunk-5q27xq7w.js +2 -0
  25. package/dist/{chunk-802qf0vz.js → chunk-5q9rmcp7.js} +1 -1
  26. package/dist/chunk-5yrn6whx.js +2 -0
  27. package/dist/chunk-667d6fz8.js +2 -0
  28. package/dist/{chunk-1erc0vrb.js → chunk-6k4f583z.js} +2 -2
  29. package/dist/{chunk-40jd0b4h.js → chunk-78yx6xxn.js} +1 -1
  30. package/dist/{chunk-2pph3dh0.js → chunk-798epzq5.js} +1 -1
  31. package/dist/chunk-7dmrxhq7.js +2 -0
  32. package/dist/{chunk-yvt8zszz.js → chunk-81byredt.js} +1 -1
  33. package/dist/{chunk-qhnpc3ac.js → chunk-88xqy2b9.js} +22 -22
  34. package/dist/{chunk-cp7hph6f.js → chunk-8xpyzcq2.js} +1 -1
  35. package/dist/chunk-9836wtag.js +2 -0
  36. package/dist/chunk-9kt6g57t.js +2 -0
  37. package/dist/{chunk-81t6zr3m.js → chunk-a5c75hxe.js} +2 -2
  38. package/dist/{chunk-93sr9q8g.js → chunk-a771dfsg.js} +1 -1
  39. package/dist/{chunk-h0sd5cda.js → chunk-amd52bnv.js} +5 -5
  40. package/dist/{chunk-szry3s17.js → chunk-azza6dcr.js} +3 -3
  41. package/dist/chunk-b3nz1qmj.js +2 -0
  42. package/dist/chunk-bcgfg3x0.js +2 -0
  43. package/dist/{chunk-gvkfydq5.js → chunk-bt51kf9z.js} +1 -1
  44. package/dist/{chunk-2kyfaa0p.js → chunk-c322rrge.js} +2 -2
  45. package/dist/chunk-cctb8fnj.js +2 -0
  46. package/dist/chunk-cpj9b887.js +2 -0
  47. package/dist/{chunk-bv7bsdfe.js → chunk-czmw5xsd.js} +2 -2
  48. package/dist/chunk-d161ndyz.js +2 -0
  49. package/dist/chunk-d5x1t498.js +2 -0
  50. package/dist/{chunk-b5mcvm6y.js → chunk-dn9fxpwt.js} +6 -6
  51. package/dist/chunk-dne8n6h3.js +3 -0
  52. package/dist/{chunk-tvag2s5a.js → chunk-eacd5755.js} +1 -1
  53. package/dist/{chunk-8fb1mqw1.js → chunk-ej46bkaw.js} +1 -1
  54. package/dist/chunk-f6n6nrdq.js +2 -0
  55. package/dist/{chunk-4mrgy3ve.js → chunk-fd6abk20.js} +4 -4
  56. package/dist/{chunk-1v86h5vn.js → chunk-fesb4h31.js} +2 -2
  57. package/dist/chunk-fgvdq014.js +2 -0
  58. package/dist/{chunk-1hpttjgq.js → chunk-fh5rp6wb.js} +1 -1
  59. package/dist/{chunk-vp827ah7.js → chunk-g7wgpys2.js} +4 -4
  60. package/dist/{chunk-33snwgdy.js → chunk-gxs2p0y7.js} +3 -3
  61. package/dist/{chunk-z6nm6rf1.js → chunk-h6z4s5p3.js} +1 -1
  62. package/dist/chunk-hzjk2027.js +2 -0
  63. package/dist/{chunk-z9tvn738.js → chunk-jcmgj8kk.js} +1 -1
  64. package/dist/{chunk-zqxqdns1.js → chunk-jt842kx3.js} +1 -1
  65. package/dist/chunk-jtwx2xte.js +2 -0
  66. package/dist/chunk-k0zadypg.js +2 -0
  67. package/dist/{chunk-dve4q9tg.js → chunk-kbhm1wqt.js} +3 -3
  68. package/dist/{chunk-258qj7pt.js → chunk-km9g9drp.js} +1 -1
  69. package/dist/chunk-kr5ap3qn.js +2 -0
  70. package/dist/{chunk-t61vdbje.js → chunk-ktvr45qg.js} +6 -6
  71. package/dist/chunk-kxt6xb4j.js +2 -0
  72. package/dist/chunk-kxvtyh05.js +2 -0
  73. package/dist/chunk-mba6khev.js +2 -0
  74. package/dist/{chunk-vtn0gmen.js → chunk-mfcdbqvd.js} +8 -8
  75. package/dist/{chunk-298s08st.js → chunk-n34kagea.js} +2 -2
  76. package/dist/{chunk-c8psbk2e.js → chunk-p4gbvge6.js} +1 -1
  77. package/dist/chunk-pykeaf4h.js +2 -0
  78. package/dist/chunk-qcj12mtw.js +2 -0
  79. package/dist/chunk-qky9zfvx.js +2 -0
  80. package/dist/{chunk-4c1afy15.js → chunk-qv57r0fa.js} +1 -1
  81. package/dist/chunk-rnnead1w.js +2 -0
  82. package/dist/chunk-rrvfgmqb.js +2 -0
  83. package/dist/chunk-s4c8vf27.js +2 -0
  84. package/dist/chunk-srhgfsz3.js +2 -0
  85. package/dist/{chunk-stvqwzen.js → chunk-szkqmwjg.js} +2 -2
  86. package/dist/chunk-t1x0x5sw.js +2 -0
  87. package/dist/{chunk-hqvdm4h9.js → chunk-t77pz252.js} +1 -1
  88. package/dist/chunk-t7djn7zd.js +2 -0
  89. package/dist/{chunk-tse7jzmz.js → chunk-tf239jvd.js} +1 -1
  90. package/dist/{chunk-gzt3ghgq.js → chunk-tkagcknf.js} +2 -2
  91. package/dist/chunk-txd6fq1x.js +2 -0
  92. package/dist/{chunk-f0prq6yw.js → chunk-vc1m5fr9.js} +1 -1
  93. package/dist/{chunk-jbvg29t0.js → chunk-vftdacyb.js} +1 -1
  94. package/dist/{chunk-hktvv0hd.js → chunk-vtxzaj1h.js} +2 -2
  95. package/dist/chunk-w78v0xek.js +45 -0
  96. package/dist/chunk-wrghqec5.js +2 -0
  97. package/dist/{chunk-xfxrh6vx.js → chunk-wy36z6qp.js} +1 -1
  98. package/dist/{chunk-d19vgjjt.js → chunk-x81vcxzs.js} +2 -2
  99. package/dist/{chunk-15w4adyd.js → chunk-x96ardq0.js} +1 -1
  100. package/dist/{chunk-rmavqxd8.js → chunk-xd4zvm4x.js} +2 -2
  101. package/dist/{chunk-x8mp9yvn.js → chunk-xemsypk7.js} +4 -4
  102. package/dist/{chunk-v7vkqg8f.js → chunk-xsc9zbaj.js} +2 -2
  103. package/dist/{chunk-71bbv43t.js → chunk-xx2pk2ay.js} +3 -3
  104. package/dist/{chunk-74j18qk0.js → chunk-y8h823cb.js} +28 -28
  105. package/dist/{chunk-3mynjdqr.js → chunk-ygetbydb.js} +3 -3
  106. package/dist/chunk-yn2d8x8m.js +3 -0
  107. package/dist/{chunk-mq7vvaf4.js → chunk-ywv2838m.js} +1 -1
  108. package/dist/cli.js +44 -44
  109. package/dist/craft-entry.js +2 -2
  110. package/dist/craft.js +2 -2
  111. package/dist/native/bridge/protocol.d.ts +3 -0
  112. package/dist/native/cli.d.ts +1 -0
  113. package/dist/native/cli.js +7 -2
  114. package/dist/native/compiler/bundle.d.ts +1 -0
  115. package/dist/native/compiler/bundle.js +27 -7
  116. package/dist/native/compiler/html-to-ir.js +12 -0
  117. package/dist/native/compiler/icons.d.ts +20 -0
  118. package/dist/native/compiler/icons.js +20 -0
  119. package/dist/native/runtime/craft-bridge.js +9 -1
  120. package/dist/native/runtime/craft.d.ts +2 -0
  121. package/dist/native/runtime/native-host.js +8 -0
  122. package/dist/native/runtime/shared-screen.d.ts +21 -0
  123. package/dist/native/runtime/shared-screen.js +43 -0
  124. package/dist/pwa.js +3 -3
  125. package/dist/ssg.js +2 -2
  126. package/package.json +5 -5
  127. package/dist/chunk-0adrp7qd.js +0 -2
  128. package/dist/chunk-0vdxchfw.js +0 -2
  129. package/dist/chunk-2gr5zcm3.js +0 -2
  130. package/dist/chunk-2wvezjd5.js +0 -33
  131. package/dist/chunk-379nn8yc.js +0 -2
  132. package/dist/chunk-3vqabd10.js +0 -2
  133. package/dist/chunk-490f2x2r.js +0 -2
  134. package/dist/chunk-4j2ej7er.js +0 -2
  135. package/dist/chunk-4rmdngzw.js +0 -2
  136. package/dist/chunk-52saa2nj.js +0 -2
  137. package/dist/chunk-69dc3tyz.js +0 -2
  138. package/dist/chunk-6v3p6cx1.js +0 -2
  139. package/dist/chunk-78vfptph.js +0 -2
  140. package/dist/chunk-7e6sxdp6.js +0 -2
  141. package/dist/chunk-7wxmsv41.js +0 -2
  142. package/dist/chunk-9mh1qq3g.js +0 -2
  143. package/dist/chunk-b0bgprzs.js +0 -2
  144. package/dist/chunk-c7cajwd2.js +0 -2
  145. package/dist/chunk-cg8hg6cs.js +0 -3
  146. package/dist/chunk-en0atzsp.js +0 -2
  147. package/dist/chunk-fxppbahx.js +0 -2
  148. package/dist/chunk-hhj1txvj.js +0 -2
  149. package/dist/chunk-j2q2pp0x.js +0 -2
  150. package/dist/chunk-jbj6xh7f.js +0 -3
  151. package/dist/chunk-jh385m2w.js +0 -2
  152. package/dist/chunk-kxg9q64a.js +0 -2
  153. package/dist/chunk-mdfrm5hv.js +0 -2
  154. package/dist/chunk-nfffn3s0.js +0 -2
  155. package/dist/chunk-nw7qvyek.js +0 -2
  156. package/dist/chunk-ny64ezsj.js +0 -2
  157. package/dist/chunk-qjba655t.js +0 -2
  158. package/dist/chunk-qjxxd4a0.js +0 -2
  159. package/dist/chunk-qsy7phd4.js +0 -2
  160. package/dist/chunk-rfq1jfhf.js +0 -2
  161. package/dist/chunk-rr41gk8b.js +0 -2
  162. package/dist/chunk-snyq0jj6.js +0 -2
  163. package/dist/chunk-sybzayv3.js +0 -2
  164. package/dist/chunk-v8m2khkq.js +0 -2
  165. package/dist/chunk-vbhykx9z.js +0 -2
  166. package/dist/chunk-xk2mwk61.js +0 -2
  167. package/dist/chunk-zbzmfqmk.js +0 -2
package/dist/craft.js CHANGED
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import{Hr,Ao,Po}from"./chunk-gzt3ghgq.js";import"./chunk-2pph3dh0.js";import"./chunk-c57j92td.js";import"./chunk-rmavqxd8.js";import"./chunk-v7vkqg8f.js";import"./chunk-d4k4nyj0.js";import"./chunk-m9nr12a1.js";import"./chunk-b77v56fz.js";import"./chunk-qmcmjdy7.js";import"./chunk-1erc0vrb.js";import"./chunk-81t6zr3m.js";import"./chunk-e6y6s7q8.js";import"./chunk-kp4mzspk.js";import{wu,ko,vu,xu,Co,zr,$o,Su,Eo,ku,Cu,_o,To,Ro}from"./chunk-qhnpc3ac.js";import"./chunk-8qdvhbv7.js";import"./chunk-szry3s17.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{Hr,Ao,Po}from"./chunk-tkagcknf.js";import"./chunk-798epzq5.js";import"./chunk-c57j92td.js";import"./chunk-xd4zvm4x.js";import"./chunk-xsc9zbaj.js";import"./chunk-d4k4nyj0.js";import"./chunk-0np4t9ka.js";import"./chunk-5cyz97t4.js";import"./chunk-133ggr0t.js";import"./chunk-6k4f583z.js";import"./chunk-a5c75hxe.js";import"./chunk-e6y6s7q8.js";import"./chunk-kp4mzspk.js";import{vd,ko,wd,xd,Co,zr,Eo,Sd,$o,kd,Cd,_o,To,Ro}from"./chunk-88xqy2b9.js";import"./chunk-17fan751.js";import"./chunk-azza6dcr.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{wu as CRAFT_BRIDGE_SCRIPT,zr as CRAFT_COMPONENTS,Su as CRAFT_COMPONENT_RUNTIME,$o as CRAFT_COMPONENT_STYLES,Hr as NATIVE_COMPONENTS,_o as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Ao as compileToNative,Po as createHotReloadServer,ko as generateCraftBridgeScript,V as generateCraftOptimizations,Ro as getAvailableFormats,To as getAvailableTargets,Cu as getCraftComponents,G as getSSRCacheStats,Co as injectCraftBridge,vu as isCraftEnvironment,Y as prerenderForCraft,Eo as processCraftComponents,xu as processCraftDirective,ku 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{vd as CRAFT_BRIDGE_SCRIPT,zr as CRAFT_COMPONENTS,Sd as CRAFT_COMPONENT_RUNTIME,Eo as CRAFT_COMPONENT_STYLES,Hr as NATIVE_COMPONENTS,_o as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Ao as compileToNative,Po as createHotReloadServer,ko as generateCraftBridgeScript,V as generateCraftOptimizations,Ro as getAvailableFormats,To as getAvailableTargets,Cd as getCraftComponents,G as getSSRCacheStats,Co as injectCraftBridge,wd as isCraftEnvironment,Y as prerenderForCraft,$o as processCraftComponents,xd as processCraftDirective,kd as registerCraftComponent,Q as renderSSR};
@@ -246,6 +246,9 @@ export declare interface NativeBridgeInterface {
246
246
  capabilityTimeoutMs?: number
247
247
  initialAppState?: 'active' | 'inactive' | 'background'
248
248
  colorScheme?: 'light' | 'dark'
249
+ appURL?: string
250
+ appVersion?: string
251
+ appBuild?: string
249
252
  postMessage(message: string): void
250
253
  onMessage(callback: (message: string) => void): void
251
254
  }
@@ -9,6 +9,7 @@ export declare interface NativeScreensConfig {
9
9
  initialScreen: string
10
10
  screens: Record<string, string>
11
11
  file: string
12
+ app?: string
12
13
  }
13
14
  export declare interface NativeCompileOptions {
14
15
  format?: 'ir' | 'bundle'
@@ -25,7 +25,12 @@ export function loadNativeScreensConfig(cwd = process.cwd(), configFile) {
25
25
  const initialScreen = raw.initialScreen || entries[0][0];
26
26
  if (!screens[initialScreen])
27
27
  throw Error(`Initial screen ${initialScreen} is not in screens`);
28
- return { initialScreen, screens, file };
28
+ if (raw.app !== void 0 && typeof raw.app !== "string")
29
+ throw Error(`"app" must name the app script's file`);
30
+ const app = raw.app ? path.resolve(path.dirname(file), raw.app) : void 0;
31
+ if (app && !existsSync(app))
32
+ throw Error(`App script not found: ${app}`);
33
+ return { initialScreen, screens, file, ...app ? { app } : {} };
29
34
  }
30
35
  export async function runNativeCompile(file, options = {}) {
31
36
  const cwd = path.resolve(options.cwd ?? process.cwd()), format = options.format ?? "ir";
@@ -36,7 +41,7 @@ export async function runNativeCompile(file, options = {}) {
36
41
  throw Error(`Please specify an input file: stx native compile <file.stx>, or add ${NATIVE_CONFIG_FILES[0]}`);
37
42
  let output, diagnostics = [];
38
43
  if (format === "bundle") {
39
- const bundle = config ? await compileNativeBundle({ screens: config.screens, initialScreen: config.initialScreen, minify: options.minify, root: cwd }) : await compileScreenBundle(path.resolve(cwd, file), { minify: options.minify });
44
+ const bundle = config ? await compileNativeBundle({ screens: config.screens, initialScreen: config.initialScreen, minify: options.minify, root: cwd, ...config.app ? { app: config.app } : {} }) : await compileScreenBundle(path.resolve(cwd, file), { minify: options.minify });
40
45
  output = bundle.code;
41
46
  diagnostics = bundle.diagnostics;
42
47
  } else {
@@ -27,6 +27,7 @@ export declare interface CompileNativeBundleOptions {
27
27
  routed?: boolean
28
28
  outFile?: string
29
29
  root?: string
30
+ app?: string
30
31
  }
31
32
  /** Something the compiler could not translate exactly: an unknown icon or class. */
32
33
  export declare interface NativeDiagnostic {
@@ -1,6 +1,7 @@
1
1
  import { existsSync, mkdirSync } from "node:fs";
2
2
  import path from "node:path";
3
3
  import { compileScreenFile } from "./render-screen.js";
4
+ import { NATIVE_APP_ROUTE } from "../runtime/shared-screen.js";
4
5
  import { generateSignalsRuntime } from "../../signals.js";
5
6
  function nativeRuntimeModule(name) {
6
7
  const resolved = [
@@ -43,8 +44,17 @@ export async function compileNativeBundle(options) {
43
44
  throw Error(`Screen ${name} must name a .stx file`);
44
45
  compiledScreens.push({ name, file, compiled: await compileScreenFile(file, { root }) });
45
46
  }
46
- const runtimeGlobals = nativeRuntimeModule("jsc-globals"), sharedScreen = nativeRuntimeModule("shared-screen"), route = routed ? `var routeName = g.__stxNativeRoute || ${JSON.stringify(initialScreen)};
47
- if (routeNames.indexOf(routeName) === -1) throw new Error(['Unknown native screen:', routeName].join(' '));` : "var routeName = 'main';", selections = compiledScreens.map(({ name, compiled }, index) => `${index === 0 ? "if" : "else if"} (routeName === ${JSON.stringify(routed ? name : "main")}) {
47
+ const runtimeGlobals = nativeRuntimeModule("jsc-globals"), sharedScreen = nativeRuntimeModule("shared-screen"), appFile = options.app ? path.resolve(root, options.app) : null;
48
+ if (appFile && !existsSync(appFile))
49
+ throw Error(`The app script ${options.app} does not exist`);
50
+ if (appFile && !routed)
51
+ throw Error("An app script needs a routed bundle");
52
+ if (appFile && options.screens[NATIVE_APP_ROUTE])
53
+ throw Error(`${NATIVE_APP_ROUTE} is the app script's route, not a screen name`);
54
+ const route = routed ? `var routeName = g.__stxNativeRoute || ${JSON.stringify(initialScreen)};
55
+ var isApp = ${appFile ? `routeName === ${JSON.stringify(NATIVE_APP_ROUTE)}` : "false"};
56
+ if (!isApp && routeNames.indexOf(routeName) === -1) throw new Error(['Unknown native screen:', routeName].join(' '));` : `var routeName = 'main';
57
+ var isApp = false;`, selections = compiledScreens.map(({ name, compiled }, index) => `${index === 0 ? "if" : "else if"} (routeName === ${JSON.stringify(routed ? name : "main")}) {
48
58
  nativeDocument = ${JSON.stringify(compiled.document)};
49
59
  manifest = ${JSON.stringify(compiled.manifest)};
50
60
  }`).join(`
@@ -53,7 +63,8 @@ ${compiled.setup?.code ?? "g.__stx_latestSetup = null;"}
53
63
  }`).join(`
54
64
  `), contents = `
55
65
  import { installJSCGlobals } from ${JSON.stringify(runtimeGlobals)};
56
- import { prepareSharedNativeScreen } from ${JSON.stringify(sharedScreen)};
66
+ import { prepareNativeApp, prepareSharedNativeScreen } from ${JSON.stringify(sharedScreen)};
67
+ ${appFile ? `import * as nativeAppModule from ${JSON.stringify(appFile)};` : "var nativeAppModule = null;"}
57
68
  var g = globalThis;
58
69
  installJSCGlobals(g);
59
70
  var bridge = g.__stxNativeBridge;
@@ -64,12 +75,21 @@ g.__stxNativeRoute = routeName;
64
75
  var nativeDocument;
65
76
  var manifest;
66
77
  ${selections}
67
- var screen = prepareSharedNativeScreen(nativeDocument, manifest, bridge, { routeName: routeName, routeNames: routeNames });
68
- g.__stx_host = screen.host;
69
- g.__stxNativeUnmount = function() { screen.unmount(); };
78
+ var screen = null;
79
+ var app = null;
80
+ if (isApp) {
81
+ app = prepareNativeApp(bridge, { routeName: routeName, routeNames: routeNames });
82
+ g.__stxNativeUnmount = function() { app.unmount(); };
83
+ }
84
+ else {
85
+ screen = prepareSharedNativeScreen(nativeDocument, manifest, bridge, { routeName: routeName, routeNames: routeNames });
86
+ g.__stx_host = screen.host;
87
+ g.__stxNativeUnmount = function() { screen.unmount(); };
88
+ }
70
89
  ${generateSignalsRuntime()}
71
90
  ${setups}
72
- screen.mount(g.stx, g.__stx_latestSetup || null);
91
+ if (isApp) app.start(nativeAppModule);
92
+ else screen.mount(g.stx, g.__stx_latestSetup || null);
73
93
  `, code = await build("stx:native-shared-screens", [{
74
94
  name: "stx-native-shared-screens",
75
95
  setup(builder) {
@@ -27,6 +27,14 @@ const DROP_SUBTREE = new Set(["script", "style", "head", "meta", "link", "title"
27
27
  "end-editing": "onEndEditing",
28
28
  endediting: "onEndEditing",
29
29
  scroll: "onScroll",
30
+ "scroll-begin-drag": "onScrollBeginDrag",
31
+ scrollbegindrag: "onScrollBeginDrag",
32
+ "scroll-end-drag": "onScrollEndDrag",
33
+ scrollenddrag: "onScrollEndDrag",
34
+ "momentum-scroll-begin": "onMomentumScrollBegin",
35
+ momentumscrollbegin: "onMomentumScrollBegin",
36
+ "momentum-scroll-end": "onMomentumScrollEnd",
37
+ momentumscrollend: "onMomentumScrollEnd",
30
38
  refresh: "onRefresh",
31
39
  layout: "onLayout",
32
40
  "end-reached": "onEndReached",
@@ -67,6 +75,8 @@ export const NATIVE_EVENTS = new Set([
67
75
  "onLoadEnd",
68
76
  "onLoadStart",
69
77
  "onLongPress",
78
+ "onMomentumScrollBegin",
79
+ "onMomentumScrollEnd",
70
80
  "onPause",
71
81
  "onPlay",
72
82
  "onPress",
@@ -76,6 +86,8 @@ export const NATIVE_EVENTS = new Set([
76
86
  "onRequestClose",
77
87
  "onRefresh",
78
88
  "onScroll",
89
+ "onScrollBeginDrag",
90
+ "onScrollEndDrag",
79
91
  "onShow",
80
92
  "onSlidingComplete",
81
93
  "onSubmitEditing",
@@ -53,12 +53,15 @@ export declare const LUCIDE_TO_SF: {
53
53
  'bell-off': 'bell.slash';
54
54
  'bell-ring': 'bell.and.waves.left.and.right';
55
55
  'bike': 'figure.outdoor.cycle';
56
+ 'blocks': 'square.grid.2x2';
56
57
  'bluetooth': 'antenna.radiowaves.left.and.right';
57
58
  'book': 'book';
58
59
  'book-open': 'book';
59
60
  'bookmark': 'bookmark';
60
61
  'box': 'shippingbox';
61
62
  'brain': 'brain';
63
+ 'building': 'building';
64
+ 'building-2': 'building.2';
62
65
  'cable': 'cable.connector';
63
66
  'calendar': 'calendar';
64
67
  'calendar-check': 'calendar.badge.checkmark';
@@ -74,7 +77,9 @@ export declare const LUCIDE_TO_SF: {
74
77
  'calendar-x-2': 'calendar.badge.exclamationmark';
75
78
  'camera': 'camera';
76
79
  'chart-bar': 'chart.bar';
80
+ 'chart-column': 'chart.bar';
77
81
  'chart-line': 'chart.xyaxis.line';
82
+ 'chart-no-axes-gantt': 'chart.bar.doc.horizontal';
78
83
  'check': 'checkmark';
79
84
  'check-circle': 'checkmark.circle';
80
85
  'check-circle-2': 'checkmark.circle';
@@ -87,6 +92,7 @@ export declare const LUCIDE_TO_SF: {
87
92
  'circle-arrow-down': 'arrow.down.circle';
88
93
  'circle-check': 'checkmark.circle';
89
94
  'circle-check-big': 'checkmark.circle';
95
+ 'circle-dot': 'smallcircle.filled.circle';
90
96
  'circle-help': 'questionmark.circle';
91
97
  'circle-play': 'play.circle';
92
98
  'circle-plus': 'plus.circle';
@@ -96,7 +102,11 @@ export declare const LUCIDE_TO_SF: {
96
102
  'clipboard': 'clipboard';
97
103
  'clipboard-list': 'list.clipboard';
98
104
  'clock': 'clock';
105
+ 'clock-12': 'clock';
106
+ 'clock-2': 'clock';
99
107
  'clock-3': 'clock';
108
+ 'clock-4': 'clock';
109
+ 'clock-8': 'clock';
100
110
  'cloud': 'cloud';
101
111
  'cloud-off': 'icloud.slash';
102
112
  'coffee': 'cup.and.saucer';
@@ -124,6 +134,7 @@ export declare const LUCIDE_TO_SF: {
124
134
  'globe': 'globe';
125
135
  'graduation-cap': 'graduationcap';
126
136
  'grip-vertical': 'line.3.horizontal';
137
+ 'hand-fist': 'hand.raised';
127
138
  'heart': 'heart';
128
139
  'heart-off': 'heart.slash';
129
140
  'heart-pulse': 'heart.text.square';
@@ -132,10 +143,12 @@ export declare const LUCIDE_TO_SF: {
132
143
  'home': 'house';
133
144
  'hourglass': 'hourglass';
134
145
  'house': 'house';
146
+ 'id-card': 'person.text.rectangle';
135
147
  'image': 'photo';
136
148
  'inbox': 'tray';
137
149
  'info': 'info.circle';
138
150
  'layers': 'square.3.layers.3d';
151
+ 'layout-dashboard': 'rectangle.3.group';
139
152
  'layout-grid': 'square.grid.2x2';
140
153
  'leaf': 'leaf';
141
154
  'library': 'books.vertical';
@@ -152,6 +165,7 @@ export declare const LUCIDE_TO_SF: {
152
165
  'map': 'map';
153
166
  'map-pin': 'mappin.and.ellipse';
154
167
  'medal': 'medal';
168
+ 'megaphone': 'megaphone';
155
169
  'menu': 'line.3.horizontal';
156
170
  'message-circle': 'bubble.left';
157
171
  'message-square': 'text.bubble';
@@ -184,6 +198,7 @@ export declare const LUCIDE_TO_SF: {
184
198
  'satellite': 'antenna.radiowaves.left.and.right';
185
199
  'save': 'square.and.arrow.down';
186
200
  'scale': 'scalemass';
201
+ 'scan-line': 'barcode.viewfinder';
187
202
  'search': 'magnifyingglass';
188
203
  'send': 'paperplane';
189
204
  'settings': 'gearshape';
@@ -194,6 +209,7 @@ export declare const LUCIDE_TO_SF: {
194
209
  'shield-check': 'checkmark.shield';
195
210
  'shopping-bag': 'bag';
196
211
  'shopping-cart': 'cart';
212
+ 'shuffle': 'shuffle';
197
213
  'skip-back': 'backward.end';
198
214
  'skip-forward': 'forward.end';
199
215
  'sliders': 'slider.horizontal.3';
@@ -201,10 +217,12 @@ export declare const LUCIDE_TO_SF: {
201
217
  'smartphone': 'iphone';
202
218
  'snowflake': 'snowflake';
203
219
  'sparkles': 'sparkles';
220
+ 'sprout': 'leaf';
204
221
  'square': 'square';
205
222
  'star': 'star';
206
223
  'stopwatch': 'stopwatch';
207
224
  'store': 'storefront';
225
+ 'stretch-horizontal': 'rectangle.split.1x2';
208
226
  'sun': 'sun.max';
209
227
  'sunrise': 'sunrise';
210
228
  'sunset': 'sunset';
@@ -232,8 +250,10 @@ export declare const LUCIDE_TO_SF: {
232
250
  'user-round-x': 'person.crop.circle.badge.xmark';
233
251
  'user-x': 'person.crop.circle.badge.xmark';
234
252
  'users': 'person.2';
253
+ 'users-round': 'person.2';
235
254
  'video': 'video';
236
255
  'volume-2': 'speaker.wave.2';
256
+ 'warehouse': 'building.2';
237
257
  'watch': 'applewatch';
238
258
  'waves': 'figure.pool.swim';
239
259
  'weight': 'scalemass';
@@ -27,12 +27,15 @@ export const FALLBACK_SYMBOL = "circle", LUCIDE_TO_SF = {
27
27
  "bell-off": "bell.slash",
28
28
  "bell-ring": "bell.and.waves.left.and.right",
29
29
  bike: "figure.outdoor.cycle",
30
+ blocks: "square.grid.2x2",
30
31
  bluetooth: "antenna.radiowaves.left.and.right",
31
32
  book: "book",
32
33
  "book-open": "book",
33
34
  bookmark: "bookmark",
34
35
  box: "shippingbox",
35
36
  brain: "brain",
37
+ building: "building",
38
+ "building-2": "building.2",
36
39
  cable: "cable.connector",
37
40
  calendar: "calendar",
38
41
  "calendar-check": "calendar.badge.checkmark",
@@ -48,7 +51,9 @@ export const FALLBACK_SYMBOL = "circle", LUCIDE_TO_SF = {
48
51
  "calendar-x-2": "calendar.badge.exclamationmark",
49
52
  camera: "camera",
50
53
  "chart-bar": "chart.bar",
54
+ "chart-column": "chart.bar",
51
55
  "chart-line": "chart.xyaxis.line",
56
+ "chart-no-axes-gantt": "chart.bar.doc.horizontal",
52
57
  check: "checkmark",
53
58
  "check-circle": "checkmark.circle",
54
59
  "check-circle-2": "checkmark.circle",
@@ -61,6 +66,7 @@ export const FALLBACK_SYMBOL = "circle", LUCIDE_TO_SF = {
61
66
  "circle-arrow-down": "arrow.down.circle",
62
67
  "circle-check": "checkmark.circle",
63
68
  "circle-check-big": "checkmark.circle",
69
+ "circle-dot": "smallcircle.filled.circle",
64
70
  "circle-help": "questionmark.circle",
65
71
  "circle-play": "play.circle",
66
72
  "circle-plus": "plus.circle",
@@ -70,7 +76,11 @@ export const FALLBACK_SYMBOL = "circle", LUCIDE_TO_SF = {
70
76
  clipboard: "clipboard",
71
77
  "clipboard-list": "list.clipboard",
72
78
  clock: "clock",
79
+ "clock-12": "clock",
80
+ "clock-2": "clock",
73
81
  "clock-3": "clock",
82
+ "clock-4": "clock",
83
+ "clock-8": "clock",
74
84
  cloud: "cloud",
75
85
  "cloud-off": "icloud.slash",
76
86
  coffee: "cup.and.saucer",
@@ -98,6 +108,7 @@ export const FALLBACK_SYMBOL = "circle", LUCIDE_TO_SF = {
98
108
  globe: "globe",
99
109
  "graduation-cap": "graduationcap",
100
110
  "grip-vertical": "line.3.horizontal",
111
+ "hand-fist": "hand.raised",
101
112
  heart: "heart",
102
113
  "heart-off": "heart.slash",
103
114
  "heart-pulse": "heart.text.square",
@@ -106,10 +117,12 @@ export const FALLBACK_SYMBOL = "circle", LUCIDE_TO_SF = {
106
117
  home: "house",
107
118
  hourglass: "hourglass",
108
119
  house: "house",
120
+ "id-card": "person.text.rectangle",
109
121
  image: "photo",
110
122
  inbox: "tray",
111
123
  info: "info.circle",
112
124
  layers: "square.3.layers.3d",
125
+ "layout-dashboard": "rectangle.3.group",
113
126
  "layout-grid": "square.grid.2x2",
114
127
  leaf: "leaf",
115
128
  library: "books.vertical",
@@ -126,6 +139,7 @@ export const FALLBACK_SYMBOL = "circle", LUCIDE_TO_SF = {
126
139
  map: "map",
127
140
  "map-pin": "mappin.and.ellipse",
128
141
  medal: "medal",
142
+ megaphone: "megaphone",
129
143
  menu: "line.3.horizontal",
130
144
  "message-circle": "bubble.left",
131
145
  "message-square": "text.bubble",
@@ -158,6 +172,7 @@ export const FALLBACK_SYMBOL = "circle", LUCIDE_TO_SF = {
158
172
  satellite: "antenna.radiowaves.left.and.right",
159
173
  save: "square.and.arrow.down",
160
174
  scale: "scalemass",
175
+ "scan-line": "barcode.viewfinder",
161
176
  search: "magnifyingglass",
162
177
  send: "paperplane",
163
178
  settings: "gearshape",
@@ -168,6 +183,7 @@ export const FALLBACK_SYMBOL = "circle", LUCIDE_TO_SF = {
168
183
  "shield-check": "checkmark.shield",
169
184
  "shopping-bag": "bag",
170
185
  "shopping-cart": "cart",
186
+ shuffle: "shuffle",
171
187
  "skip-back": "backward.end",
172
188
  "skip-forward": "forward.end",
173
189
  sliders: "slider.horizontal.3",
@@ -175,10 +191,12 @@ export const FALLBACK_SYMBOL = "circle", LUCIDE_TO_SF = {
175
191
  smartphone: "iphone",
176
192
  snowflake: "snowflake",
177
193
  sparkles: "sparkles",
194
+ sprout: "leaf",
178
195
  square: "square",
179
196
  star: "star",
180
197
  stopwatch: "stopwatch",
181
198
  store: "storefront",
199
+ "stretch-horizontal": "rectangle.split.1x2",
182
200
  sun: "sun.max",
183
201
  sunrise: "sunrise",
184
202
  sunset: "sunset",
@@ -206,8 +224,10 @@ export const FALLBACK_SYMBOL = "circle", LUCIDE_TO_SF = {
206
224
  "user-round-x": "person.crop.circle.badge.xmark",
207
225
  "user-x": "person.crop.circle.badge.xmark",
208
226
  users: "person.2",
227
+ "users-round": "person.2",
209
228
  video: "video",
210
229
  "volume-2": "speaker.wave.2",
230
+ warehouse: "building.2",
211
231
  watch: "applewatch",
212
232
  waves: "figure.pool.swim",
213
233
  weight: "scalemass",
@@ -40,7 +40,8 @@ function capabilityFlags(capabilities) {
40
40
  health: capabilities.has("health"),
41
41
  dialogs: capabilities.has("dialog"),
42
42
  browser: capabilities.has("browser"),
43
- appleSignIn: capabilities.has("appleSignIn")
43
+ appleSignIn: capabilities.has("appleSignIn"),
44
+ background: capabilities.has("background")
44
45
  };
45
46
  }
46
47
  function platformUserAgent(platform) {
@@ -146,6 +147,13 @@ export function installCraftBridge(protocol, nativeBridge, target = globalThis,
146
147
  };
147
148
  if (capabilities.has("browser"))
148
149
  craft.browser = { open: (url, options = {}) => ask("Browser", "open", [url, options]) };
150
+ craft.app = {
151
+ url: typeof nativeBridge.appURL === "string" ? nativeBridge.appURL : "",
152
+ version: typeof nativeBridge.appVersion === "string" ? nativeBridge.appVersion : "",
153
+ build: typeof nativeBridge.appBuild === "string" ? nativeBridge.appBuild : ""
154
+ };
155
+ if (capabilities.has("background"))
156
+ craft.background = { complete: (ok = !0, id) => request("Background", "complete", [ok !== !1, typeof id === "string" ? id : null]).then(() => !0, () => !1) };
149
157
  if (capabilities.has("appleSignIn"))
150
158
  craft.signInWithApple = (options = {}) => ask("Auth", "signInWithApple", [options]);
151
159
  if (capabilities.has("linking")) {
@@ -203,5 +203,7 @@ export declare interface NativeCraft {
203
203
  onChange: (callback: (state: string) => unknown) => () => void
204
204
  }
205
205
  deepLinks: { getInitialURL: () => Promise<string | null>, onLink: (callback: (link: unknown) => unknown) => () => void }
206
+ app: { url: string, version: string, build: string }
207
+ background?: { complete: (ok?: boolean, id?: string) => Promise<boolean> }
206
208
  }
207
209
  export type NativePermissionStatus = 'granted' | 'denied' | 'undetermined';
@@ -49,6 +49,14 @@ const NATIVE_EVENT_NAMES = {
49
49
  "end-editing": "onEndEditing",
50
50
  endediting: "onEndEditing",
51
51
  scroll: "onScroll",
52
+ "scroll-begin-drag": "onScrollBeginDrag",
53
+ scrollbegindrag: "onScrollBeginDrag",
54
+ "scroll-end-drag": "onScrollEndDrag",
55
+ scrollenddrag: "onScrollEndDrag",
56
+ "momentum-scroll-begin": "onMomentumScrollBegin",
57
+ momentumscrollbegin: "onMomentumScrollBegin",
58
+ "momentum-scroll-end": "onMomentumScrollEnd",
59
+ momentumscrollend: "onMomentumScrollEnd",
52
60
  refresh: "onRefresh",
53
61
  layout: "onLayout",
54
62
  "end-reached": "onEndReached",
@@ -5,6 +5,9 @@ import type { NativeBridgeInterface } from '../bridge/protocol';
5
5
  import type { STXDocument } from '../compiler/ir';
6
6
  /** Connect translated IR to the ordinary stx signals runtime and native bridge. */
7
7
  export declare function prepareSharedNativeScreen(document: STXDocument, manifest: BindingManifest, bridge: NativeBridgeInterface, options?: CraftBridgeOptions): SharedNativeScreen;
8
+ export declare function prepareNativeApp(bridge: NativeBridgeInterface, options?: CraftBridgeOptions): SharedNativeApp;
9
+ /** The route a host names to run the app script rather than a screen. */
10
+ export declare const NATIVE_APP_ROUTE: '__app';
8
11
  declare interface SharedSignalsRuntime {
9
12
  hydrateHost: (root: unknown, setup: (() => Record<string, unknown>) | Record<string, unknown> | null, manifest: BindingManifest, nodes: Map<number, unknown>) => (() => void)
10
13
  }
@@ -13,3 +16,21 @@ export declare interface SharedNativeScreen {
13
16
  mount: (runtime: SharedSignalsRuntime, setup: (() => Record<string, unknown>) | null) => void
14
17
  unmount: () => void
15
18
  }
19
+ export declare interface SharedNativeApp {
20
+ start: (main: NativeAppMain | { default?: NativeAppMain } | null | undefined) => void
21
+ unmount: () => void
22
+ }
23
+ /**
24
+ * The app script: one context for the app's whole life, with no screen.
25
+ *
26
+ * What a phone app does whatever is on screen lives here: registering for
27
+ * push and following a tapped notification, background refresh, keeping the
28
+ * account's details fresh for the screens. The host runs it from the same
29
+ * bundle as the screens, under the route `__app` (Craft's `nativeApp`), and
30
+ * it gets the same `craft` bridge a screen does, minus drawing. The host's
31
+ * app events - a notification tapped or received, a silent push, a
32
+ * background refresh - arrive as the page's CustomEvents on its global
33
+ * (`craftNotificationResponse`, `craftBackgroundRefresh`, ...), so code
34
+ * shared with the page (`@stacksjs/mobile`) hears them unchanged.
35
+ */
36
+ export type NativeAppMain = (craft: Record<string, any>) => void | (() => void) | Promise<void | (() => void)>;
@@ -59,3 +59,46 @@ export function prepareSharedNativeScreen(document, manifest, bridge, options =
59
59
  }
60
60
  };
61
61
  }
62
+ export const NATIVE_APP_ROUTE = "__app";
63
+ export function prepareNativeApp(bridge, options = {}) {
64
+ const protocol = new STXBridge;
65
+ protocol.initialize(bridge);
66
+ const craft = installCraftBridge(protocol, bridge, globalThis, { ...options, routeName: options.routeName || NATIVE_APP_ROUTE });
67
+ let cleanup = null, stopped = !1;
68
+ const report = (error) => console.error(`[stx native] the app script failed: ${error instanceof Error ? error.stack || error.message : String(error)}`), keep = (value) => {
69
+ if (typeof value !== "function")
70
+ return;
71
+ if (stopped)
72
+ value();
73
+ else
74
+ cleanup = value;
75
+ };
76
+ return {
77
+ start(main) {
78
+ const run = typeof main === "function" ? main : main?.default;
79
+ if (typeof run !== "function") {
80
+ console.error("[stx native] the app script exports no function to run");
81
+ return;
82
+ }
83
+ try {
84
+ const answer = run(craft);
85
+ if (answer && typeof answer.then === "function")
86
+ answer.then(keep, report);
87
+ else
88
+ keep(answer);
89
+ } catch (error) {
90
+ report(error);
91
+ }
92
+ },
93
+ unmount() {
94
+ stopped = !0;
95
+ try {
96
+ cleanup?.();
97
+ } catch (error) {
98
+ report(error);
99
+ }
100
+ cleanup = null;
101
+ protocol.dispose("screen-closed");
102
+ }
103
+ };
104
+ }
package/dist/pwa.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{Ln,Oe,Bo,Wa}from"./chunk-4c1afy15.js";import{Nn,Vr,Ha,Va,Ua}from"./chunk-jbvg29t0.js";import{No,Lo,jo,Fa,za}from"./chunk-e62nw7zk.js";import{oe,gt,Ur}from"./chunk-hkjqqx92.js";import{Xc,Gc,Jc,Yc,fr,md}from"./chunk-jwjggr91.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-mdfrm5hv.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{Ln,Oe,Bo,Wa}from"./chunk-qv57r0fa.js";import{Nn,Vr,Ha,Va,Ua}from"./chunk-vftdacyb.js";import{No,Lo,jo,Fa,za}from"./chunk-e62nw7zk.js";import{oe,gt,Ur}from"./chunk-hkjqqx92.js";import{Xc,Gc,Jc,Yc,fr,mu}from"./chunk-3ynfz6h8.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-wrghqec5.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=Ln(n,t);if(a){let s=Oe(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 Vr(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,Lo as auditBuildOutput,No as auditConfig,re as buildPwaAssets,jo as calculateAuditResult,za as formatAuditResult,Ur as formatSize,j as generateManifest,_ as generateManifestJson,Va as generateManifestLink,F as generateOfflinePage,oe as generatePrecacheManifest,gt as generatePrecacheManifestJs,M as generatePwaIcons,Nn as generatePwaTags,Ln as generateServiceWorker,Wa as generateServiceWorkerAuto,Ha as generateSwRegistrationScript,Ua as generateThemeColorMeta,N as getExpectedIconPaths,Oe as getServiceWorkerFileName,Vr as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,Bo as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,fr as pwaDirectives,Xc as pwaInstallDirective,Jc as pwaOfflineDirective,Yc as pwaPushDirective,Gc as pwaUpdateDirective,md as registerPwaDirectives,Fa 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=Ln(n,t);if(a){let s=Oe(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 Vr(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,Lo as auditBuildOutput,No as auditConfig,re as buildPwaAssets,jo as calculateAuditResult,za as formatAuditResult,Ur as formatSize,j as generateManifest,_ as generateManifestJson,Va as generateManifestLink,F as generateOfflinePage,oe as generatePrecacheManifest,gt as generatePrecacheManifestJs,M as generatePwaIcons,Nn as generatePwaTags,Ln as generateServiceWorker,Wa as generateServiceWorkerAuto,Ha as generateSwRegistrationScript,Ua as generateThemeColorMeta,N as getExpectedIconPaths,Oe as getServiceWorkerFileName,Vr as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,Bo as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,fr as pwaDirectives,Xc as pwaInstallDirective,Jc as pwaOfflineDirective,Yc as pwaPushDirective,Gc as pwaUpdateDirective,mu as registerPwaDirectives,Fa as runPwaAudit,D as validateManifest};