@stacksjs/stx 0.2.915 → 0.2.919
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/app-shell.js +3 -2
- package/dist/{chunk-frpsrv1e.js → chunk-09xqy448.js} +2 -2
- package/dist/chunk-0ebaf0pr.js +2 -0
- package/dist/chunk-0jjq552g.js +2 -0
- package/dist/chunk-0wctbtad.js +7 -0
- package/dist/{chunk-r7y1196g.js → chunk-0xyfs691.js} +4 -4
- package/dist/{chunk-w98yt4d4.js → chunk-14df2jzs.js} +2 -2
- package/dist/chunk-15rc8t28.js +2 -0
- package/dist/chunk-1a2c4pv8.js +54 -0
- package/dist/{chunk-1jakr6f2.js → chunk-1baxccfq.js} +18 -18
- package/dist/{chunk-0vyytd9v.js → chunk-1bf0grbf.js} +3 -3
- package/dist/chunk-1jrhjn2b.js +2 -0
- package/dist/chunk-1svffhzq.js +2 -0
- package/dist/{chunk-1hx6dyy9.js → chunk-1ts1pg90.js} +2 -2
- package/dist/{chunk-88fx8xc1.js → chunk-1vsjmwr1.js} +2 -2
- package/dist/{chunk-cxsc37fg.js → chunk-2f46pcg0.js} +2 -2
- package/dist/{chunk-pcwq66w3.js → chunk-2jm7map2.js} +2 -2
- package/dist/chunk-2m4ydym0.js +33 -0
- package/dist/chunk-2mv29s6w.js +9 -0
- package/dist/{chunk-d1ka4dvr.js → chunk-2szhk8mh.js} +5 -5
- package/dist/{chunk-gg715pj6.js → chunk-2zb642qr.js} +6 -6
- package/dist/chunk-3aayrnbh.js +21 -0
- package/dist/chunk-3br07y64.js +20 -0
- package/dist/{chunk-2f5jjxcj.js → chunk-3efpqm1f.js} +2 -2
- package/dist/chunk-3ftrv1f7.js +182 -0
- package/dist/{chunk-barb4gka.js → chunk-3hfv217t.js} +6 -6
- package/dist/{chunk-eptzpvn0.js → chunk-3kpxkjgm.js} +3 -3
- package/dist/{chunk-4w8t0a9e.js → chunk-3tcy9r6r.js} +27 -27
- package/dist/{chunk-zv3rn0ch.js → chunk-40j2pmnb.js} +6 -6
- package/dist/chunk-426gq0g5.js +2 -0
- package/dist/chunk-4ge80k8j.js +2 -0
- package/dist/chunk-4vdfqr64.js +2 -0
- package/dist/chunk-4yz33vzb.js +2 -0
- package/dist/chunk-4zcswx6x.js +2 -0
- package/dist/{chunk-smnt37jq.js → chunk-50zzar2c.js} +3 -3
- package/dist/{chunk-vayzmvf5.js → chunk-514yg4dr.js} +6 -6
- package/dist/{chunk-vnk582z7.js → chunk-5fdc8pej.js} +102 -36
- package/dist/chunk-5ht628zp.js +2 -0
- package/dist/chunk-67zy5p7x.js +2 -0
- package/dist/chunk-6bm7t0hm.js +3 -0
- package/dist/{chunk-7qzanp9y.js → chunk-6n6kndk0.js} +1 -1
- package/dist/chunk-6x5a2w5a.js +3 -0
- package/dist/{chunk-xc5esqcb.js → chunk-6ybq9pfh.js} +2 -2
- package/dist/{chunk-23x3k751.js → chunk-7axtwg1f.js} +2 -2
- package/dist/chunk-8153bfpx.js +2 -0
- package/dist/{chunk-16sfjkc4.js → chunk-858p3hkz.js} +2 -2
- package/dist/chunk-86p0m920.js +2 -0
- package/dist/chunk-88texeh4.js +2 -0
- package/dist/chunk-8mye65n9.js +2 -0
- package/dist/chunk-8ycgk8w6.js +2 -0
- package/dist/{chunk-npj20tj9.js → chunk-9707zz6v.js} +2 -2
- package/dist/{chunk-pyyda92j.js → chunk-9gr7m3tb.js} +1 -1
- package/dist/{chunk-952dfmcb.js → chunk-9mack1g8.js} +3 -3
- package/dist/chunk-9xcsn4pb.js +2 -0
- package/dist/{chunk-3jc6yb02.js → chunk-9zwmfkfg.js} +9 -9
- package/dist/chunk-a5tg553d.js +2 -0
- package/dist/chunk-agxxqjjt.js +2 -0
- package/dist/{chunk-phzhmnnm.js → chunk-ayrd026n.js} +3 -3
- package/dist/chunk-b44pvac7.js +2 -0
- package/dist/chunk-b4yp16a2.js +2 -0
- package/dist/{chunk-95j8660f.js → chunk-cbqe84g3.js} +2 -2
- package/dist/{chunk-qsexsrw2.js → chunk-d4xjwebv.js} +5 -5
- package/dist/{chunk-pmn9kynz.js → chunk-d69k67bn.js} +11 -11
- package/dist/chunk-ex6dne7e.js +3 -0
- package/dist/chunk-fb63xppz.js +2 -0
- package/dist/chunk-ffqqkeye.js +2 -0
- package/dist/chunk-fjpt8arw.js +3 -0
- package/dist/{chunk-mgj074y2.js → chunk-fn0y9z1t.js} +5 -5
- package/dist/{chunk-ar6jeqmm.js → chunk-ft34x0h1.js} +4 -4
- package/dist/{chunk-7x3tt27s.js → chunk-fwxgzktt.js} +2 -2
- package/dist/chunk-g1v12bjm.js +2 -0
- package/dist/chunk-gg0kkn2e.js +2 -0
- package/dist/chunk-ggg8b8n1.js +2 -0
- package/dist/chunk-ggrcg7k7.js +2 -0
- package/dist/{chunk-11c7xg1z.js → chunk-gjyz5ma7.js} +1 -1
- package/dist/chunk-gmn9ba8f.js +3 -0
- package/dist/chunk-gqe574d9.js +2 -0
- package/dist/chunk-h4nqjks2.js +2 -0
- package/dist/chunk-hajamm16.js +2 -0
- package/dist/chunk-hg2n2264.js +2 -0
- package/dist/{chunk-6t8ce21j.js → chunk-hht7n4zd.js} +2 -2
- package/dist/chunk-hxabvt31.js +2 -0
- package/dist/chunk-j3sat6vn.js +2 -0
- package/dist/chunk-j9gbnqxq.js +2 -0
- package/dist/{chunk-1hbf5e1h.js → chunk-jgtn9t5n.js} +2 -2
- package/dist/chunk-jj2z4nxa.js +2 -0
- package/dist/{chunk-0jdz31q1.js → chunk-jjq7c8s2.js} +3 -3
- package/dist/chunk-k289127j.js +2 -0
- package/dist/{chunk-p3fepzt9.js → chunk-kk9h53xg.js} +3 -3
- package/dist/{chunk-xnp031ba.js → chunk-ktv65e3n.js} +7 -7
- package/dist/chunk-m1hfh2t4.js +2 -0
- package/dist/{chunk-9b2wdkbq.js → chunk-m390z8w8.js} +11 -11
- package/dist/chunk-m3qwqhxp.js +2 -0
- package/dist/{chunk-t85zac4y.js → chunk-m6hrb7rm.js} +58 -58
- package/dist/{chunk-7gwysmrs.js → chunk-m86sjbx7.js} +3 -3
- package/dist/chunk-m9smh7fs.js +2 -0
- package/dist/{chunk-1jvt9t3r.js → chunk-m9ta0640.js} +2 -2
- package/dist/chunk-mhnjtc42.js +2 -0
- package/dist/{chunk-hhspwfva.js → chunk-mn9t5fnv.js} +2 -2
- package/dist/{chunk-36cz2v8k.js → chunk-mnpfvxpa.js} +31 -31
- package/dist/{chunk-2vx2ben8.js → chunk-mr9pp5cf.js} +2 -2
- package/dist/{chunk-1jxkc6d0.js → chunk-mztjpp7m.js} +2 -2
- package/dist/chunk-n4bxb2hx.js +2 -0
- package/dist/chunk-n958bxm6.js +2 -0
- package/dist/{chunk-8wqhzzkn.js → chunk-neymp1bb.js} +3 -3
- package/dist/chunk-nkbnsbb0.js +3 -0
- package/dist/chunk-nkr1aa5z.js +2 -0
- package/dist/{chunk-nhyv3w4r.js → chunk-p0xqm2ne.js} +1 -1
- package/dist/chunk-p3vswt0f.js +2 -0
- package/dist/{chunk-z110bf2c.js → chunk-p3x7kwb5.js} +7 -7
- package/dist/chunk-p4twxjfs.js +6 -0
- package/dist/chunk-p8wnp4p1.js +2 -0
- package/dist/{chunk-bvqgq18r.js → chunk-p97h91zx.js} +2 -2
- package/dist/chunk-pjv4dskp.js +2 -0
- package/dist/{chunk-5jc9hmwg.js → chunk-pwg544dw.js} +2 -2
- package/dist/chunk-pxvp0cc9.js +3 -0
- package/dist/chunk-q3z252d9.js +2 -0
- package/dist/{chunk-q9gbdzw0.js → chunk-qda8tmk9.js} +2 -2
- package/dist/chunk-qfkak3jb.js +2 -0
- package/dist/chunk-qnytvyy0.js +2 -0
- package/dist/{chunk-fznjm7qt.js → chunk-qsnw0qyp.js} +2 -2
- package/dist/{chunk-ftvpz1j4.js → chunk-qtzfbv7e.js} +5 -5
- package/dist/{chunk-9xmx8hc7.js → chunk-qzqqzraq.js} +8 -8
- package/dist/{chunk-47z0m17p.js → chunk-rk16391e.js} +3 -3
- package/dist/chunk-rt7xy537.js +2 -0
- package/dist/chunk-rwjye578.js +2 -0
- package/dist/{chunk-cwcmmgvz.js → chunk-s1x2pc9b.js} +2 -2
- package/dist/{chunk-zbpvmgjn.js → chunk-sbr3wg75.js} +65 -65
- package/dist/chunk-sftznswb.js +2 -0
- package/dist/{chunk-cq4cwfqf.js → chunk-sxrcac01.js} +2 -2
- package/dist/{chunk-fzcqw147.js → chunk-tb4be5ct.js} +3 -3
- package/dist/{chunk-m8n14s3z.js → chunk-tnbzg7fd.js} +2 -2
- package/dist/{chunk-jr2r2nh5.js → chunk-txk2z7v0.js} +4 -4
- package/dist/chunk-tz5ktd6d.js +2 -0
- package/dist/{chunk-302nw40c.js → chunk-v060015m.js} +1 -1
- package/dist/chunk-v1a5h1tc.js +38 -0
- package/dist/{chunk-7anbc757.js → chunk-v1x96kjr.js} +8 -8
- package/dist/chunk-vb609vbj.js +1323 -0
- package/dist/chunk-vf7tpgqz.js +70 -0
- package/dist/chunk-vtcyber4.js +2 -0
- package/dist/chunk-vtj3dwhh.js +4 -0
- package/dist/{chunk-p9fyn5k4.js → chunk-whnzf9hn.js} +5 -5
- package/dist/chunk-wq2bpt0w.js +2 -0
- package/dist/{chunk-sdmq09jw.js → chunk-wv0wsavj.js} +2 -2
- package/dist/chunk-wv8zt78c.js +2 -0
- package/dist/{chunk-whc4jptx.js → chunk-wxqay5c2.js} +1 -1
- package/dist/{chunk-gfp39bzr.js → chunk-x40j67z1.js} +2 -2
- package/dist/chunk-xakqpa4z.js +3 -0
- package/dist/{chunk-dgt9kfkp.js → chunk-xap1f1bw.js} +2 -2
- package/dist/{chunk-zk5g49p5.js → chunk-xk7hdpq5.js} +3 -3
- package/dist/{chunk-zkwkhesc.js → chunk-xmy75h5v.js} +2 -2
- package/dist/{chunk-dp6r6gtb.js → chunk-xpsg91dh.js} +5 -5
- package/dist/{chunk-va4xam1q.js → chunk-xq5s4vc1.js} +1 -1
- package/dist/chunk-xy3ex6ht.js +2 -0
- package/dist/chunk-y899wtm8.js +2 -0
- package/dist/chunk-ye45znz5.js +2 -0
- package/dist/chunk-yegp50jb.js +2 -0
- package/dist/chunk-yq9aqpk8.js +2 -0
- package/dist/{chunk-5xbx0r3k.js → chunk-yvaqgdv1.js} +2 -2
- package/dist/{chunk-etmq1qny.js → chunk-yye2pec5.js} +14 -14
- package/dist/{chunk-47nzpbvm.js → chunk-yzqb7y45.js} +6 -6
- package/dist/{chunk-n0nf8n0h.js → chunk-z6nyyt3n.js} +6 -6
- package/dist/{chunk-fs43342z.js → chunk-zaj3nnvv.js} +2 -2
- package/dist/{chunk-2qk2ppgm.js → chunk-zb6my502.js} +1 -1
- package/dist/{chunk-ra2tzsvz.js → chunk-zrxvj3zf.js} +5 -5
- package/dist/chunk-zt45dqfx.js +2 -0
- package/dist/cli.js +38 -38
- package/dist/color-mode-boot.d.ts +1 -8
- package/dist/color-mode-boot.js +46 -2
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/dev-server/ts-css.d.ts +1 -1
- package/dist/dev-server/ts-css.js +2 -2
- package/dist/document-shell.d.ts +2 -0
- package/dist/document-shell.js +15 -3
- package/dist/document-tags.d.ts +2 -0
- package/dist/document-tags.js +9 -0
- package/dist/head-injection.d.ts +2 -0
- package/dist/head-injection.js +1 -0
- package/dist/head.d.ts +2 -0
- package/dist/head.js +2 -2
- package/dist/native/compiler/html-to-ir.d.ts +3 -1
- package/dist/native/compiler/html-to-ir.js +31 -0
- package/dist/native/compiler/ir.d.ts +1 -0
- package/dist/native/components/primitives.d.ts +1 -0
- package/dist/native/event-names.js +2 -0
- package/dist/native/runtime/browser-renderer.d.ts +1 -0
- package/dist/native/runtime/browser-renderer.js +23 -6
- package/dist/native/testing.d.ts +1 -0
- package/dist/native/testing.js +33 -0
- package/dist/page-head.js +1 -9
- package/dist/process.js +1 -1
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +13 -13
- package/dist/types/config-types.d.ts +2 -1
- package/dist/variable-extractor.js +6 -1
- package/package.json +5 -5
- package/dist/chunk-0adc8x2h.js +0 -9
- package/dist/chunk-1gj46s0g.js +0 -2
- package/dist/chunk-1mx3j280.js +0 -2
- package/dist/chunk-1p6gaaf3.js +0 -3
- package/dist/chunk-1rfzs48h.js +0 -2
- package/dist/chunk-20hy5p3p.js +0 -2
- package/dist/chunk-29v3b5ks.js +0 -2
- package/dist/chunk-2cay3heb.js +0 -2
- package/dist/chunk-33fnbw33.js +0 -2
- package/dist/chunk-357qjcj1.js +0 -3
- package/dist/chunk-38y11q8x.js +0 -2
- package/dist/chunk-3q80f7mt.js +0 -2
- package/dist/chunk-43kz6rx9.js +0 -2
- package/dist/chunk-490rrkrp.js +0 -2
- package/dist/chunk-49980am3.js +0 -2
- package/dist/chunk-4a9bqc8f.js +0 -33
- package/dist/chunk-4e18r89n.js +0 -3
- package/dist/chunk-4r0028av.js +0 -1323
- package/dist/chunk-4vz17ytv.js +0 -68
- package/dist/chunk-4w9pvpfd.js +0 -2
- package/dist/chunk-5afnyvw5.js +0 -2
- package/dist/chunk-5pb1x7x6.js +0 -2
- package/dist/chunk-6n50b07t.js +0 -2
- package/dist/chunk-76mn123c.js +0 -2
- package/dist/chunk-8egbh6z1.js +0 -2
- package/dist/chunk-8n9jd8cz.js +0 -2
- package/dist/chunk-8tfpv6zf.js +0 -6
- package/dist/chunk-94qc4zwb.js +0 -2
- package/dist/chunk-9928zdej.js +0 -3
- package/dist/chunk-9ay18k46.js +0 -2
- package/dist/chunk-9tv0tw7f.js +0 -3
- package/dist/chunk-a5h9bwrc.js +0 -2
- package/dist/chunk-am7xmh9p.js +0 -2
- package/dist/chunk-bdkst2wp.js +0 -2
- package/dist/chunk-bej9kz05.js +0 -2
- package/dist/chunk-ccgabq3a.js +0 -2
- package/dist/chunk-cv6d4zr5.js +0 -2
- package/dist/chunk-e5rag6rh.js +0 -3
- package/dist/chunk-eqdg72re.js +0 -2
- package/dist/chunk-fvr3h2fr.js +0 -7
- package/dist/chunk-g0hkknzm.js +0 -2
- package/dist/chunk-g44932zc.js +0 -2
- package/dist/chunk-g4w3wms2.js +0 -2
- package/dist/chunk-gmmqz698.js +0 -2
- package/dist/chunk-hxftzw0x.js +0 -2
- package/dist/chunk-j3d3q3g7.js +0 -2
- package/dist/chunk-jmggm1ep.js +0 -3
- package/dist/chunk-jz37h2z0.js +0 -4
- package/dist/chunk-k8s3hyh2.js +0 -2
- package/dist/chunk-m8mmasgc.js +0 -2
- package/dist/chunk-man5ap64.js +0 -54
- package/dist/chunk-mdgcjzcn.js +0 -38
- package/dist/chunk-mjny8x91.js +0 -2
- package/dist/chunk-mjr5fkc2.js +0 -2
- package/dist/chunk-n1y82svg.js +0 -2
- package/dist/chunk-na0e3s88.js +0 -2
- package/dist/chunk-new89wh2.js +0 -2
- package/dist/chunk-nrap20qt.js +0 -2
- package/dist/chunk-q85wy43m.js +0 -2
- package/dist/chunk-q9yahsww.js +0 -2
- package/dist/chunk-qdwtemy1.js +0 -2
- package/dist/chunk-qp0ndbk6.js +0 -2
- package/dist/chunk-r1fhahnn.js +0 -2
- package/dist/chunk-r4e17p2x.js +0 -2
- package/dist/chunk-rnsa5zz5.js +0 -2
- package/dist/chunk-rzsvxjse.js +0 -2
- package/dist/chunk-senrtnx2.js +0 -2
- package/dist/chunk-sw5g5mbd.js +0 -2
- package/dist/chunk-t63y6qd5.js +0 -2
- package/dist/chunk-v1wr2vdx.js +0 -2
- package/dist/chunk-v6gkjg5f.js +0 -3
- package/dist/chunk-vq7m7xcz.js +0 -182
- package/dist/chunk-wsfqb5jk.js +0 -2
- package/dist/chunk-wvc6eayq.js +0 -2
- package/dist/chunk-wz44vmgn.js +0 -21
- package/dist/chunk-x1kzqxj5.js +0 -2
- package/dist/chunk-xa98a901.js +0 -2
- package/dist/chunk-xj95sk0y.js +0 -2
- package/dist/chunk-xtf3sab5.js +0 -2
- package/dist/chunk-yga49yw3.js +0 -2
- package/dist/chunk-yn02d599.js +0 -2
- package/dist/chunk-z5nx021e.js +0 -20
- package/dist/chunk-z9wwa50p.js +0 -2
package/dist/craft.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
2
|
+
import"./chunk-vf7tpgqz.js";import{Xo,Ja,Ya}from"./chunk-tb4be5ct.js";import"./chunk-mnpfvxpa.js";import"./chunk-jjq7c8s2.js";import"./chunk-858p3hkz.js";import"./chunk-ayrd026n.js";import"./chunk-ex6dne7e.js";import"./chunk-vb609vbj.js";import"./chunk-14df2jzs.js";import"./chunk-qda8tmk9.js";import"./chunk-mr9pp5cf.js";import"./chunk-5fdc8pej.js";import"./chunk-3tcy9r6r.js";import"./chunk-ktv65e3n.js";import"./chunk-txk2z7v0.js";import"./chunk-2mv29s6w.js";import"./chunk-fwxgzktt.js";import"./chunk-m390z8w8.js";import"./chunk-sbr3wg75.js";import"./chunk-d69k67bn.js";import"./chunk-1a2c4pv8.js";import"./chunk-3aayrnbh.js";import"./chunk-whnzf9hn.js";import"./chunk-zaj3nnvv.js";import"./chunk-1bf0grbf.js";import{Yu,Za,sy,oy,Qa,Go,vs,ec,tc,iy,ay,nc,rc,sc,oc}from"./chunk-1baxccfq.js";import"./chunk-2szhk8mh.js";import"./chunk-xakqpa4z.js";import"./chunk-fjpt8arw.js";import"./chunk-v1x96kjr.js";import"./chunk-p0xqm2ne.js";import"./chunk-50zzar2c.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{Yu as CRAFT_BRIDGE_SCRIPT,Go as CRAFT_COMPONENTS,ec as CRAFT_COMPONENT_RUNTIME,vs as CRAFT_COMPONENT_STYLES,Xo as NATIVE_COMPONENTS,nc as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Ja as compileToNative,Ya as createHotReloadServer,rc as findCraftBinary,Za as generateCraftBridgeScript,V as generateCraftOptimizations,oc as getAvailableFormats,sc as getAvailableTargets,ay as getCraftComponents,G as getSSRCacheStats,Qa as injectCraftBridge,sy as isCraftEnvironment,Y as prerenderForCraft,tc as processCraftComponents,oy as processCraftDirective,iy as registerCraftComponent,Q as renderSSR};
|
|
@@ -71,7 +71,7 @@ export declare function withLinkedModuleBundles(htmlContent: string): string;
|
|
|
71
71
|
* Inject generated CSS into HTML content
|
|
72
72
|
* Tries to inject before </head>, falls back to <body> or prepends
|
|
73
73
|
*/
|
|
74
|
-
export declare function injectCss(htmlContent: string, appDir?: string, serveMode?: boolean, dedupeRenderedScopedStyles?: boolean): Promise<string>;
|
|
74
|
+
export declare function injectCss(htmlContent: string, appDir?: string, serveMode?: boolean, dedupeRenderedScopedStyles?: boolean, inlineGeneratedCssBytes?: number): Promise<string>;
|
|
75
75
|
// Type for Css module
|
|
76
76
|
declare interface CssModule {
|
|
77
77
|
CSSGenerator: new (config: CssConfig) => CSSGenerator
|
|
@@ -417,11 +417,11 @@ async function generateCssUncached(htmlContent, appDir) {
|
|
|
417
417
|
return "";
|
|
418
418
|
}
|
|
419
419
|
}
|
|
420
|
-
export async function injectCss(htmlContent, appDir, serveMode = !1, dedupeRenderedScopedStyles = !1) {
|
|
420
|
+
export async function injectCss(htmlContent, appDir, serveMode = !1, dedupeRenderedScopedStyles = !1, inlineGeneratedCssBytes = 0) {
|
|
421
421
|
const css = await generateCss(htmlContent, appDir);
|
|
422
422
|
if (!css)
|
|
423
423
|
return dedupeRenderedScopedStyles ? dedupeScopedStyles(htmlContent) : htmlContent;
|
|
424
|
-
const serveHash = serveMode ? registerCssServeAsset(css) : void 0, assetTag = serveHash ? `<link data-css="generated" rel="stylesheet" href="/_stx/css.${serveHash}.css">` : `<style data-css="generated">
|
|
424
|
+
const inline = inlineGeneratedCssBytes > 0 && Buffer.byteLength(css) <= inlineGeneratedCssBytes, serveHash = serveMode && !inline ? registerCssServeAsset(css) : void 0, assetTag = serveHash ? `<link data-css="generated" rel="stylesheet" href="/_stx/css.${serveHash}.css">` : `<style data-css="generated">
|
|
425
425
|
${css}
|
|
426
426
|
</style>`;
|
|
427
427
|
if (dedupeRenderedScopedStyles)
|
package/dist/document-shell.d.ts
CHANGED
|
@@ -22,6 +22,8 @@ export declare function metaDedupKey(m: Record<string, string>): string;
|
|
|
22
22
|
* equivalent inside a string literal.
|
|
23
23
|
*/
|
|
24
24
|
export declare function inlineScriptContent(s: { content?: unknown, type?: unknown }): string;
|
|
25
|
+
/** Serialize the opt-in separately from ordinary HTML attributes. */
|
|
26
|
+
export declare function headScriptAttributes(script: Record<string, unknown>): Record<string, unknown>;
|
|
25
27
|
/**
|
|
26
28
|
* Build the attribute string for the shell's `<html>` open tag.
|
|
27
29
|
*
|
package/dist/document-shell.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { headCloseIndex } from "./document-tags.js";
|
|
2
|
+
import { BEFORE_RUNTIME_SCRIPT_MARKER } from "./head-injection.js";
|
|
2
3
|
import { generateColorModeBootScript } from "./color-mode-boot.js";
|
|
3
4
|
export const COMPONENT_WRAPPER_RULE = "[data-stx-component-wrapper]:not([stx-hydrate]){display:contents}", CLOAK_STYLE = `<style data-stx-cloak>[x-cloak]{display:none !important}${COMPONENT_WRAPPER_RULE}</style>`, HTML_ATTRS_MARKER = "data-stx-html-attrs", HTML_CLASS_MARKER = "data-stx-html-class";
|
|
4
5
|
const SAFE_ATTR_NAME = /^[A-Za-z_:][\w:.-]*$/;
|
|
@@ -35,8 +36,19 @@ export function inlineScriptContent(s) {
|
|
|
35
36
|
const content = String(s.content), type = typeof s.type === "string" ? s.type.trim().toLowerCase() : "";
|
|
36
37
|
return /json$|^importmap$/.test(type) ? content.replace(/<\//g, "<\\/") : content;
|
|
37
38
|
}
|
|
39
|
+
export function headScriptAttributes(script) {
|
|
40
|
+
const { content, beforeRuntime, ...attributes } = script;
|
|
41
|
+
if (beforeRuntime !== !0)
|
|
42
|
+
return attributes;
|
|
43
|
+
const type = String(attributes.type ?? "").trim().toLowerCase();
|
|
44
|
+
if (typeof content !== "string" || !content.trim() || attributes.src || attributes.async || attributes.defer || type && type !== "text/javascript" && type !== "application/javascript")
|
|
45
|
+
throw Error("A beforeRuntime head script must be synchronous inline JavaScript.");
|
|
46
|
+
delete attributes.async;
|
|
47
|
+
delete attributes.defer;
|
|
48
|
+
return { ...attributes, [BEFORE_RUNTIME_SCRIPT_MARKER]: "" };
|
|
49
|
+
}
|
|
38
50
|
function inlineScriptTag(s) {
|
|
39
|
-
const attrs = attrPairs(s
|
|
51
|
+
const attrs = attrPairs(headScriptAttributes(s));
|
|
40
52
|
return `<script${attrs ? ` ${attrs}` : ""}>${inlineScriptContent(s)}</script>`;
|
|
41
53
|
}
|
|
42
54
|
export function buildHtmlAttrs(htmlAttrs = {}, lang = "en") {
|
|
@@ -246,7 +258,7 @@ export function generateDocumentShell(content, headConfig = {}, options = {}) {
|
|
|
246
258
|
}).join(`
|
|
247
259
|
`), configHeadScripts = headScriptTags.map((s) => {
|
|
248
260
|
if (s.src)
|
|
249
|
-
return ` <script ${attrPairs(s
|
|
261
|
+
return ` <script ${attrPairs(headScriptAttributes(s))}></script>`;
|
|
250
262
|
if (s.content)
|
|
251
263
|
return ` ${inlineScriptTag(s)}`;
|
|
252
264
|
return "";
|
|
@@ -338,7 +350,7 @@ export function injectConfigHeadTags(html, headConfig = {}) {
|
|
|
338
350
|
if (s.src) {
|
|
339
351
|
if (head.includes(`src="${s.src}"`))
|
|
340
352
|
continue;
|
|
341
|
-
parts.push(` <script ${attrPairs(s
|
|
353
|
+
parts.push(` <script ${attrPairs(headScriptAttributes(s))}></script>`);
|
|
342
354
|
} else if (s.content) {
|
|
343
355
|
if (head.includes(inlineScriptContent(s)))
|
|
344
356
|
continue;
|
package/dist/document-tags.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** Read an opening tag's attributes with lowercased names and first duplicate wins. */
|
|
2
|
+
export declare function tagAttributes(token: string): Record<string, string>;
|
|
1
3
|
/** The index of the document's `</head>`, or -1. */
|
|
2
4
|
export declare function headCloseIndex(html: string): number;
|
|
3
5
|
/** The index of the document's `</body>`, or -1. */
|
package/dist/document-tags.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
const RAW_TEXT_OR_TAG = /<!--[\s\S]*?-->|<(script|style|textarea|title)\b[^>]*>[\s\S]*?<\/\1\s*>|<\/(head|body)\s*>/gi;
|
|
2
|
+
export function tagAttributes(token) {
|
|
3
|
+
const attrs = Object.create(null), attributes = token.replace(/^<\w+\b|>$/g, "");
|
|
4
|
+
for (const match of attributes.matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g)) {
|
|
5
|
+
const name = match[1].toLowerCase();
|
|
6
|
+
if (!(name in attrs))
|
|
7
|
+
attrs[name] = match[2] ?? match[3] ?? match[4] ?? "";
|
|
8
|
+
}
|
|
9
|
+
return attrs;
|
|
10
|
+
}
|
|
2
11
|
function closeTagIndex(html, tag, which) {
|
|
3
12
|
if (!html.includes(`</${tag}`) && !html.includes(`</${tag.toUpperCase()}`))
|
|
4
13
|
return -1;
|
package/dist/head-injection.d.ts
CHANGED
|
@@ -52,6 +52,8 @@ export declare function headInsertionPoint(html: string): number | null;
|
|
|
52
52
|
*
|
|
53
53
|
* @module head-injection
|
|
54
54
|
*/
|
|
55
|
+
/** A document-only classic script that runs ahead of the client runtime. */
|
|
56
|
+
export declare const BEFORE_RUNTIME_SCRIPT_MARKER: 'data-stx-before-runtime';
|
|
55
57
|
/** Fragments waiting to be spliced into one document. */
|
|
56
58
|
export declare interface HeadInjections {
|
|
57
59
|
afterOpen: string[]
|
package/dist/head-injection.js
CHANGED
package/dist/head.d.ts
CHANGED
|
@@ -152,6 +152,7 @@ export declare interface ScriptTag {
|
|
|
152
152
|
type?: string
|
|
153
153
|
async?: boolean
|
|
154
154
|
defer?: boolean
|
|
155
|
+
beforeRuntime?: boolean
|
|
155
156
|
content?: string
|
|
156
157
|
id?: string
|
|
157
158
|
}
|
|
@@ -215,6 +216,7 @@ export declare interface PageMeta {
|
|
|
215
216
|
title?: string
|
|
216
217
|
description?: string
|
|
217
218
|
status?: number
|
|
219
|
+
cache?: boolean
|
|
218
220
|
layout?: LayoutName | false
|
|
219
221
|
middleware?: string | string[]
|
|
220
222
|
transition?: string | { name: string; mode?: string }
|
package/dist/head.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { replaceDirectiveCalls, reportDirectiveFailure, splitTopLevelArgs } from "./directive-arguments.js";
|
|
2
|
-
import { inlineScriptContent } from "./document-shell.js";
|
|
2
|
+
import { headScriptAttributes, inlineScriptContent } from "./document-shell.js";
|
|
3
3
|
import { ErrorCodes } from "./error-handling.js";
|
|
4
4
|
import { resolveMetaArguments } from "./meta-arguments.js";
|
|
5
5
|
import { normalizeHeadKeys, USE_HEAD_KEYS } from "./head-keys.js";
|
|
@@ -162,7 +162,7 @@ export function renderHead(config = currentHead) {
|
|
|
162
162
|
parts.push(`<link ${attrs}>`);
|
|
163
163
|
}
|
|
164
164
|
for (const script of config.script || []) {
|
|
165
|
-
const { content,
|
|
165
|
+
const { content } = script, attrs = headScriptAttributes({ ...script }), attrStr = Object.entries(attrs).filter(([_, v]) => v !== void 0).map(([k, v]) => {
|
|
166
166
|
if (typeof v === "boolean")
|
|
167
167
|
return v ? k : "";
|
|
168
168
|
return `${k}="${escapeHtml(String(v))}"`;
|
|
@@ -79,4 +79,6 @@ export type TranslationDiagnosticKind = | 'unmapped-tag'
|
|
|
79
79
|
| 'stray-end-tag'
|
|
80
80
|
/** A theme declaration cannot be evaluated faithfully on the native target. */
|
|
81
81
|
| 'unsupported-theme-rule'
|
|
82
|
-
| 'unsupported-style-rule'
|
|
82
|
+
| 'unsupported-style-rule'
|
|
83
|
+
/** A vertical ScrollView held a list that fills its space, so it was compiled as a View and the list scrolls instead. */
|
|
84
|
+
| 'list-owns-scrolling';
|
|
@@ -17,6 +17,7 @@ export const NATIVE_EVENTS = new Set([
|
|
|
17
17
|
"onChange",
|
|
18
18
|
"onChangeText",
|
|
19
19
|
"onDismiss",
|
|
20
|
+
"onDismissComplete",
|
|
20
21
|
"onEnd",
|
|
21
22
|
"onEndEditing",
|
|
22
23
|
"onEndReached",
|
|
@@ -524,6 +525,7 @@ export async function translateHtmlToIR(html, options = {}) {
|
|
|
524
525
|
};
|
|
525
526
|
nameControlsFromLabels(root);
|
|
526
527
|
project(root);
|
|
528
|
+
yieldScrollingToLists(root, diagnostics);
|
|
527
529
|
boundScrollingViewports(root);
|
|
528
530
|
return { root, diagnostics };
|
|
529
531
|
}
|
|
@@ -551,6 +553,35 @@ function nameControlsFromLabels(root) {
|
|
|
551
553
|
label.props["aria-hidden"] = "true";
|
|
552
554
|
}
|
|
553
555
|
}
|
|
556
|
+
function yieldScrollingToLists(node, diagnostics) {
|
|
557
|
+
for (const child of node.children)
|
|
558
|
+
if (typeof child !== "string")
|
|
559
|
+
yieldScrollingToLists(child, diagnostics);
|
|
560
|
+
if (node.type !== "ScrollView" || node.props.horizontal)
|
|
561
|
+
return;
|
|
562
|
+
for (const child of node.children) {
|
|
563
|
+
const list = typeof child === "string" ? null : flexibleVerticalList(child);
|
|
564
|
+
if (!list)
|
|
565
|
+
continue;
|
|
566
|
+
node.type = "View";
|
|
567
|
+
diagnostics.push({ kind: "list-owns-scrolling", tag: "ScrollView", name: list });
|
|
568
|
+
return;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
function flexibleVerticalList(node) {
|
|
572
|
+
if (node.type === "FlatList" || node.type === "SectionList")
|
|
573
|
+
return !(Boolean(node.props.horizontal) || /(?:^|\s)overflow-x-(?:auto|scroll)(?:\s|$)/.test(node._classes ?? "")) && (Number(node.style.flex) > 0 || Number(node.style.flexGrow) > 0) ? node.type : null;
|
|
574
|
+
if (!["View", "SafeAreaView", "KeyboardAvoidingView"].includes(node.type))
|
|
575
|
+
return null;
|
|
576
|
+
if (node.style.height !== void 0 || node.style.maxHeight !== void 0)
|
|
577
|
+
return null;
|
|
578
|
+
for (const child of node.children) {
|
|
579
|
+
const list = typeof child === "string" ? null : flexibleVerticalList(child);
|
|
580
|
+
if (list)
|
|
581
|
+
return list;
|
|
582
|
+
}
|
|
583
|
+
return null;
|
|
584
|
+
}
|
|
554
585
|
function boundScrollingViewports(node, inRow = !1) {
|
|
555
586
|
if (["ScrollView", "FlatList", "SectionList"].includes(node.type))
|
|
556
587
|
return !node.props.horizontal && (Number(node.style.flex) > 0 || Number(node.style.flexGrow) > 0);
|
|
@@ -402,6 +402,7 @@ export declare interface ModalProps extends BaseProps {
|
|
|
402
402
|
onRequestClose?: () => void
|
|
403
403
|
onShow?: () => void
|
|
404
404
|
onDismiss?: () => void
|
|
405
|
+
onDismissComplete?: () => void
|
|
405
406
|
}
|
|
406
407
|
export declare interface ActivityIndicatorProps extends BaseProps {
|
|
407
408
|
animating?: boolean
|
|
@@ -48,6 +48,8 @@ export const NATIVE_EVENT_NAMES = {
|
|
|
48
48
|
requestclose: "onRequestClose",
|
|
49
49
|
show: "onShow",
|
|
50
50
|
dismiss: "onDismiss",
|
|
51
|
+
"dismiss-complete": "onDismissComplete",
|
|
52
|
+
dismisscomplete: "onDismissComplete",
|
|
51
53
|
"sliding-complete": "onSlidingComplete",
|
|
52
54
|
slidingcomplete: "onSlidingComplete",
|
|
53
55
|
"load-start": "onLoadStart",
|
|
@@ -232,7 +232,20 @@ export class BrowserScreenRenderer {
|
|
|
232
232
|
this.fire(record, "onRequestClose");
|
|
233
233
|
}
|
|
234
234
|
});
|
|
235
|
-
|
|
235
|
+
if (record.type === "Modal")
|
|
236
|
+
listen("close", () => {
|
|
237
|
+
const presentation = record.modalPresentation;
|
|
238
|
+
this.fire(record, "onDismiss");
|
|
239
|
+
if (!presentation)
|
|
240
|
+
return;
|
|
241
|
+
const dialog = element;
|
|
242
|
+
queueMicrotask(() => {
|
|
243
|
+
if (!dialog.isConnected || dialog.open || record.modalPresentation !== presentation)
|
|
244
|
+
return;
|
|
245
|
+
record.modalPresentation = void 0;
|
|
246
|
+
this.fire(record, "onDismissComplete");
|
|
247
|
+
});
|
|
248
|
+
});
|
|
236
249
|
listen("scroll", () => this.fire(record, "onScroll", { contentOffset: { x: element.scrollLeft, y: element.scrollTop }, layoutMeasurement: { width: element.clientWidth, height: element.clientHeight }, contentSize: { width: element.scrollWidth, height: element.scrollHeight } }));
|
|
237
250
|
const videoEvents = { play: "onPlay", pause: "onPause", ended: "onEnd", timeupdate: "onProgress", loadedmetadata: "onLoad", loadstart: "onLoadStart", loadeddata: "onLoadEnd", error: "onError", enterpictureinpicture: "onPictureInPictureStart", leavepictureinpicture: "onPictureInPictureStop" };
|
|
238
251
|
if (record.type === "Video")
|
|
@@ -516,17 +529,21 @@ export class BrowserScreenRenderer {
|
|
|
516
529
|
if (dialog.open)
|
|
517
530
|
dialog.close();
|
|
518
531
|
css.display = "none";
|
|
519
|
-
} else
|
|
532
|
+
} else {
|
|
533
|
+
if (!dialog.open)
|
|
534
|
+
record.modalPresentation = void 0;
|
|
520
535
|
queueMicrotask(() => {
|
|
521
536
|
if (!dialog.isConnected || !record.props.visible)
|
|
522
537
|
return;
|
|
523
538
|
css.display = "flex";
|
|
524
539
|
css.flexDirection = "column";
|
|
525
|
-
if (
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
540
|
+
if (dialog.open)
|
|
541
|
+
return;
|
|
542
|
+
record.modalPresentation = {};
|
|
543
|
+
dialog.showModal();
|
|
544
|
+
this.fire(record, "onShow");
|
|
529
545
|
});
|
|
546
|
+
}
|
|
530
547
|
}
|
|
531
548
|
if (type === "ActivityIndicator" || type === "RefreshControl") {
|
|
532
549
|
element.setAttribute("aria-label", String(props.accessibilityLabel ?? "Loading"));
|
package/dist/native/testing.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ export declare interface NativeScreenOptions {
|
|
|
44
44
|
snapshots?: Record<string, unknown>
|
|
45
45
|
snapshotWrite?: (name: string, value: unknown) => Promise<unknown>
|
|
46
46
|
dialog?: { actionSheet?: (options: any) => Promise<string>, confirm?: (options: any) => Promise<boolean> }
|
|
47
|
+
modalDismissDelayMs?: number
|
|
47
48
|
colorScheme?: 'light' | 'dark'
|
|
48
49
|
viewportWidth?: number
|
|
49
50
|
params?: Record<string, unknown>
|
package/dist/native/testing.js
CHANGED
|
@@ -145,6 +145,29 @@ export function mountNativeScreen(code, screen, options = {}) {
|
|
|
145
145
|
for (const child of node.children || [])
|
|
146
146
|
if (typeof child !== "string")
|
|
147
147
|
visit(child);
|
|
148
|
+
}, modalCompletions = new Map, modalVisible = (node) => typeof node.props.visible === "boolean" ? node.props.visible : Boolean(node.style.display && node.style.display !== "none"), cancelModalCompletion = (id) => {
|
|
149
|
+
const pending = modalCompletions.get(id);
|
|
150
|
+
if (pending?.timer !== void 0)
|
|
151
|
+
timers.clearTimeout(pending.timer);
|
|
152
|
+
modalCompletions.delete(id);
|
|
153
|
+
}, finishModalDismissal = (node) => {
|
|
154
|
+
cancelModalCompletion(node.id);
|
|
155
|
+
const pending = {};
|
|
156
|
+
modalCompletions.set(node.id, pending);
|
|
157
|
+
const deliver = () => {
|
|
158
|
+
if (ended || modalCompletions.get(node.id) !== pending)
|
|
159
|
+
return;
|
|
160
|
+
modalCompletions.delete(node.id);
|
|
161
|
+
if (nodes.get(node.id) !== node || modalVisible(node))
|
|
162
|
+
return;
|
|
163
|
+
const handlerId = node.events.onDismissComplete;
|
|
164
|
+
if (handlerId)
|
|
165
|
+
receive(JSON.stringify({ type: "EVENT", payload: { handlerId, nativeEvent: {} } }));
|
|
166
|
+
}, delay = options.modalDismissDelayMs ?? 0;
|
|
167
|
+
if (delay > 0)
|
|
168
|
+
pending.timer = timers.setTimeout(deliver, delay);
|
|
169
|
+
else
|
|
170
|
+
queueMicrotask(deliver);
|
|
148
171
|
}, openStream = (at, signal) => {
|
|
149
172
|
const queue = [], waiting = [], encode = (text) => new TextEncoder().encode(text), stop = () => {
|
|
150
173
|
stream.open = !1;
|
|
@@ -337,6 +360,8 @@ export function mountNativeScreen(code, screen, options = {}) {
|
|
|
337
360
|
const drop = (node) => {
|
|
338
361
|
if (!node)
|
|
339
362
|
return;
|
|
363
|
+
if (node.type === "Modal")
|
|
364
|
+
cancelModalCompletion(node.id);
|
|
340
365
|
nodes.delete(node.id);
|
|
341
366
|
for (const child of node.children || [])
|
|
342
367
|
if (typeof child !== "string")
|
|
@@ -358,11 +383,18 @@ export function mountNativeScreen(code, screen, options = {}) {
|
|
|
358
383
|
}
|
|
359
384
|
const node = nodes.get(operation.id);
|
|
360
385
|
if (node && operation.patch) {
|
|
386
|
+
const wasModalVisible = node.type === "Modal" && modalVisible(node);
|
|
361
387
|
node.style = { ...node.style, ...operation.patch.style };
|
|
362
388
|
node.props = { ...node.props, ...operation.patch.props };
|
|
363
389
|
node.events = { ...node.events, ...operation.patch.events };
|
|
364
390
|
if (operation.patch.children)
|
|
365
391
|
node.children = operation.patch.children;
|
|
392
|
+
if (node.type === "Modal") {
|
|
393
|
+
if (modalVisible(node))
|
|
394
|
+
cancelModalCompletion(node.id);
|
|
395
|
+
else if (wasModalVisible && node.events.onDismissComplete)
|
|
396
|
+
finishModalDismissal(node);
|
|
397
|
+
}
|
|
366
398
|
}
|
|
367
399
|
}
|
|
368
400
|
if (message.type === "NAVIGATE_OPEN")
|
|
@@ -440,6 +472,7 @@ export function mountNativeScreen(code, screen, options = {}) {
|
|
|
440
472
|
timeouts.clear();
|
|
441
473
|
immediateTimeouts.clear();
|
|
442
474
|
intervals.clear();
|
|
475
|
+
modalCompletions.clear();
|
|
443
476
|
streams.forEach((stream) => stream.end());
|
|
444
477
|
}
|
|
445
478
|
};
|
package/dist/page-head.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { escapeAttr } from "./builtins/escape.js";
|
|
2
|
+
import { tagAttributes } from "./document-tags.js";
|
|
2
3
|
import { scanAtElementPosition } from "./html-masking.js";
|
|
3
4
|
import { decodeTitleEntities } from "./spa-nav.js";
|
|
4
5
|
function quoteValue(value) {
|
|
@@ -11,15 +12,6 @@ function headTags(html) {
|
|
|
11
12
|
return tag.exec(source) ? tag.lastIndex : -1;
|
|
12
13
|
}).map(({ token }) => token);
|
|
13
14
|
}
|
|
14
|
-
function tagAttributes(token) {
|
|
15
|
-
const attrs = Object.create(null), attributes = token.replace(/^<\w+\b|>$/g, "");
|
|
16
|
-
for (const match of attributes.matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g)) {
|
|
17
|
-
const name = match[1].toLowerCase();
|
|
18
|
-
if (!(name in attrs))
|
|
19
|
-
attrs[name] = match[2] ?? match[3] ?? match[4] ?? "";
|
|
20
|
-
}
|
|
21
|
-
return attrs;
|
|
22
|
-
}
|
|
23
15
|
export function pageHeadFragment(html) {
|
|
24
16
|
const metadata = [];
|
|
25
17
|
for (const token of headTags(html)) {
|
package/dist/process.js
CHANGED
|
@@ -482,7 +482,7 @@ ${tag}`).join(""));
|
|
|
482
482
|
if (isTopLevel)
|
|
483
483
|
result = normalizeCriticalHeadOrder(result);
|
|
484
484
|
if (isTopLevel && context.__stx_inject_css !== !1)
|
|
485
|
-
result = await injectCss(result, void 0, options.buildMode === "serve", !0);
|
|
485
|
+
result = await injectCss(result, void 0, options.buildMode === "serve", !0, options.inlineGeneratedCssBytes);
|
|
486
486
|
else if (isTopLevel)
|
|
487
487
|
result = dedupeScopedStyles(result);
|
|
488
488
|
if (isTopLevel)
|
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{Eo,sn,iu,pm}from"./chunk-0xyfs691.js";import{Co,la,lm,um,dm}from"./chunk-40j2pmnb.js";import{ru,su,ou,am,cm}from"./chunk-9707zz6v.js";import{ot,Xn,ua}from"./chunk-3kpxkjgm.js";import{fm,gm,mm,hm,To,eb}from"./chunk-7axtwg1f.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-yegp50jb.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=ot(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=Eo(n,t);if(a){let s=sn(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 la(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,su as auditBuildOutput,ru as auditConfig,re as buildPwaAssets,ou as calculateAuditResult,cm as formatAuditResult,ua as formatSize,j as generateManifest,_ as generateManifestJson,um as generateManifestLink,F as generateOfflinePage,ot as generatePrecacheManifest,Xn as generatePrecacheManifestJs,M as generatePwaIcons,Co as generatePwaTags,Eo as generateServiceWorker,pm as generateServiceWorkerAuto,lm as generateSwRegistrationScript,dm as generateThemeColorMeta,N as getExpectedIconPaths,sn as getServiceWorkerFileName,la as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,iu as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,To as pwaDirectives,fm as pwaInstallDirective,mm as pwaOfflineDirective,hm as pwaPushDirective,gm as pwaUpdateDirective,eb as registerPwaDirectives,am as runPwaAudit,D as validateManifest};
|