@stacksjs/stx 0.2.819 → 0.2.820
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-p7hy0seh.js → chunk-01cwrww2.js} +1 -1
- package/dist/{chunk-nsxjt6h3.js → chunk-06hc6rs6.js} +1 -1
- package/dist/{chunk-skht06a2.js → chunk-076fj387.js} +1 -1
- package/dist/chunk-09285y4b.js +2 -0
- package/dist/chunk-0e0z4ab6.js +2 -0
- package/dist/{chunk-12sd0ep5.js → chunk-0p797a25.js} +15 -15
- package/dist/{chunk-g7mjv276.js → chunk-1f7d1c0y.js} +2 -2
- package/dist/{chunk-brbqz5he.js → chunk-2235krey.js} +13 -13
- package/dist/{chunk-fmawgk87.js → chunk-2nj9aewf.js} +1 -1
- package/dist/{chunk-m7hfcxt3.js → chunk-2vqpz4qv.js} +2 -2
- package/dist/{chunk-dq9djbgq.js → chunk-30rpspzt.js} +4 -4
- package/dist/{chunk-ax16vnn5.js → chunk-36sb6j2v.js} +6 -6
- package/dist/{chunk-1hg0zb3p.js → chunk-3axb6t08.js} +2 -2
- package/dist/chunk-3bf48zrh.js +2 -0
- package/dist/chunk-3kaw5zjm.js +2 -0
- package/dist/chunk-3na8kkec.js +2 -0
- package/dist/{chunk-mr2ke5km.js → chunk-3yh6y00f.js} +6 -6
- package/dist/{chunk-m9dyqae7.js → chunk-3zhwcckc.js} +5 -5
- package/dist/chunk-49hywhze.js +2 -0
- package/dist/{chunk-1a8qtvs1.js → chunk-4mj9dem1.js} +2 -2
- package/dist/chunk-4qsamkyc.js +2 -0
- package/dist/{chunk-rccv14mn.js → chunk-4t4af1mb.js} +5 -5
- package/dist/{chunk-e4d0jgcw.js → chunk-5e88021j.js} +6 -6
- package/dist/{chunk-vmxzktdr.js → chunk-67kbsav0.js} +1 -1
- package/dist/chunk-6h1qa3hw.js +2 -0
- package/dist/{chunk-xc7nynb9.js → chunk-6qvn1h09.js} +3 -3
- package/dist/{chunk-k3t72x38.js → chunk-76eh43e9.js} +2 -2
- package/dist/chunk-77s1kvzj.js +2 -0
- package/dist/chunk-7ffmz1fb.js +2 -0
- package/dist/chunk-7pz76f28.js +2 -0
- package/dist/{chunk-6s9bk98p.js → chunk-7yb82rm6.js} +2 -2
- package/dist/{chunk-72jt897s.js → chunk-8ttmzcxb.js} +12 -12
- package/dist/{chunk-035m9ada.js → chunk-8w9spdbn.js} +4 -4
- package/dist/{chunk-6a0ekt1n.js → chunk-90p175a7.js} +3 -3
- package/dist/chunk-91s9c9wa.js +2 -0
- package/dist/{chunk-e3t2bqyf.js → chunk-9gmceny5.js} +5 -5
- package/dist/chunk-a8fy7jv8.js +2 -0
- package/dist/{chunk-4fbg7gq8.js → chunk-akj26p4b.js} +2 -2
- package/dist/{chunk-93f6kwht.js → chunk-aqh663ef.js} +2 -2
- package/dist/{chunk-1p3vmy65.js → chunk-atszywea.js} +4 -4
- package/dist/chunk-b22yj5j5.js +2 -0
- package/dist/{chunk-b9d70mgr.js → chunk-b4x5ndt9.js} +3 -3
- package/dist/{chunk-j476jghg.js → chunk-b89wsq8r.js} +1 -1
- package/dist/{chunk-zhvmcj78.js → chunk-bfbh0hfn.js} +5 -5
- package/dist/{chunk-cbt1dchd.js → chunk-bfztkcfe.js} +4 -4
- package/dist/{chunk-3dg2zg8d.js → chunk-bkdfkm10.js} +3 -3
- package/dist/{chunk-0rjcbqk3.js → chunk-brhas9mp.js} +2 -2
- package/dist/{chunk-x46hqa74.js → chunk-bsg90smr.js} +4 -4
- package/dist/{chunk-1tzqqr0p.js → chunk-bt0amey5.js} +2 -2
- package/dist/{chunk-1rvgv1fr.js → chunk-btxnrqxf.js} +5 -5
- package/dist/chunk-c1e45rtv.js +2 -0
- package/dist/chunk-cckq47hd.js +2 -0
- package/dist/{chunk-tj6zvs8f.js → chunk-cxz4cdcn.js} +2 -2
- package/dist/{chunk-mbhvf0sv.js → chunk-d6d2s7n6.js} +2 -2
- package/dist/chunk-det3z847.js +2 -0
- package/dist/{chunk-gcje06er.js → chunk-e4jwhmpb.js} +30 -30
- package/dist/chunk-ec2f30f7.js +3 -0
- package/dist/{chunk-ngh1aeff.js → chunk-exghjgzk.js} +4 -4
- package/dist/{chunk-mjg9cx5a.js → chunk-f0txsdpa.js} +3 -3
- package/dist/{chunk-0s93s6ep.js → chunk-ftfjwjes.js} +3 -3
- package/dist/chunk-g8kcg8v2.js +2 -0
- package/dist/chunk-g8nqmnb7.js +2 -0
- package/dist/{chunk-hwcfgs3e.js → chunk-gjf8cjdt.js} +3 -3
- package/dist/{chunk-xka9fdye.js → chunk-gywyr2x3.js} +2 -2
- package/dist/{chunk-p3dc6rg2.js → chunk-h1hm975m.js} +6 -6
- package/dist/chunk-h67pm636.js +2 -0
- package/dist/{chunk-jdddw8en.js → chunk-h7fgk4ew.js} +2 -2
- package/dist/chunk-hb8jxg45.js +2 -0
- package/dist/{chunk-s6mte5vy.js → chunk-hbdzhpy1.js} +4 -4
- package/dist/chunk-he6tejhc.js +2 -0
- package/dist/chunk-hfgzqapw.js +2 -0
- package/dist/chunk-j0hrk24j.js +2 -0
- package/dist/chunk-j2fgv2pe.js +2 -0
- package/dist/{chunk-vhzngsmd.js → chunk-j4cjn4m1.js} +79 -79
- package/dist/{chunk-k3zcadcc.js → chunk-j737tnvt.js} +4 -4
- package/dist/chunk-j79bjm48.js +2 -0
- package/dist/chunk-jjbdtj4w.js +2 -0
- package/dist/{chunk-nqdh7z2d.js → chunk-jzgyrxye.js} +1 -1
- package/dist/{chunk-bnewgd23.js → chunk-k0bztfk3.js} +2 -2
- package/dist/chunk-k0xdvegc.js +2 -0
- package/dist/{chunk-9gwhs0gk.js → chunk-k81trehg.js} +2 -2
- package/dist/chunk-m3wk6b1r.js +2 -0
- package/dist/chunk-m7nsk6fb.js +2 -0
- package/dist/chunk-m934bzg2.js +2 -0
- package/dist/{chunk-znx5m1jv.js → chunk-me6kgvsm.js} +1 -1
- package/dist/chunk-mmeck545.js +2 -0
- package/dist/{chunk-s9b6abkb.js → chunk-mwxbdpb1.js} +2 -2
- package/dist/chunk-mz6qjee1.js +2 -0
- package/dist/chunk-mzvccryg.js +2 -0
- package/dist/chunk-n4pzq9k7.js +2 -0
- package/dist/{chunk-baj6w8ja.js → chunk-n7arptzc.js} +2 -2
- package/dist/{chunk-7c5b0th8.js → chunk-nb5d00dz.js} +10 -10
- package/dist/{chunk-v041eh5f.js → chunk-nype1b17.js} +3 -3
- package/dist/{chunk-1ae3megp.js → chunk-p1fpferp.js} +6 -6
- package/dist/chunk-p6e3zz9e.js +2 -0
- package/dist/{chunk-4gg9594a.js → chunk-p77cnteg.js} +5 -5
- package/dist/chunk-prt4ntb0.js +2 -0
- package/dist/{chunk-sxad7x2s.js → chunk-pvj0bpqg.js} +4 -4
- package/dist/chunk-q5bct2ks.js +2 -0
- package/dist/{chunk-rpen41w3.js → chunk-q7zwv88b.js} +2 -2
- package/dist/{chunk-4jaet63w.js → chunk-qe5h58mx.js} +2 -2
- package/dist/{chunk-gtd6qs1r.js → chunk-qj4r08jb.js} +2 -2
- package/dist/{chunk-sh1hbhhb.js → chunk-qz3fdmrc.js} +3 -3
- package/dist/chunk-r2hjn9ds.js +2 -0
- package/dist/{chunk-he8rmsdq.js → chunk-rm1510e0.js} +12 -12
- package/dist/chunk-rtk813jv.js +2 -0
- package/dist/chunk-s2zsa16d.js +2 -0
- package/dist/chunk-s53hy1gs.js +2 -0
- package/dist/{chunk-ek5ynvqh.js → chunk-sb6jph84.js} +1 -1
- package/dist/chunk-sddp2398.js +2 -0
- package/dist/chunk-sj24g10j.js +2 -0
- package/dist/chunk-sv4emtcj.js +2 -0
- package/dist/chunk-t6y9ar2j.js +2 -0
- package/dist/chunk-t9byym6f.js +2 -0
- package/dist/chunk-t9rj27hc.js +2 -0
- package/dist/chunk-tcyvwy8p.js +2 -0
- package/dist/chunk-tg18j1yf.js +2 -0
- package/dist/chunk-tj7dh2dz.js +2 -0
- package/dist/{chunk-j8r0am39.js → chunk-tksjakyv.js} +1 -1
- package/dist/chunk-vafxrky2.js +2 -0
- package/dist/chunk-vyb4sxh9.js +42 -0
- package/dist/{chunk-6n11z33h.js → chunk-vzbyn4nh.js} +5 -5
- package/dist/chunk-w04h1t4t.js +2 -0
- package/dist/{chunk-gahpv8ce.js → chunk-wc7dn3mr.js} +2 -2
- package/dist/{chunk-f6nk205v.js → chunk-wceg59n0.js} +1 -1
- package/dist/{chunk-t2sg2tp2.js → chunk-wf0n9gpj.js} +4 -4
- package/dist/{chunk-c5vzr1va.js → chunk-wpendr22.js} +2 -2
- package/dist/chunk-wps6y6n5.js +2 -0
- package/dist/{chunk-427mhgje.js → chunk-wy0gghvh.js} +1 -1
- package/dist/chunk-x30gh7vt.js +2 -0
- package/dist/{chunk-m7kct2sg.js → chunk-xc0kwms2.js} +4 -4
- package/dist/{chunk-jw7cakxt.js → chunk-xdbwghty.js} +9 -9
- package/dist/{chunk-em2yy1te.js → chunk-xpy9yjyx.js} +6 -6
- package/dist/{chunk-9egd7tx3.js → chunk-y8p85kcj.js} +2 -2
- package/dist/{chunk-7xs45trj.js → chunk-y9bj3566.js} +2 -2
- package/dist/chunk-ybpysahk.js +2 -0
- package/dist/{chunk-jgj16jmg.js → chunk-ydr5y7va.js} +2 -2
- package/dist/chunk-ytyyfvke.js +2 -0
- package/dist/{chunk-8dmey36n.js → chunk-z23arg8m.js} +2 -2
- package/dist/chunk-z845f18k.js +2 -0
- package/dist/{chunk-e758jz81.js → chunk-zbyfxcrr.js} +6 -6
- package/dist/{chunk-sjd6rt97.js → chunk-zefkd9t8.js} +4 -4
- package/dist/cli.js +19 -19
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/html-masking.d.ts +10 -0
- package/dist/html-masking.js +50 -0
- package/dist/pwa.js +3 -3
- package/dist/server-bindings.js +28 -30
- package/dist/ssg.js +4 -4
- package/package.json +5 -5
- package/dist/chunk-03mtfndv.js +0 -2
- package/dist/chunk-0633xsmx.js +0 -2
- package/dist/chunk-0wrmcexg.js +0 -2
- package/dist/chunk-18qxd18d.js +0 -2
- package/dist/chunk-1cd0w20k.js +0 -2
- package/dist/chunk-2k3ga51z.js +0 -2
- package/dist/chunk-54kn2jtw.js +0 -2
- package/dist/chunk-54mc7876.js +0 -2
- package/dist/chunk-6e76tz09.js +0 -2
- package/dist/chunk-72w08sh9.js +0 -2
- package/dist/chunk-7p7hdn42.js +0 -2
- package/dist/chunk-88mhhbqj.js +0 -2
- package/dist/chunk-9736003n.js +0 -2
- package/dist/chunk-9b52cnzm.js +0 -2
- package/dist/chunk-9bhvh2dc.js +0 -2
- package/dist/chunk-9y1dm510.js +0 -2
- package/dist/chunk-a4yzet7p.js +0 -2
- package/dist/chunk-abzrvxct.js +0 -2
- package/dist/chunk-avbvedyx.js +0 -2
- package/dist/chunk-cvq4bz8y.js +0 -2
- package/dist/chunk-d7p5jr31.js +0 -2
- package/dist/chunk-dh1f8ga0.js +0 -2
- package/dist/chunk-dzp2a775.js +0 -2
- package/dist/chunk-f86ehf7n.js +0 -2
- package/dist/chunk-fn2cqvb1.js +0 -2
- package/dist/chunk-fzj3e3zk.js +0 -2
- package/dist/chunk-gsc617cx.js +0 -2
- package/dist/chunk-h8kbcz9t.js +0 -2
- package/dist/chunk-hx575xy8.js +0 -2
- package/dist/chunk-j58z3y2g.js +0 -2
- package/dist/chunk-j5t40n2g.js +0 -2
- package/dist/chunk-jcz6rd9n.js +0 -2
- package/dist/chunk-k5nd8zqh.js +0 -2
- package/dist/chunk-kz6qw9fm.js +0 -42
- package/dist/chunk-m5cdkb11.js +0 -2
- package/dist/chunk-mcgqgheq.js +0 -2
- package/dist/chunk-mz1mgfq3.js +0 -3
- package/dist/chunk-n1tbc7da.js +0 -2
- package/dist/chunk-n7dm6prj.js +0 -2
- package/dist/chunk-nknpr8cy.js +0 -2
- package/dist/chunk-nqn4dvqd.js +0 -2
- package/dist/chunk-nt5dh56c.js +0 -2
- package/dist/chunk-p04dabqm.js +0 -2
- package/dist/chunk-pe89ztq6.js +0 -2
- package/dist/chunk-pe9npaby.js +0 -2
- package/dist/chunk-pmq2pdr9.js +0 -2
- package/dist/chunk-r2v042ym.js +0 -2
- package/dist/chunk-r3zmbpv2.js +0 -2
- package/dist/chunk-r57s8jqs.js +0 -2
- package/dist/chunk-rjzp7za8.js +0 -2
- package/dist/chunk-sata7rh2.js +0 -2
- package/dist/chunk-tsb5h4e2.js +0 -2
- package/dist/chunk-v7h8vd9n.js +0 -2
- package/dist/chunk-v8h2kns0.js +0 -2
- package/dist/chunk-vvcfrsjg.js +0 -2
- package/dist/chunk-vyw40ym7.js +0 -2
- package/dist/chunk-whq40bdm.js +0 -2
- package/dist/chunk-xsck49x5.js +0 -2
- package/dist/chunk-z0c35c5c.js +0 -2
- package/dist/chunk-zwp7n01x.js +0 -2
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{gl,ml}from"./chunk-bt0amey5.js";import{f,A,st,d}from"./chunk-8ttmzcxb.js";import{V,yr,Os,Ns,oi,ii,Ms,wr,ci,Ne,pe,G,xr,oe,J,O,rt,Sr,ui,Cr,Fe,s,p,U,wn}from"./chunk-j4cjn4m1.js";import{n}from"./chunk-ec2f30f7.js";import{se}from"./chunk-wceg59n0.js";import{r}from"./chunk-b4x5ndt9.js";import{g}from"./chunk-0dve54ne.js";import{createHash as Rt}from"crypto";import Q from"fs";import Z from"path";import{decode as an,generateThumbHash as cn}from"ts-images";import{createImageDeliveryCatalog as bt}from"ts-images/delivery";import je from"fs";function Ce(e,i,t){let o=Buffer.alloc(t),a=je.readSync(e,o,0,t,i);return o.subarray(0,a)}function Me(e){if(e.length<25)return!1;let i=(o,a)=>String.fromCharCode(...e.subarray(o,a));if(i(0,4)!=="RIFF"||i(8,12)!=="WEBP")return!1;let t=i(12,16);if(t==="VP8X")return(e[20]&16)!==0;if(t==="VP8L")return((e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>28&1)===1;return!1}function Le(e){let i;try{i=je.openSync(e,"r");let t=Ce(i,0,33);if(t.length>=3&&t[0]===255&&t[1]===216&&t[2]===255)return"none";if(t.length>=26&&t[0]===137&&t.toString("latin1",1,4)==="PNG"){let o=t[25];if(o===4||o===6)return"possible";let a=8;for(let c=0;c<64;c++){let l=Ce(i,a,8);if(l.length<8)return"unknown";let m=l.toString("latin1",4,8);if(m==="tRNS")return"possible";if(m==="IDAT"||m==="IEND")return"none";a+=12+l.readUInt32BE(0)}return"unknown"}if(t.length>=25&&t.toString("latin1",0,4)==="RIFF"&&t.toString("latin1",8,12)==="WEBP"){if(Me(t))return"possible";let o=t.toString("latin1",12,16);return o==="VP8 "||o==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(i!==void 0)je.closeSync(i)}}import Qt from"fs";import Re from"os";import{join as gt}from"path";import{fileURLToPath as mt}from"url";import{Worker as pt}from"worker_threads";var ke=Symbol("stx.image-worker.unavailable");function en(e=typeof Re.availableParallelism==="function"?Re.availableParallelism():Re.cpus().length){return Math.max(1,Math.min(2,e-1))}var Ae=0,yt=[];async function tn(){if(Ae<en()){Ae++;return}await new Promise((e)=>yt.push(e)),Ae++}function nn(){Ae--,yt.shift()?.()}var rn="@stacksjs/stx/builtins/image-warmup-worker";function sn(e=process.cwd()){let i=import.meta.url.endsWith(".ts")?"ts":"js";try{let t=new URL(`./image-warmup-worker.${i}`,import.meta.url);if(t.protocol==="file:"&&Qt.existsSync(mt(t)))return mt(t)}catch{}try{let t=typeof Bun<"u"?Bun.resolveSync(rn,e):void 0;return t&&on(t)?t:void 0}catch{return}}function on(e,i=process.env){let t=e.replace(/\\/g,"/");if(t.split("/").some((a)=>/@\d[^/]*@@@\d+$/.test(a)))return!1;return![i.BUN_INSTALL_CACHE_DIR,gt(i.BUN_INSTALL||gt(Re.homedir(),".bun"),"install","cache")].filter((a)=>!!a).map((a)=>`${a.replace(/\\/g,"/").replace(/\/$/,"")}/`).some((a)=>t.startsWith(a))}var ht=!1;function he(e){if(!ht)ht=!0,console.warn(`[stx] image worker unavailable (${e}); running the image pass on the serving thread instead. Results are the same, but requests may stall while it runs.`);return ke}function ze(e){return e instanceof Error?e.message:String(e)}async function Ue(e,i){if(typeof pt!=="function")return he("node:worker_threads has no Worker in this runtime");let t=sn();if(!t)return he("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await tn();try{return await new Promise((o,a)=>{let c;try{c=new pt(t)}catch(y){o(he(`could not start ${t}: ${ze(y)}`));return}let l=!1,m=!1,u=(y)=>{if(m)return;m=!0,y(),c.terminate()};c.on("message",(y)=>{if(y.type==="ready"){l=!0,c.postMessage({task:e,args:i});return}if(y.type==="result"){u(()=>o(y.value));return}let S=Error(y.error?.message??"image worker failed");if(y.error?.name)S.name=y.error.name;if(y.error?.stack)S.stack=y.error.stack;u(()=>a(S))}),c.on("error",(y)=>{u(()=>l?a(y instanceof Error?y:Error(ze(y)||"image worker crashed")):o(he(`the worker failed before it was ready: ${ze(y)}`)))}),c.on("exit",(y)=>{u(()=>l?a(Error("image worker exited before it finished")):o(he(`the worker exited with code ${y} before it was ready`)))})})}finally{nn()}}var ln=new Set([".avif",".jpeg",".jpg",".png",".webp"]),un=[320,640,960,1280,1920],ye="/_stx/images",fn=`stx:${ye}:alpha-1`,dn=`stx:${ye}:opaque-1`,gn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Pe;function mn(e,i){let t=Z.dirname(Bun.resolveSync(e,i));while(t!==Z.dirname(t)){let o=Z.join(t,"package.json");if(Q.existsSync(o)){let a=JSON.parse(Q.readFileSync(o,"utf8"));if(a.name===e)return a.version}t=Z.dirname(t)}return}function vt(){if(Pe!==void 0)return Pe;let e;try{e=Z.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Pe=gn.map((i)=>{let t;try{t=e?mn(i,e):void 0}catch{}return`${i.replace("@stacksjs/","")}@${t??"unknown"}`}).join("+"),Pe}var xt=Symbol.for("stx.image-delivery");function be(){let e=globalThis;return e[xt]??={catalog:new Map,transparent:new Set},e[xt]}var wt=new Set;function pn(e){return`/${e.split(Z.sep).map(encodeURIComponent).join("/")}`}function hn(e){let i=Z.extname(e),t=e.slice(0,-i.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),o=Rt("sha256").update(e).digest("hex").slice(0,8);return`${t||"image"}-${o}`}function $t(e,i=`stx:${ye}`){let t=(o)=>`${ye}/${o.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:i,async stat(o){let a=Z.join(e,o);try{let c=await Q.promises.stat(a);return c.size>0?{bytes:c.size,path:a,url:t(o)}:null}catch{return null}},async write(o,a){let c=Z.join(e,o);await Q.promises.mkdir(Z.dirname(c),{recursive:!0});let l=`${c}.${process.pid}.tmp`;return await Q.promises.writeFile(l,a),await Q.promises.rename(l,c),{bytes:a.byteLength,path:c,url:t(o)}},url:t}}async function At(e,i=e){let t=await Q.promises.readdir(i,{withFileTypes:!0});t.sort((a,c)=>a.name.localeCompare(c.name));let o=[];for(let a of t){let c=Z.join(i,a.name);if(a.isDirectory()){o.push(...await At(e,c));continue}if(!a.isFile()||!ln.has(Z.extname(a.name).toLowerCase()))continue;o.push({absolutePath:c,relativePath:Z.relative(e,c)})}return o}function St(e,i){return e.map((t)=>({key:pn(t.relativePath),input:t.absolutePath,name:hn(t.relativePath),...yn(t.absolutePath)?{options:{storage:i}}:{}}))}function yn(e){return Le(e)==="possible"}function bn(e){for(let i=3;i<e.length;i+=4)if(e[i]!==255)return!0;return!1}async function vn(e){let i=Object.entries(e).filter(([,a])=>a.fallback.format==="png"),t=new Set,o=8;for(let a=0;a<i.length;a+=8)await Promise.all(i.slice(a,a+8).map(async([c,l])=>{let m=l.variants.filter((u)=>u.format==="png").sort((u,y)=>u.width-y.width)[0];try{let u=await an(new Uint8Array(await Q.promises.readFile(m?.path??l.fallback.path)));if(bn(u.data))t.add(c)}catch{t.add(c)}}));return t}function xn(e,i){let t=[];for(let o of i){let a=e[o],c=a?.variants.filter((m)=>m.format==="webp")??[];if(!a||c.length===0)continue;if(!c.some((m)=>{let u;try{return u=Q.openSync(m.path,"r"),!Me(Ce(u,0,32))}catch{return!0}finally{if(u!==void 0)Q.closeSync(u)}}))continue;if(a.variants=a.variants.filter((m)=>m.format!=="webp"),delete a.sources.webp,t.push(o),!wt.has(o))wt.add(o),console.warn(`[stx-images] ${o} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return t}async function $n(e){let i=[],t=8;for(let o=0;o<e.length;o+=8){let a=e.slice(o,o+8),c=await Promise.all(a.map(async(l)=>{try{return await cn(l.absolutePath),l}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${l.relativePath}`),null}}));i.push(...c.filter((l)=>l!==null))}return i}function We(e){return Z.join(e,"undecodable.json")}function Sn(e){try{let i=Q.readFileSync(We(e),"utf-8"),t=JSON.parse(i);return t&&typeof t==="object"?t:{}}catch{return{}}}function Cn(e,i){try{Q.mkdirSync(Z.dirname(We(e)),{recursive:!0}),Q.writeFileSync(We(e),JSON.stringify(i))}catch{}}function Ct(e){try{let i=Q.statSync(e);return{mtimeMs:i.mtimeMs,size:i.size}}catch{return}}function kt(e){if(!e||e.startsWith("data:")||e.startsWith("blob:")||/^https?:\/\//i.test(e)||e.startsWith("//"))return;let i=e.split(/[?#]/,1)[0];if(!i)return;try{return`/${i.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function Lo(e){let i=kt(e);return i?be().catalog.get(i):void 0}function jo(e){let i=kt(e);return i?be().transparent.has(i):!1}function Bo(e){let i=(o)=>e.variants.filter((a)=>a.format===o).reduce((a,c)=>a+c.bytes,0),t=i(e.fallback.format);return["avif","webp"].map((o)=>({format:o,srcset:e.sources[o]||"",bytes:i(o)})).filter((o)=>o.srcset&&o.bytes>0&&o.bytes<t).sort((o,a)=>o.bytes-a.bytes).map(({format:o,srcset:a})=>({format:o,srcset:a}))}function Ih(e){let i=Lo(e);if(!i)return;return{src:i.fallback.url,srcset:i.sources[i.fallback.format]||"",sources:Bo(i).map(({format:t,srcset:o})=>({type:`image/${t}`,srcset:o})),width:i.source.width,height:i.source.height,placeholder:jo(e)?void 0:i.placeholder?.dataUrl}}function ls(){let e=be();e.catalog=new Map,e.transparent=new Set}function Rn(e){let i=be();i.catalog=new Map(e.entries),i.transparent=new Set(e.transparent)}async function Oh(e,i,t={}){if(!e||!Q.existsSync(e))return ls(),{count:0,fingerprint:""};if(t.offThread){let v=await Ue("delivery",{publicDir:e,outputDir:i});if(v!==ke)return Rn(v.state),v.result}let o=await At(e);if(o.length===0)return ls(),{count:0,fingerprint:""};let a=Sn(i),c=o.filter((v)=>{let b=a[v.relativePath];if(!b)return!0;let w=Ct(v.absolutePath);return!w||w.mtimeMs!==b.mtimeMs||w.size!==b.size});if(c.length===0)return ls(),{count:0,fingerprint:""};let l=$t(Z.join(i,"_stx","images"),`${fn}:${vt()}`),m={outDir:Z.join(i,"_stx","images"),storage:$t(Z.join(i,"_stx","images"),`${dn}:${vt()}`),baseUrl:ye,widths:un,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},u=c,y;try{y=await bt({...m,entries:St(c,l)})}catch(v){if(u=await $n(c),u.length===c.length)throw v;let b=new Set(u.map((k)=>k.relativePath)),w=!1;for(let k of c){if(b.has(k.relativePath))continue;let P=Ct(k.absolutePath);if(!P)continue;a[k.relativePath]=P,w=!0}if(w)Cn(i,a);if(u.length===0)return ls(),{count:0,fingerprint:""};y=await bt({...m,entries:St(u,l)})}let S=await vn(y.entries),h=xn(y.entries,S),C=be();C.catalog=new Map(Object.entries(y.entries)),C.transparent=S;let x=S.size===0&&h.length===0?y.fingerprint:Rt("sha256").update(y.fingerprint).update(JSON.stringify({transparent:[...S].sort(),droppedWebp:h.sort()})).digest("hex");return{count:u.length,fingerprint:x}}class Pt{builtins=new Map;registerBuiltin(e){this.builtins.set(e.name.toLowerCase(),e);for(let i of e.aliases)this.builtins.set(i.toLowerCase(),e)}isBuiltin(e){return this.builtins.has(e.toLowerCase())}getBuiltin(e){return this.builtins.get(e.toLowerCase())??null}async resolveFile(e,i,t,o){let a=oi(e,o);if(a!==void 0)return a;for(let c of ii(e,i,t,o))if(await s(c))return c;return null}}var ue=new Pt;var re="\x00stx-boolean-attribute";function He(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var An=new Set(["accesskey","autocapitalize","autofocus","class","contenteditable","dir","draggable","enterkeyhint","exportparts","hidden","id","inert","inputmode","is","itemid","itemprop","itemref","itemscope","itemtype","lang","nonce","part","role","slot","spellcheck","style","tabindex","title","translate","accept","action","alt","autocomplete","capture","cite","cols","colspan","content","controls","datetime","default","download","enctype","for","form","formaction","formenctype","formmethod","formnovalidate","formtarget","height","href","hreflang","kind","label","loading","loop","max","maxlength","media","method","min","minlength","multiple","muted","name","open","pattern","placeholder","playsinline","poster","preload","readonly","referrerpolicy","rel","required","reversed","rows","rowspan","scope","selected","shape","size","span","src","srcdoc","srclang","srcset","start","step","target","type","usemap","value","width","wrap"]);function qe(e){let i=e.toLowerCase();return i.startsWith("aria-")||i.startsWith("data-")||An.has(i)}function ie(e,i){let t=[];for(let[o,a]of Object.entries(e.static)){if(i.has(o))continue;let c=e.staticNames?.[o]??o;if(typeof a==="boolean"){if(a)t.push(p(c));continue}if(a===re){t.push(p(c));continue}t.push(`${p(c)}="${wn(c,He(String(a)))}"`)}return t}function ae(e,i){let t=[];for(let[o,a]of Object.entries(e.serverDynamic??{})){if(i.has(o))continue;if(a===null||a===void 0||a===!1)continue;let c=e.serverDynamicNames?.[o]??o;if(a===!0){t.push(p(c));continue}if(typeof a==="object")continue;t.push(`${p(c)}="${wn(c,He(String(a)))}"`)}return t}function kn(e){if(e.clientReactive.to)return{value:e.clientReactive.to,reactive:!0};if(e.serverDynamic.to!==void 0)return{value:String(e.serverDynamic.to),reactive:!1};if(typeof e.static.to==="string")return{value:e.static.to,reactive:!1};return{value:"#",reactive:!1}}var Xe={name:"StxLink",aliases:["stx-link"],render(e,i,t){let o=kn(e),a=(typeof e.static.class==="string"?e.static.class:"")||(typeof e.static.className==="string"?e.static.className:""),c=typeof e.static.activeClass==="string"?e.static.activeClass:"active",l=typeof e.static.exactActiveClass==="string"?e.static.exactActiveClass:"exact-active",m=e.static.prefetch===!0||e.static.prefetch==="true"||e.serverDynamic.prefetch===!0,u=[];if(o.reactive)u.push(`:href="${n(o.value)}"`);else u.push(`href="${n(wr(o.value,"navigable"))}"`);if(a)u.push(`class="${n(a)}"`);if(u.push("data-stx-link"),u.push(`data-stx-active-class="${n(c)}"`),u.push(`data-stx-exact-active-class="${n(l)}"`),m)u.push("data-stx-prefetch");let y=typeof e.static.activeMatch==="string"?e.static.activeMatch.trim():"";if(y)u.push(`data-stx-active-match="${n(y)}"`);let S=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return u.push(...ie(e,S)),u.push(...ae(e,S)),`<a ${u.join(" ")}>${i}</a>`}};var Pn=new Map;function Ve(e){if(!e)return;let i=e.split("?")[0].split("#")[0];return Pn.get(i)}var In={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Ze=[320,640,768,1024,1280,1536,1920];function X(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}function Ie(e,i,t=!1){let o=e.serverDynamic[i];if(o!==void 0)return o!==!1&&o!=="false";let a=e.static[i];if(a!==void 0)return a!=="false"&&a!==!1;return t}function Ge(e){if(e.includes("(")||e.includes(","))return e;let i=e.trim().split(/\s+/),t=[];for(let o of i)if(o.includes(":")){let[a,c]=o.split(":"),l=In[a];if(l)t.push(`(max-width: ${l}px) ${c}`);else{let m=Number.parseInt(a);if(!Number.isNaN(m))t.push(`(max-width: ${m}px) ${c}`)}}else t.push(o);return t.join(", ")}function Ke(e,i,t,o){return i.map((a)=>`${ve(e,a,void 0,t,o)} ${a}w`).join(", ")}function _n(e,i,t,o,a){return i.map((c)=>{let l=t?t*c:void 0;return`${ve(e,l,void 0,o,a)} ${c}x`}).join(", ")}function ve(e,i,t,o,a){if(!o||o==="local"||o==="static")return e;if(o==="cloudinary"){let c=[];if(i)c.push(`w_${i}`);if(t)c.push(`h_${t}`);if(a)c.push(`f_${a}`);c.push("q_auto");let l=c.join(",");return e.replace("/upload/",`/upload/${l}/`)}if(o==="imgix"){let c=new URLSearchParams;if(i)c.set("w",String(i));if(t)c.set("h",String(t));if(a)c.set("fm",a);c.set("auto","format");let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}if(o==="bunny"){let c=new URLSearchParams;if(i)c.set("width",String(i));if(t)c.set("height",String(t));if(a)c.set("format",a);let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}return e}function En(e){return`var s=this.style;${e.map((i)=>`s.${i}=''`).join(";")}`}function Nn(e,i,t="#e5e7eb"){let o=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${i}"><rect width="100%" height="100%" fill="${t}"/></svg>`;return`data:image/svg+xml;base64,${btoa(o)}`}var Je={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,i,t){let o=X(e,"src")||"",a=Lo(o),c=X(e,"alt")||"",l=X(e,"width")||(a?String(a.source.width):void 0),m=X(e,"height")||(a?String(a.source.height):void 0),u=X(e,"sizes"),y=X(e,"srcset"),S=X(e,"densities"),h=X(e,"format"),C=jo(o)||Ve(o)?.transparent===!0,x=X(e,"placeholder")||(a&&!C?"thumbhash":void 0),v=X(e,"placeholderColor")||"#e5e7eb",b=X(e,"provider"),w=X(e,"class")||X(e,"className")||"",k=X(e,"style")||"",P=X(e,"objectFit")||X(e,"fit"),R=X(e,"objectPosition")||X(e,"position"),B=X(e,"quality"),K=Ie(e,"lazy",!0),M=Ie(e,"preload",!1),F=Ie(e,"priority",!1),W=X(e,"loading"),E=X(e,"decoding")||"async",T=!!a||Ie(e,"picture",!1)||!!h,N=l?Number.parseInt(l):void 0,H=m?Number.parseInt(m):void 0,z=y||"",q="";if(a)z=a.sources[a.fallback.format]||"",q=u?Ge(u):"100vw";else if(!z&&u&&b&&b!=="local"&&b!=="static")z=Ke(o,Ze,b,h),q=Ge(u);else if(!z&&S){let I=S.split(/\s+/).map((_)=>Number.parseFloat(_.replace("x","")));z=_n(o,I,N,b,h)}else if(u)q=Ge(u);let L=[];if(k)L.push(k);if(P)L.push(`object-fit:${P}`);if(R)L.push(`object-position:${R}`);if(N&&H)L.push(`aspect-ratio:${N}/${H}`);let D=[],ce=x==="blur"||x==="color"||x==="thumbhash";if(ce&&!C){let I=a?.placeholder?{dataUrl:a.placeholder.dataUrl,color:v}:Ve(o);if(I&&x==="color")L.push(`background-color:${I.color}`),D.push("backgroundColor");else if(I)L.push(`background-color:${I.color}`),L.push(`background-image:url(${I.dataUrl})`),L.push("background-size:cover"),L.push("background-repeat:no-repeat"),D.push("backgroundColor","backgroundImage");else{let _=Nn(N||16,H||9,v);L.push(`background-image:url(${_})`),L.push("background-size:cover"),L.push("background-repeat:no-repeat"),D.push("backgroundImage")}}else if(!ce&&x&&x!=="empty"&&x!=="none")L.push(`background-image:url(${n(x)})`),L.push("background-size:cover"),L.push("background-repeat:no-repeat"),D.push("backgroundImage");let $e=a?.fallback.url||ve(o,N,H,b,h),Y=[];if(Y.push(`src="${n(wr($e,"fetched"))}"`),Y.push(`alt="${n(c)}"`),l)Y.push(`width="${n(l)}"`);if(m)Y.push(`height="${n(m)}"`);let le=W||(F||M?"eager":K?"lazy":"");if(le)Y.push(`loading="${n(le)}"`);if(F)Y.push('fetchpriority="high"');if(Y.push(`decoding="${n(E)}"`),w)Y.push(`class="${n(w)}"`);if(L.length>0)Y.push(`style="${n(L.join(";"))}"`);if(z)Y.push(`srcset="${n(wr(z,"fetched"))}"`);if(q)Y.push(`sizes="${n(q)}"`);let te=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","objectFit","objectPosition","fit","position","format","provider","quality","densities","preload","priority","picture","loading","decoding"]);if(D.length>0){let I=typeof e.static.onload==="string"?e.static.onload:"",_=En(D)+(I?`;${I}`:"");Y.push(`onload="${n(_)}"`),te.add("onload")}Y.push(...ie(e,te)),Y.push(...ae(e,te));let De=`<img ${Y.join(" ")} />`,j="";if(M){let _=h==="webp"?"image/webp":h==="avif"?"image/avif":"";j=`<link rel="preload" as="image" href="${n($e)}"${_?` type="${_}"`:""}${z?` imagesrcset="${n(z)}"`:""}${q?` imagesizes="${n(q)}"`:""} />
|
|
3
|
+
`}if(T){let I=[];if(a)for(let _ of Bo(a))I.push(`<source type="image/${_.format}" srcset="${n(_.srcset)}"${q?` sizes="${n(q)}"`:""} />`);if(!a&&(h==="avif"||h==="auto")){let _=ve(o,N,H,b,"avif"),ee=z?Ke(o,Ze,b,"avif"):`${_}`;I.push(`<source type="image/avif" srcset="${n(ee)}"${q?` sizes="${n(q)}"`:""} />`)}if(!a&&(h==="webp"||h==="auto")){let _=ve(o,N,H,b,"webp"),ee=z?Ke(o,Ze,b,"webp"):`${_}`;I.push(`<source type="image/webp" srcset="${n(ee)}"${q?` sizes="${n(q)}"`:""} />`)}return`${j}<picture>
|
|
4
|
+
${I.join(`
|
|
5
|
+
`)}
|
|
6
|
+
${De}
|
|
7
|
+
</picture>`}return`${j}${De}`}};var It="/images/safe-image-default.svg";function fe(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}var On=`<script>window.__stxSafeImageHandler||(window.__stxSafeImageHandler=function(i){if(i.__stx_fb)return;i.__stx_fb=1;var f=i.getAttribute('data-fallback')||'${It}';var c=i.getAttribute('data-fallback-class');i.src=f;if(c)i.className=c;});</script>`,Ye={name:"SafeImage",aliases:["safe-image","safe-img"],render(e,i,t){let o=fe(e,"src")||"",a=fe(e,"alt")||"",c=fe(e,"fallback")||It,l=fe(e,"class")||fe(e,"className")||"",m=fe(e,"fallbackClassName")||"",u=[];if(u.push(`src="${n(o)}"`),u.push(`alt="${n(a)}"`),l)u.push(`class="${n(l)}"`);if(u.push(`data-fallback="${n(c)}"`),m)u.push(`data-fallback-class="${n(m)}"`);u.push('onerror="window.__stxSafeImageHandler(this)"');let y=new Set(["src","alt","fallback","class","className","fallbackClassName"]);u.push(...ie(e,y)),u.push(...ae(e,y));let S=`<img ${u.join(" ")} />`,h=t.context;if(!h.__safeImageHandlerEmitted)return h.__safeImageHandlerEmitted=!0,`${On}${S}`;return S}};function Qe(e){return e.replace(/[;{}()]/g,"").replace(/url/gi,"")}function xe(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}function _e(e,i,t){let o=xe(e,i);if(o!==void 0){let a=Number.parseInt(o,10);if(!Number.isNaN(a))return a}return t}var et={name:"StxLoadingIndicator",aliases:["stx-loading-indicator"],render(e,i,t){let o=Qe(xe(e,"color")||"#6366f1"),a=Qe(xe(e,"initialColor")||xe(e,"initial-color")||""),c=Qe(xe(e,"height")||"3px"),l=_e(e,"duration",2000),m=_e(e,"throttle",200),u=_e(e,"zIndex",999999)||_e(e,"z-index",999999),y=a?`linear-gradient(to right, ${a}, ${o})`:o;return`
|
|
8
|
+
<div id="stx-loading-indicator" style="position:fixed;top:0;left:0;right:0;height:${c};background:${y};z-index:${u};transform:scaleX(0);transform-origin:left;transition:transform 0.1s ease-out,opacity 0.3s ease;opacity:0;pointer-events:none">
|
|
9
|
+
<div style="position:absolute;top:0;left:0;right:0;bottom:0;background:linear-gradient(90deg,transparent 0%,rgba(255,255,255,0.4) 50%,transparent 100%);animation:stx-shimmer 1.5s infinite"></div>
|
|
10
|
+
</div>
|
|
11
|
+
<style>@keyframes stx-shimmer{0%{transform:translateX(-100%)}100%{transform:translateX(100%)}}</style>
|
|
12
|
+
<script>
|
|
13
|
+
(function(){var el=document.getElementById('stx-loading-indicator'),p=0,l=!1,i=null;function u(v){p=Math.min(Math.max(v,0),100);if(el){el.style.opacity=p>0?'1':'0';el.style.transform='scaleX('+(p/100)+')'}}window.stxLoading={start:function(){l=!0;p=0;u(10);if(i)clearInterval(i);i=setInterval(function(){if(!l)return;var r=90-p,inc=Math.max(0.5,r*0.1);if(p<90)u(p+inc)},${m})},finish:function(){l=!1;if(i){clearInterval(i);i=null}u(100);setTimeout(function(){if(el)el.style.opacity='0';setTimeout(function(){p=0;if(el)el.style.transform='scaleX(0)'},300)},200)},set:function(v){u(v)},clear:function(){l=!1;p=0;if(i){clearInterval(i);i=null}if(el){el.style.opacity='0';el.style.transform='scaleX(0)'}}};document.addEventListener('click',function(e){var a=e.target.closest&&e.target.closest('a');if(!a)return;var h=a.getAttribute('href');if(!h||h.startsWith('http')||h.startsWith('#')||h.startsWith('mailto:')||h.startsWith('tel:')||a.target==='_blank')return;window.stxLoading.start()});window.addEventListener('popstate',function(){window.stxLoading.start()});window.addEventListener('load',function(){window.stxLoading.finish()})})();
|
|
14
|
+
</script>`}};function Et(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}function Bn(e,i,t){let o=Et(e,i);if(o!==void 0){let a=Number.parseInt(o,10);if(!Number.isNaN(a))return a}return t}var _t={"top-right":"top:1rem;right:1rem","top-left":"top:1rem;left:1rem","top-center":"top:1rem;left:50%;transform:translateX(-50%)","bottom-right":"bottom:1rem;right:1rem","bottom-left":"bottom:1rem;left:1rem","bottom-center":"bottom:1rem;left:50%;transform:translateX(-50%)"},tt={name:"StxToast",aliases:["stx-toast"],render(e,i,t){let o=n(Et(e,"position")||"top-right"),a=Bn(e,"max",5),c=_t[o]||_t["top-right"];return`<div id="stx-toast-container" data-stx-toast-position="${o}" data-stx-toast-max="${a}" style="position:fixed;${c};z-index:999999;display:flex;flex-direction:column;gap:0.5rem;pointer-events:none;max-width:24rem;width:100%"></div>
|
|
15
|
+
<style>
|
|
16
|
+
@keyframes stx-toast-in{from{opacity:0;transform:translateX(100%)}to{opacity:1;transform:translateX(0)}}
|
|
17
|
+
@keyframes stx-toast-out{from{opacity:1;transform:translateX(0)}to{opacity:0;transform:translateX(100%)}}
|
|
18
|
+
@keyframes stx-toast-in-left{from{opacity:0;transform:translateX(-100%)}to{opacity:1;transform:translateX(0)}}
|
|
19
|
+
@keyframes stx-toast-out-left{from{opacity:1;transform:translateX(0)}to{opacity:0;transform:translateX(-100%)}}
|
|
20
|
+
@keyframes stx-toast-in-center{from{opacity:0;transform:translateY(-1rem)}to{opacity:1;transform:translateY(0)}}
|
|
21
|
+
@keyframes stx-toast-out-center{from{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-1rem)}}
|
|
22
|
+
</style>`}};function Ee(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}var Nt={sm:"max-width:24rem",md:"max-width:32rem",lg:"max-width:42rem",xl:"max-width:56rem",full:"max-width:calc(100vw - 2rem);max-height:calc(100vh - 2rem)"},nt={name:"StxModal",aliases:["stx-modal"],render(e,i,t){let o=Ee(e,"id");if(!o)return console.warn('[stx] <StxModal> requires an "id" prop'),"<!-- StxModal: missing id prop -->";let a=n(o),c=Ee(e,"size")||"md",l=Ee(e,"closeOnBackdrop")!=="false",m=Ee(e,"closeOnEscape")!=="false",u=Nt[c]||Nt.md;return`<div id="stx-modal-${a}" class="stx-modal-backdrop" data-stx-modal="${a}" data-close-backdrop="${l}" data-close-escape="${m}" style="display:none;position:fixed;inset:0;z-index:99999;align-items:center;justify-content:center;background:rgba(0,0,0,0.5);backdrop-filter:blur(2px);opacity:0;transition:opacity 0.2s ease" aria-modal="true" role="dialog">
|
|
23
|
+
<div class="stx-modal-panel" style="${u};width:100%;margin:1rem;border-radius:0.75rem;box-shadow:0 20px 60px rgba(0,0,0,0.3);overflow:hidden;transform:scale(0.95) translateY(8px);transition:transform 0.2s ease,opacity 0.2s ease;opacity:0;background:var(--stx-modal-bg,#fff);color:var(--stx-modal-text,#1f2937)">
|
|
24
|
+
<div style="padding:1.5rem">${i}</div>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
<style>
|
|
28
|
+
@media(prefers-color-scheme:dark){[data-stx-modal]{--stx-modal-bg:#1f2937;--stx-modal-text:#f3f4f6}}
|
|
29
|
+
.stx-modal-backdrop[data-stx-modal-open]{display:flex!important;opacity:1}
|
|
30
|
+
.stx-modal-backdrop[data-stx-modal-open] .stx-modal-panel{transform:scale(1) translateY(0);opacity:1}
|
|
31
|
+
</style>`}};function de(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}var Ot={sm:"16rem",md:"24rem",lg:"32rem",xl:"40rem"},it={name:"StxDrawer",aliases:["stx-drawer"],render(e,i,t){let o=de(e,"id");if(!o)return console.warn('[stx] <StxDrawer> requires an "id" prop'),"<!-- StxDrawer: missing id prop -->";let a=n(o),c=de(e,"side")||"right",l=de(e,"size")||"md",m=de(e,"closeOnBackdrop")!=="false",u=de(e,"closeOnEscape")!=="false",y=de(e,"overlay")!=="false",S=Ot[l]||Ot.md,h=c==="left",C=h?"left:0":"right:0",x=h?"translateX(-100%)":"translateX(100%)",v=h?"stx-drawer-slide-left":"stx-drawer-slide-right";return`<div id="stx-drawer-${a}" class="stx-drawer-backdrop" data-stx-drawer="${a}" data-close-backdrop="${m}" data-close-escape="${u}" style="display:none;position:fixed;inset:0;z-index:99999;${y?"background:rgba(0,0,0,0.5);backdrop-filter:blur(2px)":"background:transparent;pointer-events:none"};opacity:0;transition:opacity 0.2s ease" role="dialog" aria-modal="true">
|
|
32
|
+
<div class="stx-drawer-panel" style="position:fixed;top:0;bottom:0;${C};width:${S};max-width:100vw;transform:${x};transition:transform 0.3s cubic-bezier(0.4,0,0.2,1);background:var(--stx-drawer-bg,#fff);color:var(--stx-drawer-text,#1f2937);box-shadow:0 20px 60px rgba(0,0,0,0.3);overflow-y:auto;pointer-events:auto">
|
|
33
|
+
<div style="padding:1.5rem">${i}</div>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
<style>
|
|
37
|
+
@media(prefers-color-scheme:dark){[data-stx-drawer]{--stx-drawer-bg:#1f2937;--stx-drawer-text:#f3f4f6}}
|
|
38
|
+
.stx-drawer-backdrop[data-stx-drawer-open]{display:block!important;opacity:1}
|
|
39
|
+
.stx-drawer-backdrop[data-stx-drawer-open] .stx-drawer-panel{transform:translateX(0)}
|
|
40
|
+
</style>`}};import{existsSync as Tn,readFileSync as Dn}from"fs";var Oe=new Map,Bt=new Set;function jn(e){if(Bt.has(e))return;Bt.add(e),console.warn(`[stx] icon collection "${e}" is not installed, so its icons render as nothing. Install it with \`bun add -d @iconify-json/${e}\`.`)}function Mn(e){let i=process.cwd();for(let t of[`${i}/node_modules/@iconify-json/${e}/icons.json`,`${i}/pantry/@iconify-json/${e}/icons.json`,`${i}/node_modules/@iconify/json/json/${e}.json`,`${i}/pantry/@iconify/json/json/${e}.json`])if(Tn(t))return t;for(let t of[`@iconify-json/${e}/icons.json`,`@iconify/json/json/${e}.json`])try{return g.resolve(t)}catch{}return null}function Ln(e){if(Oe.has(e))return Oe.get(e);let i=Mn(e);if(!i)return jn(e),null;try{let t=JSON.parse(Dn(i,"utf8"));return Oe.set(e,t),t}catch{return null}}function zn(e,i,t,o){let a=[];if(i.rotate)a.push(`rotate(${i.rotate*90} ${t/2} ${o/2})`);if(i.hFlip)a.push(`translate(${t} 0) scale(-1 1)`);if(i.vFlip)a.push(`translate(0 ${o}) scale(1 -1)`);return a.length?`<g transform="${a.join(" ")}">${e}</g>`:e}function Un(e,i){let t=i,o=e.icons[t],a={hFlip:!1,vFlip:!1,rotate:0};for(let m=0;!o&&m<8;m++){let u=e.aliases?.[t];if(!u)return null;if(u.hFlip)a.hFlip=!a.hFlip;if(u.vFlip)a.vFlip=!a.vFlip;if(u.rotate)a.rotate=((a.rotate+u.rotate)%4+4)%4;t=u.parent,o=e.icons[t]}if(!o)return null;let c=o.width??e.width??24,l=o.height??e.height??24;return{body:zn(o.body,a,c,l),width:c,height:l}}function ge(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);if(e.static[i]!==void 0)return String(e.static[i]);if(e.clientReactive[i]!==void 0)return e.clientReactive[i];return}var ot={name:"Icon",aliases:["icon","stx-icon"],render(e,i,t){let o=ge(e,"name")??ge(e,"icon");if(!o)return"<!-- Icon: missing name/icon prop -->";let a="lucide",c=o;if(o.includes(":")){let w=o.split(":");a=w[0],c=w[1]}let l=n(ge(e,"size")||"24"),m=n(ge(e,"color")||"currentColor"),u=n(ge(e,"class")||""),y=n(ge(e,"style")||""),S=Oe.get(a)??Ln(a);if(!S)return`<!-- Icon: collection "${a}" not loaded -->`;let h=Un(S,c);if(!h)return`<!-- Icon: "${c}" not found in ${a} -->`;let C=`0 0 ${h.width} ${h.height}`,x=h.body;if(m!=="currentColor")x=x.replace(/currentColor/g,m);let v=u?` class="${u}"`:"",b=y?` style="${y}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${l}" viewBox="${C}" fill="none"${v}${b}>${x}</svg>`}};function Tt(e,...i){for(let t of i){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let o=e.static[t];if(typeof o==="string")return o}return}function Dt(e,i){let t=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${i}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),o=e.match(t);if(!o)return{region:null,rest:e};return{region:o[2],rest:e.replace(o[0],"")}}var at={name:"Suspense",aliases:["suspense"],render(e,i,t){let o=Dt(i,"fallback"),a=o.rest,c=Dt(a,"error"),l=c.rest,m=o.region??Tt(e,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',u=c.region??Tt(e,"errorFallback","error-fallback")??'<div class="stx-suspense-error">Something went wrong.</div>';return`<div data-stx-suspense><div data-stx-suspense-fallback>${m}</div><div data-stx-suspense-error hidden>${u}</div><div data-stx-suspense-content hidden>${l}</div></div>`}};function Be(e,...i){for(let t of i){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let o=e.static[t];if(typeof o==="string")return o}return}var ct={name:"TransitionGroup",aliases:["transition-group"],render(e,i,t){let o=(Be(e,"name")||"v").replace(/["'<>]/g,""),a=(Be(e,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",c=Be(e,"class"),l=Be(e,"id"),m=[`data-stx-transition-group="${o}"`,c?`class="${c}"`:"",l?`id="${l}"`:""].filter(Boolean).join(" ");return`<${a} ${m}>${i}</${a}>`}};function jt(e=ue){e.registerBuiltin(Xe),e.registerBuiltin(Je),e.registerBuiltin(Ye),e.registerBuiltin(et),e.registerBuiltin(tt),e.registerBuiltin(nt),e.registerBuiltin(it),e.registerBuiltin(ot),e.registerBuiltin(at),e.registerBuiltin(ct)}var Mt=new Map;function Fn(e){let i=Mt.get(e.source);if(!i)i=new RegExp(`(${e.source})(?![\\w.:-])`,"y"),Mt.set(e.source,i);return i}var Lt=new WeakMap;function zt(e){let i=Lt.get(e);if(!i)i=new Set([...e].map((o)=>o.toLowerCase())),Lt.set(e,i);let t=i;return(o)=>!/[a-z]/.test(o)&&t.has(o.toLowerCase())}function Wn(e,i){let t="";for(let o=i;o<e.length;o++){let a=e[o];if(t){if(a==="\\")o++;else if(a===t)t=""}else if(a==='"'||a==="'")t=a;else if(a===">")return o}return e.length}function Ut(e,i,t){let o=[],a=0,c=typeof t==="function"?t:t?(l)=>t.has(l.toLowerCase()):void 0;while(a<e.length){let l=e.indexOf("<",a);if(l===-1)break;let m=Fn(i);m.lastIndex=l+1;let u=m.exec(e);if(!u){a=l+1;continue}let y=u[1];if(c&&c(y)){let w=l+1+y.length;while(w<e.length&&e[w]!==">")w++;a=w+1;continue}let S=l+1+y.length,h=null,C=S,x=-1,v=!1;while(S<e.length){let w=e[S];if(h){if(w==="\\"&&S+1<e.length){S+=2;continue}if(w===h)h=null;S++;continue}if(w==='"'||w==="'"){h=w,S++;continue}if(w==="/"&&S+1<e.length&&e[S+1]===">"){x=S+2,v=!0;break}if(w===">"){x=S+1;break}S++}if(x===-1){a=l+1;continue}let b=e.slice(C,v?x-2:x-1).trim();if(v)o.push({fullMatch:e.slice(l,x),tagName:y,attributes:b,content:"",startIndex:l,endIndex:x,isSelfClosing:!0}),a=x;else{let w=`<${y}`,k=`</${y}>`,P=1,R=x,B=-1;while(P>0&&R<e.length){let F=e.indexOf(w,R),W=e.indexOf(k,R);if(W===-1)break;if(F!==-1&&F<W){let E=e[F+w.length];if(E===" "||E===">"||E==="/"||E===`
|
|
41
|
+
`||E==="\t"){let T=Wn(e,F+w.length);if(e[T-1]!=="/")P++;R=T+1}else R=F+w.length}else{if(P--,P===0){B=W;break}R=W+k.length}}if(B===-1){a=x;continue}let K=e.slice(x,B),M=B+k.length;o.push({fullMatch:e.slice(l,M),tagName:y,attributes:b,content:K,startIndex:l,endIndex:M,isSelfClosing:!1}),a=M}}return o}function lt(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/�?39;/g,"'").replace(/'/gi,"'").replace(/&/g,"&")}function Ft(e,i){try{let t=Buffer.from(e,"base64").toString("utf8");return JSON.parse(t)}catch{}try{let t=e.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&");return JSON.parse(t)}catch(t){if(i?.debug)console.error("Error decoding __stx_ prop:",t);return e}}function Te(e,i){let t=0,o="",a=i;while(a<e.length){let c=e[a];if(o){if(c==="\\")a++;else if(c===o)o=""}else if(c==='"'||c==="'"||c==="`")o=c;else if(c==="{")t++;else if(c==="}"){if(t--,t===0)return e.slice(i,a+1)}a++}return e.slice(i)}function Wt(e){let i=e.trim();if(!i.startsWith("{")||!i.endsWith("}"))return null;if(Te(i,0).length!==i.length)return null;return i.slice(1,-1).trim()}function Ht(e){let i=[],t=0,o=e.length;while(t<o){while(t<o&&/\s/.test(e[t]))t++;if(t>=o)break;let a="";while(t<o&&!/[\s=]/.test(e[t]))a+=e[t],t++;if(!a)break;while(t<o&&/\s/.test(e[t]))t++;if(t<o&&e[t]==="="){t++;while(t<o&&/\s/.test(e[t]))t++;let c="";if(t<o&&(e[t]==='"'||e[t]==="'")){let l=e[t];t++;while(t<o&&e[t]!==l){if(e[t]==="\\"&&t+1<o)t++,c+=e[t];else c+=e[t];t++}if(t<o)t++}else if(e[t]==="{")c=Te(e,t),t+=c.length;else while(t<o&&!/\s/.test(e[t]))c+=e[t],t++;i.push({name:a,value:c})}else i.push({name:a,value:!0})}return i}var Hn=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),qn=new Set([":for","x-for","v-for","@for"]),Xn=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Vn(e){return ut(e).map((i)=>[i.start,i.end])}function ut(e){let i=[],t=new Map;for(let o of ci(e)){let a=o.name.toLowerCase();if(o.closing){let y=t.get(a)?.pop();if(y)y.end=o.end;continue}let l=/(?::for|x-for|v-for|@for)\s*=/.test(o.attributes)?Ht(o.attributes).find((y)=>qn.has(y.name)):void 0,m=typeof l?.value==="string"?l.value:null,u=m!==null?{start:o.start,end:o.end,names:J(m)}:null;if(u)i.push(u);if(!o.selfClosing&&!Xn.has(a)){let y=t.get(a);if(!y)y=[],t.set(a,y);y.push(u)}}return i}function qt(e){if(typeof e==="string")return e;if(Array.isArray(e))return e.filter(Boolean).map((i)=>qt(i)).join(" ");if(e&&typeof e==="object")return Object.entries(e).filter(([,i])=>i).map(([i])=>i).join(" ");return e?String(e):""}function cc(e,i){if(!/:[\w-]+=/.test(e))return e;let t=e,o=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,a=[],c;while((c=o.exec(e))!==null)a.push([c.index,c.index+c[0].length]);a.push(...Vn(e));let l=new Set([...rt(i),...Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[]]);function m(h){return a.some(([C,x])=>h>=C&&h<x)}let u=[],y=new Map,S=256;for(let h of ci(t)){if(h.closing||m(h.start))continue;let C=h.attributes.trimEnd();if(!C||!C.includes(":"))continue;let x=/(?:^|\s)data-native(?:\s|=|$)/i.test(C.replace(/"[^"]*"|'[^']*'/g,"")),v=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,b,w=C,k=!1;while((b=v.exec(C))!==null){if(xr(C,b.index,!0)?.kind==="attribute")continue;let P=b[1],R=b[2];if(gl(P))continue;if(O(R,l))continue;if(R.includes("()")&&!R.includes(".get(")||R.includes("$store")||R.includes("$ref"))continue;try{let B=Object.keys(i),K=Object.values(i),M=R.match(/^([a-zA-Z_$][\w$]*)/);if(M&&!B.includes(M[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(M[1]))continue;let F=JSON.stringify([B,R]),W=y.get(F);if(!W){if(W=Function(...B,`return (${R})`),y.size>=S)y.clear();y.set(F,W)}let E=W(...K);if(P==="class"){let T=U(qt(E));if(T){let N=w.match(/\sclass="([^"]*)"/);if(N)w=w.replace(N[0],()=>` class="${N[1]} ${T}"`);else w=w.replace(b[0],()=>` class="${T}"`)}else w=w.replace(b[0],"");k=!0;continue}if(Hn.has(P)){if(E)w=w.replace(b[0],` ${P}`);else w=w.replace(b[0],"");k=!0;continue}if(E===null||E===void 0||E===!1)w=w.replace(b[0],"");else{let T=x&&typeof E==="object"?JSON.stringify(E):String(E),N=wn(P,T);w=w.replace(b[0],()=>` ${P}="${N}"`)}k=!0}catch(B){if(B instanceof oe)throw B;continue}}if(k){let P=h.selfClosing?" /":"",B=`<${h.name}${w}${P}>`;u.push({start:h.start,end:h.end,replacement:B})}}if(u.length>0){let h=Array(u.length*2+1),C=0;for(let x=0;x<u.length;x++){let{start:v,end:b,replacement:w}=u[x];h[x*2]=t.slice(C,v),h[x*2+1]=w,C=b}h[u.length*2]=t.slice(C),t=h.join("")}return t}import Xt from"fs";import Vt from"path";var Zt=!1;function Zn(e,i,t,o=!1,a=new Set){let c={static:{},staticNames:{},serverDynamic:{},serverDynamicNames:{},clientReactive:{},events:{}},l=new Set(Array.isArray(i.__stx_client_signal_names)?i.__stx_client_signal_names:[]),m=(h)=>{if(l.size===0)return!1;let C=r(h),x=C.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(x&&l.has(x))return!0;for(let v of l){let b=v.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${b}\\s*\\(`).test(C))return!0}return!1},u=new Set(ml),y=(h)=>{if(!h.includes("-")||h.startsWith("@")||h.startsWith(":")||h.startsWith("x-")||h.startsWith("__"))return h;if(h.startsWith("aria-")||h.startsWith("data-"))return h;return h.replace(/-([a-z0-9])/g,(C,x)=>x.toUpperCase())},S=(h,C)=>{let x=y(h);if(c.static[x]=C,x!==h)c.staticNames[x]=h};for(let[h,C]of Object.entries(e)){let x=h.startsWith("x-")&&!u.has(h)&&!h.startsWith("x-bind:")&&!h.startsWith("x-on:")?`:${h.slice(2)}`:h;if(x.startsWith("@")){c.events[x]=C;continue}if(x.startsWith("__stx_")){let v=y(x.slice(6));c.serverDynamic[v]=Ft(C,t);continue}if(x.startsWith(":")){let v=y(x.slice(1)),b=C===re?v:C;if(v==="if"||v==="for"||v==="show"){c.clientReactive[v]=b;continue}if(o){c.clientReactive[v]=b;continue}if(O(b,a)){c.clientReactive[v]=b;continue}if(m(b)){c.clientReactive[v]=b;continue}try{if(!f(b)){if(t.debug)console.error(`Unsafe expression in :${v} binding: ${b}`);c.clientReactive[v]=b;continue}let w=Object.keys(i),k=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]),P=new Set(Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[]);if(st(b).some((M)=>!k.has(M)&&!w.includes(M)&&(!(M in globalThis)||P.has(M)))){c.clientReactive[v]=b;continue}let K=d(b,w)(...Object.values(i));if(c.serverDynamic[v]=K,v!==x.slice(1)&&c.serverDynamicNames)c.serverDynamicNames[v]=x.slice(1)}catch{c.clientReactive[v]=b}continue}if(typeof C==="string"&&C.includes("{{")&&C.includes("}}")){let v=Gn(C,a);if(v!==null){c.clientReactive[y(x)]=v;continue}let b=C.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(b)try{let w=b[1];if(f(w)){let P=d(w,Object.keys(i))(...Object.values(i));S(x,P!=null?String(P):"")}else{if(t.debug)console.error(`Unsafe expression in ${x}: ${w}`);S(x,C)}}catch(w){if(t.debug)console.error(`Error evaluating expression for ${x}:`,w);S(x,C)}else{let w=C,k=/\{\{\s*([\s\S]+?)\s*\}\}/g,P;while((P=k.exec(C))!==null)try{let R=P[1];if(!f(R)){if(t.debug)console.error(`Unsafe expression in ${x}: ${R}`);continue}let K=d(R,Object.keys(i))(...Object.values(i));w=w.replace(P[0],String(K??""))}catch(R){if(t.debug)console.error(`Error evaluating expression in ${x}:`,R)}S(x,w)}continue}S(x,C===re?"true":lt(C))}return c}function Gn(e,i){if(i.size===0)return null;let t=/\{\{\s*([\s\S]+?)\s*\}\}/g,o=[...e.matchAll(t)];if(!o.some((m)=>O(m[1],i)))return null;let a=e.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(a&&o.length===1)return a[1];let c="",l=0;for(let m of o)c+=e.slice(l,m.index).replace(/[`\\$]/g,(u)=>`\\${u}`),c+=`\${${m[1]}}`,l=m.index+m[0].length;return c+=e.slice(l).replace(/[`\\$]/g,(m)=>`\\${m}`),`\`${c}\``}var Kn=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function Jn(e,i,t){if(!e.includes("@"))return e;if(!Kn.some(([a,c])=>a.test(e)&&e.includes(c)))return e;try{return se(e,i,t)}catch{return e}}function me(e){let i={},t=0,o=e.length;while(t<o){while(t<o&&/\s/.test(e[t]))t++;if(t>=o)break;let a="";while(t<o&&!/[\s=]/.test(e[t]))a+=e[t],t++;if(!a)break;while(t<o&&/\s/.test(e[t]))t++;if(t<o&&e[t]==="="){t++;while(t<o&&/\s/.test(e[t]))t++;let c="";if(t<o&&(e[t]==='"'||e[t]==="'")){let l=e[t];t++;while(t<o){let m=e[t];if(m==="\\"&&t+1<o){t++,c+=e[t],t++;continue}if(m===l){t++;break}c+=m,t++}}else if(e[t]==="{"){c=Te(e,t),t+=c.length;let l=Wt(c);if(l!==null){i[`:${a}`]=l;continue}}else while(t<o&&!/\s/.test(e[t]))c+=e[t],t++;i[a]=c}else i[a]=re}return i}function Gt(e){return Object.entries(e).map(([i,t])=>t===re?i:`${i}="${Yn(t)}"`).join(" ")}function Yn(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Qn(e){let i=new Set,t=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,o;while((o=t.exec(e))!==null){let a=o[1];if(ue.isBuiltin(a))i.add(a)}return[...i].sort()}async function Nf(e,i,t,o,a){if(!/import\s/.test(e))return e;if(!i.__importedComponents)i.__importedComponents=new Map;let c=i.__importedComponents,l=Vt.dirname(t),m=[],u=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;for(let h of e.matchAll(u)){let[C,x,v]=h,b=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,w=v,k,P=[];while((k=b.exec(v))!==null){let[R,B,K,M]=k,F=null,W=null;if(M.startsWith(".")||M.startsWith("/")){let N=Vt.resolve(l,M);if(N.endsWith(".stx"))W=N;else{let H=`${N}.stx`;try{if(Xt.statSync(H).isFile())W=H}catch{try{if(Xt.statSync(N).isDirectory())F=N}catch{}}}}else F=Os(M,l);if(!F&&!W)continue;let E=!1,T=(N,H)=>{c.set(N,H),c.set(N.toLowerCase(),H);let z=N.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();c.set(z,H),a.add(H)};if(K&&W)T(K,W),E=!0;else if(B){let N=B.slice(1,-1).split(",").map((z)=>z.trim()).filter(Boolean).map((z)=>{let q=z.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(q)return{source:q[1],local:q[2]};return{source:z,local:z}}),H=F?yr(F):null;for(let{source:z,local:q}of N){let L=null;if(W)L=W;else if(H)L=H.get(z)??H.get(z.toLowerCase())??H.get(z.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(L)T(q,L),E=!0}}if(E)P.push({start:k.index,end:k.index+R.length})}if(P.length===0)continue;for(let R=P.length-1;R>=0;R--)w=w.slice(0,P[R].start)+w.slice(P[R].end);m.push({start:h.index,end:h.index+C.length,value:`<script${x}>${w}</script>`})}if(m.length===0)return e;let y=[],S=0;for(let h of m)y.push(e.slice(S,h.start),h.value),S=h.end;return y.push(e.slice(S)),y.join("")}async function er(e,i,t,o,a){let c=e;if(!i.__importedComponents)i.__importedComponents=new Map;let l=i.__importedComponents,m=/@import\s*\(\s*([^)]+)\s*\)/g,u;while((u=m.exec(c))!==null){let[y,S]=u,h=S.split(",").map((C)=>C.trim().replace(/^['"]|['"]$/g,"")).filter((C)=>C.length>0);for(let C of h){let x=C.split("/"),b=x[x.length-1].replace(/\.stx$/,""),w=b.includes("-")?b.split("-").map((R)=>R.charAt(0).toUpperCase()+R.slice(1)).join(""):b.charAt(0).toUpperCase()+b.slice(1),k=null,P=Ns(C,t,o);for(let R of P)try{if(await Bun.file(R).exists()){k=R;break}}catch{}if(k){l.set(w,k),l.set(b,k),l.set(b.toLowerCase(),k);let R=w.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(l.set(R,k),a.add(k),o.debug)console.log(`Imported component: ${w} -> ${k}`)}else if(o.debug)console.warn(`Could not resolve imported component: ${C}`)}c=c.replace(y,""),m.lastIndex=0}return c}async function tr(e,i,t,o,a){let c=e,l=o.componentsDir||"components";if(!i.__processedComponents)i.__processedComponents=new Set;let m=i.__processedComponents,u=/@component\s*\(/g,y;while((y=u.exec(c))!==null){let S=y.index,h=S+y[0].length-1,C=1,x=h+1;while(x<c.length&&C>0){if(c[x]==="(")C++;else if(c[x]===")"){if(C--,C===0)break}x++}if(C!==0)break;let v=c.substring(h+1,x),b=x+1,w=v.match(/^\s*['"]([^'"]+)['"]/);if(!w){u.lastIndex=0;continue}let k=w[1],P,R=v.slice(w[0].length),B=R.match(/^\s*,\s*/);if(B)P=R.slice(B[0].length).trim();let K={};if(P)try{K=A(P,i)}catch(N){let H=N instanceof Error?N.message:String(N);c=c.replace(c.substring(S,b),`[Error parsing component props: ${H}]`);continue}let M="",F=b,E=c.substring(b).match(/^([\s\S]*?)@endcomponent/);if(E)M=E[1].trim(),F=b+E[0].length;let T=await Fe(k,K,M,l,i,t,o,m,a);c=c.substring(0,S)+T+c.substring(F),u.lastIndex=0}return c}async function nr(e,i,t,o,a){if(!e)return e;let c=e,l=o.componentsDir||"components";if(!i.__processedComponents)i.__processedComponents=new Set;let m=i.__processedComponents,u=ir(c);if(u.size>0){let b=Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[];i.__stx_client_declared_names=[...new Set([...b,...u])]}let y=G(c);c=y.output;let S=rt(i);return c=await v(c,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),c=await v(c,/[A-Z][a-zA-Z0-9]*/,!0,zt(Sr)),c=await v(c,/[a-z][a-z0-9]*/,!1,Sr),c=y.restore(c),c;async function v(b,w,k,P){if(!b)return b;let R=b,B=Ut(R,w,P),K=ut(R),M=new Map;for(let E=B.length-1;E>=0;E--){let T=B[E],N=k?V(T.tagName):T.tagName,H=me(Jn(T.attributes,i,t)),z=K.filter(({start:I,end:_})=>T.startIndex>=I&&T.startIndex<_),q=z.length>0,L=new Set(S);for(let I of z)for(let _ of I.names)L.add(_);let D=Zn(H,i,o,q,L);if(typeof D.clientReactive.for==="string")for(let I of J(D.clientReactive.for))L.add(I);let ce=ue.getBuiltin(T.tagName),$e=ce?await Cr(T.tagName,l,i,t,o):!1,Y=T.tagName==="Image"&&Ms([...Object.keys(D.static),...Object.keys(D.serverDynamic),...Object.keys(D.clientReactive)],Object.keys(D.events),{...D.static,...D.serverDynamic})&&(o._pluginComponentDirs??[]).some((I)=>yr(I).has("Image"));if(ce&&!$e&&!Y){let I={context:i,filePath:t,options:o,dependencies:a},_=ce.render(D,T.content,I);if(Object.keys(D.events).length>0){let ee=Gt(D.events);_=_.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${ee}`)}if(Object.keys(D.clientReactive).length>0)_=Kt(_,D.clientReactive);M.set(E,_);continue}if(!k&&T.tagName.includes("-")&&!await Cr(N,l,i,t,o))continue;let le={};for(let[I,_]of Object.entries(D.static))le[I]=_;for(let[I,_]of Object.entries(D.serverDynamic))le[I]=_;let te={declaredProps:new Set,consumedProps:new Set,reactiveProps:Object.keys(D.clientReactive),events:Object.keys(D.events)},j=await Fe(N,le,y.restore(T.content),l,i,t,o,m,a,[...L],te,T.tagName);if(j=rr(j,D,te.declaredProps,te.consumedProps,o._nativeHostAttrs),o._nativeHostAttrs){let I=te.reactiveProps.filter((ne)=>!te.consumedProps.has(ne)&&!["if","for","show","key","ref"].includes(ne)).map(V),_=ft(j,!0);if(I.length&&_){if(!Object.hasOwn(me(j.slice(_.insertPos,_.tagEnd)),"data-stx-native-host-root"))j=j.slice(0,_.insertPos)+' data-stx-native-host-root="true"'+j.slice(_.insertPos);let ne=we(j);j=j.slice(0,ne.insertPos)+` data-stx-native-forward="${I.join(" ")}"`+j.slice(ne.insertPos)}let ee=ft(j,!0);if(ee){let ne=me(j.slice(ee.insertPos,ee.tagEnd)),Se=we(j),Yt=me(j.slice(Se.insertPos,Se.tagEnd));if(Object.hasOwn(ne,"data-stx-native-host-root")&&!Object.hasOwn(Yt,"data-stx-native-host-owner"))j=j.slice(0,Se.insertPos)+" data-stx-native-host-owner"+j.slice(Se.insertPos)}}if(Object.keys(D.events).length>0){let I=we(j);if(I){let _=Gt(D.events),ee=Object.keys(D.events).map((ne)=>ne.replace(/^@/,"").split(".")[0]).join(" ");j=j.substring(0,I.insertPos)+` data-stx-parent-events="${ee}" ${_}`+j.substring(I.insertPos)}}if(Object.keys(D.clientReactive).length>0)j=Kt(j,D.clientReactive);M.set(E,j)}if(M.size===0)return R;let F="",W=0;for(let E=0;E<B.length;E++){let T=M.get(E);if(T===void 0)continue;F+=R.slice(W,B[E].startIndex),F+=T,W=B[E].endIndex}return F+=R.slice(W),F}}function Kt(e,i){let t=new Set(["if","for"]),o=new Set(["show"]),a=Object.entries(i).filter(([S])=>!t.has(S)),c=a.filter(([S])=>!o.has(S)).map(([S])=>V(S)).join(" "),l=e,m=a.length>0?we(l):null;if(m){let S=a.map(([C,x])=>`:${V(C)}="${x.replace(/"/g,""")}"`).join(" "),h=c?` data-stx-parent-bindings="${c}"`:"";l=l.substring(0,m.insertPos)+`${h} ${S}`+l.substring(m.insertPos)}let u=i.if;if(u)l=`<template :if="${u.replace(/"/g,""")}">${l}</template>`;let y=i.for;if(y){let S=i.key,h=S?` :key="${S.replace(/"/g,""")}"`:"";l=`<template :for="${y.replace(/"/g,""")}"${h}>${l}</template>`}return l}function rr(e,i,t=new Set,o=new Set,a=!1){let c=ft(e,a);if(!c)return e;let l=e.slice(c.insertPos,c.tagEnd),m=i.serverDynamic.class??i.static.class;if(a&&typeof m==="string"&&m&&!o.has("class")){let v=/(^|\s)class\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i,b=v.test(l)?l.replace(v,(w,k,P,R,B)=>`${k}class="${n(`${lt(P??R??B)} ${m}`)}"`):` class="${n(m)}"${l}`;e=e.slice(0,c.insertPos)+b+e.slice(c.tagEnd),c.tagEnd+=b.length-l.length,l=b}let u=a||/\bdata-native(?:\s|=)/i.test(l),y=u?o:t,S=new Set(Object.keys(me(l))),h=new Set(["class","className"]);for(let v of Object.keys(i.static)){let b=i.staticNames[v]??v;if(S.has(b)||y.has(v)||!u&&!qe(b))h.add(v)}for(let v of Object.keys(i.serverDynamic)){let b=i.serverDynamicNames?.[v]??v;if(S.has(b)||y.has(v)||!u&&!qe(b))h.add(v)}let C=[];if(u){for(let[v,b]of Object.entries(i.static)){if(h.has(v)||b!==!0&&b!==re)continue;h.add(v),C.push(`${n(i.staticNames?.[v]??v)}="true"`)}for(let[v,b]of Object.entries(i.serverDynamic)){if(h.has(v)||b!==!0)continue;h.add(v),C.push(`${n(i.serverDynamicNames?.[v]??v)}="true"`)}}let x=[...ie(i,h),...ae(i,h),...C];if(u){for(let[v,b]of Object.entries(i.serverDynamic)){if(h.has(v)||b!==!1)continue;let w=i.serverDynamicNames?.[v]??v;x.push(`${n(w)}="false"`)}for(let[v,b]of Object.entries(i.serverDynamic)){if(h.has(v)||b===null||typeof b!=="object")continue;let w=JSON.stringify(b);if(w!==void 0){let k=i.serverDynamicNames?.[v]??v;x.push(`${n(k)}="${n(w)}"`)}}}if(x.length===0)return e;return`${e.slice(0,c.insertPos)} ${x.join(" ")}${e.slice(c.insertPos)}`}function we(e){let i=Jt(e,0);if(i)return i;let t=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(e);if(t)return{insertPos:t.index+1+t[1].length,tagEnd:dt(e,t.index+1+t[1].length)};return null}function ft(e,i=!1){let t=we(e);if(!t)return null;let o=e.slice(t.insertPos,t.tagEnd),a=/\bdata-stx-component-wrapper(?:\s|=|>|$)/i.test(o)?Jt(e,t.tagEnd+1):t;return a&&i?sr(e,a)??a:a}function sr(e,i){if(!e.includes("data-stx-native-host-root"))return null;let t=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),o=e.lastIndexOf("<",i.insertPos),a=0,c;while(o>=0&&o<e.length){if(e.startsWith("<!--",o)){let S=e.indexOf("-->",o+4);if(S<0)return null;o=e.indexOf("<",S+3);continue}let l=/^<(\/?)([a-z][\w-]*)\b/i.exec(e.slice(o));if(!l){o=e.indexOf("<",o+1);continue}let m=l[2].toLowerCase(),u=o+l[0].length,y=dt(e,u);if(l[1]){if(a--,c!==void 0&&a<c)c=void 0;if(a<=0)return null}else if(m==="script"||m==="style"){let S=new RegExp(`</${m}\\s*>`,"gi");if(S.lastIndex=y+1,!S.exec(e))return null;o=e.indexOf("<",S.lastIndex);continue}else{let S=me(e.slice(u,y)),h=a>0&&(Object.hasOwn(S,"data-stx-component-wrapper")||Object.hasOwn(S,"data-stx-native-host-owner"));if(c===void 0&&!h&&Object.hasOwn(S,"data-stx-native-host-root"))return{insertPos:u,tagEnd:y};if(!t.has(m)&&e[y-1]!=="/"){if(a++,c===void 0&&h)c=a}else if(a===0)return null}o=e.indexOf("<",y+1)}return null}function Jt(e,i){let t=i;while(t<e.length){let o=e.slice(t),a=o.match(/^\s+/);if(a){t+=a[0].length;continue}if(o.startsWith("<!--")){let m=e.indexOf("-->",t+4);if(m===-1)return null;t=m+3;continue}let c=o.match(/^<(script|style)\b[^>]*>/i);if(c){let m=`</${c[1].toLowerCase()}>`,u=e.toLowerCase().indexOf(m,t+c[0].length);if(u===-1)return null;t=u+m.length;continue}let l=o.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!l)return null;return{insertPos:t+1+l[1].length,tagEnd:dt(e,t+1+l[1].length)}}return null}function dt(e,i){let t="";for(let o=i;o<e.length;o++){let a=e[o];if(t){if(a==="\\")o++;else if(a===t)t=""}else if(a==='"'||a==="'")t=a;else if(a===">")return o}return e.length}function ir(e){let i=new Set;for(let t of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let o=t[1];if(!/\bclient\b/.test(o)||/\bserver\b/.test(o))continue;for(let a of ui(t[2]))i.add(a);for(let a of t[2].matchAll(/^\s*import\s+(?:type\s+)?(?:([\w$]+)\s*,?\s*)?(?:\{([^}]*)\}|\*\s+as\s+([\w$]+))?\s*from\s/gm)){if(a[1])i.add(a[1]);if(a[3])i.add(a[3]);for(let c of(a[2]??"").split(",")){let l=c.replace(/^\s*type\s+/,"").split(/\s+as\s+/).pop().trim();if(/^[A-Za-z_$][\w$]*$/.test(l))i.add(l)}}}return i}async function us(e,i,t,o,a){if(!Zt)jt(ue),Zt=!0;let c=await Nf(e,i,t,o,a);c=await er(c,i,t,o,a),c=await tr(c,i,t,o,a);let l=[];for(let m=0;m<3;m++){let u=l.length,y=pe(c,Ne,(h,C)=>`\x00STX_COMPONENT_COMMENT_${u+C}\x00`,`STX_COMPONENT_COMMENT:${u}`);l.push(...y.tokens);let S=c;if(c=await nr(y.output,i,t,o,a),c===S)break}if(l.length>0)c=c.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(m,u)=>l[Number(u)]??"");if(o.debug){let m=Qn(c);if(m.length>0)console.warn(`[stx] ${t}: unresolved component tag(s) after render passes: ${m.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return c}
|
|
42
|
+
export{Lo,jo,Bo,Ih,ls,Oh,cc,Nf,us};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var d=0;function l(){return`keep-alive-${++d}-${Date.now().toString(36)}`}function
|
|
2
|
+
var d=0;function l(){return`keep-alive-${++d}-${Date.now().toString(36)}`}function _m(e,t={},n){let i=/@keepAlive(?:\s*\(([^)]*)\))?\s*([\s\S]*?)@endkeepAlive/gi;return e.replace(i,(a,c,o)=>{let s=l(),r=u(c||"");return p(s,o.trim(),r)})}function u(e){let t={max:10},n=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,i;while((i=n.exec(e))!==null){let a=i[1],c=i[2]||i[3],o=i[4];switch(a){case"max":t.max=o?parseInt(o,10):10;break;case"include":t.include=c;break;case"exclude":t.exclude=c;break;case"id":t.id=c;break}}return t}function p(e,t,n){let{max:i,include:a,exclude:c}=n,o=n.id||e;return`
|
|
3
3
|
<div class="stx-keep-alive" data-keep-alive-id="${e}" data-custom-id="${o}">
|
|
4
4
|
<div class="stx-keep-alive-content" data-keep-alive-content="${e}">
|
|
5
5
|
${t}
|
|
@@ -286,7 +286,7 @@ else {
|
|
|
286
286
|
});
|
|
287
287
|
})();
|
|
288
288
|
</script>
|
|
289
|
-
`}function
|
|
289
|
+
`}function Cm(e={}){return{id:e.id||l(),cache:new Map,max:e.max||10,include:e.include?e.include.split(",").map((n)=>n.trim()):null,exclude:e.exclude?e.exclude.split(",").map((n)=>n.trim()):null}}function Em(e,t){if(t.exclude&&t.exclude.includes(e))return!1;if(t.include&&!t.include.includes(e))return!1;return!0}function Tm(){return`
|
|
290
290
|
/* STX Keep-Alive Styles */
|
|
291
291
|
.stx-keep-alive {
|
|
292
292
|
position: relative;
|
|
@@ -311,7 +311,7 @@ else {
|
|
|
311
311
|
.stx-keep-alive-content > [data-activated] {
|
|
312
312
|
opacity: 1;
|
|
313
313
|
}
|
|
314
|
-
`}function
|
|
314
|
+
`}function $m(){return`
|
|
315
315
|
// STX Keep-Alive Runtime
|
|
316
316
|
(function() {
|
|
317
317
|
if (typeof window === 'undefined') return;
|
|
@@ -347,5 +347,5 @@ else {
|
|
|
347
347
|
|
|
348
348
|
console.log('[stx] Keep-alive runtime initialized');
|
|
349
349
|
})();
|
|
350
|
-
`}function
|
|
351
|
-
export{
|
|
350
|
+
`}function Rm(e){if(typeof document<"u")document.addEventListener("stx:activated",(t)=>{e(t.detail)})}function Am(e){if(typeof document<"u")document.addEventListener("stx:deactivated",(t)=>{e(t.detail)})}
|
|
351
|
+
export{_m,Cm,Em,Tm,$m,Rm,Am};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Tl,$l}from"./chunk-2235krey.js";import"./chunk-cxz4cdcn.js";import"./chunk-ftfjwjes.js";import"./chunk-aqh663ef.js";import"./chunk-wc7dn3mr.js";import"./chunk-8w9spdbn.js";import"./chunk-30rpspzt.js";import"./chunk-nb5d00dz.js";import"./chunk-h7fgk4ew.js";import"./chunk-3zhwcckc.js";import"./chunk-z23arg8m.js";import"./chunk-d6d2s7n6.js";import"./chunk-67kbsav0.js";import"./chunk-ydr5y7va.js";import"./chunk-akj26p4b.js";import"./chunk-mwxbdpb1.js";import"./chunk-pvj0bpqg.js";import"./chunk-vzbyn4nh.js";import"./chunk-p1fpferp.js";import"./chunk-3yh6y00f.js";import"./chunk-nype1b17.js";import"./chunk-h1hm975m.js";import"./chunk-3axb6t08.js";import"./chunk-f0txsdpa.js";import"./chunk-btxnrqxf.js";import"./chunk-9gmceny5.js";import"./chunk-xc0kwms2.js";import"./chunk-90p175a7.js";import"./chunk-hbdzhpy1.js";import"./chunk-atszywea.js";import"./chunk-n7arptzc.js";import"./chunk-gjf8cjdt.js";import{Qt}from"./chunk-b89wsq8r.js";import"./chunk-zefkd9t8.js";import"./chunk-bsg90smr.js";import"./chunk-7sh9fa3q.js";import{Re,i}from"./chunk-0p797a25.js";import"./chunk-zbyfxcrr.js";import"./chunk-p77cnteg.js";import"./chunk-c84pxd2k.js";import"./chunk-vyb4sxh9.js";import"./chunk-ec2f30f7.js";import"./chunk-qe5h58mx.js";import"./chunk-wceg59n0.js";import"./chunk-5e88021j.js";import{we}from"./chunk-4t4af1mb.js";import"./chunk-2nj9aewf.js";import{lr,ur}from"./chunk-gywyr2x3.js";import{xs,B,a}from"./chunk-xdbwghty.js";import"./chunk-bkdfkm10.js";import"./chunk-k81trehg.js";import"./chunk-wf0n9gpj.js";import"./chunk-xpy9yjyx.js";import"./chunk-qj4r08jb.js";import{m,Le}from"./chunk-j4cjn4m1.js";import"./chunk-k0bztfk3.js";import"./chunk-2vqpz4qv.js";import"./chunk-8ttmzcxb.js";import"./chunk-r9e0r6jx.js";import"./chunk-bt0amey5.js";import"./chunk-tksjakyv.js";import"./chunk-qz3fdmrc.js";export{xs as buildWebComponents,ur as cacheTemplate,lr as checkCache,Qt as classifyAllScripts,Tl as createMiddleware,$l as createRoute,B as defaultConfig,m as extractVariables,we as injectRouterScript,a as loadStxConfig,Le as processClientScript,i as processDirectives,Re as readMarkdownFile};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ze,N,Dt}from"./chunk-m7hfcxt3.js";import{T}from"./chunk-72jt897s.js";import{ft,Ce,L,qe,Ee,da,ho,pa,In}from"./chunk-m9dyqae7.js";import{St,ue,et}from"./chunk-gtd6qs1r.js";import{Io}from"./chunk-x46hqa74.js";import{On}from"./chunk-j3st59hv.js";import{be}from"./chunk-rccv14mn.js";import Z from"fs";import P from"path";var{serve:ce}=globalThis.Bun;import F from"zlib";import{promisify as Q}from"util";var K=Q(F.brotliCompress),ee=Q(F.gzip),te=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ne=["text/event-stream","multipart/x-mixed-replace"],re=1024;function se(t){if(!t)return!1;let e=t.toLowerCase();if(ne.some((a)=>e.startsWith(a)))return!1;return te.some((a)=>e.startsWith(a))}function oe(t){let e=new Map;for(let a of t.split(",")){let[r,...i]=a.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of i){let l=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(g);if(!l)continue;let m=Number.parseFloat(l[1]);if(Number.isFinite(m))h=m}e.set(f,h)}return e}function ae(t){if(!t)return null;let e=oe(t),a=e.get("*"),r=(i)=>e.get(i)??a??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var Y=33554432,H=new Map,U=0;function ie(t,e){if(e.length>Y/8)return;H.set(t,e),U+=e.length;for(let[a,r]of H){if(U<=Y)break;H.delete(a),U-=r.length}}async function $n(t,e,a={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!se(e.headers.get("content-type")))return e;let r=ae(t.headers.get("accept-encoding"));if(!r)return e;let i;try{i=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(i,{status:e.status,statusText:e.statusText,headers:J(e.headers)});if(i.length<(a.threshold??re))return f();try{let h=a.quality??5,g=`${r}:${h}:${i.length}:${Bun.hash(i)}`,l=H.get(g);if(!l)l=r==="br"?await K(i,{params:{[F.constants.BROTLI_PARAM_QUALITY]:h,[F.constants.BROTLI_PARAM_SIZE_HINT]:i.length}}):await ee(i),ie(g,l);if(l.length>=i.length)return f();let m=J(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function J(t){let e=new Headers(t),a=e.get("Vary");if(!a)return e.set("Vary","Accept-Encoding"),e;if(!a.split(",").some((i)=>i.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${a}, Accept-Encoding`);return e}class G{now;entries=new T(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,a){let r,i=async()=>{let s=r??await a();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",L(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return i();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${Ce(t)?"fragment":"document"}`,g=this.entries.get(h),l=(s)=>{let b=new Headers(s.headers);return b.set("Cache-Control","private, no-store"),b.set("Age",String(Math.max(0,Math.floor((this.now()-s.created)/1000)))),new Response(s.body.slice(0),{headers:b})},m=g?(this.now()-g.created)/1000:1/0;if(g&&m<e.maxAge)return l(g);let v=this.generation,k=async()=>{let s=await a();r=s;let b=(s.headers.get("Vary")??"").toLowerCase().split(",").map((y)=>y.trim()).filter(Boolean);if(s.status!==200||s.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(s.headers.get("Cache-Control")??"")||b.some((y)=>y!=="x-stx-router"&&y!=="accept-encoding"))return null;let E=await s.clone().arrayBuffer();if(E.byteLength>1048576)return null;s.headers.set("Vary",L(s.headers.get("Vary")).Vary);let n={body:E,headers:Array.from(s.headers.entries()),created:this.now(),path:f.pathname};if(this.generation===v)this.entries.set(h,n);return n},x=this.pending.get(h);if(!x){if(this.pending.size>=1000)return i();x=k().finally(()=>{if(this.pending.get(h)===x)this.pending.delete(h)}),this.pending.set(h,x)}if(g&&m<e.maxAge+(e.swr??0))return x.catch(()=>{}),l(g);let M=await x;return M?l(M):i()}}var pe={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function Xg(t={}){let e=P.resolve(t.outputDir||".output"),a=t.port??3000,r=da(e);if(!r)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${r.routes.length} routes...`);let i=On(r.routeRules),f=new G,h=Io(e,r.apiRoutes??[]),g=Bun.file(P.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?N(l):void 0,v=new Map,k=new Map,x=new Map,M=new Map;for(let n of r.routes)try{let y=P.join(e,n.compiledPath),c=JSON.parse(await Bun.file(y).text());if(m)c.html=Dt(c.html,m);v.set(n.pattern,c),x.set(n.pattern,et(c.html)),M.set(n.pattern,be(c.html));let X=P.join(e,n.fragmentPath);if(qe(c.html,r.routerContainer||"main")&&await Bun.file(X).exists()){let A=await Bun.file(X).text();k.set(n.pattern,m?Dt(A,m):A)}}catch(y){console.warn(`[stx] Failed to load route ${n.pattern}:`,y)}let s=new Map,b=[];for(let n of r.routes)if(n.hasParams){let{regex:y,params:c}=ue(n.pattern,{page:!0});b.push({regex:y,route:n,paramNames:c})}else s.set(n.pattern,n);let E=ce({port:a,async fetch(n){return $n(n,await ze(m??N(),async()=>{let c=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[c])return t.apiRoutes[c](n);let X=await h(n);if(X)return X;if((n.method==="GET"||n.method==="HEAD")&&c!=="/"){let p=P.resolve(e,"public"),d;try{d=decodeURIComponent(c)}catch{d=c}if(!d.includes("\x00")){let u=P.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${P.sep}`))try{if(Z.existsSync(u)&&Z.statSync(u).isFile()){let R=P.extname(u).toLowerCase(),B=pe[R]||"application/octet-stream",_=c.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(c);return new Response(Bun.file(u),{headers:{"Content-Type":B,"Cache-Control":_?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=Ce(n),C=null,q={};if(C=s.get(c)||null,!C)for(let{regex:p,route:d,paramNames:u}of b){let o=c.match(p);if(o){C=d,u.forEach((R,B)=>{q[R]=o[B+1]});break}}if(!C){let p=St(c)?null:s.get("/404")||null;if(p){let d=v.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let O=i(c),W=Object.keys(O).length>0;return f.respond(n,O.cache,async()=>{let p=v.get(C.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let o=k.get(C.pattern);if(o){let R=x.get(C.pattern);return new Response(o,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...M.has(C.pattern)?{"X-STX-Runtime":M.get(C.pattern)?"true":"false"}:{},...R?{"X-STX-Layout":R.layout,"X-STX-Layout-Group":R.group}:{},...L(),...O.cache?{}:{"Cache-Control":ft}}})}}let d=ho(n.method),u=v.get(C.pattern);if(!u){let o=s.get("/500")||null;if(o){let R=v.get(o.pattern);if(R)return new Response(R.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(C.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",...L(),"Cache-Control":"public, max-age=60"}});try{let{html:o,boundaries:R,redirect:B,cookies:_,status:I,headers:D}=await In(u,{params:q,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:m});if(B)return pa(B,_,D);if(R&&R.length>0){let{renderStreamingPage:S,streamToResponse:z}=await import("./chunk-pe89ztq6.js"),j=new Headers({...L(),...D,"Cache-Control":"private, no-store"});for(let V of _??[])j.append("Set-Cookie",V);if(A&&!d&&qe(o,r.routerContainer||"main")){let V=et(o);j.set("X-STX-Fragment","true"),j.set("X-STX-Runtime",be(o)?"true":"false"),j.set("X-STX-Layout",V.layout),j.set("X-STX-Layout-Group",V.group)}return z(S(A&&!d&&qe(o,r.routerContainer||"main")?Ee(o,r.routerContainer||"main",!0):o,R,{timeoutMs:30000}),{status:I??u.status??200,headers:j})}let w=new Headers({"Content-Type":"text/html",...L(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let S of _??[])w.append("Set-Cookie",S);for(let[S,z]of Object.entries(D??{}))w.set(S,z);if(w.set("Vary",L(w.get("Vary")).Vary),A&&!d&&qe(o,r.routerContainer||"main")){let S=et(o);return w.set("X-STX-Fragment","true"),w.set("X-STX-Runtime",be(o)?"true":"false"),w.set("X-STX-Layout",S.layout),w.set("X-STX-Layout-Group",S.group),new Response(Ee(o,r.routerContainer||"main",!0),{status:I??u.status??200,headers:w})}return new Response(o,{status:I??u.status??200,headers:w})}catch(o){if(console.error(`[stx] Hydration error for ${c}:`,o),W)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${E.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${v.size} pre-loaded)`),{port:E.port,stop:()=>{f.invalidate(),E.stop()},invalidate:(n)=>f.invalidate(n)}}
|
|
3
|
-
export{$n,
|
|
2
|
+
import{ze,N,Dt}from"./chunk-2vqpz4qv.js";import{T}from"./chunk-8ttmzcxb.js";import{ft,Ce,L,qe,Ee,pa,ho,fa,In}from"./chunk-3zhwcckc.js";import{St,ue,et}from"./chunk-qj4r08jb.js";import{Io}from"./chunk-bsg90smr.js";import{On}from"./chunk-j3st59hv.js";import{be}from"./chunk-4t4af1mb.js";import Z from"fs";import P from"path";var{serve:ce}=globalThis.Bun;import F from"zlib";import{promisify as Q}from"util";var K=Q(F.brotliCompress),ee=Q(F.gzip),te=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ne=["text/event-stream","multipart/x-mixed-replace"],re=1024;function se(t){if(!t)return!1;let e=t.toLowerCase();if(ne.some((a)=>e.startsWith(a)))return!1;return te.some((a)=>e.startsWith(a))}function oe(t){let e=new Map;for(let a of t.split(",")){let[r,...i]=a.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of i){let l=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(g);if(!l)continue;let m=Number.parseFloat(l[1]);if(Number.isFinite(m))h=m}e.set(f,h)}return e}function ae(t){if(!t)return null;let e=oe(t),a=e.get("*"),r=(i)=>e.get(i)??a??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var Y=33554432,H=new Map,U=0;function ie(t,e){if(e.length>Y/8)return;H.set(t,e),U+=e.length;for(let[a,r]of H){if(U<=Y)break;H.delete(a),U-=r.length}}async function $n(t,e,a={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!se(e.headers.get("content-type")))return e;let r=ae(t.headers.get("accept-encoding"));if(!r)return e;let i;try{i=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(i,{status:e.status,statusText:e.statusText,headers:J(e.headers)});if(i.length<(a.threshold??re))return f();try{let h=a.quality??5,g=`${r}:${h}:${i.length}:${Bun.hash(i)}`,l=H.get(g);if(!l)l=r==="br"?await K(i,{params:{[F.constants.BROTLI_PARAM_QUALITY]:h,[F.constants.BROTLI_PARAM_SIZE_HINT]:i.length}}):await ee(i),ie(g,l);if(l.length>=i.length)return f();let m=J(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function J(t){let e=new Headers(t),a=e.get("Vary");if(!a)return e.set("Vary","Accept-Encoding"),e;if(!a.split(",").some((i)=>i.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${a}, Accept-Encoding`);return e}class G{now;entries=new T(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,a){let r,i=async()=>{let s=r??await a();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",L(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return i();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${Ce(t)?"fragment":"document"}`,g=this.entries.get(h),l=(s)=>{let b=new Headers(s.headers);return b.set("Cache-Control","private, no-store"),b.set("Age",String(Math.max(0,Math.floor((this.now()-s.created)/1000)))),new Response(s.body.slice(0),{headers:b})},m=g?(this.now()-g.created)/1000:1/0;if(g&&m<e.maxAge)return l(g);let v=this.generation,k=async()=>{let s=await a();r=s;let b=(s.headers.get("Vary")??"").toLowerCase().split(",").map((y)=>y.trim()).filter(Boolean);if(s.status!==200||s.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(s.headers.get("Cache-Control")??"")||b.some((y)=>y!=="x-stx-router"&&y!=="accept-encoding"))return null;let E=await s.clone().arrayBuffer();if(E.byteLength>1048576)return null;s.headers.set("Vary",L(s.headers.get("Vary")).Vary);let n={body:E,headers:Array.from(s.headers.entries()),created:this.now(),path:f.pathname};if(this.generation===v)this.entries.set(h,n);return n},x=this.pending.get(h);if(!x){if(this.pending.size>=1000)return i();x=k().finally(()=>{if(this.pending.get(h)===x)this.pending.delete(h)}),this.pending.set(h,x)}if(g&&m<e.maxAge+(e.swr??0))return x.catch(()=>{}),l(g);let M=await x;return M?l(M):i()}}var pe={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function Gg(t={}){let e=P.resolve(t.outputDir||".output"),a=t.port??3000,r=pa(e);if(!r)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${r.routes.length} routes...`);let i=On(r.routeRules),f=new G,h=Io(e,r.apiRoutes??[]),g=Bun.file(P.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?N(l):void 0,v=new Map,k=new Map,x=new Map,M=new Map;for(let n of r.routes)try{let y=P.join(e,n.compiledPath),c=JSON.parse(await Bun.file(y).text());if(m)c.html=Dt(c.html,m);v.set(n.pattern,c),x.set(n.pattern,et(c.html)),M.set(n.pattern,be(c.html));let X=P.join(e,n.fragmentPath);if(qe(c.html,r.routerContainer||"main")&&await Bun.file(X).exists()){let A=await Bun.file(X).text();k.set(n.pattern,m?Dt(A,m):A)}}catch(y){console.warn(`[stx] Failed to load route ${n.pattern}:`,y)}let s=new Map,b=[];for(let n of r.routes)if(n.hasParams){let{regex:y,params:c}=ue(n.pattern,{page:!0});b.push({regex:y,route:n,paramNames:c})}else s.set(n.pattern,n);let E=ce({port:a,async fetch(n){return $n(n,await ze(m??N(),async()=>{let c=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[c])return t.apiRoutes[c](n);let X=await h(n);if(X)return X;if((n.method==="GET"||n.method==="HEAD")&&c!=="/"){let p=P.resolve(e,"public"),d;try{d=decodeURIComponent(c)}catch{d=c}if(!d.includes("\x00")){let u=P.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${P.sep}`))try{if(Z.existsSync(u)&&Z.statSync(u).isFile()){let R=P.extname(u).toLowerCase(),B=pe[R]||"application/octet-stream",_=c.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(c);return new Response(Bun.file(u),{headers:{"Content-Type":B,"Cache-Control":_?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=Ce(n),C=null,q={};if(C=s.get(c)||null,!C)for(let{regex:p,route:d,paramNames:u}of b){let o=c.match(p);if(o){C=d,u.forEach((R,B)=>{q[R]=o[B+1]});break}}if(!C){let p=St(c)?null:s.get("/404")||null;if(p){let d=v.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let O=i(c),W=Object.keys(O).length>0;return f.respond(n,O.cache,async()=>{let p=v.get(C.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let o=k.get(C.pattern);if(o){let R=x.get(C.pattern);return new Response(o,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...M.has(C.pattern)?{"X-STX-Runtime":M.get(C.pattern)?"true":"false"}:{},...R?{"X-STX-Layout":R.layout,"X-STX-Layout-Group":R.group}:{},...L(),...O.cache?{}:{"Cache-Control":ft}}})}}let d=ho(n.method),u=v.get(C.pattern);if(!u){let o=s.get("/500")||null;if(o){let R=v.get(o.pattern);if(R)return new Response(R.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(C.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",...L(),"Cache-Control":"public, max-age=60"}});try{let{html:o,boundaries:R,redirect:B,cookies:_,status:I,headers:D}=await In(u,{params:q,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:m});if(B)return fa(B,_,D);if(R&&R.length>0){let{renderStreamingPage:S,streamToResponse:z}=await import("./chunk-7ffmz1fb.js"),j=new Headers({...L(),...D,"Cache-Control":"private, no-store"});for(let V of _??[])j.append("Set-Cookie",V);if(A&&!d&&qe(o,r.routerContainer||"main")){let V=et(o);j.set("X-STX-Fragment","true"),j.set("X-STX-Runtime",be(o)?"true":"false"),j.set("X-STX-Layout",V.layout),j.set("X-STX-Layout-Group",V.group)}return z(S(A&&!d&&qe(o,r.routerContainer||"main")?Ee(o,r.routerContainer||"main",!0):o,R,{timeoutMs:30000}),{status:I??u.status??200,headers:j})}let w=new Headers({"Content-Type":"text/html",...L(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let S of _??[])w.append("Set-Cookie",S);for(let[S,z]of Object.entries(D??{}))w.set(S,z);if(w.set("Vary",L(w.get("Vary")).Vary),A&&!d&&qe(o,r.routerContainer||"main")){let S=et(o);return w.set("X-STX-Fragment","true"),w.set("X-STX-Runtime",be(o)?"true":"false"),w.set("X-STX-Layout",S.layout),w.set("X-STX-Layout-Group",S.group),new Response(Ee(o,r.routerContainer||"main",!0),{status:I??u.status??200,headers:w})}return new Response(o,{status:I??u.status??200,headers:w})}catch(o){if(console.error(`[stx] Hydration error for ${c}:`,o),W)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${E.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${v.size} pre-loaded)`),{port:E.port,stop:()=>{f.invalidate(),E.stop()},invalidate:(n)=>f.invalidate(n)}}
|
|
3
|
+
export{$n,Gg};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{u,f,nl,d,t,l}from"./chunk-72jt897s.js";import{Ze,vt,ln,Ko}from"./chunk-fmawgk87.js";function L(w,e){try{let p=w.trim();if(f(p))return d(p,Object.keys(e))(...Object.values(e));else return u(p,e)}catch{return!1}}function Q(w,e,p){let n=w,v=!0;while(v){v=!1;let g=n.match(/@switch\s*\(/);if(!g||g.index===void 0)break;let b=g.index,s=Ko(n,b);if(!s)break;try{let o;if(f(s.expression))o=d(s.expression,Object.keys(e))(...Object.values(e));else o=u(s.expression,e);let r="",a=!1;for(let i of s.cases)if(i.type==="default"){if(!a)r=i.content.trim()}else try{let y;if(i.value&&f(i.value))y=d(i.value,Object.keys(e))(...Object.values(e));else if(i.value)y=u(i.value,e);if(o===y){r=i.content.trim(),a=!0;break}}catch{continue}n=n.substring(0,b)+r+n.substring(s.end),v=!0}catch(o){let r=o instanceof Error?o.message:String(o),a=l("Switch",`Error evaluating @switch expression: ${r}`,t.EVALUATION_ERROR);n=n.substring(0,b)+a+n.substring(s.end);break}}return n}function H(w){let e=[];return{masked:w.replace(/<script\b[\s\S]*?<\/script\s*>/gi,(n)=>(e.push(n),`\x00stx-script-${e.length-1}\x00`)),scripts:e}}function J(w,e){if(e.length===0)return w;return w.replace(/\u0000stx-script-(\d+)\u0000/g,(p,n)=>e[Number(n)]??p)}function se(w,e,p){let{masked:n,scripts:v}=H(w);return J(K(n,e,p),v)}function K(w,e,p){let n=w;n=Q(n,e,p);{let g=!0;while(g){g=!1;let b=n.match(/@unless\s*\(/);if(!b||b.index===void 0)break;let s=b.index,o=Ze(n,s+7);if(!o)break;let r=o.endPos,a=vt(n,"unless","endunless",r);if(a===-1){console.warn(`[stx] @unless directive at position ${s} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let i=n.slice(r,a),y=o.expression,m=-1;{let x=0,k=/@(?:if|unless)\s*\(/g,h=/@(?:endif|endunless)(?![a-z])/g,E=/@else(?![a-z])/g,S=[],C;while((C=k.exec(i))!==null)S.push({pos:C.index,type:"open"});while((C=h.exec(i))!==null)S.push({pos:C.index,type:"close"});while((C=E.exec(i))!==null)S.push({pos:C.index,type:"else"});S.sort((P,R)=>P.pos-R.pos);for(let P of S)if(P.type==="open")x++;else if(P.type==="close")x--;else if(P.type==="else"&&x===0){m=P.pos;break}}let c;if(m!==-1){let x=i.slice(0,m),k=i.slice(m+5);c=`@if (${y})${k}@else ${x}@endif`}else c=`@if (!(${y}))${i}@endif`;n=n.substring(0,s)+c+n.substring(a+10),g=!0}}n=zo(n,e,p),n=Ho(n,e,p),n=Fo(n,e);let v=()=>{let g=ln(n);if(g.length===0)return!1;let b=Array(g.length);for(let r=g.length-1;r>=0;r--){let a=g[r];try{let i="",y=!1;for(let m of a.branches){if(y)break;if(m.type==="else")i=m.content,y=!0;else try{if(m.condition?nl(m.condition,e):!1)i=m.content,y=!0}catch(c){i=l(m.type==="if"?"If":"Elseif",`Error in @${m.type}(${m.condition}): ${c instanceof Error?c.message:String(c)}`,t.EVALUATION_ERROR),y=!0}}b[r]=i}catch(i){let y=i instanceof Error?i.message:String(i);b[r]=l("If",`Error processing @if block: ${y}`,t.EVALUATION_ERROR)}}let s=Array(g.length*2+1),o=0;for(let r=0;r<g.length;r++){let a=g[r];s[r*2]=n.slice(o,a.start),s[r*2+1]=b[r],o=a.end}return s[g.length*2]=n.slice(o),n=s.join(""),!0};while(!0){let g=n;if(!v())break;if(n===g)break}return n}function q(w){let e=0;while(e<w.length&&/\s/.test(w[e]))e++;if(w[e]!=="(")return null;e++;while(e<w.length&&/\s/.test(w[e]))e++;let p=w[e];if(p!=="'"&&p!=='"')return null;e++;let n=[];while(e<w.length){let v=w[e];if(v==="\\"&&e+1<w.length){n.push(w[e+1]),e+=2;continue}if(v===p){e++;break}n.push(v),e++}while(e<w.length&&/\s/.test(w[e]))e++;if(w[e]!==")")return null;return e++,{value:n.join(""),consumed:e}}function Fo(w,e){let p=w;function n(s,o,r,a){let i=1,y=a,m=new RegExp(`@${o}(?:\\s*\\(|\\s|$)`,"g"),c=new RegExp(`@${r}(?![a-z])`,"g");while(y<s.length&&i>0){m.lastIndex=y,c.lastIndex=y;let x=m.exec(s),k=c.exec(s),h=x?x.index:1/0,E=k?k.index:1/0;if(h<E)i++,y=h+x[0].length;else if(E<1/0){if(i--,i===0)return E;y=E+k[0].length}else break}return-1}function v(s,o,r){let a=0,i=new RegExp(`@${o}(?:\\s*\\(|\\s|$)`,"g"),y=new RegExp(`@${r}(?![a-z])`,"g"),m=/@else(?![a-z])/g,c=[],x;while((x=i.exec(s))!==null)c.push({pos:x.index,type:"open"});while((x=y.exec(s))!==null)c.push({pos:x.index,type:"close"});while((x=m.exec(s))!==null)c.push({pos:x.index,type:"else"});c.sort((k,h)=>k.pos-h.pos);for(let k of c)if(k.type==="open")a++;else if(k.type==="close")a--;else if(k.type==="else"&&a===0)return k.pos;return-1}{let s=!0;while(s){s=!1;let o=p.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!o||o.index===void 0)break;let r=o.index,a,i,y=p.slice(r+5),m=q(y);if(m)a=m.value,i=r+5+m.consumed;else i=r+5;let c=n(p,"auth","endauth",i);if(c===-1){console.warn(`[stx] @auth directive at position ${r} has no matching @endauth \u2014 the block was skipped.`);break}let x=p.slice(i,c),k=v(x,"auth","endauth"),h;if(!e.auth)h=!1;else h=a?L(`auth?.check && auth?.user?.[${a}]`,e):L("auth?.check",e);let E;if(k!==-1){let S=x.slice(0,k),C=x.slice(k+5);E=h?S:C}else E=h?x:"";p=p.substring(0,r)+E+p.substring(c+8),s=!0}}{let s=!0;while(s){s=!1;let o=p.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!o||o.index===void 0)break;let r=o.index,a,i,y=p.slice(r+6),m=q(y);if(m)a=m.value,i=r+6+m.consumed;else i=r+6;let c=n(p,"guest","endguest",i);if(c===-1){console.warn(`[stx] @guest directive at position ${r} has no matching @endguest \u2014 the block was skipped.`);break}let x=p.slice(i,c),k=v(x,"guest","endguest"),h;if(!e.auth)h=!0;else h=a?L(`!auth?.check || !auth?.user?.[${a}]`,e):L("!auth?.check",e);let E;if(k!==-1){let S=x.slice(0,k),C=x.slice(k+5);E=h?S:C}else E=h?x:"";p=p.substring(0,r)+E+p.substring(c+9),s=!0}}function g(s,o,r){if(e.userCan&&typeof e.userCan[s]==="boolean")return e.userCan[s];if(e.permissions?.check&&typeof e.permissions.check==="function")try{let a=[s];if(o)a.push(o);if(r){let i=L(r,e);a.push(i)}return e.permissions.check(...a)}catch{return!1}return!1}function b(s){let o=s.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!o)return null;return{ability:o[1],type:o[2],id:o[3]?.trim(),paramsEnd:o[0].length}}for(let s of["can","cannot"]){let o=`end${s}`,r=s==="can"?"elsecan":"elsecannot",a=!0;while(a){a=!1;let i=p.match(new RegExp(`@${s}\\s*\\(`));if(!i||i.index===void 0)break;let y=i.index,m=p.slice(y+`@${s}`.length),c=b(m);if(!c)break;let x=y+`@${s}`.length+c.paramsEnd,k=n(p,s,o,x);if(k===-1){console.warn(`[stx] @${s} directive at position ${y} has no matching @${o} \u2014 the block was skipped.`);break}let h=p.slice(x,k),E=[],S=0,C=new RegExp(`@${s}\\s*\\(`,"g"),P=new RegExp(`@${o}(?![a-z])`,"g"),R=new RegExp(`@${r}\\s*\\(`,"g"),T=/@else(?![a-z])/g,_=[],M;while((M=C.exec(h))!==null)_.push({pos:M.index,type:"open"});while((M=P.exec(h))!==null)_.push({pos:M.index,type:"close"});while((M=R.exec(h))!==null)_.push({pos:M.index,type:"elseDirective"});while((M=T.exec(h))!==null)_.push({pos:M.index,type:"else"});_.sort((A,z)=>A.pos-z.pos);for(let A of _){if(A.type==="open"){S++;continue}if(A.type==="close"){S--;continue}if(S===0)E.push(A)}let I=[],F=0;for(let A=0;A<E.length;A++){let z=E[A];if(I.push({content:h.slice(F,z.pos),ability:void 0}),z.type==="elseDirective"){let D=h.slice(z.pos+`@${r}`.length),B=b(D);if(B){I[I.length-1]={content:h.slice(F,z.pos)},F=z.pos+`@${r}`.length+B.paramsEnd,I.push({content:"",ability:B.ability,type:B.type,id:B.id}),I.pop();let G=E[A+1],U=G?G.pos:h.length;I.push({content:h.slice(F,U),ability:B.ability,type:B.type,id:B.id}),F=U}}else F=z.pos+5}if(F<h.length){let A=I[I.length-1];if(E.length>0&&E[E.length-1].type==="else")I.push({content:h.slice(F),isFinalElse:!0});else if(I.length===0)I.push({content:h.slice(F)})}let O=g(c.ability,c.type,c.id),j=s==="can"?O:!O,V="";if(j)V=I[0]?.content||"";else{let A=!1;for(let z=1;z<I.length;z++){let D=I[z];if(D.isFinalElse){V=D.content,A=!0;break}if(D.ability){let B=g(D.ability,D.type,D.id);if(s==="can"?B:!B){V=D.content,A=!0;break}}}if(!A&&I.length>0){let z=I[I.length-1];if(z.isFinalElse)V=z.content}}p=p.substring(0,y)+V+p.substring(k+`@${o}`.length),a=!0}}return p}function zo(w,e,p){let n=w;function v(g,b,s,o,r){let a=!0;while(a){a=!1;let i=new RegExp(`@${b}\\s*\\(`),y=g.match(i);if(!y||y.index===void 0)break;let m=y.index,c=Ze(g,m+`@${b}`.length);if(!c)break;let x=c.endPos,k=vt(g,b,s,x);if(k===-1){console.warn(`[stx] @${b} directive at position ${m} has no matching @${s} \u2014 the block was skipped.`);break}let h=g.slice(x,k),E=c.expression,S=-1,C=0,P=0;while(P<h.length){let R=h.indexOf("@",P);if(R===-1)break;let T=h.substring(R);if(/^@(?:if|unless|isset|empty)\s*\(/.test(T)){C++,P=R+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(T)){C--,P=R+1;continue}if(C===0&&/^@else(?![a-z])/.test(T)){S=R;break}P=R+1}try{let R=o(E.trim()),T;if(S!==-1){let _=h.slice(0,S),M=h.slice(S+5);T=R?_:M}else T=R?h:"";g=g.substring(0,m)+T+g.substring(k+`@${s}`.length),a=!0}catch(R){let T=R instanceof Error?R.message:String(R),_=l(r,`Error processing @${b} directive: ${T}`,t.EVALUATION_ERROR);g=g.substring(0,m)+_+g.substring(k+`@${s}`.length);break}}return g}return n=v(n,"isset","endisset",(g)=>{let b=L(g,e);return b!==void 0&&b!==null},"Isset"),n=v(n,"empty","endempty",(g)=>{let b=L(g,e);return b===void 0||b===null||b===""||b===0||b===!1||Array.isArray(b)&&b.length===0||typeof b==="object"&&b!==null&&Object.keys(b).length===0},"Empty"),n}function Ho(w,e,p){let n=w,v="development";function g(b,s,o,r){let a=new RegExp(`@${s}(?![a-z])`,"g"),i=new RegExp(`@${o}(?![a-z])`,"g"),y=new RegExp(`^@${s}(?![a-z])`),m=new RegExp(`^@${o}(?![a-z])`),c=b,x=!0;while(x){x=!1,a.lastIndex=0;let k=a.exec(c);if(!k)break;let h=k.index,E=h+k[0].length;if(s==="env"){let O=c.substring(E).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!O)break;E+=O[0].length,r=v===O[2]}let S=1,C=E,P=-1;while(S>0&&C<c.length){a.lastIndex=C,i.lastIndex=C;let O=a.exec(c),j=i.exec(c),V=O?O.index:1/0,A=j?j.index:1/0;if(V<A)S++,C=V+O[0].length;else if(A<1/0){if(S--,S===0){P=A;break}C=A+j[0].length}else break}if(P===-1){console.warn(`[stx] @${s} directive at position ${h} has no matching @${o} \u2014 the block was skipped.`);break}let R=c.substring(E,P),T=-1,_=0,M=0;while(M<R.length){let O=R.indexOf("@",M);if(O===-1)break;let j=R.substring(O);if(y.test(j)){_++,M=O+1;continue}if(m.test(j)){_--,M=O+1;continue}if(_===0&&/^@else(?![a-z])/.test(j)){T=O;break}M=O+1}let I;if(T!==-1){let O=R.slice(0,T),j=R.slice(T+5);I=r?O:j}else I=r?R:"";let F=`@${o}`.length;c=c.substring(0,h)+I+c.substring(P+F),x=!0}return c}return n=g(n,"env","endenv",!1),n=g(n,"production","endproduction",v==="production"),n=g(n,"development","enddevelopment",v==="development"),n=g(n,"staging","endstaging",v==="staging"),n=g(n,"testing","endtesting",v==="testing"),n}
|
|
2
|
+
import{u,f,rl,d,t,l}from"./chunk-8ttmzcxb.js";import{Ze,vt,ln,Ko}from"./chunk-2nj9aewf.js";function L(w,e){try{let p=w.trim();if(f(p))return d(p,Object.keys(e))(...Object.values(e));else return u(p,e)}catch{return!1}}function Q(w,e,p){let n=w,v=!0;while(v){v=!1;let g=n.match(/@switch\s*\(/);if(!g||g.index===void 0)break;let b=g.index,s=Ko(n,b);if(!s)break;try{let o;if(f(s.expression))o=d(s.expression,Object.keys(e))(...Object.values(e));else o=u(s.expression,e);let r="",a=!1;for(let i of s.cases)if(i.type==="default"){if(!a)r=i.content.trim()}else try{let y;if(i.value&&f(i.value))y=d(i.value,Object.keys(e))(...Object.values(e));else if(i.value)y=u(i.value,e);if(o===y){r=i.content.trim(),a=!0;break}}catch{continue}n=n.substring(0,b)+r+n.substring(s.end),v=!0}catch(o){let r=o instanceof Error?o.message:String(o),a=l("Switch",`Error evaluating @switch expression: ${r}`,t.EVALUATION_ERROR);n=n.substring(0,b)+a+n.substring(s.end);break}}return n}function H(w){let e=[];return{masked:w.replace(/<script\b[\s\S]*?<\/script\s*>/gi,(n)=>(e.push(n),`\x00stx-script-${e.length-1}\x00`)),scripts:e}}function J(w,e){if(e.length===0)return w;return w.replace(/\u0000stx-script-(\d+)\u0000/g,(p,n)=>e[Number(n)]??p)}function se(w,e,p){let{masked:n,scripts:v}=H(w);return J(K(n,e,p),v)}function K(w,e,p){let n=w;n=Q(n,e,p);{let g=!0;while(g){g=!1;let b=n.match(/@unless\s*\(/);if(!b||b.index===void 0)break;let s=b.index,o=Ze(n,s+7);if(!o)break;let r=o.endPos,a=vt(n,"unless","endunless",r);if(a===-1){console.warn(`[stx] @unless directive at position ${s} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let i=n.slice(r,a),y=o.expression,m=-1;{let x=0,k=/@(?:if|unless)\s*\(/g,h=/@(?:endif|endunless)(?![a-z])/g,E=/@else(?![a-z])/g,S=[],C;while((C=k.exec(i))!==null)S.push({pos:C.index,type:"open"});while((C=h.exec(i))!==null)S.push({pos:C.index,type:"close"});while((C=E.exec(i))!==null)S.push({pos:C.index,type:"else"});S.sort((P,R)=>P.pos-R.pos);for(let P of S)if(P.type==="open")x++;else if(P.type==="close")x--;else if(P.type==="else"&&x===0){m=P.pos;break}}let c;if(m!==-1){let x=i.slice(0,m),k=i.slice(m+5);c=`@if (${y})${k}@else ${x}@endif`}else c=`@if (!(${y}))${i}@endif`;n=n.substring(0,s)+c+n.substring(a+10),g=!0}}n=zo(n,e,p),n=Ho(n,e,p),n=Fo(n,e);let v=()=>{let g=ln(n);if(g.length===0)return!1;let b=Array(g.length);for(let r=g.length-1;r>=0;r--){let a=g[r];try{let i="",y=!1;for(let m of a.branches){if(y)break;if(m.type==="else")i=m.content,y=!0;else try{if(m.condition?rl(m.condition,e):!1)i=m.content,y=!0}catch(c){i=l(m.type==="if"?"If":"Elseif",`Error in @${m.type}(${m.condition}): ${c instanceof Error?c.message:String(c)}`,t.EVALUATION_ERROR),y=!0}}b[r]=i}catch(i){let y=i instanceof Error?i.message:String(i);b[r]=l("If",`Error processing @if block: ${y}`,t.EVALUATION_ERROR)}}let s=Array(g.length*2+1),o=0;for(let r=0;r<g.length;r++){let a=g[r];s[r*2]=n.slice(o,a.start),s[r*2+1]=b[r],o=a.end}return s[g.length*2]=n.slice(o),n=s.join(""),!0};while(!0){let g=n;if(!v())break;if(n===g)break}return n}function q(w){let e=0;while(e<w.length&&/\s/.test(w[e]))e++;if(w[e]!=="(")return null;e++;while(e<w.length&&/\s/.test(w[e]))e++;let p=w[e];if(p!=="'"&&p!=='"')return null;e++;let n=[];while(e<w.length){let v=w[e];if(v==="\\"&&e+1<w.length){n.push(w[e+1]),e+=2;continue}if(v===p){e++;break}n.push(v),e++}while(e<w.length&&/\s/.test(w[e]))e++;if(w[e]!==")")return null;return e++,{value:n.join(""),consumed:e}}function Fo(w,e){let p=w;function n(s,o,r,a){let i=1,y=a,m=new RegExp(`@${o}(?:\\s*\\(|\\s|$)`,"g"),c=new RegExp(`@${r}(?![a-z])`,"g");while(y<s.length&&i>0){m.lastIndex=y,c.lastIndex=y;let x=m.exec(s),k=c.exec(s),h=x?x.index:1/0,E=k?k.index:1/0;if(h<E)i++,y=h+x[0].length;else if(E<1/0){if(i--,i===0)return E;y=E+k[0].length}else break}return-1}function v(s,o,r){let a=0,i=new RegExp(`@${o}(?:\\s*\\(|\\s|$)`,"g"),y=new RegExp(`@${r}(?![a-z])`,"g"),m=/@else(?![a-z])/g,c=[],x;while((x=i.exec(s))!==null)c.push({pos:x.index,type:"open"});while((x=y.exec(s))!==null)c.push({pos:x.index,type:"close"});while((x=m.exec(s))!==null)c.push({pos:x.index,type:"else"});c.sort((k,h)=>k.pos-h.pos);for(let k of c)if(k.type==="open")a++;else if(k.type==="close")a--;else if(k.type==="else"&&a===0)return k.pos;return-1}{let s=!0;while(s){s=!1;let o=p.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!o||o.index===void 0)break;let r=o.index,a,i,y=p.slice(r+5),m=q(y);if(m)a=m.value,i=r+5+m.consumed;else i=r+5;let c=n(p,"auth","endauth",i);if(c===-1){console.warn(`[stx] @auth directive at position ${r} has no matching @endauth \u2014 the block was skipped.`);break}let x=p.slice(i,c),k=v(x,"auth","endauth"),h;if(!e.auth)h=!1;else h=a?L(`auth?.check && auth?.user?.[${a}]`,e):L("auth?.check",e);let E;if(k!==-1){let S=x.slice(0,k),C=x.slice(k+5);E=h?S:C}else E=h?x:"";p=p.substring(0,r)+E+p.substring(c+8),s=!0}}{let s=!0;while(s){s=!1;let o=p.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!o||o.index===void 0)break;let r=o.index,a,i,y=p.slice(r+6),m=q(y);if(m)a=m.value,i=r+6+m.consumed;else i=r+6;let c=n(p,"guest","endguest",i);if(c===-1){console.warn(`[stx] @guest directive at position ${r} has no matching @endguest \u2014 the block was skipped.`);break}let x=p.slice(i,c),k=v(x,"guest","endguest"),h;if(!e.auth)h=!0;else h=a?L(`!auth?.check || !auth?.user?.[${a}]`,e):L("!auth?.check",e);let E;if(k!==-1){let S=x.slice(0,k),C=x.slice(k+5);E=h?S:C}else E=h?x:"";p=p.substring(0,r)+E+p.substring(c+9),s=!0}}function g(s,o,r){if(e.userCan&&typeof e.userCan[s]==="boolean")return e.userCan[s];if(e.permissions?.check&&typeof e.permissions.check==="function")try{let a=[s];if(o)a.push(o);if(r){let i=L(r,e);a.push(i)}return e.permissions.check(...a)}catch{return!1}return!1}function b(s){let o=s.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!o)return null;return{ability:o[1],type:o[2],id:o[3]?.trim(),paramsEnd:o[0].length}}for(let s of["can","cannot"]){let o=`end${s}`,r=s==="can"?"elsecan":"elsecannot",a=!0;while(a){a=!1;let i=p.match(new RegExp(`@${s}\\s*\\(`));if(!i||i.index===void 0)break;let y=i.index,m=p.slice(y+`@${s}`.length),c=b(m);if(!c)break;let x=y+`@${s}`.length+c.paramsEnd,k=n(p,s,o,x);if(k===-1){console.warn(`[stx] @${s} directive at position ${y} has no matching @${o} \u2014 the block was skipped.`);break}let h=p.slice(x,k),E=[],S=0,C=new RegExp(`@${s}\\s*\\(`,"g"),P=new RegExp(`@${o}(?![a-z])`,"g"),R=new RegExp(`@${r}\\s*\\(`,"g"),T=/@else(?![a-z])/g,_=[],M;while((M=C.exec(h))!==null)_.push({pos:M.index,type:"open"});while((M=P.exec(h))!==null)_.push({pos:M.index,type:"close"});while((M=R.exec(h))!==null)_.push({pos:M.index,type:"elseDirective"});while((M=T.exec(h))!==null)_.push({pos:M.index,type:"else"});_.sort((A,z)=>A.pos-z.pos);for(let A of _){if(A.type==="open"){S++;continue}if(A.type==="close"){S--;continue}if(S===0)E.push(A)}let I=[],F=0;for(let A=0;A<E.length;A++){let z=E[A];if(I.push({content:h.slice(F,z.pos),ability:void 0}),z.type==="elseDirective"){let D=h.slice(z.pos+`@${r}`.length),B=b(D);if(B){I[I.length-1]={content:h.slice(F,z.pos)},F=z.pos+`@${r}`.length+B.paramsEnd,I.push({content:"",ability:B.ability,type:B.type,id:B.id}),I.pop();let G=E[A+1],U=G?G.pos:h.length;I.push({content:h.slice(F,U),ability:B.ability,type:B.type,id:B.id}),F=U}}else F=z.pos+5}if(F<h.length){let A=I[I.length-1];if(E.length>0&&E[E.length-1].type==="else")I.push({content:h.slice(F),isFinalElse:!0});else if(I.length===0)I.push({content:h.slice(F)})}let O=g(c.ability,c.type,c.id),j=s==="can"?O:!O,V="";if(j)V=I[0]?.content||"";else{let A=!1;for(let z=1;z<I.length;z++){let D=I[z];if(D.isFinalElse){V=D.content,A=!0;break}if(D.ability){let B=g(D.ability,D.type,D.id);if(s==="can"?B:!B){V=D.content,A=!0;break}}}if(!A&&I.length>0){let z=I[I.length-1];if(z.isFinalElse)V=z.content}}p=p.substring(0,y)+V+p.substring(k+`@${o}`.length),a=!0}}return p}function zo(w,e,p){let n=w;function v(g,b,s,o,r){let a=!0;while(a){a=!1;let i=new RegExp(`@${b}\\s*\\(`),y=g.match(i);if(!y||y.index===void 0)break;let m=y.index,c=Ze(g,m+`@${b}`.length);if(!c)break;let x=c.endPos,k=vt(g,b,s,x);if(k===-1){console.warn(`[stx] @${b} directive at position ${m} has no matching @${s} \u2014 the block was skipped.`);break}let h=g.slice(x,k),E=c.expression,S=-1,C=0,P=0;while(P<h.length){let R=h.indexOf("@",P);if(R===-1)break;let T=h.substring(R);if(/^@(?:if|unless|isset|empty)\s*\(/.test(T)){C++,P=R+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(T)){C--,P=R+1;continue}if(C===0&&/^@else(?![a-z])/.test(T)){S=R;break}P=R+1}try{let R=o(E.trim()),T;if(S!==-1){let _=h.slice(0,S),M=h.slice(S+5);T=R?_:M}else T=R?h:"";g=g.substring(0,m)+T+g.substring(k+`@${s}`.length),a=!0}catch(R){let T=R instanceof Error?R.message:String(R),_=l(r,`Error processing @${b} directive: ${T}`,t.EVALUATION_ERROR);g=g.substring(0,m)+_+g.substring(k+`@${s}`.length);break}}return g}return n=v(n,"isset","endisset",(g)=>{let b=L(g,e);return b!==void 0&&b!==null},"Isset"),n=v(n,"empty","endempty",(g)=>{let b=L(g,e);return b===void 0||b===null||b===""||b===0||b===!1||Array.isArray(b)&&b.length===0||typeof b==="object"&&b!==null&&Object.keys(b).length===0},"Empty"),n}function Ho(w,e,p){let n=w,v="development";function g(b,s,o,r){let a=new RegExp(`@${s}(?![a-z])`,"g"),i=new RegExp(`@${o}(?![a-z])`,"g"),y=new RegExp(`^@${s}(?![a-z])`),m=new RegExp(`^@${o}(?![a-z])`),c=b,x=!0;while(x){x=!1,a.lastIndex=0;let k=a.exec(c);if(!k)break;let h=k.index,E=h+k[0].length;if(s==="env"){let O=c.substring(E).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!O)break;E+=O[0].length,r=v===O[2]}let S=1,C=E,P=-1;while(S>0&&C<c.length){a.lastIndex=C,i.lastIndex=C;let O=a.exec(c),j=i.exec(c),V=O?O.index:1/0,A=j?j.index:1/0;if(V<A)S++,C=V+O[0].length;else if(A<1/0){if(S--,S===0){P=A;break}C=A+j[0].length}else break}if(P===-1){console.warn(`[stx] @${s} directive at position ${h} has no matching @${o} \u2014 the block was skipped.`);break}let R=c.substring(E,P),T=-1,_=0,M=0;while(M<R.length){let O=R.indexOf("@",M);if(O===-1)break;let j=R.substring(O);if(y.test(j)){_++,M=O+1;continue}if(m.test(j)){_--,M=O+1;continue}if(_===0&&/^@else(?![a-z])/.test(j)){T=O;break}M=O+1}let I;if(T!==-1){let O=R.slice(0,T),j=R.slice(T+5);I=r?O:j}else I=r?R:"";let F=`@${o}`.length;c=c.substring(0,h)+I+c.substring(P+F),x=!0}return c}return n=g(n,"env","endenv",!1),n=g(n,"production","endproduction",v==="production"),n=g(n,"development","enddevelopment",v==="development"),n=g(n,"staging","endstaging",v==="staging"),n=g(n,"testing","endtesting",v==="testing"),n}
|
|
3
3
|
export{se,Fo,zo,Ho};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import c from"fs";import i from"path";import{createHash as k}from"crypto";var j=["pages","components","layouts","partials","composables"],w=new Set;function
|
|
3
|
-
`)}`);let o=r.outputs.find((a)=>a.kind==="entry-point");if(!o||r.outputs.length!==1)throw Error(`Unsupported layer config output: ${e}`);let s=(await import(`data:text/javascript;base64,${Buffer.from(await o.text()).toString("base64")}`)).default;if(!x(s))throw Error(`Layer ${e} must default-export a config object`);return s}async function
|
|
4
|
-
`)}function
|
|
5
|
-
export{
|
|
2
|
+
import c from"fs";import i from"path";import{createHash as k}from"crypto";var j=["pages","components","layouts","partials","composables"],w=new Set;function xc(e){try{return w.has(c.realpathSync(e))}catch{return w.has(i.resolve(e))}}var _=new Set(["extends","root",...j.map((e)=>`${e}Dir`),"publicDir","stateDir","cachePath"]),x=(e)=>e!==null&&typeof e==="object"&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null);function b(e,n,r=""){if(Array.isArray(n))return["middleware","plugins"].includes(r)?[...Array.isArray(e)?e:[],...n]:[...n];if(!x(n))return n;let o={...x(e)?e:{}};for(let[s,a]of Object.entries(n)){if(["__proto__","constructor","prototype"].includes(s))throw Error(`Invalid layer config key: ${s}`);o[s]=b(o[s],a,s)}return o}function v(e){for(let n of["stx.config.ts","stx.config.js","stx.config.mjs",".config/stx.config.ts",".config/stx.ts","ui.config.ts"]){let r=i.join(e,n);if(c.existsSync(r))return c.realpathSync(r)}throw Error(`Application layer has no stx.config.ts: ${e}`)}function E(e,n,r){if(typeof e!=="string"||!e||/^(?:https?:|git[+:])/.test(e))throw Error(`Invalid application layer ${JSON.stringify(e)} in ${n}; use a local path or installed package`);if(e.startsWith(".")||i.isAbsolute(e)){let s=i.resolve(n,e);return c.statSync(s).isDirectory()?v(s):c.realpathSync(s)}let o=n;while(!0){let s=i.join(o,"node_modules",e),a=i.join(s,"package.json");if(c.existsSync(a)){r.add(c.realpathSync(a));let g=JSON.parse(c.readFileSync(a,"utf8"));return g.stx?.layer?c.realpathSync(i.resolve(s,g.stx.layer)):v(s)}let p=i.dirname(o);if(p===o)break;o=p}throw Error(`Cannot resolve application layer ${JSON.stringify(e)} from ${n}`)}async function C(e,n){let r=await Bun.build({entrypoints:[e],target:"bun",format:"esm",splitting:!1,plugins:[{name:"stx-layer-config",setup(a){a.onResolve({filter:/^[^./]/},(p)=>{if(p.path.startsWith("node:"))return{path:p.path,external:!0};return{path:Bun.resolveSync(p.path,p.resolveDir),external:!0}}),a.onLoad({filter:/./},(p)=>{let g=c.realpathSync(p.path);n.add(g),w.add(g);return})}}]});if(!r.success)throw Error(`Cannot load layer ${e}: ${r.logs.join(`
|
|
3
|
+
`)}`);let o=r.outputs.find((a)=>a.kind==="entry-point");if(!o||r.outputs.length!==1)throw Error(`Unsupported layer config output: ${e}`);let s=(await import(`data:text/javascript;base64,${Buffer.from(await o.text()).toString("base64")}`)).default;if(!x(s))throw Error(`Layer ${e} must default-export a config object`);return s}async function Sc(e,n){let r=new Set,o=[],s=[],a=new Set,p=[];async function g(t,l){if(t=c.realpathSync(t),p.includes(t))throw Error(`Application layer cycle: ${[...p,t].join(" -> ")}`);if(a.has(t))return;a.add(t),p.push(t);let d=await C(t,r);l??=i.basename(i.dirname(t))===".config"?i.dirname(i.dirname(t)):i.dirname(t),l=c.realpathSync(l);let D=i.resolve(l,d.root??"."),L=Object.fromEntries(j.map((y)=>[y,i.resolve(D,d[`${y}Dir`]??(y==="composables"?"functions":y))]));o.push({root:l,configFile:t,resources:L});let u={...d};if(u.plugins)u.plugins=u.plugins.map((y)=>{let h=typeof y==="string"?y:y[0],S=h.startsWith(".")?i.resolve(l,h):i.isAbsolute(h)?h:Bun.resolveSync(h,l);return r.add(c.realpathSync(S)),typeof y==="string"?S:[S,y[1]]});if(typeof u.css==="string")u.css=i.resolve(l,u.css);if(u.serverApi)u.serverApi={...typeof u.serverApi==="object"?u.serverApi:{},dir:i.resolve(l,typeof u.serverApi==="object"?u.serverApi.dir??"server/api":"server/api")};if(s.push(u),d.extends!==void 0&&!Array.isArray(d.extends))throw Error(`extends in ${t} must be an array`);for(let y of d.extends??[])await g(E(y,l,r));p.pop()}await g(v(e),e);for(let t of["package.json","bun.lock","package-lock.json","pnpm-lock.yaml"]){let l=i.join(e,t);if(c.existsSync(l))r.add(c.realpathSync(l))}let f=b({},n);for(let t=s.length-1;t>=0;t--){let l=t===0?s[t]:Object.fromEntries(Object.entries(s[t]).filter(([d])=>!_.has(d)));f=b(f,l)}let m={layers:o,configDependencies:[...r].sort()};return f._layerGraph=m,f._layerPageDirs=o.map((t)=>t.resources.pages),f._layerComponentDirs=o.map((t)=>t.resources.components),f._layerLayoutDirs=o.map((t)=>t.resources.layouts),f._layerPartialDirs=o.map((t)=>t.resources.partials),f._layerComposableDirs=o.map((t)=>t.resources.composables),await Yo(m,e),{config:f,graph:m}}async function Yo(e,n){let r=new Map,o=[];for(let s of e.layers)for(let[a,p]of Object.entries(s.resources)){if(!c.existsSync(p))continue;let g=new Bun.Glob(a==="composables"?"**/*.ts":"**/*.stx");for(let f of[...g.scanSync({cwd:p})].sort()){let m=`${a}/${f}`,t=i.join(p,f),l=r.get(m);if(l)o.push({resource:m,winner:l,shadowed:t});else r.set(m,t)}}Object.assign(e,{overrides:o}),await Bun.write(i.join(n,".stx/layers.json"),JSON.stringify(e,null,2))}function A(e){let n=new Set(e.configDependencies);function r(o){if(!c.existsSync(o))return;n.add(o);for(let s of c.readdirSync(o,{withFileTypes:!0}).sort((a,p)=>a.name.localeCompare(p.name))){if(s.name.startsWith(".")||s.name==="node_modules")continue;let a=i.join(o,s.name);if(s.isDirectory())r(a);else if(s.isFile())n.add(a)}}for(let o of e.layers)for(let s of Object.values(o.resources))r(s);return[...n].sort()}function Ss(e){return O(A(e))}function ks(e){return O(e.configDependencies)}function O(e){return e.map((n)=>{try{let r=c.statSync(n);return`${n}:${r.mtimeMs}:${r.size}`}catch{return`${n}:missing`}}).join(`
|
|
4
|
+
`)}function kc(e){return e.layers.map((n)=>({config:i.relative(n.root,n.configFile),files:A({layers:[n],configDependencies:e.configDependencies.filter((r)=>r.startsWith(`${n.root}${i.sep}`))}).filter((r)=>c.statSync(r).isFile()).map((r)=>({path:i.relative(n.root,r).replaceAll(i.sep,"/"),sha256:k("sha256").update(c.readFileSync(r)).digest("hex")}))}))}
|
|
5
|
+
export{xc,Sc,Yo,Ss,ks,kc};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
function E(){let{NODE_ENV:n}=process.env;return n==="production"}function K(){let{STX_DEBUG:n}=process.env;return!E()||n==="true"}function _n(){let{NODE_ENV:n}=process.env;return n==="test"}function
|
|
3
|
-
export{E,K,_n
|
|
2
|
+
function E(){let{NODE_ENV:n}=process.env;return n==="production"}function K(){let{STX_DEBUG:n}=process.env;return!E()||n==="true"}function _n(){let{NODE_ENV:n}=process.env;return n==="test"}function Ri(n,t){return t??(n==="compile"||E())}function Cn(n){if(!n)return n;try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(n).trim()}catch{return n}}
|
|
3
|
+
export{E,K,_n,Ri,Cn};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{tr,i}from"./chunk-0p797a25.js";import"./chunk-zbyfxcrr.js";import"./chunk-p77cnteg.js";import"./chunk-c84pxd2k.js";import"./chunk-vyb4sxh9.js";import"./chunk-ec2f30f7.js";import"./chunk-qe5h58mx.js";import"./chunk-wceg59n0.js";import"./chunk-5e88021j.js";import{we}from"./chunk-4t4af1mb.js";import"./chunk-2nj9aewf.js";import"./chunk-gywyr2x3.js";import"./chunk-xdbwghty.js";import"./chunk-bkdfkm10.js";import"./chunk-k81trehg.js";import"./chunk-wf0n9gpj.js";import"./chunk-xpy9yjyx.js";import"./chunk-qj4r08jb.js";import{Oe,zs,Hs}from"./chunk-j4cjn4m1.js";import"./chunk-k0bztfk3.js";import"./chunk-2vqpz4qv.js";import"./chunk-8ttmzcxb.js";import"./chunk-r9e0r6jx.js";import"./chunk-bt0amey5.js";export{tr as buildModulesTag,we as injectRouterScript,i as processDirectives,zs as processJsonDirective,Hs as processOnceDirective,Oe as validateClientScript};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{E}from"./chunk-
|
|
2
|
+
import{E}from"./chunk-wpendr22.js";import{Ue,Tn}from"./chunk-y9bj3566.js";function m(e){let t={"cache-first":{className:"CacheFirst",importFrom:"workbox-strategies"},"network-first":{className:"NetworkFirst",importFrom:"workbox-strategies"},"stale-while-revalidate":{className:"StaleWhileRevalidate",importFrom:"workbox-strategies"},"network-only":{className:"NetworkOnly",importFrom:"workbox-strategies"},"cache-only":{className:"CacheOnly",importFrom:"workbox-strategies"}};return t[e]||t["network-first"]}function g(e){return m(e).className}function d(e){let t=e.pwa;if(!t?.enabled)return"";let r=t.routes||[],n=t.cacheStorage,c=[];for(let a of r){let i=g(a.strategy),s=[];if(a.maxAgeSeconds||a.maxEntries||n?.maxEntries){let o=a.maxEntries||n?.maxEntries||100,u=a.maxAgeSeconds||(n?.maxAge?n.maxAge*24*60*60:void 0);s.push(`new ExpirationPlugin({
|
|
3
3
|
maxEntries: ${o},
|
|
4
4
|
${u?`maxAgeSeconds: ${u},`:""}
|
|
5
5
|
purgeOnQuotaError: true,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ie,C,Y}from"./chunk-
|
|
2
|
+
import{Ie,C,Y}from"./chunk-j4cjn4m1.js";import{k}from"./chunk-bt0amey5.js";import{P,En}from"./chunk-r9e0r6jx.js";import{a}from"./chunk-xdbwghty.js";import{he,nn,rn,sn}from"./chunk-zefkd9t8.js";import{wt}from"./chunk-5e88021j.js";import{mt,zn,Gt,ce}from"./chunk-tsvnhc0c.js";import{E,Cn}from"./chunk-wpendr22.js";import A from"fs";import b from"path";import x from"process";function U(s,o){for(let e of s.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(e[1])o.add(e[1]);for(let e of s.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let t of(e[1]??"").split(",")){let r=((t.includes(":")?t.split(":").pop():t)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(r))o.add(r)}for(let e of s.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let t of(e[1]??"").split(",")){let n=t.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(n))o.add(n)}}var h=new Map;async function O(s,o=E()){let e;if(s)e=b.resolve(s);else{let l=await a();e=b.resolve(l.root||x.cwd(),l.storesDir||"stores")}let t=`${e}\x00${rn()}\x00${o?"shared":"inline"}`,n=new Bun.Glob("*.ts"),r=[];try{for await(let l of n.scan({cwd:e,absolute:!0})){let c=b.basename(l,".ts");if(["index","types"].includes(c))continue;if(l.includes(".d.ts"))continue;r.push(l)}}catch{return ce(h,t,"",{chunks:[]}),null}let i=()=>[...new Set([...r,...r.flatMap((l)=>he(l))])],f=mt(i()),u=Gt(h,t,f);if(u!==void 0)return u.chunks.length>0?u:null;if(r.length===0)return ce(h,t,f,{chunks:[]}),null;let m=[];for(let l of r){let c=await Bun.file(l).text();m.push({file:l,hasUseStore:/useStore\s*\(/.test(c)})}m.sort((l,c)=>{if(l.hasUseStore===c.hasUseStore)return 0;return l.hasUseStore?1:-1});let p=m.map((l)=>l.file),g=[],d=Y({loader:"ts",target:"browser",define:C()});for(let l of p)try{let c=await Bun.file(l).text(),_=b.basename(l,".ts"),y=new Set;U(c,y);let v=[...c.matchAll(/\bdefineStore\s*(?:<[^>()]*>)?\(\s*(['"`])([^'"`$\\]+)\1/g)].map((N)=>N[2]),I=c.match(/\bdefineStore\s*(?:<[^>()]*>)?\(/g)?.length??0;if(nn(c))c=await sn(c,l,{projectRoot:x.cwd(),externalizeUserModules:o});c=wt(c),c=P(c),c=En(c),c=c.replace(/^export\s+(default\s+)?/gm,""),c=d.transformSync(c),g.push({name:_,ids:v.length===I?v:[],declared:y,code:`// Store: ${_}
|
|
3
3
|
${c.trim()}`})}catch(c){console.warn(`[stx] Failed to load store ${l}:`,c)}if(g.length===0)return ce(h,t,f,{chunks:[]}),null;f=mt(i());let S={chunks:g};return ce(h,t,f,S),S}function R(s){let o=new Set;for(let r of s)for(let i of r.declared)o.add(i);let e=s.map((r)=>r.code).join(`
|
|
4
4
|
|
|
5
5
|
`),n=`;(function(){
|
|
@@ -12,7 +12,7 @@ var __stx = window.stx || {};
|
|
|
12
12
|
${k.filter((i)=>!n.has(i)&&new RegExp(`\\b${i}\\b`).test(e.code)).map((i)=>`var ${i} = __stx[${JSON.stringify(i)}];`).join(`
|
|
13
13
|
`)}
|
|
14
14
|
${e.code}
|
|
15
|
-
}`})}var M=new WeakMap;async function
|
|
15
|
+
}`})}var M=new WeakMap;async function oh(s){let o=await O(s);if(!o)return null;let e=M.get(o);if(e===void 0)e=R(o.chunks),M.set(o,e);return e}function T(s){if(!/\buseStore\b/.test(s))return!1;if(/\buseStore\s+as\s+[A-Za-z_$]/.test(s))return!0;if(/\{[^{}]*\buseStore\s*:\s*[A-Za-z_$[{][^{}]*\}\s*=(?!=)/.test(s))return!0;if(/\[\s*(['"`])useStore\1\s*\]/.test(s.replace(/\b(?:var|let|const)\s+useStore\s*=\s*[\w$.]*\[\s*(['"`])useStore\1\s*\]/g," ")))return!0;let o=s.replace(/\/\*[\s\S]*?\*\//g," ").replace(/(^|[^:\\'"`])\/\/[^\n]*/g,"$1 ").replace(/\b(?:var|let|const)\s+useStore\s*=\s*[\w$.]*\[\s*(['"`])useStore\1\s*\]/g," ").replace(/\b(?:const|let|var)\s*\{[^{}]*\}\s*=/g," ").replace(/\bimport\s*(?:type\s+)?\{[^{}]*\}\s*from\b/g," ").replace(/\bexport\s*(?:type\s+)?\{[^{}]*\}/g," ").replace(/\btypeof\s+useStore\b/g," ").replace(/(['"`])useStore\1/g," ");for(let e of o.matchAll(/\buseStore\b/g)){let t=o.slice(Math.max(0,e.index-9),e.index);if(/\bfunction\s*$/.test(t))continue;let n=o.slice(e.index+8).trimStart();if(n.startsWith("(")||n.startsWith("<")||n.startsWith("?.("))continue;if(/^=(?![=>])/.test(n))continue;return!0}return!1}function bo(...s){let o=new Set,e=!1;for(let t of s){if(!t)continue;if(/__STX_STORES__|\b_stores\b/.test(t))e=!0;if(T(t))e=!0;let n=t.match(/\buseStore\s*(?:<[^>()]*>)?\s*(?:\?\.\s*)?\(/g)?.length??0;if(n===0)continue;let r=0;for(let i of t.matchAll(/\buseStore\s*(?:<[^>()]*>)?\s*(?:\?\.\s*)?\(\s*(['"`])([^'"`$\\]+)\1\s*[,)]/g))o.add(i[2]),r++;if(r!==n)e=!0}return{names:o,all:e}}var z=new Map;function ih(s){let o=new Set,e=!1;for(let t of s){if(/\.(?:css|json|svg|wasm|png|jpe?g|gif|webp|avif|woff2?|ttf|txt|md)$/i.test(t))continue;let n;try{let r=A.statSync(t),i=z.get(t);if(i&&i.mtimeMs===r.mtimeMs&&i.size===r.size)n=i.read;else n=bo(A.readFileSync(t,"utf8")),z.set(t,{mtimeMs:r.mtimeMs,size:r.size,read:n})}catch{n={names:new Set,all:!0}}if(n.all)e=!0;for(let r of n.names)o.add(r)}return{names:o,all:e}}function ah(s=x.env){return s.STX_PAGE_STORES==="all"}async function ch(s,o,e={}){let t=await O(s,e.sharedModules);if(!t)return null;let{chunks:n}=t,r=bo(...o);if(e.reads){if(e.reads.all)r.all=!0;for(let u of e.reads.names)r.names.add(u)}let i=e.runOnce?W(t):void 0,f;if(e.all||r.all||n.some((u)=>u.ids.length===0)||i===null)f=n;else{let u=new Map;for(let d of n)for(let S of d.ids)u.set(S,d);let m=new Set,p=[...r.names],g=!1;while(p.length>0&&!g){let d=u.get(p.pop());if(!d||m.has(d))continue;m.add(d);let S=bo(d.code);if(S.all)g=!0;else p.push(...S.names)}f=g?n:n.filter((d)=>m.has(d))}if(f.length===0)return null;if(i){let u=f.map((d)=>i.get(d)),m=f.map((d)=>d.name),p=F.get(t);if(!p)F.set(t,p=new Map);let g=p.get(m.join("\x00"));if(g===void 0)p.set(m.join("\x00"),g=Z(m,u));return{code:g,stores:m,functions:u}}return{code:R(f),stores:f.map((u)=>u.name),functions:j(f)}}var F=new WeakMap,w=new WeakMap;function W(s){if(w.has(s))return w.get(s);let o=j(s.chunks),e=o?new Map(s.chunks.map((t,n)=>[t,o[n]])):null;return w.set(s,e),e}function Z(s,o){let t=`;(function(){
|
|
16
16
|
var ran = window.__stxStoreFiles || (window.__stxStoreFiles = {});
|
|
17
17
|
function run(name, define) {
|
|
18
18
|
if (ran[name]) return;
|
|
@@ -22,5 +22,5 @@ function run(name, define) {
|
|
|
22
22
|
}
|
|
23
23
|
${s.map((n,r)=>`run(${JSON.stringify(n)}, ${o[r]})`).join(`;
|
|
24
24
|
`)};
|
|
25
|
-
})();`;return E()?Cn(t):t}function
|
|
26
|
-
export{
|
|
25
|
+
})();`;return E()?Cn(t):t}function lh(){h.clear(),zn()}
|
|
26
|
+
export{oh,bo,ih,ah,ch,lh};
|