@stacksjs/stx 0.2.889 → 0.2.891
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-1n33yrar.js → chunk-062qfv99.js} +2 -2
- package/dist/chunk-08kcxz79.js +2 -0
- package/dist/chunk-0fyh29m1.js +2 -0
- package/dist/{chunk-2a5g80mq.js → chunk-0jdz31q1.js} +3 -3
- package/dist/{chunk-mhxg6j6s.js → chunk-0jkj8thz.js} +1 -1
- package/dist/{chunk-nbdscgvj.js → chunk-0t31rf3v.js} +6 -6
- package/dist/chunk-0w578pgv.js +3 -0
- package/dist/{chunk-f3cyghnb.js → chunk-0yxvz6qz.js} +4 -4
- package/dist/chunk-0zynd3x0.js +2 -0
- package/dist/chunk-10c7pg5h.js +2 -0
- package/dist/{chunk-cz1sdes5.js → chunk-115bb91s.js} +2 -2
- package/dist/chunk-12m3qagv.js +2 -0
- package/dist/{chunk-1gyxxfdf.js → chunk-12nmmdnp.js} +1 -1
- package/dist/chunk-1a7a8cjs.js +2 -0
- package/dist/chunk-1ph2yhfn.js +3 -0
- package/dist/{chunk-mt8edb75.js → chunk-1vp0h7d6.js} +57 -57
- package/dist/{chunk-me4yq8c2.js → chunk-29cw0fcr.js} +2 -2
- package/dist/chunk-2eq3aret.js +2 -0
- package/dist/chunk-3b3mkgpj.js +3 -0
- package/dist/{chunk-snv80b1b.js → chunk-3bsz7zj3.js} +2 -2
- package/dist/chunk-3ngbdap1.js +2 -0
- package/dist/chunk-3t30a2nx.js +2 -0
- package/dist/{chunk-eyx92t9n.js → chunk-41z7f41b.js} +2 -2
- package/dist/chunk-484x27q5.js +2 -0
- package/dist/{chunk-87g5xmmr.js → chunk-4f3456ht.js} +14 -14
- package/dist/{chunk-sjjw6y49.js → chunk-4r6hbjx7.js} +4 -4
- package/dist/chunk-4ts8qztg.js +2 -0
- package/dist/{chunk-700m927w.js → chunk-5zs5hrgz.js} +2 -2
- package/dist/{chunk-0ncafcs2.js → chunk-67j2m620.js} +3 -3
- package/dist/{chunk-bwx6w87c.js → chunk-6aq1pv9a.js} +1 -1
- package/dist/chunk-6kkatcka.js +2 -0
- package/dist/{chunk-cgfjrgfw.js → chunk-6kt9wxja.js} +11 -11
- package/dist/{chunk-kx09v9ya.js → chunk-70paeznz.js} +9 -9
- package/dist/{chunk-48rwqchc.js → chunk-7d2j41e3.js} +9 -9
- package/dist/{chunk-b15c4g3e.js → chunk-8ay5r808.js} +6 -6
- package/dist/{chunk-njpva3zq.js → chunk-8hdp4ark.js} +1 -1
- package/dist/chunk-8res5m9x.js +2 -0
- package/dist/{chunk-zf68afyh.js → chunk-8y39f6z3.js} +3 -3
- package/dist/{chunk-4akw3bym.js → chunk-90qwzwsm.js} +1 -1
- package/dist/{chunk-ch9028z3.js → chunk-9f8fda1j.js} +1 -1
- package/dist/chunk-9w6k311w.js +1322 -0
- package/dist/chunk-9zhpv03v.js +2 -0
- package/dist/{chunk-q9tc9rdv.js → chunk-a0aqs5a8.js} +2 -2
- package/dist/chunk-a5d5qveh.js +2 -0
- package/dist/{chunk-6gtecbe7.js → chunk-a7bqrjm5.js} +2 -2
- package/dist/{chunk-7hpca9c7.js → chunk-aasgawa9.js} +5 -5
- package/dist/{chunk-3dqfjpz4.js → chunk-ac3e6nhg.js} +29 -29
- package/dist/chunk-arr79m90.js +2 -0
- package/dist/{chunk-58qzyyyv.js → chunk-b0jk94wx.js} +3 -3
- package/dist/{chunk-mctzpw0w.js → chunk-b18vpz6p.js} +4 -4
- package/dist/chunk-bsbd6y64.js +2 -0
- package/dist/{chunk-ymqm898x.js → chunk-bvqgq18r.js} +2 -2
- package/dist/chunk-cf527twj.js +2 -0
- package/dist/chunk-cgrg6xzg.js +2 -0
- package/dist/{chunk-vc432a0w.js → chunk-dm069acv.js} +9 -9
- package/dist/{chunk-ranjkpc8.js → chunk-e16ef18k.js} +1 -1
- package/dist/chunk-e28czxw3.js +2 -0
- package/dist/{chunk-p8shtje2.js → chunk-e5md1cck.js} +45 -45
- package/dist/chunk-essd43ad.js +2 -0
- package/dist/chunk-fs7tv867.js +20 -0
- package/dist/chunk-fsk3rk2x.js +2 -0
- package/dist/{chunk-zwwhpxp7.js → chunk-g5nfqzfh.js} +2 -2
- package/dist/{chunk-6pz5gq6v.js → chunk-gcjqxvbb.js} +25 -21
- package/dist/{chunk-2gn2nc2j.js → chunk-gk0h2hp7.js} +1 -1
- package/dist/{chunk-9d91h636.js → chunk-gwayvyg5.js} +2 -2
- package/dist/{chunk-bqtj62ys.js → chunk-gydvy8a3.js} +7 -7
- package/dist/{chunk-eceeqy74.js → chunk-gzc16hs8.js} +2 -2
- package/dist/{chunk-xy8smv5e.js → chunk-h7yme97q.js} +2 -2
- package/dist/chunk-h87pjzn7.js +2 -0
- package/dist/chunk-hq03mwtw.js +2 -0
- package/dist/chunk-j9kejcrx.js +2 -0
- package/dist/chunk-jhbz5w30.js +2 -0
- package/dist/chunk-k0mndyb4.js +2 -0
- package/dist/{chunk-hm9d40yf.js → chunk-k89gbytd.js} +2 -2
- package/dist/{chunk-51720m79.js → chunk-kd7k31x3.js} +9 -9
- package/dist/{chunk-t0ttxayz.js → chunk-kfbw96c5.js} +2 -2
- package/dist/chunk-kh3sxa3j.js +2 -0
- package/dist/{chunk-mjp1z9kz.js → chunk-khm56bfm.js} +1 -1
- package/dist/chunk-kr4z3633.js +2 -0
- package/dist/{chunk-6pdy7ajr.js → chunk-kvz7ad7p.js} +1 -1
- package/dist/{chunk-nkyff7v6.js → chunk-kxewj557.js} +27 -27
- package/dist/chunk-mbpz45v9.js +2 -0
- package/dist/{chunk-b6bf0t02.js → chunk-mhrnjaka.js} +4 -4
- package/dist/{chunk-mw7hacm3.js → chunk-mxf6cfbg.js} +23 -23
- package/dist/{chunk-pctf14yw.js → chunk-n64zbwzr.js} +1 -1
- package/dist/{chunk-eqffvse2.js → chunk-n6q1d66k.js} +1 -1
- package/dist/chunk-nd0f11at.js +2 -0
- package/dist/{chunk-3hsv6ejp.js → chunk-neg6ckjg.js} +7 -7
- package/dist/{chunk-kbbbpae2.js → chunk-nq60tjkz.js} +2 -2
- package/dist/{chunk-6kyqejnq.js → chunk-nvre22sw.js} +22 -22
- package/dist/{chunk-967ydrq4.js → chunk-p3hbsrk9.js} +2 -2
- package/dist/chunk-p9cwapm8.js +2 -0
- package/dist/{chunk-w82nk19t.js → chunk-ph4tgp9g.js} +1 -1
- package/dist/{chunk-kj43fbzm.js → chunk-phx820py.js} +1 -1
- package/dist/{chunk-5ssv10ep.js → chunk-pjpf21y9.js} +1 -1
- package/dist/{chunk-7212fwzz.js → chunk-psykt348.js} +2 -2
- package/dist/{chunk-pz554g43.js → chunk-pvm48tse.js} +3 -3
- package/dist/{chunk-zek9t5za.js → chunk-pwpge9bj.js} +2 -2
- package/dist/{chunk-0k437z3q.js → chunk-qn45rk5n.js} +1 -1
- package/dist/{chunk-95sd8h5g.js → chunk-qrk535j6.js} +6 -6
- package/dist/{chunk-446tb2th.js → chunk-rc7djca5.js} +49 -49
- package/dist/{chunk-55tc5w32.js → chunk-sh7a0g09.js} +2 -2
- package/dist/chunk-sydgagr1.js +2 -0
- package/dist/chunk-tspqdt8e.js +2 -0
- package/dist/chunk-v6gkjg5f.js +3 -0
- package/dist/chunk-vm57848v.js +2 -0
- package/dist/{chunk-ankap9pc.js → chunk-vya7cck4.js} +1 -1
- package/dist/{chunk-hgf7bc50.js → chunk-w8djc4qb.js} +9 -9
- package/dist/chunk-wg6fmren.js +4 -0
- package/dist/chunk-wwb6c5rr.js +2 -0
- package/dist/chunk-x691tnkx.js +2 -0
- package/dist/{chunk-mgh5rst1.js → chunk-x9036mfd.js} +2 -2
- package/dist/{chunk-brzjass3.js → chunk-xc5esqcb.js} +2 -2
- package/dist/{chunk-5kqezrjt.js → chunk-xvprhdcb.js} +1 -1
- package/dist/chunk-y7qm1m0e.js +2 -0
- package/dist/{chunk-m95sygv4.js → chunk-ye6ev3qp.js} +1 -1
- package/dist/{chunk-s93yh7ed.js → chunk-ypyezjr0.js} +2 -2
- package/dist/{chunk-4kmg6g5n.js → chunk-yv797v6e.js} +9 -9
- package/dist/{chunk-cmg9x1ka.js → chunk-z012vpdz.js} +3 -3
- package/dist/{chunk-dymck524.js → chunk-z6ndrx2p.js} +5 -5
- package/dist/{chunk-2nqmw4dv.js → chunk-z8sv926e.js} +1 -1
- package/dist/{chunk-s0mf56y1.js → chunk-z92e297r.js} +4 -4
- package/dist/chunk-zd21ntcm.js +2 -0
- package/dist/{chunk-6c1vm6bs.js → chunk-zkwkhesc.js} +2 -2
- package/dist/{chunk-hpzje67q.js → chunk-zwqkbk2m.js} +2 -2
- package/dist/chunk-zxjdfgdx.js +3 -0
- package/dist/cli.js +28 -28
- package/dist/client/signals-timer-runtime.js +4 -0
- package/dist/component-contract.d.ts +1 -0
- package/dist/component-contract.js +6 -4
- package/dist/component-library.js +217 -60
- package/dist/component-renderer.js +23 -10
- package/dist/composition-api.d.ts +7 -1
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/emits-declaration.d.ts +9 -0
- package/dist/emits-declaration.js +64 -0
- package/dist/native/prop-names.js +7 -2
- package/dist/native/runtime/craft-bridge.js +29 -2
- package/dist/native/runtime/craft.d.ts +32 -0
- package/dist/native/runtime/native-host.js +27 -11
- package/dist/props-declaration.d.ts +2 -0
- package/dist/props-declaration.js +25 -0
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +28 -28
- package/package.json +5 -5
- package/stx.d.ts +2 -1
- package/dist/chunk-0g9cceht.js +0 -2
- package/dist/chunk-0rpj5t80.js +0 -2
- package/dist/chunk-2ba4zfa0.js +0 -2
- package/dist/chunk-2wkpksg1.js +0 -2
- package/dist/chunk-3yjyjq0m.js +0 -2
- package/dist/chunk-444haxxa.js +0 -2
- package/dist/chunk-4rvfeee5.js +0 -2
- package/dist/chunk-5aa83bpm.js +0 -2
- package/dist/chunk-67rppc5v.js +0 -2
- package/dist/chunk-77c89d23.js +0 -2
- package/dist/chunk-79vbkez0.js +0 -2
- package/dist/chunk-8354mzpd.js +0 -2
- package/dist/chunk-8ygf6jnt.js +0 -2
- package/dist/chunk-94mpe1ny.js +0 -3
- package/dist/chunk-9n5h4sqc.js +0 -3
- package/dist/chunk-9ztn7w4y.js +0 -2
- package/dist/chunk-asnd03sr.js +0 -2
- package/dist/chunk-b0b5yr97.js +0 -2
- package/dist/chunk-b0e7dgv8.js +0 -3
- package/dist/chunk-b7jj45bz.js +0 -2
- package/dist/chunk-dzqfv801.js +0 -3
- package/dist/chunk-ery4tty7.js +0 -20
- package/dist/chunk-evwrxsxd.js +0 -3
- package/dist/chunk-fdqdz018.js +0 -2
- package/dist/chunk-g6ap4085.js +0 -2
- package/dist/chunk-gz9pknbw.js +0 -1204
- package/dist/chunk-hjb4c8g2.js +0 -2
- package/dist/chunk-jhbj9ja2.js +0 -2
- package/dist/chunk-k9abxnpa.js +0 -2
- package/dist/chunk-mvavjydq.js +0 -2
- package/dist/chunk-qqng9545.js +0 -2
- package/dist/chunk-rjm515e2.js +0 -2
- package/dist/chunk-rye4b2x3.js +0 -2
- package/dist/chunk-ryj8139z.js +0 -2
- package/dist/chunk-s9b809n2.js +0 -2
- package/dist/chunk-sb67wg5x.js +0 -2
- package/dist/chunk-sqwx2g02.js +0 -2
- package/dist/chunk-tbh7r1wh.js +0 -2
- package/dist/chunk-tpyekw0q.js +0 -2
- package/dist/chunk-v2627s75.js +0 -2
- package/dist/chunk-v98n53nk.js +0 -2
- package/dist/chunk-w34vvhm7.js +0 -2
- package/dist/chunk-wbmx0rge.js +0 -2
- package/dist/chunk-yjwa7ktk.js +0 -2
- package/dist/chunk-z47p2gx8.js +0 -2
- package/dist/chunk-z6kw6sct.js +0 -4
- package/dist/chunk-zhywjwdr.js +0 -2
package/dist/craft-entry.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
2
|
+
import"./chunk-9w6k311w.js";import{Uo,Va,Wa}from"./chunk-z012vpdz.js";import"./chunk-mxf6cfbg.js";import"./chunk-0jdz31q1.js";import"./chunk-ac3e6nhg.js";import"./chunk-x9036mfd.js";import"./chunk-vk2jy6mn.js";import"./chunk-3b3mkgpj.js";import"./chunk-41z7f41b.js";import"./chunk-ypyezjr0.js";import"./chunk-q0y8gv18.js";import"./chunk-gzc16hs8.js";import"./chunk-e5md1cck.js";import"./chunk-qrk535j6.js";import"./chunk-rb2zbdqd.js";import"./chunk-gwayvyg5.js";import"./chunk-dm069acv.js";import"./chunk-1vp0h7d6.js";import"./chunk-w8djc4qb.js";import"./chunk-7d2j41e3.js";import"./chunk-yv797v6e.js";import"./chunk-z6ndrx2p.js";import"./chunk-05x1rd86.js";import"./chunk-pvm48tse.js";import{Hu,qa,Xh,Jh,Ka,Vo,hs,Ga,Xa,Yh,Zh,Ja,Ya,Za,Qa}from"./chunk-nvre22sw.js";import"./chunk-0yxvz6qz.js";import"./chunk-0w578pgv.js";import"./chunk-xvprhdcb.js";import"./chunk-gydvy8a3.js";import"./chunk-n64zbwzr.js";import"./chunk-n6q1d66k.js";import"./chunk-b0jk94wx.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,Vo as CRAFT_COMPONENTS,Ga as CRAFT_COMPONENT_RUNTIME,hs as CRAFT_COMPONENT_STYLES,Uo as NATIVE_COMPONENTS,Ja as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Va 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-9w6k311w.js";import{Uo,Va,Wa}from"./chunk-z012vpdz.js";import"./chunk-mxf6cfbg.js";import"./chunk-0jdz31q1.js";import"./chunk-ac3e6nhg.js";import"./chunk-x9036mfd.js";import"./chunk-vk2jy6mn.js";import"./chunk-3b3mkgpj.js";import"./chunk-41z7f41b.js";import"./chunk-ypyezjr0.js";import"./chunk-q0y8gv18.js";import"./chunk-gzc16hs8.js";import"./chunk-e5md1cck.js";import"./chunk-qrk535j6.js";import"./chunk-rb2zbdqd.js";import"./chunk-gwayvyg5.js";import"./chunk-dm069acv.js";import"./chunk-1vp0h7d6.js";import"./chunk-w8djc4qb.js";import"./chunk-7d2j41e3.js";import"./chunk-yv797v6e.js";import"./chunk-z6ndrx2p.js";import"./chunk-05x1rd86.js";import"./chunk-pvm48tse.js";import{Hu,qa,Xh,Jh,Ka,Vo,hs,Ga,Xa,Yh,Zh,Ja,Ya,Za,Qa}from"./chunk-nvre22sw.js";import"./chunk-0yxvz6qz.js";import"./chunk-0w578pgv.js";import"./chunk-xvprhdcb.js";import"./chunk-gydvy8a3.js";import"./chunk-n64zbwzr.js";import"./chunk-n6q1d66k.js";import"./chunk-b0jk94wx.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,Vo as CRAFT_COMPONENTS,Ga as CRAFT_COMPONENT_RUNTIME,hs as CRAFT_COMPONENT_STYLES,Uo as NATIVE_COMPONENTS,Ja as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Va 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};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ComponentLibraryEvent } from './types.js';
|
|
2
|
+
export declare function parseEmitsDeclaration(code: string): EmitsDeclaration | null;
|
|
3
|
+
export declare interface EmitsDeclaration {
|
|
4
|
+
text: string
|
|
5
|
+
start: number
|
|
6
|
+
end: number
|
|
7
|
+
typeName?: string
|
|
8
|
+
events: Record<string, ComponentLibraryEvent>
|
|
9
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { macroCall } from "./component-contract.js";
|
|
2
|
+
import { parseStringLiteral } from "./directive-arguments.js";
|
|
3
|
+
import { Tokenizer } from "./parser/tokenizer.js";
|
|
4
|
+
import { localType, skipBalanced, splitTopLevel } from "./props-declaration.js";
|
|
5
|
+
function eventName(raw) {
|
|
6
|
+
const name = raw.trim();
|
|
7
|
+
return /^[A-Za-z_$][\w$]*$/.test(name) ? name : parseStringLiteral(name) ?? void 0;
|
|
8
|
+
}
|
|
9
|
+
function detailFromTuple(tuple) {
|
|
10
|
+
const members = splitTopLevel(tuple.trim().slice(1, -1), ",", !0);
|
|
11
|
+
if (members.length !== 1)
|
|
12
|
+
return tuple.trim();
|
|
13
|
+
const member = members[0];
|
|
14
|
+
if (member.startsWith("..."))
|
|
15
|
+
return tuple.trim();
|
|
16
|
+
const labelled = /^(?:[A-Za-z_$][\w$]*)(\?)?\s*:\s*([\s\S]+)$/.exec(member), optional = labelled ? !!labelled[1] : member.endsWith("?"), type = labelled ? labelled[2] : optional ? member.slice(0, -1).trim() : member;
|
|
17
|
+
return optional ? `(${type}) | undefined | []` : type;
|
|
18
|
+
}
|
|
19
|
+
export function parseEmitsDeclaration(code) {
|
|
20
|
+
const call = macroCall(code, ["defineEmits"], !0);
|
|
21
|
+
if (!call)
|
|
22
|
+
return null;
|
|
23
|
+
const events = Object.create(null), typeName = /^[A-Za-z_$][\w$]*$/.test(call.type.trim()) ? call.type.trim() : void 0, type = typeName ? localType(code, typeName) : call.type.trim();
|
|
24
|
+
if (type?.startsWith("{"))
|
|
25
|
+
for (const member of splitTopLevel(type.slice(1, -1), `;,
|
|
26
|
+
`, !0)) {
|
|
27
|
+
if (member.startsWith("(")) {
|
|
28
|
+
const end = skipBalanced(member, 0, "(", ")");
|
|
29
|
+
if (end < 0)
|
|
30
|
+
continue;
|
|
31
|
+
const parameters = splitTopLevel(member.slice(1, end - 1), ",", !0), first = parameters.shift() || "", colon = first.indexOf(":");
|
|
32
|
+
if (colon < 0)
|
|
33
|
+
continue;
|
|
34
|
+
for (const literal of splitTopLevel(first.slice(colon + 1), "|", !0)) {
|
|
35
|
+
const name = eventName(literal);
|
|
36
|
+
if (name !== void 0)
|
|
37
|
+
events[name] = { detailType: detailFromTuple(`[${parameters.join(", ")}]`) };
|
|
38
|
+
}
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const tokens = new Tokenizer(member, "javascript").tokenize().filter((token) => !["WHITESPACE", "COMMENT", "EOF"].includes(token.type)), key = tokens[0], colon = tokens.findIndex((token) => token.value === ":");
|
|
42
|
+
if (!key || colon < 0)
|
|
43
|
+
continue;
|
|
44
|
+
const name = eventName(key.value), value = member.slice(tokens[colon].end).trim();
|
|
45
|
+
if (name !== void 0)
|
|
46
|
+
events[name] = { detailType: value.startsWith("[") ? detailFromTuple(value) : value };
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
const argument = call.args[0]?.trim() || "";
|
|
50
|
+
if (argument.startsWith("["))
|
|
51
|
+
for (const item of splitTopLevel(argument.slice(1, -1), ",", !1)) {
|
|
52
|
+
const name = eventName(item);
|
|
53
|
+
if (name !== void 0)
|
|
54
|
+
events[name] = { detailType: "unknown" };
|
|
55
|
+
}
|
|
56
|
+
else if (argument.startsWith("{"))
|
|
57
|
+
for (const member of splitTopLevel(argument.slice(1, -1), ",", !1)) {
|
|
58
|
+
const key = new Tokenizer(member, "javascript").tokenize().find((token) => !["WHITESPACE", "COMMENT"].includes(token.type)), name = key && eventName(key.value);
|
|
59
|
+
if (name !== void 0)
|
|
60
|
+
events[name] = { detailType: "unknown" };
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return { ...call, text: code.slice(call.start, call.end), typeName, events };
|
|
64
|
+
}
|
|
@@ -102,13 +102,17 @@ const NATIVE_PROP_NAMES = [
|
|
|
102
102
|
"ghostText",
|
|
103
103
|
"rowHeight",
|
|
104
104
|
"labelFontSize",
|
|
105
|
+
"labelFontWeight",
|
|
106
|
+
"selectionInset",
|
|
107
|
+
"contentInset",
|
|
105
108
|
"pictureInPicture",
|
|
106
109
|
"transitionID",
|
|
107
110
|
"dragData",
|
|
108
111
|
"dragURL",
|
|
109
112
|
"dropTypes",
|
|
110
113
|
"dropInside",
|
|
111
|
-
"selectTextOnFocus"
|
|
114
|
+
"selectTextOnFocus",
|
|
115
|
+
"iconOnly"
|
|
112
116
|
];
|
|
113
117
|
export const NATIVE_BOOLEAN_PROPS = new Set([
|
|
114
118
|
"alwaysBounceHorizontal",
|
|
@@ -149,7 +153,8 @@ export const NATIVE_BOOLEAN_PROPS = new Set([
|
|
|
149
153
|
"showsCompass",
|
|
150
154
|
"showsScale",
|
|
151
155
|
"pictureInPicture",
|
|
152
|
-
"grabberVisible"
|
|
156
|
+
"grabberVisible",
|
|
157
|
+
"iconOnly"
|
|
153
158
|
]);
|
|
154
159
|
const nativePropNames = new Map(NATIVE_PROP_NAMES.map((name) => [normaliseKey(name), name]));
|
|
155
160
|
function normaliseKey(name) {
|
|
@@ -8,6 +8,7 @@ const permissionFallbacks = new WeakSet;
|
|
|
8
8
|
function capabilityFlags(capabilities) {
|
|
9
9
|
return {
|
|
10
10
|
desktop: capabilities.has("desktop"),
|
|
11
|
+
updater: capabilities.has("updater"),
|
|
11
12
|
haptics: capabilities.has("haptics"),
|
|
12
13
|
rawMotionSensors: capabilities.has("rawMotionSensors"),
|
|
13
14
|
barometer: capabilities.has("barometer"),
|
|
@@ -413,6 +414,32 @@ export function installCraftBridge(protocol, nativeBridge, target = globalThis,
|
|
|
413
414
|
setDefaultBrowser: () => request("Desktop", "setDefaultBrowser", [])
|
|
414
415
|
};
|
|
415
416
|
}
|
|
417
|
+
if (capabilities.has("updater") || capabilities.has("desktop")) {
|
|
418
|
+
const isStatus = (value) => !!value && typeof value === "object" && typeof value.state === "string", unavailable = () => ({
|
|
419
|
+
currentVersion: craft.app.version,
|
|
420
|
+
state: "unavailable",
|
|
421
|
+
selfUpdating: !1,
|
|
422
|
+
reason: "This version of the app cannot update itself."
|
|
423
|
+
}), failed = (error) => {
|
|
424
|
+
const code = String(error?.code ?? "");
|
|
425
|
+
if (["CAPABILITY_DISABLED", "UNSUPPORTED", "UNSUPPORTED_METHOD", "UNSUPPORTED_MODULE"].includes(code))
|
|
426
|
+
return unavailable();
|
|
427
|
+
const message = typeof error?.message === "string" ? error.message : String(error);
|
|
428
|
+
return { currentVersion: craft.app.version, state: "error", selfUpdating: !1, error: message };
|
|
429
|
+
}, answer = (method) => request("Updater", method, []).then((value) => isStatus(value) ? value : unavailable(), failed);
|
|
430
|
+
craft.updater = {
|
|
431
|
+
status: () => answer("status"),
|
|
432
|
+
check: () => answer("check"),
|
|
433
|
+
install: () => answer("install"),
|
|
434
|
+
relaunch: () => request("Updater", "relaunch", []).then(() => {
|
|
435
|
+
return;
|
|
436
|
+
}),
|
|
437
|
+
onChange: (callback) => protocol.on("CRAFT_EVENT", ({ payload }) => {
|
|
438
|
+
if (payload?.event === "craftUpdaterChange" && isStatus(payload.detail))
|
|
439
|
+
callback(payload.detail);
|
|
440
|
+
})
|
|
441
|
+
};
|
|
442
|
+
}
|
|
416
443
|
if (capabilities.has("web")) {
|
|
417
444
|
const call = (method, args) => request("Web", method, args), web = {
|
|
418
445
|
create: (options = {}) => call("create", [options]),
|
|
@@ -1100,7 +1127,7 @@ export function installCraftBridge(protocol, nativeBridge, target = globalThis,
|
|
|
1100
1127
|
return Promise.reject(TypeError("fetch in a native screen sends string bodies only"));
|
|
1101
1128
|
if (body != null && (method === "GET" || method === "HEAD"))
|
|
1102
1129
|
return Promise.reject(TypeError("A GET or HEAD request cannot have a body"));
|
|
1103
|
-
const signal = init.signal || source.signal;
|
|
1130
|
+
const signal = init.signal || source.signal, omitCredentials = (init.credentials || source.credentials) === "omit";
|
|
1104
1131
|
if (signal?.aborted)
|
|
1105
1132
|
return Promise.reject(abortError(signal.reason));
|
|
1106
1133
|
if (typeof init.onUploadProgress === "function" && !capabilities.has("uploadProgress"))
|
|
@@ -1113,7 +1140,7 @@ export function installCraftBridge(protocol, nativeBridge, target = globalThis,
|
|
|
1113
1140
|
if (!signal?.aborted)
|
|
1114
1141
|
init.onUploadProgress(value);
|
|
1115
1142
|
});
|
|
1116
|
-
return protocol.request("API_REQUEST", { version: 1, module: "Network", method: "fetch", args: [{ url, method, headers, body: body == null ? null : body, ...form ? { form } : {}, ...uploadProgressId ? { uploadProgressId } : {} }], ...form ? { untimed: !0 } : {} }, form ? null : void 0, signal).then((data) => {
|
|
1143
|
+
return protocol.request("API_REQUEST", { version: 1, module: "Network", method: "fetch", args: [{ url, method, headers, body: body == null ? null : body, ...omitCredentials ? { credentials: "omit" } : {}, ...form ? { form } : {}, ...uploadProgressId ? { uploadProgressId } : {} }], ...form ? { untimed: !0 } : {} }, form ? null : void 0, signal).then((data) => {
|
|
1117
1144
|
const responseBody = data?.body == null ? "" : String(data.body);
|
|
1118
1145
|
let bodyUsed = !1;
|
|
1119
1146
|
return response(data, { get bodyUsed() {
|
|
@@ -256,6 +256,7 @@ export declare interface NativeCraft {
|
|
|
256
256
|
barometer?: NativeBarometer
|
|
257
257
|
liveActivity?: NativeLiveActivities
|
|
258
258
|
desktop?: NativeDesktop
|
|
259
|
+
updater?: NativeUpdater
|
|
259
260
|
web?: NativeWeb
|
|
260
261
|
platform: string
|
|
261
262
|
capabilityProtocolVersion: number
|
|
@@ -416,6 +417,35 @@ export declare interface NativeCraft {
|
|
|
416
417
|
app: { url: string, version: string, build: string }
|
|
417
418
|
background?: { complete: (ok?: boolean, id?: string) => Promise<boolean> }
|
|
418
419
|
}
|
|
420
|
+
/** What `craft.updater` reports: in every answer and in every change. */
|
|
421
|
+
export declare interface NativeUpdateStatus {
|
|
422
|
+
currentVersion: string
|
|
423
|
+
state: NativeUpdateState
|
|
424
|
+
selfUpdating: boolean
|
|
425
|
+
reason?: string
|
|
426
|
+
version?: string
|
|
427
|
+
notes?: string
|
|
428
|
+
publishedAt?: string
|
|
429
|
+
progress?: number
|
|
430
|
+
error?: string
|
|
431
|
+
lastCheckedAt?: string
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* In-app updates (`craft.updater`), answered by the host's `Updater` module.
|
|
435
|
+
*
|
|
436
|
+
* Present on Craft's AppKit host. A host that has the surface but cannot
|
|
437
|
+
* update (no `updates` in its config, a Mac App Store build, a host older than
|
|
438
|
+
* the module) answers every call with `state: 'unavailable'` and
|
|
439
|
+
* `selfUpdating: false`, so a screen draws from the status and never from
|
|
440
|
+
* whether a call threw.
|
|
441
|
+
*/
|
|
442
|
+
export declare interface NativeUpdater {
|
|
443
|
+
status: () => Promise<NativeUpdateStatus>
|
|
444
|
+
check: () => Promise<NativeUpdateStatus>
|
|
445
|
+
install: () => Promise<NativeUpdateStatus>
|
|
446
|
+
relaunch: () => Promise<void>
|
|
447
|
+
onChange: (callback: (status: NativeUpdateStatus) => void) => () => void
|
|
448
|
+
}
|
|
419
449
|
export declare interface NativeDesktop {
|
|
420
450
|
openWindow: (options: { name: string, route: string, title?: string, titlebarStyle?: 'standard' | 'transparent', width?: number, height?: number, minWidth?: number, minHeight?: number, floating?: boolean, params?: Record<string, unknown> }) => Promise<{ name: string }>
|
|
421
451
|
closeWindow: () => Promise<void>
|
|
@@ -567,6 +597,8 @@ export type NativePedometerEvent = | { state: 'sample', kind: 'interval', startD
|
|
|
567
597
|
| { state: 'sample', kind: 'step', count: 1, timestampMs: number }
|
|
568
598
|
| { state: 'stopped', reason: 'requested' | 'background' | 'disposed' | 'sensorError' | 'permissionDenied' }
|
|
569
599
|
export type NativePasskeyCredential = NativePasskeyRegistration | NativePasskeyAssertion;
|
|
600
|
+
/** Where an in-app update stands. */
|
|
601
|
+
export type NativeUpdateState = 'unavailable' | 'idle' | 'checking' | 'current' | 'available' | 'downloading' | 'installing' | 'installed' | 'error';
|
|
570
602
|
export type NativeWebEvent = | ({ type: 'state' } & NativeWebTabState)
|
|
571
603
|
| { type: 'navigationStart' | 'navigationFinish', tab: string, url: string }
|
|
572
604
|
| { type: 'navigationError', tab: string, url: string, code: number, domain: string, message: string }
|
|
@@ -623,26 +623,28 @@ export function createNativeHost(options) {
|
|
|
623
623
|
return !1;
|
|
624
624
|
return !0;
|
|
625
625
|
}
|
|
626
|
-
function
|
|
626
|
+
function forwardedHostRoots(node, name) {
|
|
627
|
+
const found = [];
|
|
627
628
|
if (!isBindingNode(node))
|
|
628
|
-
return;
|
|
629
|
+
return found;
|
|
629
630
|
const forward = node.getAttribute("data-stx-native-forward");
|
|
630
631
|
if (!forward || !words(forward).includes(name))
|
|
631
|
-
return;
|
|
632
|
+
return found;
|
|
632
633
|
const find = (candidate) => {
|
|
633
634
|
if (candidate !== node && isBindingNode(candidate) && candidate.hasAttribute("data-stx-native-host-owner"))
|
|
634
635
|
return;
|
|
635
|
-
if (isBindingNode(candidate) && candidate.hasAttribute("data-stx-native-host-root"))
|
|
636
|
-
|
|
636
|
+
if (isBindingNode(candidate) && candidate.hasAttribute("data-stx-native-host-root")) {
|
|
637
|
+
found.push(candidate);
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
637
640
|
for (const child of recordOf(candidate).children) {
|
|
638
641
|
if (isBindingNode(child) && child.hasAttribute("data-stx-component-wrapper"))
|
|
639
642
|
continue;
|
|
640
|
-
|
|
641
|
-
if (match)
|
|
642
|
-
return match;
|
|
643
|
+
find(child);
|
|
643
644
|
}
|
|
644
645
|
};
|
|
645
|
-
|
|
646
|
+
find(node);
|
|
647
|
+
return found;
|
|
646
648
|
}
|
|
647
649
|
function callerBindingOnWrapper(node, name) {
|
|
648
650
|
if (!isBindingNode(node) || !node.hasAttribute("data-stx-component-wrapper"))
|
|
@@ -1128,7 +1130,14 @@ export function createNativeHost(options) {
|
|
|
1128
1130
|
}
|
|
1129
1131
|
},
|
|
1130
1132
|
setAttribute(node, name, value) {
|
|
1131
|
-
const forwarded =
|
|
1133
|
+
const [forwarded, ...alternates] = forwardedHostRoots(node, name);
|
|
1134
|
+
for (const alternate of alternates) {
|
|
1135
|
+
if (alternate === node)
|
|
1136
|
+
continue;
|
|
1137
|
+
reflectAttribute(alternate, name, value);
|
|
1138
|
+
if (!applyForwardedStyle(alternate, name, value))
|
|
1139
|
+
this.setAttribute(alternate, name, value);
|
|
1140
|
+
}
|
|
1132
1141
|
reflectAttribute(node, name, value);
|
|
1133
1142
|
if (forwarded) {
|
|
1134
1143
|
if (forwarded !== node)
|
|
@@ -1197,7 +1206,14 @@ export function createNativeHost(options) {
|
|
|
1197
1206
|
emit({ op: "updateNode", id: node.__stxId, patch: { props: patch } });
|
|
1198
1207
|
},
|
|
1199
1208
|
removeAttribute(node, name) {
|
|
1200
|
-
const forwarded =
|
|
1209
|
+
const [forwarded, ...alternates] = forwardedHostRoots(node, name);
|
|
1210
|
+
for (const alternate of alternates) {
|
|
1211
|
+
if (alternate === node)
|
|
1212
|
+
continue;
|
|
1213
|
+
reflectAttribute(alternate, name, void 0, !0);
|
|
1214
|
+
if (!applyForwardedStyle(alternate, name, void 0))
|
|
1215
|
+
this.removeAttribute(alternate, name);
|
|
1216
|
+
}
|
|
1201
1217
|
reflectAttribute(node, name, void 0, !0);
|
|
1202
1218
|
if (forwarded) {
|
|
1203
1219
|
reflectAttribute(forwarded, name, void 0, !0);
|
|
@@ -51,6 +51,8 @@ export declare function parsePropsDeclaration(source: string): PropsDeclaration
|
|
|
51
51
|
export declare function parseDefaults(object: string): Array<[string, string]>;
|
|
52
52
|
/** Literal defaults only: no client functions, imports, identifiers or getters run in SSR. */
|
|
53
53
|
export declare function literalValue(source: string): unknown;
|
|
54
|
+
/** Resolve local macro-support types with the same balanced scanner as props. */
|
|
55
|
+
export declare function localType(code: string, name: string): string | undefined;
|
|
54
56
|
declare interface PropsDeclaration {
|
|
55
57
|
text: string
|
|
56
58
|
propNames: string[]
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { topLevelDeclarationSites } from "./client-parameter-bindings.js";
|
|
2
2
|
import { Tokenizer } from "./parser/tokenizer.js";
|
|
3
3
|
import { parseStringLiteral } from "./directive-arguments.js";
|
|
4
|
+
import { bracketDepths, stripCommentsAndLiterals } from "./strip-literals.js";
|
|
4
5
|
function withoutComments(source) {
|
|
5
6
|
const tokens = new Tokenizer(source, "javascript").tokenize();
|
|
6
7
|
let code = source;
|
|
@@ -352,3 +353,27 @@ export function literalValue(source) {
|
|
|
352
353
|
return;
|
|
353
354
|
}
|
|
354
355
|
}
|
|
356
|
+
export function localType(code, name) {
|
|
357
|
+
const masked = stripCommentsAndLiterals(code), depths = bracketDepths(masked).depths, pattern = /\b(interface|type)\s+([A-Za-z_$][\w$]*)\b/g;
|
|
358
|
+
for (const match of masked.matchAll(pattern)) {
|
|
359
|
+
if (match[2] !== name || depths[match.index] !== 0)
|
|
360
|
+
continue;
|
|
361
|
+
const start = match.index + match[0].length, open = masked.indexOf("{", start);
|
|
362
|
+
if (match[1] === "interface" && open >= 0) {
|
|
363
|
+
const end = skipBalanced(masked, open, "{", "}");
|
|
364
|
+
if (end >= 0)
|
|
365
|
+
return code.slice(open, end);
|
|
366
|
+
}
|
|
367
|
+
if (match[1] === "type") {
|
|
368
|
+
const equal = masked.indexOf("=", start);
|
|
369
|
+
if (equal < 0)
|
|
370
|
+
continue;
|
|
371
|
+
const rest = code.slice(equal + 1).trimStart();
|
|
372
|
+
if (rest[0] === "{") {
|
|
373
|
+
const end = skipBalanced(rest, 0, "{", "}");
|
|
374
|
+
if (end >= 0)
|
|
375
|
+
return rest.slice(0, end);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
package/dist/pwa.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{xo,
|
|
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-
|
|
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-x691tnkx.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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}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=
|
|
236
|
+
</html>`}function b(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}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=nt(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=xo(n,t);if(a){let s=tn(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 ra(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,Xl as auditBuildOutput,Gl as auditConfig,re as buildPwaAssets,Jl as calculateAuditResult,Qg as formatAuditResult,sa as formatSize,j as generateManifest,_ as generateManifestJson,tm as generateManifestLink,F as generateOfflinePage,nt as generatePrecacheManifest,Hn as generatePrecacheManifestJs,M as generatePwaIcons,vo as generatePwaTags,xo as generateServiceWorker,rm as generateServiceWorkerAuto,em as generateSwRegistrationScript,nm as generateThemeColorMeta,N as getExpectedIconPaths,tn as getServiceWorkerFileName,ra as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,Yl as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,So as pwaDirectives,sm as pwaInstallDirective,im as pwaOfflineDirective,am as pwaPushDirective,om as pwaUpdateDirective,Wy as registerPwaDirectives,Zg as runPwaAudit,D as validateManifest};
|