@stacksjs/stx 0.2.762 → 0.2.765
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-01484snf.js +2 -0
- package/dist/{chunk-b51p56k5.js → chunk-07c8rk93.js} +2 -2
- package/dist/chunk-09cera09.js +2 -0
- package/dist/{chunk-zhrz4zvw.js → chunk-0d29b573.js} +4 -4
- package/dist/chunk-0f5276fm.js +2 -0
- package/dist/{chunk-8yyq3nfg.js → chunk-0nzeqc13.js} +2 -2
- package/dist/chunk-16n128gh.js +2 -0
- package/dist/chunk-171bbyqv.js +2 -0
- package/dist/{chunk-dnsf934e.js → chunk-1day2nbr.js} +5 -5
- package/dist/chunk-1g0g498y.js +2 -0
- package/dist/{chunk-x5seqmrv.js → chunk-1g5fg1ys.js} +2 -2
- package/dist/chunk-1qppvj48.js +2 -0
- package/dist/{chunk-tpfxvw4q.js → chunk-1w4a0xya.js} +14 -14
- package/dist/chunk-1z77g0j6.js +2 -0
- package/dist/chunk-2hbwpm36.js +177 -0
- package/dist/{chunk-rh2qth8r.js → chunk-2mckhfet.js} +5 -5
- package/dist/chunk-31e7xkrt.js +2 -0
- package/dist/chunk-3ffz7pd4.js +2 -0
- package/dist/{chunk-37y8sg48.js → chunk-3mf27gj6.js} +2 -2
- package/dist/{chunk-gwjh981q.js → chunk-49w4cbqb.js} +7 -7
- package/dist/chunk-4bhbtvtm.js +2 -0
- package/dist/{chunk-18chz0q4.js → chunk-4m3666pm.js} +1 -1
- package/dist/{chunk-xtwc2dbk.js → chunk-4tppbw4r.js} +2 -2
- package/dist/{chunk-rmk8efc3.js → chunk-4yk7zngj.js} +109 -109
- package/dist/{chunk-rj3p5fdy.js → chunk-51dxp9w9.js} +3 -3
- package/dist/chunk-59r38w60.js +2 -0
- package/dist/chunk-5ttj2c0h.js +2 -0
- package/dist/chunk-5x312c05.js +2 -0
- package/dist/chunk-65h2h51z.js +2 -0
- package/dist/chunk-6ch8t3d9.js +3 -0
- package/dist/{chunk-tshpcvcy.js → chunk-6h6teyxp.js} +2 -2
- package/dist/{chunk-319aez2f.js → chunk-6jnrpnxb.js} +3 -3
- package/dist/chunk-6rd0zz6k.js +2 -0
- package/dist/{chunk-8y54tpbr.js → chunk-74y29xxs.js} +5 -5
- package/dist/{chunk-t1shvfhm.js → chunk-7aw9qm74.js} +47 -47
- package/dist/chunk-7bvhpdqv.js +2 -0
- package/dist/{chunk-0fs9kx0h.js → chunk-7yx2ztt5.js} +2 -2
- package/dist/{chunk-f8p8ggvw.js → chunk-8hanmv49.js} +4 -4
- package/dist/{chunk-j1tsda22.js → chunk-8prk7e1z.js} +10 -10
- package/dist/{chunk-nm9tnxnw.js → chunk-8zgvr0fw.js} +5 -5
- package/dist/{chunk-pqbxa0r7.js → chunk-a2yptg7r.js} +2 -2
- package/dist/{chunk-qystt1qc.js → chunk-a627f39k.js} +1 -1
- package/dist/{chunk-ds6mbfdq.js → chunk-as4s0nf5.js} +3 -3
- package/dist/chunk-axxd53tn.js +2 -0
- package/dist/{chunk-evxp3wmv.js → chunk-ay02q27h.js} +7 -7
- package/dist/{chunk-2eamszdq.js → chunk-ay5g5cbk.js} +2 -2
- package/dist/chunk-b8ar6431.js +2 -0
- package/dist/{chunk-yb71b2d6.js → chunk-b8hsvzqb.js} +2 -2
- package/dist/chunk-bnm7ym0g.js +2 -0
- package/dist/{chunk-0sd4td6z.js → chunk-bnwkytme.js} +3 -3
- package/dist/chunk-brg2ydrk.js +2 -0
- package/dist/chunk-bwkw2dw3.js +2 -0
- package/dist/chunk-c0fwppzc.js +2 -0
- package/dist/{chunk-8rk79ha1.js → chunk-c1b481my.js} +2 -2
- package/dist/chunk-c5kpc7rn.js +2 -0
- package/dist/{chunk-59k4xb92.js → chunk-c5mbhfff.js} +5 -5
- package/dist/chunk-c8256r1a.js +2 -0
- package/dist/chunk-cap6exxx.js +2 -0
- package/dist/{chunk-mbe4gqd3.js → chunk-ccedry39.js} +2 -2
- package/dist/chunk-cft1sprt.js +2 -0
- package/dist/{chunk-qjbcp3tc.js → chunk-cswar3zs.js} +3 -3
- package/dist/{chunk-t2cq4bpe.js → chunk-dphhs29v.js} +6 -6
- package/dist/chunk-dt0deg4z.js +2 -0
- package/dist/{chunk-jgk5j35w.js → chunk-dvh63p75.js} +4 -4
- package/dist/{chunk-932zx5q4.js → chunk-dxk5r71v.js} +6 -6
- package/dist/{chunk-d96xddt9.js → chunk-e1e5xf8z.js} +13 -13
- package/dist/{chunk-w2pch5xn.js → chunk-e645nk33.js} +2 -2
- package/dist/{chunk-qpb80r4b.js → chunk-efr9dgt6.js} +2 -2
- package/dist/chunk-ejqr5cva.js +2 -0
- package/dist/{chunk-fxmc5006.js → chunk-et831a4y.js} +2 -2
- package/dist/{chunk-5yhv5eqq.js → chunk-ev4zxhpd.js} +2 -2
- package/dist/chunk-evbxyw80.js +2 -0
- package/dist/chunk-f66n66c8.js +2 -0
- package/dist/chunk-f6h8yagj.js +2 -0
- package/dist/{chunk-y8pftjg8.js → chunk-fjbhtakz.js} +1 -1
- package/dist/chunk-fpsm2qed.js +2 -0
- package/dist/{chunk-v1ff2dfp.js → chunk-fta169tc.js} +3 -3
- package/dist/{chunk-a222bwpc.js → chunk-ftt3r7wh.js} +5 -5
- package/dist/{chunk-48g9wez2.js → chunk-fz717vpc.js} +29 -29
- package/dist/chunk-fzf7yfpn.js +2 -0
- package/dist/chunk-gaatje2g.js +2 -0
- package/dist/{chunk-b0z2n941.js → chunk-h8yk9qm7.js} +2 -2
- package/dist/chunk-hfcmbbkq.js +2 -0
- package/dist/{chunk-3mz088mb.js → chunk-jb1c4e49.js} +2 -2
- package/dist/chunk-jhz0dvqz.js +2 -0
- package/dist/chunk-k54pgbzm.js +2 -0
- package/dist/{chunk-r8zhed35.js → chunk-kc3kt59e.js} +2 -2
- package/dist/chunk-kkx2gqk8.js +2 -0
- package/dist/{chunk-rqd6b2nc.js → chunk-knzp4c6m.js} +3 -3
- package/dist/{chunk-m3z13f59.js → chunk-kwy0spcd.js} +3 -3
- package/dist/{chunk-b7x8b83z.js → chunk-m15nbvck.js} +1 -1
- package/dist/{chunk-wby7qzha.js → chunk-m3dr63n0.js} +3 -3
- package/dist/{chunk-eb6p3p62.js → chunk-mdtjjzqc.js} +2 -2
- package/dist/{chunk-epa73jvs.js → chunk-mmcqgwk7.js} +2 -2
- package/dist/{chunk-02c46de1.js → chunk-mpaepc7n.js} +165 -42
- package/dist/{chunk-0kq0k4pg.js → chunk-n5dd6rpt.js} +2 -2
- package/dist/{chunk-jyp2mmts.js → chunk-n8gfetjx.js} +2 -2
- package/dist/chunk-n9zka6dg.js +2 -0
- package/dist/{chunk-bvctccab.js → chunk-nj5azxxj.js} +3 -3
- package/dist/{chunk-42zqmcnc.js → chunk-nr3pepv1.js} +3 -3
- package/dist/{chunk-r1tp2gnr.js → chunk-p42kp93g.js} +1 -1
- package/dist/{chunk-2zd51tj4.js → chunk-pqgk9mxp.js} +2 -2
- package/dist/chunk-pvx57vpw.js +2 -0
- package/dist/{chunk-fhpsf4z7.js → chunk-q22hwm64.js} +5 -5
- package/dist/chunk-qcz104h3.js +2 -0
- package/dist/chunk-qgvez75f.js +2 -0
- package/dist/{chunk-y4mp1rra.js → chunk-qv2k0qb1.js} +94 -94
- package/dist/{chunk-k2ex94n8.js → chunk-qv99gqee.js} +1 -1
- package/dist/chunk-r0j6jkxc.js +2 -0
- package/dist/{chunk-ben8bjnk.js → chunk-rv0yth27.js} +4 -4
- package/dist/chunk-rzh4xgb4.js +2 -0
- package/dist/chunk-rzv9xcyp.js +2 -0
- package/dist/{chunk-4tgn1frg.js → chunk-s2py8kg7.js} +2 -2
- package/dist/chunk-s922mx0k.js +2 -0
- package/dist/{chunk-rd33qkfs.js → chunk-s9m2gfns.js} +7 -7
- package/dist/{chunk-xt034729.js → chunk-scq0h2cs.js} +6 -6
- package/dist/{chunk-ak93e1zz.js → chunk-stww901w.js} +5 -5
- package/dist/chunk-sy4wqxta.js +2 -0
- package/dist/chunk-szdm8wfn.js +2 -0
- package/dist/chunk-t424gvwc.js +2 -0
- package/dist/{chunk-yk456jp4.js → chunk-t6d7m4tf.js} +7 -7
- package/dist/{chunk-mdvtermb.js → chunk-t70s45hc.js} +2 -2
- package/dist/{chunk-dvpk4c1y.js → chunk-t8cgxk8w.js} +2 -2
- package/dist/{chunk-edhxg3rz.js → chunk-tqf8a258.js} +56 -56
- package/dist/{chunk-9k8ztdcc.js → chunk-vkpmemb1.js} +2 -2
- package/dist/chunk-vtvaa8y9.js +2 -0
- package/dist/chunk-vvj09a7b.js +2 -0
- package/dist/{chunk-rxm1mjkb.js → chunk-vvm38ysm.js} +1 -1
- package/dist/chunk-vwjy6491.js +2 -0
- package/dist/{chunk-736ex6r5.js → chunk-vy1weqvj.js} +4 -4
- package/dist/chunk-w2nzevn0.js +2 -0
- package/dist/chunk-wadp2rmj.js +2 -0
- package/dist/{chunk-k9247v28.js → chunk-wb2ej5by.js} +1 -1
- package/dist/chunk-wbkcwj27.js +2 -0
- package/dist/{chunk-2typf9dh.js → chunk-wp4nqnn7.js} +1 -1
- package/dist/chunk-wzp8y0a4.js +2 -0
- package/dist/chunk-xc1he6hs.js +2 -0
- package/dist/{chunk-m6rzsbas.js → chunk-xcstrdhp.js} +4 -4
- package/dist/{chunk-cdcrd33m.js → chunk-ysfeg3cn.js} +2 -2
- package/dist/chunk-ytzzth34.js +2 -0
- package/dist/{chunk-xgnmgjpv.js → chunk-z6sg0dq3.js} +4 -4
- package/dist/{chunk-k9wr8xf5.js → chunk-zfaa5xn5.js} +6 -6
- package/dist/chunk-zhxg6b64.js +2 -0
- package/dist/{chunk-rha8sv1h.js → chunk-zjar9jdd.js} +2 -2
- package/dist/{chunk-89801pjp.js → chunk-zs8yjtaz.js} +5 -5
- package/dist/{chunk-q3azy64b.js → chunk-ztbk9yqv.js} +4 -4
- package/dist/cli.js +19 -19
- package/dist/client/signals-bootstrap-runtime.js +1 -1
- package/dist/client/signals-class-runtime.js +5 -5
- package/dist/client/signals-dom-ready-runtime.js +1 -0
- package/dist/client/signals-expression-runtime.js +118 -0
- package/dist/client/signals-for-runtime.js +7 -7
- package/dist/client/signals-if-chain-runtime.js +3 -3
- package/dist/client/signals-if-runtime.js +7 -7
- package/dist/client/signals-model-runtime.js +1 -1
- package/dist/client/signals-process-element-runtime.js +12 -8
- package/dist/client/signals-show-runtime.js +1 -1
- package/dist/client/signals-style-runtime.js +1 -1
- package/dist/composables/index.d.ts +2 -0
- package/dist/composables/index.js +1 -0
- package/dist/composables/use-virtual-list.d.ts +24 -0
- package/dist/composables/use-virtual-list.js +76 -0
- package/dist/config.js +3 -0
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/document-shell.d.ts +10 -1
- package/dist/document-shell.js +1 -1
- package/dist/expressions.js +19 -0
- package/dist/index.d.ts +1 -1
- package/dist/native/compiler/render-screen.d.ts +2 -8
- package/dist/native/compiler/render-screen.js +3 -10
- package/dist/native/event-names.js +2 -0
- package/dist/native/primitives-dir.d.ts +13 -0
- package/dist/native/primitives-dir.js +14 -0
- package/dist/native/prop-names.js +1 -0
- package/dist/process.js +1 -1
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +8 -8
- package/dist/state-management.d.ts +22 -0
- package/dist/types/config-types.d.ts +2 -0
- package/dist/unresolved-identifiers.js +1 -0
- package/dist/utils.js +20 -2
- package/package.json +5 -5
- package/stx.d.ts +4 -0
- package/dist/chunk-00nz3pas.js +0 -2
- package/dist/chunk-05jdq9tw.js +0 -177
- package/dist/chunk-0cajfv7y.js +0 -2
- package/dist/chunk-13v3vgb6.js +0 -2
- package/dist/chunk-1p8t2ekg.js +0 -2
- package/dist/chunk-1rcntvgx.js +0 -2
- package/dist/chunk-1w5gtkd6.js +0 -2
- package/dist/chunk-28vtqwxh.js +0 -2
- package/dist/chunk-298gj90a.js +0 -2
- package/dist/chunk-2gn6smrq.js +0 -2
- package/dist/chunk-2wq0h5ye.js +0 -2
- package/dist/chunk-3wxb7mfb.js +0 -2
- package/dist/chunk-528cn6qm.js +0 -2
- package/dist/chunk-5x0g7e9y.js +0 -2
- package/dist/chunk-633a53wg.js +0 -2
- package/dist/chunk-6b737vch.js +0 -2
- package/dist/chunk-72ns4q88.js +0 -2
- package/dist/chunk-86cg9qqm.js +0 -2
- package/dist/chunk-8czxtjwm.js +0 -2
- package/dist/chunk-8h5mqs28.js +0 -2
- package/dist/chunk-940wny2b.js +0 -2
- package/dist/chunk-9fh4ah7t.js +0 -2
- package/dist/chunk-a81rt2t4.js +0 -3
- package/dist/chunk-ad9dt9rk.js +0 -2
- package/dist/chunk-ak4w2emd.js +0 -2
- package/dist/chunk-b8dtz3v8.js +0 -2
- package/dist/chunk-cenvzm5q.js +0 -2
- package/dist/chunk-d49pst1m.js +0 -2
- package/dist/chunk-dj0qy19b.js +0 -2
- package/dist/chunk-e2q79dfs.js +0 -2
- package/dist/chunk-ebxncrd8.js +0 -2
- package/dist/chunk-fht1zs1r.js +0 -2
- package/dist/chunk-fjfrgef4.js +0 -2
- package/dist/chunk-fmk9hjht.js +0 -2
- package/dist/chunk-fxnk5ee8.js +0 -2
- package/dist/chunk-j1z7tgdp.js +0 -2
- package/dist/chunk-jq1698j4.js +0 -2
- package/dist/chunk-k0jkpw0q.js +0 -2
- package/dist/chunk-k469ym7a.js +0 -2
- package/dist/chunk-m5740sd3.js +0 -2
- package/dist/chunk-mdw96yhg.js +0 -2
- package/dist/chunk-mebf9vwb.js +0 -2
- package/dist/chunk-p2se8s6r.js +0 -2
- package/dist/chunk-p7zrz0wb.js +0 -2
- package/dist/chunk-pdnyfk2v.js +0 -2
- package/dist/chunk-qfhjtz2q.js +0 -2
- package/dist/chunk-r5tsewzd.js +0 -2
- package/dist/chunk-rnvrtcz6.js +0 -2
- package/dist/chunk-s36cpnxa.js +0 -2
- package/dist/chunk-tfy1m821.js +0 -2
- package/dist/chunk-vc3ppphz.js +0 -2
- package/dist/chunk-vttx66q0.js +0 -2
- package/dist/chunk-vxs07119.js +0 -2
- package/dist/chunk-x1x69g3s.js +0 -2
- package/dist/chunk-x8hz5gzb.js +0 -2
- package/dist/chunk-xfdtym3s.js +0 -2
- package/dist/chunk-y6mqq78g.js +0 -2
- package/dist/chunk-ycttwgpg.js +0 -2
- package/dist/chunk-yd6x9226.js +0 -2
- package/dist/chunk-yn3kff5k.js +0 -2
- package/dist/chunk-ynjm2tm0.js +0 -2
- package/dist/chunk-zpjdp0he.js +0 -2
package/dist/craft.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{bo,ma,ha}from"./chunk-6jnrpnxb.js";import"./chunk-fz717vpc.js";import"./chunk-1w4a0xya.js";import"./chunk-07c8rk93.js";import"./chunk-4833k99b.js";import"./chunk-qv2k0qb1.js";import"./chunk-1g5fg1ys.js";import"./chunk-t8cgxk8w.js";import"./chunk-c1b481my.js";import"./chunk-8hanmv49.js";import"./chunk-tqf8a258.js";import"./chunk-ay02q27h.js";import"./chunk-ztbk9yqv.js";import"./chunk-b8hsvzqb.js";import"./chunk-s9m2gfns.js";import"./chunk-7aw9qm74.js";import"./chunk-z6sg0dq3.js";import"./chunk-49w4cbqb.js";import"./chunk-t6d7m4tf.js";import"./chunk-kwy0spcd.js";import"./chunk-h8yk9qm7.js";import"./chunk-kc3kt59e.js";import{lu,ya,uh,dh,ba,wo,Jr,wa,va,ph,fh,xa,Sa,ka,_a}from"./chunk-e1e5xf8z.js";import"./chunk-xcstrdhp.js";import"./chunk-6ch8t3d9.js";import"./chunk-vkpmemb1.js";import"./chunk-dxk5r71v.js";import"./chunk-qv99gqee.js";import"./chunk-knzp4c6m.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{lu as CRAFT_BRIDGE_SCRIPT,wo as CRAFT_COMPONENTS,wa as CRAFT_COMPONENT_RUNTIME,Jr as CRAFT_COMPONENT_STYLES,bo as NATIVE_COMPONENTS,xa as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,ma as compileToNative,ha as createHotReloadServer,Sa as findCraftBinary,ya as generateCraftBridgeScript,V as generateCraftOptimizations,_a as getAvailableFormats,ka as getAvailableTargets,fh as getCraftComponents,G as getSSRCacheStats,ba as injectCraftBridge,uh as isCraftEnvironment,Y as prerenderForCraft,va as processCraftComponents,dh as processCraftDirective,ph as registerCraftComponent,Q as renderSSR};
|
package/dist/document-shell.d.ts
CHANGED
|
@@ -165,6 +165,15 @@ export declare function injectConfigHeadTags(html: string, headConfig?: AppHeadC
|
|
|
165
165
|
* so runtime `useHead` tags aren't double-emitted).
|
|
166
166
|
*/
|
|
167
167
|
export declare function ensureDocumentShell(html: string, headConfig?: AppHeadConfig, options?: Parameters<typeof generateDocumentShell>[2], alreadyHasShell?: boolean): string;
|
|
168
|
+
/**
|
|
169
|
+
* A component's root is wrapped in `<div data-stx-component-wrapper>` to carry
|
|
170
|
+
* its scope. The wrapper is bookkeeping, not layout: as a grid or flex item it
|
|
171
|
+
* took the track and broke `grid-template-columns` and `.parent > .child`
|
|
172
|
+
* selectors, so it generates no box of its own. A deferred island
|
|
173
|
+
* (`stx-hydrate`) keeps one, because its visibility trigger observes it and an
|
|
174
|
+
* element with no box never intersects.
|
|
175
|
+
*/
|
|
176
|
+
export declare const COMPONENT_WRAPPER_RULE: '[data-stx-component-wrapper]:not([stx-hydrate]){display:contents}';
|
|
168
177
|
/**
|
|
169
178
|
* Inline x-cloak rule shipped in the SSR <head> (stacksjs/stx#1736).
|
|
170
179
|
*
|
|
@@ -176,7 +185,7 @@ export declare function ensureDocumentShell(html: string, headConfig?: AppHeadCo
|
|
|
176
185
|
* belt-and-suspenders for SPA-nav fragments that arrive without SSR head
|
|
177
186
|
* emission.
|
|
178
187
|
*/
|
|
179
|
-
export declare const CLOAK_STYLE:
|
|
188
|
+
export declare const CLOAK_STYLE: string;
|
|
180
189
|
/**
|
|
181
190
|
* Markers recording which `<html>` attributes stx itself wrote from `htmlAttrs`
|
|
182
191
|
* (stacksjs/stx#1798).
|
package/dist/document-shell.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { generateColorModeBootScript } from "./color-mode-boot.js";
|
|
2
|
-
export const CLOAK_STYLE =
|
|
2
|
+
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";
|
|
3
3
|
const SAFE_ATTR_NAME = /^[A-Za-z_:][\w:.-]*$/;
|
|
4
4
|
function escapeAttr(value) {
|
|
5
5
|
return String(value).replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
package/dist/expressions.js
CHANGED
|
@@ -260,6 +260,23 @@ export function replaceInterpolations(input, replacer, braces = 2) {
|
|
|
260
260
|
}
|
|
261
261
|
return cursor === 0 ? input : output + input.slice(cursor);
|
|
262
262
|
}
|
|
263
|
+
function isBraceLiteralInBinding(source, offset, expr) {
|
|
264
|
+
const quote = expr[0];
|
|
265
|
+
if (quote !== "'" && quote !== '"' && quote !== "`")
|
|
266
|
+
return !1;
|
|
267
|
+
const context = classifyHtmlInterpolation(source, offset);
|
|
268
|
+
if (!context || context.kind !== "attribute" || context.quote === quote)
|
|
269
|
+
return !1;
|
|
270
|
+
if (!/^(?::|@|x-|v-)/.test(context.name))
|
|
271
|
+
return !1;
|
|
272
|
+
let count = 0;
|
|
273
|
+
for (let i = 0;i < context.valuePrefix.length; i++)
|
|
274
|
+
if (context.valuePrefix[i] === "\\")
|
|
275
|
+
i++;
|
|
276
|
+
else if (context.valuePrefix[i] === quote)
|
|
277
|
+
count++;
|
|
278
|
+
return count % 2 === 1;
|
|
279
|
+
}
|
|
263
280
|
export function escapeHtml(unsafe) {
|
|
264
281
|
return unsafe.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
265
282
|
}
|
|
@@ -592,6 +609,8 @@ export function processExpressions(template, context, filePath) {
|
|
|
592
609
|
})), enclosingLoopNames = new Set(inheritedClientLoopNames(context));
|
|
593
610
|
output = replaceInterpolations(output, (match, expr, offset) => {
|
|
594
611
|
const trimmedExpr = expr.trim();
|
|
612
|
+
if (isBraceLiteralInBinding(output, offset, expr))
|
|
613
|
+
return match;
|
|
595
614
|
if (readsEnclosingLoopVariable(slotScopes, offset, trimmedExpr))
|
|
596
615
|
return match;
|
|
597
616
|
if (readsAnyName(trimmedExpr, enclosingLoopNames))
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export type { RuntimeConfigDefaults, PublicRuntimeConfig } from './runtime-config-types';
|
|
3
3
|
export type { ServerApiOptions, ServerApiRoute } from './server-api';
|
|
4
4
|
export type { ApiHandlerContext } from './api-handler';
|
|
5
|
-
export type { Store, StoreOptions, PersistOptions, DefineStoreOptions } from './state-management';
|
|
5
|
+
export type { Store, StoreOptions, StoreRegistry, PersistOptions, DefineStoreOptions } from './state-management';
|
|
6
6
|
export type { StxComponentInstance, EmitFn } from './composition-api';
|
|
7
7
|
export type { ModelSignal, ModelOptions, ModelModifiers } from './component-model';
|
|
8
8
|
export type { VNode } from './jsx-runtime';
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
+
import { nativePrimitivesDir } from '../primitives-dir';
|
|
1
2
|
import { type BindingManifest } from '../../binding-manifest';
|
|
2
3
|
import { type GeneratedSetupScript, type NativeClientScript } from './setup-script';
|
|
3
4
|
import type { STXDocument } from './ir';
|
|
4
5
|
import type { TranslationDiagnostic } from './html-to-ir';
|
|
5
|
-
/**
|
|
6
|
-
* Where the native primitive components live, for an app's stx config.
|
|
7
|
-
*
|
|
8
|
-
* Resolved by looking, because the answer differs between running from source,
|
|
9
|
-
* the per-module build and the bundled CLI. A path that is merely plausible
|
|
10
|
-
* would fail only in the built binary, which is the one users run.
|
|
11
|
-
*/
|
|
12
|
-
export declare function nativePrimitivesDir(): string;
|
|
13
6
|
/**
|
|
14
7
|
* Render a screen's source with stx and translate it to the native IR.
|
|
15
8
|
*/
|
|
@@ -30,3 +23,4 @@ export declare interface CompiledScreen {
|
|
|
30
23
|
diagnostics: TranslationDiagnostic[]
|
|
31
24
|
html: string
|
|
32
25
|
}
|
|
26
|
+
export { nativePrimitivesDir };
|
|
@@ -6,19 +6,12 @@ import { processDirectives } from "../../process.js";
|
|
|
6
6
|
import { processScriptSetup } from "../../signal-processing.js";
|
|
7
7
|
import { appThemeCSS } from "./app-theme.js";
|
|
8
8
|
import { excludeNativeSubtrees, translateHtmlToDocument } from "./html-to-ir.js";
|
|
9
|
+
import { nativePrimitivesDir } from "../primitives-dir.js";
|
|
9
10
|
import { extractClientScript } from "./client-script.js";
|
|
10
11
|
import { extractLayoutChrome } from "./layout-chrome.js";
|
|
11
12
|
import { extractGeneratedSetupScript, extractNativeClientScripts } from "./setup-script.js";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
path.join(import.meta.dir, "..", "primitives"),
|
|
15
|
-
path.join(import.meta.dir, "native", "primitives")
|
|
16
|
-
];
|
|
17
|
-
for (const candidate of candidates)
|
|
18
|
-
if (existsSync(path.join(candidate, "View.stx")))
|
|
19
|
-
return candidate;
|
|
20
|
-
return candidates[0];
|
|
21
|
-
}
|
|
13
|
+
|
|
14
|
+
export { nativePrimitivesDir };
|
|
22
15
|
export async function compileScreenSource(source, filePath, options = {}) {
|
|
23
16
|
source = await excludeNativeSubtrees(source);
|
|
24
17
|
const root = options.root ?? path.dirname(filePath), loaded = await loadStxConfig(root), sourceRoot = typeof loaded.root === "string" && loaded.root ? path.resolve(root, loaded.root) : root, fromRoot = (dir, fallback) => dir ? path.isAbsolute(dir) ? dir : path.resolve(sourceRoot, dir) : path.join(sourceRoot, fallback), config = {
|
|
@@ -21,6 +21,8 @@ export const NATIVE_EVENT_NAMES = {
|
|
|
21
21
|
submit: "onSubmitEditing",
|
|
22
22
|
"submit-editing": "onSubmitEditing",
|
|
23
23
|
submitediting: "onSubmitEditing",
|
|
24
|
+
"accept-completion": "onAcceptCompletion",
|
|
25
|
+
acceptcompletion: "onAcceptCompletion",
|
|
24
26
|
"end-editing": "onEndEditing",
|
|
25
27
|
endediting: "onEndEditing",
|
|
26
28
|
scroll: "onScroll",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the native primitive components (`View`, `Text`, `Button`, ...) live.
|
|
3
|
+
*
|
|
4
|
+
* Resolved by looking, because the answer differs between running from source,
|
|
5
|
+
* the per-module build and the bundled CLI. A path that is merely plausible
|
|
6
|
+
* would fail only in the built binary, which is the one users run.
|
|
7
|
+
*
|
|
8
|
+
* Both render targets use it: a native screen resolves primitives ahead of the
|
|
9
|
+
* convention directories, and the web server resolves them last, so a page
|
|
10
|
+
* written with `<View>` and `<Text>` renders as plain HTML where the app has
|
|
11
|
+
* not defined a component of that name.
|
|
12
|
+
*/
|
|
13
|
+
export declare function nativePrimitivesDir(): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
export function nativePrimitivesDir() {
|
|
4
|
+
const candidates = [
|
|
5
|
+
path.join(import.meta.dir, "primitives"),
|
|
6
|
+
path.join(import.meta.dir, "..", "primitives"),
|
|
7
|
+
path.join(import.meta.dir, "native", "primitives"),
|
|
8
|
+
path.join(import.meta.dir, "..", "native", "primitives")
|
|
9
|
+
];
|
|
10
|
+
for (const candidate of candidates)
|
|
11
|
+
if (existsSync(path.join(candidate, "View.stx")))
|
|
12
|
+
return candidate;
|
|
13
|
+
return candidates[0];
|
|
14
|
+
}
|
package/dist/process.js
CHANGED
|
@@ -639,7 +639,7 @@ ${joined}` : joined;
|
|
|
639
639
|
}, available = [
|
|
640
640
|
...layoutsIn(resolvedOptions.layoutsDir),
|
|
641
641
|
...layoutsIn(resolvedOptions.fallbackLayoutsDir)
|
|
642
|
-
].filter((name, index, all) => all.indexOf(name) === index).sort(), warning = `Layout not found: ${layoutPath} (referenced from ${filePath})` + (available.length > 0 ? `. Available layouts: ${available.join(", ")}` : resolvedOptions.layoutsDir ? `. No .stx layouts found in ${resolvedOptions.layoutsDir}` : "");
|
|
642
|
+
].filter((name, index, all) => all.indexOf(name) === index).sort(), searched = [resolvedOptions.layoutsDir, resolvedOptions.fallbackLayoutsDir].filter((dir) => typeof dir === "string" && dir.length > 0), searchedNote = searched.length > 0 ? ` Searched: ${searched.join(", ")} (set \`layoutsDir\` to look elsewhere).` : "", warning = `Layout not found: ${layoutPath} (referenced from ${filePath})` + (available.length > 0 ? `. Available layouts: ${available.join(", ")}` : resolvedOptions.layoutsDir ? `. No .stx layouts found in ${resolvedOptions.layoutsDir}` : "") + searchedNote;
|
|
643
643
|
errorLogger.log(Error(warning), { layoutPath, filePath, available }, "error");
|
|
644
644
|
console.error(`[stx] ${warning}`);
|
|
645
645
|
if (resolvedOptions.debug)
|
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{Js,zt,yl,wg}from"./chunk-dvh63p75.js";import{Gs,$i,hg,yg,bg}from"./chunk-74y29xxs.js";import{gl,ml,hl,gg,mg}from"./chunk-mdtjjzqc.js";import{Ue,En,Ri}from"./chunk-ev4zxhpd.js";import{vg,xg,Sg,kg,Ys,oy}from"./chunk-et831a4y.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-b8ar6431.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=Ue(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=Ue(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=Js(n,t);if(a){let s=zt(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 $i(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,ml as auditBuildOutput,gl as auditConfig,re as buildPwaAssets,hl as calculateAuditResult,mg as formatAuditResult,Ri as formatSize,j as generateManifest,_ as generateManifestJson,yg as generateManifestLink,F as generateOfflinePage,Ue as generatePrecacheManifest,En as generatePrecacheManifestJs,M as generatePwaIcons,Gs as generatePwaTags,Js as generateServiceWorker,wg as generateServiceWorkerAuto,hg as generateSwRegistrationScript,bg as generateThemeColorMeta,N as getExpectedIconPaths,zt as getServiceWorkerFileName,$i as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,yl as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,Ys as pwaDirectives,vg as pwaInstallDirective,Sg as pwaOfflineDirective,kg as pwaPushDirective,xg as pwaUpdateDirective,oy as registerPwaDirectives,gg as runPwaAudit,D as validateManifest};
|
package/dist/ssg.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-wmnzapn8.js";import{w,
|
|
3
|
-
`)}function
|
|
2
|
+
import"./chunk-wmnzapn8.js";import{w,Zc}from"./chunk-1w4a0xya.js";import"./chunk-07c8rk93.js";import"./chunk-4833k99b.js";import{$t,S}from"./chunk-qv2k0qb1.js";import"./chunk-1g5fg1ys.js";import"./chunk-t8cgxk8w.js";import"./chunk-c1b481my.js";import{St,kt,_t,Ct,Et,Tt}from"./chunk-8hanmv49.js";import{a}from"./chunk-tqf8a258.js";import{ks}from"./chunk-ay02q27h.js";import"./chunk-ztbk9yqv.js";import"./chunk-c5mbhfff.js";import{he,Qt,en}from"./chunk-rv0yth27.js";import"./chunk-b8hsvzqb.js";import{y}from"./chunk-s9m2gfns.js";import{ht,i}from"./chunk-7aw9qm74.js";import"./chunk-z6sg0dq3.js";import"./chunk-49w4cbqb.js";import{ls}from"./chunk-t6d7m4tf.js";import"./chunk-kwy0spcd.js";import"./chunk-h8yk9qm7.js";import{Ka,Xa,Ga}from"./chunk-7yx2ztt5.js";import{Yt,Jn,Yn}from"./chunk-wwnqbv9j.js";import{Zt}from"./chunk-vvm38ysm.js";import"./chunk-6ch8t3d9.js";import"./chunk-vkpmemb1.js";import{X,we}from"./chunk-dxk5r71v.js";import"./chunk-qv99gqee.js";import"./chunk-knzp4c6m.js";import{l}from"./chunk-s2py8kg7.js";import{s,ge}from"./chunk-nr3pepv1.js";import D from"fs";import f from"path";import{createHash as Pt}from"crypto";function Dt(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var Rt=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function It(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(Rt,(e,u,g,v)=>{let x=v.trim();if(!x)return e;if(/\bdata-stx-src=/.test(g))return e;if(r.minify)x=Dt(x);let p=It(x);if(!n.has(p))n.set(p,x);let P=r.integrity?` data-stx-integrity="sha384-${Pt("sha384").update(x).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${u}" data-stx-src="/_stx/islands/${p}.js"${P}${g}></script>`}),c=Array.from(n,([e,u])=>({hash:e,code:u}));return{html:o,chunks:c}}var Bt=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 c=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,u;while((u=e.exec(t))!==null)if(Bt.has(r.get(u[1])||""))c.add(u[2]);let g=/<\/head\s*>/iy,v=S(t,(p,P)=>(g.lastIndex=P,g.exec(p)?g.lastIndex:-1))[0]?.start??-1;if(c.size===0||v===-1)return t;let x=Array.from(c).filter((p)=>!t.includes(`rel="prefetch" href="${p}"`)).map((p)=>`<link rel="prefetch" href="${p}" as="script">`).join("");if(!x)return t;return t.slice(0,v)+x+t.slice(v)}var jt=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function K(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 Ft(t){for(let r of jt){let n=t[r];if(!n)continue;let o=K(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"?K(n):null}async function At(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 c=n.resolve(t,o);if(!r(c))continue;try{let e=await import(c),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=K(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 c=await At(r);if(c)return{url:c,source:"site.config",via:"url"};let e=Ft(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 q(t){return async()=>({paths:await t(),fallback:!1})}var Ot;function Lt(t){let r=s(t),{depths:n}=ge(r),o=/\b(?:async\s+)?function\s+getStaticPaths\s*\(/g,c;while((c=o.exec(r))!==null){if(n[c.index]!==0)continue;let u=w(r,"(",")",o.lastIndex-1),g=r.indexOf("{",u+1),v=w(r,"{","}",g);if(u<0||g<0||v<0)break;return t.slice(c.index,v+1)}let e=/\b(?:const|let|var)\s+getStaticPaths\s*=/g;while((c=e.exec(r))!==null){if(n[c.index]!==0)continue;let u=Zc(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=Zt(n),c=[...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 c){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))&&$t(u,"defineStaticPaths"))throw SyntaxError("Cannot evaluate a module-local defineStaticPaths binding during isolated hook extraction");r="execute";let v=Function("defineStaticPaths",`return (${g})`)(q);if(typeof v!=="function")throw TypeError("getStaticPaths must be a function");let x=await v();r="result";let p=Array.isArray(x)?{paths:x}:x;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 c=0;for(let e=0;e<o.length;e++){let u=o.charCodeAt(e);c=(c<<5)-c+u,c=c&c}return Math.abs(c).toString(36)}get(t,r){let n=this.cache.get(t);if(!n)return null;let o=mt(r).some((u)=>D.existsSync(u)),c=[r,...n.dependencies??[]].some((u)=>u.endsWith(".stx")&&D.existsSync(u)&&ls(D.readFileSync(u,"utf8")).some((g)=>/\bserver\b/.test(g.attrs)));if(o||c)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 c=this.getHash(r,n);this.cache.set(t,{hash:c,html:o,generatedAt:Date.now(),dependencies:n})}}class ft{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 c=o.replace(/_/g,"/").replace(".json","");if(t.test(c))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 c of o.paths){let e=t.pattern;for(let[u,g]of Object.entries(c.params))e=e.replace(`:${u}`,g).replace(`:${u}*`,g);r.push({url:e,params:c.params,props:c.props,revalidate:c.revalidate})}}return r}function mt(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 mt(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,...c}=n;return c}}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 c=o[1];if(!c.includes("getStaticProps"))return null;try{let e=c.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,16 +37,16 @@ ${t.map((o)=>{let c=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();en();let n=await a(process.cwd()),o=n.build||{},c=await ut({explicit:t.domain||o.domain,stxConfig:n});if(c.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:c.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||l(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,x={},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-
|
|
40
|
+
</rss>`}async function Vt(t={}){let r=Date.now();en();let n=await a(process.cwd()),o=n.build||{},c=await ut({explicit:t.domain||o.domain,stxConfig:n});if(c.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:c.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||l(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,x={},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-c5kpc7rn.js");try{E=m(await d(process.cwd()))}catch{}}let{prepareImageDelivery:b}=await import("./chunk-qcz104h3.js"),R=await b(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 T=new pt(e.cacheDir,E);if(e.cache)await T.load();try{let{generateCss:d}=await import("./chunk-c5kpc7rn.js");await d('<div class="bg-black"></div>')}catch{}St();let yt=n?.routeMiddleware?.dir||"middleware";await _t(process.cwd(),yt);let J=kt();if(J.length>0)console.log(`Loaded ${J.length} middleware: ${J.join(", ")}`);let xt=n?.routeMiddleware?.global||[];Ga(n?.layoutsDir,l(process.cwd()));let Z=X(".",{pagesDir:e.pagesDir,pagesDirs:n?._layerPageDirs});console.log(`Found ${Z.length} routes`);let M=[];for(let d of Z)try{let m=await Ut(d);for(let k of m)M.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=M.length+u.failedCount,console.log(`Generating ${M.length} pages...`);let _=[],Q=[];for(let d=0;d<M.length;d+=e.concurrency)Q.push(M.slice(d,d+e.concurrency));for(let d of Q)await Promise.all(d.map(async(m)=>{let{route:k,url:h,params:G,props:bt,revalidate:rt}=m;try{await e.hooks.onPageStart?.(h);let A=await Bun.file(k.filePath).text(),O=te(A),vt=O?.middleware?Array.isArray(O.middleware)?O.middleware:[O.middleware]:[],nt=[...xt,...vt];if(nt.length>0){let B=Ct(h,G,O||{}),L=Et(B,null,void 0,{isServer:!0}),j=await Tt(nt,L);if(j.redirect){let C=typeof j.redirect==="string"?j.redirect:j.redirect.path||j.redirect,H=ee(String(C),h),U=re(h,e);await D.promises.mkdir(f.dirname(U),{recursive:!0}),await Bun.write(U,H),u.successCount++,u.pages.push({route:h,outputPath:U,size:Buffer.byteLength(H),cached:!1}),_.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=A.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(it)try{if(!await Function("route",`
|
|
41
41
|
const validate = ${it[1]};
|
|
42
42
|
return validate(route);
|
|
43
|
-
`)({params:
|
|
43
|
+
`)({params:G})){console.warn(`Validation failed for ${h}, skipping...`);return}}catch{}let I=null,st=!1;if(e.cache){if(I=T.get(h,k.filePath),I)st=!0,u.cachedCount++}if(!I){let B=await wt(k,G,bt,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:
|
|
44
44
|
${B.includeFailures.join(`
|
|
45
45
|
`)}
|
|
46
46
|
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:
|
|
47
47
|
${B.serverScriptFailures.join(`
|
|
48
48
|
`)}
|
|
49
|
-
Set ssg.failOnServerScriptError to false to build anyway.`);if(e.cache)T.set(h,k.filePath,B.dependencies,I)}let
|
|
49
|
+
Set ssg.failOnServerScriptError to false to build anyway.`);if(e.cache)T.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:L}=ot(I,{integrity:e.integrityIslands,minify:e.minify});if(L.length>0){let j=f.join(e.outputDir,"_stx","islands");await D.promises.mkdir(j,{recursive:!0});for(let C of L){let H=f.join(j,`${C.hash}.js`);if(!await Bun.file(H).exists())await Bun.write(H,C.code);if(!g.has(C.hash)){g.add(C.hash);let U=Buffer.byteLength(C.code,"utf8");v+=U,x[C.hash]={bytes:U,file:`/_stx/islands/${C.hash}.js`}}}if(p[h]=L.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,O,e.sitemapExclude))_.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(A){u.failedCount++,u.errors.push({route:h,error:A}),await e.hooks.onError?.(A,h),console.error(`Error generating ${h}:`,A)}}));let tt=Qt();if(tt.length>0){let d=tt.map((m)=>`${m.filePath}: ${m.message}`).join(`
|
|
50
50
|
`);throw Error(`Client script bundling failed:
|
|
51
51
|
${d}`)}if(e.cache)await T.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>
|
|
52
52
|
<html lang="en">
|
|
@@ -69,7 +69,7 @@ ${d}`)}if(e.cache)await T.save();if(e.generate404){let d=f.join(e.pagesDir,"404.
|
|
|
69
69
|
<a href="/">Go home</a>
|
|
70
70
|
</div>
|
|
71
71
|
</body>
|
|
72
|
-
</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},
|
|
72
|
+
</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},G=await i(await Bun.file(m).text(),{},m,h,k);await Bun.write(f.join(e.outputDir,`${d}.html`),G)}}let V=f.join(e.pagesDir,"error.stx");if(await Bun.file(V).exists()){let d=new Set,m={...n,minifyClient:!0,debug:!1,cache:!1},k=await i(await Bun.file(V).text(),{},V,m,d);await Bun.write(f.join(e.outputDir,"error.html"),k)}if(e.sitemap&&_.length>0){let d=qt(_,e.domain),m=f.join(e.outputDir,"sitemap.xml");await Bun.write(m,d),u.sitemapPath=m,console.log(`Generated sitemap.xml with ${_.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=ks({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 z=Ka(e.outputDir);if(z.assets>0)console.log(`Externalized ${z.assets} asset(s) from ${z.pages} page(s) (${(z.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);let W=Xa(e.outputDir);if(W.assets>0)console.log(`Externalized ${W.assets} repeated asset(s) from ${W.pages} page(s) (${(W.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=Yn();if(et)await Y(et,f.join(e.outputDir,Jn)),console.log(`Copied assets from ${Yt}`)}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:x,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?`
|
|
73
73
|
Island chunks: ${u.islandChunks.count} (${(u.islandChunks.totalBytes/1024).toFixed(1)} KB lifted out of inline HTML)`:"";return console.log(`
|
|
74
74
|
Build complete!
|
|
75
75
|
Total: ${u.totalPages} pages
|
|
@@ -77,7 +77,7 @@ Build complete!
|
|
|
77
77
|
Cached: ${u.cachedCount}
|
|
78
78
|
Failed: ${u.failedCount}
|
|
79
79
|
Time: ${u.buildTime}ms${P}
|
|
80
|
-
`),u}async function Y(t,r){await D.promises.mkdir(r,{recursive:!0});let n=await D.promises.readdir(t,{withFileTypes:!0});for(let o of n){let c=f.join(t,o.name),e=f.join(r,o.name);if(o.isDirectory())await D.promises.mkdir(e,{recursive:!0}),await Y(c,e);else await D.promises.copyFile(c,e)}}function Kt(t={}){let r=t.cacheDir||l(process.cwd(),"ssg-cache"),n=new ft(r),o=t.revalidate||3600;return{async get(c){let e=await n.get(c);if(!e)return null;if(Date.now()>e.revalidateAfter)this.revalidate(c).catch(console.error);return{html:e.html,headers:{"Cache-Control":`public, max-age=${o}, stale-while-revalidate=${o*2}`,ETag:e.etag,"X-ISR-Generated":new Date(e.generatedAt).toISOString(),...e.headers}}},async revalidate(c){let u=
|
|
80
|
+
`),u}async function Y(t,r){await D.promises.mkdir(r,{recursive:!0});let n=await D.promises.readdir(t,{withFileTypes:!0});for(let o of n){let c=f.join(t,o.name),e=f.join(r,o.name);if(o.isDirectory())await D.promises.mkdir(e,{recursive:!0}),await Y(c,e);else await D.promises.copyFile(c,e)}}function Kt(t={}){let r=t.cacheDir||l(process.cwd(),"ssg-cache"),n=new ft(r),o=t.revalidate||3600;return{async get(c){let e=await n.get(c);if(!e)return null;if(Date.now()>e.revalidateAfter)this.revalidate(c).catch(console.error);return{html:e.html,headers:{"Cache-Control":`public, max-age=${o}, stale-while-revalidate=${o*2}`,ETag:e.etag,"X-ISR-Generated":new Date(e.generatedAt).toISOString(),...e.headers}}},async revalidate(c){let u=X(".",{pagesDir:t.pagesDir||"pages"}).find((P)=>c.match(P.regex)!==null);if(!u){console.warn(`Route not found for revalidation: ${c}`);return}let g=c.match(u.regex),v={};if(g)u.params.forEach((P,E)=>{v[P]=g[E+1]});let x=await a(),{html:p}=await wt(u,v,{},t,x);await n.set(c,{html:p,generatedAt:Date.now(),revalidateAfter:Date.now()+o*1000,etag:zt(p)}),console.log(`Revalidated: ${c}`)},async invalidate(c){if(typeof c==="string")await n.invalidate(c);else await n.invalidatePattern(c)}}}function Xt(){return{name:"markdown",extensions:[".md",".mdx"],async load(t){let r=await Bun.file(t).text(),n=r.match(/^---\n([\s\S]*?)\n---/),o={},c=r;if(n){let x=n[1];c=r.slice(n[0].length).trim();for(let p of x.split(`
|
|
81
81
|
`)){let P=p.indexOf(":");if(P>0){let E=p.slice(0,P).trim(),b=p.slice(P+1).trim();if(b==="true")b=!0;else if(b==="false")b=!1;else if(/^\d+$/.test(b))b=parseInt(b,10);else if(/^\d+\.\d+$/.test(b))b=parseFloat(b);else if(b.startsWith("[")&&b.endsWith("]"))b=b.slice(1,-1).split(",").map((R)=>R.trim().replace(/^['"]|['"]$/g,""));o[E]=b}}}let e=c.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*)\*\*/gim,"<strong>$1</strong>").replace(/\*(.*)\*/gim,"<em>$1</em>").replace(/`([^`]+)`/gim,"<code>$1</code>").replace(/\[([^\]]+)\]\(([^)]+)\)/gim,'<a href="$2">$1</a>').replace(/\n/gim,"<br>"),u=[],g=/<h([1-6])>([^<]+)<\/h[1-6]>/gi,v;while((v=g.exec(e))!==null){let x=parseInt(v[1],10),p=v[2],P=p.toLowerCase().replace(/[^a-z0-9]+/g,"-");u.push({id:P,text:p,level:x})}return{content:e,data:o,toc:u}}}}function te(t){return ht(t)}function ee(t,r){return`<!DOCTYPE html>
|
|
82
82
|
<html>
|
|
83
83
|
<head>
|
|
@@ -90,4 +90,4 @@ Build complete!
|
|
|
90
90
|
<p>Redirecting to <a href="${t}">${t}</a>...</p>
|
|
91
91
|
<script>window.location.replace('${t}')</script>
|
|
92
92
|
</body>
|
|
93
|
-
</html>`}function re(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 Ae={generateStaticSite:Vt,createISRHandler:Kt,defineStaticPaths:
|
|
93
|
+
</html>`}function re(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 Ae={generateStaticSite:Vt,createISRHandler:Kt,defineStaticPaths:q,createMarkdownLoader:Xt};export{Kt as createISRHandler,Xt as createMarkdownLoader,Nt as declaresPageAction,Ae as default,q as defineStaticPaths,Vt as generateStaticSite,Wt as isExcludedFromSitemap};
|
|
@@ -66,6 +66,7 @@ export declare function throttleMiddleware<T>(ms: number): StoreMiddleware<T>;
|
|
|
66
66
|
* Use a store in a template context.
|
|
67
67
|
* Returns a reactive reference that auto-updates.
|
|
68
68
|
*/
|
|
69
|
+
export declare function useStore<K extends keyof StoreRegistry>(name: K): StoreRegistry[K];
|
|
69
70
|
export declare function useStore<T>(nameOrStore: string | Store<T>): T;
|
|
70
71
|
/**
|
|
71
72
|
* Create a store directive for use in templates.
|
|
@@ -214,6 +215,27 @@ export declare function transformStoreImports(code: string): string;
|
|
|
214
215
|
* ```
|
|
215
216
|
*/
|
|
216
217
|
export declare function registerStoresClient(stores: Record<string, object>): void;
|
|
218
|
+
/**
|
|
219
|
+
* The stores of an app, by id. Empty here: an app fills it in, and
|
|
220
|
+
* `useStore('tasks')` is then typed as that store instead of `unknown`.
|
|
221
|
+
*
|
|
222
|
+
* ```ts
|
|
223
|
+
* // resources/stores/tasks.ts
|
|
224
|
+
* export const tasks = defineStore('tasks', () => ({ open: state<Todo[]>([]) }))
|
|
225
|
+
*
|
|
226
|
+
* // resources/stores/registry.d.ts
|
|
227
|
+
* declare module '@stacksjs/stx' {
|
|
228
|
+
* interface StoreRegistry { tasks: typeof import('./tasks').tasks }
|
|
229
|
+
* }
|
|
230
|
+
* ```
|
|
231
|
+
*
|
|
232
|
+
* Auto-imported `useStore` in `.stx` files reads the global `StxStoreRegistry`
|
|
233
|
+
* (declared in `stx.d.ts`) the same way: `declare global { interface
|
|
234
|
+
* StxStoreRegistry { tasks: ... } }`. An id the registry does not name still
|
|
235
|
+
* works, and returns `useStore<T>`'s `T`.
|
|
236
|
+
*/
|
|
237
|
+
// eslint-disable-next-line ts/no-empty-object-type
|
|
238
|
+
export declare interface StoreRegistry {}
|
|
217
239
|
/** Store options */
|
|
218
240
|
export declare interface StoreOptions<T> {
|
|
219
241
|
name?: string
|
|
@@ -304,6 +304,7 @@ export declare interface StxConfig {
|
|
|
304
304
|
componentsDir: string
|
|
305
305
|
_rootComponentsDir?: string
|
|
306
306
|
_targetComponentDirs?: string[]
|
|
307
|
+
_nativePrimitivesFallback?: { dir: string, except: string[] }
|
|
307
308
|
_targetComponentFallbackNames?: string[]
|
|
308
309
|
_nativeHostAttrs?: boolean
|
|
309
310
|
layoutsDir?: string
|
|
@@ -313,6 +314,7 @@ export declare interface StxConfig {
|
|
|
313
314
|
storesDir?: string
|
|
314
315
|
composablesDir?: string
|
|
315
316
|
defaultLayout?: string
|
|
317
|
+
nativePrimitives?: boolean
|
|
316
318
|
plugins?: Array<string | [string, Record<string, any>]>
|
|
317
319
|
componentPackages?: string[]
|
|
318
320
|
publicDir?: string
|
package/dist/utils.js
CHANGED
|
@@ -47,7 +47,16 @@ export {
|
|
|
47
47
|
extractVariables,
|
|
48
48
|
hasVariables
|
|
49
49
|
} from "./variable-extractor.js";
|
|
50
|
-
const componentsCache = new LRUCache(500),
|
|
50
|
+
const componentsCache = new LRUCache(500), componentStamps = new Map;
|
|
51
|
+
function fileStamp(filePath) {
|
|
52
|
+
try {
|
|
53
|
+
const stat = fs.statSync(filePath);
|
|
54
|
+
return `${stat.size}:${stat.mtimeMs}`;
|
|
55
|
+
} catch {
|
|
56
|
+
return "";
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const componentResolutionCache = new LRUCache(1000), userComponentFileCache = new LRUCache(2000), realDirCache = new LRUCache(500), COMPONENT_RENDER_CACHE_BYTES = 33554432;
|
|
51
60
|
let appliedComponentRenderCacheBytes = COMPONENT_RENDER_CACHE_BYTES;
|
|
52
61
|
function applyComponentRenderCacheBudget(options) {
|
|
53
62
|
const configured = options.componentRenderCacheBytes;
|
|
@@ -585,6 +594,9 @@ export async function userComponentFileExists(componentPath, componentsDir, pare
|
|
|
585
594
|
if (targetIsFallback)
|
|
586
595
|
for (const dir of options._targetComponentDirs ?? [])
|
|
587
596
|
push(dir);
|
|
597
|
+
const primitives = options._nativePrimitivesFallback;
|
|
598
|
+
if (primitives && !primitives.except.some((name) => name.toLowerCase() === baseName.toLowerCase()))
|
|
599
|
+
push(primitives.dir);
|
|
588
600
|
if (baseName.startsWith("./") || baseName.startsWith("../"))
|
|
589
601
|
return fileExists(path.resolve(path.dirname(parentFilePath), `${baseName}.stx`));
|
|
590
602
|
const ownComponentsDir = realDir(path.resolve(import.meta.dir, "components")), resolvedDirs = searchDirs.map((dir) => path.isAbsolute(dir) ? dir : path.resolve(resolveBase, dir)), key = `${variants.join("\x00")}\x00\x00${resolvedDirs.join("\x00")}`, known = userComponentFileCache.get(key);
|
|
@@ -752,6 +764,9 @@ export async function renderComponentWithSlot(componentPath, props, slotContent,
|
|
|
752
764
|
if (dir && !searchDirs.includes(dir))
|
|
753
765
|
searchDirs.push(dir);
|
|
754
766
|
}
|
|
767
|
+
const primitiveFallback = options._nativePrimitivesFallback;
|
|
768
|
+
if (primitiveFallback && !primitiveFallback.except.some((name) => name.toLowerCase() === baseName.toLowerCase()) && !searchDirs.includes(primitiveFallback.dir))
|
|
769
|
+
searchDirs.push(primitiveFallback.dir);
|
|
755
770
|
const normalizedSearchDirs = [...new Set(searchDirs.map((dir) => {
|
|
756
771
|
if (!dir)
|
|
757
772
|
return dir;
|
|
@@ -830,12 +845,14 @@ export async function renderComponentWithSlot(componentPath, props, slotContent,
|
|
|
830
845
|
}
|
|
831
846
|
dependencies.add(componentFilePath);
|
|
832
847
|
let componentContent;
|
|
833
|
-
if (componentsCache.has(componentFilePath))
|
|
848
|
+
if (componentsCache.has(componentFilePath) && componentStamps.get(componentFilePath) === fileStamp(componentFilePath))
|
|
834
849
|
componentContent = componentsCache.get(componentFilePath);
|
|
835
850
|
else
|
|
836
851
|
try {
|
|
852
|
+
const stamp = fileStamp(componentFilePath);
|
|
837
853
|
componentContent = await Bun.file(componentFilePath).text();
|
|
838
854
|
componentsCache.set(componentFilePath, componentContent);
|
|
855
|
+
componentStamps.set(componentFilePath, stamp);
|
|
839
856
|
} catch (error) {
|
|
840
857
|
const message = error instanceof Error ? error.message : String(error);
|
|
841
858
|
reportUnresolvedComponent(componentPath, parentFilePath, [componentFilePath], message);
|
|
@@ -1402,6 +1419,7 @@ ${colors.dim}${context}${colors.reset}
|
|
|
1402
1419
|
}
|
|
1403
1420
|
export function clearComponentCache() {
|
|
1404
1421
|
componentsCache.clear();
|
|
1422
|
+
componentStamps.clear();
|
|
1405
1423
|
componentResolutionCache.clear();
|
|
1406
1424
|
userComponentFileCache.clear();
|
|
1407
1425
|
realDirCache.clear();
|
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.765",
|
|
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.11",
|
|
130
130
|
"@stacksjs/clapp": "^0.2.16",
|
|
131
|
-
"@stacksjs/desktop": "0.2.
|
|
132
|
-
"@stacksjs/sanitizer": "0.2.
|
|
131
|
+
"@stacksjs/desktop": "0.2.765",
|
|
132
|
+
"@stacksjs/sanitizer": "0.2.765",
|
|
133
133
|
"@stacksjs/ts-i18n": "^0.1.11",
|
|
134
|
-
"bun-plugin-stx": "0.2.
|
|
134
|
+
"bun-plugin-stx": "0.2.765",
|
|
135
135
|
"bunfig": "^0.15.21",
|
|
136
|
-
"stx-router": "0.2.
|
|
136
|
+
"stx-router": "0.2.765",
|
|
137
137
|
"ts-broadcasting": "^0.0.11",
|
|
138
138
|
"ts-images": "^0.2.22",
|
|
139
139
|
"ts-syntax-highlighter": "^0.2.1"
|