@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
package/dist/craft-entry.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
`),scripts:
|
|
4
|
-
`),metadata:{renderTime:0,cacheHit:!0,totalSize:
|
|
5
|
-
`),scripts:
|
|
6
|
-
`),hydrationData:
|
|
2
|
+
import{Fr,ki,Ci}from"./chunk-j03revz2.js";import"./chunk-z0g9jvv0.js";import"./chunk-shr559s7.js";import"./chunk-czxt605c.js";import"./chunk-ce1sejr3.js";import"./chunk-8nhshfz6.js";import"./chunk-69mc2np8.js";import"./chunk-h0atqq82.js";import"./chunk-m4sk62wb.js";import"./chunk-xfp7k0v8.js";import"./chunk-ngc2wke4.js";import"./chunk-2gr351s0.js";import"./chunk-7gkv67ky.js";import"./chunk-ak1cgcah.js";import{yu,hi,bu,vu,yi,Br,bi,wu,vi,xu,Su,wi,xi,Si}from"./chunk-sd47dzs0.js";import"./chunk-ynvdvbat.js";import"./chunk-752hw7cd.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
|
|
3
|
+
`),scripts:t.scripts.join(`
|
|
4
|
+
`),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
|
|
5
|
+
`),scripts:t.scripts.join(`
|
|
6
|
+
`),hydrationData:i,metadata:{renderTime:s,cacheHit:!1,totalSize:a.length,componentCount:t.metadata.componentCount}}}function V(t,e){let n=[],r=[],a=[],i=new Map,s=[];return y(t.tree,(o,c)=>{if(o.type==="component"&&o.componentName){if(T(o.componentName))n.push(o.componentName)}if(o.type==="element"&&o.tag){let p=J(o);if(p)s.push(p);if(o.props){for(let[l,f]of Object.entries(o.props))if(l.startsWith("on")&&typeof f==="string"){let g=`handler_${i.size}`;i.set(g,f)}}}if(o.isStatic&&o.type==="element")r.push(b(o));else if(!o.isStatic&&o.type!=="text")a.push(o.tag||o.componentName||"unknown")}),{nativeComponents:n,staticHTML:r,dynamicParts:a,eventHandlers:i,nativeWidgets:s}}function Y(t,e={}){let n=R(t),r=P(n,e),a=new Map,i=[];return y(n.tree,(s)=>{if(s.type==="component"&&s.componentName){if(T(s.componentName)){i.push(s.componentName);let o=`<!--craft:${s.componentName}:${s.hydrationKey||"default"}-->`;a.set(s.hydrationKey||s.componentName,o)}}}),{staticHTML:r,dynamicPlaceholders:a,craftComponents:i}}function M(t){let e={type:"fragment",children:[]},n=e,r=[e],a=t,i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);while(a.length>0){let s=a.match(/^<(@?[\w-]+)([^>]*)>/);if(s){let[p,l,f]=s,g=z(f),u=l.startsWith("@craft-"),C=u?l:l.toLowerCase(),S={type:u?"component":"element",tag:C,props:g,children:[],componentName:u?C.slice(1):void 0,isStatic:!v(f),hydrationKey:F()};if(n.children=n.children||[],n.children.push(S),!i.has(C)&&!f.endsWith("/"))r.push(S),n=S;a=a.slice(p.length);continue}let o=a.match(/^<\/(@?[\w-]+)>/);if(o){let[p,l]=o,g=l.startsWith("@craft-")?l:l.toLowerCase();while(r.length>1){let u=r.pop();if(n=r[r.length-1],u.tag===g)break}a=a.slice(p.length);continue}let c=a.match(/^[^<]+/);if(c){let p=c[0];if(p.trim()){let l={type:"text",text:p,isStatic:!v(p)};n.children=n.children||[],n.children.push(l)}a=a.slice(p.length);continue}a=a.slice(1)}return e}function z(t){let e={},n=/([\w-:@]+)(?:=(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,r;while((r=n.exec(t))!==null){let[,a,i,s,o]=r,c=i??s??o??!0;e[a]=c}return e}function y(t,e,n=[]){if(e(t,n),t.children)t.children.forEach((r,a)=>{y(r,e,[...n,`${a}`])})}function h(t,e){switch(t.type){case"text":return x(t.text||"",e);case"element":case"component":{let n=t.tag||"div",r=N(t.props||{},e),a=(t.children||[]).map((i)=>h(i,e)).join("");if(!t.children||t.children.length===0){if(["input","br","hr","img","meta","link"].includes(n))return`<${n}${r} />`}return`<${n}${r}>${a}</${n}>`}case"fragment":return(t.children||[]).map((n)=>h(n,e)).join("");case"slot":return`<!--slot:${t.slotName||"default"}-->`;default:return""}}function b(t){if(t.type==="text")return t.text||"";let e=t.tag||"div",n=N(t.props||{},{});return`<${e}${n}></${e}>`}function N(t,e){let n=[];for(let[r,a]of Object.entries(t))if(a===!0)n.push(` ${r}`);else if(a!==!1&&a!==null&&a!==void 0){let i=x(String(a),e);n.push(` ${r}="${k(i)}"`)}return n.join("")}async function H(t,e){return h(t,e)}function P(t,e){let n=[];return y(t.tree,(r)=>{if(r.isStatic)n.push(h(r,e))}),n.join("")}function j(t,e,n){let r={templateId:e.id,context:n,dynamicParts:Array.from(e.dynamicParts.entries())},a=`
|
|
7
7
|
<script data-craft-hydration>
|
|
8
|
-
window.__CRAFT_HYDRATION__ = ${JSON.stringify(
|
|
9
|
-
</script>`;return{html:
|
|
8
|
+
window.__CRAFT_HYDRATION__ = ${JSON.stringify(r)};
|
|
9
|
+
</script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{yu as CRAFT_BRIDGE_SCRIPT,Br as CRAFT_COMPONENTS,wu as CRAFT_COMPONENT_RUNTIME,bi as CRAFT_COMPONENT_STYLES,Fr as NATIVE_COMPONENTS,wi as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,ki as compileToNative,Ci as createHotReloadServer,hi as generateCraftBridgeScript,V as generateCraftOptimizations,Si as getAvailableFormats,xi as getAvailableTargets,Su as getCraftComponents,G as getSSRCacheStats,yi as injectCraftBridge,bu as isCraftEnvironment,Y as prerenderForCraft,vi as processCraftComponents,vu as processCraftDirective,xu as registerCraftComponent,Q as renderSSR};
|
package/dist/craft.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
`),scripts:
|
|
4
|
-
`),metadata:{renderTime:0,cacheHit:!0,totalSize:
|
|
5
|
-
`),scripts:
|
|
6
|
-
`),hydrationData:
|
|
2
|
+
import{Fr,ki,Ci}from"./chunk-j03revz2.js";import"./chunk-z0g9jvv0.js";import"./chunk-shr559s7.js";import"./chunk-czxt605c.js";import"./chunk-ce1sejr3.js";import"./chunk-8nhshfz6.js";import"./chunk-69mc2np8.js";import"./chunk-h0atqq82.js";import"./chunk-m4sk62wb.js";import"./chunk-xfp7k0v8.js";import"./chunk-ngc2wke4.js";import"./chunk-2gr351s0.js";import"./chunk-7gkv67ky.js";import"./chunk-ak1cgcah.js";import{yu,hi,bu,vu,yi,Br,bi,wu,vi,xu,Su,wi,xi,Si}from"./chunk-sd47dzs0.js";import"./chunk-ynvdvbat.js";import"./chunk-752hw7cd.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
|
|
3
|
+
`),scripts:t.scripts.join(`
|
|
4
|
+
`),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
|
|
5
|
+
`),scripts:t.scripts.join(`
|
|
6
|
+
`),hydrationData:i,metadata:{renderTime:s,cacheHit:!1,totalSize:a.length,componentCount:t.metadata.componentCount}}}function V(t,e){let n=[],r=[],a=[],i=new Map,s=[];return y(t.tree,(o,c)=>{if(o.type==="component"&&o.componentName){if(T(o.componentName))n.push(o.componentName)}if(o.type==="element"&&o.tag){let p=J(o);if(p)s.push(p);if(o.props){for(let[l,f]of Object.entries(o.props))if(l.startsWith("on")&&typeof f==="string"){let g=`handler_${i.size}`;i.set(g,f)}}}if(o.isStatic&&o.type==="element")r.push(b(o));else if(!o.isStatic&&o.type!=="text")a.push(o.tag||o.componentName||"unknown")}),{nativeComponents:n,staticHTML:r,dynamicParts:a,eventHandlers:i,nativeWidgets:s}}function Y(t,e={}){let n=R(t),r=P(n,e),a=new Map,i=[];return y(n.tree,(s)=>{if(s.type==="component"&&s.componentName){if(T(s.componentName)){i.push(s.componentName);let o=`<!--craft:${s.componentName}:${s.hydrationKey||"default"}-->`;a.set(s.hydrationKey||s.componentName,o)}}}),{staticHTML:r,dynamicPlaceholders:a,craftComponents:i}}function M(t){let e={type:"fragment",children:[]},n=e,r=[e],a=t,i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);while(a.length>0){let s=a.match(/^<(@?[\w-]+)([^>]*)>/);if(s){let[p,l,f]=s,g=z(f),u=l.startsWith("@craft-"),C=u?l:l.toLowerCase(),S={type:u?"component":"element",tag:C,props:g,children:[],componentName:u?C.slice(1):void 0,isStatic:!v(f),hydrationKey:F()};if(n.children=n.children||[],n.children.push(S),!i.has(C)&&!f.endsWith("/"))r.push(S),n=S;a=a.slice(p.length);continue}let o=a.match(/^<\/(@?[\w-]+)>/);if(o){let[p,l]=o,g=l.startsWith("@craft-")?l:l.toLowerCase();while(r.length>1){let u=r.pop();if(n=r[r.length-1],u.tag===g)break}a=a.slice(p.length);continue}let c=a.match(/^[^<]+/);if(c){let p=c[0];if(p.trim()){let l={type:"text",text:p,isStatic:!v(p)};n.children=n.children||[],n.children.push(l)}a=a.slice(p.length);continue}a=a.slice(1)}return e}function z(t){let e={},n=/([\w-:@]+)(?:=(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,r;while((r=n.exec(t))!==null){let[,a,i,s,o]=r,c=i??s??o??!0;e[a]=c}return e}function y(t,e,n=[]){if(e(t,n),t.children)t.children.forEach((r,a)=>{y(r,e,[...n,`${a}`])})}function h(t,e){switch(t.type){case"text":return x(t.text||"",e);case"element":case"component":{let n=t.tag||"div",r=N(t.props||{},e),a=(t.children||[]).map((i)=>h(i,e)).join("");if(!t.children||t.children.length===0){if(["input","br","hr","img","meta","link"].includes(n))return`<${n}${r} />`}return`<${n}${r}>${a}</${n}>`}case"fragment":return(t.children||[]).map((n)=>h(n,e)).join("");case"slot":return`<!--slot:${t.slotName||"default"}-->`;default:return""}}function b(t){if(t.type==="text")return t.text||"";let e=t.tag||"div",n=N(t.props||{},{});return`<${e}${n}></${e}>`}function N(t,e){let n=[];for(let[r,a]of Object.entries(t))if(a===!0)n.push(` ${r}`);else if(a!==!1&&a!==null&&a!==void 0){let i=x(String(a),e);n.push(` ${r}="${k(i)}"`)}return n.join("")}async function H(t,e){return h(t,e)}function P(t,e){let n=[];return y(t.tree,(r)=>{if(r.isStatic)n.push(h(r,e))}),n.join("")}function j(t,e,n){let r={templateId:e.id,context:n,dynamicParts:Array.from(e.dynamicParts.entries())},a=`
|
|
7
7
|
<script data-craft-hydration>
|
|
8
|
-
window.__CRAFT_HYDRATION__ = ${JSON.stringify(
|
|
9
|
-
</script>`;return{html:
|
|
8
|
+
window.__CRAFT_HYDRATION__ = ${JSON.stringify(r)};
|
|
9
|
+
</script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{yu as CRAFT_BRIDGE_SCRIPT,Br as CRAFT_COMPONENTS,wu as CRAFT_COMPONENT_RUNTIME,bi as CRAFT_COMPONENT_STYLES,Fr as NATIVE_COMPONENTS,wi as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,ki as compileToNative,Ci as createHotReloadServer,hi as generateCraftBridgeScript,V as generateCraftOptimizations,Si as getAvailableFormats,xi as getAvailableTargets,Su as getCraftComponents,G as getSSRCacheStats,yi as injectCraftBridge,bu as isCraftEnvironment,Y as prerenderForCraft,vi as processCraftComponents,vu as processCraftDirective,xu as registerCraftComponent,Q as renderSSR};
|
package/dist/database.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ix as Q}from"./chunk-2fw05hs2.js";var $={default:"sqlite",connections:{},logging:!1,cacheTTL:0,maxCacheSize:1000},V={},A={},L=new Map,S=[];function i(z){$={...$,...z}}function o(){return{...$}}function r(){$={default:"sqlite",connections:{},logging:!1,cacheTTL:0,maxCacheSize:1000};for(let z of Object.keys(V))delete V[z];L.clear(),S.length=0}function a(z,H){V[z]=H}function F(z){let H=z||$.default;if(V[H])return V[H];let U=$.connections[H];if(!U)throw Error(`Database connection "${H}" not configured`);let W=h(U);return V[H]=W,W}function h(z){switch(z.driver){case"sqlite":return q(z);case"postgres":return y(z);case"mysql":return f(z);default:throw Error(`Unsupported database driver: ${z.driver}`)}}function q(z){let H=null,U=!1;return{async connect(){if(U)return;let{Database:W}=await import("bun:sqlite");H=new W(z.database,{create:!0,readwrite:!0}),U=!0},async disconnect(){if(H)H.close(),H=null,U=!1},async query(W,J=[]){if(!U)await this.connect();let X=performance.now();try{let Y=H.prepare(W).all(...J);if($.logging)B(W,J,performance.now()-X);return Y}catch(Z){throw new O(`Query failed: ${Z}`,W,J)}},async insert(W,J=[]){if(!U)await this.connect();let X=performance.now();try{let Y=H.prepare(W).run(...J);if($.logging)B(W,J,performance.now()-X);return Y.lastInsertRowid}catch(Z){throw new O(`Insert failed: ${Z}`,W,J)}},async execute(W,J=[]){if(!U)await this.connect();let X=performance.now();try{let Y=H.prepare(W).run(...J);if($.logging)B(W,J,performance.now()-X);return Y.changes}catch(Z){throw new O(`Execute failed: ${Z}`,W,J)}},async beginTransaction(){if(!U)await this.connect();H.run("BEGIN TRANSACTION")},async commit(){H.run("COMMIT")},async rollback(){H.run("ROLLBACK")},isConnected(){return U}}}function y(z){let H=!1,U=null;return{async connect(){if(H)return;try{let{Client:W}=await import("pg");U=new W({host:z.host||"localhost",port:z.port||5432,database:z.database,user:z.username,password:z.password,ssl:z.ssl}),await U.connect(),H=!0}catch(W){throw Error(`PostgreSQL connection failed. Install 'pg' package: ${W}`)}},async disconnect(){if(U)await U.end(),U=null,H=!1},async query(W,J=[]){if(!H)await this.connect();let X=performance.now();try{let Z=await U.query(W,J);if($.logging)B(W,J,performance.now()-X);return Z.rows}catch(Z){throw new O(`Query failed: ${Z}`,W,J)}},async insert(W,J=[]){if(!H)await this.connect();let X=performance.now();try{let Z=await U.query(`${W} RETURNING id`,J);if($.logging)B(W,J,performance.now()-X);return Z.rows[0]?.id}catch(Z){throw new O(`Insert failed: ${Z}`,W,J)}},async execute(W,J=[]){if(!H)await this.connect();let X=performance.now();try{let Z=await U.query(W,J);if($.logging)B(W,J,performance.now()-X);return Z.rowCount||0}catch(Z){throw new O(`Execute failed: ${Z}`,W,J)}},async beginTransaction(){if(!H)await this.connect();await U.query("BEGIN")},async commit(){await U.query("COMMIT")},async rollback(){await U.query("ROLLBACK")},isConnected(){return H}}}function f(z){let H=!1,U=null;return{async connect(){if(H)return;try{U=(await import("mysql2/promise")).createPool({host:z.host||"localhost",port:z.port||3306,database:z.database,user:z.username,password:z.password,waitForConnections:!0,connectionLimit:z.poolSize||10,queueLimit:0}),H=!0}catch(W){throw Error(`MySQL connection failed. Install 'mysql2' package: ${W}`)}},async disconnect(){if(U)await U.end(),U=null,H=!1},async query(W,J=[]){if(!H)await this.connect();let X=performance.now();try{let[Z]=await U.execute(W,J);if($.logging)B(W,J,performance.now()-X);return Z}catch(Z){throw new O(`Query failed: ${Z}`,W,J)}},async insert(W,J=[]){if(!H)await this.connect();let X=performance.now();try{let[Z]=await U.execute(W,J);if($.logging)B(W,J,performance.now()-X);return Z.insertId}catch(Z){throw new O(`Insert failed: ${Z}`,W,J)}},async execute(W,J=[]){if(!H)await this.connect();let X=performance.now();try{let[Z]=await U.execute(W,J);if($.logging)B(W,J,performance.now()-X);return Z.affectedRows||0}catch(Z){throw new O(`Execute failed: ${Z}`,W,J)}},async beginTransaction(){if(!H)await this.connect();let W=await U.getConnection();return await W.beginTransaction(),W},async commit(){await U.execute("COMMIT")},async rollback(){await U.execute("ROLLBACK")},isConnected(){return H}}}class D{_table="";_columns=["*"];_wheres=[];_orders=[];_joins=[];_groupBy=[];_having=[];_limit;_offset;_distinct=!1;_connection;_bindings=[];_modelDefinition;constructor(z){if(z)this._table=z}table(z){return this._table=z,this}from(z){return this.table(z)}connection(z){return this._connection=z,this}select(...z){return this._columns=z.length>0?z:["*"],this}addSelect(...z){if(this._columns[0]==="*")this._columns=z;else this._columns.push(...z);return this}distinct(){return this._distinct=!0,this}where(z,H,U){let W="=",J=H;if(U!==void 0)W=H,J=U;return this._wheres.push({column:z,operator:W,value:J,boolean:"and"}),this}orWhere(z,H,U){let W="=",J=H;if(U!==void 0)W=H,J=U;return this._wheres.push({column:z,operator:W,value:J,boolean:"or"}),this}whereIn(z,H){return this._wheres.push({column:z,operator:"in",value:H,boolean:"and"}),this}whereNotIn(z,H){return this._wheres.push({column:z,operator:"not in",value:H,boolean:"and"}),this}whereNull(z){return this._wheres.push({column:z,operator:"is null",value:null,boolean:"and"}),this}whereNotNull(z){return this._wheres.push({column:z,operator:"is not null",value:null,boolean:"and"}),this}whereBetween(z,H,U){return this._wheres.push({column:z,operator:"between",value:[H,U],boolean:"and"}),this}whereLike(z,H){return this._wheres.push({column:z,operator:"like",value:H,boolean:"and"}),this}join(z,H,U,W){return this._joins.push({type:"inner",table:z,first:H,operator:U,second:W}),this}leftJoin(z,H,U,W){return this._joins.push({type:"left",table:z,first:H,operator:U,second:W}),this}rightJoin(z,H,U,W){return this._joins.push({type:"right",table:z,first:H,operator:U,second:W}),this}orderBy(z,H="asc"){return this._orders.push({column:z,direction:H}),this}orderByDesc(z){return this.orderBy(z,"desc")}groupBy(...z){return this._groupBy.push(...z),this}having(z,H,U){return this._having.push({column:z,operator:H,value:U,boolean:"and"}),this}limit(z){return this._limit=z,this}take(z){return this.limit(z)}offset(z){return this._offset=z,this}skip(z){return this.offset(z)}forPage(z,H=15){return this.offset((z-1)*H).limit(H)}async get(){let{sql:z,bindings:H}=this.toSql();if($.cacheTTL&&$.cacheTTL>0){let J=this.getCacheKey(z,H),X=g(J);if(X!==void 0)return X}let W=await F(this._connection).query(z,H);if($.cacheTTL&&$.cacheTTL>0){let J=this.getCacheKey(z,H);m(J,W,$.cacheTTL)}return W}async first(){return(await this.limit(1).get())[0]||null}async firstOrFail(){let z=await this.first();if(!z)throw Error("No results found");return z}async find(z,H="id"){return this.where(H,z).first()}async value(z){let H=await this.select(z).first();return H?H[z]:null}async pluck(z){return(await this.select(z).get()).map((U)=>U[z])}async exists(){return(await this.select(E("1")).limit(1).get()).length>0}async doesntExist(){return!await this.exists()}async count(z="*"){let H=await this.select(E(`COUNT(${z}) as count`)).first();return Number(H?.count||0)}async max(z){return(await this.select(E(`MAX(${z}) as max`)).first())?.max}async min(z){return(await this.select(E(`MIN(${z}) as min`)).first())?.min}async sum(z){let H=await this.select(E(`SUM(${z}) as sum`)).first();return Number(H?.sum||0)}async avg(z){return(await this.select(E(`AVG(${z}) as avg`)).first())?.avg}async insert(z){let H=Object.keys(z),U=H.map(()=>"?").join(", "),W=Object.values(z),J=`INSERT INTO ${this._table} (${H.join(", ")}) VALUES (${U})`,X=F(this._connection);return P(this._table),X.insert(J,W)}async insertAll(z){if(z.length===0)return;let H=Object.keys(z[0]),U=z.map(()=>`(${H.map(()=>"?").join(", ")})`).join(", "),W=z.flatMap((Z)=>Object.values(Z)),J=`INSERT INTO ${this._table} (${H.join(", ")}) VALUES ${U}`,X=F(this._connection);P(this._table),await X.execute(J,W)}async update(z){this._bindings=[];let H=this.buildWhereClause(),U=[...this._bindings],W=Object.keys(z).map((Y)=>`${Y} = ?`).join(", "),J=[...Object.values(z),...U],X=`UPDATE ${this._table} SET ${W}${H}`,Z=F(this._connection);return P(this._table),Z.execute(X,J)}async increment(z,H=1){this._bindings=[];let U=this.buildWhereClause(),W=`UPDATE ${this._table} SET ${z} = ${z} + ?${U}`,J=F(this._connection);return P(this._table),J.execute(W,[H,...this._bindings])}async decrement(z,H=1){return this.increment(z,-H)}async delete(){this._bindings=[];let z=this.buildWhereClause(),H=`DELETE FROM ${this._table}${z}`,U=F(this._connection);return P(this._table),U.execute(H,this._bindings)}async truncate(){let z=F(this._connection);P(this._table),await z.execute(`DELETE FROM ${this._table}`)}toSql(){this._bindings=[];let z="SELECT ";if(this._distinct)z+="DISTINCT ";z+=this._columns.map((H)=>{if(typeof H==="object"&&H.__raw)return H.sql;return H}).join(", "),z+=` FROM ${this._table}`;for(let H of this._joins)z+=` ${H.type.toUpperCase()} JOIN ${H.table} ON ${H.first} ${H.operator} ${H.second}`;if(z+=this.buildWhereClause(),this._groupBy.length>0)z+=` GROUP BY ${this._groupBy.join(", ")}`;if(this._having.length>0){let H=this._having.map((U,W)=>{let J=W===0?"":` ${U.boolean.toUpperCase()} `;return this._bindings.push(U.value),`${J}${U.column} ${U.operator} ?`});z+=` HAVING ${H.join("")}`}if(this._orders.length>0)z+=` ORDER BY ${this._orders.map((H)=>`${H.column} ${H.direction.toUpperCase()}`).join(", ")}`;if(this._limit!==void 0)z+=` LIMIT ${this._limit}`;if(this._offset!==void 0)z+=` OFFSET ${this._offset}`;return{sql:z,bindings:this._bindings}}buildWhereClause(){if(this._wheres.length===0)return"";return this._wheres.map((H,U)=>{let W=U===0?" WHERE ":` ${H.boolean.toUpperCase()} `;switch(H.operator){case"in":{let J=H.value,X=J.map(()=>"?").join(", ");return this._bindings.push(...J),`${W}${H.column} IN (${X})`}case"not in":{let J=H.value,X=J.map(()=>"?").join(", ");return this._bindings.push(...J),`${W}${H.column} NOT IN (${X})`}case"between":{let[J,X]=H.value;return this._bindings.push(J,X),`${W}${H.column} BETWEEN ? AND ?`}case"is null":return`${W}${H.column} IS NULL`;case"is not null":return`${W}${H.column} IS NOT NULL`;default:return this._bindings.push(H.value),`${W}${H.column} ${H.operator} ?`}}).join("")}getCacheKey(z,H){return`${this._table}:${z}:${JSON.stringify(H)}`}clone(){let z=new D(this._table);return z._columns=[...this._columns],z._wheres=[...this._wheres],z._orders=[...this._orders],z._joins=[...this._joins],z._groupBy=[...this._groupBy],z._having=[...this._having],z._limit=this._limit,z._offset=this._offset,z._distinct=this._distinct,z._connection=this._connection,z}}function G(z){return new D(z)}function t(z){return G(z)}function E(z,H=[]){return{__raw:!0,sql:z,bindings:H}}function n(z,H){let U=H.primaryKey||"id",W={name:z,definition:H,async find(J){let X=await G(H.table).where(U,J).first();return X?N(W,X):null},async findOrFail(J){let X=await this.find(J);if(!X)throw Error(`${z} not found with ${U} = ${J}`);return X},async all(){return(await G(H.table).get()).map((X)=>N(W,X))},async create(J){let X={...H.defaults,...J},Z=H.fillable?Object.fromEntries(Object.entries(X).filter(([_])=>H.fillable.includes(_))):X;if(H.timestamps!==!1){let _=new Date().toISOString(),R=typeof H.timestamps==="object"?H.timestamps.createdAt||"created_at":"created_at",T=typeof H.timestamps==="object"?H.timestamps.updatedAt||"updated_at":"updated_at";Z[R]=_,Z[T]=_}let Y=await G(H.table).insert(Z);return this.findOrFail(Y)},async update(J){return G(H.table).update(J)},async destroy(J){let X=Array.isArray(J)?J:[J];return G(H.table).whereIn(U,X).delete()},query(){return G(H.table)},where(J,X,Z){return this.query().where(J,X,Z)},async first(){let J=await this.query().first();return J?N(W,J):null},async get(){return(await this.query().get()).map((X)=>N(W,X))},async count(){return this.query().count()}};return A[z]=W,W}function k(z){let H=A[z];if(!H)throw Error(`Model "${z}" not defined. Use defineModel() first.`);return H}function e(z){return z in A}function N(z,H){let{definition:U}=z,W=U.primaryKey||"id",J={...H},X={...H};if(U.casts){for(let[Y,_]of Object.entries(U.casts))if(Y in X)X[Y]=p(X[Y],_)}let Z={exists:!0,original:J,attributes:X,get(Y){return X[Y]},set(Y,_){X[Y]=_},toJSON(){let Y={...X};if(U.hidden)for(let _ of U.hidden)delete Y[_];return Y},async save(){let Y={};for(let _ of Object.keys(X))if(X[_]!==J[_])Y[_]=X[_];if(Object.keys(Y).length>0){if(U.timestamps!==!1){let _=typeof U.timestamps==="object"?U.timestamps.updatedAt||"updated_at":"updated_at";Y[_]=new Date().toISOString()}await G(U.table).where(W,J[W]).update(Y),Object.assign(J,Y)}},async delete(){if(U.softDeletes){let Y=typeof U.softDeletes==="string"?U.softDeletes:"deleted_at";await G(U.table).where(W,J[W]).update({[Y]:new Date().toISOString()})}else await G(U.table).where(W,J[W]).delete();Z.exists=!1},async refresh(){let Y=await G(U.table).where(W,J[W]).first();if(Y)Object.assign(J,Y),Object.assign(X,Y)},isDirty(Y){if(Y)return X[Y]!==J[Y];return Object.keys(X).some((_)=>X[_]!==J[_])}};if(U.relationships)for(let[Y,_]of Object.entries(U.relationships))Object.defineProperty(Z,Y,{value:async()=>{return b(Z,_,z)},enumerable:!1});return new Proxy(Z,{get(Y,_){if(_ in Y)return Y[_];return X[_]},set(Y,_,R){if(_ in Y)Y[_]=R;else X[_]=R;return!0}})}async function b(z,H,U){let W=k(H.model),J=U.definition.primaryKey||"id";switch(H.type){case"hasOne":{let X=H.foreignKey||`${U.name.toLowerCase()}_id`,Z=await G(W.definition.table).where(X,z.get(J)).first();return Z?N(W,Z):null}case"hasMany":{let X=H.foreignKey||`${U.name.toLowerCase()}_id`;return(await G(W.definition.table).where(X,z.get(J)).get()).map((Y)=>N(W,Y))}case"belongsTo":{let X=H.foreignKey||`${H.model.toLowerCase()}_id`,Z=H.localKey||"id",Y=await G(W.definition.table).where(Z,z.get(X)).first();return Y?N(W,Y):null}case"belongsToMany":{let X=H.pivotTable||[U.name,H.model].sort().join("_").toLowerCase(),Z=H.pivotForeignKey||`${U.name.toLowerCase()}_id`,Y=H.pivotRelatedKey||`${H.model.toLowerCase()}_id`,_=W.definition.primaryKey||"id";return(await G(W.definition.table).join(X,`${W.definition.table}.${_}`,"=",`${X}.${Y}`).where(`${X}.${Z}`,z.get(J)).get()).map((T)=>N(W,T))}default:return null}}function p(z,H){if(z===null||z===void 0)return z;switch(H){case"string":return String(z);case"number":return Number(z);case"boolean":return Boolean(z);case"date":return new Date(z);case"json":case"array":return typeof z==="string"?JSON.parse(z):z;default:return z}}async function zz(z,H){let U=F(H);await U.beginTransaction();try{let W=await z();return await U.commit(),W}catch(W){throw await U.rollback(),W}}function g(z){let H=L.get(z);if(!H)return;if(Date.now()-H.timestamp>H.ttl*1000){L.delete(z);return}return H.result}function m(z,H,U){if(L.size>=($.maxCacheSize||1000)){let W=L.keys().next().value;if(W)L.delete(W)}L.set(z,{result:H,timestamp:Date.now(),ttl:U})}function P(z){for(let H of L.keys())if(H.startsWith(`${z}:`))L.delete(H)}function Hz(){L.clear()}function Jz(){return{size:L.size,keys:[...L.keys()]}}function B(z,H,U){if(S.push({sql:z,bindings:H,duration:U,timestamp:new Date}),S.length>1000)S.shift()}function Uz(){return[...S]}function Wz(){S.length=0}function Xz(z=!0){$.logging=z}class O extends Error{sql;bindings;constructor(z,H,U){super(z);this.sql=H;this.bindings=U;this.name="DatabaseError"}}async function u(z,H,U,W){let J=/@db\(\s*['"]([^'"]+)['"]\s*\)((?:->\w+\([^)]*\))*)/g,X=z,Z=[...z.matchAll(J)];for(let Y of Z){let[_,R,T]=Y;try{let j=await s(R,T),I=`$${R}`;H[I]=j,X=X.replace(_,"")}catch(j){X=X.replace(_,`<!-- DB Error: ${j instanceof Error?j.message:String(j)} -->`)}}return X}async function d(z,H,U,W){let J=/@model\(\s*['"]([^'"]+)['"]\s*\)((?:->\w+\([^)]*\))*)/g,X=z,Z=[...z.matchAll(J)];for(let Y of Z){let[_,R,T]=Y;try{let j=k(R),I=await l(j,T),K=`$${R.toLowerCase()}`;H[K]=I,X=X.replace(_,"")}catch(j){X=X.replace(_,`<!-- Model Error: ${j instanceof Error?j.message:String(j)} -->`)}}return X}async function c(z,H,U,W){let J=/@query\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\[[^\]]*\]))?\s*\)\s*as\s+\$(\w+)/g,X=z,Z=[...z.matchAll(J)];for(let Y of Z){let[_,R,T,j]=Y;try{let I=T?JSON.parse(T):[],v=await F().query(R,I);H[`$${j}`]=v,X=X.replace(_,"")}catch(I){X=X.replace(_,`<!-- Query Error: ${I instanceof Error?I.message:String(I)} -->`)}}return X}async function s(z,H){let U=G(z),W=/->(\w+)\(([^)]*)\)/g,J=[...H.matchAll(W)],X=U;for(let[,Z,Y]of J){let _=M(Y);if(typeof X[Z]==="function"){if(X=X[Z](..._),X instanceof Promise){X=await X;break}}}if(X instanceof D)X=await X.get();return X}async function l(z,H){let U=/->(\w+)\(([^)]*)\)/g,W=[...H.matchAll(U)],J=z;for(let[,X,Z]of W){let Y=M(Z);if(typeof J[X]==="function"){if(J=J[X](...Y),J instanceof Promise)J=await J}else if(J instanceof D){if(typeof J[X]==="function"){if(J=J[X](...Y),J instanceof Promise)J=await J}}}if(J instanceof D)J=await J.get();return J}function M(z){if(!z.trim())return[];let H=[],U="",W=0,J=!1,X="";for(let Z=0;Z<z.length;Z++){let Y=z[Z];if(!J&&(Y==='"'||Y==="'"))J=!0,X=Y,U+=Y;else if(J&&Y===X)J=!1,U+=Y;else if(!J&&(Y==="["||Y==="{"||Y==="("))W++,U+=Y;else if(!J&&(Y==="]"||Y==="}"||Y===")"))W--,U+=Y;else if(!J&&W===0&&Y===",")H.push(x(U.trim())),U="";else U+=Y}if(U.trim())H.push(x(U.trim()));return H}function x(z){if(z.startsWith('"')&&z.endsWith('"')||z.startsWith("'")&&z.endsWith("'"))return z.slice(1,-1);if(z==="true")return!0;if(z==="false")return!1;if(z==="null")return null;let H=Number(z);if(!Number.isNaN(H))return H;try{return JSON.parse(z)}catch{return z}}async function Yz(z,H,U,W){let J=z;return J=await c(J,H,U,W),J=await d(J,H,U,W),J=await u(J,H,U,W),J}class w{_connection;connection(z){return this._connection=z,this}async create(z,H){let U=new C(z);H(U);let W=U.toCreateSQL();await F(this._connection).execute(W)}async drop(z){await F(this._connection).execute(`DROP TABLE IF EXISTS ${z}`)}async rename(z,H){await F(this._connection).execute(`ALTER TABLE ${z} RENAME TO ${H}`)}async hasTable(z){let H=F(this._connection);try{return await H.query(`SELECT 1 FROM ${z} LIMIT 1`),!0}catch{return!1}}}class C{table;columns=[];indices=[];constructor(z){this.table=z}id(z="id"){return this.columns.push(`${z} INTEGER PRIMARY KEY AUTOINCREMENT`),this}string(z,H=255){return this.columns.push(`${z} VARCHAR(${H})`),this}text(z){return this.columns.push(`${z} TEXT`),this}integer(z){return this.columns.push(`${z} INTEGER`),this}boolean(z){return this.columns.push(`${z} BOOLEAN DEFAULT 0`),this}datetime(z){return this.columns.push(`${z} DATETIME`),this}timestamps(){return this.columns.push("created_at DATETIME DEFAULT CURRENT_TIMESTAMP"),this.columns.push("updated_at DATETIME DEFAULT CURRENT_TIMESTAMP"),this}softDeletes(){return this.columns.push("deleted_at DATETIME"),this}json(z){return this.columns.push(`${z} TEXT`),this}foreignId(z){return this.columns.push(`${z} INTEGER`),this}index(z){let H=Array.isArray(z)?z:[z],U=`idx_${this.table}_${H.join("_")}`;return this.indices.push(`CREATE INDEX ${U} ON ${this.table} (${H.join(", ")})`),this}unique(z){let H=Array.isArray(z)?z:[z],U=`uniq_${this.table}_${H.join("_")}`;return this.indices.push(`CREATE UNIQUE INDEX ${U} ON ${this.table} (${H.join(", ")})`),this}toCreateSQL(){return`CREATE TABLE IF NOT EXISTS ${this.table} (
|
|
2
|
+
var u={default:"sqlite",connections:{},logging:!1,cacheTTL:0,maxCacheSize:1000},k={},C={},f=new Map,P=[];function z(t){u={...u,...t}}function V(){return{...u}}function G(){u={default:"sqlite",connections:{},logging:!1,cacheTTL:0,maxCacheSize:1000};for(let t of Object.keys(k))delete k[t];f.clear(),P.length=0}function X(t,e){k[t]=e}function g(t){let e=t||u.default;if(k[e])return k[e];let r=u.connections[e];if(!r)throw Error(`Database connection "${e}" not configured`);let s=N(r);return k[e]=s,s}function N(t){switch(t.driver){case"sqlite":return D(t);case"postgres":return S(t);case"mysql":return L(t);default:throw Error(`Unsupported database driver: ${t.driver}`)}}function D(t){let e=null,r=!1;return{async connect(){if(r)return;let{Database:s}=await import("bun:sqlite");e=new s(t.database,{create:!0,readwrite:!0}),r=!0},async disconnect(){if(e)e.close(),e=null,r=!1},async query(s,n=[]){if(!r)await this.connect();let i=performance.now();try{let o=e.prepare(s).all(...n);if(u.logging)y(s,n,performance.now()-i);return o}catch(a){throw new p(`Query failed: ${a}`,s,n)}},async insert(s,n=[]){if(!r)await this.connect();let i=performance.now();try{let o=e.prepare(s).run(...n);if(u.logging)y(s,n,performance.now()-i);return o.lastInsertRowid}catch(a){throw new p(`Insert failed: ${a}`,s,n)}},async execute(s,n=[]){if(!r)await this.connect();let i=performance.now();try{let o=e.prepare(s).run(...n);if(u.logging)y(s,n,performance.now()-i);return o.changes}catch(a){throw new p(`Execute failed: ${a}`,s,n)}},async beginTransaction(){if(!r)await this.connect();e.run("BEGIN TRANSACTION")},async commit(){e.run("COMMIT")},async rollback(){e.run("ROLLBACK")},isConnected(){return r}}}function S(t){let e=!1,r=null;return{async connect(){if(e)return;try{let{Client:s}=await import("pg");r=new s({host:t.host||"localhost",port:t.port||5432,database:t.database,user:t.username,password:t.password,ssl:t.ssl}),await r.connect(),e=!0}catch(s){throw Error(`PostgreSQL connection failed. Install 'pg' package: ${s}`)}},async disconnect(){if(r)await r.end(),r=null,e=!1},async query(s,n=[]){if(!e)await this.connect();let i=performance.now();try{let a=await r.query(s,n);if(u.logging)y(s,n,performance.now()-i);return a.rows}catch(a){throw new p(`Query failed: ${a}`,s,n)}},async insert(s,n=[]){if(!e)await this.connect();let i=performance.now();try{let a=await r.query(`${s} RETURNING id`,n);if(u.logging)y(s,n,performance.now()-i);return a.rows[0]?.id}catch(a){throw new p(`Insert failed: ${a}`,s,n)}},async execute(s,n=[]){if(!e)await this.connect();let i=performance.now();try{let a=await r.query(s,n);if(u.logging)y(s,n,performance.now()-i);return a.rowCount||0}catch(a){throw new p(`Execute failed: ${a}`,s,n)}},async beginTransaction(){if(!e)await this.connect();await r.query("BEGIN")},async commit(){await r.query("COMMIT")},async rollback(){await r.query("ROLLBACK")},isConnected(){return e}}}function L(t){let e=!1,r=null;return{async connect(){if(e)return;try{let s=await import("mysql2/promise");r=s.createPool({host:t.host||"localhost",port:t.port||3306,database:t.database,user:t.username,password:t.password,waitForConnections:!0,connectionLimit:t.poolSize||10,queueLimit:0}),e=!0}catch(s){throw Error(`MySQL connection failed. Install 'mysql2' package: ${s}`)}},async disconnect(){if(r)await r.end(),r=null,e=!1},async query(s,n=[]){if(!e)await this.connect();let i=performance.now();try{let[a]=await r.execute(s,n);if(u.logging)y(s,n,performance.now()-i);return a}catch(a){throw new p(`Query failed: ${a}`,s,n)}},async insert(s,n=[]){if(!e)await this.connect();let i=performance.now();try{let[a]=await r.execute(s,n);if(u.logging)y(s,n,performance.now()-i);return a.insertId}catch(a){throw new p(`Insert failed: ${a}`,s,n)}},async execute(s,n=[]){if(!e)await this.connect();let i=performance.now();try{let[a]=await r.execute(s,n);if(u.logging)y(s,n,performance.now()-i);return a.affectedRows||0}catch(a){throw new p(`Execute failed: ${a}`,s,n)}},async beginTransaction(){if(!e)await this.connect();let s=await r.getConnection();return await s.beginTransaction(),s},async commit(){await r.execute("COMMIT")},async rollback(){await r.execute("ROLLBACK")},isConnected(){return e}}}class x{_table="";_columns=["*"];_wheres=[];_orders=[];_joins=[];_groupBy=[];_having=[];_limit;_offset;_distinct=!1;_connection;_bindings=[];_modelDefinition;constructor(t){if(t)this._table=t}table(t){return this._table=t,this}from(t){return this.table(t)}connection(t){return this._connection=t,this}select(...t){return this._columns=t.length>0?t:["*"],this}addSelect(...t){if(this._columns[0]==="*")this._columns=t;else this._columns.push(...t);return this}distinct(){return this._distinct=!0,this}where(t,e,r){let s="=",n=e;if(r!==void 0)s=e,n=r;return this._wheres.push({column:t,operator:s,value:n,boolean:"and"}),this}orWhere(t,e,r){let s="=",n=e;if(r!==void 0)s=e,n=r;return this._wheres.push({column:t,operator:s,value:n,boolean:"or"}),this}whereIn(t,e){return this._wheres.push({column:t,operator:"in",value:e,boolean:"and"}),this}whereNotIn(t,e){return this._wheres.push({column:t,operator:"not in",value:e,boolean:"and"}),this}whereNull(t){return this._wheres.push({column:t,operator:"is null",value:null,boolean:"and"}),this}whereNotNull(t){return this._wheres.push({column:t,operator:"is not null",value:null,boolean:"and"}),this}whereBetween(t,e,r){return this._wheres.push({column:t,operator:"between",value:[e,r],boolean:"and"}),this}whereLike(t,e){return this._wheres.push({column:t,operator:"like",value:e,boolean:"and"}),this}join(t,e,r,s){return this._joins.push({type:"inner",table:t,first:e,operator:r,second:s}),this}leftJoin(t,e,r,s){return this._joins.push({type:"left",table:t,first:e,operator:r,second:s}),this}rightJoin(t,e,r,s){return this._joins.push({type:"right",table:t,first:e,operator:r,second:s}),this}orderBy(t,e="asc"){return this._orders.push({column:t,direction:e}),this}orderByDesc(t){return this.orderBy(t,"desc")}groupBy(...t){return this._groupBy.push(...t),this}having(t,e,r){return this._having.push({column:t,operator:e,value:r,boolean:"and"}),this}limit(t){return this._limit=t,this}take(t){return this.limit(t)}offset(t){return this._offset=t,this}skip(t){return this.offset(t)}forPage(t,e=15){return this.offset((t-1)*e).limit(e)}async get(){let{sql:t,bindings:e}=this.toSql();if(u.cacheTTL&&u.cacheTTL>0){let n=this.getCacheKey(t,e),i=Q(n);if(i!==void 0)return i}let s=await g(this._connection).query(t,e);if(u.cacheTTL&&u.cacheTTL>0){let n=this.getCacheKey(t,e);B(n,s,u.cacheTTL)}return s}async first(){return(await this.limit(1).get())[0]||null}async firstOrFail(){let t=await this.first();if(!t)throw Error("No results found");return t}async find(t,e="id"){return this.where(e,t).first()}async value(t){let e=await this.select(t).first();return e?e[t]:null}async pluck(t){return(await this.select(t).get()).map((r)=>r[t])}async exists(){return(await this.select(_("1")).limit(1).get()).length>0}async doesntExist(){return!await this.exists()}async count(t="*"){let e=await this.select(_(`COUNT(${t}) as count`)).first();return Number(e?.count||0)}async max(t){return(await this.select(_(`MAX(${t}) as max`)).first())?.max}async min(t){return(await this.select(_(`MIN(${t}) as min`)).first())?.min}async sum(t){let e=await this.select(_(`SUM(${t}) as sum`)).first();return Number(e?.sum||0)}async avg(t){return(await this.select(_(`AVG(${t}) as avg`)).first())?.avg}async insert(t){let e=Object.keys(t),r=e.map(()=>"?").join(", "),s=Object.values(t),n=`INSERT INTO ${this._table} (${e.join(", ")}) VALUES (${r})`,i=g(this._connection);return T(this._table),i.insert(n,s)}async insertAll(t){if(t.length===0)return;let e=Object.keys(t[0]),r=t.map(()=>`(${e.map(()=>"?").join(", ")})`).join(", "),s=t.flatMap((a)=>Object.values(a)),n=`INSERT INTO ${this._table} (${e.join(", ")}) VALUES ${r}`,i=g(this._connection);T(this._table),await i.execute(n,s)}async update(t){this._bindings=[];let e=this.buildWhereClause(),r=[...this._bindings],s=Object.keys(t).map((o)=>`${o} = ?`).join(", "),n=[...Object.values(t),...r],i=`UPDATE ${this._table} SET ${s}${e}`,a=g(this._connection);return T(this._table),a.execute(i,n)}async increment(t,e=1){this._bindings=[];let r=this.buildWhereClause(),s=`UPDATE ${this._table} SET ${t} = ${t} + ?${r}`,n=g(this._connection);return T(this._table),n.execute(s,[e,...this._bindings])}async decrement(t,e=1){return this.increment(t,-e)}async delete(){this._bindings=[];let t=this.buildWhereClause(),e=`DELETE FROM ${this._table}${t}`,r=g(this._connection);return T(this._table),r.execute(e,this._bindings)}async truncate(){let t=g(this._connection);T(this._table),await t.execute(`DELETE FROM ${this._table}`)}toSql(){this._bindings=[];let t="SELECT ";if(this._distinct)t+="DISTINCT ";t+=this._columns.map((e)=>{if(typeof e==="object"&&e.__raw)return e.sql;return e}).join(", "),t+=` FROM ${this._table}`;for(let e of this._joins)t+=` ${e.type.toUpperCase()} JOIN ${e.table} ON ${e.first} ${e.operator} ${e.second}`;if(t+=this.buildWhereClause(),this._groupBy.length>0)t+=` GROUP BY ${this._groupBy.join(", ")}`;if(this._having.length>0){let e=this._having.map((r,s)=>{let n=s===0?"":` ${r.boolean.toUpperCase()} `;return this._bindings.push(r.value),`${n}${r.column} ${r.operator} ?`});t+=` HAVING ${e.join("")}`}if(this._orders.length>0)t+=` ORDER BY ${this._orders.map((e)=>`${e.column} ${e.direction.toUpperCase()}`).join(", ")}`;if(this._limit!==void 0)t+=` LIMIT ${this._limit}`;if(this._offset!==void 0)t+=` OFFSET ${this._offset}`;return{sql:t,bindings:this._bindings}}buildWhereClause(){if(this._wheres.length===0)return"";return this._wheres.map((e,r)=>{let s=r===0?" WHERE ":` ${e.boolean.toUpperCase()} `;switch(e.operator){case"in":{let n=e.value,i=n.map(()=>"?").join(", ");return this._bindings.push(...n),`${s}${e.column} IN (${i})`}case"not in":{let n=e.value,i=n.map(()=>"?").join(", ");return this._bindings.push(...n),`${s}${e.column} NOT IN (${i})`}case"between":{let[n,i]=e.value;return this._bindings.push(n,i),`${s}${e.column} BETWEEN ? AND ?`}case"is null":return`${s}${e.column} IS NULL`;case"is not null":return`${s}${e.column} IS NOT NULL`;default:return this._bindings.push(e.value),`${s}${e.column} ${e.operator} ?`}}).join("")}getCacheKey(t,e){return`${this._table}:${t}:${JSON.stringify(e)}`}clone(){let t=new x(this._table);return t._columns=[...this._columns],t._wheres=[...this._wheres],t._orders=[...this._orders],t._joins=[...this._joins],t._groupBy=[...this._groupBy],t._having=[...this._having],t._limit=this._limit,t._offset=this._offset,t._distinct=this._distinct,t._connection=this._connection,t}}function l(t){return new x(t)}function Y(t){return l(t)}function _(t,e=[]){return{__raw:!0,sql:t,bindings:e}}function H(t,e){let r=e.primaryKey||"id",s={name:t,definition:e,async find(n){let i=await l(e.table).where(r,n).first();return i?b(s,i):null},async findOrFail(n){let i=await this.find(n);if(!i)throw Error(`${t} not found with ${r} = ${n}`);return i},async all(){return(await l(e.table).get()).map((i)=>b(s,i))},async create(n){let i={...e.defaults,...n},a=e.fillable?Object.fromEntries(Object.entries(i).filter(([c])=>e.fillable.includes(c))):i;if(e.timestamps!==!1){let c=new Date().toISOString(),h=typeof e.timestamps==="object"?e.timestamps.createdAt||"created_at":"created_at",m=typeof e.timestamps==="object"?e.timestamps.updatedAt||"updated_at":"updated_at";a[h]=c,a[m]=c}let o=await l(e.table).insert(a);return this.findOrFail(o)},async update(n){return l(e.table).update(n)},async destroy(n){let i=Array.isArray(n)?n:[n];return l(e.table).whereIn(r,i).delete()},query(){return l(e.table)},where(n,i,a){return this.query().where(n,i,a)},async first(){let n=await this.query().first();return n?b(s,n):null},async get(){return(await this.query().get()).map((i)=>b(s,i))},async count(){return this.query().count()}};return C[t]=s,s}function v(t){let e=C[t];if(!e)throw Error(`Model "${t}" not defined. Use defineModel() first.`);return e}function Z(t){return t in C}function b(t,e){let{definition:r}=t,s=r.primaryKey||"id",n={...e},i={...e};if(r.casts){for(let[o,c]of Object.entries(r.casts))if(o in i)i[o]=q(i[o],c)}let a={exists:!0,original:n,attributes:i,get(o){return i[o]},set(o,c){i[o]=c},toJSON(){let o={...i};if(r.hidden)for(let c of r.hidden)delete o[c];return o},async save(){let o={};for(let c of Object.keys(i))if(i[c]!==n[c])o[c]=i[c];if(Object.keys(o).length>0){if(r.timestamps!==!1){let c=typeof r.timestamps==="object"?r.timestamps.updatedAt||"updated_at":"updated_at";o[c]=new Date().toISOString()}await l(r.table).where(s,n[s]).update(o),Object.assign(n,o)}},async delete(){if(r.softDeletes){let o=typeof r.softDeletes==="string"?r.softDeletes:"deleted_at";await l(r.table).where(s,n[s]).update({[o]:new Date().toISOString()})}else await l(r.table).where(s,n[s]).delete();a.exists=!1},async refresh(){let o=await l(r.table).where(s,n[s]).first();if(o)Object.assign(n,o),Object.assign(i,o)},isDirty(o){if(o)return i[o]!==n[o];return Object.keys(i).some((c)=>i[c]!==n[c])}};if(r.relationships)for(let[o,c]of Object.entries(r.relationships))Object.defineProperty(a,o,{value:async()=>j(a,c,t),enumerable:!1});return new Proxy(a,{get(o,c){if(c in o)return o[c];return i[c]},set(o,c,h){if(c in o)o[c]=h;else i[c]=h;return!0}})}async function j(t,e,r){let s=v(e.model),n=r.definition.primaryKey||"id";switch(e.type){case"hasOne":{let i=e.foreignKey||`${r.name.toLowerCase()}_id`,a=await l(s.definition.table).where(i,t.get(n)).first();return a?b(s,a):null}case"hasMany":{let i=e.foreignKey||`${r.name.toLowerCase()}_id`;return(await l(s.definition.table).where(i,t.get(n)).get()).map((o)=>b(s,o))}case"belongsTo":{let i=e.foreignKey||`${e.model.toLowerCase()}_id`,a=e.localKey||"id",o=await l(s.definition.table).where(a,t.get(i)).first();return o?b(s,o):null}case"belongsToMany":{let i=e.pivotTable||[r.name,e.model].sort().join("_").toLowerCase(),a=e.pivotForeignKey||`${r.name.toLowerCase()}_id`,o=e.pivotRelatedKey||`${e.model.toLowerCase()}_id`,c=s.definition.primaryKey||"id";return(await l(s.definition.table).join(i,`${s.definition.table}.${c}`,"=",`${i}.${o}`).where(`${i}.${a}`,t.get(n)).get()).map((m)=>b(s,m))}default:return null}}function q(t,e){if(t===null||t===void 0)return t;switch(e){case"string":return String(t);case"number":return Number(t);case"boolean":return Boolean(t);case"date":return new Date(t);case"json":case"array":return typeof t==="string"?JSON.parse(t):t;default:return t}}async function tt(t,e){let r=g(e);await r.beginTransaction();try{let s=await t();return await r.commit(),s}catch(s){throw await r.rollback(),s}}function Q(t){let e=f.get(t);if(!e)return;if(Date.now()-e.timestamp>e.ttl*1000){f.delete(t);return}return e.result}function B(t,e,r){if(f.size>=(u.maxCacheSize||1000)){let s=f.keys().next().value;if(s)f.delete(s)}f.set(t,{result:e,timestamp:Date.now(),ttl:r})}function T(t){for(let e of f.keys())if(e.startsWith(`${t}:`))f.delete(e)}function et(){f.clear()}function nt(){return{size:f.size,keys:[...f.keys()]}}function y(t,e,r){if(P.push({sql:t,bindings:e,duration:r,timestamp:new Date}),P.length>1000)P.shift()}function rt(){return[...P]}function st(){P.length=0}function it(t=!0){u.logging=t}class p extends Error{sql;bindings;constructor(t,e,r){super(t);this.sql=e;this.bindings=r;this.name="DatabaseError"}}async function K(t,e,r,s){let n=/@db\(\s*['"]([^'"]+)['"]\s*\)((?:->\w+\([^)]*\))*)/g,i=t,a=[...t.matchAll(n)];for(let o of a){let[c,h,m]=o;try{let d=await W(h,m),w=`$${h}`;e[w]=d,i=i.replace(c,"")}catch(d){i=i.replace(c,`<!-- DB Error: ${d instanceof Error?d.message:String(d)} -->`)}}return i}async function U(t,e,r,s){let n=/@model\(\s*['"]([^'"]+)['"]\s*\)((?:->\w+\([^)]*\))*)/g,i=t,a=[...t.matchAll(n)];for(let o of a){let[c,h,m]=o;try{let d=v(h),w=await J(d,m),E=`$${h.toLowerCase()}`;e[E]=w,i=i.replace(c,"")}catch(d){i=i.replace(c,`<!-- Model Error: ${d instanceof Error?d.message:String(d)} -->`)}}return i}async function F(t,e,r,s){let n=/@query\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\[[^\]]*\]))?\s*\)\s*as\s+\$(\w+)/g,i=t,a=[...t.matchAll(n)];for(let o of a){let[c,h,m,d]=o;try{let w=m?JSON.parse(m):[],A=await g().query(h,w);e[`$${d}`]=A,i=i.replace(c,"")}catch(w){i=i.replace(c,`<!-- Query Error: ${w instanceof Error?w.message:String(w)} -->`)}}return i}async function W(t,e){let r=l(t),s=/->(\w+)\(([^)]*)\)/g,n=[...e.matchAll(s)],i=r;for(let[,a,o]of n){let c=O(o);if(typeof i[a]==="function"){if(i=i[a](...c),i instanceof Promise){i=await i;break}}}if(i instanceof x)i=await i.get();return i}async function J(t,e){let r=/->(\w+)\(([^)]*)\)/g,s=[...e.matchAll(r)],n=t;for(let[,i,a]of s){let o=O(a);if(typeof n[i]==="function"){if(n=n[i](...o),n instanceof Promise)n=await n}else if(n instanceof x){if(typeof n[i]==="function"){if(n=n[i](...o),n instanceof Promise)n=await n}}}if(n instanceof x)n=await n.get();return n}function O(t){if(!t.trim())return[];let e=[],r="",s=0,n=!1,i="";for(let a=0;a<t.length;a++){let o=t[a];if(!n&&(o==='"'||o==="'"))n=!0,i=o,r+=o;else if(n&&o===i)n=!1,r+=o;else if(!n&&(o==="["||o==="{"||o==="("))s++,r+=o;else if(!n&&(o==="]"||o==="}"||o===")"))s--,r+=o;else if(!n&&s===0&&o===",")e.push(R(r.trim())),r="";else r+=o}if(r.trim())e.push(R(r.trim()));return e}function R(t){if(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1);if(t==="true")return!0;if(t==="false")return!1;if(t==="null")return null;let e=Number(t);if(!Number.isNaN(e))return e;try{return JSON.parse(t)}catch{return t}}async function ot(t,e,r,s){let n=t;return n=await F(n,e,r,s),n=await U(n,e,r,s),n=await K(n,e,r,s),n}class I{_connection;connection(t){return this._connection=t,this}async create(t,e){let r=new M(t);e(r);let s=r.toCreateSQL();await g(this._connection).execute(s)}async drop(t){await g(this._connection).execute(`DROP TABLE IF EXISTS ${t}`)}async rename(t,e){await g(this._connection).execute(`ALTER TABLE ${t} RENAME TO ${e}`)}async hasTable(t){let e=g(this._connection);try{return await e.query(`SELECT 1 FROM ${t} LIMIT 1`),!0}catch{return!1}}}class M{table;columns=[];indices=[];constructor(t){this.table=t}id(t="id"){return this.columns.push(`${t} INTEGER PRIMARY KEY AUTOINCREMENT`),this}string(t,e=255){return this.columns.push(`${t} VARCHAR(${e})`),this}text(t){return this.columns.push(`${t} TEXT`),this}integer(t){return this.columns.push(`${t} INTEGER`),this}boolean(t){return this.columns.push(`${t} BOOLEAN DEFAULT 0`),this}datetime(t){return this.columns.push(`${t} DATETIME`),this}timestamps(){return this.columns.push("created_at DATETIME DEFAULT CURRENT_TIMESTAMP"),this.columns.push("updated_at DATETIME DEFAULT CURRENT_TIMESTAMP"),this}softDeletes(){return this.columns.push("deleted_at DATETIME"),this}json(t){return this.columns.push(`${t} TEXT`),this}foreignId(t){return this.columns.push(`${t} INTEGER`),this}index(t){let e=Array.isArray(t)?t:[t],r=`idx_${this.table}_${e.join("_")}`;return this.indices.push(`CREATE INDEX ${r} ON ${this.table} (${e.join(", ")})`),this}unique(t){let e=Array.isArray(t)?t:[t],r=`uniq_${this.table}_${e.join("_")}`;return this.indices.push(`CREATE UNIQUE INDEX ${r} ON ${this.table} (${e.join(", ")})`),this}toCreateSQL(){return`CREATE TABLE IF NOT EXISTS ${this.table} (
|
|
3
3
|
${this.columns.join(`,
|
|
4
4
|
`)}
|
|
5
|
-
)`}getIndexSQL(){return this.indices}}function
|
|
5
|
+
)`}getIndexSQL(){return this.indices}}function at(){return new I}export{M as Blueprint,p as DatabaseError,x as QueryBuilder,I as SchemaBuilder,et as clearQueryCache,st as clearQueryLog,z as configureDatabase,H as defineModel,it as enableQueryLogging,g as getAdapter,V as getDatabaseConfig,v as getModel,nt as getQueryCacheStats,rt as getQueryLog,Z as hasModel,ot as processDatabaseDirectives,K as processDbDirective,U as processModelDirective,F as processQueryDirective,l as query,_ as raw,X as registerAdapter,G as resetDatabaseConfig,at as schema,Y as table,tt as transaction};
|
|
@@ -25,7 +25,7 @@ export function renderImageComponent(props, context = {}) {
|
|
|
25
25
|
fetchpriority,
|
|
26
26
|
objectFit,
|
|
27
27
|
objectPosition
|
|
28
|
-
} = props,
|
|
28
|
+
} = props, { class: className, style } = props, { processedImage, variants, optimize = !0, isDev = !1 } = context;
|
|
29
29
|
if (variants && variants.length > 0)
|
|
30
30
|
return renderPicture(props, variants, processedImage);
|
|
31
31
|
if (isDev || !optimize)
|
|
@@ -46,7 +46,7 @@ function renderPicture(props, variants, processedImage) {
|
|
|
46
46
|
objectFit,
|
|
47
47
|
objectPosition,
|
|
48
48
|
placeholder = "none"
|
|
49
|
-
} = props,
|
|
49
|
+
} = props, { class: className, style } = props, grouped = groupVariantsByFormat(variants), fallback = getFallbackVariant(variants), sizesAttr = typeof sizes === "object" ? generateSizes(sizes) : sizes, aspectRatio = processedImage ? processedImage.aspectRatio : width && height ? Number(width) / Number(height) : void 0, styleAttrs = [];
|
|
50
50
|
if (aspectRatio)
|
|
51
51
|
styleAttrs.push(`aspect-ratio: ${aspectRatio}`);
|
|
52
52
|
if (objectFit)
|
|
@@ -117,7 +117,7 @@ function renderSimpleImg(props) {
|
|
|
117
117
|
fetchpriority,
|
|
118
118
|
objectFit,
|
|
119
119
|
objectPosition
|
|
120
|
-
} = props,
|
|
120
|
+
} = props, { class: className, style } = props, styleAttrs = [];
|
|
121
121
|
if (objectFit)
|
|
122
122
|
styleAttrs.push(`object-fit: ${objectFit}`);
|
|
123
123
|
if (objectPosition)
|
|
@@ -143,7 +143,7 @@ function renderPlaceholder(props) {
|
|
|
143
143
|
fetchpriority,
|
|
144
144
|
objectFit,
|
|
145
145
|
objectPosition
|
|
146
|
-
} = props,
|
|
146
|
+
} = props, { class: className, style } = props, styleAttrs = [];
|
|
147
147
|
if (objectFit)
|
|
148
148
|
styleAttrs.push(`object-fit: ${objectFit}`);
|
|
149
149
|
if (objectPosition)
|
package/dist/index.d.ts
CHANGED
|
@@ -133,8 +133,10 @@ export {
|
|
|
133
133
|
} from './builtins/image-placeholder';
|
|
134
134
|
export {
|
|
135
135
|
clearImageDeliveryCatalog,
|
|
136
|
+
deliveredImage,
|
|
136
137
|
getImageDelivery,
|
|
137
138
|
prepareImageDelivery,
|
|
139
|
+
type DeliveredImage,
|
|
138
140
|
} from './builtins/image-delivery';
|
|
139
141
|
// Core functionality - these are the primary modules
|
|
140
142
|
export * from './reactivity';
|
package/dist/index.js
CHANGED
|
@@ -58,7 +58,7 @@ export async function renderImgComponent(props, context = {}) {
|
|
|
58
58
|
objectPosition,
|
|
59
59
|
crossorigin,
|
|
60
60
|
referrerpolicy
|
|
61
|
-
} = props,
|
|
61
|
+
} = props, { class: className, style, id } = props, dataAttrs = props.data || {}, { isDev = !1, baseUrl = "" } = context;
|
|
62
62
|
if (isDev && !context.optimize)
|
|
63
63
|
return renderSimpleImg(props);
|
|
64
64
|
let placeholder, placeholderCss;
|
|
@@ -118,7 +118,7 @@ async function renderPictureElement(props, componentId, placeholder, context) {
|
|
|
118
118
|
objectPosition,
|
|
119
119
|
crossorigin,
|
|
120
120
|
referrerpolicy
|
|
121
|
-
} = props,
|
|
121
|
+
} = props, { class: className, style } = props, dataAttrs = props.data || {}, sizesAttr = typeof sizes === "object" ? generateSizesAttribute(sizes) : sizes || "100vw", sources = [];
|
|
122
122
|
for (const format of formats) {
|
|
123
123
|
const srcset = generateWidthSrcset(src, widths, { ...params, q: quality }, format), mimeType = getMimeType(format);
|
|
124
124
|
if (lazy && !priority)
|
|
@@ -179,7 +179,7 @@ function renderDprBasedImg(props, componentId, placeholder, context) {
|
|
|
179
179
|
objectPosition,
|
|
180
180
|
crossorigin,
|
|
181
181
|
referrerpolicy
|
|
182
|
-
} = props,
|
|
182
|
+
} = props, { class: className, style } = props, dataAttrs = props.data || {}, numericWidth = typeof width === "number" ? width : Number.parseInt(String(width), 10), srcset = generateDprSrcset(src, numericWidth, dpr, { ...params, q: quality }), imgAttrs = buildImgAttributes({
|
|
183
183
|
src: buildImageUrl(src, { ...params, w: numericWidth, q: quality }),
|
|
184
184
|
alt,
|
|
185
185
|
width,
|
|
@@ -218,7 +218,7 @@ function renderSimpleImg(props) {
|
|
|
218
218
|
crossorigin,
|
|
219
219
|
referrerpolicy,
|
|
220
220
|
priority = !1
|
|
221
|
-
} = props,
|
|
221
|
+
} = props, { class: className, style, id } = props, dataAttrs = props.data || {};
|
|
222
222
|
return {
|
|
223
223
|
html: `<img ${buildImgAttributes({
|
|
224
224
|
src,
|
|
@@ -462,7 +462,7 @@ async function renderFromProcessedResult(props, processed, context) {
|
|
|
462
462
|
objectPosition,
|
|
463
463
|
crossorigin,
|
|
464
464
|
referrerpolicy
|
|
465
|
-
} = props,
|
|
465
|
+
} = props, { class: className, style } = props, id = props.id || `stx-img-${Math.random().toString(36).slice(2, 8)}`, dataAttrs = props.data || {}, variants = processed.variants || [], fallbackVariant = variants.find((v) => v.format === "jpeg") || variants.find((v) => v.format === "webp") || variants[0], fallbackSrc = fallbackVariant?.url || props.src, srcset = variants.filter((v) => v.format === (fallbackVariant?.format || "jpeg")).map((v) => `${v.url} ${v.width}w`).join(", "), formatGroups = new Map;
|
|
466
466
|
for (const variant of variants) {
|
|
467
467
|
if (!formatGroups.has(variant.format))
|
|
468
468
|
formatGroups.set(variant.format, []);
|
|
@@ -14,7 +14,7 @@ export async function renderProtectedImg(props) {
|
|
|
14
14
|
auth,
|
|
15
15
|
fallback,
|
|
16
16
|
oneTimeUse = !0
|
|
17
|
-
} = props,
|
|
17
|
+
} = props, { class: className, style } = props;
|
|
18
18
|
if (auth) {
|
|
19
19
|
if (!await checkAuthAccess(auth)) {
|
|
20
20
|
if (fallback)
|
|
@@ -76,7 +76,7 @@ export async function renderProtectedVideo(props) {
|
|
|
76
76
|
autoplay = !1,
|
|
77
77
|
muted = !1,
|
|
78
78
|
loop = !1
|
|
79
|
-
} = props,
|
|
79
|
+
} = props, { class: className, style, alt } = props;
|
|
80
80
|
if (auth) {
|
|
81
81
|
if (!await checkAuthAccess(auth))
|
|
82
82
|
return {
|
|
@@ -41,7 +41,7 @@ export async function renderVideoComponent(props, context = {}) {
|
|
|
41
41
|
crossorigin,
|
|
42
42
|
disablePictureInPicture = !1,
|
|
43
43
|
disableRemotePlayback = !1
|
|
44
|
-
} = props, poster = generatedPoster || originalPoster,
|
|
44
|
+
} = props, poster = generatedPoster || originalPoster, { class: className, style } = props, id = props.id || `stx-video-${Math.random().toString(36).slice(2, 8)}`;
|
|
45
45
|
if (player === "ts-video")
|
|
46
46
|
return renderTsVideoPlayer(props, context);
|
|
47
47
|
if (embedType && embedType !== "video")
|
|
@@ -130,7 +130,7 @@ ${sourceTags}
|
|
|
130
130
|
return { html, script };
|
|
131
131
|
}
|
|
132
132
|
function renderEmbed(url, type, props) {
|
|
133
|
-
const { width = 640, height = 360 } = props,
|
|
133
|
+
const { width = 640, height = 360 } = props, { class: className, style } = props, id = props.id || `stx-embed-${Math.random().toString(36).slice(2, 8)}`;
|
|
134
134
|
let embedUrl, videoId = null;
|
|
135
135
|
switch (type) {
|
|
136
136
|
case "youtube":
|
|
@@ -185,7 +185,7 @@ function renderTsVideoPlayer(props, context = {}) {
|
|
|
185
185
|
lazy = !0,
|
|
186
186
|
width,
|
|
187
187
|
height
|
|
188
|
-
} = props,
|
|
188
|
+
} = props, { class: className, style } = props, id = props.id || `ts-video-${Math.random().toString(36).slice(2, 8)}`, playerConfig = {
|
|
189
189
|
src: sources.length > 0 ? sources : src,
|
|
190
190
|
autoplay,
|
|
191
191
|
loop,
|
|
@@ -467,7 +467,7 @@ function renderFromProcessedResult(props, processed, context) {
|
|
|
467
467
|
crossorigin,
|
|
468
468
|
disablePictureInPicture = !1,
|
|
469
469
|
disableRemotePlayback = !1
|
|
470
|
-
} = props,
|
|
470
|
+
} = props, { class: className, style } = props, id = props.id || `stx-video-${Math.random().toString(36).slice(2, 8)}`;
|
|
471
471
|
let videoSrc = props.src, mimeType = detectMimeType(videoSrc);
|
|
472
472
|
if (processed.transcoded) {
|
|
473
473
|
videoSrc = processed.transcoded.url;
|