@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,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import s from"path";var h=new Set([".jpg",".jpeg",".png",".gif"]),d=[{ext:".avif",mime:"image/avif"},{ext:".webp",mime:"image/webp"}];async function Ta(e,r){let a=r.formats??d;if(!r.publicDir)return e;let i=y(e),o=[],m=/<img\b[^>]*?>/gi,c=[],u;while((u=m.exec(e))!==null){let t=u[0],n=t.match(/\bsrc=["']([^"']+)["']/i);if(!n)continue;if(A(u.index,i))continue;c.push({idx:u.index,length:t.length,src:n[1],raw:t})}if(c.length===0)return e;let f=await Promise.all(c.map(async(t)=>{let n=await S(t.src,r.publicDir,a);return{match:t,sources:n}}));for(let{match:t,sources:n}of f){if(n.length===0)continue;let x=`<picture>${n.map((p)=>`<source type="${p.mime}" srcset="${P(p.url)}">`).join("")}${t.raw}</picture>`;o.push({start:t.idx,end:t.idx+t.length,replacement:x})}if(o.length===0)return e;let l="",g=0;for(let t of o)l+=e.slice(g,t.start),l+=t.replacement,g=t.end;return l+=e.slice(g),l}async function S(e,r,a){if(!w(e))return[];let i=s.extname(e).toLowerCase();if(!h.has(i))return[];if(!e.startsWith("/"))return[];let o=s.join(r,e.slice(1)),m=s.dirname(o),c=s.basename(o,i),u=s.resolve(m),f=s.resolve(r);if(!u.startsWith(f))return[];let l=s.posix.dirname(e),g=a.map(async(n)=>{let b=s.join(m,`${c}${n.ext}`);if(!await Bun.file(b).exists())return null;return{url:s.posix.join(l,`${c}${n.ext}`),mime:n.mime}});return(await Promise.all(g)).filter((n)=>n!==null)}function w(e){if(!e)return!1;if(e.startsWith("http://")||e.startsWith("https://"))return!1;if(e.startsWith("//"))return!1;if(e.startsWith("data:"))return!1;return!0}function y(e){let r=[],a=/<picture\b[^>]*>[\s\S]*?<\/picture>/gi,i;while((i=a.exec(e))!==null)r.push([i.index,i.index+i[0].length]);return r}function A(e,r){for(let[a,i]of r)if(e>=a&&e<i)return!0;return!1}function P(e){return e.replace(/&/g,"&").replace(/"/g,""")}
|
|
3
|
+
export{Ta};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{u}from"./chunk-cg8hg6cs.js";import{mkdir as w,writeFile as m}from"fs/promises";import{join as l}from"path";var f="https://api.iconify.design";async function D(){let e=await fetch(`${f}/collections`);if(!e.ok)throw Error(`Failed to fetch collections: ${e.statusText}`);return await e.json()}async function P(e,t){try{let c=u.resolve("@iconify/json"),r=`${`${c.substring(0,c.lastIndexOf("/node_modules/@iconify/json/"))}/node_modules/@iconify/json`}/json/${e}.json`,s=Bun.file(r);if(await s.exists()){let a=await s.json();if(t&&t.length>0){let d={};for(let y of t)if(a.icons[y])d[y]=a.icons[y];return{...a,icons:d}}return a}}catch{}let n=t&&t.length>0?`${f}/${e}.json?icons=${t.join(",")}`:`${f}/${e}.json`,i=await fetch(n);if(!i.ok)throw Error(`Failed to fetch icons for ${e}: ${i.statusText}`);return await i.json()}function F(e,t=24,n=24){return{body:e.body,width:e.width||t,height:e.height||n,viewBox:`0 0 ${e.width||t} ${e.height||n}`}}function T(e,t){let n=h(e);return`import type { IconData } from '@stacksjs/iconify-core'
|
|
3
3
|
|
|
4
|
-
export const ${
|
|
4
|
+
export const ${n}: IconData = ${JSON.stringify(t,null,2)}
|
|
5
5
|
|
|
6
|
-
export default ${
|
|
7
|
-
`}function
|
|
6
|
+
export default ${n}
|
|
7
|
+
`}function A(e,t){return`<script>
|
|
8
8
|
// Get props with defaults (handle undefined)
|
|
9
|
-
const iconWidth = (typeof width !== 'undefined' ? width : null) || (typeof size !== 'undefined' ? size : null) || ${
|
|
10
|
-
const iconHeight = (typeof height !== 'undefined' ? height : null) || (typeof size !== 'undefined' ? size : null) || ${
|
|
9
|
+
const iconWidth = (typeof width !== 'undefined' ? width : null) || (typeof size !== 'undefined' ? size : null) || ${t.width||24}
|
|
10
|
+
const iconHeight = (typeof height !== 'undefined' ? height : null) || (typeof size !== 'undefined' ? size : null) || ${t.height||24}
|
|
11
11
|
const iconColor = typeof color !== 'undefined' ? color : 'currentColor'
|
|
12
|
-
const viewBox = "${
|
|
12
|
+
const viewBox = "${t.viewBox||`0 0 ${t.width||24} ${t.height||24}`}"
|
|
13
13
|
|
|
14
14
|
// Build transform
|
|
15
15
|
const transforms = []
|
|
@@ -33,7 +33,7 @@ const styleAttr = styles.length > 0 ? \` style="\${styles.join(' ')}"\` : ''
|
|
|
33
33
|
const classAttr = typeof className !== 'undefined' && className ? \` class="\${className}"\` : ''
|
|
34
34
|
|
|
35
35
|
// Icon body
|
|
36
|
-
let body = ${JSON.stringify(
|
|
36
|
+
let body = ${JSON.stringify(t.body)}
|
|
37
37
|
if (iconColor && iconColor !== 'currentColor') {
|
|
38
38
|
body = body.replace(/currentColor/g, iconColor)
|
|
39
39
|
}
|
|
@@ -43,17 +43,17 @@ const svg = \`<svg xmlns="http://www.w3.org/2000/svg" width="\${iconWidth}" heig
|
|
|
43
43
|
</script>
|
|
44
44
|
|
|
45
45
|
{!! svg !!}
|
|
46
|
-
`}function
|
|
47
|
-
${
|
|
46
|
+
`}function _(e){let t=new Set;return`// Icon data exports
|
|
47
|
+
${e.map((i)=>{let o=h(i);if(t.has(o)){let r=i.replace(/[^a-zA-Z0-9]/g,"_");if(/^[0-9]/.test(r))r=`_${r}`;o=r;let s=2;while(t.has(o))o=`${r}_${s}`,s++}return t.add(o),`export { default as ${o} } from './${i}.js'`}).join(`
|
|
48
48
|
`)}
|
|
49
49
|
|
|
50
50
|
export * from './types.js'
|
|
51
|
-
`}function
|
|
51
|
+
`}function E(e){return`import type { IconData, IconProps } from '@stacksjs/iconify-core'
|
|
52
52
|
|
|
53
53
|
export type { IconData, IconProps }
|
|
54
54
|
|
|
55
|
-
export type ${
|
|
56
|
-
`}function N(
|
|
55
|
+
export type ${W(e)}Icon = IconData
|
|
56
|
+
`}function N(e,t,n){let i={name:`@stacksjs/iconify-${e}`,type:"module",version:"0.0.1",description:`${t.name} icons for stx from Iconify`,author:t.author?.name||"Iconify",license:t.license?.spdx||"MIT",repository:{type:"git",url:"https://github.com/stacksjs/stx.git",directory:`packages/iconify-${e}`},keywords:["iconify","icons","svg",e,t.name,"stx"],sideEffects:!1,exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./*":"./dist/*"},main:"./dist/index.js",module:"./dist/index.js",types:"./dist/index.d.ts",files:["dist"],scripts:{build:"bun build.ts",prepublishOnly:"bun build.ts"},dependencies:{"@stacksjs/iconify-core":"workspace:*"}};return JSON.stringify(i,null,2)}function U(e){return`import { existsSync, readdirSync, statSync } from 'node:fs'
|
|
57
57
|
import { dirname, join } from 'node:path'
|
|
58
58
|
import { fileURLToPath } from 'node:url'
|
|
59
59
|
import dts from 'bun-plugin-dtsx'
|
|
@@ -88,7 +88,7 @@ function isDistFresh() {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
if (isDistFresh()) {
|
|
91
|
-
console.log('\u2713 @stacksjs/iconify-${
|
|
91
|
+
console.log('\u2713 @stacksjs/iconify-${e} dist is fresh, skipping rebuild')
|
|
92
92
|
} else {
|
|
93
93
|
await Bun.build({
|
|
94
94
|
entrypoints: [join(srcDir, 'index.ts')],
|
|
@@ -100,16 +100,16 @@ if (isDistFresh()) {
|
|
|
100
100
|
sourcemap: 'external',
|
|
101
101
|
splitting: true,
|
|
102
102
|
})
|
|
103
|
-
console.log('\u2713 Built @stacksjs/iconify-${
|
|
103
|
+
console.log('\u2713 Built @stacksjs/iconify-${e}')
|
|
104
104
|
}
|
|
105
|
-
`}function
|
|
105
|
+
`}function R(e,t,n){return`# @stacksjs/iconify-${e}
|
|
106
106
|
|
|
107
|
-
${
|
|
107
|
+
${t.name} icons for stx from Iconify.
|
|
108
108
|
|
|
109
109
|
## Installation
|
|
110
110
|
|
|
111
111
|
\`\`\`bash
|
|
112
|
-
bun add @stacksjs/iconify-${
|
|
112
|
+
bun add @stacksjs/iconify-${e}
|
|
113
113
|
\`\`\`
|
|
114
114
|
|
|
115
115
|
## Usage
|
|
@@ -118,7 +118,7 @@ bun add @stacksjs/iconify-${G}
|
|
|
118
118
|
|
|
119
119
|
\`\`\`html
|
|
120
120
|
<script>
|
|
121
|
-
import { home } from '@stacksjs/iconify-${
|
|
121
|
+
import { home } from '@stacksjs/iconify-${e}'
|
|
122
122
|
import { renderIcon } from '@stacksjs/iconify-core'
|
|
123
123
|
|
|
124
124
|
export const homeIcon = renderIcon(home, { size: 24, color: 'currentColor' })
|
|
@@ -132,7 +132,7 @@ bun add @stacksjs/iconify-${G}
|
|
|
132
132
|
### In TypeScript/JavaScript
|
|
133
133
|
|
|
134
134
|
\`\`\`typescript
|
|
135
|
-
import { home, account, settings } from '@stacksjs/iconify-${
|
|
135
|
+
import { home, account, settings } from '@stacksjs/iconify-${e}'
|
|
136
136
|
import { renderIcon } from '@stacksjs/iconify-core'
|
|
137
137
|
|
|
138
138
|
const svg = renderIcon(home, {
|
|
@@ -143,38 +143,38 @@ const svg = renderIcon(home, {
|
|
|
143
143
|
|
|
144
144
|
## Available Icons
|
|
145
145
|
|
|
146
|
-
This package contains ${
|
|
146
|
+
This package contains ${n} icons from ${t.name}.
|
|
147
147
|
|
|
148
148
|
## License
|
|
149
149
|
|
|
150
|
-
${
|
|
150
|
+
${t.license?.title||"MIT"}
|
|
151
151
|
|
|
152
|
-
${
|
|
152
|
+
${t.license?.url?`License: ${t.license.url}`:""}
|
|
153
153
|
|
|
154
154
|
## Credits
|
|
155
155
|
|
|
156
|
-
- Icons: ${
|
|
156
|
+
- Icons: ${t.author?.name||"Iconify"}${t.author?.url?` (${t.author.url})`:""}
|
|
157
157
|
- Iconify: https://iconify.design/
|
|
158
|
-
`}function
|
|
159
|
-
`);return`# ${
|
|
158
|
+
`}function M(e,t,n){let i=n.length,c=n.slice(0,5).map(h),o=c.map((s)=>`${s.charAt(0).toUpperCase()}${s.slice(1)}Icon`),r=n.map((s)=>`- \`${h(s)}\``).join(`
|
|
159
|
+
`);return`# ${t.name}
|
|
160
160
|
|
|
161
|
-
> ${
|
|
161
|
+
> ${t.name} icons for stx from Iconify
|
|
162
162
|
|
|
163
163
|
## Overview
|
|
164
164
|
|
|
165
|
-
This package provides access to ${
|
|
165
|
+
This package provides access to ${i} icons from the ${t.name} collection through the stx iconify integration.
|
|
166
166
|
|
|
167
|
-
**Collection ID:** \`${
|
|
168
|
-
**Total Icons:** ${
|
|
169
|
-
${
|
|
170
|
-
${
|
|
171
|
-
${
|
|
172
|
-
${
|
|
167
|
+
**Collection ID:** \`${e}\`
|
|
168
|
+
**Total Icons:** ${i}
|
|
169
|
+
${t.author?.name?`**Author:** ${t.author.name}${t.author.url?` ([Website](${t.author.url}))`:""}`:""}
|
|
170
|
+
${t.license?.title?`**License:** ${t.license.title}${t.license.url?` ([Details](${t.license.url}))`:""}`:""}
|
|
171
|
+
${t.category?`**Category:** ${t.category}`:""}
|
|
172
|
+
${t.palette!==void 0?`**Palette:** ${t.palette?"Yes (color icons)":"No (monotone icons)"}`:""}
|
|
173
173
|
|
|
174
174
|
## Installation
|
|
175
175
|
|
|
176
176
|
\`\`\`bash
|
|
177
|
-
bun add @stacksjs/iconify-${
|
|
177
|
+
bun add @stacksjs/iconify-${e}
|
|
178
178
|
\`\`\`
|
|
179
179
|
|
|
180
180
|
## Quick Start
|
|
@@ -184,30 +184,30 @@ bun add @stacksjs/iconify-${G}
|
|
|
184
184
|
Icons are available as .stx components that can be used directly in templates:
|
|
185
185
|
|
|
186
186
|
\`\`\`html
|
|
187
|
-
<${
|
|
188
|
-
<${
|
|
189
|
-
<${
|
|
187
|
+
<${o[0]||"Icon"} height="1em" />
|
|
188
|
+
<${o[0]||"Icon"} width="1em" height="1em" />
|
|
189
|
+
<${o[0]||"Icon"} height="24" />
|
|
190
190
|
\`\`\`
|
|
191
191
|
|
|
192
192
|
### With Properties
|
|
193
193
|
|
|
194
194
|
\`\`\`html
|
|
195
195
|
<!-- Using size property -->
|
|
196
|
-
<${
|
|
197
|
-
<${
|
|
196
|
+
<${o[0]||"Icon"} size="24" />
|
|
197
|
+
<${o[0]||"Icon"} size="1em" />
|
|
198
198
|
|
|
199
199
|
<!-- Using width and height -->
|
|
200
|
-
<${
|
|
200
|
+
<${o[0]||"Icon"} width="24" height="32" />
|
|
201
201
|
|
|
202
202
|
<!-- With color -->
|
|
203
|
-
<${
|
|
204
|
-
<${
|
|
203
|
+
<${o[0]||"Icon"} size="24" color="red" />
|
|
204
|
+
<${o[0]||"Icon"} size="24" color="#4a90e2" />
|
|
205
205
|
|
|
206
206
|
<!-- With CSS class -->
|
|
207
|
-
<${
|
|
207
|
+
<${o[0]||"Icon"} size="24" class="icon-primary" />
|
|
208
208
|
|
|
209
209
|
<!-- With all properties -->
|
|
210
|
-
<${
|
|
210
|
+
<${o[0]||"Icon"}
|
|
211
211
|
size="32"
|
|
212
212
|
color="#4a90e2"
|
|
213
213
|
class="my-icon"
|
|
@@ -232,9 +232,9 @@ Icons are available as .stx components that can be used directly in templates:
|
|
|
232
232
|
</head>
|
|
233
233
|
<body>
|
|
234
234
|
<div class="icon-grid">
|
|
235
|
-
<${
|
|
236
|
-
<${
|
|
237
|
-
<${
|
|
235
|
+
<${o[0]||"Icon"} size="24" />
|
|
236
|
+
<${o[1]||"Icon"} size="24" color="#4a90e2" />
|
|
237
|
+
<${o[2]||"Icon"} size="32" class="my-icon" />
|
|
238
238
|
</div>
|
|
239
239
|
</body>
|
|
240
240
|
</html>
|
|
@@ -245,10 +245,10 @@ Icons are available as .stx components that can be used directly in templates:
|
|
|
245
245
|
You can also import icon data and use the \`renderIcon\` function directly:
|
|
246
246
|
|
|
247
247
|
\`\`\`typescript
|
|
248
|
-
import { ${
|
|
248
|
+
import { ${c.slice(0,3).join(", ")} } from '@stacksjs/iconify-${e}'
|
|
249
249
|
import { renderIcon } from '@stacksjs/iconify-core'
|
|
250
250
|
|
|
251
|
-
const svg = renderIcon(${
|
|
251
|
+
const svg = renderIcon(${c[0]||"icon"}, { size: 24 })
|
|
252
252
|
\`\`\`
|
|
253
253
|
|
|
254
254
|
## Icon Properties
|
|
@@ -269,23 +269,23 @@ All icon component functions and \`renderIcon\` accept the following properties:
|
|
|
269
269
|
|
|
270
270
|
## Color
|
|
271
271
|
|
|
272
|
-
${
|
|
272
|
+
${t.palette?`### Color Icons
|
|
273
273
|
|
|
274
274
|
This collection contains color icons. While you can still set a color property, it may override the original colors.`:"### Monotone Icons\n\nMonotone icons use `currentColor` by default, allowing you to change icon color via the `color` property or CSS:"}
|
|
275
275
|
|
|
276
276
|
\`\`\`html
|
|
277
277
|
<!-- Via color property -->
|
|
278
|
-
<${
|
|
279
|
-
<${
|
|
278
|
+
<${o[0]||"Icon"} size="24" color="red" />
|
|
279
|
+
<${o[0]||"Icon"} size="24" color="#4a90e2" />
|
|
280
280
|
|
|
281
281
|
<!-- Via inline style -->
|
|
282
|
-
<${
|
|
282
|
+
<${o[0]||"Icon"} size="24" style="color: green;" />
|
|
283
283
|
|
|
284
284
|
<!-- Via CSS class -->
|
|
285
|
-
<${
|
|
285
|
+
<${o[0]||"Icon"} size="24" class="text-primary" />
|
|
286
286
|
\`\`\`
|
|
287
287
|
|
|
288
|
-
${!
|
|
288
|
+
${!t.palette?`\`\`\`css
|
|
289
289
|
/* In your CSS */
|
|
290
290
|
.text-primary {
|
|
291
291
|
color: #4a90e2;
|
|
@@ -321,16 +321,16 @@ You do not need to set both properties. If you set one property, the other prope
|
|
|
321
321
|
**Examples:**
|
|
322
322
|
|
|
323
323
|
\`\`\`html
|
|
324
|
-
<${
|
|
325
|
-
<${
|
|
326
|
-
<${
|
|
324
|
+
<${o[0]||"DraftsIcon"} height="1em" />
|
|
325
|
+
<${o[0]||"DraftsIcon"} width="1em" height="1em" />
|
|
326
|
+
<${o[0]||"DraftsIcon"} height="24" />
|
|
327
327
|
\`\`\`
|
|
328
328
|
|
|
329
329
|
You can also use the \`size\` property as a shorthand for setting both width and height:
|
|
330
330
|
|
|
331
331
|
\`\`\`html
|
|
332
|
-
<${
|
|
333
|
-
<${
|
|
332
|
+
<${o[0]||"DraftsIcon"} size="24" />
|
|
333
|
+
<${o[0]||"DraftsIcon"} size="1em" />
|
|
334
334
|
\`\`\`
|
|
335
335
|
|
|
336
336
|
### CSS Sizing
|
|
@@ -338,21 +338,21 @@ You can also use the \`size\` property as a shorthand for setting both width and
|
|
|
338
338
|
You can also control icon size via CSS:
|
|
339
339
|
|
|
340
340
|
\`\`\`css
|
|
341
|
-
.${
|
|
341
|
+
.${h(e)}-icon {
|
|
342
342
|
width: 1em;
|
|
343
343
|
height: 1em;
|
|
344
344
|
}
|
|
345
345
|
\`\`\`
|
|
346
346
|
|
|
347
347
|
\`\`\`html
|
|
348
|
-
<${
|
|
348
|
+
<${o[0]||"DraftsIcon"} class="${h(e)}-icon" />
|
|
349
349
|
\`\`\`
|
|
350
350
|
|
|
351
351
|
## Available Icons
|
|
352
352
|
|
|
353
|
-
This package contains **${
|
|
353
|
+
This package contains **${i}** icons:
|
|
354
354
|
|
|
355
|
-
${
|
|
355
|
+
${r}
|
|
356
356
|
|
|
357
357
|
## Usage Examples
|
|
358
358
|
|
|
@@ -360,10 +360,10 @@ ${X}
|
|
|
360
360
|
|
|
361
361
|
\`\`\`html
|
|
362
362
|
<nav>
|
|
363
|
-
<a href="/"><${
|
|
364
|
-
<a href="/about"><${
|
|
365
|
-
<a href="/contact"><${
|
|
366
|
-
<a href="/settings"><${
|
|
363
|
+
<a href="/"><${o[0]||"Icon"} size="20" class="nav-icon" /> Home</a>
|
|
364
|
+
<a href="/about"><${o[1]||"Icon"} size="20" class="nav-icon" /> About</a>
|
|
365
|
+
<a href="/contact"><${o[2]||"Icon"} size="20" class="nav-icon" /> Contact</a>
|
|
366
|
+
<a href="/settings"><${o[3]||"Icon"} size="20" class="nav-icon" /> Settings</a>
|
|
367
367
|
</nav>
|
|
368
368
|
|
|
369
369
|
<style>
|
|
@@ -385,7 +385,7 @@ ${X}
|
|
|
385
385
|
### Custom Styling
|
|
386
386
|
|
|
387
387
|
\`\`\`html
|
|
388
|
-
<${
|
|
388
|
+
<${o[0]||"Icon"}
|
|
389
389
|
size="24"
|
|
390
390
|
class="icon icon-primary"
|
|
391
391
|
style="opacity: 0.8; transition: opacity 0.2s;"
|
|
@@ -406,15 +406,15 @@ ${X}
|
|
|
406
406
|
\`\`\`html
|
|
407
407
|
<div class="status-grid">
|
|
408
408
|
<div class="status-item">
|
|
409
|
-
<${
|
|
409
|
+
<${o[0]||"Icon"} size="16" color="#22c55e" />
|
|
410
410
|
<span>Success</span>
|
|
411
411
|
</div>
|
|
412
412
|
<div class="status-item">
|
|
413
|
-
<${
|
|
413
|
+
<${o[1]||"Icon"} size="16" color="#f59e0b" />
|
|
414
414
|
<span>Warning</span>
|
|
415
415
|
</div>
|
|
416
416
|
<div class="status-item">
|
|
417
|
-
<${
|
|
417
|
+
<${o[2]||"Icon"} size="16" color="#ef4444" />
|
|
418
418
|
<span>Error</span>
|
|
419
419
|
</div>
|
|
420
420
|
</div>
|
|
@@ -425,8 +425,8 @@ ${X}
|
|
|
425
425
|
1. **Use Components Directly**: Import and use icon components in your templates
|
|
426
426
|
\`\`\`html
|
|
427
427
|
<!-- Recommended -->
|
|
428
|
-
<${
|
|
429
|
-
<${
|
|
428
|
+
<${o[0]||"Icon"} size="24" />
|
|
429
|
+
<${o[1]||"Icon"} size="24" color="#4a90e2" />
|
|
430
430
|
\`\`\`
|
|
431
431
|
|
|
432
432
|
2. **Use CSS for Theming**: Apply consistent styling through CSS classes
|
|
@@ -443,24 +443,24 @@ ${X}
|
|
|
443
443
|
\`\`\`
|
|
444
444
|
|
|
445
445
|
\`\`\`html
|
|
446
|
-
<${
|
|
446
|
+
<${o[0]||"Icon"} size="24" class="icon" />
|
|
447
447
|
\`\`\`
|
|
448
448
|
|
|
449
449
|
3. **Set Appropriate Sizes**: Use \`1em\` for inline icons, fixed pixel sizes for standalone icons
|
|
450
450
|
\`\`\`html
|
|
451
451
|
<!-- Inline with text -->
|
|
452
|
-
<p>Click the <${
|
|
452
|
+
<p>Click the <${o[0]||"Icon"} height="1em" /> icon to continue</p>
|
|
453
453
|
|
|
454
454
|
<!-- Standalone -->
|
|
455
|
-
<${
|
|
455
|
+
<${o[0]||"Icon"} size="24" />
|
|
456
456
|
\`\`\`
|
|
457
457
|
|
|
458
458
|
4. **Use Data Import for Advanced Use Cases**: When you need more control
|
|
459
459
|
\`\`\`html
|
|
460
460
|
@js
|
|
461
|
-
import { ${
|
|
461
|
+
import { ${c[0]||"icon"} } from '@stacksjs/iconify-${e}'
|
|
462
462
|
import { renderIcon } from '@stacksjs/iconify-core'
|
|
463
|
-
global.customIcon = renderIcon(${
|
|
463
|
+
global.customIcon = renderIcon(${c[0]||"icon"}, { size: 24 })
|
|
464
464
|
@endjs
|
|
465
465
|
|
|
466
466
|
{!! customIcon !!}
|
|
@@ -472,10 +472,10 @@ This package includes full TypeScript support with type definitions for all icon
|
|
|
472
472
|
|
|
473
473
|
\`\`\`typescript
|
|
474
474
|
import type { IconData } from '@stacksjs/iconify-core'
|
|
475
|
-
import { ${
|
|
475
|
+
import { ${c[0]||"icon"} } from '@stacksjs/iconify-${e}'
|
|
476
476
|
|
|
477
477
|
// Icons are typed as IconData
|
|
478
|
-
const myIcon: IconData = ${
|
|
478
|
+
const myIcon: IconData = ${c[0]||"icon"}
|
|
479
479
|
\`\`\`
|
|
480
480
|
|
|
481
481
|
## Related Packages
|
|
@@ -486,20 +486,20 @@ const myIcon: IconData = ${Z[0]||"icon"}
|
|
|
486
486
|
|
|
487
487
|
## License
|
|
488
488
|
|
|
489
|
-
${
|
|
489
|
+
${t.license?.title||"MIT"}
|
|
490
490
|
|
|
491
|
-
${
|
|
491
|
+
${t.license?.url?`See [license details](${t.license.url}) for more information.`:""}
|
|
492
492
|
|
|
493
493
|
## Credits
|
|
494
494
|
|
|
495
|
-
- **Icons**: ${
|
|
495
|
+
- **Icons**: ${t.author?.name||"Iconify"}${t.author?.url?` ([Website](${t.author.url}))`:""}
|
|
496
496
|
- **Iconify**: [https://iconify.design/](https://iconify.design/)
|
|
497
|
-
- **Icon Set**: [View on Iconify](https://icon-sets.iconify.design/${
|
|
497
|
+
- **Icon Set**: [View on Iconify](https://icon-sets.iconify.design/${e}/)
|
|
498
498
|
|
|
499
499
|
## Resources
|
|
500
500
|
|
|
501
|
-
- [Browse all icons in this collection](https://icon-sets.iconify.design/${
|
|
501
|
+
- [Browse all icons in this collection](https://icon-sets.iconify.design/${e}/)
|
|
502
502
|
- [Iconify documentation](https://iconify.design/docs/)
|
|
503
503
|
- [stx iconify integration guide](../../docs/iconify.md)
|
|
504
|
-
`}async function
|
|
505
|
-
\uD83D\uDCE6 Generating package for ${
|
|
504
|
+
`}async function G(e,t,n,i){console.log(`
|
|
505
|
+
\uD83D\uDCE6 Generating package for ${e}...`);let o=(await D())[e];if(!o)throw Error(`Collection ${e} not found`);console.log(` Collection: ${o.name}`),console.log(` Total icons: ${o.total}`);let r=await P(e,n),s=Object.keys(r.icons);console.log(` Generating ${s.length} icons...`);let a=l(t,`iconify-${e}`),d=l(a,"src");await w(d,{recursive:!0});let y=r.width||24,b=r.height||24;for(let p of s){let g=r.icons[p],I=F(g,y,b),z=T(p,I);await m(l(d,`${p}.ts`),z);let k=A(p,I);await m(l(d,`${p}-icon.stx`),k)}let v=_(s);await m(l(d,"index.ts"),v);let C=E(e);await m(l(d,"types.ts"),C);let S=N(e,o,s.length);await m(l(a,"package.json"),S);let x=U(e);await m(l(a,"build.ts"),x);let j=R(e,o,s.length);if(await m(l(a,"README.md"),j),i){let p=l(i,`iconify-${e}.md`),g=M(e,o,s);await w(i,{recursive:!0}),await m(p,g),console.log(` \u2713 Generated documentation in ${p}`)}console.log(` \u2713 Generated ${s.length} icons in ${a}`)}var B=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","let","static","yield","implements","interface","package","private","protected","public","await","eval","arguments"]);function h(e){let t=e.replace(/-([a-z0-9])/g,(n)=>n[1].toUpperCase());if(t=t.replace(/[^a-zA-Z0-9_$]/g,"_"),/^[0-9]/.test(t))t=`_${t}`;if(B.has(t))t=`${t}_`;return t}function W(e){let t=h(e);return t.charAt(0).toUpperCase()+t.slice(1)}export{D as fetchCollections,G as generatePackage};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var l=new Map,u=new Map;function m(t){if(l.set(t.name,t),t.client)u.set(t.name,t.client)}function qe(t){return m(t),{name:t.name,hasEndTag:t.hasEndTag??!0,description:t.description,handler:async(r,o,a,s)=>{let n=f(o,t.defaults);if(t.validate){let e=t.validate(n);if(e!==!0){let d=typeof e==="string"?e:`Invalid parameters for @${t.name}`;throw Error(d)}}let i=r;if(t.transform)i=await t.transform(r,n,a,s);if(t.clientScript){let e=t.clientScript(n);i+=`<script>${e}</script>`}if(t.css){let e=t.css(n);i+=`<style>${e}</style>`}return i}}}function f(t,c){let r={...c};for(let o of t){let a=o.indexOf(":"),s=o.indexOf("="),n=a>=0&&(s<0||a<s)?a:s;if(n>=0){let i=o.slice(0,n).trim(),e=o.slice(n+1).trim();if(e==="true")e=!0;else if(e==="false")e=!1;else if(e==="null")e=null;else if(!Number.isNaN(Number(e)))e=Number(e);else if(typeof e==="string"&&e.startsWith("{"))try{e=JSON.parse(e)}catch{}r[i]=e}else{let i=Object.keys(r).filter((e)=>!c||!(e in c)).length;r[i===0?"value":`arg${i}`]=o}}return r}
|
|
3
|
+
export{qe};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import o from"fs";import u from"path";var h={".html":"includeHtml",".htm":"includeHtml",".js":"includeJs",".mjs":"includeJs",".css":"includeCss",".png":"includeImages",".jpg":"includeImages",".jpeg":"includeImages",".gif":"includeImages",".webp":"includeImages",".svg":"includeImages",".ico":"includeImages",".woff":"includeFonts",".woff2":"includeFonts",".ttf":"includeFonts",".eot":"includeFonts",".otf":"includeFonts"};function p(e){let r=0;for(let t=0;t<e.length;t++){let n=e[t];r=(r<<5)-r+n,r=r&r}return Math.abs(r).toString(16).padStart(8,"0")}function x(e,r){let t=u.basename(e);for(let n of r)if(n.startsWith("*.")){let i=n.slice(1);if(t.endsWith(i))return!0}else if(n.includes("*")){let i=new RegExp(`^${n.replace(/\*/g,".*")}$`);if(i.test(t)||i.test(e))return!0}else if(t===n||e.includes(n))return!0;return!1}function S(e,r,t){let n=u.extname(e).toLowerCase(),i=h[n],c=(t.maxFileSizeKB||500)*1024;if(r>c)return!1;if(t.exclude&&x(e,t.exclude))return!1;if(t.include&&t.include.length>0){for(let s of t.include)if(s.startsWith("*.")){if(e.endsWith(s.slice(1)))return!0}else if(e.includes(s))return!0}if(i&&t[i]===!0)return!0;if(!i)return!1;return!1}function f(e,r,t,n){let i=o.readdirSync(e,{withFileTypes:!0});for(let c of i){let s=u.join(e,c.name);if(c.isDirectory()){if(["node_modules",".git",".stx"].includes(c.name))continue;f(s,r,t,n)}else if(c.isFile()){let a=o.statSync(s),l=u.relative(r,s);if(S(l,a.size,t)){let d=o.readFileSync(s),g=p(d),m=`/${l.replace(/\\/g,"/")}`;n.push({url:m,revision:g,size:a.size})}}}}function ae(e,r){let t=r.pwa?.precache,n=[];if(!t?.enabled)return{entries:[],totalSize:0,fileCount:0};if(!o.existsSync(e))return{entries:[],totalSize:0,fileCount:0};f(e,e,t,n),n.sort((c,s)=>c.url.localeCompare(s.url));let i=n.reduce((c,s)=>c+s.size,0);return{entries:n,totalSize:i,fileCount:n.length}}function pt(e){if(e.entries.length===0)return"[]";return`[
|
|
3
|
+
${e.entries.map((t)=>` { url: '${t.url}', revision: '${t.revision}' }`).join(`,
|
|
4
|
+
`)}
|
|
5
|
+
]`}function Hr(e){if(e<1024)return`${e} B`;if(e<1048576)return`${(e/1024).toFixed(1)} KB`;return`${(e/1048576).toFixed(2)} MB`}
|
|
6
|
+
export{ae,pt,Hr};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import"./chunk-ce1sejr3.js";import"./chunk-8nhshfz6.js";import{y,N}from"./chunk-69mc2np8.js";import"./chunk-z0g9jvv0.js";import{P,D}from"./chunk-h0atqq82.js";import"./chunk-shr559s7.js";import"./chunk-czxt605c.js";import"./chunk-m4sk62wb.js";import"./chunk-xfp7k0v8.js";import"./chunk-ak1cgcah.js";import"./chunk-ngc2wke4.js";import"./chunk-2gr351s0.js";import"./chunk-7gkv67ky.js";import"./chunk-752hw7cd.js";import f from"path";var b=["applyOfflineUpdate","broadcast","cacheMedia","calculateDistance","canNotify","clearCookies","clearFetchCache","clearOfflineData","clearStorage","copyToClipboard","createShareableFile","defineForm","getBatteryLevel","getCookie","getCurrentPosition","getStorageKeys","getStorageSize","getVoices","hasBattery","hasCameraPermission","hasGeolocationPermission","hasMicrophonePermission","hasNotificationPermission","hasResizeObserver","hexToHsl","hexToRgb","isBroadcastChannelSupported","isCharging","isDeviceMotionSupported","isDeviceOrientationSupported","isEventSourceSupported","isEyeDropperSupported","isInFullscreen","isMutationObserverSupported","isPermissionGranted","isSpeechRecognitionSupported","isSpeechSynthesisSupported","isWakeLockSupported","isWebSocketSupported","notify","onOfflineUpdateReady","parseCookies","pickColor","prefetch","removeCookie","requestMediaPermissions","requestMotionPermission","requestNotificationPermission","requestOrientationPermission","setCookie","share","shareCurrentPage","shareFiles","shareText","shareURL","shareWithFallback","speak","stopSpeaking","toggleFullscreen","useAsyncData","useAttributeObserver","useAutoLogout","useAutoWakeLock","useBattery","useBreakpoint","useBroadcastChannel","useChannel","useChildListObserver","useClipboard","useColorHistory","useConditionalWakeLock","useCookies","useCopySelection","useDeviceMotion","useDeviceOrientation","useElementSize","useElementTextSelection","useElementVisibility","useEventSource","useEyeDropper","useFavicon","useForm","useFullscreen","useGeolocation","useGeolocationWatch","useHotkey","useIdle","useIdleState","useInfiniteScroll","useIntersectionObserver","useIntersectionObserverMultiple","useIsDesktop","useIsMobile","useIsTablet","useKeyPressed","useKeySequence","useKeyboard","useLastActive","useLazyLoad","useMeta","useMouse","useMouseInElement","useMutationObserver","useNetwork","useNotification","useOnline","useOutbox","useParallax","usePermission","usePermissions","usePointer","usePost","useResizeObserver","useResizeObserverMultiple","useSSE","useScroll","useSelectionPopup","useShare","useSpeechRecognition","useSpeechSynthesis","useStorage","useTextObserver","useTextSelection","useTitle","useVisibility","useWakeLock","useWindowSize"],M=new Set(b);var l=new Map,h=P(64),S=new Set,v=0,C=new Set(b);function W(){l.clear(),h.clear()}function E(o){let n=new Map;for(let r of o){let a=f.basename(r);if(a.endsWith(".d.ts"))continue;let t=a.replace(/\.[jt]s$/,"");if(t==="index")continue;if(t===a)continue;let i=n.get(t);if(i&&!i.endsWith(".js"))continue;n.set(t,r)}return[...n.values()].sort()}function R(o,n){let r=n.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(?:^|[^\\w$.])(?:const|let|var|function|class)\\s+${r}\\b`).test(o)}function I(o){if(!o)return[];let n=D(o,v),r=h.get(n);if(r)return r.slice();let a=o.replace(/<script\b[^>]*\bdata-stx-runtime\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-framework-composables\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-stores\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-composables\b[^>]*>[\s\S]*?<\/script>/gi,""),t=[];for(let i of C){if(S.has(i))continue;let u=i.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");if(new RegExp(`(^|[^\\w$.])${u}\\s*\\(`).test(a))t.push(i)}return t.sort(),h.set(n,t),t.slice()}async function U(o,n){let r=I(o);if(r.length===0)return null;let a=n??f.join(import.meta.dir,"composables"),t=`${a}\x00${r.join(",")}`,i=l.get(t);if(i!==void 0)return i||null;let u=N({loader:"ts",target:"browser",define:y()}),k=new Set(r),m=[],d=new Set,p=[];try{let s=new Bun.Glob("*.{ts,js}");for await(let e of s.scan({cwd:a,absolute:!0}))p.push(e)}catch{return l.set(t,""),null}p=E(p);for(let s of p){let e;try{e=await Bun.file(s).text()}catch{continue}let g=[];try{g=u.scan(e).exports.filter((c)=>c!=="default")}catch{continue}if(!g.some((c)=>k.has(c)))continue;try{e=e.replace(/^import\s+.*from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^import\s+type\s+.*$/gm,""),e=e.replace(/^export\s+\*\s+(?:as\s+\w+\s+)?from\s*['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^export\s+(?:type\s+)?\{[\s\S]*?\}\s*(?:from\s*['"][^'"]+['"]\s*)?;?\s*$/gm,""),e=e.replace(/^export\s+default\s+/gm,""),e=e.replace(/^export\s+(?=(?:declare\s+)?(?:abstract\s+)?(?:async\s+)?(?:function|class|const|let|var|type|interface|enum)\b)/gm,""),m.push(`// ${f.basename(s).replace(/\.[jt]s$/,"")}
|
|
3
|
+
${u.transformSync(e).trim()}`);for(let c of g)d.add(c)}catch(c){console.warn(`[stx] framework composable ${f.basename(s)} could not be bundled:`,c)}}let w=r.filter((s)=>!d.has(s)&&!R(o,s));if(w.length>0)console.warn(`[stx] could not bundle ${w.join(", ")} from @stacksjs/stx/composables \u2014 `+"calls to them will throw ReferenceError in the browser. Import them explicitly so the bundler inlines them, or use a runtime equivalent from window.stx.");if(m.length===0)return l.set(t,""),null;let O=[...d].map((s)=>` try { if (!(${JSON.stringify(s)} in __s)) { __s[${JSON.stringify(s)}] = ${s}; if (!(${JSON.stringify(s)} in window)) window[${JSON.stringify(s)}] = ${s}; } } catch (e) {}`).join(`
|
|
4
|
+
`),x=`<script data-stx-framework-composables>
|
|
5
|
+
;(function(){
|
|
6
|
+
var __s = window.stx = window.stx || {};
|
|
7
|
+
${m.join(`
|
|
8
|
+
|
|
9
|
+
`)}
|
|
10
|
+
${O}
|
|
11
|
+
})();
|
|
12
|
+
</script>`;return l.set(t,x),x}function A(o){S.clear();for(let n of o)S.add(n);v++}export{A as __setRuntimeOwnedForTest,W as clearFrameworkComposableCache,U as getFrameworkComposableScript,I as referencedFrameworkComposables,E as selectComposableFiles};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{m}from"./chunk-ce1sejr3.js";import{R,Pt}from"./chunk-8nhshfz6.js";import{y,ze,N,i}from"./chunk-69mc2np8.js";import{ce,mt,ht}from"./chunk-mepdnezf.js";import{De,Xt,Q}from"./chunk-f46qsp4m.js";import _ from"path";var g=new Map,v=new Map,P=["composables","functions"];function E(n){let t=_.basename(n,".ts");return t==="index"||t==="types"||n.endsWith(".d.ts")}async function G(n){if(n)return _.resolve(n);let t=`<default>:${process.cwd()}`,l=v.get(t);if(l!==void 0)return l;let s=await J();if(s!==null)v.set(t,s);return s}async function J(){let n=await i(),t=n.root||process.cwd(),l=n.composablesDir;if(l)return _.resolve(t,l);for(let s of P){let r=_.resolve(t,s);try{let c=new Bun.Glob("**/*.ts");for await(let a of c.scan({cwd:r,absolute:!0}))if(!E(a))return r}catch{}}return null}async function j(n){let t=Array.isArray(n)?n:n?[_.resolve(n)]:(await i())._layerComposableDirs??[await G()].filter((s)=>!!s),l=new Map;for(let s of t){let r=new Bun.Glob("**/*.ts");try{for await(let c of r.scan({cwd:s,absolute:!0})){let a=_.relative(s,c);if(!E(c)&&!l.has(a))l.set(a,c)}}catch{}}return{key:t.join("\x00"),files:[...l.values()].sort()}}async function Mr(n){let{files:t}=await j(n),l=N({loader:"ts",target:"browser",define:y()}),s=[];for(let r of t)try{let c=await Bun.file(r).text(),a=l.scan(c).exports.filter((d)=>d!=="default");if(a.length>0)s.push({file:r,names:a})}catch{}return s}function T(n,t){return new RegExp(`\\b${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(n)}function z(n,t,l){let s=new Map;for(let{file:d,names:f}of n)for(let u of f)if(!s.has(u))s.set(u,d);let r=(d)=>{let f=[];for(let[u,w]of s)if(T(d,u))f.push(w);return f},c=new Set,a=l.flatMap(r);while(a.length>0){let d=[];for(let f of a){if(c.has(f))continue;c.add(f);for(let u of r(t.get(f)??""))if(!c.has(u))d.push(u)}a=d}return c}async function bl(n,t,l){let{key:s,files:r}=await j(n);if(!s)return null;let c=()=>[...new Set([...r,...r.flatMap((e)=>ce(e))])],a=De(c());if(r.length===0)return Q(g,s,a,""),null;r.sort();let d=N({loader:"ts",target:"browser",define:y()}),f=new Map,u=[];for(let e of r)try{let o=await Bun.file(e).text();f.set(e,o);let h=d.scan(o).exports.filter((p)=>p!=="default");if(h.length>0)u.push({file:e,names:h})}catch{f.set(e,"")}let w=t===void 0?new Set(r):z(u,f,l?[t,...l]:[t]);if(w.size===0)return null;let B=r.filter((e)=>w.has(e)),x=`${s}\x00${B.join("\x00")}`,M=Xt(g,x,a);if(M!==void 0)return M||null;let S=[],b=new Set,D=new Set;for(let e of B)try{let o=f.get(e)??await Bun.file(e).text(),h=_.basename(e,".ts");for(let p of o.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(p[1])D.add(p[1]);try{for(let p of d.scan(o).exports)if(p!=="default")b.add(p)}catch{}if(o=R(o),mt(o))o=await ht(o,e,{projectRoot:process.cwd(),externalizeUserModules:!1}),o=ze(o);o=Pt(o),o=o.replace(/^export\s+(default\s+)?/gm,""),o=d.transformSync(o),S.push(`// Composable: ${h}
|
|
3
|
+
${o.trim()}`)}catch(o){console.warn(`[stx] Failed to load composable ${e}:`,o)}if(S.length===0||b.size===0)return Q(g,x,a,""),null;let F=[...b].map((e)=>` try { if (!(${JSON.stringify(e)} in __c)) __c[${JSON.stringify(e)}] = ${e}; } catch (e) {}`).join(`
|
|
4
|
+
`),k=JSON.stringify([...b]),C=S.join(`
|
|
5
|
+
|
|
6
|
+
`),O=m.filter((e)=>!D.has(e)&&new RegExp(`\\b${e}\\b`).test(C)).map((e)=>`var ${e} = __stx[${JSON.stringify(e)}];`).join(`
|
|
7
|
+
`),I=JSON.stringify(new Bun.CryptoHasher("md5").update(`${k}\x00${C}`).digest("hex").slice(0,12)),A=`;(function(){
|
|
8
|
+
var __bundles = window.__stxComposableBundles || (window.__stxComposableBundles = {});
|
|
9
|
+
if (__bundles[${I}]) return;
|
|
10
|
+
__bundles[${I}] = true;
|
|
11
|
+
var __published = window.__stxComposableGlobals || (window.__stxComposableGlobals = {});
|
|
12
|
+
window.__composables = window.__composables || {};
|
|
13
|
+
var __c = window.__composables;
|
|
14
|
+
var __stx = window.stx || {};
|
|
15
|
+
${O}
|
|
16
|
+
${C}
|
|
17
|
+
${F}
|
|
18
|
+
var __names = ${k};
|
|
19
|
+
for (var __i = 0; __i < __names.length; __i++) {
|
|
20
|
+
var __n = __names[__i];
|
|
21
|
+
if (!(__n in __c) || __published[__n]) continue;
|
|
22
|
+
var __takenByBuiltin = !!(window.stx && __n in window.stx);
|
|
23
|
+
if (__takenByBuiltin || __n in window) {
|
|
24
|
+
console.warn('[stx] composable "' + __n + '" is not available as a bare identifier: '
|
|
25
|
+
+ (__takenByBuiltin ? 'a built-in of that name already exists' : 'window already defines that property')
|
|
26
|
+
+ '. Rename it, or use: import { ' + __n + ' } from "@composables"');
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
window[__n] = __c[__n];
|
|
30
|
+
__published[__n] = true;
|
|
31
|
+
}
|
|
32
|
+
})();`;return a=De(c()),Q(g,x,a,A),A}function vl(){g.clear(),v.clear()}
|
|
33
|
+
export{Mr,bl,vl};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{U}from"./chunk-6hc5vz20.js";function g(e,t){let r={};for(let n of e)r[n]=U(t(n));return new Proxy({},{get:(n,a)=>r[a]?.(),set:(n,a,o)=>{if(r[a])r[a].set(o);else r[a]=U(o);return!0},has:(n,a)=>(a in r),deleteProperty:(n,a)=>(delete r[a],!0),ownKeys:()=>Reflect.ownKeys(r),getOwnPropertyDescriptor:(n,a)=>(a in r)?{enumerable:!0,configurable:!0,writable:!0,value:r[a]()}:void 0})}function v(e,t){let r={};for(let n of t)r[n]=e[n];return r}function gi(e,t){let r=Object.keys(e),n=g(r,(i)=>t?.[i]??e[i].getDefaultValue()),a=g(r,()=>[]),o=g(r,()=>!1),c=g(r,()=>!1),f=g(r,()=>!1),s=U(!1);async function u(i){f[i]=!0;let d=await e[i].validate(n[i],n);return a[i]=d,f[i]=!1,d.length===0}async function l(){s.set(!0);let i=await Promise.all(r.map(u));return s.set(!1),i.every(Boolean)}function m(){for(let i of r)n[i]=t?.[i]??e[i].getDefaultValue(),a[i]=[],o[i]=!1,c[i]=!1}function h(i){for(let d of r)if(d in i)n[d]=i[d],c[d]=!0}function b(i,d){n[i]=d,c[i]=!0}function y(i,d=!0){if(o[i]=d,d)u(i)}function p(i){return{value:n[i],errors:a[i],touched:o[i],dirty:c[i],valid:a[i].length===0,validating:f[i]}}function V(i){return async(d)=>{d?.preventDefault?.();for(let w of r)o[w]=!0;if(await l())await i(v(n,r))}}return{values:n,errors:a,touched:o,dirty:c,get isValid(){return r.every((i)=>a[i].length===0)},get isValidating(){return s()||r.some((i)=>f[i])},get isDirty(){return r.some((i)=>c[i])},validate:l,validateField:u,reset:m,setValues:h,setFieldValue:b,setFieldTouched:y,getFieldState:p,handleSubmit:V}}var ka=gi;class qt{rules=[];defaultValue="";addRule(e){let t=new qt;return t.rules=[...this.rules,e],t.defaultValue=this.defaultValue,t}required(e="This field is required"){return this.addRule({name:"required",message:e,validate:(t)=>{if(t===null||t===void 0)return e;if(typeof t==="string"&&t.trim()==="")return e;if(Array.isArray(t)&&t.length===0)return e;return!0}})}email(e="Please enter a valid email"){return this.addRule({name:"email",message:e,validate:(t)=>{if(!t)return!0;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(t))||e}})}url(e="Please enter a valid URL"){return this.addRule({name:"url",message:e,validate:(t)=>{if(!t)return!0;try{return new URL(String(t)),!0}catch{return e}}})}min(e,t){let r=t||`Must be at least ${e} characters`;return this.addRule({name:"min",message:r,validate:(n)=>{if(!n)return!0;return String(n).length>=e||r}})}max(e,t){let r=t||`Must be no more than ${e} characters`;return this.addRule({name:"max",message:r,validate:(n)=>{if(!n)return!0;return String(n).length<=e||r}})}length(e,t,r){let n=r||`Must be between ${e} and ${t} characters`;return this.addRule({name:"length",message:n,validate:(a)=>{if(!a)return!0;let o=String(a).length;return o>=e&&o<=t||n}})}pattern(e,t="Invalid format"){return this.addRule({name:"pattern",message:t,validate:(r)=>{if(!r)return!0;return e.test(String(r))||t}})}hasUppercase(e="Must contain an uppercase letter"){return this.pattern(/[A-Z]/,e)}hasLowercase(e="Must contain a lowercase letter"){return this.pattern(/[a-z]/,e)}hasNumber(e="Must contain a number"){return this.pattern(/\d/,e)}hasSpecial(e="Must contain a special character"){return this.pattern(/[!@#$%^&*(),.?":{}|<>]/,e)}alphanumeric(e="Only letters and numbers allowed"){return this.pattern(/^[a-zA-Z0-9]+$/,e)}startsWithLetter(e="Must start with a letter"){return this.pattern(/^[a-zA-Z]/,e)}noSpaces(e="Spaces are not allowed"){return this.addRule({name:"noSpaces",message:e,validate:(t)=>{if(!t)return!0;return!String(t).includes(" ")||e}})}number(e="Must be a number"){let t=this.addRule({name:"number",message:e,validate:(r)=>{if(!r&&r!==0)return!0;return!Number.isNaN(Number(r))||e}});return t.defaultValue=0,t}integer(e="Must be a whole number"){return this.addRule({name:"integer",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number.isInteger(Number(t))||e}})}positive(e="Must be a positive number"){return this.addRule({name:"positive",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number(t)>0||e}})}negative(e="Must be a negative number"){return this.addRule({name:"negative",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number(t)<0||e}})}minValue(e,t){let r=t||`Must be at least ${e}`;return this.addRule({name:"minValue",message:r,validate:(n)=>{if(!n&&n!==0)return!0;return Number(n)>=e||r}})}maxValue(e,t){let r=t||`Must be no more than ${e}`;return this.addRule({name:"maxValue",message:r,validate:(n)=>{if(!n&&n!==0)return!0;return Number(n)<=e||r}})}between(e,t,r){let n=r||`Must be between ${e} and ${t}`;return this.addRule({name:"between",message:n,validate:(a)=>{if(!a&&a!==0)return!0;let o=Number(a);return o>=e&&o<=t||n}})}matches(e,t){let r=t||`Must match ${e}`;return this.addRule({name:"matches",message:r,validate:(n,a)=>{if(!a)return!0;return n===a[e]||r}})}oneOf(e,t){let r=t||`Must be one of: ${e.join(", ")}`;return this.addRule({name:"oneOf",message:r,validate:(n)=>{if(!n)return!0;return e.includes(n)||r}})}notOneOf(e,t){let r=t||`Cannot be one of: ${e.join(", ")}`;return this.addRule({name:"notOneOf",message:r,validate:(n)=>{if(!n)return!0;return!e.includes(n)||r}})}date(e="Must be a valid date"){return this.addRule({name:"date",message:e,validate:(t)=>{if(!t)return!0;let r=new Date(String(t));return!Number.isNaN(r.getTime())||e}})}before(e,t){let r=new Date(e),n=t||`Must be before ${r.toLocaleDateString()}`;return this.addRule({name:"before",message:n,validate:(a)=>{if(!a)return!0;return new Date(String(a))<r||n}})}after(e,t){let r=new Date(e),n=t||`Must be after ${r.toLocaleDateString()}`;return this.addRule({name:"after",message:n,validate:(a)=>{if(!a)return!0;return new Date(String(a))>r||n}})}custom(e,t="Invalid value"){return this.addRule({name:"custom",message:t,validate:e})}async(e,t="Invalid value"){return this.addRule({name:"async",message:t,async:!0,validate:e})}when(e,t){let r=new qt;r.rules=[...this.rules],r.defaultValue=this.defaultValue;for(let n of t.getRules())r.rules.push({...n,validate:(a,o)=>{if(!e(a,o||{}))return!0;return n.validate(a,o)}});return r}getRules(){return this.rules}getDefaultValue(){return this.defaultValue}default(e){let t=new qt;return t.rules=[...this.rules],t.defaultValue=e,t}async validate(e,t){let r=[];for(let n of this.rules){let a=await n.validate(e,t);if(a!==!0)r.push(a)}return r}validateSync(e,t){let r=[];for(let n of this.rules){if(n.async)continue;let a=n.validate(e,t);if(a!==!0)r.push(a)}return r}}var hl=new qt;function Ca(e,t,r){let n=/@error\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderror/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return u.map((l)=>c.replace(/\{\{\s*message\s*\}\}/g,l)).join(`
|
|
3
|
+
`)}catch{return""}})}function $a(e,t,r){let n=/@errors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderrors/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return u.map((l)=>c.replace(/\{\{\s*message\s*\}\}/g,l)).join(`
|
|
4
|
+
`)}catch{return""}})}function Ea(e,t,r){let n=/@hasErrors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@endhasErrors/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return c}catch{return""}})}function yl(e,t,r){let n=e;return n=Ca(n,t,r),n=$a(n,t,r),n=Ea(n,t,r),n}export{gi,ka,qt,hl,Ca,$a,Ea,yl};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Broadcast as s,BroadcastServer as h}from"ts-broadcasting";import{channel as il}from"ts-broadcasting";import{Broadcast as ol,BroadcastServer as al}from"ts-broadcasting";var e=null,u=[];function Yc(){return e}async function Zc(n){if(e)return e;let t=n.driver??"bun",r=n.host??"0.0.0.0",c=n.port??6001,l=n.scheme??"ws",a={verbose:n.verbose??!1,driver:t,default:t,connections:{[t]:{driver:t,host:r,port:c,scheme:l}}};return e=new h(a),s.setServer(e),await e.start(),e}async function Qc(){for(let n of u)clearInterval(n);if(u.length=0,!e)return;await e.stop(),e=null}async function el(n){let t=await import(n),r=t.default??t;if(typeof r!=="function")throw Error(`routes/channels.ts must export a default function, got ${typeof r}`);let c=0;return r({channel(a,o){if(c++,o.authorize&&e)e.channels.channel(a,o.authorize);if(o.interval&&o.data){let d=o.event??`${a}.updated`,p=o.data,v=setInterval(async()=>{try{let g=await p();Go(a,d,g)}catch{}},o.interval);u.push(v)}}}),c}var f=!1;function i(){if(e)return!0;if(!f)f=!0,console.warn("[stx] broadcast() called before server started \u2014 messages will be sent once broadcasting is ready");return!1}function Go(n,t,r){if(!i())return;s.send(n,t,r)}function tl(n,t,r){if(!i())return;s.toUser(n,t,r)}function nl(n,t,r){if(!i())return;s.toUsers(n,t,r)}function rl(n,t,r){if(!i())return;s.send(`private-${n}`,t,r)}function sl(n,t,r){if(!i())return;s.presence(n,t,r)}
|
|
3
|
+
export{Yc,Zc,Qc,el,Go,tl,nl,rl,sl,il,ol,al};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{cl}from"./chunk-e57rhf65.js";import"./chunk-69mc2np8.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-2gr351s0.js";import"./chunk-h0atqq82.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{cl as buildApp};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{le}from"./chunk-69mc2np8.js";import{de,S,Ke}from"./chunk-ngc2wke4.js";import{z}from"./chunk-h0atqq82.js";import{Y,Ce}from"./chunk-czxt605c.js";import{Pe,se,C,ie,ai,kr,ci,Mt}from"./chunk-scezfp0w.js";import{Wr}from"./chunk-xtdw3692.js";import{Nt}from"./chunk-9g27ybyr.js";import J from"fs";import M from"path";var{serve:ae}=globalThis.Bun;import k from"zlib";import{promisify as q}from"util";var Q=q(k.brotliCompress),Z=q(k.gzip),K=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ee=["text/event-stream","multipart/x-mixed-replace"],te=1024;function ne(t){if(!t)return!1;let e=t.toLowerCase();if(ee.some((a)=>e.startsWith(a)))return!1;return K.some((a)=>e.startsWith(a))}function re(t){let e=new Map;for(let a of t.split(",")){let[s,...i]=a.trim().split(";"),l=s.trim().toLowerCase();if(!l)continue;let m=1;for(let f of i){let x=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(f);if(!x)continue;let g=Number.parseFloat(x[1]);if(Number.isFinite(g))m=g}e.set(l,m)}return e}function oe(t){if(!t)return null;let e=re(t),a=e.get("*"),s=(i)=>e.get(i)??a??0;if(s("br")>0)return"br";if(s("gzip")>0)return"gzip";return null}async function Ot(t,e,a={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!ne(e.headers.get("content-type")))return e;let s=oe(t.headers.get("accept-encoding"));if(!s)return e;let i;try{i=new Uint8Array(await e.arrayBuffer())}catch{return e}let l=()=>new Response(i,{status:e.status,statusText:e.statusText,headers:W(e.headers)});if(i.length<(a.threshold??te))return l();try{let m=s==="br"?await Q(i,{params:{[k.constants.BROTLI_PARAM_QUALITY]:a.quality??5,[k.constants.BROTLI_PARAM_SIZE_HINT]:i.length}}):await Z(i);if(m.length>=i.length)return l();let f=W(e.headers);return f.set("Content-Encoding",s),f.set("Content-Length",String(m.length)),new Response(m,{status:e.status,statusText:e.statusText,headers:f})}catch{return l()}}function W(t){let e=new Headers(t),a=e.get("Vary");if(!a)return e.set("Vary","Accept-Encoding"),e;if(!a.split(",").some((i)=>i.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${a}, Accept-Encoding`);return e}class D{now;entries=new z(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,a){let s,i=async()=>{let r=s??await a();return r.headers.set("Cache-Control","private, no-store"),r.headers.set("Vary",C(r.headers.get("Vary")).Vary),r};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return i();let l=new URL(t.url),m=`${l.origin}${l.pathname}${l.search}|${se(t)?"fragment":"document"}`,f=this.entries.get(m),x=(r)=>{let T=new Headers(r.headers);return T.set("Cache-Control","private, no-store"),T.set("Age",String(Math.max(0,Math.floor((this.now()-r.created)/1000)))),new Response(r.body.slice(0),{headers:T})},g=f?(this.now()-f.created)/1000:1/0;if(f&&g<e.maxAge)return x(f);let b=this.generation,B=async()=>{let r=await a();s=r;let T=(r.headers.get("Vary")??"").toLowerCase().split(",").map((R)=>R.trim()).filter(Boolean);if(r.status!==200||r.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(r.headers.get("Cache-Control")??"")||T.some((R)=>R!=="x-stx-router"&&R!=="accept-encoding"))return null;let L=await r.clone().arrayBuffer();if(L.byteLength>1048576)return null;r.headers.set("Vary",C(r.headers.get("Vary")).Vary);let n={body:L,headers:Array.from(r.headers.entries()),created:this.now(),path:l.pathname};if(this.generation===b)this.entries.set(m,n);return n},v=this.pending.get(m);if(!v){if(this.pending.size>=1000)return i();v=B().finally(()=>{if(this.pending.get(m)===v)this.pending.delete(m)}),this.pending.set(m,v)}if(f&&g<e.maxAge+(e.swr??0))return v.catch(()=>{}),x(f);let E=await v;return E?x(E):i()}}var ce={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function ll(t={}){let e=M.resolve(t.outputDir||".output"),a=t.port??3000,s=ai(e);if(!s)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${s.routes.length} routes...`);let i=Nt(s.routeRules),l=new D,m=Wr(e,s.apiRoutes??[]),f=Bun.file(M.join(e,"server/runtime-config.json")),x=t.runtimeConfig??(await f.exists()?await f.json():void 0),g=x?S(x):void 0,b=new Map,B=new Map,v=new Map,E=new Map;for(let n of s.routes)try{let R=M.join(e,n.compiledPath),c=JSON.parse(await Bun.file(R).text());if(g)c.html=Ke(c.html,g);b.set(n.pattern,c),v.set(n.pattern,Ce(c.html)),E.set(n.pattern,le(c.html));let N=M.join(e,n.fragmentPath);if(await Bun.file(N).exists()){let A=await Bun.file(N).text();B.set(n.pattern,g?Ke(A,g):A)}}catch(R){console.warn(`[stx] Failed to load route ${n.pattern}:`,R)}let r=new Map,T=[];for(let n of s.routes)if(n.hasParams){let{regex:R,params:c}=Y(n.pattern);T.push({regex:R,route:n,paramNames:c})}else r.set(n.pattern,n);let L=ae({port:a,async fetch(n){return Ot(n,await de(g??S(),async()=>{let c=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[c])return t.apiRoutes[c](n);let N=await m(n);if(N)return N;if((n.method==="GET"||n.method==="HEAD")&&c!=="/"){let p=M.resolve(e,"public"),d;try{d=decodeURIComponent(c)}catch{d=c}if(!d.includes("\x00")){let u=M.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${M.sep}`))try{if(J.existsSync(u)&&J.statSync(u).isFile()){let h=M.extname(u).toLowerCase(),j=ce[h]||"application/octet-stream",_=c.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(c);return new Response(Bun.file(u),{headers:{"Content-Type":j,"Cache-Control":_?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=se(n),y=null,G={};if(y=r.get(c)||null,!y)for(let{regex:p,route:d,paramNames:u}of T){let o=c.match(p);if(o){y=d,u.forEach((h,j)=>{G[h]=o[j+1]});break}}if(!y){let p=r.get("/404")||null;if(p){let d=b.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}let O=i(c),U=Object.keys(O).length>0;return l.respond(n,O.cache,async()=>{let p=b.get(y.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let o=B.get(y.pattern);if(o){let h=v.get(y.pattern);return new Response(o,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...E.has(y.pattern)?{"X-STX-Runtime":E.get(y.pattern)?"true":"false"}:{},...h?{"X-STX-Layout":h.layout,"X-STX-Layout-Group":h.group}:{},...C(),...O.cache?{}:{"Cache-Control":Pe}}})}}let d=kr(n.method),u=b.get(y.pattern);if(!u){let o=r.get("/500")||null;if(o){let h=b.get(o.pattern);if(h)return new Response(h.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(y.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",...C(),"Cache-Control":"public, max-age=60"}});try{let{html:o,boundaries:h,redirect:j,cookies:_,status:H,headers:I}=await Mt(u,{params:G,request:n,method:n.method,__stx_strict_hydration:U,__stx_runtime_config:g});if(j)return ci(j,_,I);if(h&&h.length>0){let{renderStreamingPage:P,streamToResponse:F}=await import("./chunk-bmt7w2pk.js"),X=new Headers({...C(),...I,"Cache-Control":"private, no-store"});for(let V of _??[])X.append("Set-Cookie",V);if(A&&!d){let V=Ce(o);X.set("X-STX-Fragment","true"),X.set("X-STX-Runtime",le(o)?"true":"false"),X.set("X-STX-Layout",V.layout),X.set("X-STX-Layout-Group",V.group)}return F(P(A&&!d?ie(o,s.routerContainer||"main"):o,h,{timeoutMs:30000}),{status:H??u.status??200,headers:X})}let w=new Headers({"Content-Type":"text/html",...C(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let P of _??[])w.append("Set-Cookie",P);for(let[P,F]of Object.entries(I??{}))w.set(P,F);if(w.set("Vary",C(w.get("Vary")).Vary),A&&!d){let P=Ce(o);return w.set("X-STX-Fragment","true"),w.set("X-STX-Runtime",le(o)?"true":"false"),w.set("X-STX-Layout",P.layout),w.set("X-STX-Layout-Group",P.group),new Response(ie(o,s.routerContainer||"main"),{status:H??u.status??200,headers:w})}return new Response(o,{status:H??u.status??200,headers:w})}catch(o){if(console.error(`[stx] Hydration error for ${c}:`,o),U)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${L.port}`),console.log(`[stx] Serving ${s.routes.length} routes (${b.size} pre-loaded)`),{port:L.port,stop:()=>{l.invalidate(),L.stop()},invalidate:(n)=>l.invalidate(n)}}
|
|
3
|
+
export{Ot,ll};
|