@stacksjs/stx 0.2.634 → 0.2.636
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-0bptz1km.js +2852 -0
- package/dist/{chunk-968jp303.js → chunk-0ergsswn.js} +3 -3
- package/dist/{chunk-xrkechs8.js → chunk-0j9f54wv.js} +5 -5
- package/dist/{chunk-p77g4mhy.js → chunk-104xw4ps.js} +2 -2
- package/dist/chunk-1071avjd.js +2 -0
- package/dist/{chunk-923vrf9c.js → chunk-17x6e5mm.js} +7 -7
- package/dist/chunk-1ejpz9gv.js +2 -0
- package/dist/{chunk-2bxsc7gf.js → chunk-1m5cjrpw.js} +4 -4
- package/dist/chunk-1p6yd17s.js +2 -0
- package/dist/{chunk-v4tmwamd.js → chunk-1s02ff6n.js} +2 -2
- package/dist/{chunk-27784ceh.js → chunk-215fsx0k.js} +4 -4
- package/dist/{chunk-8kc6byaz.js → chunk-26g3m2mg.js} +5 -5
- package/dist/{chunk-72p9brmx.js → chunk-26gr5d4w.js} +9 -9
- package/dist/chunk-2kppq4pg.js +18 -0
- package/dist/chunk-2yvdnffe.js +2 -0
- package/dist/chunk-3hkp5hym.js +2 -0
- package/dist/chunk-444pz8yk.js +2 -0
- package/dist/{chunk-pxpmx8vc.js → chunk-45xhjrha.js} +1 -1
- package/dist/{chunk-90pe63me.js → chunk-48yja477.js} +3 -3
- package/dist/chunk-4a4zc8yd.js +2 -0
- package/dist/chunk-4b5f28te.js +2 -0
- package/dist/chunk-4mm9ttc7.js +2 -0
- package/dist/{chunk-phbnrw2h.js → chunk-4n24jbfs.js} +2 -2
- package/dist/chunk-4p4qp5ka.js +2 -0
- package/dist/{chunk-y8h823cb.js → chunk-51ea655x.js} +41 -41
- package/dist/{chunk-pk757m0k.js → chunk-5e063mgs.js} +1 -1
- package/dist/{chunk-0hs8jgw5.js → chunk-5pyv9gjh.js} +2 -2
- package/dist/{chunk-gv15dd41.js → chunk-60azcvwr.js} +3 -3
- package/dist/{chunk-236twqn4.js → chunk-69n2ty1n.js} +3 -3
- package/dist/{chunk-7q55jxf5.js → chunk-6avpd901.js} +2 -2
- package/dist/chunk-6g4kd71m.js +2 -0
- package/dist/chunk-6pewcgfq.js +2 -0
- package/dist/chunk-6vjg5xf3.js +2 -0
- package/dist/chunk-6vqk6yfm.js +2 -0
- package/dist/{chunk-k5atee35.js → chunk-77pj0xem.js} +1 -1
- package/dist/{chunk-ygpa12ez.js → chunk-7ftn9ber.js} +3 -3
- package/dist/{chunk-g2rxbaah.js → chunk-7jp0w5j8.js} +3 -3
- package/dist/{chunk-jbmjcs83.js → chunk-7mkw98cr.js} +2 -2
- package/dist/{chunk-w9e17a74.js → chunk-7p8kyf4z.js} +4 -4
- package/dist/chunk-7z6ryf20.js +2 -0
- package/dist/chunk-87kza2ez.js +2 -0
- package/dist/{chunk-bd5na0h0.js → chunk-88p10v0w.js} +5 -5
- package/dist/chunk-8cqx63aw.js +3 -0
- package/dist/chunk-8scndwf6.js +2 -0
- package/dist/{chunk-jzmz66a3.js → chunk-95ygdn0n.js} +3 -3
- package/dist/{chunk-gxpgwpq7.js → chunk-9hqjezhx.js} +2 -2
- package/dist/chunk-9ny6xzw0.js +2 -0
- package/dist/chunk-9r538d93.js +2 -0
- package/dist/{chunk-j1rnhv0w.js → chunk-9yk5rasj.js} +3 -3
- package/dist/{chunk-xrrkf04f.js → chunk-a0ygyftk.js} +2 -2
- package/dist/{chunk-4fv3jq16.js → chunk-ahyq08mp.js} +2 -2
- package/dist/{chunk-6bhaa9g7.js → chunk-arrvcn7c.js} +13 -13
- package/dist/{chunk-zs7t42b5.js → chunk-aztp8r80.js} +5 -5
- package/dist/chunk-b2teprjf.js +2 -0
- package/dist/{chunk-xm911f1g.js → chunk-b2v6v7w8.js} +1 -1
- package/dist/{chunk-pbphq5pj.js → chunk-b4j5bpec.js} +2 -2
- package/dist/{chunk-gh34r6qb.js → chunk-bsts9pr5.js} +2 -2
- package/dist/{chunk-0qt1887j.js → chunk-bx3ar1wz.js} +2 -2
- package/dist/{chunk-ftkrsvqp.js → chunk-c06b0akz.js} +1 -1
- package/dist/{chunk-86zj56pf.js → chunk-c858mepd.js} +5 -5
- package/dist/chunk-cd76dwdn.js +2 -0
- package/dist/{chunk-vhktd16g.js → chunk-cwvd8dc3.js} +2 -2
- package/dist/{chunk-avt9cske.js → chunk-drrczm0b.js} +6 -6
- package/dist/{chunk-g35zftfn.js → chunk-dtg82vm2.js} +1 -1
- package/dist/chunk-e21q08vs.js +2 -0
- package/dist/chunk-e2p8ytdd.js +2 -0
- package/dist/chunk-e7bd4vxb.js +2 -0
- package/dist/chunk-eeqw8jkw.js +127 -0
- package/dist/{chunk-p4hmv654.js → chunk-eyy6zmdk.js} +2 -2
- package/dist/chunk-fdxyj3pk.js +2 -0
- package/dist/chunk-ffjvqjyh.js +2 -0
- package/dist/{chunk-y89m80pf.js → chunk-fk79x8ns.js} +4 -4
- package/dist/{chunk-az1y9jks.js → chunk-fqg0espy.js} +2 -2
- package/dist/chunk-ft6gfbr5.js +2 -0
- package/dist/{chunk-5x59qjzs.js → chunk-fwdptew6.js} +6 -6
- package/dist/{chunk-94yycjz8.js → chunk-fztvkacg.js} +2 -2
- package/dist/chunk-g14mwhqz.js +2 -0
- package/dist/chunk-g1ae3haw.js +3 -0
- package/dist/chunk-g1mp4e7h.js +2 -0
- package/dist/{chunk-k2nrx78c.js → chunk-gcj5jfbv.js} +2 -2
- package/dist/{chunk-3yh585yv.js → chunk-gqz26wza.js} +3 -3
- package/dist/chunk-h0d5vg33.js +2 -0
- package/dist/{chunk-8qrhz7n7.js → chunk-hjtym7d9.js} +6 -6
- package/dist/chunk-j0jz4mfm.js +2 -0
- package/dist/chunk-j37720vw.js +2 -0
- package/dist/{chunk-cy1j2zpr.js → chunk-jdx4za9p.js} +2 -2
- package/dist/chunk-jmdrhpy7.js +2 -0
- package/dist/chunk-jp3vgscy.js +2 -0
- package/dist/chunk-jshv1ye7.js +2 -0
- package/dist/chunk-jtvrfwd8.js +2 -0
- package/dist/{chunk-tn7hgtyn.js → chunk-k4xytaq3.js} +5 -5
- package/dist/chunk-k5pm9bex.js +2 -0
- package/dist/{chunk-6dzqjbsz.js → chunk-kjspmegt.js} +2 -2
- package/dist/{chunk-a887js9p.js → chunk-kmzc09w6.js} +5 -5
- package/dist/chunk-krchxt50.js +2 -0
- package/dist/chunk-kxbw0e2f.js +3 -0
- package/dist/chunk-kztnn301.js +2 -0
- package/dist/chunk-mbqqc20a.js +2 -0
- package/dist/{chunk-8hjrr8j3.js → chunk-mcs3wbs4.js} +39 -39
- package/dist/{chunk-fdy0hka5.js → chunk-mek121wh.js} +27 -27
- package/dist/{chunk-0whv8hnp.js → chunk-mn97jhaq.js} +2 -2
- package/dist/chunk-ms4121x1.js +2 -0
- package/dist/{chunk-w8bf4mbw.js → chunk-mwqas1qk.js} +3 -3
- package/dist/chunk-n708h31w.js +2 -0
- package/dist/{chunk-gqdh68vx.js → chunk-nxn7gnpq.js} +2 -2
- package/dist/{chunk-tc7gm68a.js → chunk-pf5s5gjp.js} +2 -2
- package/dist/{chunk-bng1ayzm.js → chunk-phqtp1b4.js} +10 -10
- package/dist/chunk-pn719qwa.js +2 -0
- package/dist/{chunk-v5500ews.js → chunk-pp6ycfay.js} +2 -2
- package/dist/{chunk-3kkf43fv.js → chunk-pvfx0dgz.js} +2 -2
- package/dist/chunk-pwn2keqq.js +2 -0
- package/dist/{chunk-7gq7w95h.js → chunk-qy11cp1v.js} +4 -4
- package/dist/chunk-r0s7vdha.js +2 -0
- package/dist/chunk-rwjr5bmd.js +2 -0
- package/dist/chunk-ryj2m6fk.js +2 -0
- package/dist/chunk-s15nte19.js +2 -0
- package/dist/chunk-spz80xnc.js +2 -0
- package/dist/{chunk-t7e9y46s.js → chunk-tvs9a3vk.js} +1 -1
- package/dist/{chunk-8b2452m1.js → chunk-tw10tgz8.js} +11 -11
- package/dist/chunk-vj5fghnv.js +2 -0
- package/dist/chunk-vvgs62za.js +2 -0
- package/dist/chunk-vvseb46a.js +2 -0
- package/dist/{chunk-y04hzz4w.js → chunk-w41kp60h.js} +4 -4
- package/dist/chunk-wj4rf7sb.js +2 -0
- package/dist/{chunk-q6evk3a4.js → chunk-wjq1wqn6.js} +2 -2
- package/dist/chunk-wywkr0rt.js +2 -0
- package/dist/{chunk-nh7bcc4h.js → chunk-xdqwq7a6.js} +2 -2
- package/dist/chunk-xekmvpha.js +2 -0
- package/dist/{chunk-rq1c46zb.js → chunk-xgd6xgvz.js} +34 -9
- package/dist/chunk-xj5rk4pj.js +2 -0
- package/dist/chunk-xqtzk9wr.js +2 -0
- package/dist/chunk-y1j13dha.js +2 -0
- package/dist/{chunk-kpxty3pe.js → chunk-y255yybn.js} +2 -2
- package/dist/chunk-y51ndrdb.js +2 -0
- package/dist/chunk-z5ewms99.js +2 -0
- package/dist/{chunk-jq7ymh7q.js → chunk-z8ftsz64.js} +6 -6
- package/dist/{chunk-tx4xxpgg.js → chunk-zsq0754x.js} +3 -3
- package/dist/cli.js +76 -76
- package/dist/client/signals-public-api-runtime.js +1 -0
- package/dist/client/signals-timer-runtime.js +24 -0
- package/dist/craft-bridge.js +2 -2
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/lazy-module.js +2 -1
- package/dist/menubar.d.ts +2 -0
- package/dist/menubar.js +15 -2
- package/dist/native/compiler/headwind-to-style.d.ts +6 -3
- package/dist/native/compiler/headwind-to-style.js +25 -3
- package/dist/native/compiler/html-to-ir.js +4 -4
- package/dist/native/prop-names.d.ts +1 -1
- package/dist/native/prop-names.js +3 -1
- package/dist/native/runtime/native-host.js +66 -7
- package/dist/native-build.d.ts +1 -0
- package/dist/native-build.js +5 -3
- package/dist/process.d.ts +1 -0
- package/dist/process.js +1 -1
- package/dist/pwa.js +3 -3
- package/dist/render.js +3 -3
- package/dist/runtime-globals.js +1 -0
- package/dist/ssg.js +9 -9
- package/dist/stx-module.d.ts +1 -0
- package/package.json +5 -5
- package/stx-module.d.ts +1 -0
- package/stx.d.ts +7 -0
- package/dist/chunk-0mgtrbaa.js +0 -2
- package/dist/chunk-0xc6rncm.js +0 -2852
- package/dist/chunk-1tpr8d8n.js +0 -2
- package/dist/chunk-20kjbf3h.js +0 -2
- package/dist/chunk-3gcg3gvy.js +0 -2
- package/dist/chunk-3wsrhj0k.js +0 -2
- package/dist/chunk-575cqc6z.js +0 -2
- package/dist/chunk-5x836mv3.js +0 -2
- package/dist/chunk-5yceay9n.js +0 -2
- package/dist/chunk-6pg2kxsq.js +0 -2
- package/dist/chunk-7nthebqr.js +0 -2
- package/dist/chunk-7s5304ae.js +0 -2
- package/dist/chunk-8dybd0g5.js +0 -2
- package/dist/chunk-8em788gc.js +0 -2
- package/dist/chunk-9svygzeg.js +0 -2
- package/dist/chunk-9z4qr5w9.js +0 -2
- package/dist/chunk-af4ss0p5.js +0 -2
- package/dist/chunk-aj34t5h3.js +0 -2
- package/dist/chunk-atcy4zq6.js +0 -2
- package/dist/chunk-az28kd7f.js +0 -2
- package/dist/chunk-cncdgxk3.js +0 -2
- package/dist/chunk-d2t2pq1s.js +0 -3
- package/dist/chunk-dcx2t3sy.js +0 -2
- package/dist/chunk-dn28q0m3.js +0 -2
- package/dist/chunk-dn89zg1v.js +0 -2
- package/dist/chunk-dwddzp5f.js +0 -2
- package/dist/chunk-enchx79c.js +0 -2
- package/dist/chunk-ev8ma4ph.js +0 -2
- package/dist/chunk-ftrsaag8.js +0 -2
- package/dist/chunk-g6efz3ww.js +0 -2
- package/dist/chunk-gd59tkhr.js +0 -2
- package/dist/chunk-h1g9m148.js +0 -2
- package/dist/chunk-h8tew5mz.js +0 -2
- package/dist/chunk-hdrcgepx.js +0 -127
- package/dist/chunk-hn64343d.js +0 -2
- package/dist/chunk-htaed68z.js +0 -2
- package/dist/chunk-j5jkh05f.js +0 -2
- package/dist/chunk-j90yng9b.js +0 -2
- package/dist/chunk-jabb3v4c.js +0 -2
- package/dist/chunk-jczvjn7z.js +0 -2
- package/dist/chunk-kqkhcbrx.js +0 -2
- package/dist/chunk-mgzegkvk.js +0 -2
- package/dist/chunk-mk71833d.js +0 -2
- package/dist/chunk-n3s3w1f5.js +0 -2
- package/dist/chunk-nj0b4ryt.js +0 -2
- package/dist/chunk-ny6enm8b.js +0 -3
- package/dist/chunk-p8ndfekp.js +0 -2
- package/dist/chunk-qhjm9hvz.js +0 -2
- package/dist/chunk-qzy34xmt.js +0 -2
- package/dist/chunk-ra40trfh.js +0 -2
- package/dist/chunk-rjq597cn.js +0 -2
- package/dist/chunk-rrdwynz4.js +0 -2
- package/dist/chunk-sddytf9n.js +0 -2
- package/dist/chunk-sg5zgq5v.js +0 -18
- package/dist/chunk-shhtbdnj.js +0 -2
- package/dist/chunk-t4g97h08.js +0 -2
- package/dist/chunk-t7f9zmy8.js +0 -2
- package/dist/chunk-tme29zh9.js +0 -3
- package/dist/chunk-x1xx8qt0.js +0 -2
- package/dist/chunk-xmfhb2v0.js +0 -2
- package/dist/chunk-xsw183n7.js +0 -2
- package/dist/chunk-xtwe2rnp.js +0 -2
- package/dist/chunk-xxnh7gv8.js +0 -2
- package/dist/chunk-y84n0dvg.js +0 -2
- package/dist/chunk-zr0k9pz5.js +0 -2
- package/dist/chunk-zytcxy8p.js +0 -2
package/dist/craft-bridge.js
CHANGED
|
@@ -322,7 +322,7 @@ else if (data.type === 'event' && data.method) {
|
|
|
322
322
|
});
|
|
323
323
|
|
|
324
324
|
// Build the craft API object
|
|
325
|
-
window.craft = Object.assign({},
|
|
325
|
+
window.craft = Object.assign({}, {
|
|
326
326
|
// Meta
|
|
327
327
|
isCraft,
|
|
328
328
|
on,
|
|
@@ -454,7 +454,7 @@ else if (data.type === 'event' && data.method) {
|
|
|
454
454
|
// Native component helpers
|
|
455
455
|
nativeUI,
|
|
456
456
|
components: componentAPI
|
|
457
|
-
});
|
|
457
|
+
}, existingCraft, { nativeUI, components: componentAPI });
|
|
458
458
|
|
|
459
459
|
// Dispatch ready event
|
|
460
460
|
window.dispatchEvent(new CustomEvent('craft:ready', { detail: { isCraft: isCraft() } }));
|
package/dist/craft-entry.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{us,ei,ti}from"./chunk-0ergsswn.js";import"./chunk-hjtym7d9.js";import"./chunk-y255yybn.js";import"./chunk-fk79x8ns.js";import"./chunk-g1ae3haw.js";import"./chunk-ahyq08mp.js";import"./chunk-0bptz1km.js";import"./chunk-tw10tgz8.js";import"./chunk-arrvcn7c.js";import"./chunk-a0ygyftk.js";import"./chunk-jdx4za9p.js";import"./chunk-pvfx0dgz.js";import"./chunk-1m5cjrpw.js";import"./chunk-7ftn9ber.js";import{Wu,Go,qu,Gu,Ko,ls,Xo,Ku,Jo,Xu,Ju,Yo,Zo,Qo}from"./chunk-mek121wh.js";import"./chunk-2kppq4pg.js";import"./chunk-95ygdn0n.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{
|
|
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{Wu as CRAFT_BRIDGE_SCRIPT,ls as CRAFT_COMPONENTS,Ku as CRAFT_COMPONENT_RUNTIME,Xo as CRAFT_COMPONENT_STYLES,us as NATIVE_COMPONENTS,Yo as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,ei as compileToNative,ti as createHotReloadServer,Go as generateCraftBridgeScript,V as generateCraftOptimizations,Qo as getAvailableFormats,Zo as getAvailableTargets,Ju as getCraftComponents,G as getSSRCacheStats,Ko as injectCraftBridge,qu as isCraftEnvironment,Y as prerenderForCraft,Jo as processCraftComponents,Gu as processCraftDirective,Xu as registerCraftComponent,Q as renderSSR};
|
package/dist/craft.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{us,ei,ti}from"./chunk-0ergsswn.js";import"./chunk-hjtym7d9.js";import"./chunk-y255yybn.js";import"./chunk-fk79x8ns.js";import"./chunk-g1ae3haw.js";import"./chunk-ahyq08mp.js";import"./chunk-0bptz1km.js";import"./chunk-tw10tgz8.js";import"./chunk-arrvcn7c.js";import"./chunk-a0ygyftk.js";import"./chunk-jdx4za9p.js";import"./chunk-pvfx0dgz.js";import"./chunk-1m5cjrpw.js";import"./chunk-7ftn9ber.js";import{Wu,Go,qu,Gu,Ko,ls,Xo,Ku,Jo,Xu,Ju,Yo,Zo,Qo}from"./chunk-mek121wh.js";import"./chunk-2kppq4pg.js";import"./chunk-95ygdn0n.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{
|
|
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{Wu as CRAFT_BRIDGE_SCRIPT,ls as CRAFT_COMPONENTS,Ku as CRAFT_COMPONENT_RUNTIME,Xo as CRAFT_COMPONENT_STYLES,us as NATIVE_COMPONENTS,Yo as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,ei as compileToNative,ti as createHotReloadServer,Go as generateCraftBridgeScript,V as generateCraftOptimizations,Qo as getAvailableFormats,Zo as getAvailableTargets,Ju as getCraftComponents,G as getSSRCacheStats,Ko as injectCraftBridge,qu as isCraftEnvironment,Y as prerenderForCraft,Jo as processCraftComponents,Gu as processCraftDirective,Xu as registerCraftComponent,Q as renderSSR};
|
package/dist/lazy-module.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { version } from "../package.json" with { type: "json" };
|
|
2
|
+
const LAZY_MODULE_PROMISES = Symbol.for(`stx.lazy-module-promises.${version}`);
|
|
2
3
|
function modulePromises() {
|
|
3
4
|
const shared = globalThis;
|
|
4
5
|
shared[LAZY_MODULE_PROMISES] ??= new Map;
|
package/dist/menubar.d.ts
CHANGED
|
@@ -33,12 +33,14 @@ export declare interface MenuBarAppOptions<T extends Record<string, unknown>> {
|
|
|
33
33
|
template: string
|
|
34
34
|
templateSource?: string
|
|
35
35
|
preferences?: T
|
|
36
|
+
preferencesPath?: string
|
|
36
37
|
context?: (preferences: Preferences<T>) => Record<string, unknown> | Promise<Record<string, unknown>>
|
|
37
38
|
routes?: Routes<T>
|
|
38
39
|
menu?: (preferences: Preferences<T>) => MenuBarMenuItem[]
|
|
39
40
|
launchAtLogin?: keyof T
|
|
40
41
|
window?: WindowOptions
|
|
41
42
|
port?: number
|
|
43
|
+
onStop?: () => void
|
|
42
44
|
}
|
|
43
45
|
export declare interface MenuBarApp<T extends Record<string, unknown>> {
|
|
44
46
|
readonly preferences: Preferences<T>
|
package/dist/menubar.js
CHANGED
|
@@ -31,7 +31,8 @@ export function applyPreferencePatch(preferences, patch) {
|
|
|
31
31
|
export function createMenuBarApp(options) {
|
|
32
32
|
const preferences = createPreferences({
|
|
33
33
|
name: options.name.toLowerCase(),
|
|
34
|
-
defaults: options.preferences ?? {}
|
|
34
|
+
defaults: options.preferences ?? {},
|
|
35
|
+
path: options.preferencesPath
|
|
35
36
|
}), routes = new Map(Object.entries(options.routes ?? {}).map(([key, handler]) => [normalizeRouteKey(key), handler])), builtins = {
|
|
36
37
|
"GET /api/preferences": () => preferences.getAll(),
|
|
37
38
|
"POST /api/preferences": async (request) => applyPreferencePatch(preferences, await request.json()),
|
|
@@ -40,7 +41,7 @@ export function createMenuBarApp(options) {
|
|
|
40
41
|
for (const [key, handler] of Object.entries(builtins))
|
|
41
42
|
if (!routes.has(key))
|
|
42
43
|
routes.set(key, handler);
|
|
43
|
-
let server = null, window = null, url = null;
|
|
44
|
+
let server = null, window = null, url = null, stopping = !1, started = !1;
|
|
44
45
|
async function renderPopup() {
|
|
45
46
|
const renderOptions = { context: await options.context?.(preferences) ?? {}, wrapInDocument: !0, title: options.name }, html = options.templateSource ? await renderTemplateString(options.templateSource, options.template, renderOptions) : await renderTemplate(options.template, renderOptions);
|
|
46
47
|
return new Response(html, { headers: { "Content-Type": "text/html; charset=utf-8" } });
|
|
@@ -77,6 +78,9 @@ export function createMenuBarApp(options) {
|
|
|
77
78
|
return url;
|
|
78
79
|
},
|
|
79
80
|
async start() {
|
|
81
|
+
if (started)
|
|
82
|
+
return this;
|
|
83
|
+
started = !0;
|
|
80
84
|
if (!server)
|
|
81
85
|
serve();
|
|
82
86
|
bindLaunchAtLogin();
|
|
@@ -85,9 +89,18 @@ export function createMenuBarApp(options) {
|
|
|
85
89
|
title: options.name,
|
|
86
90
|
...options.window
|
|
87
91
|
});
|
|
92
|
+
if (!window) {
|
|
93
|
+
this.stop();
|
|
94
|
+
throw Error(`Could not open ${options.name}'s native window`);
|
|
95
|
+
}
|
|
96
|
+
window.onClosed(() => this.stop());
|
|
88
97
|
return this;
|
|
89
98
|
},
|
|
90
99
|
stop() {
|
|
100
|
+
if (stopping)
|
|
101
|
+
return;
|
|
102
|
+
stopping = !0;
|
|
103
|
+
options.onStop?.();
|
|
91
104
|
window?.close();
|
|
92
105
|
window = null;
|
|
93
106
|
server?.stop();
|
|
@@ -9,10 +9,11 @@ export declare function nativePaletteColor(reference: string): string | undefine
|
|
|
9
9
|
/**
|
|
10
10
|
* The class list as styles, with `dark:` variants kept apart.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
* variants
|
|
12
|
+
* `focus:` is opt-in for hosts that report it (currently TextInput). Other
|
|
13
|
+
* variants remain diagnostic, including focus-visible: focus alone does not
|
|
14
|
+
* establish keyboard modality. Unsupported rings are never faked as borders.
|
|
14
15
|
*/
|
|
15
|
-
export declare function compileClassStyles(classes: string, variables?: NativeStyleVariables): ClassStyles;
|
|
16
|
+
export declare function compileClassStyles(classes: string, variables?: NativeStyleVariables, options?: { focus?: boolean, focusWithin?: boolean }): ClassStyles;
|
|
16
17
|
export declare function compileHeadwindToStyle(classes: string | string[], unknown?: string[]): STXStyle;
|
|
17
18
|
/**
|
|
18
19
|
* ============================================================================
|
|
@@ -411,6 +412,8 @@ declare const borderRadius: Record<string, number>;
|
|
|
411
412
|
export declare interface ClassStyles {
|
|
412
413
|
style: STXStyle
|
|
413
414
|
dark?: STXStyle
|
|
415
|
+
focus?: { style: STXStyle, dark?: STXStyle }
|
|
416
|
+
focusWithin?: { style: STXStyle, dark?: STXStyle }
|
|
414
417
|
unknown: string[]
|
|
415
418
|
numberOfLines?: number
|
|
416
419
|
icon?: string
|
|
@@ -1199,8 +1199,11 @@ function parseShadow(className, style) {
|
|
|
1199
1199
|
Object.assign(style, { shadowColor: "#000000", shadowOpacity: opacity, shadowRadius: radius, shadowOffset: { width: 0, height: offset }, elevation });
|
|
1200
1200
|
return !0;
|
|
1201
1201
|
}
|
|
1202
|
-
export function compileClassStyles(classes, variables) {
|
|
1203
|
-
const plain = [], dark = [], semanticDark = [], unsupported = [],
|
|
1202
|
+
export function compileClassStyles(classes, variables, options = {}) {
|
|
1203
|
+
const plain = [], dark = [], semanticDark = [], unsupported = [], focusLayers = {
|
|
1204
|
+
focus: { classes: [], originals: new Map },
|
|
1205
|
+
focusWithin: { classes: [], originals: new Map }
|
|
1206
|
+
}, originals = new Map;
|
|
1204
1207
|
function roleClasses(name, scheme) {
|
|
1205
1208
|
const match = /^(text|bg|border|ring)-([a-z-]+)(\/[^\s]+)?$/.exec(name), role = match && SEMANTIC_TOKENS[match[2]];
|
|
1206
1209
|
if (role) {
|
|
@@ -1231,7 +1234,14 @@ export function compileClassStyles(classes, variables) {
|
|
|
1231
1234
|
originals.get(translated).add(original);
|
|
1232
1235
|
return translated;
|
|
1233
1236
|
}
|
|
1234
|
-
for (const name of classes.split(/\s+/).filter(Boolean))
|
|
1237
|
+
for (const name of classes.split(/\s+/).filter(Boolean)) {
|
|
1238
|
+
const focused = /^(dark:)?(focus|focus-within):(dark:)?(.+)$/.exec(name), focusKey = focused?.[2] === "focus" ? "focus" : "focusWithin";
|
|
1239
|
+
if (focused && options[focusKey] && !(focused[1] && focused[3])) {
|
|
1240
|
+
const translated = `${focused[1] || focused[3] ? "dark:" : ""}${focused[4]}`, layer = focusLayers[focusKey];
|
|
1241
|
+
layer.classes.push(translated);
|
|
1242
|
+
layer.originals.set(translated, [...layer.originals.get(translated) ?? [], name]);
|
|
1243
|
+
continue;
|
|
1244
|
+
}
|
|
1235
1245
|
if (name.startsWith("dark:")) {
|
|
1236
1246
|
const translated = roleClasses(name.slice(5), "dark");
|
|
1237
1247
|
if (!translated)
|
|
@@ -1249,6 +1259,7 @@ export function compileClassStyles(classes, variables) {
|
|
|
1249
1259
|
semanticDark.push(...darkClasses.map((value) => remember(value, name)));
|
|
1250
1260
|
} else
|
|
1251
1261
|
unsupported.push(name);
|
|
1262
|
+
}
|
|
1252
1263
|
const unknown = [], style = compileHeadwindToStyle(plain, unknown), result = { style, unknown };
|
|
1253
1264
|
if (dark.length || semanticDark.length)
|
|
1254
1265
|
result.dark = compileHeadwindToStyle([...semanticDark, ...dark], unknown);
|
|
@@ -1267,6 +1278,17 @@ export function compileClassStyles(classes, variables) {
|
|
|
1267
1278
|
}
|
|
1268
1279
|
const authoredUnknown = unknown.flatMap((name) => [...originals.get(name) ?? [name]]);
|
|
1269
1280
|
result.unknown = [...new Set([...authoredUnknown.filter((name) => !/^line-clamp-\d+$/.test(name)), ...unsupported])];
|
|
1281
|
+
for (const key of ["focus", "focusWithin"]) {
|
|
1282
|
+
const layer = focusLayers[key];
|
|
1283
|
+
if (!layer.classes.length)
|
|
1284
|
+
continue;
|
|
1285
|
+
const focused = compileClassStyles(layer.classes.join(" "), variables);
|
|
1286
|
+
result[key] = { style: focused.style, dark: focused.dark };
|
|
1287
|
+
result.unknown = [...new Set([...result.unknown, ...focused.unknown.flatMap((name) => layer.originals.get(name) ?? [name])])];
|
|
1288
|
+
for (const name of layer.classes)
|
|
1289
|
+
if (/^(?:dark:)?(?:truncate|line-clamp-\d+|i-[a-z0-9]+-.+)$/.test(name))
|
|
1290
|
+
result.unknown.push(...layer.originals.get(name));
|
|
1291
|
+
}
|
|
1270
1292
|
return result;
|
|
1271
1293
|
}
|
|
1272
1294
|
export function compileHeadwindToStyle(classes, unknown) {
|
|
@@ -155,7 +155,7 @@ function readAttributes(tag, attributes, diagnostics, styleContext = {}) {
|
|
|
155
155
|
props[prop] = decoded;
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
|
-
const compiledClasses = classes ? compileClassStyles(classes, variables) : void 0;
|
|
158
|
+
const focus = props["data-native"] ? props["data-native"] === "TextInput" : tag === "textarea" || tag === "input" && !["checkbox", "radio", "hidden"].includes(String(props.type ?? "text").toLowerCase()), compiledClasses = classes ? compileClassStyles(classes, variables, { focus, focusWithin: !0 }) : void 0;
|
|
159
159
|
for (const name of new Set(compiledClasses?.unknown ?? []))
|
|
160
160
|
diagnostics.push({ kind: "unknown-class", tag, name });
|
|
161
161
|
const style = applyNativeLayoutDefaults({ ...compiledClasses?.style, ...inline });
|
|
@@ -286,7 +286,7 @@ export async function translateHtmlToIR(html, options = {}) {
|
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
|
-
if (type === tag && !NATIVE_TYPES.has(type) && !DROP_SUBTREE.has(tag) && !UNWRAP.has(tag) && !seenUnmapped.has(tag)) {
|
|
289
|
+
if (!inheritedDrop && type === tag && !NATIVE_TYPES.has(type) && !DROP_SUBTREE.has(tag) && !UNWRAP.has(tag) && !seenUnmapped.has(tag)) {
|
|
290
290
|
seenUnmapped.add(tag);
|
|
291
291
|
diagnostics.push({ kind: "unmapped-tag", tag });
|
|
292
292
|
}
|
|
@@ -304,7 +304,7 @@ export async function translateHtmlToIR(html, options = {}) {
|
|
|
304
304
|
props["data-stx-form"] = !0;
|
|
305
305
|
if (tag === "button" && props.type === void 0)
|
|
306
306
|
props.type = "submit";
|
|
307
|
-
if (type === "Video" && props.source === void 0 && props.src !== void 0) {
|
|
307
|
+
if ((type === "Video" || type === "Image") && props.source === void 0 && props.src !== void 0) {
|
|
308
308
|
props.source = props.src;
|
|
309
309
|
delete props.src;
|
|
310
310
|
}
|
|
@@ -340,7 +340,7 @@ export async function translateHtmlToIR(html, options = {}) {
|
|
|
340
340
|
node,
|
|
341
341
|
variables,
|
|
342
342
|
declaredNative: typeof declared === "string" && NATIVE_TYPES.has(declared),
|
|
343
|
-
dropped: dropped || inheritedDrop || BOX_ONLY.has(tag),
|
|
343
|
+
dropped: dropped || inheritedDrop || BOX_ONLY.has(tag) || type === "Video",
|
|
344
344
|
discard: dropped || inheritedDrop,
|
|
345
345
|
unwrap: UNWRAP.has(tag)
|
|
346
346
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Restore a native protocol prop after HTML lowercasing or kebab-case binding emission. */
|
|
2
|
-
export declare function nativePropName(name: string): string;
|
|
2
|
+
export declare function nativePropName(name: string, type?: string): string;
|
|
3
3
|
/**
|
|
4
4
|
* Native props that are booleans, where an attribute written bare means true
|
|
5
5
|
* as it does in HTML. HTML hands a bare attribute over as an empty string, so
|
|
@@ -134,6 +134,8 @@ const nativePropNames = new Map(NATIVE_PROP_NAMES.map((name) => [normaliseKey(na
|
|
|
134
134
|
function normaliseKey(name) {
|
|
135
135
|
return name.replace(/[-_]/g, "").toLowerCase();
|
|
136
136
|
}
|
|
137
|
-
export function nativePropName(name) {
|
|
137
|
+
export function nativePropName(name, type) {
|
|
138
|
+
if ((type === "Image" || type === "Video") && name.toLowerCase() === "src")
|
|
139
|
+
return "source";
|
|
138
140
|
return nativePropNames.get(normaliseKey(name)) ?? name;
|
|
139
141
|
}
|
|
@@ -104,6 +104,8 @@ export function createNativeHost(options) {
|
|
|
104
104
|
if (!record)
|
|
105
105
|
return;
|
|
106
106
|
record.materialized = !1;
|
|
107
|
+
record.focused = !1;
|
|
108
|
+
record.focusWithin = !1;
|
|
107
109
|
node.__stxDetachedRecord = record;
|
|
108
110
|
record.children.forEach(retainDetachedDescriptors);
|
|
109
111
|
records.delete(node.__stxId);
|
|
@@ -226,6 +228,11 @@ export function createNativeHost(options) {
|
|
|
226
228
|
}
|
|
227
229
|
function installControlListeners(node) {
|
|
228
230
|
const record = descriptorOf(node);
|
|
231
|
+
if (record?.type === "TextInput" && !record.focusListenersInstalled) {
|
|
232
|
+
record.focusListenersInstalled = !0;
|
|
233
|
+
host.listen(node, "focus", () => {});
|
|
234
|
+
host.listen(node, "blur", () => {});
|
|
235
|
+
}
|
|
229
236
|
if (!record || controlsWithDefaultListeners.has(node))
|
|
230
237
|
return;
|
|
231
238
|
let delegatedPress = !1;
|
|
@@ -282,8 +289,29 @@ export function createNativeHost(options) {
|
|
|
282
289
|
inherited = parseNativeStyleLayers([source], inherited, report).variables;
|
|
283
290
|
const resolved = parseNativeStyleLayers([record.styleSource, record.boundStyle, record.forwardedStyle], inherited, report);
|
|
284
291
|
record.variables = resolved.variables;
|
|
285
|
-
const classes = compileClassStyles(`${record.classes} ${record.forwardedClasses ?? ""}`, record.variables);
|
|
286
|
-
|
|
292
|
+
const classes = compileClassStyles(`${record.classes} ${record.forwardedClasses ?? ""}`, record.variables, { focus: record.type === "TextInput", focusWithin: !0 }), classStyle = { ...classes.style, ...colorScheme === "dark" ? classes.dark : {} };
|
|
293
|
+
for (const layer of [record.focusWithin && classes.focusWithin, record.focused && classes.focus]) {
|
|
294
|
+
if (!layer)
|
|
295
|
+
continue;
|
|
296
|
+
const focused = { ...layer.style, ...colorScheme === "dark" ? layer.dark : {} };
|
|
297
|
+
if (classStyle.transform && focused.transform) {
|
|
298
|
+
const overridden = new Set(focused.transform.flatMap((step) => Object.keys(step)));
|
|
299
|
+
focused.transform = [...classStyle.transform.filter((step) => !Object.keys(step).some((key) => overridden.has(key))), ...focused.transform];
|
|
300
|
+
}
|
|
301
|
+
Object.assign(classStyle, focused);
|
|
302
|
+
}
|
|
303
|
+
return { ...applyNativeLayoutDefaults({ ...classStyle, ...resolved.styles[0], ...record.baseStyle, ...resolved.styles[1], ...resolved.styles[2] }), ...record.visible && !isHiddenInput(record) ? {} : { display: "none" } };
|
|
304
|
+
}
|
|
305
|
+
function refreshFocusChain(node) {
|
|
306
|
+
for (let current = node;current; current = current.__stxOwner) {
|
|
307
|
+
const record = descriptorOf(current);
|
|
308
|
+
if (!record)
|
|
309
|
+
continue;
|
|
310
|
+
const within = record.visible && (record.focused === !0 || record.children.some((child) => descriptorOf(child)?.focusWithin === !0)), changed = record.focusWithin !== within;
|
|
311
|
+
record.focusWithin = within;
|
|
312
|
+
if (current.__stxAnchor === void 0 && (changed || current === node))
|
|
313
|
+
applyClasses(current.__stxId, record, !0);
|
|
314
|
+
}
|
|
287
315
|
}
|
|
288
316
|
function refreshStyleTree(node, inherited = node.__stxOwner ? descriptorOf(node.__stxOwner)?.variables : stylesheetVariables, appearanceChanged = !1) {
|
|
289
317
|
if (node.__stxAnchor !== void 0)
|
|
@@ -346,7 +374,7 @@ export function createNativeHost(options) {
|
|
|
346
374
|
record.style = style;
|
|
347
375
|
if (record.materialized && changed)
|
|
348
376
|
emit({ op: "updateNode", id, patch: { style: { ...patch, ...style } } });
|
|
349
|
-
const classes = compileClassStyles(`${record.classes} ${record.forwardedClasses ?? ""}`, record.variables), unsupported = new Set(classes.unknown);
|
|
377
|
+
const classes = compileClassStyles(`${record.classes} ${record.forwardedClasses ?? ""}`, record.variables, { focus: record.type === "TextInput", focusWithin: !0 }), unsupported = new Set(classes.unknown);
|
|
350
378
|
for (const name of unsupported)
|
|
351
379
|
if (!record.reportedClasses?.has(name))
|
|
352
380
|
console.warn(`[STX Native] unknown-class: ${id}: ${name}`);
|
|
@@ -522,7 +550,7 @@ export function createNativeHost(options) {
|
|
|
522
550
|
return null;
|
|
523
551
|
if (isBindingNode(node))
|
|
524
552
|
return node.getAttribute(name);
|
|
525
|
-
const
|
|
553
|
+
const record = descriptorOf(node), value = record?.props[nativePropName(name, record.type)];
|
|
526
554
|
return value == null || value === !1 ? null : value === !0 ? "" : String(value);
|
|
527
555
|
},
|
|
528
556
|
observeChildren(node, callback) {
|
|
@@ -626,8 +654,12 @@ export function createNativeHost(options) {
|
|
|
626
654
|
applyClasses(node.__stxId, record);
|
|
627
655
|
return;
|
|
628
656
|
}
|
|
629
|
-
const
|
|
657
|
+
const record = recordOf(node), prop = nativePropName(name, record.type), accessibilityBefore = prop === "role" || prop.startsWith("aria-") || prop.startsWith("accessibility") ? projectAccessibility(record.props) : void 0;
|
|
630
658
|
record.props[prop] = value;
|
|
659
|
+
if (record.focused && disabled(record)) {
|
|
660
|
+
record.focused = !1;
|
|
661
|
+
refreshFocusChain(node);
|
|
662
|
+
}
|
|
631
663
|
if (record.type === "Icon" && prop === "name") {
|
|
632
664
|
const icon = resolveIconName(String(value ?? ""));
|
|
633
665
|
this.setAttribute(node, "iconify", icon.iconify ?? null);
|
|
@@ -662,7 +694,7 @@ export function createNativeHost(options) {
|
|
|
662
694
|
this.setAttribute(node, name, "");
|
|
663
695
|
return;
|
|
664
696
|
}
|
|
665
|
-
const
|
|
697
|
+
const record = recordOf(node), prop = nativePropName(name, record.type), accessibilityBefore = prop === "role" || prop.startsWith("aria-") || prop.startsWith("accessibility") ? projectAccessibility(record.props) : void 0;
|
|
666
698
|
delete record.props[prop];
|
|
667
699
|
const patch = { [prop]: null };
|
|
668
700
|
if (accessibilityBefore)
|
|
@@ -767,6 +799,18 @@ export function createNativeHost(options) {
|
|
|
767
799
|
const id = nextId("h");
|
|
768
800
|
registrations.set(nativeEvent, id);
|
|
769
801
|
handlers.set(id, (payload) => {
|
|
802
|
+
if (record.type === "TextInput" && (nativeEvent === "onFocus" || nativeEvent === "onBlur")) {
|
|
803
|
+
let focused = nativeEvent === "onFocus" && !disabled(record);
|
|
804
|
+
for (let current = node;focused && current; current = current.__stxOwner) {
|
|
805
|
+
const ancestor = descriptorOf(current);
|
|
806
|
+
if (!ancestor?.materialized || !ancestor.visible || ancestor.style.display === "none")
|
|
807
|
+
focused = !1;
|
|
808
|
+
}
|
|
809
|
+
if (record.focused !== focused) {
|
|
810
|
+
record.focused = focused;
|
|
811
|
+
refreshFocusChain(node);
|
|
812
|
+
}
|
|
813
|
+
}
|
|
770
814
|
if (disabled(record))
|
|
771
815
|
return;
|
|
772
816
|
if (nativeEvent === "onChangeText" || nativeEvent === "onValueChange") {
|
|
@@ -853,6 +897,14 @@ export function createNativeHost(options) {
|
|
|
853
897
|
setVisible(node, visible) {
|
|
854
898
|
const record = recordOf(node), was = record.visible;
|
|
855
899
|
record.visible = visible;
|
|
900
|
+
if (!visible)
|
|
901
|
+
for (const target of [node, ...collectDescendants(node)]) {
|
|
902
|
+
const child = descriptorOf(target);
|
|
903
|
+
if (!child?.focused)
|
|
904
|
+
continue;
|
|
905
|
+
child.focused = !1;
|
|
906
|
+
refreshFocusChain(target);
|
|
907
|
+
}
|
|
856
908
|
if (!visible) {
|
|
857
909
|
if (was)
|
|
858
910
|
record.shownDisplay = record.baseStyle.display;
|
|
@@ -936,6 +988,11 @@ export function createNativeHost(options) {
|
|
|
936
988
|
refreshStyleTree(node, record.variables);
|
|
937
989
|
insertIntoBindingParent(parent, node, index);
|
|
938
990
|
setConnected(node, record.materialized);
|
|
991
|
+
if (descriptorOf(node)?.focusWithin) {
|
|
992
|
+
if (oldOwner && oldOwner !== parent)
|
|
993
|
+
refreshFocusChain(oldOwner);
|
|
994
|
+
refreshFocusChain(parent);
|
|
995
|
+
}
|
|
939
996
|
if (oldOwner && oldOwner !== parent)
|
|
940
997
|
notifyChildren(oldOwner);
|
|
941
998
|
notifyChildren(parent);
|
|
@@ -966,7 +1023,7 @@ export function createNativeHost(options) {
|
|
|
966
1023
|
return ids;
|
|
967
1024
|
},
|
|
968
1025
|
remove(node) {
|
|
969
|
-
const wasMaterialized = descriptorOf(node)?.materialized === !0, owner = node.__stxOwner;
|
|
1026
|
+
const wasMaterialized = descriptorOf(node)?.materialized === !0, hadFocus = descriptorOf(node)?.focusWithin === !0, owner = node.__stxOwner;
|
|
970
1027
|
if (owner) {
|
|
971
1028
|
const record = recordOf(owner), at = record.children.findIndex((child) => child.__stxId === node.__stxId);
|
|
972
1029
|
if (at !== -1)
|
|
@@ -981,6 +1038,8 @@ export function createNativeHost(options) {
|
|
|
981
1038
|
setConnected(node, !1);
|
|
982
1039
|
releaseHandlers(node);
|
|
983
1040
|
retainDetachedDescriptors(node);
|
|
1041
|
+
if (hadFocus)
|
|
1042
|
+
refreshFocusChain(owner);
|
|
984
1043
|
notifyChildren(owner);
|
|
985
1044
|
if (node.__stxAnchor !== void 0 || !wasMaterialized)
|
|
986
1045
|
return;
|
package/dist/native-build.d.ts
CHANGED
package/dist/native-build.js
CHANGED
|
@@ -104,7 +104,9 @@ async function buildMacOS(html, appName, appVersion, outputDir, format, config,
|
|
|
104
104
|
height: config.window?.height || 800,
|
|
105
105
|
devTools: Boolean(config.devTools)
|
|
106
106
|
};
|
|
107
|
-
if (
|
|
107
|
+
if (config.trayPopover)
|
|
108
|
+
manifest.trayPopover = !0;
|
|
109
|
+
else if (menubarOnly)
|
|
108
110
|
manifest.menubarOnly = !0;
|
|
109
111
|
else if (config.systemTray)
|
|
110
112
|
manifest.systemTray = !0;
|
|
@@ -131,7 +133,7 @@ exec "$DIR/craft" --html-file "$RESOURCES/index.html" \\
|
|
|
131
133
|
`--title "${config.window?.title || appName}"`,
|
|
132
134
|
`--width ${config.window?.width || 1200}`,
|
|
133
135
|
`--height ${config.window?.height || 800}`,
|
|
134
|
-
menubarOnly ? "--menubar-only" : config.systemTray ? "--system-tray" : "",
|
|
136
|
+
config.trayPopover ? "--tray-popover" : menubarOnly ? "--menubar-only" : config.systemTray ? "--system-tray" : "",
|
|
135
137
|
config.devTools ? "" : "--no-devtools",
|
|
136
138
|
config.window?.frameless ? "--frameless" : "",
|
|
137
139
|
config.window?.transparent ? "--transparent" : "",
|
|
@@ -158,7 +160,7 @@ exec "$DIR/craft" --html-file "$RESOURCES/index.html" \\
|
|
|
158
160
|
LSMinimumSystemVersion: config.minimumSystemVersion || "13.0",
|
|
159
161
|
NSHighResolutionCapable: !0,
|
|
160
162
|
NSSupportsAutomaticGraphicsSwitching: !0,
|
|
161
|
-
LSUIElement: config.menubarOnly ?? Boolean(config.systemTray),
|
|
163
|
+
LSUIElement: config.trayPopover || (config.menubarOnly ?? Boolean(config.systemTray)),
|
|
162
164
|
...hasIcon ? { CFBundleIconFile: "AppIcon" } : {},
|
|
163
165
|
...config.category ? { LSApplicationCategoryType: config.category } : {},
|
|
164
166
|
...config.copyright ? { NSHumanReadableCopyright: config.copyright } : {},
|
package/dist/process.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { processJsonDirective, processOnceDirective } from './misc-directives';
|
|
2
2
|
import { validateClientScript } from './script-validation';
|
|
3
3
|
import type { StxOptions } from './types';
|
|
4
|
+
export declare function buildModulesTag(sources: Array<string | null>, options: StxOptions, dependencies?: Set<string>): Promise<string | null>;
|
|
4
5
|
export declare function processDirectives(template: string, context: Record<string, any>, filePath: string, options: StxOptions, dependencies: Set<string>): Promise<string>;
|
|
5
6
|
// Re-export public API from extracted modules (preserves backwards compatibility)
|
|
6
7
|
export { injectRouterScript } from './runtime-injection';
|
package/dist/process.js
CHANGED
|
@@ -226,7 +226,7 @@ async function externalBundleTag(attrs, code, options) {
|
|
|
226
226
|
const { registerServeModuleBundle } = await import("./caching.js");
|
|
227
227
|
return `<script ${attrs} src="${registerServeModuleBundle(code)}"></script>`;
|
|
228
228
|
}
|
|
229
|
-
async function buildModulesTag(sources, options, dependencies) {
|
|
229
|
+
export async function buildModulesTag(sources, options, dependencies) {
|
|
230
230
|
try {
|
|
231
231
|
const { registeredModuleIdsIn, buildModuleRegistryScript } = await importOnce("stx/client-module-registry", () => import("./client-module-registry.js")), inputs = [], code = await buildModuleRegistryScript(registeredModuleIdsIn(...sources), {
|
|
232
232
|
minify: minifiesClientCode(options.buildMode),
|
package/dist/pwa.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
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{or,qe,ui,yc}from"./chunk-w41kp60h.js";import{sr,ds,gc,mc,hc}from"./chunk-17x6e5mm.js";import{ai,ci,li,pc,fc}from"./chunk-kjspmegt.js";import{de,Tt,ps}from"./chunk-9yk5rasj.js";import{vl,wl,xl,Sl,Mr,Hd}from"./chunk-eyy6zmdk.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-ffjvqjyh.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=de(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{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=de(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=or(n,t);if(a){let s=qe(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 ds(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,ci as auditBuildOutput,ai as auditConfig,re as buildPwaAssets,li as calculateAuditResult,fc as formatAuditResult,ps as formatSize,j as generateManifest,_ as generateManifestJson,mc as generateManifestLink,F as generateOfflinePage,de as generatePrecacheManifest,Tt as generatePrecacheManifestJs,M as generatePwaIcons,sr as generatePwaTags,or as generateServiceWorker,yc as generateServiceWorkerAuto,gc as generateSwRegistrationScript,hc as generateThemeColorMeta,N as getExpectedIconPaths,qe as getServiceWorkerFileName,ds as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,ui as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,Mr as pwaDirectives,vl as pwaInstallDirective,xl as pwaOfflineDirective,Sl as pwaPushDirective,wl as pwaUpdateDirective,Hd as registerPwaDirectives,pc as runPwaAudit,D as validateManifest};
|