@stacksjs/stx 0.2.846 → 0.2.849
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.d.ts +2 -1
- package/dist/app-shell.js +3 -3
- package/dist/{chunk-cpdfxy8g.js → chunk-056rsqc6.js} +12 -12
- package/dist/{chunk-wzpd3htt.js → chunk-09412heg.js} +7 -7
- package/dist/chunk-0d4zhbjz.js +2 -0
- package/dist/{chunk-ng8nkbp2.js → chunk-0ey7kc6t.js} +2 -2
- package/dist/chunk-0g05v7m1.js +2 -0
- package/dist/{chunk-z26fg4p0.js → chunk-0wms5teg.js} +2 -2
- package/dist/{chunk-nsc93haq.js → chunk-0zgxxhvs.js} +6 -6
- package/dist/chunk-11snc6n0.js +2 -0
- package/dist/{chunk-82vf29ty.js → chunk-12r22pf0.js} +2 -2
- package/dist/{chunk-j1n2xb48.js → chunk-14cvwsy1.js} +2 -2
- package/dist/{chunk-0e4y6h1h.js → chunk-1k12cc65.js} +14 -14
- package/dist/chunk-1menbxwb.js +2 -0
- package/dist/chunk-1p968nww.js +2 -0
- package/dist/chunk-1pf4y2yr.js +2 -0
- package/dist/{chunk-6pgq75h9.js → chunk-25m74mh1.js} +5 -5
- package/dist/{chunk-xq9w5g23.js → chunk-2j3gttzf.js} +1 -1
- package/dist/chunk-2sxmmjt1.js +2 -0
- package/dist/{chunk-h76wsqr4.js → chunk-2ts9pb6s.js} +2 -2
- package/dist/{chunk-caw0wzns.js → chunk-2xf323h9.js} +3 -3
- package/dist/chunk-34afrhts.js +2 -0
- package/dist/chunk-37bzsnr7.js +2 -0
- package/dist/chunk-3m5v3ynh.js +4 -0
- package/dist/chunk-3m6n90sk.js +2 -0
- package/dist/{chunk-zx2xwrp3.js → chunk-3qyz80d6.js} +6 -6
- package/dist/{chunk-an6vb4ng.js → chunk-46t924aw.js} +2 -2
- package/dist/{chunk-9hfk5wf1.js → chunk-4fc8zs15.js} +5 -5
- package/dist/chunk-4q4mtrc5.js +2 -0
- package/dist/{chunk-xskygt2v.js → chunk-54p27ney.js} +5 -5
- package/dist/chunk-5bm8hmwd.js +2 -0
- package/dist/chunk-5r2z29n8.js +2 -0
- package/dist/{chunk-wbx27kdd.js → chunk-5wr1qqz3.js} +2 -2
- package/dist/{chunk-wvsnp294.js → chunk-63sqdcr6.js} +9 -9
- package/dist/chunk-660preb9.js +2 -0
- package/dist/chunk-6hd83cj4.js +2 -0
- package/dist/{chunk-gs33xdk7.js → chunk-6xcmeev9.js} +5 -5
- package/dist/chunk-740njbwc.js +2 -0
- package/dist/chunk-77fs8281.js +2 -0
- package/dist/chunk-7c73t536.js +2 -0
- package/dist/chunk-7ycmnsh5.js +2 -0
- package/dist/{chunk-r3v1zaj0.js → chunk-81ysx0tc.js} +2 -2
- package/dist/{chunk-hp8ny2zb.js → chunk-83dxfhkw.js} +5 -5
- package/dist/chunk-84gg2atb.js +2 -0
- package/dist/chunk-86z8zrn9.js +3 -0
- package/dist/{chunk-5903tzcw.js → chunk-88a7qaw8.js} +3 -3
- package/dist/{chunk-1qp5808r.js → chunk-8bxws458.js} +3 -3
- package/dist/{chunk-j3zy3mrn.js → chunk-8vkywnpx.js} +9 -9
- package/dist/{chunk-zkn55966.js → chunk-90mm5bf8.js} +6 -6
- package/dist/{chunk-8az9e5b9.js → chunk-93c08def.js} +5 -5
- package/dist/chunk-9c6yvh3p.js +2 -0
- package/dist/chunk-9f0pv6sz.js +2 -0
- package/dist/chunk-9fxeqf0e.js +2 -0
- package/dist/{chunk-4041q9sd.js → chunk-9mbyhepc.js} +5 -5
- package/dist/{chunk-vxayh4az.js → chunk-9qxx2teq.js} +6 -6
- package/dist/{chunk-p8ry1q7c.js → chunk-9sjtph54.js} +3 -3
- package/dist/chunk-atsjexk0.js +2 -0
- package/dist/{chunk-x3pxxx7j.js → chunk-b147ejha.js} +3 -3
- package/dist/{chunk-1w5hte9z.js → chunk-b3n1m4m5.js} +2 -2
- package/dist/chunk-bcefawtc.js +2 -0
- package/dist/chunk-bkqqa8aw.js +2 -0
- package/dist/chunk-bmds786f.js +2 -0
- package/dist/{chunk-ph57nv7v.js → chunk-bsw6hd14.js} +2 -2
- package/dist/{chunk-s2a51j0k.js → chunk-bttvkzxh.js} +6 -6
- package/dist/chunk-c0azgkss.js +2 -0
- package/dist/{chunk-v8y01jbr.js → chunk-c541s99z.js} +4 -4
- package/dist/{chunk-50tnhq5f.js → chunk-c7qej674.js} +30 -30
- package/dist/chunk-cbz7jtzf.js +2 -0
- package/dist/{chunk-bsr6kf34.js → chunk-ct54e34a.js} +1 -1
- package/dist/{chunk-84myqca7.js → chunk-cww1zk8y.js} +2 -2
- package/dist/{chunk-d1pat213.js → chunk-dv9q56r7.js} +2 -2
- package/dist/chunk-e1n286mv.js +2 -0
- package/dist/{chunk-t3e95q80.js → chunk-eg2p1cyw.js} +14 -14
- package/dist/{chunk-7rcc2tzz.js → chunk-emf6ee94.js} +3 -3
- package/dist/chunk-evdskc25.js +2 -0
- package/dist/chunk-f18rxz70.js +2 -0
- package/dist/{chunk-wd632rge.js → chunk-f2zgh4xr.js} +7 -7
- package/dist/chunk-f8akfzzn.js +2 -0
- package/dist/chunk-f8wmxwa3.js +2 -0
- package/dist/{chunk-neh3kewg.js → chunk-fa3ygt8c.js} +4 -4
- package/dist/{chunk-n475s55q.js → chunk-fez9828r.js} +2 -2
- package/dist/chunk-fseqwysr.js +2 -0
- package/dist/{chunk-ds1vj0dw.js → chunk-fx8jjasv.js} +4 -4
- package/dist/{chunk-x1n01gc1.js → chunk-ga650crj.js} +5 -5
- package/dist/{chunk-rg2gfyy0.js → chunk-gpkxphqz.js} +2 -2
- package/dist/chunk-h8zb6cek.js +2 -0
- package/dist/chunk-hc4ydhw0.js +2 -0
- package/dist/{chunk-30g5kqy0.js → chunk-he9dzchk.js} +1 -1
- package/dist/{chunk-4y6hes3h.js → chunk-hpwtjb4a.js} +2 -2
- package/dist/chunk-j08r18x1.js +2 -0
- package/dist/chunk-j539dz72.js +2 -0
- package/dist/{chunk-s6qzmwp3.js → chunk-jaf44web.js} +1 -1
- package/dist/{chunk-vyggv4k0.js → chunk-jcwtw3hd.js} +2 -2
- package/dist/{chunk-81nmqdht.js → chunk-jh36gqcq.js} +2 -2
- package/dist/{chunk-m8cpabd2.js → chunk-jm0qsr3s.js} +3 -3
- package/dist/{chunk-4v6mbvqv.js → chunk-jmshgw0t.js} +5 -5
- package/dist/chunk-jqngvqby.js +2 -0
- package/dist/{chunk-vh8wn94m.js → chunk-jtccqpwa.js} +2 -2
- package/dist/chunk-k33kgf8a.js +2 -0
- package/dist/{chunk-7qwfbafg.js → chunk-k44qj40k.js} +2 -2
- package/dist/{chunk-444sbdm8.js → chunk-k7e3e149.js} +36 -36
- package/dist/chunk-ke76eaat.js +33 -0
- package/dist/chunk-kz7ha54c.js +2 -0
- package/dist/chunk-m7cbkrz6.js +2 -0
- package/dist/{chunk-qttjrja7.js → chunk-ma9yq04p.js} +2 -2
- package/dist/chunk-md8dj6tb.js +2 -0
- package/dist/{chunk-krdfnsz6.js → chunk-mnncq81c.js} +5 -5
- package/dist/chunk-na1v2jcy.js +2 -0
- package/dist/{chunk-jf0a5ew8.js → chunk-na1x46xm.js} +3 -3
- package/dist/{chunk-sxsjxme0.js → chunk-nws4zm4k.js} +4 -4
- package/dist/chunk-p2fkggw4.js +3 -0
- package/dist/chunk-pqqyjvq9.js +2 -0
- package/dist/chunk-q18508s2.js +2 -0
- package/dist/chunk-qay7pgnq.js +2 -0
- package/dist/chunk-qczgdzjk.js +2 -0
- package/dist/{chunk-rgy9c7d8.js → chunk-qpz9jrvw.js} +3 -3
- package/dist/chunk-r40g6785.js +2 -0
- package/dist/chunk-r6085mp4.js +2 -0
- package/dist/{chunk-prrf0j54.js → chunk-r96ahk8s.js} +5 -5
- package/dist/chunk-rke4q3jk.js +2 -0
- package/dist/{chunk-mzyx6y1a.js → chunk-rqjskxpw.js} +32 -32
- package/dist/chunk-rrnvbwac.js +2 -0
- package/dist/{chunk-c78dsx3f.js → chunk-rtsshvpt.js} +10 -10
- package/dist/{chunk-66e0d2t7.js → chunk-rwc322gq.js} +2 -2
- package/dist/{chunk-r1984y6y.js → chunk-shnw9geh.js} +4 -4
- package/dist/{chunk-dspmqeg0.js → chunk-t4dkcf28.js} +114 -25
- package/dist/{chunk-2a792g5e.js → chunk-t5q31st4.js} +2 -2
- package/dist/{chunk-4jmkvzns.js → chunk-tb5h85ag.js} +2 -2
- package/dist/{chunk-098mrr5f.js → chunk-tbcvarvy.js} +2 -2
- package/dist/chunk-te1wksa0.js +2 -0
- package/dist/{chunk-6x6xthsv.js → chunk-tj533808.js} +2 -2
- package/dist/{chunk-jx14j83s.js → chunk-tm5t3hh3.js} +3 -3
- package/dist/{chunk-serwcna2.js → chunk-trgbdydw.js} +2 -2
- package/dist/chunk-v11hvvxc.js +2 -0
- package/dist/{chunk-fnfq6fkk.js → chunk-v929r67j.js} +1 -1
- package/dist/chunk-vasvns9e.js +2 -0
- package/dist/chunk-vdb3p2v3.js +2 -0
- package/dist/chunk-vm2y05sr.js +2 -0
- package/dist/{chunk-zyt8k9n0.js → chunk-wdwx2aa6.js} +2 -2
- package/dist/{chunk-6g7wrn48.js → chunk-wp14sf2j.js} +2 -2
- package/dist/{chunk-xhytkzg7.js → chunk-wzyc9da7.js} +2 -2
- package/dist/chunk-x2wn6mpd.js +2 -0
- package/dist/chunk-x45mp78q.js +2 -0
- package/dist/chunk-xa2qfe51.js +3 -0
- package/dist/{chunk-zjqvbcwa.js → chunk-xppm4cs4.js} +2 -2
- package/dist/{chunk-tzqnf28n.js → chunk-xr9rf0e6.js} +3 -3
- package/dist/chunk-xsmyhp5f.js +2 -0
- package/dist/{chunk-xj5j18nf.js → chunk-y1cneng3.js} +2 -2
- package/dist/{chunk-rn7710jg.js → chunk-y6wbbmp3.js} +3 -3
- package/dist/{chunk-evww725k.js → chunk-ynnd6nnt.js} +63 -63
- package/dist/{chunk-d4jhyxp6.js → chunk-yqjmqndq.js} +6 -6
- package/dist/{chunk-hff8z61n.js → chunk-yrmppd8r.js} +1 -1
- package/dist/{chunk-9d9sartn.js → chunk-z57xq46m.js} +1 -1
- package/dist/chunk-zecffe6a.js +2 -0
- package/dist/{chunk-ea5w92vs.js → chunk-zfb2wnha.js} +3 -3
- package/dist/cli.js +20 -20
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/native/floating-actions.d.ts +43 -0
- package/dist/native/floating-actions.js +50 -0
- package/dist/native/index.d.ts +1 -0
- package/dist/native/index.js +1 -0
- package/dist/native/primitives/FloatingActions.stx +42 -0
- package/dist/native/runtime/browser-screen.js +3 -8
- package/dist/page-head.d.ts +15 -0
- package/dist/page-head.js +35 -10
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +6 -6
- package/dist/template-compiler.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-07hvjvj1.js +0 -2
- package/dist/chunk-13sp1247.js +0 -2
- package/dist/chunk-1kdtapc1.js +0 -2
- package/dist/chunk-263gby2p.js +0 -2
- package/dist/chunk-33ggd5at.js +0 -2
- package/dist/chunk-3q19w77r.js +0 -2
- package/dist/chunk-40x0vwza.js +0 -2
- package/dist/chunk-4cmda04d.js +0 -2
- package/dist/chunk-5xt4tjpm.js +0 -2
- package/dist/chunk-6289h3tr.js +0 -2
- package/dist/chunk-6q7ke5p0.js +0 -2
- package/dist/chunk-6ya0860g.js +0 -2
- package/dist/chunk-8k7rfy77.js +0 -3
- package/dist/chunk-9enwmg0z.js +0 -2
- package/dist/chunk-a7z6j9ga.js +0 -2
- package/dist/chunk-ab6dw6f4.js +0 -2
- package/dist/chunk-adnntqk3.js +0 -2
- package/dist/chunk-bhzbcmm7.js +0 -2
- package/dist/chunk-cfez1qbm.js +0 -2
- package/dist/chunk-cgyddqxw.js +0 -2
- package/dist/chunk-cng4fhpt.js +0 -2
- package/dist/chunk-ctq1qy1g.js +0 -2
- package/dist/chunk-cyghcps7.js +0 -2
- package/dist/chunk-e26aqarz.js +0 -2
- package/dist/chunk-e7816ep3.js +0 -2
- package/dist/chunk-en8hnq2q.js +0 -2
- package/dist/chunk-enz6fsdx.js +0 -2
- package/dist/chunk-eydqn4gz.js +0 -2
- package/dist/chunk-fk7gs41v.js +0 -2
- package/dist/chunk-fx04tq90.js +0 -2
- package/dist/chunk-fzba0b0n.js +0 -2
- package/dist/chunk-g7tj2tnz.js +0 -2
- package/dist/chunk-ga0293gz.js +0 -2
- package/dist/chunk-gab3h25h.js +0 -2
- package/dist/chunk-hczqyk7c.js +0 -2
- package/dist/chunk-hs6fg0k9.js +0 -2
- package/dist/chunk-hsg4ggt0.js +0 -2
- package/dist/chunk-k3pfadjb.js +0 -2
- package/dist/chunk-kmnre1tq.js +0 -2
- package/dist/chunk-mgtp037k.js +0 -3
- package/dist/chunk-mp42d9v5.js +0 -2
- package/dist/chunk-mtmgrccj.js +0 -2
- package/dist/chunk-n20tsy6a.js +0 -2
- package/dist/chunk-nhn69eva.js +0 -4
- package/dist/chunk-pdt1phnh.js +0 -2
- package/dist/chunk-q87wwwra.js +0 -2
- package/dist/chunk-r1mvd96m.js +0 -2
- package/dist/chunk-rrj3gv46.js +0 -3
- package/dist/chunk-s321pb85.js +0 -2
- package/dist/chunk-st75663x.js +0 -2
- package/dist/chunk-stss2b88.js +0 -2
- package/dist/chunk-svxkcdhh.js +0 -2
- package/dist/chunk-t6gm8z7x.js +0 -2
- package/dist/chunk-tkssavxx.js +0 -2
- package/dist/chunk-tw6y23ew.js +0 -2
- package/dist/chunk-vm34qp5k.js +0 -2
- package/dist/chunk-vtg2tqzt.js +0 -2
- package/dist/chunk-wddaxpep.js +0 -2
- package/dist/chunk-x6bt567m.js +0 -2
- package/dist/chunk-xdzs2mxv.js +0 -32
- package/dist/chunk-xf4d9gam.js +0 -2
- package/dist/chunk-xf5db38j.js +0 -2
- package/dist/chunk-y5t7ec69.js +0 -2
- package/dist/chunk-yk90sqqv.js +0 -2
- package/dist/chunk-z231es22.js +0 -2
- package/dist/chunk-zphekzv8.js +0 -2
- package/dist/chunk-zsft5466.js +0 -2
package/dist/craft.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
2
|
+
import"./chunk-ynnd6nnt.js";import{Eo,Ca,Ea}from"./chunk-2xf323h9.js";import"./chunk-rqjskxpw.js";import"./chunk-eg2p1cyw.js";import"./chunk-0wms5teg.js";import"./chunk-xppm4cs4.js";import"./chunk-46t924aw.js";import"./chunk-gpkxphqz.js";import"./chunk-jtccqpwa.js";import"./chunk-t4dkcf28.js";import"./chunk-rtsshvpt.js";import"./chunk-09412heg.js";import"./chunk-nws4zm4k.js";import"./chunk-0ey7kc6t.js";import"./chunk-8vkywnpx.js";import"./chunk-c7qej674.js";import"./chunk-shnw9geh.js";import"./chunk-f2zgh4xr.js";import"./chunk-63sqdcr6.js";import"./chunk-88a7qaw8.js";import"./chunk-t5q31st4.js";import"./chunk-fez9828r.js";import{wu,Ta,Ch,Eh,$a,To,ns,Ra,Aa,Th,$h,Pa,Ia,Oa,Na}from"./chunk-1k12cc65.js";import"./chunk-jmshgw0t.js";import"./chunk-xa2qfe51.js";import"./chunk-cww1zk8y.js";import"./chunk-0zgxxhvs.js";import"./chunk-he9dzchk.js";import"./chunk-xr9rf0e6.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,To as CRAFT_COMPONENTS,Ra as CRAFT_COMPONENT_RUNTIME,ns as CRAFT_COMPONENT_STYLES,Eo as NATIVE_COMPONENTS,Pa as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Ca as compileToNative,Ea as createHotReloadServer,Ia as findCraftBinary,Ta as generateCraftBridgeScript,V as generateCraftOptimizations,Na as getAvailableFormats,Oa as getAvailableTargets,$h as getCraftComponents,G as getSSRCacheStats,$a as injectCraftBridge,Ch as isCraftEnvironment,Y as prerenderForCraft,Aa as processCraftComponents,Eh as processCraftDirective,Th as registerCraftComponent,Q as renderSSR};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { NativeAccessoryMenuItem, NativeTabAccessory } from './runtime/craft';
|
|
2
|
+
/**
|
|
3
|
+
* The floating actions of a screen, or of the whole app, in the order they
|
|
4
|
+
* read: top to bottom in a vertical group, leading to trailing otherwise.
|
|
5
|
+
*
|
|
6
|
+
* It answers with the `tabAccessory` a host draws them from, for
|
|
7
|
+
* `craft.navigation.setChrome` (every screen) and `setOptions` (one screen);
|
|
8
|
+
* no actions answers `null`, which takes the group away.
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* craft.navigation.setChrome({
|
|
12
|
+
* tabAccessory: floatingActions([
|
|
13
|
+
* { path: '/add', label: 'Add', symbol: 'plus', menu: [{ path: '/workouts/new', title: 'Workout', symbol: 'dumbbell' }] },
|
|
14
|
+
* { path: '/messages', label: 'Messages', symbol: 'message.fill', badge: unread },
|
|
15
|
+
* ]),
|
|
16
|
+
* })
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* The host's group has one primary action, the last: it alone shows a badge,
|
|
20
|
+
* and it always opens its path. A badge or a menu anywhere else is a mistake
|
|
21
|
+
* in the list rather than something to draw differently, so it is refused.
|
|
22
|
+
*/
|
|
23
|
+
export declare function floatingActions(actions: ReadonlyArray<NativeFloatingAction | null | undefined | false>, layout?: NativeFloatingActionsLayout): NativeTabAccessory | null;
|
|
24
|
+
/** The most actions one group holds. */
|
|
25
|
+
export declare const MAX_FLOATING_ACTIONS: 3;
|
|
26
|
+
/**
|
|
27
|
+
* One floating action: a round control over the screen that opens a path of
|
|
28
|
+
* the app, or a short menu of them. Named for what it does (`label`), drawn
|
|
29
|
+
* as a symbol.
|
|
30
|
+
*/
|
|
31
|
+
export declare interface NativeFloatingAction {
|
|
32
|
+
path: string
|
|
33
|
+
label: string
|
|
34
|
+
symbol: string
|
|
35
|
+
accessibilityLabel?: string
|
|
36
|
+
badge?: string | number | null
|
|
37
|
+
menu?: NativeAccessoryMenuItem[]
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* `vertical` and `horizontal` join the actions in one capsule of glass, as the
|
|
41
|
+
* map controls in Maps are joined; `separate` keeps a round control each.
|
|
42
|
+
*/
|
|
43
|
+
export type NativeFloatingActionsLayout = 'vertical' | 'horizontal' | 'separate';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export const MAX_FLOATING_ACTIONS = 3;
|
|
2
|
+
function badgeText(badge) {
|
|
3
|
+
if (typeof badge === "number")
|
|
4
|
+
return badge > 99 ? "99+" : badge > 0 ? String(Math.floor(badge)) : null;
|
|
5
|
+
return badge ? String(badge).slice(0, 8) : null;
|
|
6
|
+
}
|
|
7
|
+
export function floatingActions(actions, layout = "vertical") {
|
|
8
|
+
if (!Array.isArray(actions))
|
|
9
|
+
throw TypeError("floatingActions needs a list of actions");
|
|
10
|
+
if (layout !== "vertical" && layout !== "horizontal" && layout !== "separate")
|
|
11
|
+
throw TypeError(`floatingActions: unknown layout "${String(layout)}"`);
|
|
12
|
+
const list = actions.filter(Boolean);
|
|
13
|
+
if (!list.length)
|
|
14
|
+
return null;
|
|
15
|
+
if (list.length > MAX_FLOATING_ACTIONS)
|
|
16
|
+
throw TypeError(`floatingActions holds at most ${MAX_FLOATING_ACTIONS} actions, got ${list.length}`);
|
|
17
|
+
const seen = new Set;
|
|
18
|
+
for (const action of list) {
|
|
19
|
+
if (typeof action.path !== "string" || !action.path.startsWith("/") || action.path.startsWith("//"))
|
|
20
|
+
throw TypeError(`floatingActions: "${String(action.path)}" is not a path of the app`);
|
|
21
|
+
if (!action.label || !action.symbol)
|
|
22
|
+
throw TypeError(`floatingActions: ${action.path} needs a label and a symbol`);
|
|
23
|
+
if (seen.has(action.path))
|
|
24
|
+
throw TypeError(`floatingActions: ${action.path} is listed twice`);
|
|
25
|
+
seen.add(action.path);
|
|
26
|
+
}
|
|
27
|
+
const primary = list[list.length - 1];
|
|
28
|
+
if (primary.menu?.length)
|
|
29
|
+
throw TypeError(`floatingActions: the last action (${primary.path}) opens its path; put the menu on an earlier one`);
|
|
30
|
+
const companions = list.slice(0, -1).map((action) => {
|
|
31
|
+
if (badgeText(action.badge))
|
|
32
|
+
throw TypeError(`floatingActions: only the last action shows a badge, not ${action.path}`);
|
|
33
|
+
return {
|
|
34
|
+
path: action.path,
|
|
35
|
+
title: action.label,
|
|
36
|
+
symbol: action.symbol,
|
|
37
|
+
...action.accessibilityLabel ? { accessibilityLabel: action.accessibilityLabel } : {},
|
|
38
|
+
...action.menu?.length ? { menu: action.menu.map((choice) => ({ ...choice })) } : {}
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
return {
|
|
42
|
+
path: primary.path,
|
|
43
|
+
title: primary.label,
|
|
44
|
+
symbol: primary.symbol,
|
|
45
|
+
...primary.accessibilityLabel ? { accessibilityLabel: primary.accessibilityLabel } : {},
|
|
46
|
+
badge: badgeText(primary.badge),
|
|
47
|
+
...layout === "separate" ? { iconOnly: !0 } : { layout },
|
|
48
|
+
companions
|
|
49
|
+
};
|
|
50
|
+
}
|
package/dist/native/index.d.ts
CHANGED
package/dist/native/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export * from "./compiler/icons.js";
|
|
|
9
9
|
export * from "./cli.js";
|
|
10
10
|
export * from "./runtime/shared-screen.js";
|
|
11
11
|
export * from "./live-activity.js";
|
|
12
|
+
export * from "./floating-actions.js";
|
|
12
13
|
export * from "./bridge/protocol.js";
|
|
13
14
|
export * from "./components/primitives.js";
|
|
14
15
|
export {
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{{--
|
|
2
|
+
FloatingActions: the round controls that float over a screen, above the
|
|
3
|
+
trailing end of the tab bar, joined in one capsule of glass as the map
|
|
4
|
+
controls in Maps are.
|
|
5
|
+
|
|
6
|
+
<FloatingActions :actions="[
|
|
7
|
+
{ path: '/add', label: 'Add', symbol: 'plus', menu: addChoices },
|
|
8
|
+
{ path: '/messages', label: 'Messages', symbol: 'message.fill', badge: unread },
|
|
9
|
+
]" />
|
|
10
|
+
|
|
11
|
+
`layout` is `vertical` (the default), `horizontal`, or `separate` for a
|
|
12
|
+
round control each. The host draws them (Liquid Glass on iOS 26), so this
|
|
13
|
+
takes no room in the screen's own layout; they follow `actions` as it
|
|
14
|
+
changes and leave with the screen. For actions every screen shares, pass
|
|
15
|
+
`floatingActions()` from `@stacksjs/stx/native` to `craft.navigation.setChrome`.
|
|
16
|
+
--}}
|
|
17
|
+
<script client>
|
|
18
|
+
import { floatingActions } from '../floating-actions'
|
|
19
|
+
|
|
20
|
+
const floatingList = useReactiveProp('actions', [])
|
|
21
|
+
const floatingLayout = useReactiveProp('layout', 'vertical')
|
|
22
|
+
// A page drawn by a browser has no host chrome to put them in.
|
|
23
|
+
const floatingHost = typeof craft !== 'undefined' && craft && craft.navigation ? craft.navigation : null
|
|
24
|
+
let floatingSent = ''
|
|
25
|
+
|
|
26
|
+
effect(() => {
|
|
27
|
+
if (!floatingHost) return
|
|
28
|
+
const list = floatingList()
|
|
29
|
+
const accessory = floatingActions(Array.isArray(list) ? list : [], String(floatingLayout() || 'vertical'))
|
|
30
|
+
// The same actions again (a parent re-rendered) are not a change to draw.
|
|
31
|
+
const next = JSON.stringify(accessory)
|
|
32
|
+
// Nor is having none before any were shown: there is nothing to take away.
|
|
33
|
+
if (next === floatingSent || (accessory === null && !floatingSent)) return
|
|
34
|
+
floatingSent = next
|
|
35
|
+
floatingHost.setOptions({ tabAccessory: accessory })
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
onDestroy(() => {
|
|
39
|
+
if (floatingHost && floatingSent && floatingSent !== 'null') floatingHost.setOptions({ tabAccessory: null })
|
|
40
|
+
})
|
|
41
|
+
</script>
|
|
42
|
+
<div data-native="View" class="hidden" aria-hidden="true" data-floating-actions></div>
|
|
@@ -138,7 +138,7 @@ export function createBrowserScreenBridge(platform, options) {
|
|
|
138
138
|
actionContainer.setAttribute("data-tab-accessory-group", primary.layout);
|
|
139
139
|
actionContainer.setAttribute("role", "group");
|
|
140
140
|
actionContainer.setAttribute("aria-label", primary.accessibilityLabel || primary.title);
|
|
141
|
-
actionContainer.style.cssText = `position:absolute;z-index:2;inset-inline-end:
|
|
141
|
+
actionContainer.style.cssText = `position:absolute;z-index:2;inset-inline-end:22px;bottom:calc(100% + 10px);display:flex;flex-direction:${primary.layout === "vertical" ? "column" : "row"};border-radius:24px;background:color-mix(in srgb,currentColor 8%,transparent);backdrop-filter:blur(20px) saturate(180%);-webkit-backdrop-filter:blur(20px) saturate(180%);box-shadow:inset 0 0 0 .5px color-mix(in srgb,currentColor 18%,transparent),0 4px 16px #0002`;
|
|
142
142
|
tabs.append(actionContainer);
|
|
143
143
|
}
|
|
144
144
|
const actions = primary ? [...(primary.companions || []).slice(0, 2), primary] : [];
|
|
@@ -151,13 +151,8 @@ export function createBrowserScreenBridge(platform, options) {
|
|
|
151
151
|
button.setAttribute("aria-label", `${item.accessibilityLabel || item.title}${item.badge ? `, ${item.badge}` : ""}`);
|
|
152
152
|
button.style.cssText = "position:relative;display:flex;align-items:center;justify-content:center;width:56px;height:56px;flex-shrink:0;border:0;border-radius:50%;background:#8882;color:inherit";
|
|
153
153
|
if (grouped) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const separator = document.createElement("span");
|
|
157
|
-
separator.setAttribute("aria-hidden", "true");
|
|
158
|
-
separator.style.cssText = primary?.layout === "vertical" ? "height:1px;margin:0 12px;background:#8885" : "width:1px;margin:12px 0;background:#8885";
|
|
159
|
-
actionContainer.append(separator);
|
|
160
|
-
}
|
|
154
|
+
const vertical = primary?.layout === "vertical";
|
|
155
|
+
button.style.cssText = `position:relative;display:flex;align-items:center;justify-content:center;width:${vertical ? 48 : 52}px;height:${vertical ? 52 : 48}px;flex-shrink:0;border:0;border-radius:24px;background:transparent;color:inherit;cursor:pointer`;
|
|
161
156
|
}
|
|
162
157
|
const holder = document.createElement("span");
|
|
163
158
|
button.append(holder);
|
package/dist/page-head.d.ts
CHANGED
|
@@ -1,2 +1,17 @@
|
|
|
1
1
|
/** Only page metadata travels across a fragment swap; never executable head state. */
|
|
2
2
|
export declare function pageHeadFragment(html: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* The stylesheets the page's head links, for a fragment swap to add to the
|
|
5
|
+
* live document.
|
|
6
|
+
*
|
|
7
|
+
* A fragment is the container's inner content, so a page reached by a link
|
|
8
|
+
* click never brought the `<link rel="stylesheet">` its own head declares and
|
|
9
|
+
* rendered with the previous page's CSS. They are assets, not metadata, so
|
|
10
|
+
* they travel beside the metadata template rather than inside it (#2121), and
|
|
11
|
+
* the router only ever adds the ones the document lacks.
|
|
12
|
+
*
|
|
13
|
+
* Generated utility sheets (`data-css`) are left out: they reach the router
|
|
14
|
+
* their own way, and it orders them itself. Empty when the page links none,
|
|
15
|
+
* which a router reads the same as an older server that sends nothing.
|
|
16
|
+
*/
|
|
17
|
+
export declare function pageCssFragment(html: string): string;
|
package/dist/page-head.js
CHANGED
|
@@ -4,22 +4,30 @@ import { decodeTitleEntities } from "./spa-nav.js";
|
|
|
4
4
|
function quoteValue(value) {
|
|
5
5
|
return value.replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
const head = /<head\b[^>]*>([\s\S]*?)<\/head\s*>/i.exec(html)?.[1] ?? "", tag = /<(meta|link)\b(?:[^>"']|"[^"]*"|'[^']*')*>|<title\b[^>]*>[\s\S]*?<\/title\s*>/giy
|
|
7
|
+
function headTags(html) {
|
|
8
|
+
const head = /<head\b[^>]*>([\s\S]*?)<\/head\s*>/i.exec(html)?.[1] ?? "", tag = /<(meta|link)\b(?:[^>"']|"[^"]*"|'[^']*')*>|<title\b[^>]*>[\s\S]*?<\/title\s*>/giy;
|
|
9
|
+
return scanAtElementPosition(head, (source, index) => {
|
|
9
10
|
tag.lastIndex = index;
|
|
10
11
|
return tag.exec(source) ? tag.lastIndex : -1;
|
|
11
|
-
})
|
|
12
|
-
|
|
12
|
+
}).map(({ token }) => token);
|
|
13
|
+
}
|
|
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
|
+
export function pageHeadFragment(html) {
|
|
24
|
+
const metadata = [];
|
|
25
|
+
for (const token of headTags(html)) {
|
|
13
26
|
if (/^<title\b/i.test(token)) {
|
|
14
27
|
metadata.push(`<title>${quoteValue(token.replace(/^<title\b[^>]*>|<\/title\s*>$/gi, ""))}</title>`);
|
|
15
28
|
continue;
|
|
16
29
|
}
|
|
17
|
-
const attrs =
|
|
18
|
-
for (const match of attributes.matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g)) {
|
|
19
|
-
const name = match[1].toLowerCase();
|
|
20
|
-
if (!(name in attrs))
|
|
21
|
-
attrs[name] = match[2] ?? match[3] ?? match[4] ?? "";
|
|
22
|
-
}
|
|
30
|
+
const attrs = tagAttributes(token);
|
|
23
31
|
if (/^<meta\b/i.test(token)) {
|
|
24
32
|
const kind = attrs.property ? "property" : "name", name = decodeTitleEntities(attrs[kind] ?? "").toLowerCase();
|
|
25
33
|
if (name === "description" || /^(?:og|twitter):[\w:]+$/.test(name))
|
|
@@ -33,3 +41,20 @@ export function pageHeadFragment(html) {
|
|
|
33
41
|
return `<template data-stx-page-head="1">${metadata.join("")}</template>
|
|
34
42
|
`;
|
|
35
43
|
}
|
|
44
|
+
const PAGE_CSS_ATTRIBUTES = ["media", "crossorigin", "integrity"];
|
|
45
|
+
export function pageCssFragment(html) {
|
|
46
|
+
const links = [];
|
|
47
|
+
for (const token of headTags(html)) {
|
|
48
|
+
if (!/^<link\b/i.test(token))
|
|
49
|
+
continue;
|
|
50
|
+
const attrs = tagAttributes(token);
|
|
51
|
+
if (decodeTitleEntities(attrs.rel ?? "").trim().toLowerCase() !== "stylesheet")
|
|
52
|
+
continue;
|
|
53
|
+
if (!attrs.href || "data-css" in attrs || "disabled" in attrs)
|
|
54
|
+
continue;
|
|
55
|
+
const kept = PAGE_CSS_ATTRIBUTES.filter((name) => (name in attrs)).map((name) => ` ${name}="${quoteValue(attrs[name])}"`).join("");
|
|
56
|
+
links.push(`<link rel="stylesheet" href="${quoteValue(attrs.href)}"${kept}>`);
|
|
57
|
+
}
|
|
58
|
+
return links.length ? `<template data-stx-page-css="1">${links.join("")}</template>
|
|
59
|
+
` : "";
|
|
60
|
+
}
|
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{so,Vt,$l,Og}from"./chunk-c541s99z.js";import{ro,Li,Ag,Pg,Ig}from"./chunk-bttvkzxh.js";import{Cl,El,Tl,$g,Rg}from"./chunk-wzyc9da7.js";import{We,Pn,ji}from"./chunk-9sjtph54.js";import{Ng,Dg,Mg,Lg,oo,vy}from"./chunk-wdwx2aa6.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-zecffe6a.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=We(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=We(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=so(n,t);if(a){let s=Vt(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 Li(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,El as auditBuildOutput,Cl as auditConfig,re as buildPwaAssets,Tl as calculateAuditResult,Rg as formatAuditResult,ji as formatSize,j as generateManifest,_ as generateManifestJson,Pg as generateManifestLink,F as generateOfflinePage,We as generatePrecacheManifest,Pn as generatePrecacheManifestJs,M as generatePwaIcons,ro as generatePwaTags,so as generateServiceWorker,Og as generateServiceWorkerAuto,Ag as generateSwRegistrationScript,Ig as generateThemeColorMeta,N as getExpectedIconPaths,Vt as getServiceWorkerFileName,Li as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,$l as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,oo as pwaDirectives,Ng as pwaInstallDirective,Mg as pwaOfflineDirective,Lg as pwaPushDirective,Dg as pwaUpdateDirective,vy as registerPwaDirectives,$g as runPwaAudit,D as validateManifest};
|
package/dist/ssg.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
3
|
-
`)}function J(t){return async()=>({paths:await t(),fallback:!1})}var Ot;function Lt(t){let r=s(t),{depths:n}=me(r),o=/\b(?:async\s+)?function\s+getStaticPaths\s*\(/g,l;while((l=o.exec(r))!==null){if(n[l.index]!==0)continue;let u=x(r,"(",")",o.lastIndex-1),g=r.indexOf("{",u+1),v=x(r,"{","}",g);if(u<0||g<0||v<0)break;return t.slice(l.index,v+1)}let e=/\b(?:const|let|var)\s+getStaticPaths\s*=/g;while((l=e.exec(r))!==null){if(n[l.index]!==0)continue;let u=
|
|
2
|
+
import"./chunk-hpwtjb4a.js";import{x,ll}from"./chunk-eg2p1cyw.js";import"./chunk-0wms5teg.js";import"./chunk-xppm4cs4.js";import{At,y}from"./chunk-ynnd6nnt.js";import"./chunk-46t924aw.js";import"./chunk-gpkxphqz.js";import"./chunk-jtccqpwa.js";import{_t,Ct,Et,Tt,$t,Rt}from"./chunk-t4dkcf28.js";import{a}from"./chunk-rtsshvpt.js";import{As}from"./chunk-09412heg.js";import"./chunk-nws4zm4k.js";import"./chunk-54p27ney.js";import{ye,nn,rn}from"./chunk-fx8jjasv.js";import"./chunk-0ey7kc6t.js";import{b}from"./chunk-8vkywnpx.js";import{bt,i}from"./chunk-c7qej674.js";import"./chunk-shnw9geh.js";import"./chunk-f2zgh4xr.js";import{ys}from"./chunk-63sqdcr6.js";import"./chunk-88a7qaw8.js";import"./chunk-t5q31st4.js";import{rc,sc,oc}from"./chunk-tm5t3hh3.js";import{en,tr,nr}from"./chunk-86z8zrn9.js";import{tn}from"./chunk-rwc322gq.js";import"./chunk-xa2qfe51.js";import"./chunk-cww1zk8y.js";import{G,ve}from"./chunk-0zgxxhvs.js";import"./chunk-he9dzchk.js";import"./chunk-xr9rf0e6.js";import{c}from"./chunk-p2fkggw4.js";import{s,me}from"./chunk-jm0qsr3s.js";import D from"fs";import f from"path";import{createHash as vt}from"crypto";function Pt(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var kt=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function Dt(t){return Bun.hash(t).toString(16)}function ot(t,r={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let n=new Map,o=t.replace(kt,(e,u,g,v)=>{let w=v.trim();if(!w)return e;if(/\bdata-stx-src=/.test(g))return e;if(r.minify)w=Pt(w);let p=Dt(w);if(!n.has(p))n.set(p,w);let P=r.integrity?` data-stx-integrity="sha384-${vt("sha384").update(w).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${u}" data-stx-src="/_stx/islands/${p}.js"${P}${g}></script>`}),l=Array.from(n,([e,u])=>({hash:e,code:u}));return{html:o,chunks:l}}var It=new Set(["visible","idle"]);function ct(t){if(!t.includes("data-stx-src="))return t;let r=new Map,n=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,o;while((o=n.exec(t))!==null)r.set(o[1],o[2]);let l=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,u;while((u=e.exec(t))!==null)if(It.has(r.get(u[1])||""))l.add(u[2]);let g=/<\/head\s*>/iy,v=y(t,(p,P)=>(g.lastIndex=P,g.exec(p)?g.lastIndex:-1))[0]?.start??-1;if(l.size===0||v===-1)return t;let w=Array.from(l).filter((p)=>!t.includes(`rel="prefetch" href="${p}"`)).map((p)=>`<link rel="prefetch" href="${p}" as="script">`).join("");if(!w)return t;return t.slice(0,v)+w+t.slice(v)}var Bt=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function X(t){let r=t.trim();if(!r)return null;let n=/^https?:\/\//i.test(r)?r:`https://${r}`;try{return new URL(n).origin+new URL(n).pathname.replace(/\/$/,"")}catch{return null}}function jt(t){for(let r of Bt){let n=t[r];if(!n)continue;let o=X(n);if(o)return{url:o,source:"env",via:r}}return null}function lt(t){if(!t||typeof t!=="object")return null;let r=t,n=r.site?.url??r.url??r.app?.url;return typeof n==="string"?X(n):null}async function Ft(t){let{existsSync:r}=await import("fs"),n=await import("path");for(let o of["site.config.ts","site.config.js",".config/site.config.ts"]){let l=n.resolve(t,o);if(!r(l))continue;try{let e=await import(l),u=lt(e.default??e);if(u)return u}catch{}}return null}async function ut(t={}){let r=t.cwd??process.cwd(),n=t.env??process.env;if(t.explicit){let u=X(t.explicit);if(u)return{url:u,source:"option"}}let o=lt(t.stxConfig);if(o)return{url:o,source:"stx.config",via:"site.url"};let l=await Ft(r);if(l)return{url:l,source:"site.config",via:"url"};let e=jt(n);if(e)return e;return{url:"http://localhost",source:"fallback"}}function dt(){return["No site URL configured \u2014 sitemap.xml and robots.txt will point at http://localhost."," Set one in stx.config.ts (site: { url: 'https://example.com' }), in site.config.ts,"," via --domain, or with SITE_URL in the build environment."].join(`
|
|
3
|
+
`)}function J(t){return async()=>({paths:await t(),fallback:!1})}var Ot;function Lt(t){let r=s(t),{depths:n}=me(r),o=/\b(?:async\s+)?function\s+getStaticPaths\s*\(/g,l;while((l=o.exec(r))!==null){if(n[l.index]!==0)continue;let u=x(r,"(",")",o.lastIndex-1),g=r.indexOf("{",u+1),v=x(r,"{","}",g);if(u<0||g<0||v<0)break;return t.slice(l.index,v+1)}let e=/\b(?:const|let|var)\s+getStaticPaths\s*=/g;while((l=e.exec(r))!==null){if(n[l.index]!==0)continue;let u=ll(r,e.lastIndex).endPos;return t.slice(e.lastIndex,u).trim()}throw SyntaxError("Could not extract getStaticPaths; use a top-level function or const declaration")}async function gt(t){let r="read";try{let n=await Bun.file(t).text();r="parse";let o=tn(n),l=[...o.server,...o.client,...o.signals].filter((e)=>/(?:^|\s)server(?:\s|=|$)/i.test(s(e.attrs))).sort((e,u)=>n.indexOf(e.fullTag)-n.indexOf(u.fullTag));for(let e of l){if(!/\bgetStaticPaths\b/.test(s(e.content)))continue;let u=(Ot??=new Bun.Transpiler({loader:"ts",target:"bun"})).transformSync(e.content);if(!/\bgetStaticPaths\b/.test(s(u)))continue;let g=Lt(u);if(/\bdefineStaticPaths\b/.test(s(g))&&At(u,"defineStaticPaths"))throw SyntaxError("Cannot evaluate a module-local defineStaticPaths binding during isolated hook extraction");r="execute";let v=Function("defineStaticPaths",`return (${g})`)(J);if(typeof v!=="function")throw TypeError("getStaticPaths must be a function");let w=await v();r="result";let p=Array.isArray(w)?{paths:w}:w;if(!p||typeof p!=="object"||!("paths"in p)||!Array.isArray(p.paths))throw TypeError("getStaticPaths must return { paths: [...] } or an array of paths");for(let P of p.paths)if(!P||typeof P!=="object"||!P.params||typeof P.params!=="object"||Array.isArray(P.params))throw TypeError("Each getStaticPaths path must contain a params object");return{kind:"ok",value:p}}return{kind:"absent"}}catch(n){return{kind:"error",phase:r,error:n instanceof Error?n:Error(String(n))}}}class pt{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,r=""){this.cacheDir=t,this.salt=r}async load(){if(this.loaded)return;let t=f.join(this.cacheDir,"build-cache.json");if(await Bun.file(t).exists())try{let r=JSON.parse(await Bun.file(t).text());for(let[n,o]of Object.entries(r))this.cache.set(n,o)}catch{}this.loaded=!0}async save(){await D.promises.mkdir(this.cacheDir,{recursive:!0});let t=f.join(this.cacheDir,"build-cache.json"),r={};for(let[n,o]of this.cache)r[n]=o;await Bun.write(t,JSON.stringify(r))}getHash(t,r){let n=D.statSync(t),o=`${this.salt}|${t}:${n.mtimeMs}`;for(let e of r)if(D.existsSync(e)){let u=D.statSync(e);o+=`:${e}:${u.mtimeMs}`}let l=0;for(let e=0;e<o.length;e++){let u=o.charCodeAt(e);l=(l<<5)-l+u,l=l&l}return Math.abs(l).toString(36)}get(t,r){let n=this.cache.get(t);if(!n)return null;let o=ft(r).some((u)=>D.existsSync(u)),l=[r,...n.dependencies??[]].some((u)=>u.endsWith(".stx")&&D.existsSync(u)&&ys(D.readFileSync(u,"utf8")).some((g)=>/\bserver\b/.test(g.attrs)));if(o||l)return this.cache.delete(t),null;let e=this.getHash(r,n.dependencies??[]);if(n.hash!==e)return this.cache.delete(t),null;return n.html}set(t,r,n,o){let l=this.getHash(r,n);this.cache.set(t,{hash:l,html:o,generatedAt:Date.now(),dependencies:n})}}class ht{cacheDir;constructor(t){this.cacheDir=t}getFilePath(t){let r=t.replace(/[^a-zA-Z0-9]/g,"_")+".json";return f.join(this.cacheDir,"isr",r)}async get(t){let r=this.getFilePath(t);if(!await Bun.file(r).exists())return null;try{return JSON.parse(await Bun.file(r).text())}catch{return null}}async set(t,r){let n=this.getFilePath(t);await D.promises.mkdir(f.dirname(n),{recursive:!0}),await Bun.write(n,JSON.stringify(r))}async invalidate(t){let r=this.getFilePath(t);if(await Bun.file(r).exists())await D.promises.unlink(r)}async invalidatePattern(t){let r=f.join(this.cacheDir,"isr");if(!D.existsSync(r))return;let n=await D.promises.readdir(r);for(let o of n){let l=o.replace(/_/g,"/").replace(".json","");if(t.test(l))await D.promises.unlink(f.join(r,o))}}async needsRevalidation(t){let r=await this.get(t);if(!r)return!0;return Date.now()>r.revalidateAfter}}async function Ut(t){let r=[];if(!t.isDynamic)r.push({url:t.pattern,params:{}});else{let n=await gt(t.filePath);if(n.kind==="error")throw Error(`getStaticPaths ${n.phase} failed for ${t.pattern} (${t.filePath}): ${n.error.message}`,{cause:n.error});if(n.kind==="absent")return console.warn(`Warning: Dynamic route ${t.pattern} (${t.filePath}) has no getStaticPaths`),r;let o=n.value;if(o.paths.length===0)return console.info(`getStaticPaths returned no paths for dynamic route ${t.pattern} (${t.filePath})`),r;for(let l of o.paths){let e=t.pattern;for(let[u,g]of Object.entries(l.params))e=e.replace(`:${u}`,g).replace(`:${u}*`,g);r.push({url:e,params:l.params,props:l.props,revalidate:l.revalidate})}}return r}function ft(t){return[t.replace(/\.stx$/,".data.ts"),t.replace(/\.stx$/,".data.js"),t+".data.ts",t+".data.js"]}async function Mt(t){for(let r of ft(t))if(await Bun.file(r).exists())try{let n=await import(r);if(typeof n.default==="function")return await n.default();else if(typeof n.default==="object")return n.default;else if(typeof n.getData==="function")return await n.getData();else{let{default:o,...l}=n;return l}}catch(n){console.error(`Error loading data file ${r}:`,n)}return null}async function Gt(t,r,n){let o=t.match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!o)return null;let l=o[1];if(!l.includes("getStaticProps"))return null;try{let e=l.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticProps\s*\([^)]*\)\s*\{([\s\S]*?)\n\}/);if(!e)return null;return await Function("params",`
|
|
4
4
|
return (async function getStaticProps() {
|
|
5
5
|
${e[1]}
|
|
6
6
|
})()
|
|
@@ -37,13 +37,13 @@ ${t.map((o)=>{let l=new URL(o.loc,r).href,e=` <url>
|
|
|
37
37
|
${n.join(`
|
|
38
38
|
`)}
|
|
39
39
|
</channel>
|
|
40
|
-
</rss>`}async function Vt(t={}){let r=Date.now();
|
|
40
|
+
</rss>`}async function Vt(t={}){let r=Date.now();rn();let n=await a(process.cwd()),o=n.build||{},l=await ut({explicit:t.domain||o.domain,stxConfig:n});if(l.source==="fallback"&&(t.sitemap??o.sitemap??!0))console.warn(dt());let e={router:t.router??n?.router??{},pagesDir:t.pagesDir||o.pagesDir||"pages",outputDir:t.outputDir||o.outputDir||"dist",baseUrl:t.baseUrl||o.baseUrl||"/",domain:l.url,revalidate:t.revalidate??o.revalidate??!1,sitemap:t.sitemap??o.sitemap??!0,sitemapExclude:t.sitemapExclude||o.sitemapExclude||[],robots:t.robots??o.robots??!0,rss:t.rss??o.rss??!1,concurrency:t.concurrency||o.concurrency||10,cache:t.cache??o.cache??!0,cacheDir:t.cacheDir||o.cacheDir||c(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??o.minify??!0,generate404:t.generate404??o.generate404??!0,publicDir:t.publicDir||o.publicDir||"public",trailingSlash:t.trailingSlash??o.trailingSlash??!1,cleanOutput:t.cleanOutput??o.cleanOutput??!0,cacheSalt:t.cacheSalt??"",partialsDir:t.partialsDir||n?.partialsDir||"",componentsDir:t.componentsDir||n?.componentsDir||"",failOnIncludeError:t.failOnIncludeError??!0,failOnServerScriptError:t.failOnServerScriptError??!0,chunkIslands:t.chunkIslands===!0,prefetchIslands:t.prefetchIslands===!0,integrityIslands:t.integrityIslands===!0},u={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},g=new Set,v=0,w={},p={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&D.existsSync(e.outputDir))await D.promises.rm(e.outputDir,{recursive:!0});await D.promises.mkdir(e.outputDir,{recursive:!0});let E=e.cacheSalt;if(!E){let{resolveUserCssConfig:d,fingerprintConfig:m}=await import("./chunk-hc4ydhw0.js");try{E=m(await d(process.cwd()))}catch{}}let{prepareImageDelivery:S}=await import("./chunk-h8zb6cek.js"),R=await S(e.publicDir,e.outputDir);if(R.count>0)console.log(`Optimized ${R.count} image(s) for responsive delivery`),E=[E,R.fingerprint].filter(Boolean).join(":");let A=new pt(e.cacheDir,E);if(e.cache)await A.load();try{let{generateCss:d}=await import("./chunk-hc4ydhw0.js");await d('<div class="bg-black"></div>')}catch{}_t();let wt=n?.routeMiddleware?.dir||"middleware";await Et(process.cwd(),wt);let V=Ct();if(V.length>0)console.log(`Loaded ${V.length} middleware: ${V.join(", ")}`);let yt=n?.routeMiddleware?.global||[];oc(n?.layoutsDir,c(process.cwd()));let Z=G(".",{pagesDir:e.pagesDir,pagesDirs:n?._layerPageDirs});console.log(`Found ${Z.length} routes`);let L=[];for(let d of Z)try{let m=await Ut(d);for(let k of m)L.push({route:d,url:k.url,params:k.params,props:k.props,revalidate:k.revalidate??e.revalidate})}catch(m){let k=m instanceof Error?m:Error(String(m));u.failedCount++,u.errors.push({route:d.pattern,error:k}),await e.hooks.onError?.(k,d.pattern),console.error(`Error discovering paths for ${d.pattern}:`,k)}u.totalPages=L.length+u.failedCount,console.log(`Generating ${L.length} pages...`);let U=[],Q=[];for(let d=0;d<L.length;d+=e.concurrency)Q.push(L.slice(d,d+e.concurrency));for(let d of Q)await Promise.all(d.map(async(m)=>{let{route:k,url:h,params:_,props:St,revalidate:rt}=m;try{await e.hooks.onPageStart?.(h);let M=await Bun.file(k.filePath).text(),T=Yt(M),xt=T?.middleware?Array.isArray(T.middleware)?T.middleware:[T.middleware]:[],nt=[...yt,...xt];if(nt.length>0){let B=Tt(h,_,T||{}),H=$t(B,null,void 0,{isServer:!0}),j=await Rt(nt,H);if(j.redirect){let C=typeof j.redirect==="string"?j.redirect:j.redirect.path||j.redirect,z=Zt(String(C),h),O=Qt(h,e);await D.promises.mkdir(f.dirname(O),{recursive:!0}),await Bun.write(O,z),u.successCount++,u.pages.push({route:h,outputPath:O,size:Buffer.byteLength(z),cached:!1}),U.push({loc:h,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${h} \u2192 redirect to ${C}`);return}if(j.abort){let C=typeof j.abort==="string"?j.abort:j.abort?.error?.message||"aborted";console.warn(` \u21B3 ${h} \u2014 middleware aborted: ${C}`);return}}let it=T?.validate;if(typeof it==="function")try{if(!await it({params:_})){console.warn(`Validation failed for ${h}, skipping...`);return}}catch{}let I=null,st=!1;if(e.cache){if(I=A.get(h,k.filePath),I)st=!0,u.cachedCount++}if(!I){let B=await mt(k,_,St,e,n);if(I=B.html,e.failOnIncludeError&&B.includeFailures.length>0)throw Error(`${B.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
|
|
41
41
|
${B.includeFailures.join(`
|
|
42
42
|
`)}
|
|
43
43
|
Set ssg.failOnIncludeError to false to build anyway.`);if(e.failOnServerScriptError&&B.serverScriptFailures.length>0)throw Error(`${B.serverScriptFailures.length} <script server> block(s) failed, so this page would have shipped with the content they produce missing:
|
|
44
44
|
${B.serverScriptFailures.join(`
|
|
45
45
|
`)}
|
|
46
|
-
Set ssg.failOnServerScriptError to false to build anyway.`);if(e.cache)A.set(h,k.filePath,B.dependencies,I)}let N;if(e.trailingSlash)N=f.join(e.outputDir,h,"index.html");else N=h==="/"?f.join(e.outputDir,"index.html"):f.join(e.outputDir,`${h}.html`);if(e.chunkIslands){let{html:B,chunks:H}=ot(I,{integrity:e.integrityIslands,minify:e.minify});if(H.length>0){let j=f.join(e.outputDir,"_stx","islands");await D.promises.mkdir(j,{recursive:!0});for(let C of H){let z=f.join(j,`${C.hash}.js`);if(!await Bun.file(z).exists())await Bun.write(z,C.code);if(!g.has(C.hash)){g.add(C.hash);let O=Buffer.byteLength(C.code,"utf8");v+=O,w[C.hash]={bytes:O,file:`/_stx/islands/${C.hash}.js`}}}if(p[h]=H.map((C)=>C.hash),I=B,e.prefetchIslands)I=ct(I)}}if(await D.promises.mkdir(f.dirname(N),{recursive:!0}),await Bun.write(N,I),!Wt(h,I,T,e.sitemapExclude))U.push({loc:h,lastmod:new Date().toISOString().split("T")[0],priority:h==="/"?1:0.8});let at={route:h,outputPath:N,size:Buffer.byteLength(I,"utf8"),cached:st};if(rt!==!1)at.revalidateAt=Date.now()+rt*1000;u.pages.push(at),u.successCount++,await e.hooks.onPageEnd?.(h,I)}catch(M){u.failedCount++,u.errors.push({route:h,error:M}),await e.hooks.onError?.(M,h),console.error(`Error generating ${h}:`,M)}}));let tt=
|
|
46
|
+
Set ssg.failOnServerScriptError to false to build anyway.`);if(e.cache)A.set(h,k.filePath,B.dependencies,I)}let N;if(e.trailingSlash)N=f.join(e.outputDir,h,"index.html");else N=h==="/"?f.join(e.outputDir,"index.html"):f.join(e.outputDir,`${h}.html`);if(e.chunkIslands){let{html:B,chunks:H}=ot(I,{integrity:e.integrityIslands,minify:e.minify});if(H.length>0){let j=f.join(e.outputDir,"_stx","islands");await D.promises.mkdir(j,{recursive:!0});for(let C of H){let z=f.join(j,`${C.hash}.js`);if(!await Bun.file(z).exists())await Bun.write(z,C.code);if(!g.has(C.hash)){g.add(C.hash);let O=Buffer.byteLength(C.code,"utf8");v+=O,w[C.hash]={bytes:O,file:`/_stx/islands/${C.hash}.js`}}}if(p[h]=H.map((C)=>C.hash),I=B,e.prefetchIslands)I=ct(I)}}if(await D.promises.mkdir(f.dirname(N),{recursive:!0}),await Bun.write(N,I),!Wt(h,I,T,e.sitemapExclude))U.push({loc:h,lastmod:new Date().toISOString().split("T")[0],priority:h==="/"?1:0.8});let at={route:h,outputPath:N,size:Buffer.byteLength(I,"utf8"),cached:st};if(rt!==!1)at.revalidateAt=Date.now()+rt*1000;u.pages.push(at),u.successCount++,await e.hooks.onPageEnd?.(h,I)}catch(M){u.failedCount++,u.errors.push({route:h,error:M}),await e.hooks.onError?.(M,h),console.error(`Error generating ${h}:`,M)}}));let tt=nn();if(tt.length>0){let d=tt.map((m)=>`${m.filePath}: ${m.message}`).join(`
|
|
47
47
|
`);throw Error(`Client script bundling failed:
|
|
48
48
|
${d}`)}if(e.cache)await A.save();if(e.generate404){let d=f.join(e.pagesDir,"404.stx");if(await Bun.file(d).exists()){let m=new Set,k={...n,minifyClient:!0,debug:!1,cache:!1},h=await i(await Bun.file(d).text(),{},d,k,m);await Bun.write(f.join(e.outputDir,"404.html"),h)}else await Bun.write(f.join(e.outputDir,"404.html"),`<!DOCTYPE html>
|
|
49
49
|
<html lang="en">
|
|
@@ -66,7 +66,7 @@ ${d}`)}if(e.cache)await A.save();if(e.generate404){let d=f.join(e.pagesDir,"404.
|
|
|
66
66
|
<a href="/">Go home</a>
|
|
67
67
|
</div>
|
|
68
68
|
</body>
|
|
69
|
-
</html>`)}for(let d of[500]){let m=f.join(e.pagesDir,`${d}.stx`);if(await Bun.file(m).exists()){let k=new Set,h={...n,minifyClient:!0,debug:!1,cache:!1},_=await i(await Bun.file(m).text(),{},m,h,k);await Bun.write(f.join(e.outputDir,`${d}.html`),_)}}let K=f.join(e.pagesDir,"error.stx");if(await Bun.file(K).exists()){let d=new Set,m={...n,minifyClient:!0,debug:!1,cache:!1},k=await i(await Bun.file(K).text(),{},K,m,d);await Bun.write(f.join(e.outputDir,"error.html"),k)}if(e.sitemap&&U.length>0){let d=qt(U,e.domain),m=f.join(e.outputDir,"sitemap.xml");await Bun.write(m,d),u.sitemapPath=m,console.log(`Generated sitemap.xml with ${U.length} URLs`)}if(e.robots!==!1){let d=typeof e.robots==="object"?e.robots:{},m=[...e.sitemapExclude.filter((h)=>typeof h==="string"),...d.disallow||[]],k=
|
|
69
|
+
</html>`)}for(let d of[500]){let m=f.join(e.pagesDir,`${d}.stx`);if(await Bun.file(m).exists()){let k=new Set,h={...n,minifyClient:!0,debug:!1,cache:!1},_=await i(await Bun.file(m).text(),{},m,h,k);await Bun.write(f.join(e.outputDir,`${d}.html`),_)}}let K=f.join(e.pagesDir,"error.stx");if(await Bun.file(K).exists()){let d=new Set,m={...n,minifyClient:!0,debug:!1,cache:!1},k=await i(await Bun.file(K).text(),{},K,m,d);await Bun.write(f.join(e.outputDir,"error.html"),k)}if(e.sitemap&&U.length>0){let d=qt(U,e.domain),m=f.join(e.outputDir,"sitemap.xml");await Bun.write(m,d),u.sitemapPath=m,console.log(`Generated sitemap.xml with ${U.length} URLs`)}if(e.robots!==!1){let d=typeof e.robots==="object"?e.robots:{},m=[...e.sitemapExclude.filter((h)=>typeof h==="string"),...d.disallow||[]],k=As({rules:[{userAgent:d.userAgent||"*",allow:d.allow||["/"],...m.length>0?{disallow:m}:{}}],...d.sitemap!==!1&&u.sitemapPath?{sitemap:new URL("/sitemap.xml",e.domain).href}:{}});await Bun.write(f.join(e.outputDir,"robots.txt"),k),console.log("Generated robots.txt")}if(e.rss){let d=typeof e.rss==="object"?e.rss:{title:"Site Feed",description:"Latest updates",link:e.domain},m=[];if(d.getItems)m=await d.getItems();let k=Jt(d,m),h=f.join(e.outputDir,"rss.xml");await Bun.write(h,k),u.rssPath=h,console.log(`Generated rss.xml with ${m.length} items`)}let W=rc(e.outputDir);if(W.assets>0)console.log(`Externalized ${W.assets} asset(s) from ${W.pages} page(s) (${(W.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);let q=sc(e.outputDir);if(q.assets>0)console.log(`Externalized ${q.assets} repeated asset(s) from ${q.pages} page(s) (${(q.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);if(e.publicDir&&D.existsSync(e.publicDir))await Y(e.publicDir,e.outputDir),console.log(`Copied public assets from ${e.publicDir}`);let et=nr();if(et)await Y(et,f.join(e.outputDir,tr)),console.log(`Copied assets from ${en}`)}catch(E){throw await e.hooks.onError?.(E),E}if(u.buildTime=Date.now()-r,g.size>0){u.islandChunks={count:g.size,totalBytes:v};let E={generatedChunks:g.size,totalBytes:v,chunks:w,pages:p};await Bun.write(f.join(e.outputDir,"_stx","islands-manifest.json"),JSON.stringify(E,null,2))}await e.hooks.onBuildEnd?.(u);let P=u.islandChunks?`
|
|
70
70
|
Island chunks: ${u.islandChunks.count} (${(u.islandChunks.totalBytes/1024).toFixed(1)} KB lifted out of inline HTML)`:"";return console.log(`
|
|
71
71
|
Build complete!
|
|
72
72
|
Total: ${u.totalPages} pages
|
|
@@ -87,4 +87,4 @@ Build complete!
|
|
|
87
87
|
<p>Redirecting to <a href="${t}">${t}</a>...</p>
|
|
88
88
|
<script>window.location.replace('${t}')</script>
|
|
89
89
|
</body>
|
|
90
|
-
</html>`}function
|
|
90
|
+
</html>`}function Qt(t,r){if(t==="/"||t==="")return f.join(r.outputDir,"index.html");let n=t.replace(/^\/|\/$/g,"");if(r.trailingSlash)return f.join(r.outputDir,n,"index.html");return f.join(r.outputDir,`${n}.html`)}var je={generateStaticSite:Vt,createISRHandler:Kt,defineStaticPaths:J,createMarkdownLoader:Xt};export{Kt as createISRHandler,Xt as createMarkdownLoader,Nt as declaresPageAction,je as default,J as defineStaticPaths,Vt as generateStaticSite,Wt as isExcludedFromSitemap};
|
|
@@ -7,7 +7,7 @@ import { stripDocumentWrapper } from "./app-shell.js";
|
|
|
7
7
|
import { createHash } from "node:crypto";
|
|
8
8
|
import { collectBlockDeclarations } from "./stx-virtual-ts.js";
|
|
9
9
|
import { extractPageResponseStatus } from "./page-response.js";
|
|
10
|
-
import { pageHeadFragment } from "./page-head.js";
|
|
10
|
+
import { pageCssFragment, pageHeadFragment } from "./page-head.js";
|
|
11
11
|
function createRecordingContext(baseContext = {}) {
|
|
12
12
|
const accessedKeys = new Set;
|
|
13
13
|
return { context: new Proxy(baseContext, {
|
|
@@ -51,7 +51,7 @@ export async function compileTemplate(filePath, route, options = {}) {
|
|
|
51
51
|
...options,
|
|
52
52
|
buildMode: "compile",
|
|
53
53
|
strict: !1
|
|
54
|
-
}, html = await processDirectives(content, context, absolutePath, opts, dependencies), fragment = pageHeadFragment(html) + stripDocumentWrapper(html), placeholders = getPlaceholderRegistry();
|
|
54
|
+
}, html = await processDirectives(content, context, absolutePath, opts, dependencies), fragment = pageHeadFragment(html) + pageCssFragment(html) + stripDocumentWrapper(html), placeholders = getPlaceholderRegistry();
|
|
55
55
|
return {
|
|
56
56
|
route,
|
|
57
57
|
sourceFile: filePath,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/stx",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.849",
|
|
5
5
|
"description": "A performant UI Framework. Powered by Bun.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -128,12 +128,12 @@
|
|
|
128
128
|
"dependencies": {
|
|
129
129
|
"@stacksjs/ts-css": "^0.3.21",
|
|
130
130
|
"@stacksjs/clapp": "^0.2.16",
|
|
131
|
-
"@stacksjs/desktop": "0.2.
|
|
132
|
-
"@stacksjs/sanitizer": "0.2.
|
|
131
|
+
"@stacksjs/desktop": "0.2.849",
|
|
132
|
+
"@stacksjs/sanitizer": "0.2.849",
|
|
133
133
|
"@stacksjs/ts-i18n": "^0.1.11",
|
|
134
|
-
"bun-plugin-stx": "0.2.
|
|
134
|
+
"bun-plugin-stx": "0.2.849",
|
|
135
135
|
"bunfig": "^0.15.21",
|
|
136
|
-
"stx-router": "0.2.
|
|
136
|
+
"stx-router": "0.2.849",
|
|
137
137
|
"ts-broadcasting": "^0.0.11",
|
|
138
138
|
"ts-images": "^0.2.22",
|
|
139
139
|
"ts-syntax-highlighter": "^0.2.1"
|
package/dist/chunk-07hvjvj1.js
DELETED
package/dist/chunk-13sp1247.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{m,bi,Jc,Yc,fg,gg,mg,hg,yg,qs,bg,Be,Z,Fe,wg,$r,vg,el,tl,xi,ze,r,vn,nl,h,ge,ny}from"./chunk-evww725k.js";import"./chunk-rg2gfyy0.js";import"./chunk-an6vb4ng.js";import"./chunk-t3e95q80.js";import"./chunk-zjqvbcwa.js";import"./chunk-z26fg4p0.js";export{tl as SIGNAL_COMPOSABLE_CALL,ge as clearComponentCache,xi as componentClientSignalNames,bi as convertToCommonJS,h as createDetailedErrorMessage,yg as extractDirectiveNames,Jc as extractScriptFromTemplate,m as extractVariables,r as fileExists,ny as getComponentCacheStats,gg as getPositionInfo,Z as getSharedTranspiler,nl as getSourceLineInfo,hg as hasDirectives,Yc as hasVariables,vg as isHydrateTrigger,bg as isJavaScriptScript,ze as renderComponentWithSlot,vn as resolveTemplatePath,wg as scopeOnRootElement,qs as scopeSequenceKey,Be as shouldTranspileTypeScript,el as slotContentHasExpressions,Fe as transpileTypeScript,$r as userComponentFileExists,mg as validateDirective,fg as validateTemplate};
|
package/dist/chunk-1kdtapc1.js
DELETED
package/dist/chunk-263gby2p.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{ql,xm,Kl,Xl,Sm,km}from"./chunk-6x6xthsv.js";import"./chunk-evww725k.js";import"./chunk-rg2gfyy0.js";import"./chunk-an6vb4ng.js";import"./chunk-t3e95q80.js";import"./chunk-zjqvbcwa.js";import"./chunk-z26fg4p0.js";export{km as applySlots,Sm as extractSlotContent,xm as parseSlotElement,ql as parseSlots,Xl as processSlots,Kl as renderSlot};
|
package/dist/chunk-33ggd5at.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{fo,oa,qr,go,mo,In,Xt,ia,Kr,Xr,ho,yo,tm,nm,ft}from"./chunk-prrf0j54.js";export{ft as DeployError,oa as calculateSha1,qr as collectDeployFiles,Xr as createDefaultNetlifyConfig,go as createFileManifest,fo as createNetlifyClient,tm as deploy,Kr as detectProjectConfig,mo as filterRequiredFiles,In as formatSize,ia as generateNetlifyToml,Xt as getTotalSize,yo as hasNetlifyConfig,nm as initNetlify,ho as writeNetlifyConfig};
|
package/dist/chunk-3q19w77r.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{sr,i}from"./chunk-50tnhq5f.js";import"./chunk-j3zy3mrn.js";import"./chunk-wd632rge.js";import"./chunk-2a792g5e.js";import"./chunk-r1984y6y.js";import"./chunk-mgtp037k.js";import"./chunk-5903tzcw.js";import"./chunk-84myqca7.js";import"./chunk-wvsnp294.js";import{ve}from"./chunk-nsc93haq.js";import"./chunk-30g5kqy0.js";import"./chunk-ng8nkbp2.js";import"./chunk-c78dsx3f.js";import"./chunk-tzqnf28n.js";import"./chunk-vh8wn94m.js";import"./chunk-sxsjxme0.js";import"./chunk-wzpd3htt.js";import"./chunk-dspmqeg0.js";import{Ne,Us,Ws}from"./chunk-evww725k.js";import"./chunk-rg2gfyy0.js";import"./chunk-an6vb4ng.js";import"./chunk-t3e95q80.js";import"./chunk-zjqvbcwa.js";import"./chunk-z26fg4p0.js";export{sr as buildModulesTag,ve as injectRouterScript,i as processDirectives,Us as processJsonDirective,Ws as processOnceDirective,Ne as validateClientScript};
|
package/dist/chunk-40x0vwza.js
DELETED
package/dist/chunk-4cmda04d.js
DELETED