@stacksjs/stx 0.2.673 → 0.2.674
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-0jwdcqj8.js +2 -0
- package/dist/chunk-0mwdq478.js +2 -0
- package/dist/{chunk-npa7gze7.js → chunk-0nfqgv4n.js} +2 -2
- package/dist/chunk-1y6egkty.js +2 -0
- package/dist/{chunk-1sr6c0nk.js → chunk-25zmy8q6.js} +2 -2
- package/dist/chunk-2881tcqt.js +2 -0
- package/dist/chunk-2a775q7x.js +2 -0
- package/dist/chunk-2asdbd5e.js +2 -0
- package/dist/chunk-34yj93hh.js +2 -0
- package/dist/{chunk-30nes8ne.js → chunk-35ezh7de.js} +2 -2
- package/dist/{chunk-9tdnfztv.js → chunk-40tswfe7.js} +8 -8
- package/dist/chunk-41de209e.js +2 -0
- package/dist/{chunk-jst1fbdm.js → chunk-4b9s7wgy.js} +2 -2
- package/dist/{chunk-vhs13kbf.js → chunk-4bgjrrvz.js} +1 -1
- package/dist/{chunk-365vg0eg.js → chunk-4s8zacxg.js} +4 -4
- package/dist/chunk-4w6baw62.js +3 -0
- package/dist/{chunk-fbtv2k1p.js → chunk-506mv7hb.js} +2 -2
- package/dist/{chunk-fzqj1mjz.js → chunk-5qtthtg3.js} +7 -7
- package/dist/chunk-5s1ay9mv.js +2 -0
- package/dist/{chunk-wns8g6k9.js → chunk-5vt48yce.js} +6 -6
- package/dist/{chunk-qv6axke4.js → chunk-5zhp87wv.js} +2 -2
- package/dist/{chunk-hvf2e7pr.js → chunk-6s7tvmqp.js} +1 -1
- package/dist/{chunk-ecqrkyg8.js → chunk-6sjtyd0k.js} +4 -4
- package/dist/{chunk-a3d0g4mr.js → chunk-7adznted.js} +2 -2
- package/dist/chunk-7j1zgrnf.js +42 -0
- package/dist/chunk-7kznee1g.js +2 -0
- package/dist/{chunk-qjtpxsyx.js → chunk-7mvz972c.js} +3 -3
- package/dist/chunk-80zgyaqe.js +2 -0
- package/dist/chunk-84tqb1rn.js +2 -0
- package/dist/chunk-8azm7nha.js +2 -0
- package/dist/chunk-902qnyg0.js +2 -0
- package/dist/{chunk-3y41efsf.js → chunk-9dtbvjpp.js} +8 -8
- package/dist/chunk-9n6jwcpb.js +2 -0
- package/dist/{chunk-yfvm7q6t.js → chunk-a4p18ybc.js} +3 -3
- package/dist/chunk-a6y8td0d.js +2 -0
- package/dist/chunk-a7kt1ts4.js +2 -0
- package/dist/chunk-a81y8g40.js +2 -0
- package/dist/{chunk-jg5zt20a.js → chunk-aet1pgw7.js} +36 -36
- package/dist/chunk-aft1zc84.js +2 -0
- package/dist/{chunk-04kg16qs.js → chunk-am2w363p.js} +4 -4
- package/dist/{chunk-ym41ybz2.js → chunk-asezs2n3.js} +6 -6
- package/dist/{chunk-jefe0rgt.js → chunk-bawq4fqy.js} +4 -4
- package/dist/chunk-bdp2r0v4.js +2 -0
- package/dist/{chunk-m6q3f5rf.js → chunk-bkkpq8dx.js} +9 -9
- package/dist/chunk-brtvm8mb.js +2 -0
- package/dist/{chunk-2dp7hyv7.js → chunk-bsajk82t.js} +14 -14
- package/dist/chunk-bvzr9zqt.js +2 -0
- package/dist/{chunk-hzv2qj0t.js → chunk-cbjabv1w.js} +4 -4
- package/dist/chunk-cbvgtf3m.js +2 -0
- package/dist/chunk-cfydbaeq.js +2 -0
- package/dist/{chunk-t2pzy3x1.js → chunk-ck2e3e47.js} +3 -3
- package/dist/{chunk-wpmrz872.js → chunk-d09q93yf.js} +2 -2
- package/dist/{chunk-rcsgt4wy.js → chunk-d1a86qx8.js} +1 -1
- package/dist/{chunk-xqp4hstk.js → chunk-dgc1a3yt.js} +6 -6
- package/dist/chunk-dq8c3h4n.js +2 -0
- package/dist/chunk-e36pne7n.js +2 -0
- package/dist/chunk-e62qfexp.js +2 -0
- package/dist/chunk-eq5jzaj5.js +2 -0
- package/dist/{chunk-t0zh1dn9.js → chunk-f9zyf9n6.js} +65 -65
- package/dist/{chunk-dgb4z4kw.js → chunk-faakv1p6.js} +2 -2
- package/dist/{chunk-ynz7bzc6.js → chunk-fb7t1nn9.js} +3 -3
- package/dist/{chunk-ptcj11b4.js → chunk-fbmth6xv.js} +10 -10
- package/dist/{chunk-7met6yva.js → chunk-fd49fahd.js} +5 -5
- package/dist/chunk-fr39emcz.js +2 -0
- package/dist/chunk-fsq13amm.js +2 -0
- package/dist/chunk-fw413k9q.js +3 -0
- package/dist/chunk-fxh12vqd.js +2 -0
- package/dist/chunk-gcc9fa33.js +2 -0
- package/dist/chunk-h6t2ney6.js +2 -0
- package/dist/{chunk-kgfgb971.js → chunk-ham5x7ts.js} +4 -4
- package/dist/{chunk-n38yb274.js → chunk-hb3edeq9.js} +6 -6
- package/dist/{chunk-fvtwec1r.js → chunk-hegfgw27.js} +1 -1
- package/dist/{chunk-p472crv1.js → chunk-hgry3mjd.js} +1 -1
- package/dist/{chunk-sfc2v7rt.js → chunk-hsmcbh0p.js} +7 -7
- package/dist/{chunk-mxbc2ahy.js → chunk-hz4x7h0n.js} +5 -5
- package/dist/{chunk-jxda11cg.js → chunk-j6m8xqh3.js} +2 -2
- package/dist/chunk-j8g5cvvm.js +2 -0
- package/dist/chunk-jzjpyyw2.js +2 -0
- package/dist/chunk-k1b8x73j.js +2 -0
- package/dist/{chunk-h4dkvnhd.js → chunk-kdebh22m.js} +7 -7
- package/dist/{chunk-xwhmh0w0.js → chunk-mwnhdsbp.js} +2 -2
- package/dist/{chunk-0f4csefs.js → chunk-nj343mw2.js} +5 -5
- package/dist/chunk-nw9bdk2n.js +2 -0
- package/dist/chunk-p4jkswz8.js +2 -0
- package/dist/chunk-p4r90vqf.js +2 -0
- package/dist/{chunk-bnn7pd62.js → chunk-p6qd7ad0.js} +2 -2
- package/dist/chunk-p8bgy5tt.js +2 -0
- package/dist/{chunk-aprhqxky.js → chunk-pb6erpj3.js} +5 -5
- package/dist/{chunk-r3e6x87d.js → chunk-pg2v1pb5.js} +3 -3
- package/dist/{chunk-zvygkwyf.js → chunk-pqqe2b6m.js} +4 -4
- package/dist/chunk-q6nwcav4.js +2 -0
- package/dist/chunk-qmqavdz2.js +2 -0
- package/dist/chunk-qpw72bty.js +2 -0
- package/dist/chunk-qwnh1kj6.js +2 -0
- package/dist/chunk-qy9m6qdn.js +2 -0
- package/dist/chunk-qychcdsm.js +2 -0
- package/dist/{chunk-7d4z944r.js → chunk-qz5b8ed4.js} +7 -7
- package/dist/{chunk-6ajahb2x.js → chunk-r7fdw2v5.js} +3 -3
- package/dist/{chunk-mmwedr93.js → chunk-rdr09efy.js} +5 -5
- package/dist/chunk-rj3w1ama.js +2 -0
- package/dist/{chunk-prf164ct.js → chunk-rr527jt6.js} +2 -2
- package/dist/{chunk-1fd7x7b8.js → chunk-rv39s5az.js} +4 -4
- package/dist/{chunk-yg267y85.js → chunk-rym0309c.js} +3 -3
- package/dist/{chunk-chzgfna2.js → chunk-s0vtjyyj.js} +1 -1
- package/dist/{chunk-vqc4h16r.js → chunk-s2wptfm1.js} +2 -2
- package/dist/chunk-sf0r963g.js +2 -0
- package/dist/{chunk-qmfycza5.js → chunk-sqn3y9qt.js} +2 -2
- package/dist/{chunk-hmyb701s.js → chunk-srq9fqq8.js} +10 -10
- package/dist/chunk-ss820yys.js +2 -0
- package/dist/{chunk-pn1ehs6a.js → chunk-szevd7d5.js} +2 -2
- package/dist/{chunk-wbzmr6a4.js → chunk-t0k16vqv.js} +2 -2
- package/dist/chunk-t4j9g2vh.js +2 -0
- package/dist/chunk-t79jfpv6.js +3 -0
- package/dist/{chunk-rcadtv3x.js → chunk-t9kxhe46.js} +1 -1
- package/dist/{chunk-zqtbtqbq.js → chunk-tddnb5bv.js} +2 -2
- package/dist/{chunk-hvzzhkhr.js → chunk-thceyzj6.js} +2 -2
- package/dist/{chunk-8yqfpkp4.js → chunk-trh7s6k3.js} +5 -5
- package/dist/{chunk-dq56166k.js → chunk-trz8z4j4.js} +18 -18
- package/dist/chunk-ttemwrbx.js +2 -0
- package/dist/{chunk-agqcqf3q.js → chunk-twqzn21x.js} +7 -7
- package/dist/chunk-v14rq8b4.js +3 -0
- package/dist/{chunk-b4pcw34n.js → chunk-v21bhhjb.js} +1 -1
- package/dist/{chunk-ka8befem.js → chunk-v6peecfp.js} +2 -2
- package/dist/{chunk-g8r0km7g.js → chunk-vayhx642.js} +2 -2
- package/dist/{chunk-1ptwdkvn.js → chunk-vdxg7e1y.js} +2 -2
- package/dist/chunk-vq513cxx.js +2 -0
- package/dist/chunk-vvq8xe3n.js +2 -0
- package/dist/{chunk-tre98h62.js → chunk-w3d98907.js} +2 -2
- package/dist/{chunk-0qqvmfrw.js → chunk-w7t2cfgy.js} +42 -42
- package/dist/chunk-w8t31bn9.js +2 -0
- package/dist/chunk-x1kz4d7j.js +2 -0
- package/dist/chunk-xcsyqwxf.js +25 -0
- package/dist/{chunk-9p6efb17.js → chunk-xghcsg3f.js} +1 -1
- package/dist/chunk-xn9jrjzh.js +2 -0
- package/dist/{chunk-nrvwejdw.js → chunk-y1pcdeg9.js} +5 -5
- package/dist/{chunk-7b3kr56x.js → chunk-yx3dpdwc.js} +3 -3
- package/dist/{chunk-5xvan09w.js → chunk-z22zy22p.js} +2 -2
- package/dist/chunk-z97bwx8m.js +2 -0
- package/dist/{chunk-120ze5ms.js → chunk-zmg1peyg.js} +3 -3
- package/dist/{chunk-pxdww4rb.js → chunk-zp79zkkd.js} +2 -2
- package/dist/cli.js +20 -20
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/loops.js +12 -2
- package/dist/pwa.js +3 -3
- package/dist/signal-processing.d.ts +12 -0
- package/dist/signal-processing.js +1 -1
- package/dist/ssg.js +6 -6
- package/package.json +5 -5
- package/dist/chunk-028ee6q5.js +0 -2
- package/dist/chunk-02ymqwmj.js +0 -2
- package/dist/chunk-1pnp91wx.js +0 -2
- package/dist/chunk-1v60t3sb.js +0 -2
- package/dist/chunk-2f17h17f.js +0 -2
- package/dist/chunk-4c183zem.js +0 -2
- package/dist/chunk-4yt8tg4j.js +0 -2
- package/dist/chunk-52gp2xxk.js +0 -2
- package/dist/chunk-5zgrvj4b.js +0 -2
- package/dist/chunk-67kj14at.js +0 -2
- package/dist/chunk-6rzshbey.js +0 -2
- package/dist/chunk-6vzktvyw.js +0 -2
- package/dist/chunk-81q3sc0w.js +0 -2
- package/dist/chunk-864qtx7y.js +0 -2
- package/dist/chunk-89jbdtgw.js +0 -3
- package/dist/chunk-8d33aqs5.js +0 -2
- package/dist/chunk-8tdz8svp.js +0 -2
- package/dist/chunk-99bhc1h1.js +0 -42
- package/dist/chunk-9rrnyd5m.js +0 -2
- package/dist/chunk-9szxxgv5.js +0 -2
- package/dist/chunk-amkwmxs8.js +0 -2
- package/dist/chunk-b1hxtn08.js +0 -2
- package/dist/chunk-b4fd2dtk.js +0 -2
- package/dist/chunk-b4vk2m82.js +0 -2
- package/dist/chunk-b58tv8jc.js +0 -25
- package/dist/chunk-b6nzy1rg.js +0 -2
- package/dist/chunk-b823zxq6.js +0 -3
- package/dist/chunk-bdg0fydw.js +0 -2
- package/dist/chunk-dpvxe52r.js +0 -2
- package/dist/chunk-e1fetwbr.js +0 -2
- package/dist/chunk-e4vpr36s.js +0 -2
- package/dist/chunk-e6p0k6br.js +0 -2
- package/dist/chunk-f8agvh5v.js +0 -2
- package/dist/chunk-fcn71bq1.js +0 -2
- package/dist/chunk-g2jmwh7p.js +0 -2
- package/dist/chunk-g64z2e92.js +0 -2
- package/dist/chunk-gw7h5k3b.js +0 -2
- package/dist/chunk-j0v970k3.js +0 -2
- package/dist/chunk-jk41jwsc.js +0 -2
- package/dist/chunk-jr9wfthg.js +0 -2
- package/dist/chunk-k2pa44rf.js +0 -2
- package/dist/chunk-kq9y6gfy.js +0 -2
- package/dist/chunk-md2qhahg.js +0 -2
- package/dist/chunk-p38m3947.js +0 -2
- package/dist/chunk-qcjh3pp8.js +0 -2
- package/dist/chunk-qw441qys.js +0 -2
- package/dist/chunk-qxmyaajq.js +0 -2
- package/dist/chunk-qyjsne99.js +0 -2
- package/dist/chunk-rermy54w.js +0 -2
- package/dist/chunk-rwjf25ht.js +0 -2
- package/dist/chunk-rx0ep3v1.js +0 -2
- package/dist/chunk-sf0wsq74.js +0 -2
- package/dist/chunk-shpc1ttk.js +0 -2
- package/dist/chunk-sy0z64yz.js +0 -2
- package/dist/chunk-ta7bmfvg.js +0 -3
- package/dist/chunk-weqc0ssb.js +0 -2
- package/dist/chunk-wq712sw1.js +0 -2
- package/dist/chunk-xr69d4tk.js +0 -2
- package/dist/chunk-xz6dw6yw.js +0 -2
- package/dist/chunk-y8kdy3d2.js +0 -2
- package/dist/chunk-yscr04dv.js +0 -2
- package/dist/chunk-z8p6tk5z.js +0 -2
- package/dist/chunk-zhf01af3.js +0 -3
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{y,b,
|
|
3
|
-
`)}var
|
|
2
|
+
import{y,b,Ao,an}from"./chunk-f9zyf9n6.js";import{po}from"./chunk-4b9s7wgy.js";import{c}from"./chunk-v14rq8b4.js";import M from"fs";import d from"path";import{hasLocalConfig as le}from"bunfig";var mt={fg:{light:"neutral-900",dark:"neutral-100",description:"Primary text"},"fg-strong":{light:"neutral-700",dark:"neutral-300",description:"Labels, secondary headings"},"fg-muted":{light:"neutral-600",dark:"neutral-400",description:"Supporting text"},"fg-soft":{light:"neutral-500",dark:"neutral-400",description:"De-emphasised text"},"fg-subtle":{light:"neutral-400",dark:"neutral-500",description:"Recessive, non-essential text"},surface:{light:"neutral-50",dark:"neutral-800",description:"Page and panel background"},"surface-raised":{light:"neutral-100",dark:"neutral-700",description:"Cards, popovers"},"surface-sunken":{light:"neutral-200",dark:"neutral-700",description:"Wells, track backgrounds"},panel:{light:"white",dark:"neutral-800",description:"Card, menu, dialog surface"},field:{light:"white",dark:"neutral-700",description:"Form control surface"},page:{light:"neutral-50",dark:"neutral-900",description:"Page background, behind panels"},content:{light:"white",dark:"neutral-900",description:"Content area under a chrome header - a table or list body"},"surface-hover":{light:"neutral-100",dark:"neutral-700",description:"Row or item highlight on a page or panel"},"surface-raised-hover":{light:"neutral-200",dark:"neutral-600",description:"Raised surface, hovered"},"surface-sunken-hover":{light:"neutral-300",dark:"neutral-600",description:"Sunken surface, hovered"},"field-hover":{light:"neutral-50",dark:"neutral-600",description:"Form control surface, hovered"},link:{light:"blue-500",dark:"blue-400",description:"Hyperlink"},"link-hover":{light:"blue-600",dark:"blue-300",description:"Hyperlink, hovered"},inverse:{light:"neutral-900",dark:"neutral-700",description:"Tooltip bubble, inverted surface"},"inverse-ink":{light:"white",dark:"white",description:"Text on an inverted surface"},line:{light:"neutral-200",dark:"neutral-700",description:"Default border, divider"},"line-strong":{light:"neutral-300",dark:"neutral-600",description:"Input border, focus ring track"},"line-hover":{light:"neutral-400",dark:"neutral-500",description:"Border of a hovered control"},accent:{light:"blue-600",dark:"blue-400",description:"Primary action, selected state"},info:{light:"cyan-600",dark:"cyan-400",description:"Informational emphasis"},danger:{light:"red-600",dark:"red-400",description:"Errors, destructive actions"},success:{light:"green-600",dark:"green-400",description:"Confirmation"},warning:{light:"yellow-600",dark:"yellow-400",description:"Caution"},"accent-solid":{light:"blue-500",dark:"blue-600",description:"Primary button fill"},"info-solid":{light:"cyan-500",dark:"cyan-600",description:"Informational fill"},"danger-solid":{light:"red-500",dark:"red-600",description:"Destructive button fill"},"success-solid":{light:"green-500",dark:"green-600",description:"Confirmation fill"},"warning-solid":{light:"yellow-500",dark:"yellow-600",description:"Caution fill"},"accent-solid-hover":{light:"blue-600",dark:"blue-700",description:"Primary button fill, hovered"},"info-solid-hover":{light:"cyan-600",dark:"cyan-700",description:"Informational fill, hovered"},"danger-solid-hover":{light:"red-600",dark:"red-700",description:"Destructive fill, hovered"},"success-solid-hover":{light:"green-600",dark:"green-700",description:"Confirmation fill, hovered"},"warning-solid-hover":{light:"yellow-600",dark:"yellow-700",description:"Caution fill, hovered"},"accent-ink":{light:"white",dark:"white",description:"Text on a primary fill"},"info-ink":{light:"neutral-900",dark:"neutral-900",description:"Text on an informational fill"},"danger-ink":{light:"white",dark:"white",description:"Text on a destructive fill"},"success-ink":{light:"neutral-900",dark:"neutral-900",description:"Text on a confirmation fill"},"warning-ink":{light:"neutral-900",dark:"neutral-900",description:"Text on a caution fill"},"accent-soft":{light:"blue-100",dark:"blue-900",description:"Tinted primary fill"},"accent-soft-ink":{light:"blue-800",dark:"blue-200",description:"Text on a tinted primary fill"},"info-soft":{light:"cyan-100",dark:"cyan-900",description:"Tinted informational fill"},"info-soft-ink":{light:"cyan-800",dark:"cyan-200",description:"Text on a tinted informational fill"},"danger-soft":{light:"red-100",dark:"red-900",description:"Tinted destructive fill"},"danger-soft-ink":{light:"red-800",dark:"red-200",description:"Text on a tinted destructive fill"},"success-soft":{light:"green-100",dark:"green-900",description:"Tinted confirmation fill"},"success-soft-ink":{light:"green-800",dark:"green-200",description:"Text on a tinted confirmation fill"},"warning-soft":{light:"yellow-100",dark:"yellow-900",description:"Tinted caution fill"},"warning-soft-ink":{light:"yellow-800",dark:"yellow-200",description:"Text on a tinted caution fill"},secondary:{light:"purple-600",dark:"purple-400",description:"Secondary emphasis"},"secondary-solid":{light:"purple-500",dark:"purple-600",description:"Secondary fill"},"secondary-solid-hover":{light:"purple-600",dark:"purple-700",description:"Secondary fill, hovered"},"secondary-ink":{light:"white",dark:"white",description:"Text on a secondary fill"},"secondary-soft":{light:"purple-100",dark:"purple-900",description:"Tinted secondary fill"},"secondary-soft-ink":{light:"purple-800",dark:"purple-200",description:"Text on a tinted secondary fill"},"danger-fg":{light:"red-900",dark:"red-300",description:"Text in a field with an error"},"danger-fg-subtle":{light:"red-300",dark:"red-500",description:"Recessive text in a field with an error"},"danger-line":{light:"red-300",dark:"red-600",description:"Border of a field with an error"},"danger-focus":{light:"red-500",dark:"red-400",description:"Focus ring of a field with an error"}};function Ue(n){return`--stx-${n}`}function F(n,t){let s=t.lastIndexOf("-");if(s===-1)return typeof n[t]==="string"?n[t]:void 0;let r=n[t.slice(0,s)];if(!r||typeof r!=="object")return;let i=r[t.slice(s+1)];return typeof i==="string"?i:void 0}var xe=/^(?:#[\da-f]{3,8}|(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix|var)\(.*\)|white|black|transparent|currentcolor)$/i;function X(n,t){let s=t.trim();return F(n,s)??(xe.test(s)?s:void 0)}function Z(n={}){return[...Object.keys(n.roles??{}).filter((t)=>!mt[t]).map((t)=>`roles.${t}`),...Object.keys(n.shapes??{}).filter((t)=>!ge[t]).map((t)=>`shapes.${t}`),...Object.keys(n.density??{}).filter((t)=>!$e[t]).map((t)=>`density.${t}`)]}function q(n){let t={};for(let[s,r]of Object.entries(mt)){let i=F(n,r.light);if(i===void 0)continue;t[s]=`var(${Ue(s)}, ${i})`}return t}function ee(n,t={}){let s=[],r=[];for(let[i,o]of Object.entries(mt)){let l=t[i],g=typeof l==="string"?l:l?.light,a=typeof l==="string"?l:l?.dark,u=g&&X(n,g)||F(n,o.light),x=a&&X(n,a)||F(n,o.dark);if(u===void 0)continue;if(s.push(` ${Ue(i)}: ${u};`),x!==void 0)r.push(` ${Ue(i)}: ${x};`)}if(s.length===0)return"";return["/* stx role tokens \u2014 override any of these to re-theme by meaning. */",":root {",...s,"}",".dark {",...r,"}",""].join(`
|
|
3
|
+
`)}var ge={control:{value:"0.375rem",description:"Buttons, inputs, selects \u2014 rounded-md"},panel:{value:"0.5rem",description:"Cards, dialogs, menus \u2014 rounded-lg"},pill:{value:"9999px",description:"Chips and badges, which are pill-shaped by intent"}};function Qt(n){return`--stx-radius-${n}`}function te(){let n={};for(let[t,s]of Object.entries(ge))n[t]=`var(${Qt(t)}, ${s.value})`;return n}function ne(n={}){return["/* stx shape tokens \u2014 a radius by what the thing is. */",":root {",...Object.entries(ge).map(([t,s])=>` ${Qt(t)}: ${n[t]??s.value};`),"}",""].join(`
|
|
4
4
|
`)}var $e={"control-px":{value:"1rem",description:"Inline padding of a md text control \u2014 px-4"},"control-py":{value:"0.5rem",description:"Block padding of a md text control \u2014 py-2"},"control-text":{value:"1rem",description:"Font size of a md text control \u2014 text-base"},"control-leading":{value:"1.5rem",description:"Line height of a md text control \u2014 text-base"},"cell-px":{value:"1.5rem",description:"Inline padding of every table cell, header or body \u2014 px-6"},"cell-py":{value:"1rem",description:"Block padding of a body cell \u2014 py-4"},"cell-text":{value:"0.875rem",description:"Font size of a body cell \u2014 text-sm"},"cell-leading":{value:"1.25rem",description:"Line height of a body cell \u2014 text-sm"},"cell-head-py":{value:"0.75rem",description:"Block padding of a header cell \u2014 py-3"},"cell-head-text":{value:"0.75rem",description:"Font size of a header cell \u2014 text-xs"},"cell-head-leading":{value:"1rem",description:"Line height of a header cell \u2014 text-xs"}},Vn={"control-x":"control-px","control-y":"control-py","cell-x":"cell-px","cell-y":"cell-py","cell-head-y":"cell-head-py"},Un={control:{size:"control-text",leading:"control-leading"},cell:{size:"cell-text",leading:"cell-leading"},"cell-head":{size:"cell-head-text",leading:"cell-head-leading"}};function We(n){return`--stx-${n}`}function V(n){let t=$e[n];if(!t)throw Error(`[stx] unknown density token "${n}"`);return`var(${We(n)}, ${t.value})`}function se(){let n={};for(let[t,s]of Object.entries(Vn))n[t]=V(s);return n}function re(){let n={};for(let[t,{size:s,leading:r}]of Object.entries(Un))n[t]=[V(s),{lineHeight:V(r)}];return n}function ie(n={}){return["/* stx density tokens \u2014 how much room a control or a table cell takes. */",":root {",...Object.entries($e).map(([t,s])=>` ${We(t)}: ${n[t]??s.value};`),"}",""].join(`
|
|
5
5
|
`)}function oe(n){return typeof n==="object"&&n!==null&&!Array.isArray(n)}function U(n,t){let s={...n};for(let[r,i]of Object.entries(t))s[r]=oe(i)&&oe(s[r])?U(s[r],i):i;return s}function ce(n,t){if(!t.fonts)return"";let s=new n({...t.config,fonts:t.fonts,cssVariables:!1}).toCSS(!1,t.minify);return s&&!t.minify?`${s}
|
|
6
|
-
`:s}function ae(n={},t={}){let s=n.theme||{},r=t.theme||{},{extend:i,...o}=r,{extend:l,...g}=s,a=g.colors||{};g.colors={...a,...q(a)};let u=g.borderRadius||{};g.borderRadius={...u,...te()};let x=g.spacing||{};g.spacing={...x,...se()};let H=g.fontSize||{};g.fontSize={...H,...re()};let R=U(g,o),k=U(l||{},i||{});if(Object.keys(k).length>0)R.extend=k;let E=[...n.safelist||[],...t.safelist||[]],_={...n.shortcuts||{},...t.shortcuts||{}},P=[...n.preflights||[],...t.preflights||[]],{fonts:K,...D}=n,{fonts:O,roles:T,shapes:N,density:C,...w}=t,f={roles:T,shapes:N,density:C},j=O??K;return{config:{...D,...w,theme:R,safelist:E,shortcuts:_,...P.length>0?{preflights:P}:{},content:[],output:""},safelist:E,shortcuts:_,includePreflight:t.preflight!==!1,minify:t.minify===!0,tokenCSS:ee({...a,...R.colors},T)+ne(N)+ie(C),unknownRoles:Z(f),...j?{fonts:j}:{}}}var e={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bgGray:"\x1B[100m"};var p=null,A="";function de(n){try{let t=n.startsWith("file:")?new URL(n).pathname:n;A=`${t}@${Math.trunc(M.statSync(t).mtimeMs)}`}catch{A=n}}var Q=!1,v=null,I="",B=!1,he=256,S=new Map,m=new Map,z=null,me=null,G=new Map,
|
|
7
|
-
`)}async function Te(n,t){try{let s=await
|
|
6
|
+
`:s}function ae(n={},t={}){let s=n.theme||{},r=t.theme||{},{extend:i,...o}=r,{extend:l,...g}=s,a=g.colors||{};g.colors={...a,...q(a)};let u=g.borderRadius||{};g.borderRadius={...u,...te()};let x=g.spacing||{};g.spacing={...x,...se()};let H=g.fontSize||{};g.fontSize={...H,...re()};let R=U(g,o),k=U(l||{},i||{});if(Object.keys(k).length>0)R.extend=k;let E=[...n.safelist||[],...t.safelist||[]],_={...n.shortcuts||{},...t.shortcuts||{}},P=[...n.preflights||[],...t.preflights||[]],{fonts:K,...D}=n,{fonts:O,roles:T,shapes:N,density:C,...w}=t,f={roles:T,shapes:N,density:C},j=O??K;return{config:{...D,...w,theme:R,safelist:E,shortcuts:_,...P.length>0?{preflights:P}:{},content:[],output:""},safelist:E,shortcuts:_,includePreflight:t.preflight!==!1,minify:t.minify===!0,tokenCSS:ee({...a,...R.colors},T)+ne(N)+ie(C),unknownRoles:Z(f),...j?{fonts:j}:{}}}var e={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bgGray:"\x1B[100m"};var p=null,A="";function de(n){try{let t=n.startsWith("file:")?new URL(n).pathname:n;A=`${t}@${Math.trunc(M.statSync(t).mtimeMs)}`}catch{A=n}}var Q=!1,v=null,I="",B=!1,he=256,S=new Map,m=new Map,z=null,me=null,G=new Map,ue=new Set;function L(n){return Bun.hash(n).toString(16).padStart(16,"0").slice(0,16)}function W(n,t){if(S.has(n))S.delete(n);else if(S.size>=he)S.delete(S.keys().next().value);S.set(n,t)}function ke(n){let t=L(n);if(m.has(t))m.delete(t);else if(m.size>=he)m.delete(m.keys().next().value);return m.set(t,n),t}function ip(n){let t=m.get(n);if(t===void 0)return;return m.delete(n),m.set(n,t),t}async function Ce(n,t=z){if(!t)return null;try{let s=Bun.file(d.join(t,`cw-${L(n)}.css`));if(!await s.exists())return null;return await s.text()}catch{return null}}async function Se(n,t,s=z){if(!s)return;try{if(!M.existsSync(s))M.mkdirSync(s,{recursive:!0});await Bun.write(d.join(s,`cw-${L(n)}.css`),t)}catch{}}async function fe(n){try{let t=await import(n);if(t&&t.CSSGenerator)return{CSSGenerator:t.CSSGenerator,config:t.config,build:t.build,defaultConfig:t.defaultConfig,extractClasses:t.extractClasses}}catch{}return null}var we=[["@stacksjs","ts-css","dist","engine","index.js"],["@stacksjs","ts-css","src","engine","index.ts"]],be=["@stacksjs/ts-css/engine","@stacksjs/ts-css/dist/engine/index.js"];function ve(){let n=[],t=process.cwd();while(t!==d.dirname(t)){for(let s of["node_modules","pantry"])for(let r of we)n.push(d.join(t,s,...r));t=d.dirname(t)}return n}function Re(){let n=[],t=process.env.HOME||process.env.USERPROFILE||"",s=[t&&d.join(t,"Code","Tools","ts-css"),t&&d.join(t,"Code","Tools","crosswind"),t&&d.join(t,"repos","stacks-org","ts-css"),t&&d.join(t,"repos","stacks-org","crosswind"),d.join(process.cwd(),"..","ts-css"),d.join(process.cwd(),"..","crosswind")].filter(Boolean);for(let r of s)n.push(d.join(r,"packages","toolkit","dist","engine","index.js")),n.push(d.join(r,"packages","toolkit","src","engine","index.ts"));if(t)n.push(d.join(t,"Code","Tools","stx","node_modules","@stacksjs","ts-css","dist","engine","index.js"));return n}async function ra(){if(Q)return p;Q=!0;try{let n=async(i)=>{for(let o of i){if(!await Bun.file(o).exists())continue;let l=await fe(o);if(l){if(de(o),!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} CSS engine loaded from ${d.dirname(d.dirname(o))}`);return l}}return null};if(process.env.CROSSWIND_SRC){let i=d.resolve(process.env.CROSSWIND_SRC),o=await n([i]);if(!o)throw Error(`CROSSWIND_SRC did not resolve to a Css module: ${i}`);return p=o,p}let t=await n(ve());if(t)return p=t,p;let s=be;for(let i of s){let o=await fe(i);if(o){p=o;try{de(import.meta.resolve(i))}catch{A=i}if(!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} CSS engine loaded`);return p}}let r=await n(Re());if(r)return p=r,p;throw Error("Css CSSGenerator not found in any location")}catch{return console.warn(`${e.yellow}[ts-css] CSS engine not available, Tailwind styles will not be generated${e.reset}`),console.warn(`${e.yellow}Run 'bun add @stacksjs/ts-css' to enable CSS generation${e.reset}`),null}}function ap(){Y.clear(),p=null,Q=!1,v=null,I="",S.clear(),m.clear(),me=null,G.clear()}var pe=!1;async function sa(n){try{let t=le({name:"css",cwd:n})?"css":le({name:"crosswind",cwd:n})?"crosswind":null;if(!t)return null;if(t==="crosswind"&&!process.env.STACKS_DEV_QUIET&&!pe)pe=!0,console.warn(`${e.yellow}[ts-css]${e.reset} Reading the CSS config from a \`crosswind\` file. Rename it to \`css\` (e.g. config/css.ts) \u2014 the old name is deprecated.`);let{loadConfigWithResult:s}=await import("bunfig"),r=await s({name:t,cwd:n,defaultConfig:{},checkEnv:!1,verbose:!1});if(!r?.path||!r.config||Object.keys(r.config).length===0)return null;let i=d.relative(n,r.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} Loaded config from ${i||r.path}`);return r.config}catch(t){if(t instanceof Error&&t.name==="ConfigNotFoundError")return null;return console.warn(`${e.yellow}[ts-css]${e.reset} Failed to load css config:`,t instanceof Error?t.message:t),null}}async function bl(n){let t=null;try{let{loadStxConfig:s}=await import("./chunk-2881tcqt.js"),r=await s(n);if(r.css)if(typeof r.css==="string"){let i=d.isAbsolute(r.css)?r.css:d.resolve(n,r.css);if(await Bun.file(i).exists()){let o=await import(i);t=o.default||o,console.log(`${e.green}[ts-css]${e.reset} Loaded config from stx.config.ts \u2192 ${r.css}`)}}else{if(t={...r.css,content:r.css.content||[],preflight:r.css.preflight??!0,minify:r.css.minify??!1},r.css.config){let i=d.isAbsolute(r.css.config)?r.css.config:d.resolve(n,r.css.config);if(await Bun.file(i).exists()){let o=await import(i);t={...o.default||o,...t}}}console.log(`${e.green}[ts-css]${e.reset} Using inline CSS config from stx.config.ts`)}}catch{}return t||await sa(n)}function vl(n){try{let t=new WeakSet;return L(JSON.stringify(n??{},(s,r)=>{if(typeof r==="function")return`[fn]${String(r)}`;if(typeof r==="object"&&r!==null){if(t.has(r))return"[circular]";t.add(r)}return r})??"")}catch{return"unhashable"}}async function en(n){if(B)return I;B=!0;try{let t=await ra();if(!t||!t.build)return B=!1,"";if(!v)v=await sa(n);if(!v)return B=!1,"";let s=t.defaultConfig?.theme||{},r=v.theme||{},i={...t.defaultConfig,...v,theme:{...s,...r,extend:{...s.extend||{},...r.extend||{}}}},o=performance.now(),l=await t.build(i),g=performance.now()-o;if(I=l.css,console.log(`${e.cyan}[ts-css]${e.reset} Built ${l.classes.size} classes in ${g.toFixed(1)}ms`),i.output){let a=d.isAbsolute(i.output)?i.output:d.join(n,i.output),u=d.dirname(a);if(!M.existsSync(u))M.mkdirSync(u,{recursive:!0});await Bun.write(a,l.css)}return B=!1,l.css}catch(t){return console.error(`${e.red}[ts-css]${e.reset} Build error:`,t),B=!1,I}}async function Wn(n){v=null,await en(n)}function cp(){return I}function wl(n){let t=new Set,s=/class\s*=\s*["']([^"']+)["']/gi,r=s.exec(n);while(r!==null){for(let l of r[1].split(/\s+/))if(l.trim())t.add(l.trim());r=s.exec(n)}let i=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,o=i.exec(n);while(o!==null){let l=o[1].match(/'([^']+)'/g);if(l){for(let g of l)for(let a of g.slice(1,-1).split(/\s+/))if(a.trim())t.add(a.trim())}o=i.exec(n)}return t}var Y=y(64);async function xl(n,t){let s=()=>G.get(t?d.resolve(t):process.cwd())?.fingerprint??null,r=Y.get(b(n,t,s()));if(r!==void 0)return r;let i=await Te(n,t);if(i)Y.set(b(n,t,s()),i);return i}function*ye(n){yield n;let t=new Set;for(let s of n.matchAll(/\/_stx\/modules\.([0-9a-f]{16})\.js/g)){let r=s[1];if(t.has(r))continue;t.add(r);let i=po(r);if(i)yield i}}function lp(n){return[...ye(n)].join(`
|
|
7
|
+
`)}async function Te(n,t){try{let s=await ra();if(!s)return"";let r=new Set;for(let f of ye(n)){let j=typeof s.extractClasses==="function"?s.extractClasses(f):wl(f);for(let J of j)r.add(J)}if(r.size===0)return"";let i=t?d.resolve(t):process.cwd(),o=c(i,"cache");if(!z)z=o;let l=G.get(i);if(!l){let f=await bl(i);l={config:f,fingerprint:vl(f)},G.set(i,l),me=l.fingerprint}let g=[...r].sort().join(" "),a=`${A}::${l.fingerprint||"default"}::${g}`,u=S.get(a);if(u!==void 0)return W(a,u),u;let x=await Ce(a,o);if(x!==null)return W(a,x),x;let H=s.defaultConfig||s.config,R=l.config||{},k=ae(H,R),{safelist:E,includePreflight:_,minify:P,tokenCSS:K}=k;if(k.unknownRoles.length>0&&!ue.has(i))ue.add(i),console.warn(`${e.yellow}[ts-css]${e.reset} No stx role for ${k.unknownRoles.join(", ")} - these keep the stock value. Role names: semanticTokenNames() in @stacksjs/stx/theme-tokens.`);let D=k.config,O=new s.CSSGenerator(D),T=D.shortcuts||R.shortcuts||{},N=Object.keys(T).filter((f)=>r.has(f)||E.includes(f));for(let f of E)if(!T[f])O.generate(f);for(let f of r)if(!T[f])O.generate(f);let C="";if(N.length>0){let f=new s.CSSGenerator(D);for(let j of N)f.generate(j);if(C=f.toCSS(!1,P),C&&!C.endsWith(`
|
|
8
8
|
`))C+=`
|
|
9
|
-
`}let w=C+O.toCSS(_,P);return w=ce(s.CSSGenerator,k)+K+w,W(a,w),Se(a,w,o),w}catch(s){return console.warn("Failed to generate Css CSS:",s),""}}async function h(n,t,s=!1,r=!1){let i=await
|
|
9
|
+
`}let w=C+O.toCSS(_,P);return w=ce(s.CSSGenerator,k)+K+w,W(a,w),Se(a,w,o),w}catch(s){return console.warn("Failed to generate Css CSS:",s),""}}async function h(n,t,s=!1,r=!1){let i=await xl(n,t);if(!i)return r?an(n):n;let o=s?`<link data-css="generated" rel="stylesheet" href="/_stx/css.${ke(i)}.css">`:`<style data-css="generated">
|
|
10
10
|
${i}
|
|
11
11
|
</style>`;if(r)return je(n,o);let l=/(?:<style\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>)/g;if(l.test(n)){let g=!1;return n.replace(l,()=>{if(g)return"";return g=!0,o})}if(n.includes("</head>"))return n.replace("</head>",`${o}
|
|
12
12
|
</head>`);if(n.includes("<body"))return n.replace(/<body([^>]*)>/,`<body$1>
|
|
13
|
-
${o}`);return o+n}function je(n,t){let s=
|
|
13
|
+
${o}`);return o+n}function je(n,t){let s=Ao(n).map((a)=>({...a,replacement:""})),r=/(?:<style\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>)/g,i=r.exec(n);if(i!==null){let a=!0;while(i!==null)s.push({start:i.index,end:i.index+i[0].length,replacement:a?t:""}),a=!1,i=r.exec(n)}else{let a=n.indexOf("</head>");if(a!==-1)s.push({start:a,end:a,replacement:`${t}
|
|
14
14
|
`});else{let u=n.match(/<body([^>]*)>/);if(u?.index!==void 0)s.push({start:u.index,end:u.index+u[0].length,replacement:`${u[0]}
|
|
15
15
|
${t}`});else s.push({start:0,end:0,replacement:t})}}s.sort((a,u)=>a.start-u.start||a.end-u.end);for(let a=1;a<s.length;a++)if(s[a].start<s[a-1].end)return Be(an(n),t);let o=Array(s.length*2+1),l=0,g=0;for(let a of s)o[g++]=n.slice(l,a.start),o[g++]=a.replacement,l=a.end;return o[g]=n.slice(l),o.join("")}function Be(n,t){let s=/(?:<style\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>)/g;if(s.test(n)){let r=!1;return n.replace(s,()=>{if(r)return"";return r=!0,t})}if(n.includes("</head>"))return n.replace("</head>",`${t}
|
|
16
16
|
</head>`);if(n.includes("<body"))return n.replace(/<body([^>]*)>/,`<body$1>
|
|
17
17
|
${t}`);return t+n}
|
|
18
|
-
export{mt,Ue,
|
|
18
|
+
export{mt,Ue,ge,Qt,$e,Vn,Un,We,e,ip,ra,ap,sa,bl,vl,en,Wn,cp,wl,xl,lp,h};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{mn,A}from"./chunk-
|
|
2
|
+
import{mn,A}from"./chunk-25zmy8q6.js";import m from"fs";import e from"path";async function gn(r,o,i){if(r.__stx_runtime_config)return;let n=mn();if(n||i){r.__stx_runtime_config=n??A(i);return}let t=e.dirname(e.resolve(o));while(!0){if(["stx.config.ts","stx.config.js",".config/stx.config.ts",".config/stx.config.js"].some((f)=>m.existsSync(e.join(t,f)))){let{loadStxConfig:f}=await import("./chunk-2881tcqt.js"),c=await f(t);if(c.runtimeConfig)r.__stx_runtime_config=A(c.runtimeConfig);return}let s=e.dirname(t);if(s===t)return;t=s}}async function Bo(r,o){function i(n){if(n===null)return"null";if(Array.isArray(n))return`Array<${n.length?[...new Set(n.map(i))].join(" | "):"unknown"}>`;if(typeof n==="object")return`{ ${Object.entries(n).map(([t,s])=>`readonly ${JSON.stringify(t)}: ${i(s)}`).join("; ")} }`;return typeof n}await Bun.write(e.join(r,".stx/runtime-config.d.ts"),`import '@stacksjs/stx/runtime-config'
|
|
3
3
|
declare module '@stacksjs/stx/runtime-config' { interface PublicRuntimeConfig ${i(o.public??{})} }
|
|
4
4
|
`),await Bun.write(e.join(r,".stx/runtime-config-server.d.ts"),`import '@stacksjs/stx/runtime-config-server'
|
|
5
5
|
declare module '@stacksjs/stx/runtime-config-server' { interface PrivateRuntimeConfig ${i(o.private??{})} }
|
|
6
6
|
`)}
|
|
7
|
-
export{gn,
|
|
7
|
+
export{gn,Bo};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{it,at,ct}from"./chunk-tp4eqfxq.js";import"./chunk-
|
|
2
|
+
import{it,at,ct}from"./chunk-tp4eqfxq.js";import"./chunk-zp79zkkd.js";import"./chunk-ce6zddpf.js";import{g}from"./chunk-f9zyf9n6.js";import"./chunk-bsajk82t.js";import"./chunk-25zmy8q6.js";import"./chunk-mwnhdsbp.js";import{Bt,Rs,Ft,ci,ot,li,As,zt,di,Ht}from"./chunk-szevd7d5.js";import M from"fs";import x from"path";function E(t,e){let r=[x.join(t.root,"stx.config.ts"),x.join(t.root,"stx.config.js"),x.join(t.root,"stx.config.mjs")],s=e.debounceMs??300,o=null,a=[];for(let c of r)try{if(!M.existsSync(c))continue;let n=M.watch(c,(d)=>{if(d==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{li("Config file changed, restarting...");try{await e.onChange()}catch(p){ot(`Failed to restart: ${p}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var st=".stx/story/analytics.json",dt=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,st),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:dt,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:pt(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let d=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),p=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),u=p.length>0?p.reduce((i,l)=>i+l,0)/p.length:0,y=Object.entries(c).sort((i,l)=>l[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:d.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:y,variantViews:n,avgTimeSpent:u}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function pt(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var lt=".stx/story/bookmarks.json",mt=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,lt),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:mt,bookmarks:[]}}}async save(){if(!this.dirty)return;let t=B.dirname(this.storagePath);await S.promises.mkdir(t,{recursive:!0}),await S.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(t,e,r,s={}){let o={id:ut(),name:s.name||`${t}/${e}`,storyId:t,variantId:e,props:r,created:Date.now(),notes:s.notes,color:s.color};return this.storage.bookmarks.push(o),this.dirty=!0,o}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(t){return this.storage.bookmarks.filter((e)=>e.storyId===t)}getBookmark(t){return this.storage.bookmarks.find((e)=>e.id===t)}isBookmarked(t,e){return this.storage.bookmarks.some((r)=>r.storyId===t&&r.variantId===e)}updateBookmark(t,e){let r=this.getBookmark(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deleteBookmark(t){let e=this.storage.bookmarks.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.bookmarks.splice(e,1),this.dirty=!0,!0}toggleBookmark(t,e,r){let s=this.storage.bookmarks.find((a)=>a.storyId===t&&a.variantId===e);if(s)return this.deleteBookmark(s.id),{added:!1};return{added:!0,bookmark:this.addBookmark(t,e,r)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(t,e=!0){let r=JSON.parse(t),s=0;for(let o of r.bookmarks){if(e){let a=this.storage.bookmarks.find((c)=>c.id===o.id);if(a)Object.assign(a,o);else this.storage.bookmarks.push(o)}else this.storage.bookmarks.push(o);s++}if(s>0)this.dirty=!0;return s}}function ut(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var v=new Set;function N(){return{open(t){v.add(t),t.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(t){v.delete(t)},message(t,e){}}}function C(t){let e=JSON.stringify({...t,timestamp:t.timestamp||Date.now()});for(let r of v)try{r.send(e)}catch{v.delete(r)}}function V(t,e){C({type:"story-update",data:{storyId:t,...e}})}function H(t,e){C({type:"story-add",data:{storyId:t,...e}})}function O(t){C({type:"story-remove",data:{storyId:t}})}function F(t){return`
|
|
3
3
|
<script>
|
|
4
4
|
(function() {
|
|
5
5
|
const ws = new WebSocket('${t}');
|
|
@@ -556,9 +556,9 @@ window.__stxPerformance = {
|
|
|
556
556
|
|
|
557
557
|
window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
|
|
558
558
|
</script>
|
|
559
|
-
`}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-
|
|
559
|
+
`}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-jzjpyyw2.js"),p={},u=h(n);if(u)try{await g(u,p,e)}catch(f){o.push(`Warning: Could not extract script variables: ${f instanceof Error?f.message:String(f)}`)}if(r.props)Object.assign(p,r.props);let i=await d(n,p,e,{},new Set),l=Z(n),m=h(n);return i=Q(i),i=tt(i,p),{html:i,css:l,js:m,errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}async function vt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=h(e);if(!r)return null;let s={};if(await g(r,s,t),Array.isArray(s.variants))return s.variants;return null}catch{return null}}async function Y(t,e,r,s){let o=e.story?.variants;if(!o){let n=await vt(e.path);if(n)o=n}if(!o&&r==="default")return b(t,e.path,{props:s||{}});if(!o)return b(t,e.path,{props:s||{}});let a=o.find((n)=>n.id===r);if(!a&&r==="default")return b(t,e.path,{props:s||{}});if(!a)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${r}' not found`],duration:0};let c={...a.state,...s};if(a.source)return bt(t,a.source,c);return b(t,e.path,{props:c})}async function bt(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-jzjpyyw2.js"),c={...r},n=h(e);if(n)try{await g(n,c,"inline-template.stx")}catch{}let p=await a(e,c,"inline-template.stx",{},new Set);return p=Q(p),p=tt(p,c),{html:p,css:Z(e),js:h(e),errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}function Z(t){let e=[],r=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
|
|
560
560
|
`)}function Q(t){return t.replace(/<!--[\s\S]*?-->/g,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/^\s*\n/gm,"").trim()}function h(t){let e=[],r=/<script\b[^>]*>([\s\S]*?)<\/script>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
|
|
561
|
-
`)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}async function rt(t,e){let r=await zt(t);at(t,r);let s=Ht(t.config,r);ct(t,s),console.log(` Found ${r.length} story files`);let o=typeof e.host==="string"?e.host:e.host===!0?"0.0.0.0":"localhost",a=new I(t.root),c=new P(t.root),n=new k(t.root),d=N(),p=Bun.serve({port:e.port,hostname:o,fetch:async(i,l)=>{let f=new URL(i.url).pathname;if(f==="/__hmr"){if(l.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(f.startsWith("/api/"))return xt(t,f,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return wt(t,f,e.port)},websocket:{open(i){d.open(i)},close(i){d.close(i)},message(i,l){d.message(i,l)}}}),u=`http://${o}:${e.port}`,y=
|
|
561
|
+
`)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}async function rt(t,e){let r=await zt(t);at(t,r);let s=Ht(t.config,r);ct(t,s),console.log(` Found ${r.length} story files`);let o=typeof e.host==="string"?e.host:e.host===!0?"0.0.0.0":"localhost",a=new I(t.root),c=new P(t.root),n=new k(t.root),d=N(),p=Bun.serve({port:e.port,hostname:o,fetch:async(i,l)=>{let f=new URL(i.url).pathname;if(f==="/__hmr"){if(l.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(f.startsWith("/api/"))return xt(t,f,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return wt(t,f,e.port)},websocket:{open(i){d.open(i)},close(i){d.close(i)},message(i,l){d.message(i,l)}}}),u=`http://${o}:${e.port}`,y=di(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let m=await zt(t);at(t,m);let f=Ht(t.config,m);if(ct(t,f),i==="add")H(l.id,{fileName:l.fileName});else if(i==="unlink")O(l.id);else V(l.id,{fileName:l.fileName})});if(e.open){let i=u;try{let{exec:l}=await import("child_process"),m=process.platform;l(`${m==="darwin"?"open":m==="win32"?"start":"xdg-open"} ${i}`)}catch{}}return{server:p,url:u,close:async()=>{y(),p.stop()}}}async function xt(t,e,r,s){let{presetsManager:o,bookmarksManager:a,analyticsTracker:c}=s;if(e==="/api/stories")return Response.json({files:t.storyFiles.map((n)=>({id:n.id,fileName:n.fileName,relativePath:n.relativePath,treePath:n.treePath})),tree:t.tree});if(e.startsWith("/api/story/")){let n=e.slice(11),d=t.storyFiles.find((p)=>p.id===n);if(!d)return new Response("Story not found",{status:404});try{let p=await Bun.file(d.path).text();return Response.json({id:d.id,fileName:d.fileName,relativePath:d.relativePath,content:p})}catch{return new Response("Error reading story",{status:500})}}if(e==="/api/config")return Response.json({theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets});if(e.startsWith("/api/render/")){let n=new URL(r.url),d=e.slice(12).split("/"),p=d[0],u=d[1]||"default",y,i=n.searchParams.get("props");if(i)try{y=JSON.parse(i)}catch{}let l=t.storyFiles.find((m)=>m.id===p);if(!l)return new Response("Story not found",{status:404});try{let m=await Y(t,l,u,y);return Response.json({html:m.html,css:m.css,js:m.js,errors:m.errors,duration:m.duration})}catch(m){return Response.json({html:"",css:"",js:"",errors:[m instanceof Error?m.message:String(m)],duration:0},{status:500})}}if(e==="/api/presets"&&r.method==="GET")return Response.json({presets:o.getAllPresets()});if(e==="/api/presets"&&r.method==="POST")try{let n=await r.json(),d=o.createPreset(n.name,n.props,{componentId:n.componentId,description:n.description});return await o.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/presets/")&&!e.includes("/use")&&r.method==="GET"){let n=e.slice(13),d=o.getPreset(n);if(!d)return new Response("Preset not found",{status:404});return Response.json(d)}if(e.endsWith("/use")&&r.method==="POST"){let n=e.slice(13,-4),d=o.usePreset(n);if(!d)return new Response("Preset not found",{status:404});return await o.save(),Response.json(d)}if(e.startsWith("/api/presets/")&&r.method==="DELETE"){let n=e.slice(13);if(!o.deletePreset(n))return new Response("Preset not found",{status:404});return await o.save(),Response.json({success:!0})}if(e==="/api/bookmarks"&&r.method==="GET")return Response.json({bookmarks:a.getAllBookmarks()});if(e==="/api/bookmarks"&&r.method==="POST")try{let n=await r.json(),d=a.addBookmark(n.storyId,n.variantId,n.props,{name:n.name,notes:n.notes,color:n.color});return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/bookmarks/toggle"&&r.method==="POST")try{let n=await r.json(),d=a.toggleBookmark(n.storyId,n.variantId,n.props);return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/bookmarks/")&&e!=="/api/bookmarks/toggle"&&r.method==="GET"){let n=e.slice(15),d=a.getBookmark(n);if(!d)return new Response("Bookmark not found",{status:404});return Response.json(d)}if(e.startsWith("/api/bookmarks/")&&r.method==="DELETE"){let n=e.slice(15);if(!a.deleteBookmark(n))return new Response("Bookmark not found",{status:404});return await a.save(),Response.json({success:!0})}if(e==="/api/analytics/track"&&r.method==="POST")try{let n=await r.json();if(n.type==="view"&&n.componentId)c.trackView(n.componentId,n.variantId);else if(n.type==="prop_change"&&n.componentId&&n.propName)c.trackPropChange(n.componentId,n.propName,null);else if(n.type==="variant_switch"&&n.componentId&&n.variantId)c.trackVariantSwitch(n.componentId,n.variantId);else if(n.type==="search"&&n.query)c.trackSearch(n.query,0);return await c.save(),Response.json({success:!0})}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/analytics/summary"&&r.method==="GET")return Response.json({mostViewed:c.getMostViewedComponents(10),mostChangedProps:c.getMostChangedProps(10),searchAnalytics:c.getSearchAnalytics()});if(e.startsWith("/api/analytics/component/")&&r.method==="GET"){let n=e.slice(25),d=t.storyFiles.find((u)=>u.id===n),p=c.getComponentAnalytics(n,d?.fileName||n);return Response.json(p)}return new Response("Not found",{status:404})}function wt(t,e,r){let s=kt(t,r);return new Response(s,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function kt(t,e){let{theme:r}=t.config,s=r.title||"STX Story",o=`ws://localhost:${e}/__hmr`,a=F(o);return`<!DOCTYPE html>
|
|
562
562
|
<html lang="en" class="${r.darkClass||"dark"}">
|
|
563
563
|
<head>
|
|
564
564
|
<meta charset="UTF-8">
|
|
@@ -1276,5 +1276,5 @@ else {
|
|
|
1276
1276
|
<style>${W()}</style>
|
|
1277
1277
|
${D()}
|
|
1278
1278
|
</body>
|
|
1279
|
-
</html>`}import St from"fs";import Pt from"path";var Ct=new Map,Tt=[],Rt=[],It=new Map;async function nt(t){let e=t.config.setupFile;if(!e)return;let r=Pt.resolve(t.root,e);try{await St.promises.access(r)}catch{return}let s={storyContext:t,registerComponent:(o,a)=>{Ct.set(o,a)},addCSS:(o)=>{Tt.push(o)},addScript:(o)=>{Rt.push(o)},setState:(o,a)=>{It.set(o,a)}};try{let o=await import(r);if(typeof o.default==="function")await o.default(s);else if(typeof o.setupStory==="function")await o.setupStory(s)}catch(o){console.warn(`Warning: Failed to load setup file: ${o}`)}}async function we(t={}){Bt();let e=await it({mode:"dev"});if(!e.config.enabled){ot("Story feature is disabled in config.");return}await nt(e);let r=t.port??e.config.port,s,o=async()=>{s=await rt(e,{port:r,open:t.open,host:t.host}),Ft(e.storyFiles.length)
|
|
1280
|
-
`),a.stop(),await s.close(),process.exit(0)};if(process.on("SIGINT",c),process.on("SIGTERM",c),process.stdin.isTTY)process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("data",async(n)=>{switch(n.toString()){case"h":
|
|
1279
|
+
</html>`}import St from"fs";import Pt from"path";var Ct=new Map,Tt=[],Rt=[],It=new Map;async function nt(t){let e=t.config.setupFile;if(!e)return;let r=Pt.resolve(t.root,e);try{await St.promises.access(r)}catch{return}let s={storyContext:t,registerComponent:(o,a)=>{Ct.set(o,a)},addCSS:(o)=>{Tt.push(o)},addScript:(o)=>{Rt.push(o)},setState:(o,a)=>{It.set(o,a)}};try{let o=await import(r);if(typeof o.default==="function")await o.default(s);else if(typeof o.setupStory==="function")await o.setupStory(s)}catch(o){console.warn(`Warning: Failed to load setup file: ${o}`)}}async function we(t={}){Bt();let e=await it({mode:"dev"});if(!e.config.enabled){ot("Story feature is disabled in config.");return}await nt(e);let r=t.port??e.config.port,s,o=async()=>{s=await rt(e,{port:r,open:t.open,host:t.host}),Ft(e.storyFiles.length),Rs(s.url),As()};await o();let a=E(e,{onChange:async()=>{await s.close();let n=await it({mode:"dev"});Object.assign(e,n),await o()}}),c=async()=>{console.log(`
|
|
1280
|
+
`),a.stop(),await s.close(),process.exit(0)};if(process.on("SIGINT",c),process.on("SIGTERM",c),process.stdin.isTTY)process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("data",async(n)=>{switch(n.toString()){case"h":As();break;case"o":try{let{exec:p}=await import("child_process"),u=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";p(`${u} ${s.url}`)}catch{ci("Failed to open browser")}break;case"r":await s.close(),await o();break;case"c":console.clear(),Bt(),Ft(e.storyFiles.length),Rs(s.url);break;case"q":case"\x03":await c();break}});await new Promise(()=>{})}export{we as devCommand};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ju,Bu,Fu,zu,Mc,Hu,Vu,Uu,Wu,qu,Gu,Ku}from"./chunk-j6m8xqh3.js";export{Gu as Broadcast,Ku as BroadcastServer,Mc as broadcast,Wu as broadcastPresence,Uu as broadcastPrivate,qu as channel,ju as getBroadcastServer,zu as loadChannels,Bu as startBroadcasting,Fu as stopBroadcasting,Hu as toUser,Vu as toUsers};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var d=[{open:/<!--/g,close:/-->/g},{open:/<script\b/gi,close:/<\/script\s*>/gi},{open:/<style\b/gi,close:/<\/style\s*>/gi}],u=/<body\b([^>]*)>/gi;function
|
|
3
|
-
export{
|
|
2
|
+
var d=[{open:/<!--/g,close:/-->/g},{open:/<script\b/gi,close:/<\/script\s*>/gi},{open:/<style\b/gi,close:/<\/style\s*>/gi}],u=/<body\b([^>]*)>/gi;function W(n){let i=0,e,c=d.map(()=>{return});while(i<n.length){if(e===void 0||e!==null&&e.index<i)u.lastIndex=i,e=u.exec(n);if(!e)return null;let a=e.index,r=-1,o=null;for(let l=0;l<d.length;l++){let g=d[l],t=c[l];if(t===void 0||t!==null&&t.index<i)g.open.lastIndex=i,t=g.open.exec(n),c[l]=t;if(!t)continue;if(t.index<a&&(r===-1||t.index<r))r=t.index,o=g.close}if(r===-1||!o)return{index:a,tag:e[0],attrs:e[1]??""};o.lastIndex=r;let s=o.exec(n);if(!s)return null;i=s.index+s[0].length}return null}function Ge(n,i){let e=W(n);if(!e)return n;return n.slice(0,e.index)+i(e.tag,e.attrs)+n.slice(e.index+e.tag.length)}
|
|
3
|
+
export{W,Ge};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Zo,Qo,ei,wu,xu,Su,wc,ku,_u}from"./chunk-xghcsg3f.js";export{Zo as ImageProcessorCache,wc as applyTransformations,wu as clearImageCache,ku as generateResponsiveVariants,_u as generateSrcset,Qo as getCachedImageResult,Su as optimizeImage,xu as processImage,ei as setCachedImageResult};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var c=0;function l(){return`suspense-${++c}-${Date.now().toString(36)}`}function
|
|
2
|
+
var c=0;function l(){return`suspense-${++c}-${Date.now().toString(36)}`}function kd(s,n={},t){let e=/@suspense(?:\s*\(([^)]*)\))?\s*([\s\S]*?)@fallback\s*([\s\S]*?)@endsuspense/gi;return s.replace(e,(r,i,o,d)=>{let u=l(),a=p(i||"");return f(u,o.trim(),d.trim(),a)})}function p(s){let n={},t=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,e;while((e=t.exec(s))!==null){let r=e[1],i=e[2]||e[3],o=e[4];switch(r){case"id":n.id=i;break;case"timeout":n.timeout=o?parseInt(o,10):void 0;break}}return n}function f(s,n,t,e){let r=e.timeout||30000,i=e.id||s;return`
|
|
3
3
|
<div class="stx-suspense" data-suspense-id="${s}" data-custom-id="${i}" data-status="pending">
|
|
4
4
|
<div class="stx-suspense-fallback" data-suspense-fallback="${s}">
|
|
5
5
|
${t}
|
|
@@ -189,7 +189,7 @@ else {
|
|
|
189
189
|
}, 0);
|
|
190
190
|
})();
|
|
191
191
|
</script>
|
|
192
|
-
`}function
|
|
192
|
+
`}function _d(s,n,t){return{id:s,fallback:t,content:n}}async function Cd(s){let n=s.map((e)=>`
|
|
193
193
|
<div id="stx-ssr-suspense-${e.id}" class="stx-ssr-suspense">
|
|
194
194
|
${e.fallback}
|
|
195
195
|
</div>
|
|
@@ -214,7 +214,7 @@ else {
|
|
|
214
214
|
}
|
|
215
215
|
})();
|
|
216
216
|
</script>
|
|
217
|
-
`}}return{initial:n,streaming:t()}}function
|
|
217
|
+
`}}return{initial:n,streaming:t()}}function Ed(){return`
|
|
218
218
|
/* STX Suspense Styles */
|
|
219
219
|
.stx-suspense {
|
|
220
220
|
position: relative;
|
|
@@ -270,7 +270,7 @@ else {
|
|
|
270
270
|
background-size: 200% 100%;
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
|
-
`}function
|
|
273
|
+
`}function Td(){return`
|
|
274
274
|
// STX Suspense Runtime
|
|
275
275
|
(function() {
|
|
276
276
|
if (typeof window === 'undefined') return;
|
|
@@ -338,4 +338,4 @@ else {
|
|
|
338
338
|
console.log('[stx] Suspense runtime initialized');
|
|
339
339
|
})();
|
|
340
340
|
`}
|
|
341
|
-
export{
|
|
341
|
+
export{kd,_d,Cd,Ed,Td};
|
|
@@ -45,12 +45,12 @@ var p=0;function f(){return`stx-teleport-${++p}`}function g(t){let e=t.split(","
|
|
|
45
45
|
});
|
|
46
46
|
})();
|
|
47
47
|
</script>
|
|
48
|
-
`}function
|
|
48
|
+
`}function md(t,e,l){p=0;let o=/@teleport\s*\(([^)]+)\)\s*([\s\S]*?)@endteleport/g;return t.replace(o,(r,s,d)=>{let a=f(),{target:u,disabled:n}=g(s),c=d.trim();if(n)try{let i=!1;if(n==="true")i=!0;else if(n==="false")i=!1;else if(n in e)i=Boolean(e[n]);if(i)return`<div class="stx-teleport-inline" data-teleport-disabled>${c}</div>`}catch{}let m=h(a,u);return`
|
|
49
49
|
<div id="${a}" class="stx-teleport-source" style="display: none;">
|
|
50
50
|
<template>${c}</template>
|
|
51
51
|
</div>
|
|
52
52
|
${m}
|
|
53
|
-
`})}function
|
|
53
|
+
`})}function hd(){return`
|
|
54
54
|
<script>
|
|
55
55
|
(function() {
|
|
56
56
|
// Common teleport targets
|
|
@@ -68,4 +68,4 @@ var p=0;function f(){return`stx-teleport-${++p}`}function g(t){let e=t.split(","
|
|
|
68
68
|
})();
|
|
69
69
|
</script>
|
|
70
70
|
`}
|
|
71
|
-
export{
|
|
71
|
+
export{md,hd};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{x}from"./chunk-
|
|
3
|
-
${e.trim()}`)}catch(e){console.warn(`[stx] Failed to load store ${t}:`,e)}if(m.length===0)return
|
|
2
|
+
import{x}from"./chunk-zp79zkkd.js";import{T,vn}from"./chunk-ce6zddpf.js";import{S,X}from"./chunk-f9zyf9n6.js";import{o}from"./chunk-srq9fqq8.js";import{Ce,Xt,Jt,Yt}from"./chunk-rv39s5az.js";import{ht}from"./chunk-40tswfe7.js";import{pt,In,Wt,ie}from"./chunk-0nfqgv4n.js";import{C,br}from"./chunk-506mv7hb.js";import p from"path";var a=new Map;function A(c,n){for(let s of c.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(s[1])n.add(s[1]);for(let s of c.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let i of(s[1]??"").split(",")){let l=((i.includes(":")?i.split(":").pop():i)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(l))n.add(l)}for(let s of c.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let i of(s[1]??"").split(",")){let r=i.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(r))n.add(r)}}async function Fd(c){let n;if(c)n=p.resolve(c);else{let t=await o();n=p.resolve(t.root||process.cwd(),t.storesDir||"stores")}let s=`${n}\x00${Jt()}`,i=new Bun.Glob("*.ts"),r=[];try{for await(let t of i.scan({cwd:n,absolute:!0})){let e=p.basename(t,".ts");if(["index","types"].includes(e))continue;if(t.includes(".d.ts"))continue;r.push(t)}}catch{return ie(a,s,"",""),null}let l=()=>[...new Set([...r,...r.flatMap((t)=>Ce(t))])],f=pt(l()),d=Wt(a,s,f);if(d!==void 0)return d||null;if(r.length===0)return ie(a,s,f,""),null;let u=[];for(let t of r){let e=await Bun.file(t).text();u.push({file:t,hasUseStore:/useStore\s*\(/.test(e)})}u.sort((t,e)=>{if(t.hasUseStore===e.hasUseStore)return 0;return t.hasUseStore?1:-1});let y=u.map((t)=>t.file),m=[],g=new Set,v=X({loader:"ts",target:"browser",define:S()});for(let t of y)try{let e=await Bun.file(t).text(),_=p.basename(t,".ts");if(A(e,g),Xt(e))e=await Yt(e,t,{projectRoot:process.cwd(),externalizeUserModules:C()});e=ht(e),e=T(e),e=vn(e),e=e.replace(/^export\s+(default\s+)?/gm,""),e=v.transformSync(e),m.push(`// Store: ${_}
|
|
3
|
+
${e.trim()}`)}catch(e){console.warn(`[stx] Failed to load store ${t}:`,e)}if(m.length===0)return ie(a,s,f,""),null;let h=m.join(`
|
|
4
4
|
|
|
5
5
|
`),w=`;(function(){
|
|
6
6
|
var __stx = window.stx || {};
|
|
7
7
|
${x.filter((t)=>!g.has(t)&&new RegExp(`\\b${t}\\b`).test(h)).map((t)=>`var ${t} = __stx[${JSON.stringify(t)}];`).join(`
|
|
8
8
|
`)}
|
|
9
9
|
${h}
|
|
10
|
-
})();`,b=C()?
|
|
11
|
-
export{
|
|
10
|
+
})();`,b=C()?br(w):w;return f=pt(l()),ie(a,s,f,b),b}function zd(){a.clear(),In()}
|
|
11
|
+
export{Fd,zd};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{$u}from"./chunk-fb7t1nn9.js";import"./chunk-aet1pgw7.js";import"./chunk-kdebh22m.js";import"./chunk-rr527jt6.js";import"./chunk-xcsyqwxf.js";import"./chunk-bkkpq8dx.js";import"./chunk-7j1zgrnf.js";import"./chunk-v6peecfp.js";import"./chunk-40tswfe7.js";import"./chunk-twqzn21x.js";import"./chunk-hgry3mjd.js";import"./chunk-4b9s7wgy.js";import"./chunk-srq9fqq8.js";import"./chunk-rym0309c.js";import"./chunk-7adznted.js";import"./chunk-am2w363p.js";import"./chunk-5qtthtg3.js";import"./chunk-4s8zacxg.js";import"./chunk-f9zyf9n6.js";import"./chunk-mwnhdsbp.js";import"./chunk-25zmy8q6.js";import"./chunk-bsajk82t.js";import"./chunk-ce6zddpf.js";import"./chunk-zp79zkkd.js";export{$u as startInteractive};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{g,Io,Ua,Wa,Jl,Yl,Zl,Ql,eu,hs,tu,De,X,Me,nu,ur,ru,Ka,Mo,Le,n,pn,Xa,m,pe,Ap}from"./chunk-f9zyf9n6.js";import"./chunk-mwnhdsbp.js";import"./chunk-25zmy8q6.js";import"./chunk-bsajk82t.js";import"./chunk-ce6zddpf.js";import"./chunk-zp79zkkd.js";export{pe as clearComponentCache,Mo as componentClientSignalNames,Io as convertToCommonJS,m as createDetailedErrorMessage,eu as extractDirectiveNames,Ua as extractScriptFromTemplate,g as extractVariables,n as fileExists,Ap as getComponentCacheStats,Yl as getPositionInfo,X as getSharedTranspiler,Xa as getSourceLineInfo,Ql as hasDirectives,Wa as hasVariables,ru as isHydrateTrigger,tu as isJavaScriptScript,Le as renderComponentWithSlot,pn as resolveTemplatePath,nu as scopeOnRootElement,hs as scopeSequenceKey,De as shouldTranspileTypeScript,Ka as slotContentHasExpressions,Me as transpileTypeScript,ur as userComponentFileExists,Zl as validateDirective,Jl as validateTemplate};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{_c,xi,Cc,Ec,Si,Tc,$c,Rc,Ac,ki,Pc,Iu}from"./chunk-qz5b8ed4.js";import{Oi,Lc}from"./chunk-fw413k9q.js";import{Y,Z,Q,Cn,fe,_e,Ar,dt,Ut,En,Tn,$n,ee,Rn,An,Pr}from"./chunk-t79jfpv6.js";import{il}from"./chunk-w3d98907.js";import"./chunk-a4p18ybc.js";export{Z as DEFAULT_FORMATS,Q as DEFAULT_QUALITY,Y as DEFAULT_WIDTHS,Pr as ImageProcessingError,Ec as clearImageCache,Si as createImageDirective,Lc as createImageHandler,$c as createImagePlugin,Iu as defaultImageConfig,An as formatSize,ki as generateImageManifest,Ut as generateSizes,dt as generateSrcSet,En as getFallbackVariant,Ar as getImageMetadata,ee as getMimeType,Rn as getTotalSize,Tn as groupVariantsByFormat,Oi as handleImageRequest,Tc as imageDirective,fe as isImageBackendAvailable,$n as isImageFile,Cn as isSharpAvailable,Ac as optimizeDirectory,Rc as optimizeImage,xi as parseImageComponent,_e as processImage,Cc as processImageComponents,_c as renderImageComponent,il as rewriteImagesWithSiblings,Pc as writeImageManifest};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ic,_i,Ou,Oc,Nc,Nu,Du}from"./chunk-fbmth6xv.js";import"./chunk-hsmcbh0p.js";import"./chunk-rv39s5az.js";import"./chunk-hz4x7h0n.js";import"./chunk-md2jn67b.js";import"./chunk-40tswfe7.js";import"./chunk-twqzn21x.js";import"./chunk-hgry3mjd.js";import"./chunk-srq9fqq8.js";import"./chunk-rym0309c.js";import"./chunk-7adznted.js";import"./chunk-am2w363p.js";import"./chunk-5qtthtg3.js";import"./chunk-4s8zacxg.js";import{$t,zl}from"./chunk-f9zyf9n6.js";import"./chunk-mwnhdsbp.js";import"./chunk-25zmy8q6.js";import"./chunk-bsajk82t.js";import"./chunk-ce6zddpf.js";import"./chunk-zp79zkkd.js";export{Ic as buildVirtualSource,$t as extractScriptBlocks,zl as extractTemplateExpressions,Oc as findRuntimeTypeDeclarations,Nc as findStxModuleDeclarations,Du as formatTypecheckDiagnostics,Ou as sourcePathFor,Nu as typecheckStxFiles,_i as virtualPathFor};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Y,Z,Q,Cn,fe,_e,dt,Ut,En,Tn,$n,ee,Rn,An}from"./chunk-t79jfpv6.js";import{bt}from"./chunk-3hxd5td3.js";function _c(s,r={}){let{src:e,alt:t,width:n,height:a,sizes:i="100vw",loading:m="lazy",priority:o=!1,quality:u=Q,placeholder:l="none",formats:f=Z,widths:y=Y,decoding:c="async",fetchpriority:h,objectFit:d,objectPosition:g}=s,{class:p,style:v}=s,{processedImage:w,variants:I,optimize:b=!0,isDev:A=!1}=r;if(I&&I.length>0)return G(s,I,w);if(A||!b)return X(s);return te(s)}function G(s,r,e){let{src:t,alt:n,width:a,height:i,sizes:m="100vw",loading:o="lazy",priority:u=!1,decoding:l="async",fetchpriority:f,objectFit:y,objectPosition:c,placeholder:h="none"}=s,{class:d,style:g}=s,p=Tn(r),v=En(r),w=typeof m==="object"?Ut(m):m,I=e?e.aspectRatio:a&&i?Number(a)/Number(i):void 0,b=[];if(I)b.push(`aspect-ratio: ${I}`);if(y)b.push(`object-fit: ${y}`);if(c)b.push(`object-position: ${c}`);if(g)b.push(g);let A=b.length>0?` style="${b.join("; ")}"`:"",S=d?` class="${d}"`:"",F=u?"":` loading="${o}"`,R=` decoding="${l}"`,C=f?` fetchpriority="${f}"`:u?' fetchpriority="high"':"",E=["avif","webp","jpeg","png"],M=[];for(let k of E){let z=p.get(k);if(z&&z.length>0){let O=dt(z),K=ee(k);M.push(` <source type="${K}" srcset="${O}" sizes="${w}" />`)}}let U="",L="",T;if(h!=="none"&&e?.placeholder){let k=`img-${Math.random().toString(36).slice(2,8)}`;if(U=`<div class="stx-image-wrapper" id="${k}">`,L="</div>",h==="blur")T=`
|
|
3
3
|
#${k} {
|
|
4
4
|
position: relative;
|
|
5
5
|
background-image: url('${e.placeholder}');
|
|
@@ -16,21 +16,21 @@ import{X,J,Y,Cn,pe,_e,dt,Ut,En,Tn,$n,Z,Rn,An}from"./chunk-b823zxq6.js";import{bt
|
|
|
16
16
|
#${k} {
|
|
17
17
|
background-color: ${e.placeholder};
|
|
18
18
|
}
|
|
19
|
-
`.trim()}let _=a?` width="${a}"`:e?` width="${e.width}"`:"",H=i?` height="${i}"`:e?` height="${e.height}"`:"",
|
|
19
|
+
`.trim()}let _=a?` width="${a}"`:e?` width="${e.width}"`:"",H=i?` height="${i}"`:e?` height="${e.height}"`:"",J=`${U}<picture>
|
|
20
20
|
${M.join(`
|
|
21
21
|
`)}
|
|
22
22
|
<img
|
|
23
23
|
src="${v?.url||t}"
|
|
24
24
|
alt="${B(n)}"${_}${H}${S}${A}${F}${R}${C}
|
|
25
25
|
/>
|
|
26
|
-
</picture>${L}`,V;if(u&&v){let k=p.get("webp"),z=k?.[Math.floor(k.length/2)]||v,O=
|
|
26
|
+
</picture>${L}`,V;if(u&&v){let k=p.get("webp"),z=k?.[Math.floor(k.length/2)]||v,O=ee(z.format);V=`<link rel="preload" as="image" href="${z.url}" type="${O}" />`}return{html:J,preloadLink:V,placeholderCss:T}}function X(s){let{src:r,alt:e,width:t,height:n,loading:a="lazy",decoding:i="async",priority:m=!1,fetchpriority:o,objectFit:u,objectPosition:l}=s,{class:f,style:y}=s,c=[];if(u)c.push(`object-fit: ${u}`);if(l)c.push(`object-position: ${l}`);if(y)c.push(y);let h=c.length>0?` style="${c.join("; ")}"`:"",d=f?` class="${f}"`:"",g=t?` width="${t}"`:"",p=n?` height="${n}"`:"",v=m?"":` loading="${a}"`,w=` decoding="${i}"`,I=o?` fetchpriority="${o}"`:m?' fetchpriority="high"':"";return{html:`<img src="${r}" alt="${B(e)}"${g}${p}${d}${h}${v}${w}${I} />`}}function te(s){let{src:r,alt:e,width:t,height:n,sizes:a="100vw",loading:i="lazy",priority:m=!1,quality:o=Q,formats:u=Z,widths:l=Y,decoding:f="async",fetchpriority:y,objectFit:c,objectPosition:h}=s,{class:d,style:g}=s,p=[];if(c)p.push(`object-fit: ${c}`);if(h)p.push(`object-position: ${h}`);if(g)p.push(g);let v=p.length>0?` style="${p.join("; ")}"`:"",w=d?` class="${d}"`:"",I=t?` width="${t}"`:"",b=n?` height="${n}"`:"",A=m?"":` loading="${i}"`,S=` decoding="${f}"`,F=y?` fetchpriority="${y}"`:m?' fetchpriority="high"':"",R=typeof a==="object"?Ut(a):a,C=`
|
|
27
27
|
data-stx-image
|
|
28
28
|
data-src="${r}"
|
|
29
29
|
data-sizes="${R}"
|
|
30
30
|
data-quality="${o}"
|
|
31
31
|
data-formats="${u.join(",")}"
|
|
32
32
|
data-widths="${l.join(",")}"
|
|
33
|
-
`.replace(/\s+/g," ").trim();return{html:`<img src="${r}" alt="${B(e)}"${I}${b}${w}${v}${A}${S}${F} ${C} />`}}function
|
|
33
|
+
`.replace(/\s+/g," ").trim();return{html:`<img src="${r}" alt="${B(e)}"${I}${b}${w}${v}${A}${S}${F} ${C} />`}}function xi(s){let r=s.match(/<Image\s+([^>]*?)\/?>/);if(!r)return null;let e=r[1],t={},n=/(\w+)(?:=(?:"([^"]*)"|'([^']*)'|(\{[^}]+\})))?/g,a;while((a=n.exec(e))!==null){let[,i,m,o,u]=a,l=m??o??u??!0;switch(i){case"src":t.src=String(l);break;case"alt":t.alt=String(l);break;case"width":t.width=Number(l)||l;break;case"height":t.height=Number(l)||l;break;case"sizes":t.sizes=String(l);break;case"loading":t.loading=l;break;case"priority":t.priority=l===!0||l==="true";break;case"quality":t.quality=Number(l);break;case"placeholder":t.placeholder=l;break;case"class":t.class=String(l);break;case"style":t.style=String(l);break;case"decoding":t.decoding=l;break;case"fetchpriority":t.fetchpriority=l;break;case"objectFit":t.objectFit=l;break;case"objectPosition":t.objectPosition=String(l);break}}if(!t.src||!t.alt)return null;return t}async function Cc(s,r){let e=/<Image\s+[^>]*?\/?>/g,t=[],n=[],a=s,i,m=[];while((i=e.exec(s))!==null)m.push({match:i[0],index:i.index});for(let o=m.length-1;o>=0;o--){let{match:u}=m[o],l=xi(u);if(l){let f=await r(l);if(a=a.replace(u,f.html),f.preloadLink)t.push(f.preloadLink);if(f.placeholderCss)n.push(f.placeholderCss)}}return{html:a,preloadLinks:t,styles:n}}function B(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var D=new Map;function Ec(){D.clear()}async function se(s,r){let e=`${s}:${JSON.stringify(r)}`;if(D.has(e))return D.get(e);try{let t=await _e(s,r);return D.set(e,t),t}catch{return null}}function Si(){return bt({name:"image",hasEndTag:!1,description:"Render an optimized image with responsive variants",transform:async(s,r,e)=>{let{src:t,alt:n,options:a}=re(s,r,e);if(!t)return console.warn("@image directive: missing src argument"),"<!-- @image: missing src -->";let i={widths:a.widths||(a.width?[a.width]:Y),formats:a.formats||Z,quality:a.quality||Q,placeholder:(a.placeholder==="color"?"dominant-color":a.placeholder)||"none"};if(!await fe())return q(t,n||"",a);let o=await se(t,i);if(!o)return q(t,n||"",a);return ie(o,n||"",a)}})}function re(s,r,e){if(r.src)return{src:String(r.src),alt:String(r.alt||""),options:r.options||{}};let n=s.trim();if(n.startsWith("@image(")||n.startsWith("("))n=n.replace(/^@image\(/,"").replace(/^\(/,"").replace(/\)$/,"");let a=ae(n),i=a[0]||"",m=a[1]||"",o={};if(i&&!i.startsWith("/")&&!i.startsWith(".")&&!i.startsWith("http")){let u=e[i];if(typeof u==="string")i=u}if(a[2])try{if(typeof a[2]==="string")o=JSON.parse(a[2]);else o=a[2]}catch{}return{src:i,alt:m,options:o}}function ae(s){let r=[],e="",t=!1,n="",a=0,i=0;for(let m=0;m<s.length;m++){let o=s[m],u=m>0?s[m-1]:"";if((o==='"'||o==="'")&&u!=="\\"){if(!t)t=!0,n=o;else if(o===n)t=!1,n="";else e+=o;continue}if(!t){if(o==="{")a++;if(o==="}")a--;if(o==="[")i++;if(o==="]")i--;if(o===","&&a===0&&i===0){r.push(e.trim()),e="";continue}}e+=o}if(e.trim())r.push(e.trim());return r}function q(s,r,e){let t=[`src="${x(s)}"`];if(r)t.push(`alt="${x(r)}"`);if(e.width)t.push(`width="${e.width}"`);if(e.height)t.push(`height="${e.height}"`);if(e.class)t.push(`class="${x(e.class)}"`);if(e.style)t.push(`style="${x(e.style)}"`);if(e.lazy!==!1)t.push('loading="lazy"');return t.push('decoding="async"'),`<img ${t.join(" ")} />`}function ie(s,r,e){let{variants:t,placeholder:n,width:a,height:i,aspectRatio:m}=s,o=new Map;for(let g of t){let p=o.get(g.format)||[];p.push(g),o.set(g.format,p)}let u=["avif","webp","jpeg","png"],l=[];for(let g of u){let p=o.get(g);if(p&&p.length>0){let v=dt(p),w=ee(g),I=e.sizes||"100vw";l.push(` <source type="${w}" srcset="${x(v)}" sizes="${x(I)}" />`)}}let f=o.get("jpeg")||[],y=f.length>0?f[Math.floor(f.length/2)]:t[Math.floor(t.length/2)],c=[`src="${y?.url||s.src}"`,`alt="${x(r)}"`];if(e.width||a)c.push(`width="${e.width||a}"`);if(e.height||i)c.push(`height="${e.height||i}"`);if(e.class)c.push(`class="${x(e.class)}"`);let h=[];if(m)h.push(`aspect-ratio: ${m.toFixed(4)}`);if(e.style)h.push(e.style);if(h.length>0)c.push(`style="${h.join("; ")}"`);if(e.lazy!==!1&&!e.priority)c.push('loading="lazy"');if(c.push('decoding="async"'),e.priority)c.push('fetchpriority="high"');let d=`<picture>
|
|
34
34
|
`;if(d+=l.join(`
|
|
35
35
|
`)+`
|
|
36
36
|
`,d+=` <img ${c.join(" ")} />
|
|
@@ -38,6 +38,6 @@ ${M.join(`
|
|
|
38
38
|
${d}
|
|
39
39
|
</div>`}else if(e.placeholder==="color"){let p=n.replace(/[^a-zA-Z0-9#(),.\s%-]/g,"");d=`<div id="${g}" class="stx-image-placeholder" style="background-color: ${p};">
|
|
40
40
|
${d}
|
|
41
|
-
</div>`}}if(e.priority&&y){let g=
|
|
42
|
-
`+d}return d}function x(s){return s.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}var
|
|
43
|
-
export{
|
|
41
|
+
</div>`}}if(e.priority&&y){let g=ee(y.format);d=`<link rel="preload" as="image" href="${x(y.url)}" type="${g}" />
|
|
42
|
+
`+d}return d}function x(s){return s.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}var Tc=Si();import P from"fs";import j from"path";function $c(s={}){let{inputDirs:r=["public","src/assets","assets"],outputDir:e="dist/images",baseUrl:t="/images",formats:n=Z,widths:a=Y,quality:i=Q,placeholder:m="none",concurrency:o=4,cache:u=!0,cacheDir:l=".stx/image-cache",referencedOnly:f=!1,verbose:y=!1}=s,c={imageReferences:new Set,processedImages:new Map,stats:{totalImages:0,optimizedImages:0,savedBytes:0,variants:0}};return{name:"stx-image-optimization",async setup(h){if(!await fe()){console.warn("[stx-images] no image backend available, optimization disabled");return}if(u)await P.promises.mkdir(l,{recursive:!0});if(y){let g=await Cn();console.log("[stx-images] Plugin initialized"),console.log(` Backend: ${g?"sharp (native fast path) + ts-images":"ts-images (pure TS)"}`),console.log(` Input dirs: ${r.join(", ")}`),console.log(` Output dir: ${e}`),console.log(` Formats: ${n.join(", ")}`),console.log(` Widths: ${a.join(", ")}`)}},async buildStart(){c.imageReferences.clear(),c.processedImages.clear(),c.stats={totalImages:0,optimizedImages:0,savedBytes:0,variants:0}},async transform(h,d){if(d.endsWith(".html")||d.endsWith(".stx")){let g=ne(h);for(let p of g)c.imageReferences.add(p)}if(h.includes("<Image")||h.includes("@image"))return await ce(h,{formats:n,widths:a,quality:i,placeholder:m,outputDir:e,baseUrl:t,processedImages:c.processedImages});return h},async buildEnd(h){if(!await fe())return;await P.promises.mkdir(e,{recursive:!0});let g=[];for(let w of r){if(!P.existsSync(w))continue;let I=await N(w);g.push(...I)}let p=f?g.filter((w)=>oe(w,c.imageReferences)):g;if(c.stats.totalImages=p.length,y)console.log(`[stx-images] Processing ${p.length} images...`);let v=W(p,o);for(let w of v)await Promise.all(w.map(async(I)=>{try{let b=await _e(I,{formats:n,widths:a,quality:i,placeholder:m,outputDir:e,baseUrl:t});c.processedImages.set(I,b),c.stats.optimizedImages++,c.stats.variants+=b.variants.length;let A=P.statSync(I).size,S=Rn(b.variants);if(c.stats.savedBytes+=Math.max(0,A-S/b.variants.length),y)console.log(` \u2713 ${j.basename(I)} \u2192 ${b.variants.length} variants`)}catch(b){console.error(`[stx-images] Error processing ${I}:`,b)}}));if(console.log("[stx-images] Optimization complete:"),console.log(` Images: ${c.stats.optimizedImages}/${c.stats.totalImages}`),console.log(` Variants: ${c.stats.variants}`),c.stats.savedBytes>0)console.log(` Saved: ~${An(c.stats.savedBytes)}`)}}}function ne(s){let r=[],e=/src=["']([^"']+\.(jpg|jpeg|png|webp|avif|gif))["']/gi,t;while((t=e.exec(s))!==null)r.push(t[1]);let n=/<Image[^>]+src=["']([^"']+)["']/gi;while((t=n.exec(s))!==null)r.push(t[1]);let a=/@image\s*\(\s*['"]([^'"]+)['"]/gi;while((t=a.exec(s))!==null)r.push(t[1]);let i=/background(?:-image)?:\s*url\(["']?([^"')]+\.(jpg|jpeg|png|webp|avif|gif))["']?\)/gi;while((t=i.exec(s))!==null)r.push(t[1]);return r}function oe(s,r){let e=j.basename(s);for(let t of r)if(t.endsWith(e)||t.includes(e))return!0;return!1}async function ce(s,r){return s}async function N(s){let r=[];async function e(t){let n=await P.promises.readdir(t,{withFileTypes:!0});for(let a of n){let i=j.join(t,a.name);if(a.isDirectory())await e(i);else if(a.isFile()&&$n(i))r.push(i)}}return await e(s),r}function W(s,r){let e=[];for(let t=0;t<s.length;t+=r)e.push(s.slice(t,t+r));return e}async function Rc(s,r,e={}){if(!await fe())throw Error("No image backend available \u2014 install sharp or ensure ts-images is bundled");return _e(s,{...e,outputDir:r})}async function Ac(s,r,e={}){let{formats:t=Z,widths:n=Y,quality:a=Q,placeholder:i="none",concurrency:m=4,verbose:o=!1}=e;if(!await fe())throw Error("No image backend available \u2014 install sharp or ensure ts-images is bundled");await P.promises.mkdir(r,{recursive:!0});let l=await N(s),f=[],y={totalImages:l.length,optimizedImages:0,savedBytes:0,variants:0},c=W(l,m);for(let h of c){let d=await Promise.all(h.map(async(g)=>{try{let p=await _e(g,{formats:t,widths:n,quality:a,placeholder:i,outputDir:r,baseUrl:"/"});if(y.optimizedImages++,y.variants+=p.variants.length,o)console.log(` \u2713 ${j.basename(g)}`);return p}catch(p){return console.error(`Error processing ${g}:`,p),null}}));f.push(...d.filter((g)=>g!==null))}return{processed:f,stats:y}}function ki(s){let r={};for(let e of s)r[e.src]={variants:e.variants,placeholder:e.placeholder};return r}async function Pc(s,r){let e=ki(s);await Bun.write(r,JSON.stringify(e,null,2))}var Iu={enabled:!0,widths:[320,640,768,1024,1280,1536,1920],formats:["webp","jpeg"],quality:80,devOptimize:!1,cacheDir:".stx/image-cache",placeholder:"none",inputDirs:["public","src/assets","assets"],outputDir:"dist/images",baseUrl:"/images"};
|
|
43
|
+
export{_c,xi,Cc,Ec,Si,Tc,$c,Rc,Ac,ki,Pc,Iu};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import y from"fs";import R from"path";var S="_stx";function F(e){return Bun.hash(e).toString(16).slice(0,8)}function k(e){let t=[],n=(i)=>{for(let s of y.readdirSync(i,{withFileTypes:!0})){let r=R.join(i,s.name);if(s.isDirectory())n(r);else if(s.isFile()&&r.endsWith(".html"))t.push(r)}};if(y.existsSync(e))n(e);return t}var z=[{pattern:/<script\b([^>]*\bdata-stx-runtime\b[^>]*)>([\s\S]*?)<\/script>/gi,prefix:"runtime",extension:"js",contentType:"text/javascript; charset=utf-8",replace:(e)=>`<script data-stx-runtime src="${e}"></script>`},{pattern:/<script\b([^>]*\bdata-stx-router\b[^>]*)>([\s\S]*?)<\/script>/gi,prefix:"router",extension:"js",contentType:"text/javascript; charset=utf-8",replace:(e)=>`<script data-stx-router src="${e}"></script>`},{pattern:/<style\b([^>]*\bdata-css=(?:"generated"|'generated')[^>]*)>([\s\S]*?)<\/style>/gi,prefix:"css",extension:"css",contentType:"text/css; charset=utf-8",replace:(e)=>`<link data-css="generated" rel="stylesheet" href="${e}">`}];function I(e,t=`/${S}`){let n=[],i=new Set,s=0,r=e;for(let o of z)r=r.replace(o.pattern,(g,u,c)=>{if(/\b(?:src|href)\s*=/.test(u)||!c.trim())return g;let a=`${o.prefix}.${F(c)}.${o.extension}`;if(!i.has(a))i.add(a),n.push({filename:a,contents:c,contentType:o.contentType});return s+=c.length,o.replace(`${t}/${a}`)});return{html:r,assets:n,bytesInlined:s}}function
|
|
2
|
+
import y from"fs";import R from"path";var S="_stx";function F(e){return Bun.hash(e).toString(16).slice(0,8)}function k(e){let t=[],n=(i)=>{for(let s of y.readdirSync(i,{withFileTypes:!0})){let r=R.join(i,s.name);if(s.isDirectory())n(r);else if(s.isFile()&&r.endsWith(".html"))t.push(r)}};if(y.existsSync(e))n(e);return t}var z=[{pattern:/<script\b([^>]*\bdata-stx-runtime\b[^>]*)>([\s\S]*?)<\/script>/gi,prefix:"runtime",extension:"js",contentType:"text/javascript; charset=utf-8",replace:(e)=>`<script data-stx-runtime src="${e}"></script>`},{pattern:/<script\b([^>]*\bdata-stx-router\b[^>]*)>([\s\S]*?)<\/script>/gi,prefix:"router",extension:"js",contentType:"text/javascript; charset=utf-8",replace:(e)=>`<script data-stx-router src="${e}"></script>`},{pattern:/<style\b([^>]*\bdata-css=(?:"generated"|'generated')[^>]*)>([\s\S]*?)<\/style>/gi,prefix:"css",extension:"css",contentType:"text/css; charset=utf-8",replace:(e)=>`<link data-css="generated" rel="stylesheet" href="${e}">`}];function I(e,t=`/${S}`){let n=[],i=new Set,s=0,r=e;for(let o of z)r=r.replace(o.pattern,(g,u,c)=>{if(/\b(?:src|href)\s*=/.test(u)||!c.trim())return g;let a=`${o.prefix}.${F(c)}.${o.extension}`;if(!i.has(a))i.add(a),n.push({filename:a,contents:c,contentType:o.contentType});return s+=c.length,o.replace(`${t}/${a}`)});return{html:r,assets:n,bytesInlined:s}}function Yi(e){let t={pages:0,assets:0,bytesInlined:0},n=R.join(e,S),i=new Set;for(let s of k(e)){let r=y.readFileSync(s,"utf8"),{html:o,assets:g,bytesInlined:u}=I(r);if(o===r)continue;for(let c of g){if(i.has(c.filename))continue;i.add(c.filename),y.mkdirSync(n,{recursive:!0}),y.writeFileSync(R.join(n,c.filename),c.contents),t.assets++}y.writeFileSync(s,o),t.bytesInlined+=u,t.pages++}return t}import h from"fs";import T from"path";var L=1024,N=/<(script|style)\b([^>]*)>([\s\S]*?)<\/\1>/gi,_=new Set(["","module","text/javascript","application/javascript","module/javascript"]);function B(e){return Bun.hash(e).toString(16).slice(0,8)}function C(e){let t=[],n=(i)=>{for(let s of h.readdirSync(i,{withFileTypes:!0})){let r=T.join(i,s.name);if(s.isDirectory())n(r);else if(s.isFile()&&r.endsWith(".html"))t.push(r)}};if(h.existsSync(e))n(e);return t}function O(e,t){let n=e.match(new RegExp(`\\b${t}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s>]+))`,"i"));if(!n)return;return n[2]??n[3]??n[4]??""}function H(e,t,n){if(n.length<L)return!1;if(/\b(?:src|href)\s*=/i.test(t))return!1;if(e.toLowerCase()==="script"){if(!_.has((O(t,"type")??"").trim().toLowerCase()))return!1;return!0}return!0}function D(e){let t=[];for(let n of e.matchAll(/<template\b[^>]*>[\s\S]*?<\/template>/gi))t.push([n.index,n.index+n[0].length]);return t}function Zi(e){let t={pages:0,assets:0,bytesInlined:0},n=C(e);if(n.length<2)return t;let i=new Map,s=new Map;for(let a of n){let f=h.readFileSync(a,"utf8");i.set(a,f);let M=D(f);for(let d of f.matchAll(N)){let[x,p,l,m]=d;if(!H(p,l,m))continue;if(M.some(([j,A])=>d.index>=j&&d.index<A))continue;let w=`${p.toLowerCase()}\x00${m}`,b=s.get(w);if(b)b.push({file:a,whole:x,tag:p,attrs:l,body:m});else s.set(w,[{file:a,whole:x,tag:p,attrs:l,body:m}])}}let r=[...s.values()].filter((a)=>new Set(a.map((f)=>f.file)).size>1);if(r.length===0)return t;let o=T.join(e,S),g=new Map(i),u=new Map,c=[];for(let a of r){let{tag:f,body:M}=a[0],d=f.toLowerCase()==="script",x=`${d?"chunk":"style"}.${B(M)}.${d?"js":"css"}`;c.push({filename:x,contents:M,contentType:d?"text/javascript; charset=utf-8":"text/css; charset=utf-8"});let p=`/${S}/${x}`;for(let l of a){let m=d?`<script${l.attrs} src="${p}"></script>`:`<link${l.attrs} rel="stylesheet" href="${p}">`,w=g.get(l.file),b=w.replace(l.whole,()=>m);if(b===w)continue;g.set(l.file,b),u.set(l.file,(u.get(l.file)??0)+l.body.length)}}h.mkdirSync(o,{recursive:!0});for(let a of c)h.writeFileSync(T.join(o,a.filename),a.contents),t.assets++;for(let[a,f]of g){if(f===i.get(a))continue;h.writeFileSync(a,f),t.pages++,t.bytesInlined+=u.get(a)??0}return t}import E from"fs";import v from"path";var K="layout-types.d.ts";function P(e){let t=[],n=(i,s)=>{let r;try{r=E.readdirSync(i,{withFileTypes:!0})}catch{return}for(let o of r){if(o.name.startsWith("."))continue;let g=v.join(i,o.name);if(o.isDirectory())n(g,s?`${s}/${o.name}`:o.name);else if(o.isFile()&&o.name.endsWith(".stx")&&o.name!=="_layout.stx"){let u=o.name.slice(0,-4);t.push(s?`${s}/${u}`:u)}}};return n(e,""),t.sort()}function W(e){let t=["// Auto-generated by stx \u2014 do not edit.","//","// Makes `definePageMeta({ layout })` reject a name with no layout behind it.","// Include this file in your tsconfig (it lives in the stx state directory,","// `.stx/` by default) for the check to apply.",""];if(e.length===0)return t.push("// No layouts found \u2014 `layout` stays typed as `string`.","export {}",""),t.join(`
|
|
3
3
|
`);return t.push("declare module '@stacksjs/stx' {"," interface KnownLayouts {",...e.map((n)=>` '${n}': true`)," }","}","","export {}",""),t.join(`
|
|
4
|
-
`)}function
|
|
5
|
-
export{
|
|
4
|
+
`)}function Qi(e,t){if(!e)return[];let n=v.isAbsolute(e)?e:v.resolve(process.cwd(),e),i=P(n),s=W(i),r=v.join(t,K);try{if(E.existsSync(r)&&E.readFileSync(r,"utf8")===s)return i;E.mkdirSync(t,{recursive:!0}),E.writeFileSync(r,s)}catch{}return i}
|
|
5
|
+
export{Yi,Zi,Qi};
|