@stacksjs/stx 0.2.893 → 0.2.895
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.
- package/dist/{chunk-sdssbyme.js → chunk-09cmfbtq.js} +1 -1
- package/dist/{chunk-r0hesekf.js → chunk-0jsw689c.js} +2 -2
- package/dist/{chunk-qn45rk5n.js → chunk-0k437z3q.js} +1 -1
- package/dist/{chunk-5zs5hrgz.js → chunk-1bft48gk.js} +2 -2
- package/dist/{chunk-a0cjfp4h.js → chunk-1d5h81e8.js} +4 -4
- package/dist/{chunk-6e2gvepr.js → chunk-1maxx7c0.js} +2 -2
- package/dist/{chunk-d4bxha9y.js → chunk-1snd71rb.js} +5 -5
- package/dist/{chunk-kz1kv7ba.js → chunk-24jpq3x9.js} +1 -1
- package/dist/{chunk-z8sv926e.js → chunk-2nqmw4dv.js} +1 -1
- package/dist/{chunk-3kyyj4ee.js → chunk-2q3906d1.js} +1 -1
- package/dist/{chunk-gk0h2hp7.js → chunk-35j7gaj5.js} +1 -1
- package/dist/chunk-3g9rqq1q.js +2 -0
- package/dist/{chunk-45wwfx0d.js → chunk-42y9vez9.js} +1 -1
- package/dist/{chunk-nd9486pv.js → chunk-43p015r0.js} +2 -2
- package/dist/{chunk-90qwzwsm.js → chunk-4akw3bym.js} +1 -1
- package/dist/{chunk-vya7cck4.js → chunk-4d85str1.js} +1 -1
- package/dist/{chunk-avz14zcx.js → chunk-4sgsqy4m.js} +1 -1
- package/dist/{chunk-n2cyjt2a.js → chunk-50vm6n32.js} +1 -1
- package/dist/{chunk-3h8vcpdh.js → chunk-565y54r4.js} +1 -1
- package/dist/chunk-5am3wqxy.js +3 -0
- package/dist/{chunk-tbcqyehb.js → chunk-5mpqgfhk.js} +1 -1
- package/dist/{chunk-zye82rs1.js → chunk-5xg32v1j.js} +1 -1
- package/dist/{chunk-pjpf21y9.js → chunk-690518hw.js} +1 -1
- package/dist/{chunk-tfkxdkyj.js → chunk-6c5166vk.js} +4 -4
- package/dist/{chunk-8gtrh7c3.js → chunk-6e7y124e.js} +5 -5
- package/dist/{chunk-xvprhdcb.js → chunk-80ky40mm.js} +1 -1
- package/dist/chunk-892massc.js +2 -0
- package/dist/{chunk-gzc16hs8.js → chunk-8ccgty8s.js} +2 -2
- package/dist/{chunk-1ge6ssye.js → chunk-907j23v6.js} +1 -1
- package/dist/chunk-9e1kvc4x.js +2 -0
- package/dist/{chunk-mmmn609f.js → chunk-9f1z2m20.js} +1 -1
- package/dist/{chunk-9wpkgbj6.js → chunk-9fax7t00.js} +1 -1
- package/dist/{chunk-mb7vq3xg.js → chunk-9kp96zv3.js} +1 -1
- package/dist/{chunk-r21j8j6y.js → chunk-9ndmhsdx.js} +2 -2
- package/dist/{chunk-n64zbwzr.js → chunk-9rjgq8k4.js} +1 -1
- package/dist/chunk-9vf498z6.js +2 -0
- package/dist/chunk-a90qcnwb.js +2 -0
- package/dist/{chunk-kd7k31x3.js → chunk-aj5tsksz.js} +4 -4
- package/dist/{chunk-nqntsdpr.js → chunk-akfnh8mz.js} +16 -16
- package/dist/{chunk-dwdk0dgs.js → chunk-bewej27v.js} +2 -2
- package/dist/{chunk-9f8fda1j.js → chunk-ch9028z3.js} +1 -1
- package/dist/{chunk-z012vpdz.js → chunk-cmg9x1ka.js} +3 -3
- package/dist/chunk-cp5x6kx1.js +2 -0
- package/dist/{chunk-x9036mfd.js → chunk-cphc60zw.js} +2 -2
- package/dist/{chunk-2ae2bg4v.js → chunk-d91ye18t.js} +2 -2
- package/dist/{chunk-1cn2gqrs.js → chunk-dh4amsmt.js} +1 -1
- package/dist/{chunk-j3sskge5.js → chunk-dmkagztw.js} +9 -9
- package/dist/chunk-e8szp5wa.js +2 -0
- package/dist/{chunk-nhhek6r3.js → chunk-egv22r65.js} +1 -1
- package/dist/{chunk-zgz1e98d.js → chunk-f0j64d16.js} +1 -1
- package/dist/{chunk-jx22ck8c.js → chunk-f1hspgx5.js} +1 -1
- package/dist/{chunk-h74cr6b4.js → chunk-f80g9gfs.js} +4 -4
- package/dist/chunk-g4c58z3e.js +2 -0
- package/dist/chunk-h2119dke.js +2 -0
- package/dist/chunk-j7mmzse6.js +2 -0
- package/dist/chunk-jybsskzz.js +2 -0
- package/dist/chunk-kavcz5cp.js +2 -0
- package/dist/chunk-mcgheg2b.js +2 -0
- package/dist/{chunk-tshmrja0.js → chunk-mxzkva5m.js} +19 -19
- package/dist/chunk-neyr68r7.js +2 -0
- package/dist/{chunk-kwp3efvt.js → chunk-q63hewj3.js} +1 -1
- package/dist/chunk-qvxpdcc6.js +182 -0
- package/dist/{chunk-t7dh01wq.js → chunk-rbj1esz5.js} +1 -1
- package/dist/{chunk-6c4p7mkn.js → chunk-rnbgyc6a.js} +4 -4
- package/dist/chunk-rt3kt20v.js +2 -0
- package/dist/chunk-s8vnv2qz.js +2 -0
- package/dist/{chunk-a8p1jfpg.js → chunk-sxbp14d6.js} +1 -1
- package/dist/{chunk-5pwyhjgp.js → chunk-szamt7km.js} +3 -3
- package/dist/{chunk-kfbw96c5.js → chunk-t0ttxayz.js} +2 -2
- package/dist/{chunk-qrk535j6.js → chunk-t3zmfh8w.js} +4 -4
- package/dist/{chunk-gcjqxvbb.js → chunk-ta07gj66.js} +2 -2
- package/dist/chunk-tbh7r1wh.js +2 -0
- package/dist/{chunk-5wyp6mkb.js → chunk-tjbdzqmj.js} +1 -1
- package/dist/{chunk-40jqsdx7.js → chunk-twhgxmtq.js} +1 -1
- package/dist/chunk-vjvwey2m.js +2 -0
- package/dist/chunk-w1a1381e.js +2 -0
- package/dist/{chunk-mxf6cfbg.js → chunk-whcrca58.js} +6 -6
- package/dist/{chunk-6t17aj34.js → chunk-wnq48app.js} +1 -1
- package/dist/chunk-x0m6qc7k.js +2 -0
- package/dist/{chunk-brqmpfdf.js → chunk-xhzchddb.js} +1 -1
- package/dist/{chunk-ac3e6nhg.js → chunk-xmg6bmh6.js} +3 -3
- package/dist/{chunk-2eq3aret.js → chunk-xwrjre34.js} +1 -1
- package/dist/{chunk-h7yme97q.js → chunk-xy8smv5e.js} +2 -2
- package/dist/chunk-y0znf960.js +2 -0
- package/dist/{chunk-hkazdsd0.js → chunk-z1vwkjp8.js} +1 -1
- package/dist/{chunk-n5wnwgf7.js → chunk-z4gdyb70.js} +5 -5
- package/dist/{chunk-xj3xsh91.js → chunk-zaqa1kk0.js} +2 -2
- package/dist/chunk-zcykktfx.js +2 -0
- package/dist/{chunk-8y39f6z3.js → chunk-zf68afyh.js} +3 -3
- package/dist/cli.js +14 -14
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/native/accessibility.d.ts +0 -15
- package/dist/native/accessibility.js +2 -6
- package/dist/native/compiler/html-to-ir.js +1 -27
- package/dist/native/components/primitives.d.ts +1 -0
- package/dist/native/runtime/craft-bridge.js +4 -3
- package/dist/native/runtime/craft.d.ts +8 -1
- package/dist/native/runtime/native-host.js +28 -15
- package/dist/native/runtime/navigation-chrome.d.ts +2 -2
- package/dist/native/runtime/navigation-chrome.js +4 -4
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +10 -10
- package/package.json +5 -5
- package/dist/chunk-0046tjst.js +0 -2
- package/dist/chunk-11mc33tj.js +0 -2
- package/dist/chunk-1nsm5hb6.js +0 -2
- package/dist/chunk-3ngbdap1.js +0 -2
- package/dist/chunk-484x27q5.js +0 -2
- package/dist/chunk-5e80cn6p.js +0 -2
- package/dist/chunk-acp19g7b.js +0 -2
- package/dist/chunk-as1crtt9.js +0 -2
- package/dist/chunk-g1cp937x.js +0 -2
- package/dist/chunk-gazgkq70.js +0 -3
- package/dist/chunk-m7w0d5q2.js +0 -2
- package/dist/chunk-md0ws524.js +0 -2
- package/dist/chunk-p375zsge.js +0 -2
- package/dist/chunk-p7sk9ptz.js +0 -2
- package/dist/chunk-q36p39vg.js +0 -2
- package/dist/chunk-qp5qmva3.js +0 -2
- package/dist/chunk-twecn5jv.js +0 -2
- package/dist/chunk-vj7wpwzm.js +0 -2
- package/dist/chunk-vm57848v.js +0 -2
- package/dist/chunk-vvyh4e5w.js +0 -2
- package/dist/chunk-xdm6657b.js +0 -2
- package/dist/chunk-xsebmdqe.js +0 -2
- package/dist/chunk-xwcgt6re.js +0 -182
- package/dist/chunk-y2y6qtjr.js +0 -2
package/dist/craft-entry.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
2
|
+
import"./chunk-akfnh8mz.js";import{Vo,Ua,Wa}from"./chunk-cmg9x1ka.js";import"./chunk-whcrca58.js";import"./chunk-0jdz31q1.js";import"./chunk-xmg6bmh6.js";import"./chunk-cphc60zw.js";import"./chunk-vk2jy6mn.js";import"./chunk-3b3mkgpj.js";import"./chunk-41z7f41b.js";import"./chunk-42y9vez9.js";import"./chunk-q0y8gv18.js";import"./chunk-8ccgty8s.js";import"./chunk-f80g9gfs.js";import"./chunk-t3zmfh8w.js";import"./chunk-rb2zbdqd.js";import"./chunk-egv22r65.js";import"./chunk-1d5h81e8.js";import"./chunk-dmkagztw.js";import"./chunk-0jsw689c.js";import"./chunk-6c5166vk.js";import"./chunk-43p015r0.js";import"./chunk-sxbp14d6.js";import"./chunk-05x1rd86.js";import"./chunk-pvm48tse.js";import{Hu,qa,Xh,Jh,Ka,Uo,hs,Ga,Xa,Yh,Zh,Ja,Ya,Za,Qa}from"./chunk-z4gdyb70.js";import"./chunk-bewej27v.js";import"./chunk-5am3wqxy.js";import"./chunk-80ky40mm.js";import"./chunk-1snd71rb.js";import"./chunk-9rjgq8k4.js";import"./chunk-n6q1d66k.js";import"./chunk-szamt7km.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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}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{Hu as CRAFT_BRIDGE_SCRIPT,
|
|
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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}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{Hu as CRAFT_BRIDGE_SCRIPT,Uo as CRAFT_COMPONENTS,Ga as CRAFT_COMPONENT_RUNTIME,hs as CRAFT_COMPONENT_STYLES,Vo as NATIVE_COMPONENTS,Ja as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Ua as compileToNative,Wa as createHotReloadServer,Ya as findCraftBinary,qa as generateCraftBridgeScript,V as generateCraftOptimizations,Qa as getAvailableFormats,Za as getAvailableTargets,Zh as getCraftComponents,G as getSSRCacheStats,Ka as injectCraftBridge,Xh as isCraftEnvironment,Y as prerenderForCraft,Xa as processCraftComponents,Jh as processCraftDirective,Yh as registerCraftComponent,Q as renderSSR};
|
package/dist/craft.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
2
|
+
import"./chunk-akfnh8mz.js";import{Vo,Ua,Wa}from"./chunk-cmg9x1ka.js";import"./chunk-whcrca58.js";import"./chunk-0jdz31q1.js";import"./chunk-xmg6bmh6.js";import"./chunk-cphc60zw.js";import"./chunk-vk2jy6mn.js";import"./chunk-3b3mkgpj.js";import"./chunk-41z7f41b.js";import"./chunk-42y9vez9.js";import"./chunk-q0y8gv18.js";import"./chunk-8ccgty8s.js";import"./chunk-f80g9gfs.js";import"./chunk-t3zmfh8w.js";import"./chunk-rb2zbdqd.js";import"./chunk-egv22r65.js";import"./chunk-1d5h81e8.js";import"./chunk-dmkagztw.js";import"./chunk-0jsw689c.js";import"./chunk-6c5166vk.js";import"./chunk-43p015r0.js";import"./chunk-sxbp14d6.js";import"./chunk-05x1rd86.js";import"./chunk-pvm48tse.js";import{Hu,qa,Xh,Jh,Ka,Uo,hs,Ga,Xa,Yh,Zh,Ja,Ya,Za,Qa}from"./chunk-z4gdyb70.js";import"./chunk-bewej27v.js";import"./chunk-5am3wqxy.js";import"./chunk-80ky40mm.js";import"./chunk-1snd71rb.js";import"./chunk-9rjgq8k4.js";import"./chunk-n6q1d66k.js";import"./chunk-szamt7km.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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}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{Hu as CRAFT_BRIDGE_SCRIPT,
|
|
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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}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{Hu as CRAFT_BRIDGE_SCRIPT,Uo as CRAFT_COMPONENTS,Ga as CRAFT_COMPONENT_RUNTIME,hs as CRAFT_COMPONENT_STYLES,Vo as NATIVE_COMPONENTS,Ja as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Ua as compileToNative,Wa as createHotReloadServer,Ya as findCraftBinary,qa as generateCraftBridgeScript,V as generateCraftOptimizations,Qa as getAvailableFormats,Za as getAvailableTargets,Zh as getCraftComponents,G as getSSRCacheStats,Ka as injectCraftBridge,Xh as isCraftEnvironment,Y as prerenderForCraft,Xa as processCraftComponents,Jh as processCraftDirective,Yh as registerCraftComponent,Q as renderSSR};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/** Whether an attribute is one this module translates. */
|
|
2
2
|
export declare function isAccessibilityAttribute(name: string): boolean;
|
|
3
|
-
/** The role a host would announce for an ARIA `role`, or null where it has none. */
|
|
4
|
-
export declare function nativeRole(value: unknown): string | null;
|
|
5
3
|
/**
|
|
6
4
|
* The native props an attribute write implies, given the node's current props.
|
|
7
5
|
*
|
|
@@ -28,18 +26,5 @@ export declare function projectAccessibility(props: Record<string, unknown>, typ
|
|
|
28
26
|
export declare function accessibilityChanges(props: Record<string, unknown>, before: Record<string, unknown>, changedField: string, type?: string): Record<string, unknown>;
|
|
29
27
|
/** Recover authored native fields from compiler IR before reactive updates. */
|
|
30
28
|
export declare function authoredAccessibilityProps(props: Record<string, unknown>, source?: Record<string, unknown>): Record<string, unknown>;
|
|
31
|
-
/**
|
|
32
|
-
* Marks a box that names a group of controls (set by the compiler).
|
|
33
|
-
*
|
|
34
|
-
* A browser reads `<div role="group" aria-label="Pages">` as a name for what
|
|
35
|
-
* is inside. A host has no such thing for a plain box: a View with a label is
|
|
36
|
-
* one stop for a screen reader, and whatever is inside it can no longer be
|
|
37
|
-
* reached. The shared Pager was one stop called "Tour", its pages and its
|
|
38
|
-
* page dots gone. So the name of such a box is not sent: the group goes
|
|
39
|
-
* unnamed and its controls stay reachable, which is the half that matters.
|
|
40
|
-
* Hosts' own containers (a scroll view, a tab strip, a dialog) keep theirs.
|
|
41
|
-
* craft-native/craft#536 asks the host for a box that is both named and open.
|
|
42
|
-
*/
|
|
43
|
-
export declare const READER_GROUP: 'data-stx-reader-group';
|
|
44
29
|
/** Fields derived from web semantics at the native transport boundary. */
|
|
45
30
|
export declare const ACCESSIBILITY_FIELDS: readonly ['accessibilityLabel', 'accessibilityRole', 'accessibilityState', 'accessibilityValue'];
|
|
@@ -6,9 +6,7 @@ const STATE_KEYS = {
|
|
|
6
6
|
"aria-expanded": "expanded",
|
|
7
7
|
"aria-busy": "busy",
|
|
8
8
|
"aria-current": "selected"
|
|
9
|
-
}
|
|
10
|
-
export const READER_GROUP = "data-stx-reader-group";
|
|
11
|
-
const ROLES = {
|
|
9
|
+
}, ROLES = {
|
|
12
10
|
alert: "alert",
|
|
13
11
|
button: "button",
|
|
14
12
|
checkbox: "checkbox",
|
|
@@ -52,7 +50,7 @@ function stateValue(name, value) {
|
|
|
52
50
|
return;
|
|
53
51
|
return text === "" || text === "true";
|
|
54
52
|
}
|
|
55
|
-
|
|
53
|
+
function nativeRole(value) {
|
|
56
54
|
if (value === void 0 || value === null)
|
|
57
55
|
return null;
|
|
58
56
|
for (const role of String(value).trim().toLowerCase().split(/\s+/))
|
|
@@ -88,8 +86,6 @@ export function applyStaticAccessibility(props) {
|
|
|
88
86
|
}
|
|
89
87
|
if (stateValue("aria-hidden", props["aria-hidden"]) === !0)
|
|
90
88
|
derived.accessibilityRole = "none";
|
|
91
|
-
if (props[READER_GROUP] !== void 0)
|
|
92
|
-
delete derived.accessibilityLabel;
|
|
93
89
|
for (const key of ["accessibilityLabel", "accessibilityRole", "accessibilityValue"])
|
|
94
90
|
if (props[key] === void 0 && derived[key] !== void 0 && derived[key] !== null)
|
|
95
91
|
props[key] = derived[key];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ACCESSIBILITY_FIELDS,
|
|
1
|
+
import { ACCESSIBILITY_FIELDS, projectAccessibility } from "../accessibility.js";
|
|
2
2
|
import { applyStaticTextEntry } from "../text-entry.js";
|
|
3
3
|
import { NATIVE_EVENT_NAMES as EVENT_NAMES } from "../event-names.js";
|
|
4
4
|
import { NATIVE_BOOLEAN_PROPS, nativePropName } from "../prop-names.js";
|
|
@@ -523,36 +523,10 @@ export async function translateHtmlToIR(html, options = {}) {
|
|
|
523
523
|
project(child);
|
|
524
524
|
};
|
|
525
525
|
nameControlsFromLabels(root);
|
|
526
|
-
markReaderGroups(root);
|
|
527
526
|
project(root);
|
|
528
527
|
boundScrollingViewports(root);
|
|
529
528
|
return { root, diagnostics };
|
|
530
529
|
}
|
|
531
|
-
const READER_CONTROLS = new Set([
|
|
532
|
-
"Button",
|
|
533
|
-
"Link",
|
|
534
|
-
"TouchableOpacity",
|
|
535
|
-
"TouchableHighlight",
|
|
536
|
-
"Pressable",
|
|
537
|
-
"TextInput",
|
|
538
|
-
"Switch",
|
|
539
|
-
"Checkbox",
|
|
540
|
-
"Slider",
|
|
541
|
-
"Picker",
|
|
542
|
-
"SegmentedControl",
|
|
543
|
-
"DatePicker"
|
|
544
|
-
]);
|
|
545
|
-
function holdsControl(node) {
|
|
546
|
-
return node.children.some((child) => typeof child !== "string" && (READER_CONTROLS.has(child.type) || child.events.onPress !== void 0 || child.props.href !== void 0 || holdsControl(child)));
|
|
547
|
-
}
|
|
548
|
-
function markReaderGroups(node) {
|
|
549
|
-
const labelled = node.props["aria-label"] !== void 0 || node.bindings?.["aria-label"] !== void 0;
|
|
550
|
-
if (node.type === "View" && labelled && nativeRole(node.props.role) === null && node.events.onPress === void 0 && holdsControl(node))
|
|
551
|
-
node.props[READER_GROUP] = "";
|
|
552
|
-
for (const child of node.children)
|
|
553
|
-
if (typeof child !== "string")
|
|
554
|
-
markReaderGroups(child);
|
|
555
|
-
}
|
|
556
530
|
const LABELLED_CONTROLS = new Set(["TextInput", "Picker", "Switch", "Checkbox", "Slider", "DatePicker"]);
|
|
557
531
|
function nameControlsFromLabels(root) {
|
|
558
532
|
const byId = new Map, labels = [], visit = (node) => {
|
|
@@ -237,6 +237,7 @@ export declare interface DatePickerProps extends BaseProps {
|
|
|
237
237
|
maximumDate?: string | number
|
|
238
238
|
minuteInterval?: number
|
|
239
239
|
display?: 'compact' | 'inline' | 'wheels'
|
|
240
|
+
locale?: string
|
|
240
241
|
onValueChange?: (event: DatePickerChange) => void
|
|
241
242
|
onChange?: (event: DatePickerChange) => void
|
|
242
243
|
disabled?: boolean
|
|
@@ -900,7 +900,7 @@ export function installCraftBridge(protocol, nativeBridge, target = globalThis,
|
|
|
900
900
|
}, barButtons = (side) => {
|
|
901
901
|
const merged = mergeChromeButtons(ownButtons[side], effectiveChrome(), side, { name: craft.route?.name ?? "", path: craft.route?.path }), presses = navButtonPresses[side];
|
|
902
902
|
presses.clear();
|
|
903
|
-
buttonPresses(merged, (path) => craft.navigation.open(path)).forEach((press, id) => presses.set(id, press));
|
|
903
|
+
buttonPresses(merged, (path, shown) => craft.navigation.open(path, shown)).forEach((press, id) => presses.set(id, press));
|
|
904
904
|
sentButtons[side] = buttonsKey(merged);
|
|
905
905
|
return merged.map(hostButton);
|
|
906
906
|
}, sendOptions = (payload) => hostSetOptions ? hostSetOptions(payload) : protocol.send("NAVIGATION_SET_OPTIONS", payload);
|
|
@@ -909,10 +909,11 @@ export function installCraftBridge(protocol, nativeBridge, target = globalThis,
|
|
|
909
909
|
replace: (screen, params) => navigate("NAVIGATE_REPLACE", screen, params),
|
|
910
910
|
back: () => protocol.goBack(),
|
|
911
911
|
popToRoot: () => protocol.popToRoot(),
|
|
912
|
-
open: (path) => {
|
|
912
|
+
open: (path, shown) => {
|
|
913
913
|
if (typeof path !== "string" || !path.trim())
|
|
914
914
|
throw TypeError("navigation.open needs a path, such as /m/workout/42");
|
|
915
|
-
|
|
915
|
+
const presentation = typeof shown?.presentation === "string" && shown.presentation ? shown.presentation : void 0;
|
|
916
|
+
return protocol.send("NAVIGATE_OPEN", presentation ? { path, presentation } : { path });
|
|
916
917
|
},
|
|
917
918
|
setOptions: (navigationOptions) => {
|
|
918
919
|
if (!navigationOptions || typeof navigationOptions !== "object")
|
|
@@ -12,6 +12,10 @@ import type { NativeLiveActivities } from '../live-activity.js';
|
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
14
|
/** One choice in a bar button's native menu. */
|
|
15
|
+
/** How `navigation.open` shows the path it opens. */
|
|
16
|
+
export declare interface NativeOpenOptions {
|
|
17
|
+
presentation?: 'cover'
|
|
18
|
+
}
|
|
15
19
|
export declare interface NativeNavigationMenuItem {
|
|
16
20
|
id: string
|
|
17
21
|
title: string
|
|
@@ -19,6 +23,7 @@ export declare interface NativeNavigationMenuItem {
|
|
|
19
23
|
disabled?: boolean
|
|
20
24
|
destructive?: boolean
|
|
21
25
|
open?: string
|
|
26
|
+
presentation?: NativeOpenOptions['presentation']
|
|
22
27
|
onPress?: (event: { id: string }) => unknown
|
|
23
28
|
}
|
|
24
29
|
export declare interface NativeNavigationButton {
|
|
@@ -60,6 +65,7 @@ export declare interface NativeAccessoryCompanion {
|
|
|
60
65
|
title: string
|
|
61
66
|
symbol: string
|
|
62
67
|
accessibilityLabel?: string
|
|
68
|
+
presentation?: NativeOpenOptions['presentation']
|
|
63
69
|
selected?: boolean
|
|
64
70
|
menu?: NativeAccessoryMenuItem[]
|
|
65
71
|
}
|
|
@@ -86,6 +92,7 @@ export declare interface NativeNavigationOptions {
|
|
|
86
92
|
/** A button every screen of the app carries, unless the screen is where it goes. */
|
|
87
93
|
export declare interface NativeChromeButton extends NativeNavigationButton {
|
|
88
94
|
open?: string
|
|
95
|
+
presentation?: NativeOpenOptions['presentation']
|
|
89
96
|
hideOn?: string[]
|
|
90
97
|
}
|
|
91
98
|
/**
|
|
@@ -106,7 +113,7 @@ export declare interface NativeNavigation {
|
|
|
106
113
|
push: (screen: string, params?: Record<string, unknown>) => string
|
|
107
114
|
replace: (screen: string, params?: Record<string, unknown>) => string
|
|
108
115
|
back: () => string
|
|
109
|
-
open: (path: string) => string
|
|
116
|
+
open: (path: string, options?: NativeOpenOptions) => string
|
|
110
117
|
setOptions: (options: NativeNavigationOptions) => unknown
|
|
111
118
|
onButton: (callback: (event: { id: string }) => unknown) => () => void
|
|
112
119
|
onAppear: (callback: () => unknown) => () => void
|
|
@@ -713,23 +713,24 @@ export function createNativeHost(options) {
|
|
|
713
713
|
console.warn(`[STX Native] unknown-class: ${id}: ${name}`);
|
|
714
714
|
record.reportedClasses = unsupported;
|
|
715
715
|
}
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
record.props
|
|
719
|
-
record.props.iconify = icon.iconify;
|
|
720
|
-
if (record.materialized)
|
|
721
|
-
emit({ op: "updateNode", id, patch: { props: { symbol: record.props.symbol, iconify: icon.iconify } } });
|
|
722
|
-
}
|
|
723
|
-
if (classes.numberOfLines !== void 0) {
|
|
724
|
-
record.props.numberOfLines = classes.numberOfLines;
|
|
716
|
+
const derived = classProps(id, record, classes);
|
|
717
|
+
if (derived) {
|
|
718
|
+
Object.assign(record.props, derived);
|
|
725
719
|
if (record.materialized)
|
|
726
|
-
emit({ op: "updateNode", id, patch: { props:
|
|
720
|
+
emit({ op: "updateNode", id, patch: { props: derived } });
|
|
727
721
|
}
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
722
|
+
}
|
|
723
|
+
function classProps(id, record, classes) {
|
|
724
|
+
let derived;
|
|
725
|
+
if (record.type === "Icon" && classes.icon) {
|
|
726
|
+
const icon = resolveNodeIcon(id, record, classes.icon);
|
|
727
|
+
derived = { symbol: icon.symbol, iconify: icon.iconify };
|
|
732
728
|
}
|
|
729
|
+
if (classes.numberOfLines !== void 0)
|
|
730
|
+
(derived ??= {}).numberOfLines = classes.numberOfLines;
|
|
731
|
+
if (classes.resizeMode && (record.type === "Image" || record.type === "ImageBackground" || record.type === "Video") && record.props.resizeMode !== classes.resizeMode)
|
|
732
|
+
(derived ??= {}).resizeMode = classes.resizeMode;
|
|
733
|
+
return derived;
|
|
733
734
|
}
|
|
734
735
|
function resolveNodeIcon(id, record, name) {
|
|
735
736
|
const icon = resolveIconName(name), unknown = !icon.known && name.trim() ? name : void 0;
|
|
@@ -887,6 +888,14 @@ export function createNativeHost(options) {
|
|
|
887
888
|
record.style = resolveStyle(record, node.__stxId);
|
|
888
889
|
if (descriptor)
|
|
889
890
|
descriptor.style = { ...record.style };
|
|
891
|
+
if (classes) {
|
|
892
|
+
const derived = classProps(node.__stxId, record, classStylesOf(record, !1));
|
|
893
|
+
if (derived) {
|
|
894
|
+
Object.assign(record.props, derived);
|
|
895
|
+
if (descriptor)
|
|
896
|
+
Object.assign(descriptor.props, derived);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
890
899
|
records.set(node.__stxId, record);
|
|
891
900
|
decorateControl(node, type);
|
|
892
901
|
decoratePosition(node);
|
|
@@ -1088,8 +1097,12 @@ export function createNativeHost(options) {
|
|
|
1088
1097
|
queue = [];
|
|
1089
1098
|
const describe = (node) => {
|
|
1090
1099
|
const record = recordOf(node);
|
|
1091
|
-
if (!record.materialized)
|
|
1100
|
+
if (!record.materialized) {
|
|
1092
1101
|
record.style = resolveStyle(record, node.__stxId);
|
|
1102
|
+
const derived = classProps(node.__stxId, record, classStylesOf(record, !1));
|
|
1103
|
+
if (derived)
|
|
1104
|
+
Object.assign(record.props, derived);
|
|
1105
|
+
}
|
|
1093
1106
|
record.materialized = !0;
|
|
1094
1107
|
const children = record.children.filter((child) => child.__stxAnchor === void 0).map(describe);
|
|
1095
1108
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NativeChromeButton, NativeNavigationButton, NativeNavigationChrome, NativeTabItemOptions } from './craft.js';
|
|
1
|
+
import type { NativeChromeButton, NativeNavigationButton, NativeNavigationChrome, NativeOpenOptions, NativeTabItemOptions } from './craft.js';
|
|
2
2
|
/** `/m/calendar?week=2` and `https://app.test/m/calendar` are both `/m/calendar`. */
|
|
3
3
|
export declare function chromePath(value: string | undefined): string;
|
|
4
4
|
/** Whether a chrome button belongs on this screen. */
|
|
@@ -13,7 +13,7 @@ export declare function mergeChromeButtons(own: readonly NativeNavigationButton[
|
|
|
13
13
|
/** What the host is shown for a button: no callbacks, and nothing chrome-only. */
|
|
14
14
|
export declare function hostButton(button: NativeChromeButton): NativeNavigationButton;
|
|
15
15
|
/** What pressing each button, or choosing from its menu, does in the screen. */
|
|
16
|
-
export declare function buttonPresses(buttons: readonly NativeChromeButton[], open: (path: string) => unknown): Map<string, (event: { id: string }) => unknown>;
|
|
16
|
+
export declare function buttonPresses(buttons: readonly NativeChromeButton[], open: (path: string, options?: NativeOpenOptions) => unknown): Map<string, (event: { id: string }) => unknown>;
|
|
17
17
|
/** The key two sends compare by, so an unchanged bar is not sent again. */
|
|
18
18
|
export declare function buttonsKey(buttons: readonly NativeChromeButton[]): string;
|
|
19
19
|
/** The tab items of `chrome` that differ from what was last sent for each tab. */
|
|
@@ -33,18 +33,18 @@ export function mergeChromeButtons(own, chrome, side, route) {
|
|
|
33
33
|
return [...own.filter((button) => !taken.has(String(button?.id))), ...shared];
|
|
34
34
|
}
|
|
35
35
|
export function hostButton(button) {
|
|
36
|
-
const { onPress, open, hideOn, menu, ...rest } = button;
|
|
36
|
+
const { onPress, open, presentation, hideOn, menu, ...rest } = button;
|
|
37
37
|
if (!menu)
|
|
38
38
|
return rest;
|
|
39
|
-
return { ...rest, menu: menu.map(({ onPress: press, open: path, ...item }) => item) };
|
|
39
|
+
return { ...rest, menu: menu.map(({ onPress: press, open: path, presentation: shown, ...item }) => item) };
|
|
40
40
|
}
|
|
41
41
|
export function buttonPresses(buttons, open) {
|
|
42
42
|
const presses = new Map, add = (target) => {
|
|
43
|
-
const path = target.open;
|
|
43
|
+
const path = target.open, shown = target.presentation ? { presentation: target.presentation } : void 0;
|
|
44
44
|
if (typeof target.onPress === "function")
|
|
45
45
|
presses.set(String(target.id), target.onPress);
|
|
46
46
|
else if (path)
|
|
47
|
-
presses.set(String(target.id), () => open(path));
|
|
47
|
+
presses.set(String(target.id), () => shown ? open(path, shown) : open(path));
|
|
48
48
|
};
|
|
49
49
|
for (const button of buttons) {
|
|
50
50
|
add(button);
|
package/dist/pwa.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{xo,tn,Yl,rm}from"./chunk-67j2m620.js";import{vo,ra,em,tm,nm}from"./chunk-p3hbsrk9.js";import{Gl,Xl,Jl,Zg,Qg}from"./chunk-rf0smj4c.js";import{nt,Hn,sa}from"./chunk-sh7a0g09.js";import{sm,om,im,am,So,Wy}from"./chunk-ksmn19qw.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-
|
|
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-x0m6qc7k.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">
|