@stacksjs/stx 0.2.412 → 0.2.414
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/appearance-bootstrap.js +1 -1
- package/dist/binding-manifest.d.ts +1 -1
- package/dist/builtins/image-delivery.d.ts +38 -0
- package/dist/builtins/image-delivery.js +17 -0
- package/dist/builtins/stx-image.js +1 -5
- package/dist/bundle-analyzer.js +20 -20
- package/dist/chunk-020xyn9q.js +3 -0
- package/dist/chunk-04jhmfbz.js +2 -0
- package/dist/chunk-10957mcb.js +2 -0
- package/dist/chunk-1098mas0.js +2 -0
- package/dist/chunk-169n1vpx.js +12 -0
- package/dist/chunk-1b6t12hd.js +2 -0
- package/dist/chunk-1chw8xsw.js +2 -0
- package/dist/chunk-1xdzcy9d.js +14 -0
- package/dist/chunk-2ce7f416.js +2 -0
- package/dist/chunk-2gr351s0.js +7 -0
- package/dist/chunk-2mkcjw08.js +2 -0
- package/dist/chunk-2v8wztd5.js +2 -0
- package/dist/chunk-340a824p.js +2 -0
- package/dist/chunk-39g1134q.js +2 -0
- package/dist/chunk-3c74vag1.js +2 -0
- package/dist/chunk-3kthfs03.js +3 -0
- package/dist/chunk-3qn1wcdg.js +2 -0
- package/dist/chunk-3s2vnqcf.js +2 -0
- package/dist/chunk-48bwk47q.js +2 -0
- package/dist/chunk-4bjravgk.js +2 -0
- package/dist/chunk-4jjme6a5.js +2 -0
- package/dist/chunk-5g3y8kym.js +2 -0
- package/dist/chunk-5gsxpaqk.js +2 -0
- package/dist/{chunk-bwsxym3d.js → chunk-5qns2sdz.js} +17 -17
- package/dist/chunk-69mc2np8.js +2785 -0
- package/dist/chunk-6cfa3g0r.js +2 -0
- package/dist/{chunk-bjar18jd.js → chunk-6h38kkjf.js} +46 -52
- package/dist/chunk-6hc5vz20.js +3 -0
- package/dist/chunk-6q6g76vg.js +499 -0
- package/dist/{chunk-dbc5awz9.js → chunk-6sgswrqw.js} +29 -29
- package/dist/chunk-6y8hnymb.js +2 -0
- package/dist/chunk-74j18qk0.js +930 -0
- package/dist/chunk-752hw7cd.js +4 -0
- package/dist/{chunk-t5ja7qkn.js → chunk-765e1s44.js} +11 -76
- package/dist/chunk-7gkv67ky.js +4 -0
- package/dist/chunk-7z2ra0yf.js +2 -0
- package/dist/chunk-866n724v.js +2 -0
- package/dist/chunk-8nhshfz6.js +5 -0
- package/dist/chunk-92ps1xpk.js +2 -0
- package/dist/chunk-9g27ybyr.js +3 -0
- package/dist/{chunk-xq1acw1r.js → chunk-9pt8fd2n.js} +13 -13
- package/dist/{chunk-qvnbnsv9.js → chunk-9vrja6vp.js} +4 -4
- package/dist/chunk-9xrbve19.js +2 -0
- package/dist/chunk-a688m6js.js +3 -0
- package/dist/chunk-afhxw2t8.js +2 -0
- package/dist/chunk-ak1cgcah.js +5 -0
- package/dist/{chunk-4m7ajama.js → chunk-amd6ey3t.js} +14 -14
- package/dist/chunk-apg16xcn.js +2 -0
- package/dist/chunk-b52s5z0c.js +2 -0
- package/dist/chunk-b84h16er.js +61 -0
- package/dist/{chunk-hx998w7n.js → chunk-bay9s6rs.js} +13 -13
- package/dist/chunk-bmt7w2pk.js +2 -0
- package/dist/chunk-btmhj5t7.js +2 -0
- package/dist/chunk-ce1sejr3.js +3 -0
- package/dist/chunk-cg8hg6cs.js +3 -0
- package/dist/{chunk-8wp64mym.js → chunk-czxt605c.js} +4 -5
- package/dist/chunk-d44b9ktb.js +4 -0
- package/dist/chunk-daz5aqcf.js +24 -0
- package/dist/chunk-dgdm3hy3.js +2 -0
- package/dist/chunk-dvgv8nry.js +11 -0
- package/dist/chunk-dx7n22ed.js +2 -0
- package/dist/chunk-e57rhf65.js +3 -0
- package/dist/chunk-eed4fwps.js +3 -0
- package/dist/chunk-ej9j6k1q.js +3 -0
- package/dist/chunk-et0rr8c7.js +3 -0
- package/dist/chunk-f46qsp4m.js +4 -0
- package/dist/chunk-f6az0xj5.js +2 -0
- package/dist/{chunk-bjcsc6wx.js → chunk-fh1qrp68.js} +21 -21
- package/dist/chunk-fjs0a8h7.js +2 -0
- package/dist/chunk-fr2txj8q.js +829 -0
- package/dist/{chunk-vx86cf4r.js → chunk-ft4p6d28.js} +14 -14
- package/dist/chunk-fyzajkrx.js +2 -0
- package/dist/chunk-fzapbw9p.js +3 -0
- package/dist/chunk-g578mcb0.js +194 -0
- package/dist/chunk-gawrg4gb.js +216 -0
- package/dist/chunk-gw07qmjk.js +2 -0
- package/dist/chunk-h0atqq82.js +32 -0
- package/dist/chunk-h6zsqb9r.js +3 -0
- package/dist/{chunk-hdysywd8.js → chunk-h85hrwkq.js} +13 -13
- package/dist/chunk-hbxz85wy.js +2 -0
- package/dist/chunk-hjg3ndgh.js +2 -0
- package/dist/chunk-hkxsewzk.js +2 -0
- package/dist/chunk-hrbbbtbn.js +2 -0
- package/dist/chunk-j03revz2.js +8 -0
- package/dist/chunk-j9qcrwbg.js +2 -0
- package/dist/chunk-jk4njz0w.js +2 -0
- package/dist/chunk-jmabeqfq.js +2 -0
- package/dist/chunk-jt0n43mk.js +2 -0
- package/dist/chunk-kjbv8a3m.js +2 -0
- package/dist/chunk-m1vdghnx.js +2 -0
- package/dist/chunk-m4sk62wb.js +5 -0
- package/dist/chunk-md8rqn48.js +30 -0
- package/dist/chunk-mepdnezf.js +17 -0
- package/dist/chunk-mhq0pjws.js +2 -0
- package/dist/chunk-mp6hy8g4.js +2 -0
- package/dist/chunk-ngc2wke4.js +3 -0
- package/dist/chunk-nn2vstke.js +2 -0
- package/dist/chunk-p2v2a68k.js +2 -0
- package/dist/{chunk-qn5srnj3.js → chunk-pbh4smw3.js} +16 -16
- package/dist/chunk-pdt69hpb.js +2 -0
- package/dist/chunk-pgzvyrv6.js +29 -0
- package/dist/chunk-pj1wg7jg.js +2 -0
- package/dist/chunk-pqxzp1bb.js +3 -0
- package/dist/chunk-px7fvbj6.js +3 -0
- package/dist/chunk-q4c06e8x.js +20 -0
- package/dist/chunk-q6vrb2pe.js +2 -0
- package/dist/chunk-q7qchkvk.js +2 -0
- package/dist/chunk-q9bdh4s5.js +8 -0
- package/dist/chunk-qet5gc6s.js +2033 -0
- package/dist/chunk-qz519eyp.js +2 -0
- package/dist/chunk-r3f9jcf7.js +5 -0
- package/dist/chunk-rs4v4fha.js +4 -0
- package/dist/chunk-s2x4wcrz.js +2 -0
- package/dist/chunk-s5xezjps.js +3 -0
- package/dist/chunk-scezfp0w.js +30 -0
- package/dist/chunk-sd321bn3.js +2 -0
- package/dist/{chunk-eenk6s3t.js → chunk-sd47dzs0.js} +79 -79
- package/dist/chunk-se7mwqd1.js +2 -0
- package/dist/chunk-shr559s7.js +3 -0
- package/dist/chunk-syaw6b75.js +2 -0
- package/dist/chunk-t4hzprsm.js +3 -0
- package/dist/{chunk-s9za1vvd.js → chunk-t61vdbje.js} +89 -89
- package/dist/chunk-tfexmdkt.js +3 -0
- package/dist/chunk-thyt8ed8.js +6 -0
- package/dist/chunk-v091jft4.js +12 -0
- package/dist/chunk-v4vaqxrf.js +33 -0
- package/dist/chunk-vgvtnwxa.js +4 -0
- package/dist/chunk-x0q32ees.js +3 -0
- package/dist/chunk-x5bpeb4a.js +2 -0
- package/dist/chunk-x72tv2cg.js +3 -0
- package/dist/chunk-xfp7k0v8.js +64 -0
- package/dist/chunk-xtdw3692.js +6 -0
- package/dist/chunk-y1cmjvk3.js +43 -0
- package/dist/chunk-y5310237.js +311 -0
- package/dist/chunk-ya0qecph.js +27 -0
- package/dist/chunk-yazk54jr.js +8 -0
- package/dist/chunk-ydjfar14.js +2 -0
- package/dist/chunk-ym95v4nc.js +3 -0
- package/dist/chunk-ynvdvbat.js +18 -0
- package/dist/chunk-yvx1ap9b.js +3 -0
- package/dist/chunk-z0g9jvv0.js +40 -0
- package/dist/chunk-z6d0jmjb.js +2 -0
- package/dist/{chunk-fpwzacpm.js → chunk-zhxdpzga.js} +4 -4
- package/dist/cli.js +110 -110
- package/dist/craft-entry.js +7 -7
- package/dist/craft.js +7 -7
- package/dist/database.js +2 -2
- package/dist/image-optimization/component.js +4 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/media/image/component.js +5 -5
- package/dist/media/protected/component.js +2 -2
- package/dist/media/video/index.js +4 -4
- package/dist/native/bridge/protocol.d.ts +325 -0
- package/dist/native/bridge/protocol.js +219 -0
- package/dist/native/cli.d.ts +24 -0
- package/dist/native/cli.js +52 -0
- package/dist/native/compiler/bundle.d.ts +41 -0
- package/dist/native/compiler/bundle.js +90 -0
- package/dist/native/compiler/client-script.d.ts +8 -0
- package/dist/native/compiler/client-script.js +31 -0
- package/dist/native/compiler/codegen.d.ts +10 -0
- package/dist/native/compiler/codegen.js +145 -0
- package/dist/native/compiler/headwind-to-style.d.ts +395 -0
- package/dist/native/compiler/headwind-to-style.js +1163 -0
- package/dist/native/compiler/html-to-ir.d.ts +41 -0
- package/dist/native/compiler/html-to-ir.js +411 -0
- package/dist/native/compiler/icons.d.ts +220 -0
- package/dist/native/compiler/icons.js +208 -0
- package/dist/native/compiler/ir.d.ts +234 -0
- package/dist/native/compiler/ir.js +15 -0
- package/dist/native/compiler/parser.d.ts +88 -0
- package/dist/native/compiler/parser.js +753 -0
- package/dist/native/compiler/render-screen.d.ts +26 -0
- package/dist/native/compiler/render-screen.js +31 -0
- package/dist/native/components/primitives.d.ts +291 -0
- package/dist/native/components/primitives.js +22 -0
- package/dist/native/hot-reload/client.d.ts +62 -0
- package/dist/native/hot-reload/client.js +324 -0
- package/dist/native/index.d.ts +90 -0
- package/dist/native/index.js +34 -0
- package/dist/native/primitives/ActivityIndicator.stx +5 -0
- package/dist/native/primitives/Button.stx +5 -0
- package/dist/native/primitives/DatePicker.stx +5 -0
- package/dist/native/primitives/FlatList.stx +5 -0
- package/dist/native/primitives/Image.stx +5 -0
- package/dist/native/primitives/ImageBackground.stx +5 -0
- package/dist/native/primitives/KeyboardAvoidingView.stx +5 -0
- package/dist/native/primitives/Modal.stx +5 -0
- package/dist/native/primitives/Picker.stx +5 -0
- package/dist/native/primitives/Pressable.stx +5 -0
- package/dist/native/primitives/RefreshControl.stx +5 -0
- package/dist/native/primitives/SafeAreaView.stx +5 -0
- package/dist/native/primitives/ScrollView.stx +5 -0
- package/dist/native/primitives/SectionList.stx +5 -0
- package/dist/native/primitives/Slider.stx +5 -0
- package/dist/native/primitives/StatusBar.stx +5 -0
- package/dist/native/primitives/Switch.stx +5 -0
- package/dist/native/primitives/Text.stx +5 -0
- package/dist/native/primitives/TextInput.stx +5 -0
- package/dist/native/primitives/TouchableHighlight.stx +5 -0
- package/dist/native/primitives/TouchableOpacity.stx +5 -0
- package/dist/native/primitives/View.stx +5 -0
- package/dist/native/runtime/craft.d.ts +75 -0
- package/dist/native/runtime/craft.js +0 -0
- package/dist/native/runtime/entry.d.ts +1 -0
- package/dist/native/runtime/entry.js +3 -0
- package/dist/native/runtime/index.d.ts +45 -0
- package/dist/native/runtime/index.js +165 -0
- package/dist/native/runtime/native-host.d.ts +33 -0
- package/dist/native/runtime/native-host.js +184 -0
- package/dist/native/runtime/screen.d.ts +43 -0
- package/dist/native/runtime/screen.js +808 -0
- package/dist/pwa/service-worker.js +1 -1
- package/dist/pwa/workbox.js +1 -1
- package/dist/pwa.js +8 -8
- package/dist/site-url.d.ts +1 -1
- package/dist/ssg.js +53 -53
- package/dist/visual-testing.js +42 -42
- package/dist/web-components/reactive-generator.js +2 -2
- package/package.json +9 -5
- package/dist/chunk-00g9x6w2.js +0 -2
- package/dist/chunk-04tgatyy.js +0 -2
- package/dist/chunk-097jnwd5.js +0 -2
- package/dist/chunk-0btmm4m2.js +0 -147
- package/dist/chunk-0c2h69k2.js +0 -4
- package/dist/chunk-0pkk226n.js +0 -2
- package/dist/chunk-0we9nw1d.js +0 -3
- package/dist/chunk-0y46fbkx.js +0 -3
- package/dist/chunk-18n1ftn0.js +0 -33
- package/dist/chunk-1a0v39k5.js +0 -3
- package/dist/chunk-1fs9jvpb.js +0 -2
- package/dist/chunk-1qq26zt0.js +0 -2
- package/dist/chunk-1te8k8gp.js +0 -3
- package/dist/chunk-1ws3xcea.js +0 -1199
- package/dist/chunk-213jwgpx.js +0 -3
- package/dist/chunk-24w86pek.js +0 -32
- package/dist/chunk-27fgag95.js +0 -4
- package/dist/chunk-2fw05hs2.js +0 -3
- package/dist/chunk-2tbez006.js +0 -2
- package/dist/chunk-38wvkv3s.js +0 -2
- package/dist/chunk-3rkejwjp.js +0 -2
- package/dist/chunk-3t65wb35.js +0 -2
- package/dist/chunk-3w6z6tw9.js +0 -2
- package/dist/chunk-4q1c6fw2.js +0 -7
- package/dist/chunk-50pszj17.js +0 -2
- package/dist/chunk-563shnkz.js +0 -3
- package/dist/chunk-5h104qh1.js +0 -2
- package/dist/chunk-5qjk7drw.js +0 -20
- package/dist/chunk-603x5gb2.js +0 -2
- package/dist/chunk-6kd5jjwc.js +0 -2
- package/dist/chunk-6kdrncsx.js +0 -30
- package/dist/chunk-6zggmce7.js +0 -4422
- package/dist/chunk-72rwcbp6.js +0 -3
- package/dist/chunk-76w34xne.js +0 -3
- package/dist/chunk-7dmgt8at.js +0 -2
- package/dist/chunk-82pd4b5w.js +0 -2
- package/dist/chunk-8d7nf67s.js +0 -2
- package/dist/chunk-8w2mqdnv.js +0 -2
- package/dist/chunk-90b2vt2n.js +0 -2
- package/dist/chunk-9e8t0twa.js +0 -3
- package/dist/chunk-9fqp72ze.js +0 -5
- package/dist/chunk-9xew0kgf.js +0 -2
- package/dist/chunk-a7bnvz91.js +0 -24
- package/dist/chunk-akwd34xt.js +0 -29
- package/dist/chunk-anydpa34.js +0 -3
- package/dist/chunk-aq1xq0r4.js +0 -16
- package/dist/chunk-bbt3tp6f.js +0 -499
- package/dist/chunk-bn1edb1y.js +0 -47
- package/dist/chunk-btd7ds3x.js +0 -2
- package/dist/chunk-c4511wng.js +0 -2
- package/dist/chunk-c4h579e3.js +0 -2
- package/dist/chunk-cj3adc77.js +0 -5
- package/dist/chunk-cs54ek9m.js +0 -6
- package/dist/chunk-ct1jwd4r.js +0 -2
- package/dist/chunk-cxrgxzxc.js +0 -2
- package/dist/chunk-de8t7sc9.js +0 -17
- package/dist/chunk-fcnrgxck.js +0 -2
- package/dist/chunk-fqzcft9d.js +0 -2
- package/dist/chunk-gbmeh7jg.js +0 -3
- package/dist/chunk-gc06g35w.js +0 -2
- package/dist/chunk-gs18069g.js +0 -194
- package/dist/chunk-gvbf1mhs.js +0 -930
- package/dist/chunk-h564hgzt.js +0 -2
- package/dist/chunk-h83jrhfq.js +0 -3
- package/dist/chunk-hj4vpyhp.js +0 -2
- package/dist/chunk-hrkvsj5c.js +0 -11
- package/dist/chunk-hyr4ag1k.js +0 -2
- package/dist/chunk-jxvmf02k.js +0 -2
- package/dist/chunk-k5ptvy0b.js +0 -4
- package/dist/chunk-k80sn8d1.js +0 -2
- package/dist/chunk-k8t2cmyd.js +0 -2
- package/dist/chunk-kmsyvaex.js +0 -8
- package/dist/chunk-kq4b6cwj.js +0 -2
- package/dist/chunk-kvmx7dnb.js +0 -2
- package/dist/chunk-kxc2h5vn.js +0 -5
- package/dist/chunk-mbxehgrq.js +0 -2
- package/dist/chunk-mgnq5de2.js +0 -2
- package/dist/chunk-mgrckqww.js +0 -2
- package/dist/chunk-mq5ewmz6.js +0 -2
- package/dist/chunk-mrahwn5v.js +0 -8
- package/dist/chunk-n2swas11.js +0 -3
- package/dist/chunk-n4299xgy.js +0 -2
- package/dist/chunk-naw4jt7j.js +0 -2
- package/dist/chunk-ny67c03k.js +0 -3
- package/dist/chunk-p4jb9v0w.js +0 -2
- package/dist/chunk-p4zrvt5f.js +0 -14
- package/dist/chunk-p5wp0ce6.js +0 -43
- package/dist/chunk-pcxp4r9n.js +0 -3
- package/dist/chunk-pjrn29gg.js +0 -2
- package/dist/chunk-prxwsp7n.js +0 -2
- package/dist/chunk-py2r6wtv.js +0 -2
- package/dist/chunk-q738pwv6.js +0 -2
- package/dist/chunk-q9n5swx7.js +0 -3
- package/dist/chunk-qmmp5kb5.js +0 -2
- package/dist/chunk-qqpqgwvb.js +0 -30
- package/dist/chunk-rcv2ehpq.js +0 -18
- package/dist/chunk-rq414kn5.js +0 -3
- package/dist/chunk-rz9f3zqz.js +0 -7
- package/dist/chunk-s6g8wksg.js +0 -2
- package/dist/chunk-s8jd13nb.js +0 -3
- package/dist/chunk-spxsw4mp.js +0 -2
- package/dist/chunk-strcy64y.js +0 -2
- package/dist/chunk-t1htzg9e.js +0 -4
- package/dist/chunk-t1tdjjht.js +0 -216
- package/dist/chunk-tat1cjec.js +0 -2
- package/dist/chunk-td08rnk3.js +0 -3
- package/dist/chunk-tgadbsd4.js +0 -2
- package/dist/chunk-tgrpp58r.js +0 -2
- package/dist/chunk-tkyrk66a.js +0 -3
- package/dist/chunk-tp8pzf94.js +0 -3
- package/dist/chunk-twz64kvy.js +0 -2
- package/dist/chunk-v3nwkveg.js +0 -12
- package/dist/chunk-vsbmc9kt.js +0 -2
- package/dist/chunk-vzgzaw66.js +0 -12
- package/dist/chunk-wc66mcn4.js +0 -4367
- package/dist/chunk-wkanrfb3.js +0 -2
- package/dist/chunk-x8f6wqxd.js +0 -2
- package/dist/chunk-xsng1mtq.js +0 -3
- package/dist/chunk-xwts5yky.js +0 -4
- package/dist/chunk-z5rwnnk1.js +0 -3
- package/dist/chunk-zcz9rs6p.js +0 -3
- package/dist/chunk-zpcnbdhn.js +0 -64
- package/dist/chunk-zq4ssxj9.js +0 -8
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{t,a}from"./chunk-z0g9jvv0.js";import{Ge,Je,Ye,pe,Se,k,rr,pn,fe}from"./chunk-m4sk62wb.js";var I=/(?<![\w$@])@meta\s*\(/g,C=/(?<![\w$@])@metaTag\s*\(/g,x=/(?<![\w$@])@structuredData\s*\(/g,N=/(?<![\w$@])@seo\s*\(/g;function S(e,r){return(n)=>k(e,n,"the call has no closing parenthesis",r,t.INVALID_DIRECTIVE_SYNTAX)}function j(e){return"property"in e?`<meta property="${l(e.property)}" content="${l(e.content)}">`:`<meta name="${l(e.name)}" content="${l(e.content)}">`}function ks(e,r,n,p){if(!e.includes("@meta"))return e;let i=Ge(e,I,(s,c)=>{let o=pn(Je(s),r);if(o.kind==="tag")return j(o.tag);if(o.kind==="empty")return"";return k("Meta",c,o.message,n,o.code)},S("Meta",n));return i=Ge(i,C,(s,c)=>{let o=Ye(s,r);if(!o.ok)return k("MetaTag",c,o.message,n,o.code);if(o.value===void 0||o.value===null)return"";if(!Se(o.value))return k("MetaTag",c,`expected an object such as { name, content }, got ${pe(o.value)}`,n,t.TYPE_ERROR);let u=o.value;if(!u.name&&!u.property&&!u.httpEquiv)return k("MetaTag",c,"the tag needs a name, property or httpEquiv",n,t.INVALID_DIRECTIVE_SYNTAX);if(u.content===void 0||u.content===null||u.content===""||u.content===!1)return"";let g="<meta";if(u.name)g+=` name="${l(u.name)}"`;if(u.property)g+=` property="${l(u.property)}"`;if(u.httpEquiv)g+=` http-equiv="${l(u.httpEquiv)}"`;return g+=` content="${l(u.content)}">`,g},S("MetaTag",n)),i}function R(e){let r=(n)=>n["@context"]?{...n}:{...n,"@context":"https://schema.org"};if(Se(e))return r(e);if(Array.isArray(e)&&e.length>0&&e.every(Se))return e.map(r);return null}function _(e){return`<script type="application/ld+json">${JSON.stringify(e).replace(/<\//g,"<\\/")}</script>`}function Cs(e,r,n){if(!e.includes("@structuredData"))return e;return Ge(e,x,(p,i)=>{let s=Ye(p,r);if(!s.ok)return k("StructuredData",i,s.message,n,s.code);if(s.value===void 0||s.value===null)return"";let c=R(s.value);if(!c)return k("StructuredData",i,`expected an object or an array of objects, got ${pe(s.value)}`,n,t.TYPE_ERROR);try{return _(c)}catch(o){let u=o instanceof Error?o.message:String(o);return k("StructuredData",i,`the data cannot be written as JSON: ${u}`,n,t.EVALUATION_ERROR)}},S("StructuredData",n))}var L=new Set(["title","description","keywords","robots","canonical","openGraph","twitter","structuredData"]),E={image:"openGraph.image",url:"canonical or openGraph.url",type:"openGraph.type",siteName:"openGraph.siteName",locale:"openGraph.locale",og:"openGraph",author:"@meta('author', ...)"};function $s(e,r,n,p){if(!e.includes("@seo"))return e;return Ge(e,N,(i,s)=>{if(!i.trim())return k("SEO",s,"expected an object: @seo({ title, description }) or @seo(seoVariable)",n,t.INVALID_DIRECTIVE_SYNTAX);let c=Ye(i,r);if(!c.ok)return k("SEO",s,c.message,n,c.code);if(c.value===void 0||c.value===null)return"";if(!Se(c.value))return k("SEO",s,`expected an object such as { title, description }, got ${pe(c.value)}`,n,t.TYPE_ERROR);try{return q(c.value,s,n)}catch(o){let u=o instanceof Error?o.message:String(o);return k("SEO",s,`Error processing @seo directive: ${u}`,n,t.EVALUATION_ERROR)}},S("SEO",n))}function A(e,r,n,p){let i=e[r];if(i===void 0||i===null||i===!1)return;if(Se(i))return i;rr(n,`${r} must be an object, got ${pe(i)}; its tags were left out`,p);return}function q(e,r,n){let p=Object.keys(e).filter((o)=>!L.has(o));if(p.length>0){let o=p.map((u)=>E[u]?`${u} (use ${E[u]})`:u).join(", ");rr(r,`@seo does not read ${o}; ${p.length===1?"it was":"they were"} ignored`,n)}let i="";if(e.title)i+=`<title>${l(e.title)}</title>
|
|
3
|
+
`,i+=`<meta name="title" content="${l(e.title)}">
|
|
4
|
+
`;if(e.description)i+=`<meta name="description" content="${l(e.description)}">
|
|
5
|
+
`;if(e.keywords){let o=Array.isArray(e.keywords)?e.keywords.join(", "):e.keywords;i+=`<meta name="keywords" content="${l(o)}">
|
|
6
|
+
`}if(e.robots)i+=`<meta name="robots" content="${l(e.robots)}">
|
|
7
|
+
`;if(e.canonical)i+=`<link rel="canonical" href="${l(e.canonical)}">
|
|
8
|
+
`;let s=A(e,"openGraph",r,n);if(s){if(i+=`<meta property="og:type" content="${l(s.type||"website")}">
|
|
9
|
+
`,s.title||e.title){let o=s.title||e.title||"";i+=`<meta property="og:title" content="${l(o)}">
|
|
10
|
+
`}if(s.description||e.description){let o=s.description||e.description||"";i+=`<meta property="og:description" content="${l(o)}">
|
|
11
|
+
`}if(s.url||e.canonical){let o=s.url||e.canonical||"";i+=`<meta property="og:url" content="${l(o)}">
|
|
12
|
+
`}if(s.image){if(i+=`<meta property="og:image" content="${l(s.image)}">
|
|
13
|
+
`,s.imageAlt)i+=`<meta property="og:image:alt" content="${l(s.imageAlt)}">
|
|
14
|
+
`;if(s.imageWidth)i+=`<meta property="og:image:width" content="${l(String(s.imageWidth))}">
|
|
15
|
+
`;if(s.imageHeight)i+=`<meta property="og:image:height" content="${l(String(s.imageHeight))}">
|
|
16
|
+
`;if(s.imageType)i+=`<meta property="og:image:type" content="${l(s.imageType)}">
|
|
17
|
+
`}if(s.siteName)i+=`<meta property="og:site_name" content="${l(s.siteName)}">
|
|
18
|
+
`;if(s.locale)i+=`<meta property="og:locale" content="${l(s.locale)}">
|
|
19
|
+
`;if(s.profile){let o=[["first_name",s.profile.firstName],["last_name",s.profile.lastName],["username",s.profile.username],["gender",s.profile.gender]];for(let[u,g]of o)if(g)i+=`<meta property="profile:${u}" content="${l(g)}">
|
|
20
|
+
`}}let c=A(e,"twitter",r,n);if(c){if(i+=`<meta name="twitter:card" content="${l(c.card||"summary_large_image")}">
|
|
21
|
+
`,c.title||e.title){let o=c.title||e.title||"";i+=`<meta name="twitter:title" content="${l(o)}">
|
|
22
|
+
`}if(c.description||e.description){let o=c.description||e.description||"";i+=`<meta name="twitter:description" content="${l(o)}">
|
|
23
|
+
`}if(c.image||s&&s.image){let o=c.image||(s?s.image:"")||"";i+=`<meta name="twitter:image" content="${l(o)}">
|
|
24
|
+
`;let u=c.imageAlt||(!c.image&&s?s.imageAlt:void 0);if(u)i+=`<meta name="twitter:image:alt" content="${l(u)}">
|
|
25
|
+
`}if(c.site)i+=`<meta name="twitter:site" content="${l(c.site)}">
|
|
26
|
+
`;if(c.creator)i+=`<meta name="twitter:creator" content="${l(c.creator)}">
|
|
27
|
+
`}if(e.structuredData!==void 0&&e.structuredData!==null){let o=R(e.structuredData);if(o)i+=`${_(o)}
|
|
28
|
+
`;else rr(r,`structuredData must be an object or an array of objects, got ${pe(e.structuredData)}; it was left out`,n)}return i.trim()}function Es(e,r,n){if(n.seo?.enabled===!1)return e;if(e.includes("<!-- stx SEO Tags -->")||r.__stx_seo_staged===!0||n.skipDefaultSeoTags===!0)return e;let p=r.__stx_runtime_head;if(!!(p?.title||p?.meta?.some((w)=>w.property==="og:title"||w.name==="og:title"||w.name==="twitter:title"||w.name==="description")))return e;if(/<meta\s+(?:[^>]*\s)?property=["']og:title["']/i.test(e)||/<meta\s+(?:[^>]*\s)?name=["']og:title["']/i.test(e)||/<meta\s+(?:[^>]*\s)?name=["']twitter:title["']/i.test(e))return e;if(!e.includes("<head>")&&!e.includes("<head "))return e;let s=e.includes("<title>")||e.includes("</title>"),c=M(e),o=V(c),u=U(c),g="";if(r.title)g=r.title;else if(r.meta&&r.meta.title)g=r.meta.title;else if(o)g=o;else if(n.seo?.defaultConfig?.title)g=n.seo.defaultConfig.title;else g=n.defaultTitle||"stx Project";let m="";if(r.description)m=r.description;else if(r.meta&&r.meta.description)m=r.meta.description;else if(u)m=u;else if(n.seo?.defaultConfig?.description)m=n.seo.defaultConfig.description;else m=n.defaultDescription||"A website built with stx templating engine";let d="";if(r.image)d=r.image;else if(r.meta&&r.meta.image)d=r.meta.image;else if(r.openGraph&&r.openGraph.image)d=r.openGraph.image;else if(n.seo?.defaultImage)d=n.seo.defaultImage;else if(n.defaultImage)d=n.defaultImage;let f=s?"":`
|
|
29
|
+
<meta name="title" content="${l(g)}">`,h=G(c)?"":`
|
|
30
|
+
<meta name="description" content="${l(m)}">`,T=`
|
|
31
|
+
<!-- stx SEO Tags -->${f}${h}
|
|
32
|
+
<meta property="og:title" content="${l(g)}">
|
|
33
|
+
<meta property="og:description" content="${l(m)}">
|
|
34
|
+
<meta property="og:type" content="website">
|
|
35
|
+
<meta name="twitter:card" content="summary_large_image">
|
|
36
|
+
<meta name="twitter:title" content="${l(g)}">
|
|
37
|
+
<meta name="twitter:description" content="${l(m)}">
|
|
38
|
+
`;if(d)T+=`
|
|
39
|
+
<meta property="og:image" content="${l(d)}">
|
|
40
|
+
<meta name="twitter:image" content="${l(d)}">
|
|
41
|
+
`;let y=e;if(!s)y=y.replace(/<head[^>]*>/,`$&
|
|
42
|
+
<title>${l(g)}</title>`);let D=r.__stx_head_injections;if(D)return r.__stx_seo_staged=!0,D.afterOpen.push(`
|
|
43
|
+
${T}
|
|
44
|
+
`),y;return y.replace(/<head[^>]*>/,`$&
|
|
45
|
+
${T}
|
|
46
|
+
`)}function M(e){let r=e.search(/<\/head\s*>/i);return r===-1?e:e.slice(0,r)}function b(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/�*39;|'/g,"'").replace(/&/g,"&")}function V(e){let r=e.match(/<title(?:\s[^>]*)?>([\s\S]*?)<\/title\s*>/i);return r?b(r[1].trim()):""}function v(e){return(e.match(/<meta\s[^>]*>/gi)||[]).filter((r)=>/\sname\s*=\s*["']description["']/i.test(r))}function G(e){return v(e).length>0}function U(e){for(let r of v(e)){let n=r.match(/\scontent\s*=\s*(?:"([^"]*)"|'([^']*)')/i),p=(n?.[1]??n?.[2]??"").trim();if(p)return b(p)}return""}function l(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var er={name:"meta",rawParams:!0,handler:(e,r,n,p)=>{let i=pn(r,n??{});if(i.kind==="error")return k("Meta",`@meta(${r.join(", ")})`,i.message,p,i.code);if(i.kind==="empty")return"";if(n)n.__stx_runtime_head=fe(n.__stx_runtime_head??{},{meta:[i.tag]});return""},hasEndTag:!1},tr={name:"structuredData",handler:(e,r,n,p)=>{if(e.trim()==="")return a("StructuredData","structuredData directive requires JSON-LD content",t.INVALID_DIRECTIVE_SYNTAX);try{let i=JSON.parse(e);if(!i["@context"])i["@context"]="https://schema.org";if(!i["@type"])return a("StructuredData","structuredData requires @type property",t.INVALID_DIRECTIVE_SYNTAX);return _(i)}catch(i){let s=i instanceof Error?i.message:String(i);return a("StructuredData",s,t.EVALUATION_ERROR)}},hasEndTag:!0};function Uu(){return[er,tr]}function Wu(e,r){let{baseUrl:n,defaultChangefreq:p="weekly",defaultPriority:i=0.5,includeLastmod:s=!0}=r,c=n.replace(/\/$/,"");return`<?xml version="1.0" encoding="UTF-8"?>
|
|
47
|
+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
48
|
+
${e.map((u)=>{let g=u.loc.startsWith("http")?u.loc:`${c}${u.loc.startsWith("/")?"":"/"}${u.loc}`,m=u.lastmod||(s?new Date().toISOString().split("T")[0]:void 0),d=u.changefreq||p,f=u.priority??i,h=` <url>
|
|
49
|
+
<loc>${O(g)}</loc>`;if(m)h+=`
|
|
50
|
+
<lastmod>${m}</lastmod>`;return h+=`
|
|
51
|
+
<changefreq>${d}</changefreq>`,h+=`
|
|
52
|
+
<priority>${f.toFixed(1)}</priority>`,h+=`
|
|
53
|
+
</url>`,h}).join(`
|
|
54
|
+
`)}
|
|
55
|
+
</urlset>`}function qu(e,r){let n=r.replace(/\/$/,""),p=new Date().toISOString().split("T")[0];return`<?xml version="1.0" encoding="UTF-8"?>
|
|
56
|
+
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
57
|
+
${e.map((s)=>{let c=s.startsWith("http")?s:`${n}${s.startsWith("/")?"":"/"}${s}`;return` <sitemap>
|
|
58
|
+
<loc>${O(c)}</loc>
|
|
59
|
+
<lastmod>${p}</lastmod>
|
|
60
|
+
</sitemap>`}).join(`
|
|
61
|
+
`)}
|
|
62
|
+
</sitemapindex>`}async function Xu(e,r){let{extensions:n=[".stx",".html",".htm"],ignore:p=["_*",".*","node_modules","components","partials","layouts"]}=r,i=[],s=n.length===1?`*${n[0]}`:`*{${n.join(",")}}`,c=new Bun.Glob(`**/${s}`);for await(let o of c.scan(e)){if(p.some((f)=>{if(f.startsWith("*"))return o.includes(f.slice(1));return o.startsWith(f)||o.includes(`/${f}`)}))continue;let g=o.replace(/\\/g,"/").replace(/index\.(stx|html|htm)$/,"").replace(/\.(stx|html|htm)$/,"");if(!g.startsWith("/"))g=`/${g}`;if(g!=="/"&&g.endsWith("/"))g=g.slice(0,-1);let m=`${e}/${o}`,d;try{let f=await Bun.file(m).stat();if(f)d=new Date(f.mtime).toISOString().split("T")[0]}catch{}i.push({loc:g||"/",lastmod:d,priority:g==="/"?1:0.5})}return i.sort((o,u)=>o.loc.localeCompare(u.loc)),i}function nr(e){let r=[];for(let n of e.rules){if(r.push(`User-agent: ${n.userAgent}`),n.allow)for(let p of n.allow)r.push(`Allow: ${p}`);if(n.disallow)for(let p of n.disallow)r.push(`Disallow: ${p}`);if(n.crawlDelay!==void 0)r.push(`Crawl-delay: ${n.crawlDelay}`);r.push("")}if(e.sitemap){let n=Array.isArray(e.sitemap)?e.sitemap:[e.sitemap];for(let p of n)r.push(`Sitemap: ${p}`)}if(e.host)r.push(`Host: ${e.host}`);return r.join(`
|
|
63
|
+
`).trim()}function Ku(e){return nr({rules:[{userAgent:"*",allow:["/"]}],sitemap:e})}function O(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}
|
|
64
|
+
export{ks,Cs,$s,Es,er,tr,Uu,Wu,qu,Xu,nr,Ku};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Y}from"./chunk-czxt605c.js";import{de,S}from"./chunk-ngc2wke4.js";import{fo}from"./chunk-ak1cgcah.js";import{o}from"./chunk-fzapbw9p.js";import v from"fs";import m from"path";import{pathToFileURL as O}from"url";var E=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],P=new Set;function yt(s,l={}){let i=m.resolve(s,l.dir??"server/api"),a=[],f=new Map;if(!v.existsSync(i))return a;let t=Array.from(new Bun.Glob("**/*.{ts,js,mts,mjs}").scanSync({cwd:i})).sort();for(let e of t){if(e.endsWith(".d.ts"))continue;let u=e.replace(/\.(?:ts|js|mts|mjs)$/,"").split("/"),n=u.pop(),c=n.lastIndexOf("."),d=c>=0?n.slice(c+1):"get",g=d.toUpperCase();if(!E.includes(g)||d!==d.toLowerCase())throw Error(`Unsupported API method suffix in ${e}; use ${E.map((A)=>A.toLowerCase()).join(", ")}`);if(c>=0)n=n.slice(0,c);if(n!=="index")u.push(n);let r=new Set,h=u.map((A,I)=>{let y=/^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(A);if(y){if(r.has(y[2])||y[1]&&I!==u.length-1)throw Error(`Invalid API parameter in ${e}`);return r.add(y[2]),`:${y[2]}${y[1]?"*":""}`}if(!/^[\w-]+$/.test(A))throw Error(`Unsupported API path segment ${A} in ${e}`);return A}),w=`/api${h.length?`/${h.join("/")}`:""}`,x=`${g} ${w.replace(/:\w+/g,":param")}`;if(f.has(x))throw Error(`Ambiguous API route ${g} ${w}: ${f.get(x)} and ${e}`);f.set(x,e);let R=m.join(i,e);P.add(m.resolve(R)),P.add(v.realpathSync(R)),a.push({pattern:w,method:g,filePath:R})}return a.sort((e,p)=>{let u=e.pattern.split("/"),n=p.pattern.split("/"),c=(d)=>d?.endsWith("*")?0:d?.startsWith(":")?1:2;for(let d=0;d<Math.max(u.length,n.length);d++){let g=c(n[d])-c(u[d]);if(g)return g}return e.pattern.localeCompare(p.pattern)||e.method.localeCompare(p.method)})}async function Vr(s,l){let i=o(s,"api-types.d.ts"),a=["// Generated by stx. Include this file in tsconfig.json.","declare module '@stacksjs/stx/api-client' {"," interface KnownApiRoutes {"];for(let t of l){let e=`./${m.relative(m.dirname(i),t.filePath).replace(/\\/g,"/")}`,{params:p}=Y(t.pattern);a.push(` ${JSON.stringify(`${t.method} ${t.pattern}`)}: { params: { ${p.map((u)=>`${JSON.stringify(u)}: string`).join("; ")} }; response: Awaited<ReturnType<typeof import(${JSON.stringify(e)}).default>> }`)}a.push(" }","}","export {}","");let f=a.join(`
|
|
3
|
+
`);if(!await Bun.file(i).exists()||await Bun.file(i).text()!==f)await Bun.write(i,f);return i}async function Ur(s,l,i={}){let a=yt(s,i);await Vr(s,a);let f=[];for(let t of a){let e=await Bun.build({entrypoints:[t.filePath],target:"bun",format:"esm",minify:!1,splitting:!1});if(!e.success)throw Error(`API build failed for ${t.filePath}: ${e.logs.join(`
|
|
4
|
+
`)}`);let p=e.outputs.find((c)=>c.kind==="entry-point");if(!p)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await p.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),p),f.push({...t,filePath:n})}return f}function j(s,l){let i=s.map((a)=>({route:a,...Y(a.pattern)}));return async(a)=>{let f=new URL(a.url).pathname,t=i.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,p=(r)=>r.replace(/:\w+/g,":param"),u=t.filter((r)=>p(r.route.pattern)===p(e)),n=a.method,c=u.find((r)=>r.route.method===n)??(n==="HEAD"?u.find((r)=>r.route.method==="GET"):void 0);if(!c){let r=new Set(u.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=c.regex.exec(f),g=Object.create(null);try{c.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await l(c.route);if(typeof r!=="function")throw Error(`API endpoint ${c.route.filePath} must default-export a handler`);let h=await r(a,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Wr(s,l){return j(l,async(i)=>(await import(O(m.resolve(s,i.filePath)).href)).default)}async function Eu(s,l){if(!l)return async()=>null;let i=l===!0?{}:l,a=yt(s,i);return await Vr(s,a),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=yt(s,i);await Vr(s,t);let{loadStxConfig:e}=await import("./chunk-syaw6b75.js"),p=S((await e(s)).runtimeConfig);return await de(p,()=>j(t,async(u)=>{let n=await Bun.build({entrypoints:[u.filePath],target:"bun",format:"esm",splitting:!1});if(!n.success)throw Error(n.logs.join(`
|
|
5
|
+
`));let c=n.outputs.find((d)=>d.kind==="entry-point");if(!c||n.outputs.length!==1)throw Error(`Unsupported API bundle output: ${u.filePath}`);return(await import(`data:text/javascript;base64,${Buffer.from(await c.text()).toString("base64")}`)).default})(f))}catch(t){return console.error("[stx] API discovery failed:",t),Response.json({error:"API discovery failed; check the server log"},{status:500})}}}function qr(s,l,i){if(fo(s))return!0;let a=/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/;if(a.test(m.basename(s)))return!0;try{if(a.test(m.basename(v.realpathSync(s))))return!0}catch{}if(P.has(m.resolve(s)))return!0;if(!i)return!1;let f=m.resolve(l,typeof i==="object"?i.dir??"server/api":"server/api"),t=(p)=>{try{return v.realpathSync(p)}catch{return m.resolve(p)}},e=t(s);return[f,m.resolve(l,"server"),m.resolve(l,".output/server")].some((p)=>{let u=t(p);return e===u||e.startsWith(`${u}${m.sep}`)})}
|
|
6
|
+
export{yt,Vr,Ur,Wr,Eu,qr};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{L,j,B,Lt,Z,oe,Ie,ut,jt,Bt,Ft,F,zt,Ht}from"./chunk-eed4fwps.js";import{qe}from"./chunk-tfexmdkt.js";function Lo(s,r={}){let{src:e,alt:t,width:n,height:a,sizes:i="100vw",loading:m="lazy",priority:o=!1,quality:u=B,placeholder:l="none",formats:f=j,widths:y=L,decoding:c="async",fetchpriority:h,objectFit:d,objectPosition:g}=s,{class:p,style:v}=s,{processedImage:w,variants:I,optimize:b=!0,isDev:A=!1}=r;if(I&&I.length>0)return ee(s,I,w);if(A||!b)return te(s);return se(s)}function ee(s,r,e){let{src:t,alt:n,width:a,height:i,sizes:m="100vw",loading:o="lazy",priority:u=!1,decoding:l="async",fetchpriority:f,objectFit:y,objectPosition:c,placeholder:h="none"}=s,{class:d,style:g}=s,p=Bt(r),v=jt(r),w=typeof m==="object"?ut(m):m,I=e?e.aspectRatio:a&&i?Number(a)/Number(i):void 0,b=[];if(I)b.push(`aspect-ratio: ${I}`);if(y)b.push(`object-fit: ${y}`);if(c)b.push(`object-position: ${c}`);if(g)b.push(g);let A=b.length>0?` style="${b.join("; ")}"`:"",S=d?` class="${d}"`:"",C=u?"":` loading="${o}"`,T=` decoding="${l}"`,O=f?` fetchpriority="${f}"`:u?' fetchpriority="high"':"",V=["avif","webp","jpeg","png"],q=[];for(let k of V){let z=p.get(k);if(z&&z.length>0){let M=Ie(z),X=F(k);q.push(` <source type="${X}" srcset="${M}" sizes="${w}" />`)}}let N="",W="",E;if(h!=="none"&&e?.placeholder){let k=`img-${Math.random().toString(36).slice(2,8)}`;if(N=`<div class="stx-image-wrapper" id="${k}">`,W="</div>",h==="blur")E=`
|
|
3
|
+
#${k} {
|
|
4
|
+
position: relative;
|
|
5
|
+
background-image: url('${e.placeholder}');
|
|
6
|
+
background-size: cover;
|
|
7
|
+
background-position: center;
|
|
8
|
+
}
|
|
9
|
+
#${k} img {
|
|
10
|
+
transition: opacity 0.3s ease;
|
|
11
|
+
}
|
|
12
|
+
#${k}.loaded img {
|
|
13
|
+
opacity: 1;
|
|
14
|
+
}
|
|
15
|
+
`.trim();else if(h==="color")E=`
|
|
16
|
+
#${k} {
|
|
17
|
+
background-color: ${e.placeholder};
|
|
18
|
+
}
|
|
19
|
+
`.trim()}let J=a?` width="${a}"`:e?` width="${e.width}"`:"",K=i?` height="${i}"`:e?` height="${e.height}"`:"",G=`${N}<picture>
|
|
20
|
+
${q.join(`
|
|
21
|
+
`)}
|
|
22
|
+
<img
|
|
23
|
+
src="${v?.url||t}"
|
|
24
|
+
alt="${U(n)}"${J}${K}${S}${A}${C}${T}${O}
|
|
25
|
+
/>
|
|
26
|
+
</picture>${W}`,_;if(u&&v){let k=p.get("webp"),z=k?.[Math.floor(k.length/2)]||v,M=F(z.format);_=`<link rel="preload" as="image" href="${z.url}" type="${M}" />`}return{html:G,preloadLink:_,placeholderCss:E}}function te(s){let{src:r,alt:e,width:t,height:n,loading:a="lazy",decoding:i="async",priority:m=!1,fetchpriority:o,objectFit:u,objectPosition:l}=s,{class:f,style:y}=s,c=[];if(u)c.push(`object-fit: ${u}`);if(l)c.push(`object-position: ${l}`);if(y)c.push(y);let h=c.length>0?` style="${c.join("; ")}"`:"",d=f?` class="${f}"`:"",g=t?` width="${t}"`:"",p=n?` height="${n}"`:"",v=m?"":` loading="${a}"`,w=` decoding="${i}"`,I=o?` fetchpriority="${o}"`:m?' fetchpriority="high"':"";return{html:`<img src="${r}" alt="${U(e)}"${g}${p}${d}${h}${v}${w}${I} />`}}function se(s){let{src:r,alt:e,width:t,height:n,sizes:a="100vw",loading:i="lazy",priority:m=!1,quality:o=B,formats:u=j,widths:l=L,decoding:f="async",fetchpriority:y,objectFit:c,objectPosition:h}=s,{class:d,style:g}=s,p=[];if(c)p.push(`object-fit: ${c}`);if(h)p.push(`object-position: ${h}`);if(g)p.push(g);let v=p.length>0?` style="${p.join("; ")}"`:"",w=d?` class="${d}"`:"",I=t?` width="${t}"`:"",b=n?` height="${n}"`:"",A=m?"":` loading="${i}"`,S=` decoding="${f}"`,C=y?` fetchpriority="${y}"`:m?' fetchpriority="high"':"",T=typeof a==="object"?ut(a):a,O=`
|
|
27
|
+
data-stx-image
|
|
28
|
+
data-src="${r}"
|
|
29
|
+
data-sizes="${T}"
|
|
30
|
+
data-quality="${o}"
|
|
31
|
+
data-formats="${u.join(",")}"
|
|
32
|
+
data-widths="${l.join(",")}"
|
|
33
|
+
`.replace(/\s+/g," ").trim();return{html:`<img src="${r}" alt="${U(e)}"${I}${b}${w}${v}${A}${S}${C} ${O} />`}}function Js(s){let r=s.match(/<Image\s+([^>]*?)\/?>/);if(!r)return null;let e=r[1],t={},n=/(\w+)(?:=(?:"([^"]*)"|'([^']*)'|(\{[^}]+\})))?/g,a;while((a=n.exec(e))!==null){let[,i,m,o,u]=a,l=m??o??u??!0;switch(i){case"src":t.src=String(l);break;case"alt":t.alt=String(l);break;case"width":t.width=Number(l)||l;break;case"height":t.height=Number(l)||l;break;case"sizes":t.sizes=String(l);break;case"loading":t.loading=l;break;case"priority":t.priority=l===!0||l==="true";break;case"quality":t.quality=Number(l);break;case"placeholder":t.placeholder=l;break;case"class":t.class=String(l);break;case"style":t.style=String(l);break;case"decoding":t.decoding=l;break;case"fetchpriority":t.fetchpriority=l;break;case"objectFit":t.objectFit=l;break;case"objectPosition":t.objectPosition=String(l);break}}if(!t.src||!t.alt)return null;return t}async function jo(s,r){let e=/<Image\s+[^>]*?\/?>/g,t=[],n=[],a=s,i,m=[];while((i=e.exec(s))!==null)m.push({match:i[0],index:i.index});for(let o=m.length-1;o>=0;o--){let{match:u}=m[o],l=Js(u);if(l){let f=await r(l);if(a=a.replace(u,f.html),f.preloadLink)t.push(f.preloadLink);if(f.placeholderCss)n.push(f.placeholderCss)}}return{html:a,preloadLinks:t,styles:n}}function U(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var D=new Map;function Bo(){D.clear()}async function re(s,r){let e=`${s}:${JSON.stringify(r)}`;if(D.has(e))return D.get(e);try{let t=await oe(s,r);return D.set(e,t),t}catch{return null}}function Ys(){return qe({name:"image",hasEndTag:!1,description:"Render an optimized image with responsive variants",transform:async(s,r,e)=>{let{src:t,alt:n,options:a}=ae(s,r,e);if(!t)return console.warn("@image directive: missing src argument"),"<!-- @image: missing src -->";let i={widths:a.widths||(a.width?[a.width]:L),formats:a.formats||j,quality:a.quality||B,placeholder:(a.placeholder==="color"?"dominant-color":a.placeholder)||"none"};if(!await Z())return H(t,n||"",a);let o=await re(t,i);if(!o)return H(t,n||"",a);return ne(o,n||"",a)}})}function ae(s,r,e){if(r.src)return{src:String(r.src),alt:String(r.alt||""),options:r.options||{}};let n=s.trim();if(n.startsWith("@image(")||n.startsWith("("))n=n.replace(/^@image\(/,"").replace(/^\(/,"").replace(/\)$/,"");let a=ie(n),i=a[0]||"",m=a[1]||"",o={};if(i&&!i.startsWith("/")&&!i.startsWith(".")&&!i.startsWith("http")){let u=e[i];if(typeof u==="string")i=u}if(a[2])try{if(typeof a[2]==="string")o=JSON.parse(a[2]);else o=a[2]}catch{}return{src:i,alt:m,options:o}}function ie(s){let r=[],e="",t=!1,n="",a=0,i=0;for(let m=0;m<s.length;m++){let o=s[m],u=m>0?s[m-1]:"";if((o==='"'||o==="'")&&u!=="\\"){if(!t)t=!0,n=o;else if(o===n)t=!1,n="";else e+=o;continue}if(!t){if(o==="{")a++;if(o==="}")a--;if(o==="[")i++;if(o==="]")i--;if(o===","&&a===0&&i===0){r.push(e.trim()),e="";continue}}e+=o}if(e.trim())r.push(e.trim());return r}function H(s,r,e){let t=[`src="${x(s)}"`];if(r)t.push(`alt="${x(r)}"`);if(e.width)t.push(`width="${e.width}"`);if(e.height)t.push(`height="${e.height}"`);if(e.class)t.push(`class="${x(e.class)}"`);if(e.style)t.push(`style="${x(e.style)}"`);if(e.lazy!==!1)t.push('loading="lazy"');return t.push('decoding="async"'),`<img ${t.join(" ")} />`}function ne(s,r,e){let{variants:t,placeholder:n,width:a,height:i,aspectRatio:m}=s,o=new Map;for(let g of t){let p=o.get(g.format)||[];p.push(g),o.set(g.format,p)}let u=["avif","webp","jpeg","png"],l=[];for(let g of u){let p=o.get(g);if(p&&p.length>0){let v=Ie(p),w=F(g),I=e.sizes||"100vw";l.push(` <source type="${w}" srcset="${x(v)}" sizes="${x(I)}" />`)}}let f=o.get("jpeg")||[],y=f.length>0?f[Math.floor(f.length/2)]:t[Math.floor(t.length/2)],c=[`src="${y?.url||s.src}"`,`alt="${x(r)}"`];if(e.width||a)c.push(`width="${e.width||a}"`);if(e.height||i)c.push(`height="${e.height||i}"`);if(e.class)c.push(`class="${x(e.class)}"`);let h=[];if(m)h.push(`aspect-ratio: ${m.toFixed(4)}`);if(e.style)h.push(e.style);if(h.length>0)c.push(`style="${h.join("; ")}"`);if(e.lazy!==!1&&!e.priority)c.push('loading="lazy"');if(c.push('decoding="async"'),e.priority)c.push('fetchpriority="high"');let d=`<picture>
|
|
34
|
+
`;if(d+=l.join(`
|
|
35
|
+
`)+`
|
|
36
|
+
`,d+=` <img ${c.join(" ")} />
|
|
37
|
+
`,d+="</picture>",e.placeholder&&n){let g=`stx-img-${Math.random().toString(36).slice(2,8)}`;if(e.placeholder==="blur"||e.placeholder==="thumbhash"){let p=n.replace(/'/g,"%27").replace(/"/g,"%22");d=`<div id="${g}" class="stx-image-placeholder" style="background-image: url('${p}'); background-size: cover;">
|
|
38
|
+
${d}
|
|
39
|
+
</div>`}else if(e.placeholder==="color"){let p=n.replace(/[^a-zA-Z0-9#(),.\s%-]/g,"");d=`<div id="${g}" class="stx-image-placeholder" style="background-color: ${p};">
|
|
40
|
+
${d}
|
|
41
|
+
</div>`}}if(e.priority&&y){let g=F(y.format);d=`<link rel="preload" as="image" href="${x(y.url)}" type="${g}" />
|
|
42
|
+
`+d}return d}function x(s){return s.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}var Fo=Ys();import P from"fs";import R from"path";function zo(s={}){let{inputDirs:r=["public","src/assets","assets"],outputDir:e="dist/images",baseUrl:t="/images",formats:n=j,widths:a=L,quality:i=B,placeholder:m="none",concurrency:o=4,cache:u=!0,cacheDir:l=".stx/image-cache",referencedOnly:f=!1,verbose:y=!1}=s,c={imageReferences:new Set,processedImages:new Map,stats:{totalImages:0,optimizedImages:0,savedBytes:0,variants:0}};return{name:"stx-image-optimization",async setup(h){if(!await Z()){console.warn("[stx-images] no image backend available, optimization disabled");return}if(u)await P.promises.mkdir(l,{recursive:!0});if(y){let g=await Lt();console.log("[stx-images] Plugin initialized"),console.log(` Backend: ${g?"sharp (native fast path) + ts-images":"ts-images (pure TS)"}`),console.log(` Input dirs: ${r.join(", ")}`),console.log(` Output dir: ${e}`),console.log(` Formats: ${n.join(", ")}`),console.log(` Widths: ${a.join(", ")}`)}},async buildStart(){c.imageReferences.clear(),c.processedImages.clear(),c.stats={totalImages:0,optimizedImages:0,savedBytes:0,variants:0}},async transform(h,d){if(d.endsWith(".html")||d.endsWith(".stx")){let g=ce(h);for(let p of g)c.imageReferences.add(p)}if(h.includes("<Image")||h.includes("@image"))return await ge(h,{formats:n,widths:a,quality:i,placeholder:m,outputDir:e,baseUrl:t,processedImages:c.processedImages});return h},async buildEnd(h){if(!await Z())return;await P.promises.mkdir(e,{recursive:!0});let g=[];for(let w of r){if(!P.existsSync(w))continue;let I=await Q(w);g.push(...I)}let p=f?g.filter((w)=>le(w,c.imageReferences)):g;if(c.stats.totalImages=p.length,y)console.log(`[stx-images] Processing ${p.length} images...`);let v=Y(p,o);for(let w of v)await Promise.all(w.map(async(I)=>{try{let b=await oe(I,{formats:n,widths:a,quality:i,placeholder:m,outputDir:e,baseUrl:t});c.processedImages.set(I,b),c.stats.optimizedImages++,c.stats.variants+=b.variants.length;let A=P.statSync(I).size,S=zt(b.variants);if(c.stats.savedBytes+=Math.max(0,A-S/b.variants.length),y)console.log(` \u2713 ${R.basename(I)} \u2192 ${b.variants.length} variants`)}catch(b){console.error(`[stx-images] Error processing ${I}:`,b)}}));if(console.log("[stx-images] Optimization complete:"),console.log(` Images: ${c.stats.optimizedImages}/${c.stats.totalImages}`),console.log(` Variants: ${c.stats.variants}`),c.stats.savedBytes>0)console.log(` Saved: ~${Ht(c.stats.savedBytes)}`)}}}function ce(s){let r=[],e=/src=["']([^"']+\.(jpg|jpeg|png|webp|avif|gif))["']/gi,t;while((t=e.exec(s))!==null)r.push(t[1]);let n=/<Image[^>]+src=["']([^"']+)["']/gi;while((t=n.exec(s))!==null)r.push(t[1]);let a=/@image\s*\(\s*['"]([^'"]+)['"]/gi;while((t=a.exec(s))!==null)r.push(t[1]);let i=/background(?:-image)?:\s*url\(["']?([^"')]+\.(jpg|jpeg|png|webp|avif|gif))["']?\)/gi;while((t=i.exec(s))!==null)r.push(t[1]);return r}function le(s,r){let e=R.basename(s);for(let t of r)if(t.endsWith(e)||t.includes(e))return!0;return!1}async function ge(s,r){return s}async function Q(s){let r=[];async function e(t){let n=await P.promises.readdir(t,{withFileTypes:!0});for(let a of n){let i=R.join(t,a.name);if(a.isDirectory())await e(i);else if(a.isFile()&&Ft(i))r.push(i)}}return await e(s),r}function Y(s,r){let e=[];for(let t=0;t<s.length;t+=r)e.push(s.slice(t,t+r));return e}async function Ho(s,r,e={}){if(!await Z())throw Error("No image backend available \u2014 install sharp or ensure ts-images is bundled");return oe(s,{...e,outputDir:r})}async function Vo(s,r,e={}){let{formats:t=j,widths:n=L,quality:a=B,placeholder:i="none",concurrency:m=4,verbose:o=!1}=e;if(!await Z())throw Error("No image backend available \u2014 install sharp or ensure ts-images is bundled");await P.promises.mkdir(r,{recursive:!0});let l=await Q(s),f=[],y={totalImages:l.length,optimizedImages:0,savedBytes:0,variants:0},c=Y(l,m);for(let h of c){let d=await Promise.all(h.map(async(g)=>{try{let p=await oe(g,{formats:t,widths:n,quality:a,placeholder:i,outputDir:r,baseUrl:"/"});if(y.optimizedImages++,y.variants+=p.variants.length,o)console.log(` \u2713 ${R.basename(g)}`);return p}catch(p){return console.error(`Error processing ${g}:`,p),null}}));f.push(...d.filter((g)=>g!==null))}return{processed:f,stats:y}}function Zs(s){let r={};for(let e of s)r[e.src]={variants:e.variants,placeholder:e.placeholder};return r}async function Uo(s,r){let e=Zs(s);await Bun.write(r,JSON.stringify(e,null,2))}var Uc={enabled:!0,widths:[320,640,768,1024,1280,1536,1920],formats:["webp","jpeg"],quality:80,devOptimize:!1,cacheDir:".stx/image-cache",placeholder:"none",inputDirs:["public","src/assets","assets"],outputDir:"dist/images",baseUrl:"/images"};
|
|
43
|
+
export{Lo,Js,jo,Bo,Ys,Fo,zo,Ho,Vo,Zs,Uo,Uc};
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ae,pt}from"./chunk-thyt8ed8.js";import{ge}from"./chunk-px7fvbj6.js";function m(e){let t={"cache-first":{className:"CacheFirst",importFrom:"workbox-strategies"},"network-first":{className:"NetworkFirst",importFrom:"workbox-strategies"},"stale-while-revalidate":{className:"StaleWhileRevalidate",importFrom:"workbox-strategies"},"network-only":{className:"NetworkOnly",importFrom:"workbox-strategies"},"cache-only":{className:"CacheOnly",importFrom:"workbox-strategies"}};return t[e]||t["network-first"]}function g(e){return m(e).className}function d(e){let t=e.pwa;if(!t?.enabled)return"";let r=t.routes||[],n=t.cacheStorage,c=[];for(let a of r){let i=g(a.strategy),s=[];if(a.maxAgeSeconds||a.maxEntries||n?.maxEntries){let o=a.maxEntries||n?.maxEntries||100,u=a.maxAgeSeconds||(n?.maxAge?n.maxAge*24*60*60:void 0);s.push(`new ExpirationPlugin({
|
|
3
|
+
maxEntries: ${o},
|
|
4
|
+
${u?`maxAgeSeconds: ${u},`:""}
|
|
5
|
+
purgeOnQuotaError: true,
|
|
6
|
+
})`)}if(a.strategy==="network-first"||a.strategy==="stale-while-revalidate")s.push(`new CacheableResponsePlugin({
|
|
7
|
+
statuses: [0, 200],
|
|
8
|
+
})`);let l=p(a.pattern);c.push(`
|
|
9
|
+
// ${a.pattern}
|
|
10
|
+
registerRoute(
|
|
11
|
+
${l},
|
|
12
|
+
new ${i}({
|
|
13
|
+
cacheName: '${a.cacheName||h(a.pattern)}',
|
|
14
|
+
${s.length>0?`plugins: [
|
|
15
|
+
${s.join(`,
|
|
16
|
+
`)}
|
|
17
|
+
],`:""}
|
|
18
|
+
})
|
|
19
|
+
);`)}return c.join(`
|
|
20
|
+
`)}function p(e){if(e.startsWith("*.")){let t=e.slice(2);return`({ request }) => request.destination === '${f(t)}'`}if(e.endsWith("/**"))return`({ url }) => url.pathname.startsWith('${e.slice(0,-3)}')`;if(e.endsWith("/*")){let t=e.slice(0,-2);return`({ url }) => url.pathname.startsWith('${t}') && !url.pathname.slice(${t.length+1}).includes('/')`}if(e.includes("*")&&!e.startsWith("*")){let[t,r]=e.split("*");return`({ url }) => url.pathname.startsWith('${t}') && url.pathname.endsWith('${r}')`}if(e==="/"||!e.includes("*"))return`({ url }) => url.pathname === '${e}'`;return`new RegExp('${x(e).replace(/\\\*/g,".*")}')`}function f(e){return{js:"script",mjs:"script",css:"style",html:"document",htm:"document",png:"image",jpg:"image",jpeg:"image",gif:"image",svg:"image",webp:"image",avif:"image",ico:"image",woff:"font",woff2:"font",ttf:"font",eot:"font",otf:"font"}[e.toLowerCase()]||"empty"}function h(e){return"stx-"+e.replace(/[^\w]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").toLowerCase().slice(0,30)+"-cache"}function x(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function b(e,t){let r=e.pwa;if(!r?.enabled)return{mode:"generate",modules:[],skipWaiting:!0,clientsClaim:!0};let n=r.serviceWorker||{},c=r.routes||[],a=[{name:"workbox-precaching",exports:["precacheAndRoute","cleanupOutdatedCaches"]},{name:"workbox-routing",exports:["registerRoute","NavigationRoute","setDefaultHandler"]}],i=new Set;for(let o of c)i.add(g(o.strategy));if(i.size>0)a.push({name:"workbox-strategies",exports:Array.from(i)});if(c.some((o)=>o.maxAgeSeconds||o.maxEntries)||r.cacheStorage)a.push({name:"workbox-expiration",exports:["ExpirationPlugin"]});if(c.some((o)=>o.strategy==="network-first"||o.strategy==="stale-while-revalidate"))a.push({name:"workbox-cacheable-response",exports:["CacheableResponsePlugin"]});if(r.backgroundSync?.enabled)a.push({name:"workbox-background-sync",exports:["BackgroundSyncPlugin","Queue"]});if(n.navigationPreload)a.push({name:"workbox-navigation-preload",exports:["enable"]});let l=t?ae(t,e):void 0;return{mode:"generate",modules:a,precacheManifest:l?.entries,skipWaiting:n.skipWaiting??!0,clientsClaim:n.clientsClaim??!0,offlineFallback:r.offline?.enabled?"/offline.html":void 0,navigationPreload:n.navigationPreload??!1,cacheVersion:n.cacheVersion||"1.0.0"}}function W(e,t){let r=e.pwa;if(!r?.enabled)return"";let n=b(e,t),c=r.serviceWorker||{},{push:a,backgroundSync:i}=r,s=t?ae(t,e):null,l=s?pt(s):"[]",o=k(n.modules),u=d(e);return`/**
|
|
21
|
+
* Service Worker - Generated by stx with Workbox
|
|
22
|
+
* Cache Version: ${n.cacheVersion}
|
|
23
|
+
*
|
|
24
|
+
* This service worker uses Google's Workbox library for robust caching.
|
|
25
|
+
* https://developers.google.com/web/tools/workbox
|
|
26
|
+
*
|
|
27
|
+
* Features:
|
|
28
|
+
* - Precaching with automatic revision management
|
|
29
|
+
* - Runtime caching with multiple strategies
|
|
30
|
+
* - Offline fallback support
|
|
31
|
+
* - Push notifications: ${a?.enabled?"enabled":"disabled"}
|
|
32
|
+
* - Background sync: ${i?.enabled?"enabled":"disabled"}
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
// Import Workbox modules from CDN
|
|
36
|
+
importScripts('https://storage.googleapis.com/workbox-cdn/releases/7.0.0/workbox-sw.js');
|
|
37
|
+
|
|
38
|
+
// Disable Workbox logging in production. Through isProduction() rather than
|
|
39
|
+
// off process.env.NODE_ENV: this is inside a template literal, so the
|
|
40
|
+
// comparison is evaluated when the service worker is GENERATED -- and the
|
|
41
|
+
// build's transpiler folds that particular read to a constant, so every
|
|
42
|
+
// published copy of stx emitted "debug: true" and no app could turn Workbox's
|
|
43
|
+
// logging off in production however it set NODE_ENV (see ../env.ts).
|
|
44
|
+
workbox.setConfig({ debug: ${!ge()} });
|
|
45
|
+
|
|
46
|
+
// Extract modules from workbox global
|
|
47
|
+
${o}
|
|
48
|
+
|
|
49
|
+
const CACHE_VERSION = '${n.cacheVersion}';
|
|
50
|
+
const OFFLINE_PAGE = '${n.offlineFallback||"/offline.html"}';
|
|
51
|
+
|
|
52
|
+
// ============================================================================
|
|
53
|
+
// Precaching
|
|
54
|
+
// ============================================================================
|
|
55
|
+
|
|
56
|
+
// Clean up outdated caches from previous versions
|
|
57
|
+
cleanupOutdatedCaches();
|
|
58
|
+
|
|
59
|
+
// Precache static assets
|
|
60
|
+
// The manifest is injected during build or defined below
|
|
61
|
+
const PRECACHE_MANIFEST = ${l};
|
|
62
|
+
|
|
63
|
+
// Add essential assets
|
|
64
|
+
PRECACHE_MANIFEST.push(
|
|
65
|
+
{ url: '/', revision: CACHE_VERSION },
|
|
66
|
+
{ url: '/manifest.json', revision: CACHE_VERSION },
|
|
67
|
+
${n.offlineFallback?`{ url: '${n.offlineFallback}', revision: CACHE_VERSION },`:""}
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
// Precache and route all manifest entries
|
|
71
|
+
precacheAndRoute(PRECACHE_MANIFEST);
|
|
72
|
+
|
|
73
|
+
// ============================================================================
|
|
74
|
+
// Navigation Preload
|
|
75
|
+
// ============================================================================
|
|
76
|
+
|
|
77
|
+
${n.navigationPreload?`// Enable navigation preload for faster page loads
|
|
78
|
+
enable();`:"// Navigation preload disabled"}
|
|
79
|
+
|
|
80
|
+
// ============================================================================
|
|
81
|
+
// Runtime Caching
|
|
82
|
+
// ============================================================================
|
|
83
|
+
|
|
84
|
+
${u}
|
|
85
|
+
|
|
86
|
+
// ============================================================================
|
|
87
|
+
// Offline Fallback
|
|
88
|
+
// ============================================================================
|
|
89
|
+
|
|
90
|
+
${n.offlineFallback?`
|
|
91
|
+
// Set up offline fallback for navigation requests
|
|
92
|
+
const navigationRoute = new NavigationRoute(
|
|
93
|
+
new NetworkFirst({
|
|
94
|
+
cacheName: 'stx-pages-cache',
|
|
95
|
+
plugins: [
|
|
96
|
+
new CacheableResponsePlugin({ statuses: [0, 200] }),
|
|
97
|
+
],
|
|
98
|
+
}),
|
|
99
|
+
{
|
|
100
|
+
// Return offline page when navigation fails
|
|
101
|
+
async allowedHandler(request) {
|
|
102
|
+
try {
|
|
103
|
+
const response = await this.handle(request);
|
|
104
|
+
return response;
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
const cache = await caches.open('stx-offline-cache');
|
|
108
|
+
return cache.match(OFFLINE_PAGE) || new Response('You are offline', {
|
|
109
|
+
status: 503,
|
|
110
|
+
statusText: 'Service Unavailable',
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
registerRoute(navigationRoute);
|
|
117
|
+
`:"// No offline fallback configured"}
|
|
118
|
+
|
|
119
|
+
// Default handler for unmatched requests
|
|
120
|
+
setDefaultHandler(new NetworkFirst({
|
|
121
|
+
cacheName: 'stx-default-cache',
|
|
122
|
+
plugins: [
|
|
123
|
+
new CacheableResponsePlugin({ statuses: [0, 200] }),
|
|
124
|
+
new ExpirationPlugin({ maxEntries: 100, maxAgeSeconds: 60 * 60 * 24 }), // 1 day
|
|
125
|
+
],
|
|
126
|
+
}));
|
|
127
|
+
|
|
128
|
+
// ============================================================================
|
|
129
|
+
// Service Worker Lifecycle
|
|
130
|
+
// ============================================================================
|
|
131
|
+
|
|
132
|
+
${n.skipWaiting?`// Skip waiting - activate immediately
|
|
133
|
+
self.skipWaiting();`:"// Manual skipWaiting - user must trigger update"}
|
|
134
|
+
|
|
135
|
+
${n.clientsClaim?`// Claim clients - take control immediately
|
|
136
|
+
self.addEventListener('activate', () => {
|
|
137
|
+
self.clients.claim();
|
|
138
|
+
});`:"// Manual clients claim"}
|
|
139
|
+
|
|
140
|
+
// ============================================================================
|
|
141
|
+
// Message Handling
|
|
142
|
+
// ============================================================================
|
|
143
|
+
|
|
144
|
+
self.addEventListener('message', (event) => {
|
|
145
|
+
const { type, payload } = event.data || {};
|
|
146
|
+
|
|
147
|
+
switch (type) {
|
|
148
|
+
case 'SKIP_WAITING':
|
|
149
|
+
self.skipWaiting();
|
|
150
|
+
break;
|
|
151
|
+
|
|
152
|
+
case 'GET_VERSION':
|
|
153
|
+
event.source?.postMessage({ type: 'VERSION', payload: CACHE_VERSION });
|
|
154
|
+
break;
|
|
155
|
+
|
|
156
|
+
case 'CACHE_URLS':
|
|
157
|
+
if (Array.isArray(payload)) {
|
|
158
|
+
event.waitUntil(
|
|
159
|
+
caches.open('stx-dynamic-cache').then(cache => cache.addAll(payload))
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
break;
|
|
163
|
+
|
|
164
|
+
case 'CLEAR_CACHE':
|
|
165
|
+
event.waitUntil(
|
|
166
|
+
caches.keys().then(names =>
|
|
167
|
+
Promise.all(names.map(name => caches.delete(name)))
|
|
168
|
+
)
|
|
169
|
+
);
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
${a?.enabled?y(a):"// Push notifications disabled"}
|
|
175
|
+
|
|
176
|
+
${i?.enabled?S(i):"// Background sync disabled"}
|
|
177
|
+
|
|
178
|
+
console.log('[Workbox SW] Service Worker loaded - Version:', CACHE_VERSION);
|
|
179
|
+
`}function k(e){let t=[];for(let r of e){let n=r.name.replace("workbox-","");t.push(`const { ${r.exports.join(", ")} } = workbox.${w(n)};`)}return t.join(`
|
|
180
|
+
`)}function w(e){return e.replace(/-([a-z])/g,(t,r)=>r.toUpperCase())}function y(e){return`
|
|
181
|
+
// ============================================================================
|
|
182
|
+
// Push Notifications
|
|
183
|
+
// ============================================================================
|
|
184
|
+
|
|
185
|
+
const PUSH_CONFIG = {
|
|
186
|
+
defaultIcon: '${e?.defaultIcon||"/pwa-icons/icon-192x192.png"}',
|
|
187
|
+
defaultBadge: '${e?.defaultBadge||"/pwa-icons/icon-72x72.png"}',
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
self.addEventListener('push', (event) => {
|
|
191
|
+
console.log('[Workbox SW] Push notification received');
|
|
192
|
+
|
|
193
|
+
let data = {
|
|
194
|
+
title: 'Notification',
|
|
195
|
+
body: 'You have a new notification',
|
|
196
|
+
icon: PUSH_CONFIG.defaultIcon,
|
|
197
|
+
badge: PUSH_CONFIG.defaultBadge,
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
if (event.data) {
|
|
201
|
+
try {
|
|
202
|
+
const payload = event.data.json();
|
|
203
|
+
data = { ...data, ...payload };
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
data.body = event.data.text();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const options = {
|
|
211
|
+
body: data.body,
|
|
212
|
+
icon: data.icon || PUSH_CONFIG.defaultIcon,
|
|
213
|
+
badge: data.badge || PUSH_CONFIG.defaultBadge,
|
|
214
|
+
vibrate: data.vibrate || [100, 50, 100],
|
|
215
|
+
data: {
|
|
216
|
+
url: data.url || '/',
|
|
217
|
+
...data.data,
|
|
218
|
+
},
|
|
219
|
+
actions: data.actions || [],
|
|
220
|
+
tag: data.tag,
|
|
221
|
+
renotify: data.renotify || false,
|
|
222
|
+
requireInteraction: data.requireInteraction || false,
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
event.waitUntil(
|
|
226
|
+
self.registration.showNotification(data.title, options)
|
|
227
|
+
);
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
self.addEventListener('notificationclick', (event) => {
|
|
231
|
+
console.log('[Workbox SW] Notification clicked');
|
|
232
|
+
event.notification.close();
|
|
233
|
+
|
|
234
|
+
const url = event.notification.data?.url || '/';
|
|
235
|
+
|
|
236
|
+
event.waitUntil(
|
|
237
|
+
clients.matchAll({ type: 'window', includeUncontrolled: true }).then(windowClients => {
|
|
238
|
+
for (const client of windowClients) {
|
|
239
|
+
if (client.url === url && 'focus' in client) {
|
|
240
|
+
return client.focus();
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
if (clients.openWindow) {
|
|
244
|
+
return clients.openWindow(url);
|
|
245
|
+
}
|
|
246
|
+
})
|
|
247
|
+
);
|
|
248
|
+
});
|
|
249
|
+
`}function S(e){return`
|
|
250
|
+
// ============================================================================
|
|
251
|
+
// Background Sync
|
|
252
|
+
// ============================================================================
|
|
253
|
+
|
|
254
|
+
const syncQueue = new Queue('${e?.queueName||"stx-sync-queue"}', {
|
|
255
|
+
maxRetentionTime: ${e?.maxRetentionMinutes||1440}, // minutes
|
|
256
|
+
onSync: async ({ queue }) => {
|
|
257
|
+
let entry;
|
|
258
|
+
while ((entry = await queue.shiftRequest())) {
|
|
259
|
+
try {
|
|
260
|
+
await fetch(entry.request.clone());
|
|
261
|
+
console.log('[Workbox SW] Sync succeeded:', entry.request.url);
|
|
262
|
+
|
|
263
|
+
// Notify clients
|
|
264
|
+
const allClients = await self.clients.matchAll();
|
|
265
|
+
allClients.forEach(client => {
|
|
266
|
+
client.postMessage({
|
|
267
|
+
type: 'SYNC_COMPLETE',
|
|
268
|
+
url: entry.request.url,
|
|
269
|
+
success: true,
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
catch (error) {
|
|
274
|
+
console.log('[Workbox SW] Sync failed, re-queuing:', entry.request.url);
|
|
275
|
+
await queue.unshiftRequest(entry);
|
|
276
|
+
throw error;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
// Register routes that should use background sync
|
|
283
|
+
${e?.endpoints?.map((t)=>`
|
|
284
|
+
registerRoute(
|
|
285
|
+
({ url }) => url.pathname.startsWith('${t}'),
|
|
286
|
+
new NetworkOnly({
|
|
287
|
+
plugins: [
|
|
288
|
+
new BackgroundSyncPlugin('${e?.queueName||"stx-sync-queue"}', {
|
|
289
|
+
maxRetentionTime: ${e?.maxRetentionMinutes||1440},
|
|
290
|
+
}),
|
|
291
|
+
],
|
|
292
|
+
}),
|
|
293
|
+
'POST'
|
|
294
|
+
);`).join(`
|
|
295
|
+
`)||"// No background sync endpoints configured"}
|
|
296
|
+
|
|
297
|
+
// Handle form sync messages
|
|
298
|
+
self.addEventListener('message', (event) => {
|
|
299
|
+
if (event.data?.type === 'REGISTER_FORM_SYNC') {
|
|
300
|
+
const { action, method, data } = event.data.payload;
|
|
301
|
+
|
|
302
|
+
const request = new Request(action, {
|
|
303
|
+
method: method || 'POST',
|
|
304
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
305
|
+
body: new URLSearchParams(data).toString(),
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
event.waitUntil(syncQueue.pushRequest({ request }));
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
`}export{W as generateWorkboxServiceWorker};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{existsSync as W,mkdirSync as We,readFileSync as H}from"fs";import x from"path";import{existsSync as Re,mkdirSync as Ne}from"fs";import w from"path";var Z=/^[A-Za-z_$][\w$]*(?:\??\.[A-Za-z_$][\w$]*)*$/,Q=new Bun.Transpiler({loader:"ts"});function N(t){try{return Q.transformSync(t),!0}catch{return!1}}function O(t){let e=[...new Set(t)];return e.length?`const { ${e.join(", ")} } = __s; `:""}function L(t){return t._source?`<${t.type}> at ${t._source.file}:${t._source.line}`:`<${t.type}>`}function T(t,e,n,r,i){let s=e.trim();if(!s||!N(`(${s}
|
|
3
|
+
)`))throw Error(`Cannot compile ${i} "${e}" on ${L(r)}`);return t.functions.push(`function (__s) { ${O(n)}return (${s}
|
|
4
|
+
) }`),t.functions.length-1}function ee(t,e,n,r,i){let s=e.trim(),o;if(Z.test(s))o=`return typeof ${s} === 'function' ? ${s}($event) : undefined`;else if(N(`(${s}
|
|
5
|
+
)`))o=`const __r = (${s}
|
|
6
|
+
); return typeof __r === 'function' ? __r($event) : __r`;else if(N(s))o=s;else throw Error(`Cannot compile handler ${i}="${e}" on ${L(r)}`);return t.functions.push(`function (__s, $event) { ${O(n)}${o}
|
|
7
|
+
}`),t.functions.length-1}function te(t){let e=[],n=0,r=-1,i=0;for(let s=0;s<t.length;s++){let o=t[s];if(o==="{"){if(n===0)r=s;n++}else if(o==="}"&&n>0){if(n--,n===0){if(r>i)e.push({text:t.slice(i,r)});e.push({expression:t.slice(r+1,s)}),i=s+1}}}if(!e.some((s)=>("expression"in s)))return null;if(i<t.length)e.push({text:t.slice(i)});return e}function R(t,e,n,r,i){if(typeof e!=="string")return e;let s=te(e);if(!s)return e;if(s.length===1&&"expression"in s[0])return{$x:T(t,s[0].expression,n,r,i)};let o=s.map((c)=>("text"in c)?JSON.stringify(c.text):`__stxText(${c.expression.trim()}
|
|
8
|
+
)`).join(" + ");return{$x:T(t,o,n,r,i)}}function I(t,e,n){let r=e.directives,i={type:e.type,props:{},style:e.style??{},events:{},children:[]};if(e.darkStyle)i.darkStyle=e.darkStyle;let s=n;if(r?.for){let a=r.for;i.directives={for:{source:T(t,a.source,n,e,":for"),item:a.item,...a.index?{index:a.index}:{}}},s=[...n,a.item,...a.index?[a.index]:[]]}if(r){let a=i.directives??{};if(r.if!==void 0)a.if=T(t,r.if,s,e,":if");if(r.elseIf!==void 0)a.elseIf=T(t,r.elseIf,s,e,":else-if");if(r.else)a.else=!0;if(r.show!==void 0)a.show=T(t,r.show,s,e,":show");if(Object.keys(a).length)i.directives=a}if(e.bindings){let a={};for(let[d,S]of Object.entries(e.bindings)){if(d!=="class"&&d!=="style")continue;a[d]=T(t,S,s,e,`:${d}`)}if(Object.keys(a).length)i.bindings=a}if(e.key!==void 0)i.key=R(t,e.key,s,e,"key");let o=e.type==="FlatList"&&e.props.data!==void 0,c=o?[...s,"item","index"]:s,l=i.props;for(let[a,d]of Object.entries(e.props))l[a]=R(t,d,a==="keyExtractor"&&o?c:s,e,a);let h=i.events;for(let[a,d]of Object.entries(e.events))h[a]=ee(t,d,s,e,a);return i.children=e.children.map((a)=>typeof a==="string"?R(t,a,c,e,"text"):I(t,a,c)),i}function z(t){let e={functions:[],warnings:[...t.meta.warnings??[]],source:t.meta.source},n=I(e,t.root,[]),r=t.script.functions.filter((s)=>/^[A-Za-z_$][\w$]*$/.test(s)).map((s)=>`${JSON.stringify(s)}: typeof ${s} === 'function' ? ${s} : undefined`);return{code:[`import { mount as __stxMount } from ${JSON.stringify("stx:native-runtime")}`,"",t.script.code,"","// Generated by stx native from the template below the script.","function __stxText(value: any): string { return value == null || value === false ? '' : String(value) }","__stxMount({",` document: { root: ${JSON.stringify(n)} },`,` expressions: [
|
|
9
|
+
${e.functions.join(`,
|
|
10
|
+
`)}
|
|
11
|
+
] as any[],`,` functions: { ${r.join(", ")} },`,"})",""].join(`
|
|
12
|
+
`),template:n,warnings:e.warnings}}function v(t,e={},n={},r={},i=[]){return{type:t,props:e,style:n,events:r,children:i}}function B(t,e,n={}){return{version:"1.0.0",root:t,script:e,meta:{source:n.source||"unknown",compiledAt:n.compiledAt||Date.now(),headwindConfig:n.headwindConfig}}}var ne={transparent:"transparent",current:"currentColor",black:"#000000",white:"#ffffff",slate:{50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",900:"#0f172a",950:"#020617"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"},zinc:{50:"#fafafa",100:"#f4f4f5",200:"#e4e4e7",300:"#d4d4d8",400:"#a1a1aa",500:"#71717a",600:"#52525b",700:"#3f3f46",800:"#27272a",900:"#18181b",950:"#09090b"},red:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d",950:"#450a0a"},orange:{50:"#fff7ed",100:"#ffedd5",200:"#fed7aa",300:"#fdba74",400:"#fb923c",500:"#f97316",600:"#ea580c",700:"#c2410c",800:"#9a3412",900:"#7c2d12",950:"#431407"},amber:{50:"#fffbeb",100:"#fef3c7",200:"#fde68a",300:"#fcd34d",400:"#fbbf24",500:"#f59e0b",600:"#d97706",700:"#b45309",800:"#92400e",900:"#78350f",950:"#451a03"},yellow:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12",950:"#422006"},green:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d",950:"#052e16"},emerald:{50:"#ecfdf5",100:"#d1fae5",200:"#a7f3d0",300:"#6ee7b7",400:"#34d399",500:"#10b981",600:"#059669",700:"#047857",800:"#065f46",900:"#064e3b",950:"#022c22"},teal:{50:"#f0fdfa",100:"#ccfbf1",200:"#99f6e4",300:"#5eead4",400:"#2dd4bf",500:"#14b8a6",600:"#0d9488",700:"#0f766e",800:"#115e59",900:"#134e4a",950:"#042f2e"},cyan:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"},sky:{50:"#f0f9ff",100:"#e0f2fe",200:"#bae6fd",300:"#7dd3fc",400:"#38bdf8",500:"#0ea5e9",600:"#0284c7",700:"#0369a1",800:"#075985",900:"#0c4a6e",950:"#082f49"},lime:{50:"#f7fee7",100:"#ecfccb",200:"#d9f99d",300:"#bef264",400:"#a3e635",500:"#84cc16",600:"#65a30d",700:"#4d7c0f",800:"#3f6212",900:"#365314",950:"#1a2e05"},fuchsia:{50:"#fdf4ff",100:"#fae8ff",200:"#f5d0fe",300:"#f0abfc",400:"#e879f9",500:"#d946ef",600:"#c026d3",700:"#a21caf",800:"#86198f",900:"#701a75",950:"#4a044e"},neutral:{50:"#fafafa",100:"#f5f5f5",200:"#e5e5e5",300:"#d4d4d4",400:"#a3a3a3",500:"#737373",600:"#525252",700:"#404040",800:"#262626",900:"#171717",950:"#0a0a0a"},stone:{50:"#fafaf9",100:"#f5f5f4",200:"#e7e5e4",300:"#d6d3d1",400:"#a8a29e",500:"#78716c",600:"#57534e",700:"#44403c",800:"#292524",900:"#1c1917",950:"#0c0a09"},blue:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"},indigo:{50:"#eef2ff",100:"#e0e7ff",200:"#c7d2fe",300:"#a5b4fc",400:"#818cf8",500:"#6366f1",600:"#4f46e5",700:"#4338ca",800:"#3730a3",900:"#312e81",950:"#1e1b4b"},violet:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"},purple:{50:"#faf5ff",100:"#f3e8ff",200:"#e9d5ff",300:"#d8b4fe",400:"#c084fc",500:"#a855f7",600:"#9333ea",700:"#7e22ce",800:"#6b21a8",900:"#581c87",950:"#3b0764"},pink:{50:"#fdf2f8",100:"#fce7f3",200:"#fbcfe8",300:"#f9a8d4",400:"#f472b6",500:"#ec4899",600:"#db2777",700:"#be185d",800:"#9d174d",900:"#831843",950:"#500724"},rose:{50:"#fff1f2",100:"#ffe4e6",200:"#fecdd3",300:"#fda4af",400:"#fb7185",500:"#f43f5e",600:"#e11d48",700:"#be123c",800:"#9f1239",900:"#881337",950:"#4c0519"}},P={px:1,0:0,0.5:2,1:4,1.5:6,2:8,2.5:10,3:12,3.5:14,4:16,5:20,6:24,7:28,8:32,9:36,10:40,11:44,12:48,14:56,16:64,20:80,24:96,28:112,32:128,36:144,40:160,44:176,48:192,52:208,56:224,60:240,64:256,72:288,80:320,96:384},A={xs:12,sm:14,base:16,lg:18,xl:20,"2xl":24,"3xl":30,"4xl":36,"5xl":48,"6xl":60,"7xl":72,"8xl":96,"9xl":128},b={none:0,sm:2,DEFAULT:4,md:6,lg:8,xl:12,"2xl":16,"3xl":24,full:9999};function k(t){let e=t.lastIndexOf("/");if(e>0&&!t.endsWith("]")){let r=k(t.slice(0,e)),i=t.slice(e+1),s=/^\[(.+)\]$/.test(i)?Number.parseFloat(i.slice(1,-1))*(i.includes("%")?1:100):Number.parseFloat(i);if(!r||!Number.isFinite(s))return;return re(r,s/100)}if(t==="transparent")return"transparent";if(t==="current")return"currentColor";if(t==="black")return"#000000";if(t==="white")return"#ffffff";let n=t.split("-");if(n.length===2){let[r,i]=n,s=ne[r];if(s&&typeof s==="object")return s[i]}if(t.startsWith("[")&&t.endsWith("]")){let r=t.slice(1,-1);return/^(#|rgba?\(|hsla?\(|[a-z]+$)/i.test(r)?r:void 0}return}function re(t,e){if(t==="transparent")return t;let n=t.startsWith("#")?t.slice(1):"";if(n.length===3)n=n.split("").map((i)=>i+i).join("");if(n.length===8)n=n.slice(0,6);if(n.length!==6)return;let r=Math.round(Math.min(1,Math.max(0,e))*255);return`#${n}${r.toString(16).padStart(2,"0")}`}function C(t,e=16){if(!t.startsWith("[")||!t.endsWith("]"))return;let n=t.slice(1,-1),r=Number.parseFloat(n);if(!Number.isFinite(r))return;if(n.endsWith("rem"))return r*16;if(n.endsWith("em"))return r*e;return r}function p(t){if(t.startsWith("[")&&t.endsWith("]")){let e=t.slice(1,-1),n=e.endsWith("rem")?Number.parseFloat(e)*16:Number.parseFloat(e);return Number.isFinite(n)?n:void 0}return P[t]}var ie={flex:(t,e)=>(e.display="flex",!0),hidden:(t,e)=>(e.display="none",!0),grid:(t,e)=>(e.display="grid",!0),"flex-row":(t,e)=>(e.flexDirection="row",!0),"flex-col":(t,e)=>(e.flexDirection="column",!0),"flex-row-reverse":(t,e)=>(e.flexDirection="row-reverse",!0),"flex-col-reverse":(t,e)=>(e.flexDirection="column-reverse",!0),"flex-wrap":(t,e)=>(e.flexWrap="wrap",!0),"flex-nowrap":(t,e)=>(e.flexWrap="nowrap",!0),"flex-wrap-reverse":(t,e)=>(e.flexWrap="wrap-reverse",!0),"flex-1":(t,e)=>(e.flex=1,e.flexGrow=1,e.flexShrink=1,e.flexBasis=0,!0),"flex-auto":(t,e)=>(e.flexGrow=1,e.flexShrink=1,!0),"flex-initial":(t,e)=>(e.flexGrow=0,e.flexShrink=1,!0),"flex-none":(t,e)=>(e.flexGrow=0,e.flexShrink=0,!0),grow:(t,e)=>(e.flexGrow=1,!0),"grow-0":(t,e)=>(e.flexGrow=0,!0),shrink:(t,e)=>(e.flexShrink=1,!0),"shrink-0":(t,e)=>(e.flexShrink=0,!0),"justify-start":(t,e)=>(e.justifyContent="flex-start",!0),"justify-center":(t,e)=>(e.justifyContent="center",!0),"justify-end":(t,e)=>(e.justifyContent="flex-end",!0),"justify-between":(t,e)=>(e.justifyContent="space-between",!0),"justify-around":(t,e)=>(e.justifyContent="space-around",!0),"justify-evenly":(t,e)=>(e.justifyContent="space-evenly",!0),"items-start":(t,e)=>(e.alignItems="flex-start",!0),"items-center":(t,e)=>(e.alignItems="center",!0),"items-end":(t,e)=>(e.alignItems="flex-end",!0),"items-stretch":(t,e)=>(e.alignItems="stretch",!0),"items-baseline":(t,e)=>(e.alignItems="baseline",!0),"self-auto":(t,e)=>(e.alignSelf="auto",!0),"self-start":(t,e)=>(e.alignSelf="flex-start",!0),"self-center":(t,e)=>(e.alignSelf="center",!0),"self-end":(t,e)=>(e.alignSelf="flex-end",!0),"self-stretch":(t,e)=>(e.alignSelf="stretch",!0),"self-baseline":(t,e)=>(e.alignSelf="baseline",!0),"min-w-0":(t,e)=>(e.minWidth=0,!0),"aspect-square":(t,e)=>(e.aspectRatio=1,!0),"inset-0":(t,e)=>(e.top=0,e.right=0,e.bottom=0,e.left=0,!0),"tracking-tighter":(t,e)=>(e.letterSpacing=-0.8,!0),"tracking-tight":(t,e)=>(e.letterSpacing=-0.4,!0),"tracking-normal":(t,e)=>(e.letterSpacing=0,!0),"tracking-wide":(t,e)=>(e.letterSpacing=0.4,!0),"tracking-wider":(t,e)=>(e.letterSpacing=0.8,!0),"tracking-widest":(t,e)=>(e.letterSpacing=1.6,!0),"tabular-nums":()=>!0,block:()=>!0,"inline-flex":(t,e)=>(e.display="flex",!0),truncate:()=>!0,relative:(t,e)=>(e.position="relative",!0),absolute:(t,e)=>(e.position="absolute",!0),"overflow-visible":(t,e)=>(e.overflow="visible",!0),"overflow-hidden":(t,e)=>(e.overflow="hidden",!0),"overflow-scroll":(t,e)=>(e.overflow="scroll",!0),"font-thin":(t,e)=>(e.fontWeight="100",!0),"font-extralight":(t,e)=>(e.fontWeight="200",!0),"font-light":(t,e)=>(e.fontWeight="300",!0),"font-normal":(t,e)=>(e.fontWeight="400",!0),"font-medium":(t,e)=>(e.fontWeight="500",!0),"font-semibold":(t,e)=>(e.fontWeight="600",!0),"font-bold":(t,e)=>(e.fontWeight="bold",!0),"font-extrabold":(t,e)=>(e.fontWeight="800",!0),"font-black":(t,e)=>(e.fontWeight="900",!0),italic:(t,e)=>(e.fontStyle="italic",!0),"not-italic":(t,e)=>(e.fontStyle="normal",!0),"text-left":(t,e)=>(e.textAlign="left",!0),"text-center":(t,e)=>(e.textAlign="center",!0),"text-right":(t,e)=>(e.textAlign="right",!0),"text-justify":(t,e)=>(e.textAlign="justify",!0),uppercase:(t,e)=>(e.textTransform="uppercase",!0),lowercase:(t,e)=>(e.textTransform="lowercase",!0),capitalize:(t,e)=>(e.textTransform="capitalize",!0),"normal-case":(t,e)=>(e.textTransform="none",!0),underline:(t,e)=>(e.textDecorationLine="underline",!0),"line-through":(t,e)=>(e.textDecorationLine="line-through",!0),"no-underline":(t,e)=>(e.textDecorationLine="none",!0)};function se(t,e){if(!t.startsWith("bg-"))return!1;let n=t.slice(3),r=k(n);if(r)return e.backgroundColor=r,!0;return!1}function oe(t,e){if(!t.startsWith("text-"))return!1;let n=t.slice(5);if(A[n])return e.fontSize=A[n],!0;if(n.startsWith("[")&&n.endsWith("]")){let i=n.slice(1,-1);if(/^-?[\d.]+(?:px|r?em)?$/.test(i)){let s=i.endsWith("rem")||i.endsWith("em")?Number.parseFloat(i)*16:Number.parseFloat(i);if(Number.isFinite(s))return e.fontSize=s,!0}}let r=k(n);if(r)return e.color=r,!0;return!1}function ae(t,e){if(t.startsWith("p-")){let n=p(t.slice(2));if(n!==void 0)return e.padding=n,!0}if(t.startsWith("px-")){let n=p(t.slice(3));if(n!==void 0)return e.paddingHorizontal=n,!0}if(t.startsWith("py-")){let n=p(t.slice(3));if(n!==void 0)return e.paddingVertical=n,!0}if(t.startsWith("pt-")){let n=p(t.slice(3));if(n!==void 0)return e.paddingTop=n,!0}if(t.startsWith("pr-")){let n=p(t.slice(3));if(n!==void 0)return e.paddingRight=n,!0}if(t.startsWith("pb-")){let n=p(t.slice(3));if(n!==void 0)return e.paddingBottom=n,!0}if(t.startsWith("pl-")){let n=p(t.slice(3));if(n!==void 0)return e.paddingLeft=n,!0}return!1}function ce(t,e){if(t.startsWith("m-")){let n=p(t.slice(2));if(n!==void 0)return e.margin=n,!0}if(t.startsWith("mx-")){let n=p(t.slice(3));if(n!==void 0)return e.marginHorizontal=n,!0}if(t.startsWith("my-")){let n=p(t.slice(3));if(n!==void 0)return e.marginVertical=n,!0}if(t.startsWith("mt-")){let n=p(t.slice(3));if(n!==void 0)return e.marginTop=n,!0}if(t.startsWith("mr-")){let n=p(t.slice(3));if(n!==void 0)return e.marginRight=n,!0}if(t.startsWith("mb-")){let n=p(t.slice(3));if(n!==void 0)return e.marginBottom=n,!0}if(t.startsWith("ml-")){let n=p(t.slice(3));if(n!==void 0)return e.marginLeft=n,!0}return!1}function le(t,e){if(!t.startsWith("w-"))return!1;let n=t.slice(2);if(n==="full")return e.width="100%",!0;if(n==="screen")return e.width="100%",!0;if(n==="auto")return e.width="auto",!0;if(n.includes("/")){let[i,s]=n.split("/"),o=Number.parseInt(i)/Number.parseInt(s)*100;return e.width=`${o}%`,!0}let r=p(n);if(r!==void 0)return e.width=r,!0;return!1}function ue(t,e){if(!t.startsWith("h-"))return!1;let n=t.slice(2);if(n==="full")return e.height="100%",!0;if(n==="screen")return e.height="100%",!0;if(n==="auto")return e.height="auto",!0;let r=p(n);if(r!==void 0)return e.height=r,!0;return!1}function fe(t,e){if(!t.startsWith("rounded"))return!1;if(t==="rounded")return e.borderRadius=b.DEFAULT,!0;let n=t.slice(8);if(n==="")return!1;let r=/^(?:(t|b|l|r)-)?(\[[^\]]+\])$/.exec(n);if(r){let s=C(r[2]);if(s===void 0)return!1;let o={t:["borderTopLeftRadius","borderTopRightRadius"],b:["borderBottomLeftRadius","borderBottomRightRadius"],l:["borderTopLeftRadius","borderBottomLeftRadius"],r:["borderTopRightRadius","borderBottomRightRadius"]};for(let c of r[1]?o[r[1]]:["borderRadius"])e[c]=s;return!0}if(n.startsWith("t-")){let s=b[n.slice(2)]??b.DEFAULT;return e.borderTopLeftRadius=s,e.borderTopRightRadius=s,!0}if(n.startsWith("b-")){let s=b[n.slice(2)]??b.DEFAULT;return e.borderBottomLeftRadius=s,e.borderBottomRightRadius=s,!0}if(n.startsWith("l-")){let s=b[n.slice(2)]??b.DEFAULT;return e.borderTopLeftRadius=s,e.borderBottomLeftRadius=s,!0}if(n.startsWith("r-")){let s=b[n.slice(2)]??b.DEFAULT;return e.borderTopRightRadius=s,e.borderBottomRightRadius=s,!0}let i=b[n];if(i!==void 0)return e.borderRadius=i,!0;return!1}function de(t,e){if(!t.startsWith("border"))return!1;if(t==="border")return e.borderWidth=1,!0;let n=t.match(/^border-(\d+)$/);if(n)return e.borderWidth=Number.parseInt(n[1]),!0;let r=t.match(/^border-(t|r|b|l)-?(\d*)$/);if(r){let[,i,s]=r,o=s?Number.parseInt(s):1;switch(i){case"t":e.borderTopWidth=o;break;case"r":e.borderRightWidth=o;break;case"b":e.borderBottomWidth=o;break;case"l":e.borderLeftWidth=o;break}return!0}return!1}function pe(t,e){if(!t.startsWith("border-"))return!1;let n=t.slice(7),r=k(n);if(r)return e.borderColor=r,!0;return!1}function he(t,e){if(!t.startsWith("opacity-"))return!1;let n=Number.parseInt(t.slice(8));if(!Number.isNaN(n))return e.opacity=n/100,!0;return!1}function ge(t,e){if(t.startsWith("tracking-[")){let n=C(t.slice(9),typeof e.fontSize==="number"?e.fontSize:16);if(n===void 0)return!1;return e.letterSpacing=n,!0}if(t.startsWith("leading-")){let n=t.slice(8),r=typeof e.fontSize==="number"?e.fontSize:16,i={none:1,tight:1.25,snug:1.375,normal:1.5,relaxed:1.625,loose:2},s=n.startsWith("[")?/^\[[\d.]+\]$/.test(n)?Number.parseFloat(n.slice(1,-1))*r:C(n,r):i[n]!==void 0?i[n]*r:P[n];if(s===void 0||!Number.isFinite(s))return!1;return e.lineHeight=s,!0}return!1}function me(t,e){let n=/^grid-cols-(\d+)$/.exec(t);if(!n)return!1;return e.gridColumns=Number(n[1]),!0}function be(t,e){if(!t.startsWith("size-"))return!1;let n=t.slice(5),r=n==="full"?"100%":p(n);if(r===void 0)return!1;return e.width=r,e.height=r,!0}function xe(t,e){let n=/^(-?)(top|right|bottom|left)-(.+)$/.exec(t);if(!n)return!1;let r=n[3]==="full"?"100%":p(n[3]);if(r===void 0)return!1;return e[n[2]]=typeof r==="number"&&n[1]?-r:r,!0}function we(t,e){let n=/^space-(x|y)-(.+)$/.exec(t);if(!n)return!1;let r=p(n[2]);if(r===void 0)return!1;return e.gap=r,!0}function Se(t,e){if(t.startsWith("gap-")){let n=p(t.slice(4));if(n!==void 0)return e.gap=n,!0}if(t.startsWith("gap-x-")){let n=p(t.slice(6));if(n!==void 0)return e.columnGap=n,!0}if(t.startsWith("gap-y-")){let n=p(t.slice(6));if(n!==void 0)return e.rowGap=n,!0}return!1}function D(t){let e=[],n=[];for(let o of t.split(/\s+/).filter(Boolean))if(o.startsWith("dark:"))n.push(o.slice(5));else if(!o.includes(":")||o.startsWith("["))e.push(o);let r=[],s={style:F(e.join(" "),r),unknown:r};if(n.length)s.dark=F(n.join(" "),r);for(let o of e){if(o==="truncate")s.numberOfLines=1;let c=/^line-clamp-(\d+)$/.exec(o);if(c)s.numberOfLines=Number(c[1]);if(!s.icon&&/^i-[a-z0-9]+-[a-z0-9-]+$/.test(o))s.icon=o}return s.unknown=r.filter((o)=>!/^line-clamp-\d+$/.test(o)),s}function F(t,e){let n={},r=t.split(/\s+/).filter(Boolean);for(let i of r){if(/^i-[a-z0-9]+-/.test(i))continue;let s=ie[i];if(s){s("",n);continue}if(se(i,n))continue;if(oe(i,n))continue;if(ae(i,n))continue;if(ce(i,n))continue;if(le(i,n))continue;if(ue(i,n))continue;if(fe(i,n))continue;if(de(i,n))continue;if(pe(i,n))continue;if(he(i,n))continue;if(Se(i,n))continue;if(ge(i,n))continue;if(be(i,n))continue;if(me(i,n))continue;if(xe(i,n))continue;if(we(i,n))continue;if(e?.push(i),typeof process<"u"&&process.env?.NODE_ENV==="development")console.warn(`[STX Native] Unknown Headwind class: ${i}`)}return n}var Te={activity:"waveform.path.ecg","alarm-clock":"alarm","alert-circle":"exclamationmark.circle","alert-triangle":"exclamationmark.triangle",archive:"archivebox","arrow-down":"arrow.down","arrow-left":"arrow.left","arrow-right":"arrow.right","arrow-up":"arrow.up","arrow-up-right":"arrow.up.right","at-sign":"at","audio-lines":"waveform",award:"rosette","badge-check":"checkmark.seal","bar-chart":"chart.bar","bar-chart-2":"chart.bar","bar-chart-3":"chart.bar",battery:"battery.100",bed:"bed.double",bell:"bell","bell-off":"bell.slash",bike:"figure.outdoor.cycle",bluetooth:"antenna.radiowaves.left.and.right",book:"book","book-open":"book",bookmark:"bookmark",brain:"brain",calendar:"calendar","calendar-check":"calendar.badge.checkmark","calendar-clock":"calendar.badge.clock","calendar-days":"calendar","calendar-plus":"calendar.badge.plus","calendar-range":"calendar","calendar-sync":"arrow.triangle.2.circlepath",camera:"camera","chart-bar":"chart.bar","chart-line":"chart.xyaxis.line",check:"checkmark","check-circle":"checkmark.circle","check-circle-2":"checkmark.circle","chevron-down":"chevron.down","chevron-left":"chevron.left","chevron-right":"chevron.right","chevron-up":"chevron.up",circle:"circle","circle-alert":"exclamationmark.circle","circle-check":"checkmark.circle","circle-check-big":"checkmark.circle","circle-help":"questionmark.circle","circle-play":"play.circle","circle-plus":"plus.circle","circle-user":"person.crop.circle","circle-x":"xmark.circle",clapperboard:"film",clipboard:"clipboard","clipboard-list":"list.clipboard",clock:"clock",cloud:"cloud","cloud-off":"icloud.slash",coffee:"cup.and.saucer",copy:"doc.on.doc","credit-card":"creditcard",download:"arrow.down.circle",droplet:"drop",droplets:"drop",dumbbell:"dumbbell",edit:"pencil","external-link":"arrow.up.right.square",eye:"eye","eye-off":"eye.slash",file:"doc","file-text":"doc.text",filter:"line.3.horizontal.decrease",flag:"flag",flame:"flame",footprints:"figure.run",gauge:"gauge",gift:"gift",globe:"globe","graduation-cap":"graduationcap","grip-vertical":"line.3.horizontal",heart:"heart","heart-pulse":"heart.text.square","help-circle":"questionmark.circle",history:"clock.arrow.circlepath",home:"house",house:"house",image:"photo",inbox:"tray",info:"info.circle",layers:"square.3.layers.3d","layout-grid":"square.grid.2x2",library:"books.vertical",link:"link",list:"list.bullet","list-checks":"checklist",loader:"arrow.triangle.2.circlepath","loader-2":"arrow.triangle.2.circlepath","loader-circle":"arrow.triangle.2.circlepath",lock:"lock","log-in":"arrow.right.to.line","log-out":"rectangle.portrait.and.arrow.right",mail:"envelope",map:"map","map-pin":"mappin.and.ellipse",medal:"medal",menu:"line.3.horizontal","message-circle":"bubble.left","message-square":"text.bubble","message-square-quote":"quote.bubble",mic:"mic",minus:"minus",moon:"moon","more-horizontal":"ellipsis","more-vertical":"ellipsis",mountain:"mountain.2",music:"music.note",package:"shippingbox",pause:"pause","pause-circle":"pause.circle",pencil:"pencil","person-standing":"figure.walk",phone:"phone",play:"play.fill",plug:"powerplug",plus:"plus","plus-circle":"plus.circle","refresh-cw":"arrow.clockwise",repeat:"repeat","rotate-ccw":"arrow.counterclockwise",route:"point.topleft.down.to.point.bottomright.curvepath",ruler:"ruler",sailboat:"sailboat",satellite:"antenna.radiowaves.left.and.right",save:"square.and.arrow.down",scale:"scalemass",search:"magnifyingglass",send:"paperplane",settings:"gearshape","settings-2":"slider.horizontal.3",share:"square.and.arrow.up","share-2":"square.and.arrow.up",shield:"shield","shield-check":"checkmark.shield","shopping-bag":"bag","shopping-cart":"cart","skip-back":"backward.end","skip-forward":"forward.end",sliders:"slider.horizontal.3","sliders-horizontal":"slider.horizontal.3",smartphone:"iphone",snowflake:"snowflake",sparkles:"sparkles",square:"square",star:"star",stopwatch:"stopwatch",store:"storefront",sun:"sun.max",sunrise:"sunrise",sunset:"sunset",tag:"tag",target:"scope",thermometer:"thermometer.medium","thumbs-up":"hand.thumbsup",timer:"timer",trash:"trash","trash-2":"trash","trending-down":"chart.line.downtrend.xyaxis","trending-up":"chart.line.uptrend.xyaxis",trophy:"trophy",unlink:"personalhotspot.slash",upload:"arrow.up.circle",user:"person","user-plus":"person.badge.plus","user-round":"person",users:"person.2",video:"video","volume-2":"speaker.wave.2",watch:"applewatch",waves:"figure.pool.swim",weight:"scalemass",wifi:"wifi","wifi-off":"wifi.slash",wind:"wind",x:"xmark","x-circle":"xmark.circle",zap:"bolt"};function j(t,e=!1){let n=String(t??"").trim();if(!n)return{symbol:"circle",known:!1};if(e)return{symbol:n,known:!0};let r=/^i-([a-z0-9]+)-(.+)$/.exec(n)??/^([a-z0-9]+):(.+)$/.exec(n),i=r?r[1]:"lucide",s=r?r[2]:n;if(i==="lucide"){let o=Te[s];if(o)return{symbol:o,iconify:`i-lucide-${s}`,known:!0};if(!r&&n.includes("."))return{symbol:n,known:!0}}return{symbol:"circle",iconify:r?n:`i-lucide-${s}`,known:!1}}function V(t){return t.split(/\s+/).find((e)=>/^i-[a-z0-9]+-[a-z0-9-]+$/.test(e))}class M{input;pos=0;line=1;column=1;inTag=!1;templates=[];constructor(t){this.input=t}tokenize(){let t=[];while(this.pos<this.input.length){let e=this.nextToken();if(e)t.push(e)}return t.push({type:"EOF",value:"",line:this.line,column:this.column}),t}nextToken(){if(this.inTag)this.skipWhitespace();if(this.pos>=this.input.length)return null;let t=this.line,e=this.column;if(this.match("<!--")){let r=this.input.indexOf("-->",this.pos);if(r===-1)throw Error(`Unclosed comment at line ${t}`);let i=this.input.slice(this.pos,r);return this.advance(r-this.pos+3),{type:"COMMENT",value:i,line:t,column:e}}if(this.match("<script")){let i=this.input.indexOf(">",this.pos)+1,s=this.input.indexOf("</script>",i);if(s===-1)throw Error(`Unclosed <script> block at line ${t}`);let o=this.input.slice(i,s).trim(),c=this.input.slice(this.pos+7,i-1);if(this.advance(s-this.pos+9),/\bserver\b/.test(c))return null;return{type:"SCRIPT_BLOCK",value:o,line:t,column:e}}if(this.match("<style")){let i=this.input.indexOf(">",this.pos)+1,s=this.input.indexOf("</style>",i);if(s===-1)throw Error(`Unclosed <style> block at line ${t}`);let o=this.input.slice(i,s).trim();return this.advance(s-this.pos+8),{type:"STYLE_BLOCK",value:o,line:t,column:e}}if(this.match("<template>"))return this.templates.push(!1),this.advance(10),null;if(this.match("<template"))this.templates.push(!0);if(this.match("</template>")&&this.templates.pop()!==!0)return this.advance(11),null;if(this.match("</")){this.advance(2);let r=this.readTagName();if(this.skipWhitespace(),this.peek()!==">")throw Error(`Expected > at line ${this.line}`);return this.advance(1),this.inTag=!1,{type:"TAG_CLOSE",value:r,line:t,column:e}}if(this.peek()==="<"){this.advance(1);let r=this.readTagName();return this.inTag=!0,{type:"TAG_OPEN",value:r,line:t,column:e}}if(this.match("/>"))return this.advance(2),this.inTag=!1,{type:"TAG_SELF_CLOSE",value:"/>",line:t,column:e};if(this.peek()===">")return this.advance(1),this.inTag=!1,{type:"TAG_END",value:">",line:t,column:e};if(!this.inTag&&this.match("{{")){let r=this.input.indexOf("}}",this.pos+2);if(r!==-1){let i=this.input.slice(this.pos+2,r);return this.advance(r-this.pos+2),{type:"EXPRESSION",value:i.trim(),line:t,column:e}}}if(this.peek()==="{"){this.advance(1);let r=1,i="";while(r>0&&this.pos<this.input.length){let s=this.peek();if(s==="{")r++;else if(s==="}")r--;if(r>0)i+=s;this.advance(1)}return{type:"EXPRESSION",value:i.trim(),line:t,column:e}}if(this.inTag&&(this.isAlpha(this.peek())||this.peek()===":"||this.peek()==="@")){let r=this.readAttributeName();if(this.skipWhitespace(),this.peek()==="="){this.advance(1),this.skipWhitespace();let i,s;if(this.peek()==='"'||this.peek()==="'"){let o=this.peek();this.advance(1),i="";while(this.peek()!==o&&this.pos<this.input.length)i+=this.peek(),this.advance(1);this.advance(1)}else if(this.peek()==="{"){this.advance(1);let o=1;i="";while(o>0&&this.pos<this.input.length){let c=this.peek();if(c==="{")o++;else if(c==="}")o--;if(o>0)i+=c;this.advance(1)}s=`{${i}}`,i=i.trim()}else throw Error(`Expected " or { after = at line ${this.line}`);return{type:"ATTRIBUTE",value:`${r}=${i}`,raw:s,line:t,column:e}}return{type:"ATTRIBUTE",value:`${r}=true`,line:t,column:e}}let n="";while(this.pos<this.input.length&&this.peek()!=="<"&&this.peek()!=="{")n+=this.peek(),this.advance(1);if(n.trim()||n&&!n.includes(`
|
|
13
|
+
`))return{type:"TEXT",value:n,line:t,column:e};return null}match(t){return this.input.slice(this.pos,this.pos+t.length)===t}peek(){return this.input[this.pos]||""}advance(t){for(let e=0;e<t;e++){if(this.input[this.pos]===`
|
|
14
|
+
`)this.line++,this.column=1;else this.column++;this.pos++}}skipWhitespace(){while(this.pos<this.input.length&&/\s/.test(this.peek()))this.advance(1)}readTagName(){let t="";while(this.pos<this.input.length&&/[a-zA-Z0-9_-]/.test(this.peek()))t+=this.peek(),this.advance(1);return t}readAttributeName(){let t="";while(this.pos<this.input.length&&/[a-zA-Z0-9_\-:@]/.test(this.peek()))t+=this.peek(),this.advance(1);return t}isAlpha(t){return/[a-zA-Z_]/.test(t)}}class G{ctx;constructor(t,e){this.ctx={source:e,tokens:t,pos:0,scriptCode:"",exports:{},functions:[],warnings:[]}}parse(){this.extractScriptBlocks(),this.ctx.pos=0;let t=this.parseElement();if(!t)throw Error("No root element found in template");let e=B(t,{exports:this.ctx.exports,functions:this.ctx.functions,code:this.ctx.scriptCode},{source:this.ctx.source,compiledAt:Date.now()});if(this.ctx.warnings.length)e.meta.warnings=[...new Set(this.ctx.warnings)];return e}extractScriptBlocks(){while(this.ctx.pos<this.ctx.tokens.length){let t=this.peek();if(t.type==="SCRIPT_BLOCK")this.ctx.scriptCode+=`${t.value}
|
|
15
|
+
`,this.extractExportsAndFunctions(t.value);this.advance()}}extractExportsAndFunctions(t){let e=/(?:let|const|var)\s+(\w+)\s*=\s*([^;\n]+)/g,n;while((n=e.exec(t))!==null){let[,s,o]=n;try{this.ctx.exports[s]=JSON.parse(o.trim())}catch{this.ctx.exports[s]=o.trim()}}let r=/(?:function\s+(\w+)|const\s+(\w+)\s*=\s*(?:\([^)]*\)|[^=])\s*=>)/g;while((n=r.exec(t))!==null){let s=n[1]||n[2];if(s&&!this.ctx.functions.includes(s))this.ctx.functions.push(s)}let i=/async\s+function\s+(\w+)/g;while((n=i.exec(t))!==null){let s=n[1];if(s&&!this.ctx.functions.includes(s))this.ctx.functions.push(s)}}parseElement(){this.skipNonElements();let t=this.peek();if(t.type==="EOF")return null;if(t.type!=="TAG_OPEN"){if(t.type==="TEXT")return this.advance(),v("Text",{},{},{},[t.value]);if(t.type==="EXPRESSION")return this.advance(),v("Text",{},{},{},[`{${t.value}}`]);return null}let e=t.value,n={file:this.ctx.source,line:t.line,column:t.column};this.advance();let r=this.parseAttributes(e,t.line),{props:i,style:s,events:o}=r,c=this.peek();if(c.type==="TAG_SELF_CLOSE"){this.advance();let a=v(e,i,s,o,[]);return this.finishNode(a,r,n),a}if(c.type!=="TAG_END")throw Error(`Expected > or /> at line ${c.line}, got ${c.type}`);this.advance();let l=[];while(!0){this.skipComments();let a=this.peek();if(a.type==="EOF")throw Error(`Unclosed tag <${e}> at line ${t.line}`);if(a.type==="TAG_CLOSE"){if(a.value!==e)throw Error(`Mismatched closing tag: expected </${e}>, got </${a.value}> at line ${a.line}`);this.advance();break}if(a.type==="TEXT"){l.push(a.value),this.advance();continue}if(a.type==="EXPRESSION"){l.push(`{${a.value}}`),this.advance();continue}if(a.type==="TAG_OPEN"){let d=this.parseElement();if(d)l.push(d);continue}this.advance()}let h=v(e,i,s,o,l);return this.finishNode(h,r,n),h}finishNode(t,e,n){if(typeof t.props.__text==="string")t.children=[`{${t.props.__text}}`],delete t.props.__text;if(ve(t),e.classes)t._classes=e.classes;if(t._source=n,e.darkStyle)t.darkStyle=e.darkStyle;if(Object.keys(e.directives).length)t.directives=e.directives;if(Object.keys(e.bindings).length)t.bindings=e.bindings;if(e.numberOfLines!==void 0&&t.props.numberOfLines===void 0)t.props.numberOfLines=e.numberOfLines;if(t.type==="Icon")this.finishIcon(t,e.icon)}finishIcon(t,e){let n=t.props,r=(o)=>typeof o==="string"&&/\{[^}]*\}/.test(o);if(n.size!==void 0){let o=Number(n.size);if(Number.isFinite(o))t.style.width??=o,t.style.height??=o,delete n.size}if(t.children=[],n.symbol!==void 0){delete n.name;return}let i=n.name??n.icon??e;if(delete n.icon,i===void 0){if(!t.bindings?.class)this.ctx.warnings.push(`<Icon> without symbol, name or an i-* class in ${this.ctx.source}; drawn as circle`);return}if(r(i)){n.name=i;return}delete n.name;let s=j(String(i));if(n.symbol=s.symbol,s.iconify)n.iconify=s.iconify;if(!s.known)this.ctx.warnings.push(`Unknown icon ${i} in ${this.ctx.source}; drawn as ${s.symbol}`)}parseAttributes(t,e){let n={},r={},i={},s={},o="",c={};while(this.peek().type==="ATTRIBUTE"){let a=this.peek();this.advance();let[d,...S]=a.value.split("="),u=S.join("="),f=d.startsWith("x-bind:")?`:${d.slice(7)}`:d.startsWith("x-on:")?`@${d.slice(5)}`:d,g=f.startsWith(":")||f.startsWith("x-")&&f!=="x-cloak",m=g?f.startsWith(":")?f.slice(1):f.slice(2):"",Y=!a.raw&&u==="true"&&!a.value.endsWith('="true"');if(g&&m==="if"){i.if=u;continue}if(g&&(m==="else-if"||m==="elseif")){i.elseIf=u;continue}if(g&&m==="else"){i.else=!0;continue}if(g&&m==="show"){i.show=u;continue}if(g&&m==="for"){let y=U(u);if(!y)throw Error(`Cannot read :for="${u}" at line ${e}: expected "item in items" or "(item, index) in items"`);i.for=y;continue}if(g&&m==="key"){n.key=`{${u}}`;continue}if(g&&m==="text"){n.__text=u;continue}if(f==="x-cloak"||f==="x-data")continue;if(f==="class"||f==="className"||g&&(m==="class"||m==="className")){if(g||a.raw)s.class=u;else o=o?`${o} ${u}`:u;continue}if(f==="style"||g&&m==="style"){if(g){s.style=u;continue}if(a.raw){try{c={...c,...JSON.parse(u)}}catch{s.style=u}continue}try{if(u.startsWith("{")&&u.endsWith("}"))c={...c,...JSON.parse(u)};else c={...c,...JSON.parse(`{${u}}`)}}catch{c={...c,...this.parseCSSInJS(u)}}continue}if(/^on[A-Z]/.test(f)&&!ye.has(f)||f.startsWith("@")){let y=f.startsWith("@")?_e(f.slice(1)):f;if(!Y)r[y]=u;continue}if(f==="key"){n.key=a.raw??u;continue}if(g){n[m]=`{${u}}`;continue}if(a.raw){try{n[f]=JSON.parse(u)}catch{n[f]=a.raw}continue}try{n[f]=JSON.parse(u)}catch{n[f]=u}}let l=o?D(o):null;if(l&&l.unknown.length)this.ctx.warnings.push(`Classes with no native style on <${t}> at line ${e}: ${l.unknown.join(" ")}`);let h={...l?.style??{},...c};return{props:n,style:h,events:r,classes:o,directives:i,bindings:s,darkStyle:l?.dark,numberOfLines:l?.numberOfLines,icon:l?.icon??(o?V(o):void 0)}}parseCSSInJS(t){let e={},n=t.split(",").map((r)=>r.trim());for(let r of n){let i=r.indexOf(":");if(i===-1)continue;let s=r.slice(0,i).trim(),o=r.slice(i+1).trim();if(o.startsWith("'")&&o.endsWith("'")||o.startsWith('"')&&o.endsWith('"'))o=o.slice(1,-1);let c=Number(o);e[s]=Number.isNaN(c)?o:c}return e}skipNonElements(){while(this.peek().type==="SCRIPT_BLOCK"||this.peek().type==="STYLE_BLOCK"||this.peek().type==="COMMENT")this.advance()}skipComments(){while(this.peek().type==="COMMENT")this.advance()}peek(){return this.ctx.tokens[this.ctx.pos]||{type:"EOF",value:"",line:0,column:0}}advance(){this.ctx.pos++}}function ve(t){let e=t.children.some((r)=>typeof r!=="string"),n=t.children.map((r)=>typeof r==="string"&&!/^\{[\s\S]*\}$/.test(r)?r.replace(/\s+/g," "):r).filter((r)=>!(e&&typeof r==="string"&&!r.trim()));if(!e&&n.length){let r=n[0],i=n[n.length-1];if(typeof r==="string")n[0]=r.replace(/^\s+/,"");if(typeof i==="string")n[n.length-1]=n[n.length-1].replace(/\s+$/,"");n=n.filter((s)=>s!=="")}t.children=n}var ye=new Set(["onEndReachedThreshold"]),ke={click:"onPress",press:"onPress",tap:"onPress",longpress:"onLongPress",contextmenu:"onLongPress",input:"onChangeText",change:"onChange",focus:"onFocus",blur:"onBlur",submit:"onSubmitEditing",scroll:"onScroll",refresh:"onRefresh",close:"onRequestClose",layout:"onLayout"};function _e(t){let[e]=t.split(".");return ke[e.toLowerCase()]??`on${e.charAt(0).toUpperCase()}${e.slice(1)}`}function U(t){let e=t.trim(),n=/^\(?\s*([$\w]+)\s*(?:,\s*([$\w]+)\s*)?\)?\s+(?:in|of)\s+([\s\S]+)$/.exec(e);if(n)return{item:n[1],index:n[2],source:n[3].trim()};let r=/^([\s\S]+?)\s+as\s+(?:([$\w]+)\s*=>\s*)?([$\w]+)$/.exec(e);if(r)return{item:r[3],index:r[2],source:r[1].trim()};return null}function $e(t,e){let n=0,r="";for(let i=e;i<t.length;i++){let s=t[i];if(r){if(s==="\\")i++;else if(s===r)r="";continue}if(s==='"'||s==="'"||s==="`")r=s;else if(s==="(")n++;else if(s===")"&&--n===0)return i}return-1}function _(t,e){return e.includes('"')?`${t}={${e}}`:`${t}="${e}"`}function Ee(t){let e=/<script\b[\s\S]*?<\/script>|<style\b[\s\S]*?<\/style>|@(if|elseif|unless|foreach|for)\s*\(|@(else|endif|endunless|endforeach|endfor)\b/g,n="",r=0;for(let i=e.exec(t);i;i=e.exec(t)){if(i[0].startsWith("<"))continue;let s=t[i.index-1];if(s&&/[\w@.]/.test(s))continue;if(n+=t.slice(r,i.index),i[1]){let o=i.index+i[0].length-1,c=$e(t,o);if(c===-1)throw Error(`Unclosed @${i[1]}( in template`);let l=t.slice(o+1,c).trim();if(i[1]==="if")n+=`<Fragment ${_(":if",l)}>`;else if(i[1]==="unless")n+=`<Fragment ${_(":if",`!(${l})`)}>`;else if(i[1]==="elseif")n+=`</Fragment><Fragment ${_(":else-if",l)}>`;else{let h=U(l);if(!h)throw Error(`Cannot read @${i[1]}(${l})`);let a=h.index?`(${h.item}, ${h.index})`:h.item;n+=`<Fragment ${_(":for",`${a} in ${h.source}`)}>`}r=c+1,e.lastIndex=r}else n+=i[2]==="else"?"</Fragment><Fragment :else>":"</Fragment>",r=i.index+i[0].length}return n+t.slice(r)}function E(t,e="unknown.stx"){let r=new M(Ee(t)).tokenize();return new G(r,e).parse()}function Ce(){let t=[w.join(import.meta.dir,"..","runtime","entry.ts"),w.join(import.meta.dir,"..","runtime","entry.js"),w.join(import.meta.dir,"native","runtime","entry.js")];return t.find((e)=>Re(e))??t[0]}async function q(t,e,n){let r=await Bun.build({entrypoints:[t],target:"browser",format:"iife",minify:n,plugins:e,define:{"process.env.NODE_ENV":JSON.stringify(n?"production":"development")}});if(!r.success){let i=r.logs.map((s)=>String(s.message??s)).join(`
|
|
16
|
+
`);throw Error(`Could not bundle ${t}:
|
|
17
|
+
${i}`)}return(await r.outputs[0].text()).trim()}function Xe(t){return{name:"stx-native-screen",setup(e){e.onResolve({filter:/^stx:native-runtime$/},()=>({path:"runtime",namespace:"stx-native-runtime"})),e.onLoad({filter:/.*/,namespace:"stx-native-runtime"},()=>({contents:"export function mount(screen) { return globalThis.__stxNative.mount(screen) }",loader:"js"})),e.onLoad({filter:/\.stx$/},async(n)=>{let r=await Bun.file(n.path).text(),i=z(E(r,n.path));return t.push(...i.warnings),{contents:i.code,loader:"ts"}})}}}async function X(t){let e=Object.keys(t.screens);if(e.length===0)throw Error("screens must name at least one .stx file");let n=t.routed??!0,r=t.initialScreen??e[0];if(!t.screens[r])throw Error(`Initial screen ${r} is not in screens`);let i=t.minify??!1,s=w.resolve(t.root??process.cwd()),o=[],c=n?`(function () {
|
|
18
|
+
var names = ${JSON.stringify(e)};
|
|
19
|
+
var name = globalThis.__stxNativeRoute || ${JSON.stringify(r)};
|
|
20
|
+
if (names.indexOf(name) === -1) throw new Error(['Unknown native screen:', name].join(' '));
|
|
21
|
+
globalThis.__stxNativeRoute = name;
|
|
22
|
+
globalThis.__stxNativeRuntimeOptions = { routeName: name, routeNames: names };
|
|
23
|
+
})();`:"globalThis.__stxNativeRuntimeOptions = { routeName: 'main', routeNames: ['main'] };",l=await q(Ce(),[],i),h=[];for(let u of e){let f=w.resolve(s,t.screens[u]);if(!f.endsWith(".stx"))throw Error(`Screen ${u} must name a .stx file`);let g=await q(f,[Xe(o)],i),m=n?`globalThis.__stxNativeRoute === ${JSON.stringify(u)} && globalThis.__stxNativeBridge`:"globalThis.__stxNativeBridge";h.push(`// Screen ${u}: ${w.basename(f)}
|
|
24
|
+
if (${m}) {
|
|
25
|
+
${g}
|
|
26
|
+
}`)}let a=[`// STX Native bundle (${e.join(", ")})`,c,l,...h,""].join(`
|
|
27
|
+
`),d=[...new Set(o)].map((u)=>({level:"warning",message:u}));if(!t.outFile)return{code:a,diagnostics:d};let S=w.resolve(s,t.outFile);return Ne(w.dirname(S),{recursive:!0}),await Bun.write(S,a),{code:a,outFile:S,diagnostics:d}}function J(t,e={}){return X({...e,screens:{main:t},routed:!1})}var K=["native.config.json","stx-native.config.json"];function Oe(t=process.cwd(),e){let n=e?x.resolve(t,e):K.map((c)=>x.join(t,c)).find((c)=>W(c));if(!n)return null;if(!W(n))throw Error(`Native config not found: ${n}`);let r=JSON.parse(H(n,"utf8")),i=Object.entries(r.screens??{});if(i.length===0)throw Error(`${x.basename(n)} must name at least one screen in "screens"`);let s={};for(let[c,l]of i){if(!/^[A-Z][\w-]*$/i.test(c))throw Error(`Invalid native screen name: ${c}`);if(typeof l!=="string"||!l.endsWith(".stx"))throw Error(`Screen ${c} must name a .stx file`);if(s[c]=x.resolve(x.dirname(n),l),!W(s[c]))throw Error(`Screen ${c} not found: ${s[c]}`)}let o=r.initialScreen||i[0][0];if(!s[o])throw Error(`Initial screen ${o} is not in screens`);return{initialScreen:o,screens:s,file:n}}async function Ze(t,e={}){let n=x.resolve(e.cwd??process.cwd()),r=e.format??"ir";if(r!=="ir"&&r!=="bundle")throw Error(`Unknown compile format: ${r}. Expected ir or bundle.`);let i=t?null:Oe(n,e.config);if(!t&&!i)throw Error(`Please specify an input file: stx native compile <file.stx>, or add ${K[0]}`);let s,o=[];if(r==="bundle"){let l=i?await X({screens:i.screens,initialScreen:i.initialScreen,minify:e.minify,root:n}):await J(x.resolve(n,t),{minify:e.minify});s=l.code,o=l.diagnostics}else{let l=(a)=>E(H(a,"utf8"),a),h=i?{initialScreen:i.initialScreen,screens:Object.fromEntries(Object.entries(i.screens).map(([a,d])=>[a,l(d)]))}:l(x.resolve(n,t));s=JSON.stringify(h,null,2)}if(!e.output)return{output:s,diagnostics:o};let c=x.resolve(n,e.output);return We(x.dirname(c),{recursive:!0}),await Bun.write(c,s),{output:s,written:c,diagnostics:o}}export{Ze as runNativeCompile};
|