@stacksjs/stx 0.2.887 → 0.2.888
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-000mwmfq.js +1203 -0
- package/dist/chunk-043d0en0.js +2 -0
- package/dist/{chunk-3cq4a4x7.js → chunk-0d7ypcjb.js} +2 -2
- package/dist/{chunk-02qmvcmv.js → chunk-0dq9svfb.js} +2 -2
- package/dist/{chunk-cb0c6959.js → chunk-0hj5apb9.js} +1 -1
- package/dist/chunk-0w66z6eq.js +2 -0
- package/dist/{chunk-n22xtagg.js → chunk-11fxbd71.js} +2 -2
- package/dist/chunk-13wd9gf0.js +3 -0
- package/dist/{chunk-zch65qrd.js → chunk-1kc0jyhj.js} +1 -1
- package/dist/{chunk-ram5944w.js → chunk-1wkp3pks.js} +2 -2
- package/dist/{chunk-69ezjc8k.js → chunk-1xpq83mc.js} +4 -4
- package/dist/chunk-1znqedae.js +2 -0
- package/dist/{chunk-gvd8nb8z.js → chunk-2assyczz.js} +1 -1
- package/dist/{chunk-cev5z6gj.js → chunk-2drzzjcm.js} +1 -1
- package/dist/{chunk-y6eaqs8v.js → chunk-2rmqmajd.js} +3 -3
- package/dist/{chunk-59er0fc7.js → chunk-303vzq80.js} +3 -3
- package/dist/{chunk-zj5eq4b6.js → chunk-372xh1g1.js} +4 -4
- package/dist/chunk-3c7nt5qp.js +2 -0
- package/dist/{chunk-zpj6ggee.js → chunk-3ed2erm6.js} +3 -3
- package/dist/{chunk-gbncp2gp.js → chunk-3fbgpv1d.js} +2 -2
- package/dist/chunk-3zyzhcd9.js +2 -0
- package/dist/chunk-44rb9fk0.js +2 -0
- package/dist/chunk-472j3bhp.js +2 -0
- package/dist/chunk-4acce1m8.js +2 -0
- package/dist/{chunk-2r0nrvqe.js → chunk-4c9p434g.js} +2 -2
- package/dist/chunk-4kasmp98.js +2 -0
- package/dist/{chunk-e41pgmgk.js → chunk-4nnmrp7w.js} +2 -2
- package/dist/{chunk-c47stwqj.js → chunk-52mhrbps.js} +1 -1
- package/dist/chunk-53kkjn23.js +2 -0
- package/dist/{chunk-7wqz32ay.js → chunk-55kwxxm5.js} +2 -2
- package/dist/chunk-5gwvy612.js +2 -0
- package/dist/{chunk-0rdh8bw3.js → chunk-5ymf5c8m.js} +6 -6
- package/dist/{chunk-xcsgpf83.js → chunk-5ysv0499.js} +1 -1
- package/dist/{chunk-4n45qa0b.js → chunk-605g9qhp.js} +4 -4
- package/dist/chunk-61vbqrde.js +2 -0
- package/dist/chunk-6fpzwryt.js +2 -0
- package/dist/{chunk-rv0a3stz.js → chunk-6fsnnj5v.js} +5 -5
- package/dist/{chunk-q74affc4.js → chunk-6qq3wy3m.js} +2 -2
- package/dist/{chunk-h63ma36g.js → chunk-6zq3eh7d.js} +2 -2
- package/dist/chunk-7195598h.js +2 -0
- package/dist/{chunk-czcx3nbx.js → chunk-7hm1tpw0.js} +4 -4
- package/dist/{chunk-a7ryj8z8.js → chunk-7nhgpjjw.js} +6 -6
- package/dist/{chunk-0mx7rg07.js → chunk-7s3j8pqq.js} +3 -3
- package/dist/chunk-7zvf79vb.js +2 -0
- package/dist/chunk-88a735jw.js +2 -0
- package/dist/chunk-8v7yjq3b.js +2 -0
- package/dist/{chunk-463weehv.js → chunk-98mj0es1.js} +1 -1
- package/dist/{chunk-ef9m5fjb.js → chunk-9qrgdekg.js} +11 -11
- package/dist/{chunk-fg67643b.js → chunk-9tecekzq.js} +4 -4
- package/dist/chunk-a8c9j9cj.js +2 -0
- package/dist/chunk-acw851e8.js +2 -0
- package/dist/{chunk-d2pexm3z.js → chunk-ah6nc29h.js} +1 -1
- package/dist/chunk-andfvr3g.js +2 -0
- package/dist/chunk-ay5zkfdg.js +2 -0
- package/dist/{chunk-xpbakn6t.js → chunk-b0jekg4c.js} +2 -2
- package/dist/chunk-b4gptdtc.js +2 -0
- package/dist/{chunk-agd2b928.js → chunk-b8528fra.js} +2 -2
- package/dist/chunk-baaw9w7y.js +2 -0
- package/dist/{chunk-sc1gmts0.js → chunk-btsgt6w3.js} +2 -2
- package/dist/chunk-bw2p9h2g.js +2 -0
- package/dist/{chunk-6mfpns00.js → chunk-c1b0fy70.js} +4 -4
- package/dist/{chunk-qt39mb2a.js → chunk-c3ca056p.js} +1 -1
- package/dist/chunk-ce0vv7kz.js +2 -0
- package/dist/chunk-d1yj29g2.js +2 -0
- package/dist/{chunk-4j50hrgq.js → chunk-dbhmbef1.js} +4 -4
- package/dist/chunk-dfsykk1r.js +2 -0
- package/dist/{chunk-satrf398.js → chunk-dj9ztcth.js} +1 -1
- package/dist/{chunk-pgrm1vet.js → chunk-e1qcfesw.js} +5 -5
- package/dist/{chunk-cv4bfhn1.js → chunk-e2ws79vt.js} +4 -4
- package/dist/chunk-e9p596bp.js +2 -0
- package/dist/{chunk-q3epnfp4.js → chunk-e9tjxnhn.js} +4 -4
- package/dist/{chunk-dz7amds0.js → chunk-edysherg.js} +3 -3
- package/dist/{chunk-g2xy0z0e.js → chunk-em6fqvjy.js} +2 -2
- package/dist/{chunk-kaem8q20.js → chunk-fce8wj3t.js} +1 -1
- package/dist/{chunk-f2twg7ze.js → chunk-fepezvdq.js} +5 -5
- package/dist/chunk-ftecsa8e.js +2 -0
- package/dist/{chunk-50cnypys.js → chunk-gdtj5rfa.js} +5 -5
- package/dist/chunk-ge2h5v46.js +2 -0
- package/dist/chunk-gqvnz8a7.js +2 -0
- package/dist/chunk-j41gp8p3.js +2 -0
- package/dist/{chunk-nzpzyz22.js → chunk-j51wss7s.js} +1 -1
- package/dist/chunk-jxvccj30.js +2 -0
- package/dist/chunk-k5bbre7d.js +2 -0
- package/dist/chunk-kd47vgs8.js +2 -0
- package/dist/chunk-keqjafdz.js +2 -0
- package/dist/{chunk-kwf3kfr0.js → chunk-kvxdyg7e.js} +2 -2
- package/dist/chunk-kz3mejc4.js +2 -0
- package/dist/{chunk-ezna4dhj.js → chunk-mbm3ma63.js} +2 -2
- package/dist/{chunk-qx1nbryq.js → chunk-mk6thhwf.js} +2 -2
- package/dist/{chunk-twmkz0xs.js → chunk-mm1eg2pg.js} +7 -7
- package/dist/chunk-ngkh0t5b.js +2 -0
- package/dist/chunk-nx9895m6.js +2 -0
- package/dist/chunk-nxgtt1t1.js +2 -0
- package/dist/chunk-nyw2ztar.js +2 -0
- package/dist/{chunk-km14pdrt.js → chunk-p33npqjt.js} +11 -11
- package/dist/chunk-p5q27adr.js +2 -0
- package/dist/chunk-pczb7xav.js +2 -0
- package/dist/{chunk-sfyyn0mg.js → chunk-pm4kn9h2.js} +6 -6
- package/dist/chunk-ps37r6hj.js +2 -0
- package/dist/chunk-pvbhk17r.js +2 -0
- package/dist/chunk-q252qvsy.js +2 -0
- package/dist/{chunk-6qpe4f8e.js → chunk-q3bkxg2n.js} +4 -4
- package/dist/chunk-q5b0vpmm.js +2 -0
- package/dist/{chunk-4251fy7d.js → chunk-qjy5yq25.js} +9 -9
- package/dist/{chunk-pdprhg5k.js → chunk-qsnpqa8q.js} +1 -1
- package/dist/{chunk-2v7v6jcs.js → chunk-r561zt9v.js} +3 -3
- package/dist/{chunk-ybjgnnyf.js → chunk-r57jz09p.js} +5 -5
- package/dist/{chunk-dwyhpbpx.js → chunk-r8xper92.js} +2 -2
- package/dist/{chunk-sv7fdqmc.js → chunk-ry6w43p6.js} +6 -6
- package/dist/{chunk-e362e615.js → chunk-s7wp7a2x.js} +30 -30
- package/dist/chunk-sbr85vda.js +2 -0
- package/dist/{chunk-57q4nvs9.js → chunk-sbwvvjkc.js} +3 -3
- package/dist/chunk-tkab24xr.js +2 -0
- package/dist/{chunk-16aqrwmk.js → chunk-v47xc2fr.js} +5 -5
- package/dist/{chunk-q1mb0fbt.js → chunk-v8e2c2r1.js} +2 -2
- package/dist/{chunk-aaea157p.js → chunk-vazk5qbh.js} +2 -2
- package/dist/{chunk-6df3j3qq.js → chunk-vgr7gd8k.js} +1 -1
- package/dist/{chunk-kee5a3ce.js → chunk-vgsasnwm.js} +2 -2
- package/dist/{chunk-32twt3wx.js → chunk-vjfp8n6p.js} +3 -3
- package/dist/chunk-vn59yrjh.js +2 -0
- package/dist/{chunk-shcnt6aa.js → chunk-w1q86c89.js} +3 -3
- package/dist/{chunk-ws2h92mm.js → chunk-w50yggy3.js} +2 -2
- package/dist/{chunk-8e1cv1hh.js → chunk-w624s5jf.js} +3 -3
- package/dist/chunk-wa9q1gyv.js +2 -0
- package/dist/{chunk-a0q0kb0s.js → chunk-wbxmn5gk.js} +5 -5
- package/dist/{chunk-pc8dt8xs.js → chunk-wf8pdjq5.js} +1 -1
- package/dist/{chunk-88tshy2f.js → chunk-whsdyf4t.js} +6 -6
- package/dist/{chunk-3bfheqe3.js → chunk-wm287dz2.js} +2 -2
- package/dist/{chunk-rsxxajv6.js → chunk-wpa3r3b9.js} +2 -2
- package/dist/chunk-wpgxhrd7.js +2 -0
- package/dist/{chunk-yasdj4ve.js → chunk-wscry63p.js} +2 -2
- package/dist/chunk-x3azrbpr.js +2 -0
- package/dist/chunk-x50hk1hq.js +2 -0
- package/dist/{chunk-8va3fs07.js → chunk-xavx271y.js} +5 -5
- package/dist/chunk-xbkbvfcg.js +2 -0
- package/dist/{chunk-295bykzd.js → chunk-xw291tn7.js} +13 -11
- package/dist/{chunk-94ctmp0j.js → chunk-xy4j8t7w.js} +2 -2
- package/dist/{chunk-azf6tdq6.js → chunk-y76znqmh.js} +17 -17
- package/dist/{chunk-yp4tn4zn.js → chunk-y8p59h6c.js} +4 -4
- package/dist/{chunk-s7xywsqd.js → chunk-z55rpt3s.js} +2 -2
- package/dist/{chunk-ssg6ne5b.js → chunk-zf29ahhd.js} +4 -4
- package/dist/{chunk-mxvgft6p.js → chunk-zje94z0k.js} +9 -9
- package/dist/{chunk-gtv9jd68.js → chunk-znnvq1jp.js} +26 -26
- package/dist/{chunk-08cb7cyw.js → chunk-zwde52kw.js} +1 -1
- package/dist/chunk-zxff7kq9.js +2 -0
- package/dist/cli.js +19 -19
- package/dist/component-library.js +118 -21
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +6 -6
- package/package.json +5 -5
- package/dist/chunk-0gkxqcpj.js +0 -2
- package/dist/chunk-0h1dyd38.js +0 -2
- package/dist/chunk-0sew66hf.js +0 -2
- package/dist/chunk-13dgqekj.js +0 -2
- package/dist/chunk-15n20xwe.js +0 -2
- package/dist/chunk-1ta1pj1t.js +0 -2
- package/dist/chunk-1z3r2jjp.js +0 -2
- package/dist/chunk-1z6rrqvm.js +0 -2
- package/dist/chunk-41353gyc.js +0 -2
- package/dist/chunk-4pjqj54a.js +0 -2
- package/dist/chunk-53cc06w7.js +0 -2
- package/dist/chunk-5m02cbxg.js +0 -2
- package/dist/chunk-5rd0an89.js +0 -2
- package/dist/chunk-5s0w910j.js +0 -2
- package/dist/chunk-6fy11vfb.js +0 -2
- package/dist/chunk-6mjk28s3.js +0 -2
- package/dist/chunk-8h5nje66.js +0 -2
- package/dist/chunk-9h3qq2d2.js +0 -2
- package/dist/chunk-9kza7gxd.js +0 -2
- package/dist/chunk-a02gt4tz.js +0 -1199
- package/dist/chunk-a30zpnqp.js +0 -2
- package/dist/chunk-aq0fz4mr.js +0 -2
- package/dist/chunk-axra1yas.js +0 -2
- package/dist/chunk-b2vhsyf9.js +0 -2
- package/dist/chunk-c42b1y7z.js +0 -2
- package/dist/chunk-c89wryyz.js +0 -2
- package/dist/chunk-ch57kgb6.js +0 -2
- package/dist/chunk-cv1vm1w0.js +0 -2
- package/dist/chunk-d7b30bg6.js +0 -2
- package/dist/chunk-f3j1h3ch.js +0 -2
- package/dist/chunk-fz4c5e9m.js +0 -2
- package/dist/chunk-gd04nvj3.js +0 -2
- package/dist/chunk-gmp10259.js +0 -2
- package/dist/chunk-gr956aar.js +0 -2
- package/dist/chunk-h3fv0q25.js +0 -2
- package/dist/chunk-jghpzx5m.js +0 -2
- package/dist/chunk-kcqfrw10.js +0 -2
- package/dist/chunk-kfzvtzsz.js +0 -2
- package/dist/chunk-kqgspa3s.js +0 -2
- package/dist/chunk-mast9wb2.js +0 -2
- package/dist/chunk-mqy1wz09.js +0 -3
- package/dist/chunk-mv21mc9p.js +0 -2
- package/dist/chunk-n9bw9bsn.js +0 -2
- package/dist/chunk-ngzyzcrp.js +0 -2
- package/dist/chunk-nnqyn7db.js +0 -2
- package/dist/chunk-p5qac909.js +0 -2
- package/dist/chunk-pa6kgbmw.js +0 -2
- package/dist/chunk-pd089tq0.js +0 -2
- package/dist/chunk-pjjrx9pk.js +0 -2
- package/dist/chunk-pt3rp3zg.js +0 -2
- package/dist/chunk-t8r40wgf.js +0 -2
- package/dist/chunk-wjafpvjv.js +0 -2
- package/dist/chunk-x44f0eq1.js +0 -2
- package/dist/chunk-xhr35ctb.js +0 -2
- package/dist/chunk-xk15vzb6.js +0 -2
- package/dist/chunk-xmmr0916.js +0 -2
- package/dist/chunk-ywnqjqns.js +0 -2
- package/dist/chunk-z7k1xn6k.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ae,io,Wg,$y,qg,Ry,Pn,g,Y,ie,In,Oe,Kg,zi,Gg,Ay,P,Hi,Xg,Py,O,Iy}from"./chunk-000mwmfq.js";import"./chunk-fce8wj3t.js";import"./chunk-6t04tqvh.js";import"./chunk-xw291tn7.js";import"./chunk-hxhmhw23.js";import"./chunk-kvxdyg7e.js";import"./chunk-s29hp1qw.js";import"./chunk-11fxbd71.js";export{Xg as applyFilters,Ry as clearCustomFilters,Kg as clientLoopScopes,io as defaultFilters,In as escapeAttributeValue,g as escapeHtml,Y as escapeHtmlValue,ie as escapeInterpolatedHtmlValue,O as evaluateExpression,Ae as findMustacheEnd,qg as getAllFilters,Gg as interpolateScriptAttributes,zi as interpolateScriptExpressions,Ay as interpolateScriptsInTemplate,P as processExpressions,Hi as processExpressionsChunked,Wg as registerFilter,$y as registerFilters,Pn as replaceInterpolations,Py as resetRejectedExpressionWarnings,Iy as unescapeHtml,Oe as usesSignalsInScript};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{c}from"./chunk-
|
|
2
|
+
import{c}from"./chunk-b0jekg4c.js";function r(){return`<script data-stx-scoped data-stx-x-element-runtime data-stx-run="always">
|
|
3
3
|
(function() {
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Fl,zl}from"./chunk-n22xtagg.js";import{X,Ar,Ks,Gs,_i,Ei,Xs,Pe,We,xe,re,Or,Nr,me,se,B,gt,Mr,Ai,jr,Je,s,g,Y,In}from"./chunk-a02gt4tz.js";import{m,N,ht,p}from"./chunk-295bykzd.js";import{r}from"./chunk-mqy1wz09.js";import{fe}from"./chunk-d2pexm3z.js";import{br}from"./chunk-7mcs59pr.js";import{b}from"./chunk-94mpe1ny.js";import{t}from"./chunk-zpj6ggee.js";import{createHash as At}from"crypto";import J from"fs";import G from"path";import Le from"fs";function Ae(e,i,n){let o=Buffer.alloc(n),a=Le.readSync(e,o,0,n,i);return o.subarray(0,a)}function ze(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 n=i(12,16);if(n==="VP8X")return(e[20]&16)!==0;if(n==="VP8L")return((e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>28&1)===1;return!1}function Ue(e){let i;try{i=Le.openSync(e,"r");let n=Ae(i,0,33);if(n.length>=3&&n[0]===255&&n[1]===216&&n[2]===255)return"none";if(n.length>=26&&n[0]===137&&n.toString("latin1",1,4)==="PNG"){let o=n[25];if(o===4||o===6)return"possible";let a=8;for(let c=0;c<64;c++){let l=Ae(i,a,8);if(l.length<8)return"unknown";let u=l.toString("latin1",4,8);if(u==="tRNS")return"possible";if(u==="IDAT"||u==="IEND")return"none";a+=12+l.readUInt32BE(0)}return"unknown"}if(n.length>=25&&n.toString("latin1",0,4)==="RIFF"&&n.toString("latin1",8,12)==="WEBP"){if(ze(n))return"possible";let o=n.toString("latin1",12,16);return o==="VP8 "||o==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(i!==void 0)Le.closeSync(i)}}import rn from"fs";import Fe from"os";import{fileURLToPath as bt}from"url";var Ee=Symbol("stx.image-worker.unavailable");function sn(e=typeof Fe.availableParallelism==="function"?Fe.availableParallelism():Fe.cpus().length){return Math.max(1,Math.min(2,e-1))}var _e=0,vt=[];async function on(){if(_e<sn()){_e++;return}await new Promise((e)=>vt.push(e)),_e++}function an(){_e--,vt.shift()?.()}var cn="@stacksjs/stx/builtins/image-warmup-worker";function ln(e=process.cwd()){let i=import.meta.url.endsWith(".ts")?"ts":"js";try{let n=new URL(`./image-warmup-worker.${i}`,import.meta.url);if(n.protocol==="file:"&&rn.existsSync(bt(n)))return bt(n)}catch{}return br(cn,e)}var xt=!1;function ue(e){if(!xt)xt=!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 Ee}function Ie(e){return e instanceof Error?e.message:String(e)}async function He(e,i){let n;try{n=(await import("worker_threads")).Worker}catch(a){return ue(`could not load node:worker_threads: ${Ie(a)}`)}if(typeof n!=="function")return ue("node:worker_threads has no Worker in this runtime");let o=ln();if(!o)return ue("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await on();try{return await new Promise((a,c)=>{let l;try{l=new n(o)}catch(h){a(ue(`could not start ${o}: ${Ie(h)}`));return}let u=!1,f=!1,w=(h)=>{if(f)return;f=!0,h(),l.terminate()};l.on("message",(h)=>{if(h.type==="ready"){u=!0,l.postMessage({task:e,args:i});return}if(h.type==="result"){w(()=>a(h.value));return}let y=Error(h.error?.message??"image worker failed");if(h.error?.name)y.name=h.error.name;if(h.error?.stack)y.stack=h.error.stack;w(()=>c(y))}),l.on("error",(h)=>{w(()=>u?c(h instanceof Error?h:Error(Ie(h)||"image worker crashed")):a(ue(`the worker failed before it was ready: ${Ie(h)}`)))}),l.on("exit",(h)=>{w(()=>u?c(Error("image worker exited before it finished")):a(ue(`the worker exited with code ${h} before it was ready`)))})})}finally{an()}}var un=new Set([".avif",".jpeg",".jpg",".png",".webp"]),fn=[320,640,960,1280,1920],ve="/_stx/images",dn=`stx:${ve}:alpha-1`,gn=`stx:${ve}:opaque-1`,pn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Ne;function mn(e,i){let n=G.dirname(Bun.resolveSync(e,i));while(n!==G.dirname(n)){let o=G.join(n,"package.json");if(J.existsSync(o)){let a=JSON.parse(J.readFileSync(o,"utf8"));if(a.name===e)return a.version}n=G.dirname(n)}return}function wt(){if(Ne!==void 0)return Ne;let e;try{e=G.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Ne=pn.map((i)=>{let n;try{n=e?mn(i,e):void 0}catch{}return`${i.replace("@stacksjs/","")}@${n??"unknown"}`}).join("+"),Ne}var $t=Symbol.for("stx.image-delivery");function we(){let e=globalThis;return e[$t]??={catalog:new Map,transparent:new Set},e[$t]}var St=new Set;function hn(e){return`/${e.split(G.sep).map(encodeURIComponent).join("/")}`}function yn(e){let i=G.extname(e),n=e.slice(0,-i.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),o=At("sha256").update(e).digest("hex").slice(0,8);return`${n||"image"}-${o}`}function Ct(e,i=`stx:${ve}`){let n=(o)=>`${ve}/${o.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:i,async stat(o){let a=G.join(e,o);try{let c=await J.promises.stat(a);return c.size>0?{bytes:c.size,path:a,url:n(o)}:null}catch{return null}},async write(o,a){let c=G.join(e,o);await J.promises.mkdir(G.dirname(c),{recursive:!0});let l=`${c}.${process.pid}.tmp`;return await J.promises.writeFile(l,a),await J.promises.rename(l,c),{bytes:a.byteLength,path:c,url:n(o)}},url:n}}async function It(e,i=e){let n=await J.promises.readdir(i,{withFileTypes:!0});n.sort((a,c)=>a.name.localeCompare(c.name));let o=[];for(let a of n){let c=G.join(i,a.name);if(a.isDirectory()){o.push(...await It(e,c));continue}if(!a.isFile()||!un.has(G.extname(a.name).toLowerCase()))continue;o.push({absolutePath:c,relativePath:G.relative(e,c)})}return o}function Rt(e,i){return e.map((n)=>({key:hn(n.relativePath),input:n.absolutePath,name:yn(n.relativePath),...bn(n.absolutePath)?{options:{storage:i}}:{}}))}function bn(e){return Ue(e)==="possible"}function xn(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(([,c])=>c.fallback.format==="png"),n=new Set,o=8;if(i.length===0)return n;let{decode:a}=await import("ts-images");for(let c=0;c<i.length;c+=8)await Promise.all(i.slice(c,c+8).map(async([l,u])=>{let f=u.variants.filter((w)=>w.format==="png").sort((w,h)=>w.width-h.width)[0];try{let w=await a(new Uint8Array(await J.promises.readFile(f?.path??u.fallback.path)));if(xn(w.data))n.add(l)}catch{n.add(l)}}));return n}function wn(e,i){let n=[];for(let o of i){let a=e[o],c=a?.variants.filter((u)=>u.format==="webp")??[];if(!a||c.length===0)continue;if(!c.some((u)=>{let f;try{return f=J.openSync(u.path,"r"),!ze(Ae(f,0,32))}catch{return!0}finally{if(f!==void 0)J.closeSync(f)}}))continue;if(a.variants=a.variants.filter((u)=>u.format!=="webp"),delete a.sources.webp,n.push(o),!St.has(o))St.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 n}async function $n(e){let i=[],n=8;if(e.length===0)return i;let{generateThumbHash:o}=await import("ts-images");for(let a=0;a<e.length;a+=8){let c=e.slice(a,a+8),l=await Promise.all(c.map(async(u)=>{try{return await o(u.absolutePath),u}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${u.relativePath}`),null}}));i.push(...l.filter((u)=>u!==null))}return i}function qe(e){return G.join(e,"undecodable.json")}function Sn(e){try{let i=J.readFileSync(qe(e),"utf-8"),n=JSON.parse(i);return n&&typeof n==="object"?n:{}}catch{return{}}}function Cn(e,i){try{J.mkdirSync(G.dirname(qe(e)),{recursive:!0}),J.writeFileSync(qe(e),JSON.stringify(i))}catch{}}function kt(e){try{let i=J.statSync(e);return{mtimeMs:i.mtimeMs,size:i.size}}catch{return}}function Pt(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 ti(e){let i=Pt(e);return i?we().catalog.get(i):void 0}function ni(e){let i=Pt(e);return i?we().transparent.has(i):!1}function ri(e){let i=(o)=>e.variants.filter((a)=>a.format===o).reduce((a,c)=>a+c.bytes,0),n=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<n).sort((o,a)=>o.bytes-a.bytes).map(({format:o,srcset:a})=>({format:o,srcset:a}))}function iy(e){let i=ti(e);if(!i)return;return{src:i.fallback.url,srcset:i.sources[i.fallback.format]||"",sources:ri(i).map(({format:n,srcset:o})=>({type:`image/${n}`,srcset:o})),width:i.source.width,height:i.source.height,placeholder:ni(e)?void 0:i.placeholder?.dataUrl}}function _s(){let e=we();e.catalog=new Map,e.transparent=new Set}function Rn(e){let i=we();i.catalog=new Map(e.entries),i.transparent=new Set(e.transparent)}async function ay(e,i,n={}){if(!e||!J.existsSync(e))return _s(),{count:0,fingerprint:""};if(n.offThread){let d=await He("delivery",{publicDir:e,outputDir:i});if(d!==Ee)return Rn(d.state),d.result}let o=await It(e);if(o.length===0)return _s(),{count:0,fingerprint:""};let a=Sn(i),c=o.filter((d)=>{let v=a[d.relativePath];if(!v)return!0;let k=kt(d.absolutePath);return!k||k.mtimeMs!==v.mtimeMs||k.size!==v.size});if(c.length===0)return _s(),{count:0,fingerprint:""};let l=Ct(G.join(i,"_stx","images"),`${dn}:${wt()}`),u={outDir:G.join(i,"_stx","images"),storage:Ct(G.join(i,"_stx","images"),`${gn}:${wt()}`),baseUrl:ve,widths:fn,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},{createImageDeliveryCatalog:f}=await import("ts-images/delivery"),w=c,h;try{h=await f({...u,entries:Rt(c,l)})}catch(d){if(w=await $n(c),w.length===c.length)throw d;let v=new Set(w.map((A)=>A.relativePath)),k=!1;for(let A of c){if(v.has(A.relativePath))continue;let R=kt(A.absolutePath);if(!R)continue;a[A.relativePath]=R,k=!0}if(k)Cn(i,a);if(w.length===0)return _s(),{count:0,fingerprint:""};h=await f({...u,entries:Rt(w,l)})}let y=await vn(h.entries),C=wn(h.entries,y),S=we();S.catalog=new Map(Object.entries(h.entries)),S.transparent=y;let x=y.size===0&&C.length===0?h.fingerprint:At("sha256").update(h.fingerprint).update(JSON.stringify({transparent:[...y].sort(),droppedWebp:C.sort()})).digest("hex");return{count:w.length,fingerprint:x}}class _t{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,n,o){let a=_i(e,o);if(a!==void 0)return a;for(let c of Ei(e,i,n,o))if(await s(c))return c;return null}}var de=new _t;var ne="\x00stx-boolean-attribute";function Xe(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var kn=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 Ze(e){let i=e.toLowerCase();return i.startsWith("aria-")||i.startsWith("data-")||kn.has(i)}function ie(e,i){let n=[];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)n.push(g(c));continue}if(a===ne){n.push(g(c));continue}n.push(`${g(c)}="${In(c,Xe(String(a)))}"`)}return n}function oe(e,i){let n=[];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){n.push(g(c));continue}if(typeof a==="object")continue;n.push(`${g(c)}="${In(c,Xe(String(a)))}"`)}return n}function An(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 Ve={name:"StxLink",aliases:["stx-link"],render(e,i,n){let o=An(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",u=e.static.prefetch===!0||e.static.prefetch==="true"||e.serverDynamic.prefetch===!0,f=[];if(o.reactive)f.push(`:href="${r(o.value)}"`);else f.push(`href="${r(Or(o.value,"navigable"))}"`);if(a)f.push(`class="${r(a)}"`);if(f.push("data-stx-link"),f.push(`data-stx-active-class="${r(c)}"`),f.push(`data-stx-exact-active-class="${r(l)}"`),u)f.push("data-stx-prefetch");let w=typeof e.static.activeMatch==="string"?e.static.activeMatch.trim():"";if(w)f.push(`data-stx-active-match="${r(w)}"`);let h=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return f.push(...ie(e,h)),f.push(...oe(e,h)),`<a ${f.join(" ")}>${i}</a>`}};var Pn=new Map;function Ge(e){if(!e)return;let i=e.split("?")[0].split("#")[0];return Pn.get(i)}var _n={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Ke=[320,640,768,1024,1280,1536,1920];function H(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let n=e.static[i];if(typeof n==="string")return n;return}function Oe(e,i,n=!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 n}function Ye(e){if(e.includes("(")||e.includes(","))return e;let i=e.trim().split(/\s+/),n=[];for(let o of i)if(o.includes(":")){let[a,c]=o.split(":"),l=_n[a];if(l)n.push(`(max-width: ${l}px) ${c}`);else{let u=Number.parseInt(a);if(!Number.isNaN(u))n.push(`(max-width: ${u}px) ${c}`)}}else n.push(o);return n.join(", ")}function Qe(e,i,n,o){return i.map((a)=>`${$e(e,a,void 0,n,o)} ${a}w`).join(", ")}function En(e,i,n,o,a){return i.map((c)=>{let l=n?n*c:void 0;return`${$e(e,l,void 0,o,a)} ${c}x`}).join(", ")}function $e(e,i,n,o,a){if(!o||o==="local"||o==="static")return e;if(o==="cloudinary"){let c=[];if(i)c.push(`w_${i}`);if(n)c.push(`h_${n}`);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(n)c.set("h",String(n));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(n)c.set("height",String(n));if(a)c.set("format",a);let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}return e}function Nn(e){return`var s=this.style;${e.map((i)=>`s.${i}=''`).join(";")}`}function On(e,i,n="#e5e7eb"){let o=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${i}"><rect width="100%" height="100%" fill="${n}"/></svg>`;return`data:image/svg+xml;base64,${btoa(o)}`}var et={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,i,n){let o=H(e,"src")||"",a=ti(o),c=H(e,"alt")||"",l=H(e,"width")||(a?String(a.source.width):void 0),u=H(e,"height")||(a?String(a.source.height):void 0),f=H(e,"sizes"),w=H(e,"srcset"),h=H(e,"densities"),y=H(e,"format"),C=ni(o)||Ge(o)?.transparent===!0,S=H(e,"placeholder")||(a&&!C?"thumbhash":void 0),x=H(e,"placeholderColor")||"#e5e7eb",d=H(e,"provider"),v=H(e,"class")||H(e,"className")||"",k=H(e,"style")||"",A=H(e,"objectFit")||H(e,"fit"),R=H(e,"objectPosition")||H(e,"position"),E=H(e,"quality"),K=Oe(e,"lazy",!0),U=Oe(e,"preload",!1),D=Oe(e,"priority",!1),z=H(e,"loading"),O=H(e,"decoding")||"async",q=!!a||Oe(e,"picture",!1)||!!y,I=l?Number.parseInt(l):void 0,_=u?Number.parseInt(u):void 0,j=w||"",F="";if(a)j=a.sources[a.fallback.format]||"",F=f?Ye(f):"100vw";else if(!j&&f&&d&&d!=="local"&&d!=="static")j=Qe(o,Ke,d,y),F=Ye(f);else if(!j&&h){let V=h.split(/\s+/).map((P)=>Number.parseFloat(P.replace("x","")));j=En(o,V,I,d,y)}else if(f)F=Ye(f);let M=[];if(k)M.push(k);if(A)M.push(`object-fit:${A}`);if(R)M.push(`object-position:${R}`);if(I&&_)M.push(`aspect-ratio:${I}/${_}`);let te=[],ae=S==="blur"||S==="color"||S==="thumbhash";if(ae&&!C){let V=a?.placeholder?{dataUrl:a.placeholder.dataUrl,color:x}:Ge(o);if(V&&S==="color")M.push(`background-color:${V.color}`),te.push("backgroundColor");else if(V)M.push(`background-color:${V.color}`),M.push(`background-image:url(${V.dataUrl})`),M.push("background-size:cover"),M.push("background-repeat:no-repeat"),te.push("backgroundColor","backgroundImage");else{let P=On(I||16,_||9,x);M.push(`background-image:url(${P})`),M.push("background-size:cover"),M.push("background-repeat:no-repeat"),te.push("backgroundImage")}}else if(!ae&&S&&S!=="empty"&&S!=="none")M.push(`background-image:url(${r(S)})`),M.push("background-size:cover"),M.push("background-repeat:no-repeat"),te.push("backgroundImage");let L=a?.fallback.url||$e(o,I,_,d,y),Z=[];if(Z.push(`src="${r(Or(L,"fetched"))}"`),Z.push(`alt="${r(c)}"`),l)Z.push(`width="${r(l)}"`);if(u)Z.push(`height="${r(u)}"`);let Re=z||(D||U?"eager":K?"lazy":"");if(Re)Z.push(`loading="${r(Re)}"`);if(D)Z.push('fetchpriority="high"');if(Z.push(`decoding="${r(O)}"`),v)Z.push(`class="${r(v)}"`);if(M.length>0)Z.push(`style="${r(M.join(";"))}"`);if(j)Z.push(`srcset="${r(Or(j,"fetched"))}"`);if(F)Z.push(`sizes="${r(F)}"`);let be=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(te.length>0){let V=typeof e.static.onload==="string"?e.static.onload:"",P=Nn(te)+(V?`;${V}`:"");Z.push(`onload="${r(P)}"`),be.add("onload")}Z.push(...ie(e,be)),Z.push(...oe(e,be));let le=`<img ${Z.join(" ")} />`,Q="";if(U){let P=y==="webp"?"image/webp":y==="avif"?"image/avif":"";Q=`<link rel="preload" as="image" href="${r(L)}"${P?` type="${P}"`:""}${j?` imagesrcset="${r(j)}"`:""}${F?` imagesizes="${r(F)}"`:""} />
|
|
3
|
-
`}if(q){let
|
|
4
|
-
${
|
|
2
|
+
import{zl,Hl}from"./chunk-11fxbd71.js";import{J,Ar,Ks,Gs,_i,Ei,Xs,Ie,We,xe,re,Or,Nr,me,se,B,gt,Mr,Ai,jr,Je,s,g,Y,In}from"./chunk-000mwmfq.js";import{m,N,ht,p}from"./chunk-xw291tn7.js";import{r}from"./chunk-13wd9gf0.js";import{fe}from"./chunk-ah6nc29h.js";import{br}from"./chunk-7mcs59pr.js";import{b}from"./chunk-94mpe1ny.js";import{t}from"./chunk-3ed2erm6.js";import{createHash as At}from"crypto";import K from"fs";import V from"path";import Le from"fs";function Ae(e,i,n){let o=Buffer.alloc(n),a=Le.readSync(e,o,0,n,i);return o.subarray(0,a)}function ze(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 n=i(12,16);if(n==="VP8X")return(e[20]&16)!==0;if(n==="VP8L")return((e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>28&1)===1;return!1}function Ue(e){let i;try{i=Le.openSync(e,"r");let n=Ae(i,0,33);if(n.length>=3&&n[0]===255&&n[1]===216&&n[2]===255)return"none";if(n.length>=26&&n[0]===137&&n.toString("latin1",1,4)==="PNG"){let o=n[25];if(o===4||o===6)return"possible";let a=8;for(let c=0;c<64;c++){let l=Ae(i,a,8);if(l.length<8)return"unknown";let u=l.toString("latin1",4,8);if(u==="tRNS")return"possible";if(u==="IDAT"||u==="IEND")return"none";a+=12+l.readUInt32BE(0)}return"unknown"}if(n.length>=25&&n.toString("latin1",0,4)==="RIFF"&&n.toString("latin1",8,12)==="WEBP"){if(ze(n))return"possible";let o=n.toString("latin1",12,16);return o==="VP8 "||o==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(i!==void 0)Le.closeSync(i)}}import rn from"fs";import Fe from"os";import{fileURLToPath as bt}from"url";var Ee=Symbol("stx.image-worker.unavailable");function sn(e=typeof Fe.availableParallelism==="function"?Fe.availableParallelism():Fe.cpus().length){return Math.max(1,Math.min(2,e-1))}var _e=0,vt=[];async function on(){if(_e<sn()){_e++;return}await new Promise((e)=>vt.push(e)),_e++}function an(){_e--,vt.shift()?.()}var cn="@stacksjs/stx/builtins/image-warmup-worker";function ln(e=process.cwd()){let i=import.meta.url.endsWith(".ts")?"ts":"js";try{let n=new URL(`./image-warmup-worker.${i}`,import.meta.url);if(n.protocol==="file:"&&rn.existsSync(bt(n)))return bt(n)}catch{}return br(cn,e)}var xt=!1;function ue(e){if(!xt)xt=!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 Ee}function Pe(e){return e instanceof Error?e.message:String(e)}async function He(e,i){let n;try{n=(await import("worker_threads")).Worker}catch(a){return ue(`could not load node:worker_threads: ${Pe(a)}`)}if(typeof n!=="function")return ue("node:worker_threads has no Worker in this runtime");let o=ln();if(!o)return ue("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await on();try{return await new Promise((a,c)=>{let l;try{l=new n(o)}catch(h){a(ue(`could not start ${o}: ${Pe(h)}`));return}let u=!1,f=!1,w=(h)=>{if(f)return;f=!0,h(),l.terminate()};l.on("message",(h)=>{if(h.type==="ready"){u=!0,l.postMessage({task:e,args:i});return}if(h.type==="result"){w(()=>a(h.value));return}let y=Error(h.error?.message??"image worker failed");if(h.error?.name)y.name=h.error.name;if(h.error?.stack)y.stack=h.error.stack;w(()=>c(y))}),l.on("error",(h)=>{w(()=>u?c(h instanceof Error?h:Error(Pe(h)||"image worker crashed")):a(ue(`the worker failed before it was ready: ${Pe(h)}`)))}),l.on("exit",(h)=>{w(()=>u?c(Error("image worker exited before it finished")):a(ue(`the worker exited with code ${h} before it was ready`)))})})}finally{an()}}var un=new Set([".avif",".jpeg",".jpg",".png",".webp"]),fn=[320,640,960,1280,1920],ve="/_stx/images",dn=`stx:${ve}:alpha-1`,gn=`stx:${ve}:opaque-1`,pn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Ne;function mn(e,i){let n=V.dirname(Bun.resolveSync(e,i));while(n!==V.dirname(n)){let o=V.join(n,"package.json");if(K.existsSync(o)){let a=JSON.parse(K.readFileSync(o,"utf8"));if(a.name===e)return a.version}n=V.dirname(n)}return}function wt(){if(Ne!==void 0)return Ne;let e;try{e=V.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Ne=pn.map((i)=>{let n;try{n=e?mn(i,e):void 0}catch{}return`${i.replace("@stacksjs/","")}@${n??"unknown"}`}).join("+"),Ne}var $t=Symbol.for("stx.image-delivery");function we(){let e=globalThis;return e[$t]??={catalog:new Map,transparent:new Set},e[$t]}var St=new Set;function hn(e){return`/${e.split(V.sep).map(encodeURIComponent).join("/")}`}function yn(e){let i=V.extname(e),n=e.slice(0,-i.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),o=At("sha256").update(e).digest("hex").slice(0,8);return`${n||"image"}-${o}`}function Ct(e,i=`stx:${ve}`){let n=(o)=>`${ve}/${o.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:i,async stat(o){let a=V.join(e,o);try{let c=await K.promises.stat(a);return c.size>0?{bytes:c.size,path:a,url:n(o)}:null}catch{return null}},async write(o,a){let c=V.join(e,o);await K.promises.mkdir(V.dirname(c),{recursive:!0});let l=`${c}.${process.pid}.tmp`;return await K.promises.writeFile(l,a),await K.promises.rename(l,c),{bytes:a.byteLength,path:c,url:n(o)}},url:n}}async function It(e,i=e){let n=await K.promises.readdir(i,{withFileTypes:!0});n.sort((a,c)=>a.name.localeCompare(c.name));let o=[];for(let a of n){let c=V.join(i,a.name);if(a.isDirectory()){o.push(...await It(e,c));continue}if(!a.isFile()||!un.has(V.extname(a.name).toLowerCase()))continue;o.push({absolutePath:c,relativePath:V.relative(e,c)})}return o}function Rt(e,i){return e.map((n)=>({key:hn(n.relativePath),input:n.absolutePath,name:yn(n.relativePath),...bn(n.absolutePath)?{options:{storage:i}}:{}}))}function bn(e){return Ue(e)==="possible"}function xn(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(([,c])=>c.fallback.format==="png"),n=new Set,o=8;if(i.length===0)return n;let{decode:a}=await import("ts-images");for(let c=0;c<i.length;c+=8)await Promise.all(i.slice(c,c+8).map(async([l,u])=>{let f=u.variants.filter((w)=>w.format==="png").sort((w,h)=>w.width-h.width)[0];try{let w=await a(new Uint8Array(await K.promises.readFile(f?.path??u.fallback.path)));if(xn(w.data))n.add(l)}catch{n.add(l)}}));return n}function wn(e,i){let n=[];for(let o of i){let a=e[o],c=a?.variants.filter((u)=>u.format==="webp")??[];if(!a||c.length===0)continue;if(!c.some((u)=>{let f;try{return f=K.openSync(u.path,"r"),!ze(Ae(f,0,32))}catch{return!0}finally{if(f!==void 0)K.closeSync(f)}}))continue;if(a.variants=a.variants.filter((u)=>u.format!=="webp"),delete a.sources.webp,n.push(o),!St.has(o))St.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 n}async function $n(e){let i=[],n=8;if(e.length===0)return i;let{generateThumbHash:o}=await import("ts-images");for(let a=0;a<e.length;a+=8){let c=e.slice(a,a+8),l=await Promise.all(c.map(async(u)=>{try{return await o(u.absolutePath),u}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${u.relativePath}`),null}}));i.push(...l.filter((u)=>u!==null))}return i}function qe(e){return V.join(e,"undecodable.json")}function Sn(e){try{let i=K.readFileSync(qe(e),"utf-8"),n=JSON.parse(i);return n&&typeof n==="object"?n:{}}catch{return{}}}function Cn(e,i){try{K.mkdirSync(V.dirname(qe(e)),{recursive:!0}),K.writeFileSync(qe(e),JSON.stringify(i))}catch{}}function kt(e){try{let i=K.statSync(e);return{mtimeMs:i.mtimeMs,size:i.size}}catch{return}}function Pt(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 ti(e){let i=Pt(e);return i?we().catalog.get(i):void 0}function ni(e){let i=Pt(e);return i?we().transparent.has(i):!1}function ri(e){let i=(o)=>e.variants.filter((a)=>a.format===o).reduce((a,c)=>a+c.bytes,0),n=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<n).sort((o,a)=>o.bytes-a.bytes).map(({format:o,srcset:a})=>({format:o,srcset:a}))}function ay(e){let i=ti(e);if(!i)return;return{src:i.fallback.url,srcset:i.sources[i.fallback.format]||"",sources:ri(i).map(({format:n,srcset:o})=>({type:`image/${n}`,srcset:o})),width:i.source.width,height:i.source.height,placeholder:ni(e)?void 0:i.placeholder?.dataUrl}}function _s(){let e=we();e.catalog=new Map,e.transparent=new Set}function Rn(e){let i=we();i.catalog=new Map(e.entries),i.transparent=new Set(e.transparent)}async function cy(e,i,n={}){if(!e||!K.existsSync(e))return _s(),{count:0,fingerprint:""};if(n.offThread){let d=await He("delivery",{publicDir:e,outputDir:i});if(d!==Ee)return Rn(d.state),d.result}let o=await It(e);if(o.length===0)return _s(),{count:0,fingerprint:""};let a=Sn(i),c=o.filter((d)=>{let v=a[d.relativePath];if(!v)return!0;let k=kt(d.absolutePath);return!k||k.mtimeMs!==v.mtimeMs||k.size!==v.size});if(c.length===0)return _s(),{count:0,fingerprint:""};let l=Ct(V.join(i,"_stx","images"),`${dn}:${wt()}`),u={outDir:V.join(i,"_stx","images"),storage:Ct(V.join(i,"_stx","images"),`${gn}:${wt()}`),baseUrl:ve,widths:fn,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},{createImageDeliveryCatalog:f}=await import("ts-images/delivery"),w=c,h;try{h=await f({...u,entries:Rt(c,l)})}catch(d){if(w=await $n(c),w.length===c.length)throw d;let v=new Set(w.map((A)=>A.relativePath)),k=!1;for(let A of c){if(v.has(A.relativePath))continue;let R=kt(A.absolutePath);if(!R)continue;a[A.relativePath]=R,k=!0}if(k)Cn(i,a);if(w.length===0)return _s(),{count:0,fingerprint:""};h=await f({...u,entries:Rt(w,l)})}let y=await vn(h.entries),C=wn(h.entries,y),S=we();S.catalog=new Map(Object.entries(h.entries)),S.transparent=y;let x=y.size===0&&C.length===0?h.fingerprint:At("sha256").update(h.fingerprint).update(JSON.stringify({transparent:[...y].sort(),droppedWebp:C.sort()})).digest("hex");return{count:w.length,fingerprint:x}}class _t{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,n,o){let a=_i(e,o);if(a!==void 0)return a;for(let c of Ei(e,i,n,o))if(await s(c))return c;return null}}var de=new _t;var ne="\x00stx-boolean-attribute";function Xe(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var kn=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 Ze(e){let i=e.toLowerCase();return i.startsWith("aria-")||i.startsWith("data-")||kn.has(i)}function ie(e,i){let n=[];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)n.push(g(c));continue}if(a===ne){n.push(g(c));continue}n.push(`${g(c)}="${In(c,Xe(String(a)))}"`)}return n}function oe(e,i){let n=[];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){n.push(g(c));continue}if(typeof a==="object")continue;n.push(`${g(c)}="${In(c,Xe(String(a)))}"`)}return n}function An(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 Ve={name:"StxLink",aliases:["stx-link"],render(e,i,n){let o=An(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",u=e.static.prefetch===!0||e.static.prefetch==="true"||e.serverDynamic.prefetch===!0,f=[];if(o.reactive)f.push(`:href="${r(o.value)}"`);else f.push(`href="${r(Or(o.value,"navigable"))}"`);if(a)f.push(`class="${r(a)}"`);if(f.push("data-stx-link"),f.push(`data-stx-active-class="${r(c)}"`),f.push(`data-stx-exact-active-class="${r(l)}"`),u)f.push("data-stx-prefetch");let w=typeof e.static.activeMatch==="string"?e.static.activeMatch.trim():"";if(w)f.push(`data-stx-active-match="${r(w)}"`);let h=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return f.push(...ie(e,h)),f.push(...oe(e,h)),`<a ${f.join(" ")}>${i}</a>`}};var Pn=new Map;function Ge(e){if(!e)return;let i=e.split("?")[0].split("#")[0];return Pn.get(i)}var _n={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Ke=[320,640,768,1024,1280,1536,1920];function H(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let n=e.static[i];if(typeof n==="string")return n;return}function Oe(e,i,n=!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 n}function Ye(e){if(e.includes("(")||e.includes(","))return e;let i=e.trim().split(/\s+/),n=[];for(let o of i)if(o.includes(":")){let[a,c]=o.split(":"),l=_n[a];if(l)n.push(`(max-width: ${l}px) ${c}`);else{let u=Number.parseInt(a);if(!Number.isNaN(u))n.push(`(max-width: ${u}px) ${c}`)}}else n.push(o);return n.join(", ")}function Qe(e,i,n,o){return i.map((a)=>`${$e(e,a,void 0,n,o)} ${a}w`).join(", ")}function En(e,i,n,o,a){return i.map((c)=>{let l=n?n*c:void 0;return`${$e(e,l,void 0,o,a)} ${c}x`}).join(", ")}function $e(e,i,n,o,a){if(!o||o==="local"||o==="static")return e;if(o==="cloudinary"){let c=[];if(i)c.push(`w_${i}`);if(n)c.push(`h_${n}`);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(n)c.set("h",String(n));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(n)c.set("height",String(n));if(a)c.set("format",a);let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}return e}function Nn(e){return`var s=this.style;${e.map((i)=>`s.${i}=''`).join(";")}`}function On(e,i,n="#e5e7eb"){let o=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${i}"><rect width="100%" height="100%" fill="${n}"/></svg>`;return`data:image/svg+xml;base64,${btoa(o)}`}var et={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,i,n){let o=H(e,"src")||"",a=ti(o),c=H(e,"alt")||"",l=H(e,"width")||(a?String(a.source.width):void 0),u=H(e,"height")||(a?String(a.source.height):void 0),f=H(e,"sizes"),w=H(e,"srcset"),h=H(e,"densities"),y=H(e,"format"),C=ni(o)||Ge(o)?.transparent===!0,S=H(e,"placeholder")||(a&&!C?"thumbhash":void 0),x=H(e,"placeholderColor")||"#e5e7eb",d=H(e,"provider"),v=H(e,"class")||H(e,"className")||"",k=H(e,"style")||"",A=H(e,"objectFit")||H(e,"fit"),R=H(e,"objectPosition")||H(e,"position"),E=H(e,"quality"),G=Oe(e,"lazy",!0),U=Oe(e,"preload",!1),D=Oe(e,"priority",!1),z=H(e,"loading"),O=H(e,"decoding")||"async",q=!!a||Oe(e,"picture",!1)||!!y,I=l?Number.parseInt(l):void 0,_=u?Number.parseInt(u):void 0,j=w||"",F="";if(a)j=a.sources[a.fallback.format]||"",F=f?Ye(f):"100vw";else if(!j&&f&&d&&d!=="local"&&d!=="static")j=Qe(o,Ke,d,y),F=Ye(f);else if(!j&&h){let Z=h.split(/\s+/).map((P)=>Number.parseFloat(P.replace("x","")));j=En(o,Z,I,d,y)}else if(f)F=Ye(f);let M=[];if(k)M.push(k);if(A)M.push(`object-fit:${A}`);if(R)M.push(`object-position:${R}`);if(I&&_)M.push(`aspect-ratio:${I}/${_}`);let te=[],ae=S==="blur"||S==="color"||S==="thumbhash";if(ae&&!C){let Z=a?.placeholder?{dataUrl:a.placeholder.dataUrl,color:x}:Ge(o);if(Z&&S==="color")M.push(`background-color:${Z.color}`),te.push("backgroundColor");else if(Z)M.push(`background-color:${Z.color}`),M.push(`background-image:url(${Z.dataUrl})`),M.push("background-size:cover"),M.push("background-repeat:no-repeat"),te.push("backgroundColor","backgroundImage");else{let P=On(I||16,_||9,x);M.push(`background-image:url(${P})`),M.push("background-size:cover"),M.push("background-repeat:no-repeat"),te.push("backgroundImage")}}else if(!ae&&S&&S!=="empty"&&S!=="none")M.push(`background-image:url(${r(S)})`),M.push("background-size:cover"),M.push("background-repeat:no-repeat"),te.push("backgroundImage");let L=a?.fallback.url||$e(o,I,_,d,y),X=[];if(X.push(`src="${r(Or(L,"fetched"))}"`),X.push(`alt="${r(c)}"`),l)X.push(`width="${r(l)}"`);if(u)X.push(`height="${r(u)}"`);let Re=z||(D||U?"eager":G?"lazy":"");if(Re)X.push(`loading="${r(Re)}"`);if(D)X.push('fetchpriority="high"');if(X.push(`decoding="${r(O)}"`),v)X.push(`class="${r(v)}"`);if(M.length>0)X.push(`style="${r(M.join(";"))}"`);if(j)X.push(`srcset="${r(Or(j,"fetched"))}"`);if(F)X.push(`sizes="${r(F)}"`);let be=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(te.length>0){let Z=typeof e.static.onload==="string"?e.static.onload:"",P=Nn(te)+(Z?`;${Z}`:"");X.push(`onload="${r(P)}"`),be.add("onload")}X.push(...ie(e,be)),X.push(...oe(e,be));let le=`<img ${X.join(" ")} />`,Q="";if(U){let P=y==="webp"?"image/webp":y==="avif"?"image/avif":"";Q=`<link rel="preload" as="image" href="${r(L)}"${P?` type="${P}"`:""}${j?` imagesrcset="${r(j)}"`:""}${F?` imagesizes="${r(F)}"`:""} />
|
|
3
|
+
`}if(q){let Z=[];if(a)for(let P of ri(a))Z.push(`<source type="image/${P.format}" srcset="${r(P.srcset)}"${F?` sizes="${r(F)}"`:""} />`);if(!a&&(y==="avif"||y==="auto")){let P=$e(o,I,_,d,"avif"),T=j?Qe(o,Ke,d,"avif"):`${P}`;Z.push(`<source type="image/avif" srcset="${r(T)}"${F?` sizes="${r(F)}"`:""} />`)}if(!a&&(y==="webp"||y==="auto")){let P=$e(o,I,_,d,"webp"),T=j?Qe(o,Ke,d,"webp"):`${P}`;Z.push(`<source type="image/webp" srcset="${r(T)}"${F?` sizes="${r(F)}"`:""} />`)}return`${Q}<picture>
|
|
4
|
+
${Z.join(`
|
|
5
5
|
`)}
|
|
6
6
|
${le}
|
|
7
7
|
</picture>`}return`${Q}${le}`}};var Et="/images/safe-image-default.svg";function ge(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let n=e.static[i];if(typeof n==="string")return n;return}var Bn=`<script>window.__stxSafeImageHandler||(window.__stxSafeImageHandler=function(i){if(i.__stx_fb)return;i.__stx_fb=1;var f=i.getAttribute('data-fallback')||'${Et}';var c=i.getAttribute('data-fallback-class');i.src=f;if(c)i.className=c;});</script>`,tt={name:"SafeImage",aliases:["safe-image","safe-img"],render(e,i,n){let o=ge(e,"src")||"",a=ge(e,"alt")||"",c=ge(e,"fallback")||Et,l=ge(e,"class")||ge(e,"className")||"",u=ge(e,"fallbackClassName")||"",f=[];if(f.push(`src="${r(o)}"`),f.push(`alt="${r(a)}"`),l)f.push(`class="${r(l)}"`);if(f.push(`data-fallback="${r(c)}"`),u)f.push(`data-fallback-class="${r(u)}"`);f.push('onerror="window.__stxSafeImageHandler(this)"');let w=new Set(["src","alt","fallback","class","className","fallbackClassName"]);f.push(...ie(e,w)),f.push(...oe(e,w));let h=`<img ${f.join(" ")} />`,y=n.context;if(!y.__safeImageHandlerEmitted)return y.__safeImageHandlerEmitted=!0,`${Bn}${h}`;return h}};function nt(e){return e.replace(/[;{}()]/g,"").replace(/url/gi,"")}function Se(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let n=e.static[i];if(typeof n==="string")return n;return}function Be(e,i,n){let o=Se(e,i);if(o!==void 0){let a=Number.parseInt(o,10);if(!Number.isNaN(a))return a}return n}var rt={name:"StxLoadingIndicator",aliases:["stx-loading-indicator"],render(e,i,n){let o=nt(Se(e,"color")||"#6366f1"),a=nt(Se(e,"initialColor")||Se(e,"initial-color")||""),c=nt(Se(e,"height")||"3px"),l=Be(e,"duration",2000),u=Be(e,"throttle",200),f=Be(e,"zIndex",999999)||Be(e,"z-index",999999),w=a?`linear-gradient(to right, ${a}, ${o})`:o;return`
|
|
@@ -38,5 +38,5 @@ ${le}
|
|
|
38
38
|
.stx-drawer-backdrop[data-stx-drawer-open]{display:block!important;opacity:1}
|
|
39
39
|
.stx-drawer-backdrop[data-stx-drawer-open] .stx-drawer-panel{transform:translateX(0)}
|
|
40
40
|
</style>`}};import{existsSync as Dn,readFileSync as jn}from"fs";var De=new Map,Dt=new Set;function Mn(e){if(Dt.has(e))return;Dt.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 Ln(e){let i=process.cwd();for(let n 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(Dn(n))return n;for(let n of[`@iconify-json/${e}/icons.json`,`@iconify/json/json/${e}.json`])try{return b.resolve(n)}catch{}return null}function zn(e){if(De.has(e))return De.get(e);let i=Ln(e);if(!i)return Mn(e),null;try{let n=JSON.parse(jn(i,"utf8"));return De.set(e,n),n}catch{return null}}function Un(e,i,n,o){let a=[];if(i.rotate)a.push(`rotate(${i.rotate*90} ${n/2} ${o/2})`);if(i.hFlip)a.push(`translate(${n} 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 Fn(e,i){let n=i,o=e.icons[n],a={hFlip:!1,vFlip:!1,rotate:0};for(let u=0;!o&&u<8;u++){let f=e.aliases?.[n];if(!f)return null;if(f.hFlip)a.hFlip=!a.hFlip;if(f.vFlip)a.vFlip=!a.vFlip;if(f.rotate)a.rotate=((a.rotate+f.rotate)%4+4)%4;n=f.parent,o=e.icons[n]}if(!o)return null;let c=o.width??e.width??24,l=o.height??e.height??24;return{body:Un(o.body,a,c,l),width:c,height:l}}function he(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 at={name:"Icon",aliases:["icon","stx-icon"],render(e,i,n){let o=he(e,"name")??he(e,"icon");if(!o)return"<!-- Icon: missing name/icon prop -->";let a="lucide",c=o;if(o.includes(":")){let v=o.split(":");a=v[0],c=v[1]}let l=r(he(e,"size")||"24"),u=r(he(e,"color")||"currentColor"),f=r(he(e,"class")||""),w=r(he(e,"style")||""),h=De.get(a)??zn(a);if(!h)return`<!-- Icon: collection "${a}" not loaded -->`;let y=Fn(h,c);if(!y)return`<!-- Icon: "${c}" not found in ${a} -->`;let C=`0 0 ${y.width} ${y.height}`,S=y.body;if(u!=="currentColor")S=S.replace(/currentColor/g,u);let x=f?` class="${f}"`:"",d=w?` style="${w}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${l}" viewBox="${C}" fill="none"${x}${d}>${S}</svg>`}};function jt(e,...i){for(let n of i){if(e.serverDynamic[n]!==void 0)return String(e.serverDynamic[n]);let o=e.static[n];if(typeof o==="string")return o}return}function Mt(e,i){let n=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${i}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),o=e.match(n);if(!o)return{region:null,rest:e};return{region:o[2],rest:e.replace(o[0],"")}}var ct={name:"Suspense",aliases:["suspense"],render(e,i,n){let o=Mt(i,"fallback"),a=o.rest,c=Mt(a,"error"),l=c.rest,u=o.region??jt(e,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',f=c.region??jt(e,"errorFallback","error-fallback")??'<div class="stx-suspense-error">Something went wrong.</div>';return`<div data-stx-suspense><div data-stx-suspense-fallback>${u}</div><div data-stx-suspense-error hidden>${f}</div><div data-stx-suspense-content hidden>${l}</div></div>`}};function je(e,...i){for(let n of i){if(e.serverDynamic[n]!==void 0)return String(e.serverDynamic[n]);let o=e.static[n];if(typeof o==="string")return o}return}var lt={name:"TransitionGroup",aliases:["transition-group"],render(e,i,n){let o=(je(e,"name")||"v").replace(/["'<>]/g,""),a=(je(e,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",c=je(e,"class"),l=je(e,"id"),u=[`data-stx-transition-group="${o}"`,c?`class="${c}"`:"",l?`id="${l}"`:""].filter(Boolean).join(" ");return`<${a} ${u}>${i}</${a}>`}};function Lt(e=de){e.registerBuiltin(Ve),e.registerBuiltin(et),e.registerBuiltin(tt),e.registerBuiltin(rt),e.registerBuiltin(st),e.registerBuiltin(it),e.registerBuiltin(ot),e.registerBuiltin(at),e.registerBuiltin(ct),e.registerBuiltin(lt)}var zt=new Map;function Wn(e){let i=zt.get(e.source);if(!i)i=new RegExp(`(${e.source})(?![\\w.:-])`,"y"),zt.set(e.source,i);return i}var Ut=new WeakMap;function Ft(e){let i=Ut.get(e);if(!i)i=new Set([...e].map((o)=>o.toLowerCase())),Ut.set(e,i);let n=i;return(o)=>!/[a-z]/.test(o)&&n.has(o.toLowerCase())}function Hn(e,i){let n="";for(let o=i;o<e.length;o++){let a=e[o];if(n){if(a==="\\")o++;else if(a===n)n=""}else if(a==='"'||a==="'")n=a;else if(a===">")return o}return e.length}function Wt(e,i,n){let o=[],a=0,c=typeof n==="function"?n:n?(l)=>n.has(l.toLowerCase()):void 0;while(a<e.length){let l=e.indexOf("<",a);if(l===-1)break;let u=Wn(i);u.lastIndex=l+1;let f=u.exec(e);if(!f){a=l+1;continue}let w=f[1];if(c&&c(w)){let v=l+1+w.length;while(v<e.length&&e[v]!==">")v++;a=v+1;continue}let h=l+1+w.length,y=null,C=h,S=-1,x=!1;while(h<e.length){let v=e[h];if(y){if(v==="\\"&&h+1<e.length){h+=2;continue}if(v===y)y=null;h++;continue}if(v==='"'||v==="'"){y=v,h++;continue}if(v==="/"&&h+1<e.length&&e[h+1]===">"){S=h+2,x=!0;break}if(v===">"){S=h+1;break}h++}if(S===-1){a=l+1;continue}let d=e.slice(C,x?S-2:S-1).trim();if(x)o.push({fullMatch:e.slice(l,S),tagName:w,attributes:d,content:"",startIndex:l,endIndex:S,isSelfClosing:!0}),a=S;else{let v=`<${w}`,k=`</${w}>`,A=1,R=S,E=-1;while(A>0&&R<e.length){let D=e.indexOf(v,R),z=e.indexOf(k,R);if(z===-1)break;if(D!==-1&&D<z){let O=e[D+v.length];if(O===" "||O===">"||O==="/"||O===`
|
|
41
|
-
`||O==="\t"){let q=Hn(e,D+v.length);if(e[q-1]!=="/")A++;R=q+1}else R=D+v.length}else{if(A--,A===0){E=z;break}R=z+k.length}}if(E===-1){a=S;continue}let K=e.slice(S,E),U=E+k.length;o.push({fullMatch:e.slice(l,U),tagName:w,attributes:d,content:K,startIndex:l,endIndex:U,isSelfClosing:!1}),a=U}}return o}function ut(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/�?39;/g,"'").replace(/'/gi,"'").replace(/&/g,"&")}function Ht(e,i){try{let n=Buffer.from(e,"base64").toString("utf8");return JSON.parse(n)}catch{}try{let n=e.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&");return JSON.parse(n)}catch(n){if(i?.debug)console.error("Error decoding __stx_ prop:",n);return e}}function Me(e,i){let n=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==="{")n++;else if(c==="}"){if(n--,n===0)return e.slice(i,a+1)}a++}return e.slice(i)}function qt(e){let i=e.trim();if(!i.startsWith("{")||!i.endsWith("}"))return null;if(Me(i,0).length!==i.length)return null;return i.slice(1,-1).trim()}function Xt(e){let i=[],n=0,o=e.length;while(n<o){while(n<o&&/\s/.test(e[n]))n++;if(n>=o)break;let a="";while(n<o&&!/[\s=]/.test(e[n]))a+=e[n],n++;if(!a)break;while(n<o&&/\s/.test(e[n]))n++;if(n<o&&e[n]==="="){n++;while(n<o&&/\s/.test(e[n]))n++;let c="";if(n<o&&(e[n]==='"'||e[n]==="'")){let l=e[n];n++;while(n<o&&e[n]!==l){if(e[n]==="\\"&&n+1<o)n++,c+=e[n];else c+=e[n];n++}if(n<o)n++}else if(e[n]==="{")c=Me(e,n),n+=c.length;else while(n<o&&!/\s/.test(e[n]))c+=e[n],n++;i.push({name:a,value:c})}else i.push({name:a,value:!0})}return i}var qn=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),Xn=new Set([":for","x-for","v-for","@for"]),Zt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Zn(e){return ft(e).map((i)=>[i.start,i.end])}function ft(e){let i=[],n=new Map;for(let o of Pe(e)){let a=o.name.toLowerCase();if(o.closing){let w=n.get(a)?.pop();if(w)w.end=o.end;continue}let l=/(?::for|x-for|v-for|@for)\s*=/.test(o.attributes)?Xt(o.attributes).find((w)=>Xn.has(w.name)):void 0,u=typeof l?.value==="string"?l.value:null,f=u!==null?{start:o.start,end:o.end,names:se(u),tag:a}:null;if(f)i.push(f);if(!o.selfClosing&&!Zt.has(a)){let w=n.get(a);if(!w)w=[],n.set(a,w);w.push(f)}}return i}var Vn=/(?:^|\s)((?:[\w-]+:)*-?space-[xy]-(?!reverse(?:\s|$))[\w./[\]-]+)(?=\s|$)/;function Vt(e){let i=new Map,n=[];for(let o of Pe(e)){let a=o.name.toLowerCase();if(o.closing){for(let l=n.length-1;l>=0;l--)if(n[l].name===a){n.length=l;break}continue}let c=n.at(-1);if(c){if(c.utility&&c.children>0)i.set(o.start,c.utility);if(!/(?:^|\s)hidden(?=[\s=]|$)/.test(o.attributes))c.children++}if(!o.selfClosing&&!Zt.has(a)){let l=/(?:^|\s)class\s*=\s*(["'])([\s\S]*?)\1/.exec(o.attributes)?.[2];n.push({name:a,utility:l?Vn.exec(l)?.[1]??null:null,children:0})}}return i}function Gt(e){if(typeof e==="string")return e;if(Array.isArray(e))return e.filter(Boolean).map((i)=>Gt(i)).join(" ");if(e&&typeof e==="object")return Object.entries(e).filter(([,i])=>i).map(([i])=>i).join(" ");return e?String(e):""}function Pc(e,i){if(!/:[\w-]+=/.test(e))return e;let n=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(...Zn(e));let l=new Set([...gt(i),...Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[]]);function u(y){return a.some(([C,S])=>y>=C&&y<S)}let f=[],w=new Map,h=256;for(let y of Pe(n)){if(y.closing||u(y.start))continue;let C=y.attributes.trimEnd();if(!C||!C.includes(":"))continue;let S=/(?:^|\s)data-native(?:\s|=|$)/i.test(C.replace(/"[^"]*"|'[^']*'/g,"")),x=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,d,v=C,k=!1;while((d=x.exec(C))!==null){if(Nr(C,d.index,!0)?.kind==="attribute")continue;let A=d[1],R=d[2];if(Fl(A))continue;if(B(R,l))continue;if(R.includes("()")&&!R.includes(".get(")||R.includes("$store")||R.includes("$ref"))continue;try{let E=Object.keys(i),K=Object.values(i),U=R.match(/^([a-zA-Z_$][\w$]*)/);if(U&&!E.includes(U[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(U[1]))continue;let D=JSON.stringify([E,R]),z=w.get(D);if(!z){if(z=Function(...E,`return (${R})`),w.size>=h)w.clear();w.set(D,z)}let O=z(...K);if(A==="class"){let q=Y(Gt(O));if(q){let I=v.match(/\sclass="([^"]*)"/);if(I)v=v.replace(I[0],()=>` class="${I[1]} ${q}"`);else v=v.replace(d[0],()=>` class="${q}"`)}else v=v.replace(d[0],"");k=!0;continue}if(qn.has(A)){if(O)v=v.replace(d[0],` ${A}`);else v=v.replace(d[0],"");k=!0;continue}if(O===null||O===void 0||O===!1)v=v.replace(d[0],"");else{let q=S&&typeof O==="object"?JSON.stringify(O):String(O),I=In(A,q);v=v.replace(d[0],()=>` ${A}="${I}"`)}k=!0}catch(E){if(E instanceof me)throw E;continue}}if(k){let A=y.selfClosing?" /":"",E=`<${y.name}${v}${A}>`;f.push({start:y.start,end:y.end,replacement:E})}}if(f.length>0){let y=Array(f.length*2+1),C=0;for(let S=0;S<f.length;S++){let{start:x,end:d,replacement:v}=f[S];y[S*2]=n.slice(C,x),y[S*2+1]=v,C=d}y[f.length*2]=n.slice(C),n=y.join("")}return n}import Kt from"fs";import Jt from"path";var Yt=!1;function Gn(e,i,n,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:[]),u=(C)=>{if(l.size===0)return!1;let S=t(C),x=S.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(x&&l.has(x))return!0;for(let d of l){let v=d.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${v}\\s*\\(`).test(S))return!0}return!1},f=new Set(zl),w=(C)=>{if(!C.includes("-")||C.startsWith("@")||C.startsWith(":")||C.startsWith("x-")||C.startsWith("__"))return C;if(C.startsWith("aria-")||C.startsWith("data-"))return C;return C.replace(/-([a-z0-9])/g,(S,x)=>x.toUpperCase())},h=(C,S)=>{let x=w(C);if(c.static[x]=S,x!==C)c.staticNames[x]=C},y={...e};for(let[C,S]of Object.entries(e)){let x=/^v-model(?::([a-zA-Z_][a-zA-Z0-9_]*))?((?:\.[a-zA-Z]+)*)$/.exec(C);if(!x)continue;delete y[C];let d=x[1]||"modelValue";if(y[`:${d}`]=S,y[`@update:${d}`]=`${S} = $event`,x[2]){let v=x[2].slice(1).split(".").map((k)=>`${k}: true`).join(", ");y[`:${x[1]?`${d}Modifiers`:"modelModifiers"}`]=`{ ${v} }`}}for(let[C,S]of Object.entries(y)){let x=C.startsWith("x-")&&!f.has(C)&&!C.startsWith("x-bind:")&&!C.startsWith("x-on:")?`:${C.slice(2)}`:C;if(x.startsWith("@")){c.events[x]=S;continue}if(x.startsWith("__stx_")){let d=w(x.slice(6));c.serverDynamic[d]=Ht(S,n);continue}if(x.startsWith(":")){let d=w(x.slice(1)),v=S===ne?d:S;if(d==="if"||d==="for"||d==="show"){c.clientReactive[d]=v;continue}if(o){c.clientReactive[d]=v;continue}if(B(v,a)){c.clientReactive[d]=v;continue}if(u(v)){c.clientReactive[d]=v;continue}try{if(!m(v)){if(n.debug)console.error(`Unsafe expression in :${d} binding: ${v}`);c.clientReactive[d]=v;continue}let k=Object.keys(i),A=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]),R=new Set(Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[]);if(ht(v).some((D)=>!A.has(D)&&!k.includes(D)&&(!(D in globalThis)||R.has(D)))){c.clientReactive[d]=v;continue}let U=p(v,k)(...Object.values(i));if(c.serverDynamic[d]=U,d!==x.slice(1)&&c.serverDynamicNames)c.serverDynamicNames[d]=x.slice(1)}catch{c.clientReactive[d]=v}continue}if(typeof S==="string"&&S.includes("{{")&&S.includes("}}")){let d=Qn(S,a);if(d!==null){c.clientReactive[w(x)]=d;continue}let v=S.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(v)try{let k=v[1];if(m(k)){let R=p(k,Object.keys(i))(...Object.values(i));h(x,R!=null?String(R):"")}else{if(n.debug)console.error(`Unsafe expression in ${x}: ${k}`);h(x,S)}}catch(k){if(n.debug)console.error(`Error evaluating expression for ${x}:`,k);h(x,S)}else{let k=S,A=/\{\{\s*([\s\S]+?)\s*\}\}/g,R;while((R=A.exec(S))!==null)try{let E=R[1];if(!m(E)){if(n.debug)console.error(`Unsafe expression in ${x}: ${E}`);continue}let U=p(E,Object.keys(i))(...Object.values(i));k=k.replace(R[0],String(U??""))}catch(E){if(n.debug)console.error(`Error evaluating expression in ${x}:`,E)}h(x,k)}continue}h(x,S===ne?"true":ut(S))}return c}var dt=new Set;function cy(){dt.clear()}function Kn(e){let i=/^\s*(?:<!--[\s\S]*?-->\s*)*<(?:div|span)\b((?:[^>"']|"[^"]*"|'[^']*')*)>/.exec(e);return!!i&&/\sdata-stx-component-wrapper(?=[\s=]|$)/.test(i[1])&&!/\sstx-hydrate(?=[\s=]|$)/.test(i[1])}function Jn(e,i,n){let o=`${n}\x00${e}\x00${i}`;if(dt.has(o))return;dt.add(o);let a=/space-x-/.test(i)?"flex":"flex flex-col",c=i.replace(/space-[xy]-/,"gap-");console.warn(`[stx] <${e}> in ${n} is a later child of a "${i}" stack, so it gets no spacing: the utility puts its margin on the component's scope wrapper, which generates no box. Use "${a} ${c}" on the parent instead -- gap reaches through the wrapper.`)}var pt=new Set;function ly(){pt.clear()}function Yn(e,i){let n=`${i}\x00${e}`;if(pt.has(n))return;pt.add(n),console.warn(`[stx] <${e}> in ${i} is inside a <template :for>, so its props and slot expressions will not see the loop variables and render empty. Put the directive on the element the loop repeats instead -- <tr :for="..."> or <span :for="..." class="contents"> -- which binds correctly.`)}function Qn(e,i){if(i.size===0)return null;let n=/\{\{\s*([\s\S]+?)\s*\}\}/g,o=[...e.matchAll(n)];if(!o.some((u)=>B(u[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 u of o)c+=e.slice(l,u.index).replace(/[`\\$]/g,(f)=>`\\${f}`),c+=`\${${u[1]}}`,l=u.index+u[0].length;return c+=e.slice(l).replace(/[`\\$]/g,(u)=>`\\${u}`),`\`${c}\``}var er=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function tr(e,i,n){if(!e.includes("@"))return e;if(!er.some(([a,c])=>a.test(e)&&e.includes(c)))return e;try{return fe(e,i,n)}catch{return e}}function ye(e){let i={},n=0,o=e.length;while(n<o){while(n<o&&/\s/.test(e[n]))n++;if(n>=o)break;let a="";while(n<o&&!/[\s=]/.test(e[n]))a+=e[n],n++;if(!a)break;while(n<o&&/\s/.test(e[n]))n++;if(n<o&&e[n]==="="){n++;while(n<o&&/\s/.test(e[n]))n++;let c="";if(n<o&&(e[n]==='"'||e[n]==="'")){let l=e[n];n++;while(n<o){let u=e[n];if(u==="\\"&&n+1<o){n++,c+=e[n],n++;continue}if(u===l){n++;break}c+=u,n++}}else if(e[n]==="{"){c=Me(e,n),n+=c.length;let l=qt(c);if(l!==null){i[`:${a}`]=l;continue}}else while(n<o&&!/\s/.test(e[n]))c+=e[n],n++;i[a]=c}else i[a]=ne}return i}function Qt(e){return Object.entries(e).map(([i,n])=>n===ne?i:`${i}="${nr(n)}"`).join(" ")}function nr(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function rr(e){let i=new Set,n=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,o;while((o=n.exec(e))!==null){let a=o[1];if(de.isBuiltin(a))i.add(a)}return[...i].sort()}async function cg(e,i,n,o,a){if(!/import\s/.test(e))return e;if(!i.__importedComponents)i.__importedComponents=new Map;let c=i.__importedComponents,l=Jt.dirname(n),u=[],f=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;for(let y of e.matchAll(f)){let[C,S,x]=y,d=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,v=x,k,A=[];while((k=d.exec(x))!==null){let[R,E,K,U]=k,D=null,z=null;if(U.startsWith(".")||U.startsWith("/")){let I=Jt.resolve(l,U);if(I.endsWith(".stx"))z=I;else{let _=`${I}.stx`;try{if(Kt.statSync(_).isFile())z=_}catch{try{if(Kt.statSync(I).isDirectory())D=I}catch{}}}}else D=Ks(U,l);if(!D&&!z)continue;let O=!1,q=(I,_)=>{c.set(I,_),c.set(I.toLowerCase(),_);let j=I.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();c.set(j,_),a.add(_)};if(K&&z)q(K,z),O=!0;else if(E){let I=E.slice(1,-1).split(",").map((j)=>j.trim()).filter(Boolean).map((j)=>{let F=j.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(F)return{source:F[1],local:F[2]};return{source:j,local:j}}),_=D?Ar(D):null;for(let{source:j,local:F}of I){let M=null;if(z)M=z;else if(_)M=_.get(j)??_.get(j.toLowerCase())??_.get(j.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(M)q(F,M),O=!0}}if(O)A.push({start:k.index,end:k.index+R.length})}if(A.length===0)continue;for(let R=A.length-1;R>=0;R--)v=v.slice(0,A[R].start)+v.slice(A[R].end);u.push({start:y.index,end:y.index+C.length,value:`<script${S}>${v}</script>`})}if(u.length===0)return e;let w=[],h=0;for(let y of u)w.push(e.slice(h,y.start),y.value),h=y.end;return w.push(e.slice(h)),w.join("")}async function sr(e,i,n,o,a){let c=e;if(!i.__importedComponents)i.__importedComponents=new Map;let l=i.__importedComponents,u=/@import\s*\(\s*([^)]+)\s*\)/g,f;while((f=u.exec(c))!==null){let[w,h]=f,y=h.split(",").map((C)=>C.trim().replace(/^['"]|['"]$/g,"")).filter((C)=>C.length>0);for(let C of y){let S=C.split("/"),d=S[S.length-1].replace(/\.stx$/,""),v=d.includes("-")?d.split("-").map((R)=>R.charAt(0).toUpperCase()+R.slice(1)).join(""):d.charAt(0).toUpperCase()+d.slice(1),k=null,A=Gs(C,n,o);for(let R of A)try{if(await Bun.file(R).exists()){k=R;break}}catch{}if(k){l.set(v,k),l.set(d,k),l.set(d.toLowerCase(),k);let R=v.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(l.set(R,k),a.add(k),o.debug)console.log(`Imported component: ${v} -> ${k}`)}else if(o.debug)console.warn(`Could not resolve imported component: ${C}`)}c=c.replace(w,""),u.lastIndex=0}return c}async function ir(e,i,n,o,a){let c=e,l=o.componentsDir||"components";if(!i.__processedComponents)i.__processedComponents=new Set;let u=i.__processedComponents,f=/@component\s*\(/g,w;while((w=f.exec(c))!==null){let h=w.index,y=h+w[0].length-1,C=1,S=y+1;while(S<c.length&&C>0){if(c[S]==="(")C++;else if(c[S]===")"){if(C--,C===0)break}S++}if(C!==0)break;let x=c.substring(y+1,S),d=S+1,v=x.match(/^\s*['"]([^'"]+)['"]/);if(!v){f.lastIndex=d;continue}let k=v[1],A,R=x.slice(v[0].length),E=R.match(/^\s*,\s*/);if(E)A=R.slice(E[0].length).trim();let K={};if(A)try{K=N(A,i)}catch(I){let _=I instanceof Error?I.message:String(I);c=c.replace(c.substring(h,d),`[Error parsing component props: ${_}]`);continue}let U="",D=d,O=c.substring(d).match(/^([\s\S]*?)@endcomponent/);if(O)U=O[1].trim(),D=d+O[0].length;let q=await Je(k,K,U,l,i,n,o,u,a);c=c.substring(0,h)+q+c.substring(D),f.lastIndex=0}return c}async function or(e,i,n,o,a){if(!e)return e;let c=e,l=o.componentsDir||"components";if(!i.__processedComponents)i.__processedComponents=new Set;let u=i.__processedComponents,f=lr(c);if(f.size>0){let d=Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[];i.__stx_client_declared_names=[...new Set([...d,...f])]}let w=re(c);c=w.output;let h=gt(i);return c=await x(c,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),c=await x(c,/[A-Z][a-zA-Z0-9]*/,!0,Ft(Mr)),c=await x(c,/[a-z][a-z0-9]*/,!1,Mr),c=w.restore(c),c;async function x(d,v,k,A){if(!d)return d;let R=d,E=Wt(R,v,A),K=ft(R),U=!o._nativeHostAttrs&&/space-[xy]-/.test(R),D,z=new Map;for(let I=E.length-1;I>=0;I--){let _=E[I],j=k?X(_.tagName):_.tagName,F=ye(tr(_.attributes,i,n)),M=K.filter(({start:T,end:W})=>_.startIndex>=T&&_.startIndex<W);if(M.some((T)=>T.tag==="template"))Yn(_.tagName,n);let te=M.length>0,ae=new Set(h);for(let T of M)for(let W of T.names)ae.add(W);let L=Gn(F,i,o,te,ae);if(typeof L.clientReactive.for==="string")for(let T of se(L.clientReactive.for))ae.add(T);let Z=de.getBuiltin(_.tagName),Re=Z?await jr(_.tagName,l,i,n,{...o,_nativePrimitivesFallback:void 0}):!1,be=_.tagName==="Image"&&Xs([...Object.keys(L.static),...Object.keys(L.serverDynamic),...Object.keys(L.clientReactive)],Object.keys(L.events),{...L.static,...L.serverDynamic})&&(o._pluginComponentDirs??[]).some((T)=>Ar(T).has("Image"));if(Z&&!Re&&!be){let T={context:i,filePath:n,options:o,dependencies:a},W=Z.render(L,_.content,T);if(Object.keys(L.events).length>0){let ce=Qt(L.events);W=W.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${ce}`)}if(Object.keys(L.clientReactive).length>0)W=en(W,L.clientReactive);z.set(I,W);continue}if(!k&&_.tagName.includes("-")&&!await jr(j,l,i,n,o))continue;let le={};for(let[T,W]of Object.entries(L.static))le[T]=W;for(let[T,W]of Object.entries(L.serverDynamic))le[T]=W;let Q={declaredProps:new Set,consumedProps:new Set,reactiveProps:Object.keys(L.clientReactive),events:Object.keys(L.events)},V=await Je(j,le,w.restore(_.content),l,i,n,o,u,a,[...ae],Q,_.tagName);if(U&&Kn(V)){D??=Vt(R);let T=D.get(_.startIndex);if(T)Jn(_.tagName,T,n)}let P=V;if(P=ar(P,L,Q.declaredProps,Q.consumedProps,o._nativeHostAttrs),o._nativeHostAttrs){let T=Q.reactiveProps.filter((ee)=>!Q.consumedProps.has(ee)&&!["if","for","show","key","ref"].includes(ee)).map(X),W=mt(P,!0);if(T.length&&W){if(!Object.hasOwn(ye(P.slice(W.insertPos,W.tagEnd)),"data-stx-native-host-root"))P=P.slice(0,W.insertPos)+' data-stx-native-host-root="true"'+P.slice(W.insertPos);let ee=Ce(P);P=P.slice(0,ee.insertPos)+` data-stx-native-forward="${T.join(" ")}"`+P.slice(ee.insertPos)}let ce=mt(P,!0);if(ce){let ee=ye(P.slice(ce.insertPos,ce.tagEnd)),ke=Ce(P),nn=ye(P.slice(ke.insertPos,ke.tagEnd));if(Object.hasOwn(ee,"data-stx-native-host-root")&&!Object.hasOwn(nn,"data-stx-native-host-owner"))P=P.slice(0,ke.insertPos)+" data-stx-native-host-owner"+P.slice(ke.insertPos)}}if(Object.keys(L.events).length>0){let T=Ce(P);if(T){let W=Qt(L.events),ce=Object.keys(L.events).map((ee)=>ee.replace(/^@/,"").split(".")[0]).join(" ");P=P.substring(0,T.insertPos)+` data-stx-parent-events="${ce}" ${W}`+P.substring(T.insertPos)}}if(Object.keys(L.clientReactive).length>0)P=en(P,L.clientReactive);z.set(I,P)}if(z.size===0)return R;let O="",q=0;for(let I=0;I<E.length;I++){let _=z.get(I);if(_===void 0)continue;O+=R.slice(q,E[I].startIndex),O+=_,q=E[I].endIndex}return O+=R.slice(q),O}}function en(e,i){let n=new Set(["if","for"]),o=new Set(["show"]),a=Object.entries(i).filter(([h])=>!n.has(h)),c=a.filter(([h])=>!o.has(h)).map(([h])=>X(h)).join(" "),l=e,u=a.length>0?Ce(l):null;if(u){let h=a.map(([C,S])=>`:${X(C)}="${S.replace(/"/g,""")}"`).join(" "),y=c?` data-stx-parent-bindings="${c}"`:"";l=l.substring(0,u.insertPos)+`${y} ${h}`+l.substring(u.insertPos)}let f=i.if;if(f)l=`<template :if="${f.replace(/"/g,""")}">${l}</template>`;let w=i.for;if(w){let h=i.key,y=h?` :key="${h.replace(/"/g,""")}"`:"";l=`<template :for="${w.replace(/"/g,""")}"${y}>${l}</template>`}return l}function ar(e,i,n=new Set,o=new Set,a=!1){let c=mt(e,a);if(!c)return e;let l=e.slice(c.insertPos,c.tagEnd),u=i.serverDynamic.class??i.static.class;if(a&&typeof u==="string"&&u&&!o.has("class")){let x=/(^|\s)class\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i,d=x.test(l)?l.replace(x,(v,k,A,R,E)=>`${k}class="${r(`${ut(A??R??E)} ${u}`)}"`):` class="${r(u)}"${l}`;e=e.slice(0,c.insertPos)+d+e.slice(c.tagEnd),c.tagEnd+=d.length-l.length,l=d}let f=a||/\bdata-native(?:\s|=)/i.test(l),w=f?o:n,h=new Set(Object.keys(ye(l))),y=new Set(["class","className"]);for(let x of Object.keys(i.static)){let d=i.staticNames[x]??x;if(h.has(d)||w.has(x)||!f&&!Ze(d))y.add(x)}for(let x of Object.keys(i.serverDynamic)){let d=i.serverDynamicNames?.[x]??x;if(h.has(d)||w.has(x)||!f&&!Ze(d))y.add(x)}let C=[];if(f){for(let[x,d]of Object.entries(i.static)){if(y.has(x)||d!==!0&&d!==ne)continue;y.add(x),C.push(`${r(i.staticNames?.[x]??x)}="true"`)}for(let[x,d]of Object.entries(i.serverDynamic)){if(y.has(x)||d!==!0)continue;y.add(x),C.push(`${r(i.serverDynamicNames?.[x]??x)}="true"`)}}let S=[...ie(i,y),...oe(i,y),...C];if(f){for(let[x,d]of Object.entries(i.serverDynamic)){if(y.has(x)||d!==!1)continue;let v=i.serverDynamicNames?.[x]??x;S.push(`${r(v)}="false"`)}for(let[x,d]of Object.entries(i.serverDynamic)){if(y.has(x)||d===null||typeof d!=="object")continue;let v=JSON.stringify(d);if(v!==void 0){let k=i.serverDynamicNames?.[x]??x;S.push(`${r(k)}="${r(v)}"`)}}}if(S.length===0)return e;return`${e.slice(0,c.insertPos)} ${S.join(" ")}${e.slice(c.insertPos)}`}function Ce(e){let i=tn(e,0);if(i)return i;let n=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(e);if(n)return{insertPos:n.index+1+n[1].length,tagEnd:yt(e,n.index+1+n[1].length)};return null}function mt(e,i=!1){let n=Ce(e);if(!n)return null;let o=e.slice(n.insertPos,n.tagEnd),a=/\bdata-stx-component-wrapper(?:\s|=|>|$)/i.test(o)?tn(e,n.tagEnd+1):n;return a&&i?cr(e,a)??a:a}function cr(e,i){if(!e.includes("data-stx-native-host-root"))return null;let n=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 h=e.indexOf("-->",o+4);if(h<0)return null;o=e.indexOf("<",h+3);continue}let l=/^<(\/?)([a-z][\w-]*)\b/i.exec(e.slice(o));if(!l){o=e.indexOf("<",o+1);continue}let u=l[2].toLowerCase(),f=o+l[0].length,w=yt(e,f);if(l[1]){if(a--,c!==void 0&&a<c)c=void 0;if(a<=0)return null}else if(u==="script"||u==="style"){let h=new RegExp(`</${u}\\s*>`,"gi");if(h.lastIndex=w+1,!h.exec(e))return null;o=e.indexOf("<",h.lastIndex);continue}else{let h=ye(e.slice(f,w)),y=a>0&&(Object.hasOwn(h,"data-stx-component-wrapper")||Object.hasOwn(h,"data-stx-native-host-owner"));if(c===void 0&&!y&&Object.hasOwn(h,"data-stx-native-host-root"))return{insertPos:f,tagEnd:w};if(!n.has(u)&&e[w-1]!=="/"){if(a++,c===void 0&&y)c=a}else if(a===0)return null}o=e.indexOf("<",w+1)}return null}function tn(e,i){let n=i;while(n<e.length){let o=e.slice(n),a=o.match(/^\s+/);if(a){n+=a[0].length;continue}if(o.startsWith("<!--")){let u=e.indexOf("-->",n+4);if(u===-1)return null;n=u+3;continue}let c=o.match(/^<(script|style)\b[^>]*>/i);if(c){let u=`</${c[1].toLowerCase()}>`,f=e.toLowerCase().indexOf(u,n+c[0].length);if(f===-1)return null;n=f+u.length;continue}let l=o.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!l)return null;return{insertPos:n+1+l[1].length,tagEnd:yt(e,n+1+l[1].length)}}return null}function yt(e,i){let n="";for(let o=i;o<e.length;o++){let a=e[o];if(n){if(a==="\\")o++;else if(a===n)n=""}else if(a==='"'||a==="'")n=a;else if(a===">")return o}return e.length}function lr(e){let i=new Set;for(let n of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let o=n[1];if(!/\bclient\b/.test(o)||/\bserver\b/.test(o))continue;for(let a of Ai(n[2]))i.add(a);for(let a of n[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 Cs(e,i,n,o,a){if(!Yt)Lt(de),Yt=!0;let c=await cg(e,i,n,o,a);c=await sr(c,i,n,o,a),c=await ir(c,i,n,o,a);let l=[];for(let u=0;u<3;u++){let f=l.length,w=xe(c,We,(y,C)=>`\x00STX_COMPONENT_COMMENT_${f+C}\x00`,`STX_COMPONENT_COMMENT:${f}`);l.push(...w.tokens);let h=c;if(c=await or(w.output,i,n,o,a),c===h)break}if(l.length>0)c=c.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(u,f)=>l[Number(f)]??"");if(o.debug){let u=rr(c);if(u.length>0)console.warn(`[stx] ${n}: unresolved component tag(s) after render passes: ${u.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return c}
|
|
42
|
-
export{ti,ni,ri,
|
|
41
|
+
`||O==="\t"){let q=Hn(e,D+v.length);if(e[q-1]!=="/")A++;R=q+1}else R=D+v.length}else{if(A--,A===0){E=z;break}R=z+k.length}}if(E===-1){a=S;continue}let G=e.slice(S,E),U=E+k.length;o.push({fullMatch:e.slice(l,U),tagName:w,attributes:d,content:G,startIndex:l,endIndex:U,isSelfClosing:!1}),a=U}}return o}function ut(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/�?39;/g,"'").replace(/'/gi,"'").replace(/&/g,"&")}function Ht(e,i){try{let n=Buffer.from(e,"base64").toString("utf8");return JSON.parse(n)}catch{}try{let n=e.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&");return JSON.parse(n)}catch(n){if(i?.debug)console.error("Error decoding __stx_ prop:",n);return e}}function Me(e,i){let n=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==="{")n++;else if(c==="}"){if(n--,n===0)return e.slice(i,a+1)}a++}return e.slice(i)}function qt(e){let i=e.trim();if(!i.startsWith("{")||!i.endsWith("}"))return null;if(Me(i,0).length!==i.length)return null;return i.slice(1,-1).trim()}function Xt(e){let i=[],n=0,o=e.length;while(n<o){while(n<o&&/\s/.test(e[n]))n++;if(n>=o)break;let a="";while(n<o&&!/[\s=]/.test(e[n]))a+=e[n],n++;if(!a)break;while(n<o&&/\s/.test(e[n]))n++;if(n<o&&e[n]==="="){n++;while(n<o&&/\s/.test(e[n]))n++;let c="";if(n<o&&(e[n]==='"'||e[n]==="'")){let l=e[n];n++;while(n<o&&e[n]!==l){if(e[n]==="\\"&&n+1<o)n++,c+=e[n];else c+=e[n];n++}if(n<o)n++}else if(e[n]==="{")c=Me(e,n),n+=c.length;else while(n<o&&!/\s/.test(e[n]))c+=e[n],n++;i.push({name:a,value:c})}else i.push({name:a,value:!0})}return i}var qn=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),Xn=new Set([":for","x-for","v-for","@for"]),Zt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Zn(e){return ft(e).map((i)=>[i.start,i.end])}function ft(e){let i=[],n=new Map;for(let o of Ie(e)){let a=o.name.toLowerCase();if(o.closing){let w=n.get(a)?.pop();if(w)w.end=o.end;continue}let l=/(?::for|x-for|v-for|@for)\s*=/.test(o.attributes)?Xt(o.attributes).find((w)=>Xn.has(w.name)):void 0,u=typeof l?.value==="string"?l.value:null,f=u!==null?{start:o.start,end:o.end,names:se(u),tag:a}:null;if(f)i.push(f);if(!o.selfClosing&&!Zt.has(a)){let w=n.get(a);if(!w)w=[],n.set(a,w);w.push(f)}}return i}var Vn=/(?:^|\s)((?:[\w-]+:)*-?space-[xy]-(?!reverse(?:\s|$))[\w./[\]-]+)(?=\s|$)/;function Vt(e){let i=new Map,n=[];for(let o of Ie(e)){let a=o.name.toLowerCase();if(o.closing){for(let l=n.length-1;l>=0;l--)if(n[l].name===a){n.length=l;break}continue}let c=n.at(-1);if(c){if(c.utility&&c.children>0)i.set(o.start,c.utility);if(!/(?:^|\s)hidden(?=[\s=]|$)/.test(o.attributes))c.children++}if(!o.selfClosing&&!Zt.has(a)){let l=/(?:^|\s)class\s*=\s*(["'])([\s\S]*?)\1/.exec(o.attributes)?.[2];n.push({name:a,utility:l?Vn.exec(l)?.[1]??null:null,children:0})}}return i}function Gt(e){if(typeof e==="string")return e;if(Array.isArray(e))return e.filter(Boolean).map((i)=>Gt(i)).join(" ");if(e&&typeof e==="object")return Object.entries(e).filter(([,i])=>i).map(([i])=>i).join(" ");return e?String(e):""}function Ic(e,i){if(!/:[\w-]+=/.test(e))return e;let n=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(...Zn(e));let l=new Set([...gt(i),...Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[]]);function u(y){return a.some(([C,S])=>y>=C&&y<S)}let f=[],w=new Map,h=256;for(let y of Ie(n)){if(y.closing||u(y.start))continue;let C=y.attributes.trimEnd();if(!C||!C.includes(":"))continue;let S=/(?:^|\s)data-native(?:\s|=|$)/i.test(C.replace(/"[^"]*"|'[^']*'/g,"")),x=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,d,v=C,k=!1;while((d=x.exec(C))!==null){if(Nr(C,d.index,!0)?.kind==="attribute")continue;let A=d[1],R=d[2];if(zl(A))continue;if(B(R,l))continue;if(R.includes("()")&&!R.includes(".get(")||R.includes("$store")||R.includes("$ref"))continue;try{let E=Object.keys(i),G=Object.values(i),U=R.match(/^([a-zA-Z_$][\w$]*)/);if(U&&!E.includes(U[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(U[1]))continue;let D=JSON.stringify([E,R]),z=w.get(D);if(!z){if(z=Function(...E,`return (${R})`),w.size>=h)w.clear();w.set(D,z)}let O=z(...G);if(A==="class"){let q=Y(Gt(O));if(q){let I=v.match(/\sclass="([^"]*)"/);if(I)v=v.replace(I[0],()=>` class="${I[1]} ${q}"`);else v=v.replace(d[0],()=>` class="${q}"`)}else v=v.replace(d[0],"");k=!0;continue}if(qn.has(A)){if(O)v=v.replace(d[0],` ${A}`);else v=v.replace(d[0],"");k=!0;continue}if(O===null||O===void 0||O===!1)v=v.replace(d[0],"");else{let q=S&&typeof O==="object"?JSON.stringify(O):String(O),I=In(A,q);v=v.replace(d[0],()=>` ${A}="${I}"`)}k=!0}catch(E){if(E instanceof me)throw E;continue}}if(k){let A=y.selfClosing?" /":"",E=`<${y.name}${v}${A}>`;f.push({start:y.start,end:y.end,replacement:E})}}if(f.length>0){let y=Array(f.length*2+1),C=0;for(let S=0;S<f.length;S++){let{start:x,end:d,replacement:v}=f[S];y[S*2]=n.slice(C,x),y[S*2+1]=v,C=d}y[f.length*2]=n.slice(C),n=y.join("")}return n}import Kt from"fs";import Jt from"path";var Yt=!1;function Gn(e,i,n,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:[]),u=(C)=>{if(l.size===0)return!1;let S=t(C),x=S.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(x&&l.has(x))return!0;for(let d of l){let v=d.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${v}\\s*\\(`).test(S))return!0}return!1},f=new Set(Hl),w=(C)=>{if(!C.includes("-")||C.startsWith("@")||C.startsWith(":")||C.startsWith("x-")||C.startsWith("__"))return C;if(C.startsWith("aria-")||C.startsWith("data-"))return C;return C.replace(/-([a-z0-9])/g,(S,x)=>x.toUpperCase())},h=(C,S)=>{let x=w(C);if(c.static[x]=S,x!==C)c.staticNames[x]=C},y={...e};for(let[C,S]of Object.entries(e)){let x=/^v-model(?::([a-zA-Z_][a-zA-Z0-9_]*))?((?:\.[a-zA-Z]+)*)$/.exec(C);if(!x)continue;delete y[C];let d=x[1]||"modelValue";if(y[`:${d}`]=S,y[`@update:${d}`]=`${S} = $event`,x[2]){let v=x[2].slice(1).split(".").map((k)=>`${k}: true`).join(", ");y[`:${x[1]?`${d}Modifiers`:"modelModifiers"}`]=`{ ${v} }`}}for(let[C,S]of Object.entries(y)){let x=C.startsWith("x-")&&!f.has(C)&&!C.startsWith("x-bind:")&&!C.startsWith("x-on:")?`:${C.slice(2)}`:C;if(x.startsWith("@")){c.events[x]=S;continue}if(x.startsWith("__stx_")){let d=w(x.slice(6));c.serverDynamic[d]=Ht(S,n);continue}if(x.startsWith(":")){let d=w(x.slice(1)),v=S===ne?d:S;if(d==="if"||d==="for"||d==="show"){c.clientReactive[d]=v;continue}if(o){c.clientReactive[d]=v;continue}if(B(v,a)){c.clientReactive[d]=v;continue}if(u(v)){c.clientReactive[d]=v;continue}try{if(!m(v)){if(n.debug)console.error(`Unsafe expression in :${d} binding: ${v}`);c.clientReactive[d]=v;continue}let k=Object.keys(i),A=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]),R=new Set(Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[]);if(ht(v).some((D)=>!A.has(D)&&!k.includes(D)&&(!(D in globalThis)||R.has(D)))){c.clientReactive[d]=v;continue}let U=p(v,k)(...Object.values(i));if(c.serverDynamic[d]=U,d!==x.slice(1)&&c.serverDynamicNames)c.serverDynamicNames[d]=x.slice(1)}catch{c.clientReactive[d]=v}continue}if(typeof S==="string"&&S.includes("{{")&&S.includes("}}")){let d=Qn(S,a);if(d!==null){c.clientReactive[w(x)]=d;continue}let v=S.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(v)try{let k=v[1];if(m(k)){let R=p(k,Object.keys(i))(...Object.values(i));h(x,R!=null?String(R):"")}else{if(n.debug)console.error(`Unsafe expression in ${x}: ${k}`);h(x,S)}}catch(k){if(n.debug)console.error(`Error evaluating expression for ${x}:`,k);h(x,S)}else{let k=S,A=/\{\{\s*([\s\S]+?)\s*\}\}/g,R;while((R=A.exec(S))!==null)try{let E=R[1];if(!m(E)){if(n.debug)console.error(`Unsafe expression in ${x}: ${E}`);continue}let U=p(E,Object.keys(i))(...Object.values(i));k=k.replace(R[0],String(U??""))}catch(E){if(n.debug)console.error(`Error evaluating expression in ${x}:`,E)}h(x,k)}continue}h(x,S===ne?"true":ut(S))}return c}var dt=new Set;function ly(){dt.clear()}function Kn(e){let i=/^\s*(?:<!--[\s\S]*?-->\s*)*<(?:div|span)\b((?:[^>"']|"[^"]*"|'[^']*')*)>/.exec(e);return!!i&&/\sdata-stx-component-wrapper(?=[\s=]|$)/.test(i[1])&&!/\sstx-hydrate(?=[\s=]|$)/.test(i[1])}function Jn(e,i,n){let o=`${n}\x00${e}\x00${i}`;if(dt.has(o))return;dt.add(o);let a=/space-x-/.test(i)?"flex":"flex flex-col",c=i.replace(/space-[xy]-/,"gap-");console.warn(`[stx] <${e}> in ${n} is a later child of a "${i}" stack, so it gets no spacing: the utility puts its margin on the component's scope wrapper, which generates no box. Use "${a} ${c}" on the parent instead -- gap reaches through the wrapper.`)}var pt=new Set;function uy(){pt.clear()}function Yn(e,i){let n=`${i}\x00${e}`;if(pt.has(n))return;pt.add(n),console.warn(`[stx] <${e}> in ${i} is inside a <template :for>, so its props and slot expressions will not see the loop variables and render empty. Put the directive on the element the loop repeats instead -- <tr :for="..."> or <span :for="..." class="contents"> -- which binds correctly.`)}function Qn(e,i){if(i.size===0)return null;let n=/\{\{\s*([\s\S]+?)\s*\}\}/g,o=[...e.matchAll(n)];if(!o.some((u)=>B(u[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 u of o)c+=e.slice(l,u.index).replace(/[`\\$]/g,(f)=>`\\${f}`),c+=`\${${u[1]}}`,l=u.index+u[0].length;return c+=e.slice(l).replace(/[`\\$]/g,(u)=>`\\${u}`),`\`${c}\``}var er=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function tr(e,i,n){if(!e.includes("@"))return e;if(!er.some(([a,c])=>a.test(e)&&e.includes(c)))return e;try{return fe(e,i,n)}catch{return e}}function ye(e){let i={},n=0,o=e.length;while(n<o){while(n<o&&/\s/.test(e[n]))n++;if(n>=o)break;let a="";while(n<o&&!/[\s=]/.test(e[n]))a+=e[n],n++;if(!a)break;while(n<o&&/\s/.test(e[n]))n++;if(n<o&&e[n]==="="){n++;while(n<o&&/\s/.test(e[n]))n++;let c="";if(n<o&&(e[n]==='"'||e[n]==="'")){let l=e[n];n++;while(n<o){let u=e[n];if(u==="\\"&&n+1<o){n++,c+=e[n],n++;continue}if(u===l){n++;break}c+=u,n++}}else if(e[n]==="{"){c=Me(e,n),n+=c.length;let l=qt(c);if(l!==null){i[`:${a}`]=l;continue}}else while(n<o&&!/\s/.test(e[n]))c+=e[n],n++;i[a]=c}else i[a]=ne}return i}function Qt(e){return Object.entries(e).map(([i,n])=>n===ne?i:`${i}="${nr(n)}"`).join(" ")}function nr(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function rr(e){let i=new Set,n=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,o;while((o=n.exec(e))!==null){let a=o[1];if(de.isBuiltin(a))i.add(a)}return[...i].sort()}async function lg(e,i,n,o,a){if(!/import\s/.test(e))return e;if(!i.__importedComponents)i.__importedComponents=new Map;let c=i.__importedComponents,l=Jt.dirname(n),u=[],f=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;for(let y of e.matchAll(f)){let[C,S,x]=y,d=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,v=x,k,A=[];while((k=d.exec(x))!==null){let[R,E,G,U]=k,D=null,z=null;if(U.startsWith(".")||U.startsWith("/")){let I=Jt.resolve(l,U);if(I.endsWith(".stx"))z=I;else{let _=`${I}.stx`;try{if(Kt.statSync(_).isFile())z=_}catch{try{if(Kt.statSync(I).isDirectory())D=I}catch{}}}}else D=Ks(U,l);if(!D&&!z)continue;let O=!1,q=(I,_)=>{c.set(I,_),c.set(I.toLowerCase(),_);let j=I.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();c.set(j,_),a.add(_)};if(G&&z)q(G,z),O=!0;else if(E){let I=E.slice(1,-1).split(",").map((j)=>j.trim()).filter(Boolean).map((j)=>{let F=j.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(F)return{source:F[1],local:F[2]};return{source:j,local:j}}),_=D?Ar(D):null;for(let{source:j,local:F}of I){let M=null;if(z)M=z;else if(_)M=_.get(j)??_.get(j.toLowerCase())??_.get(j.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(M)q(F,M),O=!0}}if(O)A.push({start:k.index,end:k.index+R.length})}if(A.length===0)continue;for(let R=A.length-1;R>=0;R--)v=v.slice(0,A[R].start)+v.slice(A[R].end);u.push({start:y.index,end:y.index+C.length,value:`<script${S}>${v}</script>`})}if(u.length===0)return e;let w=[],h=0;for(let y of u)w.push(e.slice(h,y.start),y.value),h=y.end;return w.push(e.slice(h)),w.join("")}async function sr(e,i,n,o,a){let c=e;if(!i.__importedComponents)i.__importedComponents=new Map;let l=i.__importedComponents,u=/@import\s*\(\s*([^)]+)\s*\)/g,f;while((f=u.exec(c))!==null){let[w,h]=f,y=h.split(",").map((C)=>C.trim().replace(/^['"]|['"]$/g,"")).filter((C)=>C.length>0);for(let C of y){let S=C.split("/"),d=S[S.length-1].replace(/\.stx$/,""),v=d.includes("-")?d.split("-").map((R)=>R.charAt(0).toUpperCase()+R.slice(1)).join(""):d.charAt(0).toUpperCase()+d.slice(1),k=null,A=Gs(C,n,o);for(let R of A)try{if(await Bun.file(R).exists()){k=R;break}}catch{}if(k){l.set(v,k),l.set(d,k),l.set(d.toLowerCase(),k);let R=v.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(l.set(R,k),a.add(k),o.debug)console.log(`Imported component: ${v} -> ${k}`)}else if(o.debug)console.warn(`Could not resolve imported component: ${C}`)}c=c.replace(w,""),u.lastIndex=0}return c}async function ir(e,i,n,o,a){let c=e,l=o.componentsDir||"components";if(!i.__processedComponents)i.__processedComponents=new Set;let u=i.__processedComponents,f=/@component\s*\(/g,w;while((w=f.exec(c))!==null){let h=w.index,y=h+w[0].length-1,C=1,S=y+1;while(S<c.length&&C>0){if(c[S]==="(")C++;else if(c[S]===")"){if(C--,C===0)break}S++}if(C!==0)break;let x=c.substring(y+1,S),d=S+1,v=x.match(/^\s*['"]([^'"]+)['"]/);if(!v){f.lastIndex=d;continue}let k=v[1],A,R=x.slice(v[0].length),E=R.match(/^\s*,\s*/);if(E)A=R.slice(E[0].length).trim();let G={};if(A)try{G=N(A,i)}catch(I){let _=I instanceof Error?I.message:String(I);c=c.replace(c.substring(h,d),`[Error parsing component props: ${_}]`);continue}let U="",D=d,O=c.substring(d).match(/^([\s\S]*?)@endcomponent/);if(O)U=O[1].trim(),D=d+O[0].length;let q=await Je(k,G,U,l,i,n,o,u,a);c=c.substring(0,h)+q+c.substring(D),f.lastIndex=0}return c}async function or(e,i,n,o,a){if(!e)return e;let c=e,l=o.componentsDir||"components";if(!i.__processedComponents)i.__processedComponents=new Set;let u=i.__processedComponents,f=lr(c);if(f.size>0){let d=Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[];i.__stx_client_declared_names=[...new Set([...d,...f])]}let w=re(c);c=w.output;let h=gt(i);return c=await x(c,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),c=await x(c,/[A-Z][a-zA-Z0-9]*/,!0,Ft(Mr)),c=await x(c,/[a-z][a-z0-9]*/,!1,Mr),c=w.restore(c),c;async function x(d,v,k,A){if(!d)return d;let R=d,E=Wt(R,v,A),G=ft(R),U=!o._nativeHostAttrs&&/space-[xy]-/.test(R),D,z=new Map;for(let I=E.length-1;I>=0;I--){let _=E[I],j=k?J(_.tagName):_.tagName,F=ye(tr(_.attributes,i,n)),M=G.filter(({start:T,end:W})=>_.startIndex>=T&&_.startIndex<W);if(M.some((T)=>T.tag==="template"))Yn(_.tagName,n);let te=M.length>0,ae=new Set(h);for(let T of M)for(let W of T.names)ae.add(W);let L=Gn(F,i,o,te,ae);if(typeof L.clientReactive.for==="string")for(let T of se(L.clientReactive.for))ae.add(T);let X=de.getBuiltin(_.tagName),Re=X?await jr(_.tagName,l,i,n,{...o,_nativePrimitivesFallback:void 0}):!1,be=_.tagName==="Image"&&Xs([...Object.keys(L.static),...Object.keys(L.serverDynamic),...Object.keys(L.clientReactive)],Object.keys(L.events),{...L.static,...L.serverDynamic})&&(o._pluginComponentDirs??[]).some((T)=>Ar(T).has("Image"));if(X&&!Re&&!be){let T={context:i,filePath:n,options:o,dependencies:a},W=X.render(L,_.content,T);if(Object.keys(L.events).length>0){let ce=Qt(L.events);W=W.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${ce}`)}if(Object.keys(L.clientReactive).length>0)W=en(W,L.clientReactive);z.set(I,W);continue}if(!k&&_.tagName.includes("-")&&!await jr(j,l,i,n,o))continue;let le={};for(let[T,W]of Object.entries(L.static))le[T]=W;for(let[T,W]of Object.entries(L.serverDynamic))le[T]=W;let Q={declaredProps:new Set,consumedProps:new Set,reactiveProps:Object.keys(L.clientReactive),events:Object.keys(L.events)},Z=await Je(j,le,w.restore(_.content),l,i,n,o,u,a,[...ae],Q,_.tagName);if(U&&Kn(Z)){D??=Vt(R);let T=D.get(_.startIndex);if(T)Jn(_.tagName,T,n)}let P=Z;if(P=ar(P,L,Q.declaredProps,Q.consumedProps,o._nativeHostAttrs),o._nativeHostAttrs){let T=Q.reactiveProps.filter((ee)=>!Q.consumedProps.has(ee)&&!["if","for","show","key","ref"].includes(ee)).map(J),W=mt(P,!0);if(T.length&&W){if(!Object.hasOwn(ye(P.slice(W.insertPos,W.tagEnd)),"data-stx-native-host-root"))P=P.slice(0,W.insertPos)+' data-stx-native-host-root="true"'+P.slice(W.insertPos);let ee=Ce(P);P=P.slice(0,ee.insertPos)+` data-stx-native-forward="${T.join(" ")}"`+P.slice(ee.insertPos)}let ce=mt(P,!0);if(ce){let ee=ye(P.slice(ce.insertPos,ce.tagEnd)),ke=Ce(P),nn=ye(P.slice(ke.insertPos,ke.tagEnd));if(Object.hasOwn(ee,"data-stx-native-host-root")&&!Object.hasOwn(nn,"data-stx-native-host-owner"))P=P.slice(0,ke.insertPos)+" data-stx-native-host-owner"+P.slice(ke.insertPos)}}if(Object.keys(L.events).length>0){let T=Ce(P);if(T){let W=Qt(L.events),ce=Object.keys(L.events).map((ee)=>ee.replace(/^@/,"").split(".")[0]).join(" ");P=P.substring(0,T.insertPos)+` data-stx-parent-events="${ce}" ${W}`+P.substring(T.insertPos)}}if(Object.keys(L.clientReactive).length>0)P=en(P,L.clientReactive);z.set(I,P)}if(z.size===0)return R;let O="",q=0;for(let I=0;I<E.length;I++){let _=z.get(I);if(_===void 0)continue;O+=R.slice(q,E[I].startIndex),O+=_,q=E[I].endIndex}return O+=R.slice(q),O}}function en(e,i){let n=new Set(["if","for"]),o=new Set(["show"]),a=Object.entries(i).filter(([h])=>!n.has(h)),c=a.filter(([h])=>!o.has(h)).map(([h])=>J(h)).join(" "),l=e,u=a.length>0?Ce(l):null;if(u){let h=a.map(([C,S])=>`:${J(C)}="${S.replace(/"/g,""")}"`).join(" "),y=c?` data-stx-parent-bindings="${c}"`:"";l=l.substring(0,u.insertPos)+`${y} ${h}`+l.substring(u.insertPos)}let f=i.if;if(f)l=`<template :if="${f.replace(/"/g,""")}">${l}</template>`;let w=i.for;if(w){let h=i.key,y=h?` :key="${h.replace(/"/g,""")}"`:"";l=`<template :for="${w.replace(/"/g,""")}"${y}>${l}</template>`}return l}function ar(e,i,n=new Set,o=new Set,a=!1){let c=mt(e,a);if(!c)return e;let l=e.slice(c.insertPos,c.tagEnd),u=i.serverDynamic.class??i.static.class;if(a&&typeof u==="string"&&u&&!o.has("class")){let x=/(^|\s)class\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i,d=x.test(l)?l.replace(x,(v,k,A,R,E)=>`${k}class="${r(`${ut(A??R??E)} ${u}`)}"`):` class="${r(u)}"${l}`;e=e.slice(0,c.insertPos)+d+e.slice(c.tagEnd),c.tagEnd+=d.length-l.length,l=d}let f=a||/\bdata-native(?:\s|=)/i.test(l),w=f?o:n,h=new Set(Object.keys(ye(l))),y=new Set(["class","className"]);for(let x of Object.keys(i.static)){let d=i.staticNames[x]??x;if(h.has(d)||w.has(x)||!f&&!Ze(d))y.add(x)}for(let x of Object.keys(i.serverDynamic)){let d=i.serverDynamicNames?.[x]??x;if(h.has(d)||w.has(x)||!f&&!Ze(d))y.add(x)}let C=[];if(f){for(let[x,d]of Object.entries(i.static)){if(y.has(x)||d!==!0&&d!==ne)continue;y.add(x),C.push(`${r(i.staticNames?.[x]??x)}="true"`)}for(let[x,d]of Object.entries(i.serverDynamic)){if(y.has(x)||d!==!0)continue;y.add(x),C.push(`${r(i.serverDynamicNames?.[x]??x)}="true"`)}}let S=[...ie(i,y),...oe(i,y),...C];if(f){for(let[x,d]of Object.entries(i.serverDynamic)){if(y.has(x)||d!==!1)continue;let v=i.serverDynamicNames?.[x]??x;S.push(`${r(v)}="false"`)}for(let[x,d]of Object.entries(i.serverDynamic)){if(y.has(x)||d===null||typeof d!=="object")continue;let v=JSON.stringify(d);if(v!==void 0){let k=i.serverDynamicNames?.[x]??x;S.push(`${r(k)}="${r(v)}"`)}}}if(S.length===0)return e;return`${e.slice(0,c.insertPos)} ${S.join(" ")}${e.slice(c.insertPos)}`}function Ce(e){let i=tn(e,0);if(i)return i;let n=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(e);if(n)return{insertPos:n.index+1+n[1].length,tagEnd:yt(e,n.index+1+n[1].length)};return null}function mt(e,i=!1){let n=Ce(e);if(!n)return null;let o=e.slice(n.insertPos,n.tagEnd),a=/\bdata-stx-component-wrapper(?:\s|=|>|$)/i.test(o)?tn(e,n.tagEnd+1):n;return a&&i?cr(e,a)??a:a}function cr(e,i){if(!e.includes("data-stx-native-host-root"))return null;let n=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 h=e.indexOf("-->",o+4);if(h<0)return null;o=e.indexOf("<",h+3);continue}let l=/^<(\/?)([a-z][\w-]*)\b/i.exec(e.slice(o));if(!l){o=e.indexOf("<",o+1);continue}let u=l[2].toLowerCase(),f=o+l[0].length,w=yt(e,f);if(l[1]){if(a--,c!==void 0&&a<c)c=void 0;if(a<=0)return null}else if(u==="script"||u==="style"){let h=new RegExp(`</${u}\\s*>`,"gi");if(h.lastIndex=w+1,!h.exec(e))return null;o=e.indexOf("<",h.lastIndex);continue}else{let h=ye(e.slice(f,w)),y=a>0&&(Object.hasOwn(h,"data-stx-component-wrapper")||Object.hasOwn(h,"data-stx-native-host-owner"));if(c===void 0&&!y&&Object.hasOwn(h,"data-stx-native-host-root"))return{insertPos:f,tagEnd:w};if(!n.has(u)&&e[w-1]!=="/"){if(a++,c===void 0&&y)c=a}else if(a===0)return null}o=e.indexOf("<",w+1)}return null}function tn(e,i){let n=i;while(n<e.length){let o=e.slice(n),a=o.match(/^\s+/);if(a){n+=a[0].length;continue}if(o.startsWith("<!--")){let u=e.indexOf("-->",n+4);if(u===-1)return null;n=u+3;continue}let c=o.match(/^<(script|style)\b[^>]*>/i);if(c){let u=`</${c[1].toLowerCase()}>`,f=e.toLowerCase().indexOf(u,n+c[0].length);if(f===-1)return null;n=f+u.length;continue}let l=o.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!l)return null;return{insertPos:n+1+l[1].length,tagEnd:yt(e,n+1+l[1].length)}}return null}function yt(e,i){let n="";for(let o=i;o<e.length;o++){let a=e[o];if(n){if(a==="\\")o++;else if(a===n)n=""}else if(a==='"'||a==="'")n=a;else if(a===">")return o}return e.length}function lr(e){let i=new Set;for(let n of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let o=n[1];if(!/\bclient\b/.test(o)||/\bserver\b/.test(o))continue;for(let a of Ai(n[2]))i.add(a);for(let a of n[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 Cs(e,i,n,o,a){if(!Yt)Lt(de),Yt=!0;let c=await lg(e,i,n,o,a);c=await sr(c,i,n,o,a),c=await ir(c,i,n,o,a);let l=[];for(let u=0;u<3;u++){let f=l.length,w=xe(c,We,(y,C)=>`\x00STX_COMPONENT_COMMENT_${f+C}\x00`,`STX_COMPONENT_COMMENT:${f}`);l.push(...w.tokens);let h=c;if(c=await or(w.output,i,n,o,a),c===h)break}if(l.length>0)c=c.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(u,f)=>l[Number(f)]??"");if(o.debug){let u=rr(c);if(u.length>0)console.warn(`[stx] ${n}: unresolved component tag(s) after render passes: ${u.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return c}
|
|
42
|
+
export{ti,ni,ri,ay,_s,cy,Ic,ly,uy,lg,Cs};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{De}from"./chunk-
|
|
2
|
+
import{De}from"./chunk-kvxdyg7e.js";import{_}from"./chunk-11fxbd71.js";import{M,jn}from"./chunk-hxhmhw23.js";import{A,oe}from"./chunk-000mwmfq.js";import{a}from"./chunk-zje94z0k.js";import{Ee,hn,yn,bn}from"./chunk-dbhmbef1.js";import{Pt}from"./chunk-mm1eg2pg.js";import{Tt,er,ln,be}from"./chunk-97kgrevs.js";import{I,et}from"./chunk-w50yggy3.js";import v from"fs";import b from"path";import x from"process";function B(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 R(s,o=I()){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${yn()}\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 be(h,t,"",{chunks:[]}),null}let i=()=>[...new Set([...r,...r.flatMap((l)=>Ee(l))])],f=Tt(i()),u=ln(h,t,f);if(u!==void 0)return u.chunks.length>0?u:null;if(r.length===0)return be(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=oe({loader:"ts",target:"browser",define:A()});for(let l of p)try{let c=await Bun.file(l).text(),k=b.basename(l,".ts"),y=new Set;B(c,y);let C=[...c.matchAll(/\bdefineStore\s*(?:<[^>()]*>)?\(\s*(['"`])([^'"`$\\]+)\1/g)].map((U)=>U[2]),N=c.match(/\bdefineStore\s*(?:<[^>()]*>)?\(/g)?.length??0;if(hn(c))c=await bn(c,l,{projectRoot:x.cwd(),externalizeUserModules:o});c=Pt(c),c=M(c),c=jn(c),c=c.replace(/^export\s+(default\s+)?/gm,""),c=d.transformSync(c),g.push({name:k,ids:C.length===N?C:[],declared:y,code:`// Store: ${k}
|
|
3
3
|
${c.trim()}`})}catch(c){console.warn(`[stx] Failed to load store ${l}:`,c)}if(g.length===0)return be(h,t,f,{chunks:[]}),null;f=Tt(i());let S={chunks:g};return be(h,t,f,S),S}function j(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
|
${_.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 z=new WeakMap;async function
|
|
15
|
+
}`})}var z=new WeakMap;async function Nh(s){let o=await R(s);if(!o)return null;let e=z.get(o);if(e===void 0)e=j(o.chunks),z.set(o,e);return e}function W(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 Do(...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(W(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 F=new Map;function Mh(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=v.statSync(t),i=F.get(t);if(i&&i.mtimeMs===r.mtimeMs&&i.size===r.size)n=i.read;else n=Do(v.readFileSync(t,"utf8")),F.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 Dh(s=x.env){return s.STX_PAGE_STORES==="all"}async function Lh(s,o,e={}){let t=await R(s,e.sharedModules);if(!t)return null;let{chunks:n}=t,r=Do(...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?Z(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=Do(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=O.get(t);if(!p)O.set(t,p=new Map);let g=p.get(m.join("\x00"));if(g===void 0)p.set(m.join("\x00"),g=P(m,u));return{code:g,stores:m,functions:u}}return{code:j(f),stores:f.map((u)=>u.name),functions:E(f)}}var O=new WeakMap,w=new WeakMap;function Z(s){if(w.has(s))return w.get(s);let o=E(s.chunks),e=o?new Map(s.chunks.map((t,n)=>[t,o[n]])):null;return w.set(s,e),e}function P(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 I()?et(t):t}function
|
|
26
|
-
export{
|
|
25
|
+
})();`;return I()?et(t):t}function jh(){h.clear(),er()}
|
|
26
|
+
export{Nh,Do,Mh,Dh,Lh,jh};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{h,Di,yl,bl,Lg,jg,Bg,Fg,zg,oo,Hg,Ge,oe,Xe,Vg,jr,Ug,xl,Sl,Bi,Je,s,An,kl,y,_e,Ty}from"./chunk-000mwmfq.js";import"./chunk-fce8wj3t.js";import"./chunk-6t04tqvh.js";import"./chunk-xw291tn7.js";import"./chunk-hxhmhw23.js";import"./chunk-kvxdyg7e.js";import"./chunk-s29hp1qw.js";import"./chunk-11fxbd71.js";export{Sl as SIGNAL_COMPOSABLE_CALL,_e as clearComponentCache,Bi as componentClientSignalNames,Di as convertToCommonJS,y as createDetailedErrorMessage,zg as extractDirectiveNames,yl as extractScriptFromTemplate,h as extractVariables,s as fileExists,Ty as getComponentCacheStats,jg as getPositionInfo,oe as getSharedTranspiler,kl as getSourceLineInfo,Fg as hasDirectives,bl as hasVariables,Ug as isHydrateTrigger,Hg as isJavaScriptScript,Je as renderComponentWithSlot,An as resolveTemplatePath,Vg as scopeOnRootElement,oo as scopeSequenceKey,Ge as shouldTranspileTypeScript,xl as slotContentHasExpressions,Xe as transpileTypeScript,jr as userComponentFileExists,Bg as validateDirective,Lg as validateTemplate};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ve}from"./chunk-
|
|
2
|
+
import{ve}from"./chunk-b8528fra.js";import{Ye,F}from"./chunk-6t04tqvh.js";import{qc}from"./chunk-zf29ahhd.js";import{l}from"./chunk-z55rpt3s.js";import v from"fs";import m from"path";import{pathToFileURL as I}from"url";var P=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],R=new Set;function wn(s,c={}){let o=m.resolve(s,c.dir??"server/api"),i=[],f=new Map;if(!v.existsSync(o))return i;let t=Array.from(new Bun.Glob("**/*.{ts,js,mts,mjs}").scanSync({cwd:o})).sort();for(let e of t){if(e.endsWith(".d.ts"))continue;let p=e.replace(/\.(?:ts|js|mts|mjs)$/,"").split("/"),n=p.pop(),u=n.lastIndexOf("."),d=u>=0?n.slice(u+1):"get",g=d.toUpperCase();if(!P.includes(g)||d!==d.toLowerCase())throw Error(`Unsupported API method suffix in ${e}; use ${P.map((A)=>A.toLowerCase()).join(", ")}`);if(u>=0)n=n.slice(0,u);if(n!=="index")p.push(n);let r=new Set,h=p.map((A,j)=>{let y=/^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(A);if(y){if(r.has(y[2])||y[1]&&j!==p.length-1)throw Error(`Invalid API parameter in ${e}`);return r.add(y[2]),`:${y[2]}${y[1]?"*":""}`}if(!/^[\w-]+$/.test(A))throw Error(`Unsupported API path segment ${A} in ${e}`);return A}),w=`/api${h.length?`/${h.join("/")}`:""}`,S=`${g} ${w.replace(/:\w+/g,":param")}`;if(f.has(S))throw Error(`Ambiguous API route ${g} ${w}: ${f.get(S)} and ${e}`);f.set(S,e);let x=m.join(o,e);R.add(m.resolve(x)),R.add(v.realpathSync(x)),i.push({pattern:w,method:g,filePath:x})}return i.sort((e,a)=>{let p=e.pattern.split("/"),n=a.pattern.split("/"),u=(d)=>d?.endsWith("*")?0:d?.startsWith(":")?1:2;for(let d=0;d<Math.max(p.length,n.length);d++){let g=u(n[d])-u(p[d]);if(g)return g}return e.pattern.localeCompare(a.pattern)||e.method.localeCompare(a.method)})}async function Go(s,c){let o=l(s,"api-types.d.ts"),i=["// Generated by stx. Include this file in tsconfig.json.","declare module '@stacksjs/stx/api-client' {"," interface KnownApiRoutes {"];for(let t of c){let e=`./${m.relative(m.dirname(o),t.filePath).replace(/\\/g,"/")}`,{params:a}=ve(t.pattern);i.push(` ${JSON.stringify(`${t.method} ${t.pattern}`)}: { params: { ${a.map((p)=>`${JSON.stringify(p)}: string`).join("; ")} }; response: Awaited<ReturnType<typeof import(${JSON.stringify(e)}).default>> }`)}i.push(" }","}","export {}","");let f=i.join(`
|
|
3
3
|
`);if(!await Bun.file(o).exists()||await Bun.file(o).text()!==f)await Bun.write(o,f);return o}async function Xo(s,c,o={}){let i=wn(s,o);await Go(s,i);let f=[];for(let t of i){let e=await Bun.build({entrypoints:[t.filePath],target:"bun",format:"esm",minify:!1,splitting:!1});if(!e.success)throw Error(`API build failed for ${t.filePath}: ${e.logs.join(`
|
|
4
|
-
`)}`);let a=e.outputs.find((u)=>u.kind==="entry-point");if(!a)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await a.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(c,n),a),f.push({...t,filePath:n})}return f}function E(s,c){let o=s.map((i)=>({route:i,...ve(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,a=(r)=>r.replace(/:\w+/g,":param"),p=t.filter((r)=>a(r.route.pattern)===a(e)),n=i.method,u=p.find((r)=>r.route.method===n)??(n==="HEAD"?p.find((r)=>r.route.method==="GET"):void 0);if(!u){let r=new Set(p.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=u.regex.exec(f),g=Object.create(null);try{u.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await c(u.route);if(typeof r!=="function")throw Error(`API endpoint ${u.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Jo(s,c){return E(c,async(o)=>(await import(I(m.resolve(s,o.filePath)).href)).default)}async function
|
|
5
|
-
`));let u=n.outputs.find((d)=>d.kind==="entry-point");if(!u||n.outputs.length!==1)throw Error(`Unsupported API bundle output: ${p.filePath}`);return(await import(`data:text/javascript;base64,${Buffer.from(await u.text()).toString("base64")}`)).default})(f))}catch(t){return console.error("[stx] API discovery failed:",t),Response.json({error:"API discovery failed; check the server log"},{status:500})}}}function Yo(s,c,o){if(
|
|
6
|
-
export{wn,Go,Xo,Jo,
|
|
4
|
+
`)}`);let a=e.outputs.find((u)=>u.kind==="entry-point");if(!a)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await a.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(c,n),a),f.push({...t,filePath:n})}return f}function E(s,c){let o=s.map((i)=>({route:i,...ve(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,a=(r)=>r.replace(/:\w+/g,":param"),p=t.filter((r)=>a(r.route.pattern)===a(e)),n=i.method,u=p.find((r)=>r.route.method===n)??(n==="HEAD"?p.find((r)=>r.route.method==="GET"):void 0);if(!u){let r=new Set(p.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=u.regex.exec(f),g=Object.create(null);try{u.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await c(u.route);if(typeof r!=="function")throw Error(`API endpoint ${u.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Jo(s,c){return E(c,async(o)=>(await import(I(m.resolve(s,o.filePath)).href)).default)}async function ty(s,c){if(!c)return async()=>null;let o=c===!0?{}:c,i=wn(s,o);return await Go(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=wn(s,o);await Go(s,t);let{loadStxConfig:e}=await import("./chunk-3zyzhcd9.js"),a=F((await e(s)).runtimeConfig);return await Ye(a,()=>E(t,async(p)=>{let n=await Bun.build({entrypoints:[p.filePath],target:"bun",format:"esm",splitting:!1});if(!n.success)throw Error(n.logs.join(`
|
|
5
|
+
`));let u=n.outputs.find((d)=>d.kind==="entry-point");if(!u||n.outputs.length!==1)throw Error(`Unsupported API bundle output: ${p.filePath}`);return(await import(`data:text/javascript;base64,${Buffer.from(await u.text()).toString("base64")}`)).default})(f))}catch(t){return console.error("[stx] API discovery failed:",t),Response.json({error:"API discovery failed; check the server log"},{status:500})}}}function Yo(s,c,o){if(qc(s))return!0;let i=/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/;if(i.test(m.basename(s)))return!0;try{if(i.test(m.basename(v.realpathSync(s))))return!0}catch{}if(R.has(m.resolve(s)))return!0;if(!o)return!1;let f=m.resolve(c,typeof o==="object"?o.dir??"server/api":"server/api"),t=(a)=>{try{return v.realpathSync(a)}catch{return m.resolve(a)}},e=t(s);return[f,m.resolve(c,"server"),m.resolve(c,".output/server")].some((a)=>{let p=t(a);return e===p||e.startsWith(`${p}${m.sep}`)})}
|
|
6
|
+
export{wn,Go,Xo,Jo,ty,Yo};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{R}from"./chunk-s29hp1qw.js";import{Re,Vt,se,B,Pn,ie,P}from"./chunk-a02gt4tz.js";import{Wi,lo,d,m,N,ht,p,uo,n,u,k}from"./chunk-295bykzd.js";import{wr}from"./chunk-twmkz0xs.js";import{fe}from"./chunk-d2pexm3z.js";import{Is}from"./chunk-cb0c6959.js";var he=1000,me=!1;function xe(t,r){let i=/@(include|partial)\s*\(\s*(['"])([^'"]+)\2\s*,\s*/g,e="",o=0,s;while((s=i.exec(t))!==null){let l=s.index+s[0].length,b=s.index+s[0].indexOf("("),x=k(t,"(",")",b);if(x===-1)continue;let f=t.slice(l,x).trim();if(!f)continue;if(!Object.keys(r).some((a)=>new RegExp(`(?:^|[^\\w$.])${a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w$])`).test(f)))continue;let h;try{let a=N(f,r);if(!a||typeof a!=="object")continue;h=JSON.stringify(a)}catch{continue}e+=t.slice(o,l)+h,o=x,i.lastIndex=x}return o===0?t:e+t.slice(o)}function be(t,r){let i=/@component\s*\(/g,e=t,o,s=[];while((o=i.exec(e))!==null){let l=o.index,b=l+o[0].length-1,x=1,f=b+1;while(f<e.length&&x>0){if(e[f]==="(")x++;else if(e[f]===")"){if(x--,x===0)break}f++}if(x!==0)continue;let c=e.substring(b+1,f),h=f+1,a=c.match(/^\s*['"]([^'"]+)['"]/);if(!a)continue;let y=a[1],g=c.slice(a[0].length),A=g.match(/^\s*,\s*/);if(!A)continue;let O=g.slice(A[0].length).trim();if(!O)continue;try{let S=N(O,r),W=JSON.stringify(S),I=`@component('${y}', ${W})`;s.push({start:l,end:h,replacement:I})}catch{continue}}for(let l=s.length-1;l>=0;l--){let{start:b,end:x,replacement:f}=s[l];e=e.substring(0,b)+f+e.substring(x)}return e}function oe(t,r,i){let e=t,o=new RegExp(`${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),s;while((s=o.exec(e))!==null){let l=s.index,b=l+s[0].length-1,x=1,f=b+1,c=null,h=!1;while(f<e.length&&x>0){let g=e[f];if(h){h=!1,f++;continue}if(g==="\\"&&c){h=!0,f++;continue}if(c){if(g===c)c=null;f++;continue}if(g==='"'||g==="'"||g==="`"){c=g,f++;continue}if(g==="(")x++;else if(g===")"){if(x--,x===0)break}f++}if(x!==0)break;let a=e.substring(b+1,f),y=i(a);e=e.substring(0,l)+y+e.substring(f+1)}return e}function ye(t,r){let i=t;return i=i.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(e,o)=>{if(o in r)return`:${o}="${o}"`;return e}),i=i.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(e,o,s)=>{try{if(B(s,r.__stx_client_signal_names||[]))return e;let l=Object.keys(r),b=Object.values(r);Wi(s);let x=!1,c=p(s,l,()=>{x=!0})(...b);if(x)return e;let h=JSON.stringify(c);if(h===void 0){if(!ht(s).some((g)=>!(g in r)))return"";return e}let a=Buffer.from(h,"utf8").toString("base64");return`__stx_${o}="${a}"`}catch(l){return e}}),i}var Q="<!--__STX_BREAK__-->",ee="<!--__STX_CONTINUE__-->";function ae(t,r){let i=/\{\{\{?|\{!!|@(break|continue)(?![\w$])/g,e="",o=0;for(let s=i.exec(t);s;s=i.exec(t)){if(!s[1]){let f=s[0].length===3&&s[0]==="{{{"?3:2,c=s[0]==="{!!"?t.indexOf("!!}",i.lastIndex):Re(t,s.index,f);if(c<0)break;i.lastIndex=c+(s[0]==="{!!"?3:f);continue}let l=i.lastIndex,b=!0,x=/^\s*\(/.exec(t.slice(l));if(x){let f=l+x[0].length-1,c=k(t,"(",")",f);if(c<0)break;l=c+1;try{let h=`!!(${t.slice(f+1,c).trim()})`;b=m(h)?Boolean(p(h,Object.keys(r))(...Object.values(r))):Boolean(d(h,r))}catch{b=!1}}if(e+=t.slice(o,s.index),b)return e+(s[1]==="break"?Q:ee);o=l,i.lastIndex=l}return e+t.slice(o)}function ue(t){let r=(o)=>o.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),i="",e=0;return Pn(t,(o,s,l)=>(i+=ce(r(t.slice(e,l))),i+=`\${__stxRenderLoopValue(${l}, (${s}), ${o.length})}`,e=l+o.length,o)),i+ce(r(t.slice(e)))}function ge(t,r,i,e){return ie(t,r,i==null?"":String(i),!1,e)}function ce(t){let r=t;return r=oe(r,"@break",(i)=>{let e=i.trim();if(!uo(e))return"";return`\`; if (${e}) { break; } result += \``}),r=oe(r,"@continue",(i)=>{let e=i.trim();if(!uo(e))return"";return`\`; if (${e}) { continue; } result += \``}),r=r.replace(/@break(?!\()/g,"`; break; result += `"),r=r.replace(/@continue(?!\()/g,"`; continue; result += `"),r}function Ee(t){let r=/@forelse\s*\(/g,i,e=[],o=/@foreach\s*\(/g,s=/@endforeach/g,l;while((l=o.exec(t))!==null)e.push({pos:l.index,delta:1});while((l=s.exec(t))!==null)e.push({pos:l.index,delta:-1});e.sort((c,h)=>c.pos-h.pos);let b=[],x=0;for(let c of e)x+=c.delta,b.push({pos:c.pos,depth:x});function f(c){let h=0,a=b.length-1,y=0;while(h<=a){let g=h+a>>1;if(b[g].pos<=c)y=b[g].depth,h=g+1;else a=g-1}return y}while((i=r.exec(t))!==null){if(f(i.index)>0)continue;let c=i.index,h=i.index+i[0].length-1,a=1,y=h+1,g=-1;while(y<t.length&&a>0){if(t[y]==="(")a++;else if(t[y]===")"){if(a--,a===0){g=y;break}}y++}if(g===-1)continue;let A=t.substring(h+1,g),O=Vt(A);if(!O)continue;let{arrayExpr:S,itemVar:W}=O,I=g+1,_=1,T=I,K=/@forelse\s*\(/g,C=/@endforelse/g,L=-1;while(_>0&&T<t.length){K.lastIndex=T,C.lastIndex=T;let F=K.exec(t),E=C.exec(t);if(!E)break;if(F&&F.index<E.index)_++,T=F.index+F[0].length;else{if(_--,_===0){L=E.index;break}T=E.index+11}}if(L===-1)continue;let w=t.substring(I,L),Z=L+11,z=-1,D=0,V=0;while(V<w.length){let F=w.indexOf("@",V);if(F===-1)break;let E=w.substring(F);if(/^@forelse\s*\(/.test(E))D++,V=F+1;else if(E.startsWith("@endforelse"))D--,V=F+11;else if(D===0&&E.startsWith("@empty")){if(w.length<=F+6||!/[a-z]/i.test(w[F+6])){z=F;break}V=F+1}else V=F+1}if(z===-1)continue;return{start:c,end:Z,arrayExpr:S,itemVar:W,foreachContent:w.substring(0,z),emptyContent:w.substring(z+6)}}return null}function le(t,r){let i=t;while(!0){let e=Ee(i);if(!e)break;let{start:o,end:s,arrayExpr:l,itemVar:b,foreachContent:x,emptyContent:f}=e;try{let c;if(m(l))c=p(l,Object.keys(r))(...Object.values(r));else c=d(l,r);let h;if(!Array.isArray(c)||c.length===0)h=f;else h=`@foreach (${l} as ${b})${x}@endforeach`;i=i.substring(0,o)+h+i.substring(s)}catch(c){let h=c instanceof Error?c.message:String(c),a=u("Forelse",`Error in @forelse(${l} as ${b}): ${h}`,n.EVALUATION_ERROR);i=i.substring(0,o)+a+i.substring(s)}}return i}var de="<!--stx:foreach-not-iterable:",_e=/<!--stx:foreach-not-iterable:([^|>]*)\|([^>]*?)-->/g;function $e(t,r){return`${de}${encodeURIComponent(t)}|${encodeURIComponent(r)}-->`}function Ae(t,r){console.warn(`[stx] @foreach(${t}) in ${r}: ${t} is not iterable server-side, so the loop rendered nothing. `+"Values a server loop reads must come from <script server> or the page context \u2014 "+"a plain <script> runs in the browser.")}function Es(t){if(!t.includes(de))return t;return t.replace(_e,(r,i,e)=>(Ae(decodeURIComponent(i),decodeURIComponent(e)),""))}function lg(t,r,i,e,o=!1){let s=ne(t,r,i,e,o),l=s.next();while(!l.done)l=s.next();return l.value}async function si(t,r,i,e,o=!1){let s=ne(t,r,i,e,o),l=s.next();while(!l.done)await R(),l=s.next();return l.value}function*ne(t,r,i,e,o=!1){let s=t,l=new Set(r.__stx_client_signal_names||[]);for(let c of wr(t))l.add(c);if(l.size)r={...r,__stx_client_signal_names:[...l]};s=le(s,r);function b(c){let h=/@foreach\s*\(/g,a;while((a=h.exec(c))!==null){let y=a.index,g=a.index+a[0].length-1,A=1,O=g+1,S=-1;while(O<c.length&&A>0){if(c[O]==="(")A++;else if(c[O]===")"){if(A--,A===0){S=O;break}}O++}if(S===-1)continue;let W=c.substring(g+1,S),I=Vt(W);if(!I)continue;let _=y,{arrayExpr:T,itemVar:K}=I,C=S+1,L=1,w=C,Z=/@foreach\s*\(/g,z=/@endforeach/g;while(L>0&&w<c.length){Z.lastIndex=w,z.lastIndex=w;let D=Z.exec(c),V=z.exec(c);if(!V)break;if(D&&D.index<V.index)L++,w=D.index+D[0].length;else{if(L--,L===0){let F=c.substring(C,V.index),E=V.index+11;return{start:_,end:E,arrayExpr:T,itemVar:K,content:F}}w=V.index+11}}}return null}function*x(c,h){let a=c;while(!0){let y=b(a);if(!y)break;let{start:g,end:A,arrayExpr:O,itemVar:S,content:W}=y;try{let I=O.trim(),_;if(m(I))_=p(I,Object.keys(h))(...Object.values(h));else _=d(I,h);let T=!1;if(!Array.isArray(_))if(_ instanceof Map)_=Array.from(_),T=!0;else if(_ instanceof Set)_=Array.from(_);else if(typeof _==="string")_=Array.from(_);else if(_&&typeof _==="object"&&!(_ instanceof Date)&&!(_ instanceof RegExp))_=Object.entries(_),T=!0;else{let E=$e(I,i)+u("Foreach",`Error in @foreach: ${I} is not iterable`,n.TYPE_ERROR);a=a.substring(0,g)+E+a.substring(A);continue}let K=e?.loops?.useAltLoopVariable??me,C=S.trim(),L=null,w,Z=!1;if(C.includes("=>")){let E=C.split("=>").map((j)=>j.trim());if(E.length===2&&E[0]&&E[1])L=E[0],w=E[1];else w=C}else if(!C.startsWith("[")&&!C.startsWith("{")&&C.includes(",")){let E=C.split(",").map((j)=>j.trim());if(E.length===2&&E[0]&&E[1])w=E[0],L=E[1],Z=!0;else w=C}else w=C;let z="",D=new Set(se(`${O} as ${S}`)),V=_,F=h[lo]??new WeakMap;for(let E=0;E<V.length;E++){if(E%16===0)yield;let j=V[E],te={index:E,iteration:E+1,first:E===0,last:E===V.length-1,count:V.length},M={...h,loop:te,$loop:te,[lo]:F};if(Array.isArray(h.__stx_client_signal_names))M.__stx_client_signal_names=h.__stx_client_signal_names.filter((H)=>!D.has(H));if(w.startsWith("[")&&w.endsWith("]")){let H=w.slice(1,-1).split(",").map((U)=>U.trim());if(Array.isArray(j))H.forEach((U,X)=>{if(U)M[U]=j[X]});else M[w]=j}else if(w.startsWith("{")&&w.endsWith("}")){let H=w.slice(1,-1).split(",").map((U)=>U.trim()).filter(Boolean);if(j!==null&&typeof j==="object")H.forEach((U)=>{let X=U.indexOf(":"),Y=(X===-1?U:U.slice(0,X)).trim(),re=X===-1?Y:U.slice(X+1).trim();if(Y&&re)M[re]=j[Y]});else M[w]=j}else M[w]=j;if(L)if(!Z&&T&&Array.isArray(j)&&j.length===2)M[L]=j[0],M[w]=j[1];else M[L]=E;let v=le(W,M);v=yield*ne(v,M,i,e,!0),v=fe(v,M,i),v=ae(v,M);let J=v.indexOf(Q),G=v.indexOf(ee),q=J<0?G:G<0?J:Math.min(J,G);if(q>=0)v=v.slice(0,q);if(v=P(v,M,i),v=ye(v,M),v=be(v,M),v=xe(v,M),z+=v,q>=0&&q===J)break}a=a.substring(0,g)+z+a.substring(A)}catch(I){let _=u("Foreach",`Error in @foreach(${O.trim()} as ${S.trim()}): ${I instanceof Error?I.message:String(I)}`,n.EVALUATION_ERROR);a=a.substring(0,g)+_+a.substring(A)}}return a}s=yield*x(s,r),s=we(s,r,i,e);let f=e?.loops?.maxWhileIterations??he;return s=Ie(s,r,f),o?s:Es(s)}function ug(t){let r=/^(\s*)([A-Za-z_$][\w$]*|\[[^\]]*\]|\{[^}]*\})(\s+(?:of|in)\s)/.exec(t);if(!r||/^(?:const|let|var)$/.test(r[2]))return t;return`${r[1]}let ${t.slice(r[1].length)}`}function pe(t){return uo(t)}function we(t,r,i,e){let o=t,s=!0;while(s){s=!1;let l=o.match(/@for\s*\(/);if(!l||l.index===void 0)break;let b=l.index,x=b+l[0].length-1,f=k(o,"(",")",x);if(f===-1)break;let c=ug(o.slice(x+1,f)),h=f+1,a=Is(o.slice(b),"for","endfor");if(a.length===0)break;let y=a[0].content,g=b+a[0].end;if(!pe(c)){let A=u("For",`Unsafe expression in @for: ${c}`,n.UNSAFE_EXPRESSION);o=o.substring(0,b)+A+o.substring(g),s=!0;continue}try{let A=Oe(c),O=/@(?:for|foreach|if|unless)\s*\(/.test(y);if(A.length>0&&O){let K=ke({forExpr:c,content:y,iterVarNames:A,context:r,filePath:i,options:e});o=o.substring(0,b)+K+o.substring(g),s=!0;continue}let S=Object.keys(r),W=Object.values(r),I=ue(y),T=Function(...S,"__stxRenderLoopValue",`
|
|
2
|
+
import{R}from"./chunk-s29hp1qw.js";import{Ae,Vt,se,B,Pn,ie,P}from"./chunk-000mwmfq.js";import{Wi,lo,d,m,N,ht,p,uo,n,u,k}from"./chunk-xw291tn7.js";import{wr}from"./chunk-mm1eg2pg.js";import{fe}from"./chunk-ah6nc29h.js";import{Is}from"./chunk-0hj5apb9.js";var he=1000,me=!1;function xe(t,r){let i=/@(include|partial)\s*\(\s*(['"])([^'"]+)\2\s*,\s*/g,e="",o=0,s;while((s=i.exec(t))!==null){let l=s.index+s[0].length,b=s.index+s[0].indexOf("("),x=k(t,"(",")",b);if(x===-1)continue;let f=t.slice(l,x).trim();if(!f)continue;if(!Object.keys(r).some((a)=>new RegExp(`(?:^|[^\\w$.])${a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w$])`).test(f)))continue;let h;try{let a=N(f,r);if(!a||typeof a!=="object")continue;h=JSON.stringify(a)}catch{continue}e+=t.slice(o,l)+h,o=x,i.lastIndex=x}return o===0?t:e+t.slice(o)}function be(t,r){let i=/@component\s*\(/g,e=t,o,s=[];while((o=i.exec(e))!==null){let l=o.index,b=l+o[0].length-1,x=1,f=b+1;while(f<e.length&&x>0){if(e[f]==="(")x++;else if(e[f]===")"){if(x--,x===0)break}f++}if(x!==0)continue;let c=e.substring(b+1,f),h=f+1,a=c.match(/^\s*['"]([^'"]+)['"]/);if(!a)continue;let y=a[1],g=c.slice(a[0].length),A=g.match(/^\s*,\s*/);if(!A)continue;let O=g.slice(A[0].length).trim();if(!O)continue;try{let S=N(O,r),W=JSON.stringify(S),I=`@component('${y}', ${W})`;s.push({start:l,end:h,replacement:I})}catch{continue}}for(let l=s.length-1;l>=0;l--){let{start:b,end:x,replacement:f}=s[l];e=e.substring(0,b)+f+e.substring(x)}return e}function oe(t,r,i){let e=t,o=new RegExp(`${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),s;while((s=o.exec(e))!==null){let l=s.index,b=l+s[0].length-1,x=1,f=b+1,c=null,h=!1;while(f<e.length&&x>0){let g=e[f];if(h){h=!1,f++;continue}if(g==="\\"&&c){h=!0,f++;continue}if(c){if(g===c)c=null;f++;continue}if(g==='"'||g==="'"||g==="`"){c=g,f++;continue}if(g==="(")x++;else if(g===")"){if(x--,x===0)break}f++}if(x!==0)break;let a=e.substring(b+1,f),y=i(a);e=e.substring(0,l)+y+e.substring(f+1)}return e}function ye(t,r){let i=t;return i=i.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(e,o)=>{if(o in r)return`:${o}="${o}"`;return e}),i=i.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(e,o,s)=>{try{if(B(s,r.__stx_client_signal_names||[]))return e;let l=Object.keys(r),b=Object.values(r);Wi(s);let x=!1,c=p(s,l,()=>{x=!0})(...b);if(x)return e;let h=JSON.stringify(c);if(h===void 0){if(!ht(s).some((g)=>!(g in r)))return"";return e}let a=Buffer.from(h,"utf8").toString("base64");return`__stx_${o}="${a}"`}catch(l){return e}}),i}var Q="<!--__STX_BREAK__-->",ee="<!--__STX_CONTINUE__-->";function ae(t,r){let i=/\{\{\{?|\{!!|@(break|continue)(?![\w$])/g,e="",o=0;for(let s=i.exec(t);s;s=i.exec(t)){if(!s[1]){let f=s[0].length===3&&s[0]==="{{{"?3:2,c=s[0]==="{!!"?t.indexOf("!!}",i.lastIndex):Ae(t,s.index,f);if(c<0)break;i.lastIndex=c+(s[0]==="{!!"?3:f);continue}let l=i.lastIndex,b=!0,x=/^\s*\(/.exec(t.slice(l));if(x){let f=l+x[0].length-1,c=k(t,"(",")",f);if(c<0)break;l=c+1;try{let h=`!!(${t.slice(f+1,c).trim()})`;b=m(h)?Boolean(p(h,Object.keys(r))(...Object.values(r))):Boolean(d(h,r))}catch{b=!1}}if(e+=t.slice(o,s.index),b)return e+(s[1]==="break"?Q:ee);o=l,i.lastIndex=l}return e+t.slice(o)}function ue(t){let r=(o)=>o.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),i="",e=0;return Pn(t,(o,s,l)=>(i+=ce(r(t.slice(e,l))),i+=`\${__stxRenderLoopValue(${l}, (${s}), ${o.length})}`,e=l+o.length,o)),i+ce(r(t.slice(e)))}function ge(t,r,i,e){return ie(t,r,i==null?"":String(i),!1,e)}function ce(t){let r=t;return r=oe(r,"@break",(i)=>{let e=i.trim();if(!uo(e))return"";return`\`; if (${e}) { break; } result += \``}),r=oe(r,"@continue",(i)=>{let e=i.trim();if(!uo(e))return"";return`\`; if (${e}) { continue; } result += \``}),r=r.replace(/@break(?!\()/g,"`; break; result += `"),r=r.replace(/@continue(?!\()/g,"`; continue; result += `"),r}function Ee(t){let r=/@forelse\s*\(/g,i,e=[],o=/@foreach\s*\(/g,s=/@endforeach/g,l;while((l=o.exec(t))!==null)e.push({pos:l.index,delta:1});while((l=s.exec(t))!==null)e.push({pos:l.index,delta:-1});e.sort((c,h)=>c.pos-h.pos);let b=[],x=0;for(let c of e)x+=c.delta,b.push({pos:c.pos,depth:x});function f(c){let h=0,a=b.length-1,y=0;while(h<=a){let g=h+a>>1;if(b[g].pos<=c)y=b[g].depth,h=g+1;else a=g-1}return y}while((i=r.exec(t))!==null){if(f(i.index)>0)continue;let c=i.index,h=i.index+i[0].length-1,a=1,y=h+1,g=-1;while(y<t.length&&a>0){if(t[y]==="(")a++;else if(t[y]===")"){if(a--,a===0){g=y;break}}y++}if(g===-1)continue;let A=t.substring(h+1,g),O=Vt(A);if(!O)continue;let{arrayExpr:S,itemVar:W}=O,I=g+1,_=1,T=I,K=/@forelse\s*\(/g,C=/@endforelse/g,L=-1;while(_>0&&T<t.length){K.lastIndex=T,C.lastIndex=T;let F=K.exec(t),E=C.exec(t);if(!E)break;if(F&&F.index<E.index)_++,T=F.index+F[0].length;else{if(_--,_===0){L=E.index;break}T=E.index+11}}if(L===-1)continue;let w=t.substring(I,L),Z=L+11,z=-1,D=0,V=0;while(V<w.length){let F=w.indexOf("@",V);if(F===-1)break;let E=w.substring(F);if(/^@forelse\s*\(/.test(E))D++,V=F+1;else if(E.startsWith("@endforelse"))D--,V=F+11;else if(D===0&&E.startsWith("@empty")){if(w.length<=F+6||!/[a-z]/i.test(w[F+6])){z=F;break}V=F+1}else V=F+1}if(z===-1)continue;return{start:c,end:Z,arrayExpr:S,itemVar:W,foreachContent:w.substring(0,z),emptyContent:w.substring(z+6)}}return null}function le(t,r){let i=t;while(!0){let e=Ee(i);if(!e)break;let{start:o,end:s,arrayExpr:l,itemVar:b,foreachContent:x,emptyContent:f}=e;try{let c;if(m(l))c=p(l,Object.keys(r))(...Object.values(r));else c=d(l,r);let h;if(!Array.isArray(c)||c.length===0)h=f;else h=`@foreach (${l} as ${b})${x}@endforeach`;i=i.substring(0,o)+h+i.substring(s)}catch(c){let h=c instanceof Error?c.message:String(c),a=u("Forelse",`Error in @forelse(${l} as ${b}): ${h}`,n.EVALUATION_ERROR);i=i.substring(0,o)+a+i.substring(s)}}return i}var de="<!--stx:foreach-not-iterable:",_e=/<!--stx:foreach-not-iterable:([^|>]*)\|([^>]*?)-->/g;function $e(t,r){return`${de}${encodeURIComponent(t)}|${encodeURIComponent(r)}-->`}function Re(t,r){console.warn(`[stx] @foreach(${t}) in ${r}: ${t} is not iterable server-side, so the loop rendered nothing. `+"Values a server loop reads must come from <script server> or the page context \u2014 "+"a plain <script> runs in the browser.")}function Es(t){if(!t.includes(de))return t;return t.replace(_e,(r,i,e)=>(Re(decodeURIComponent(i),decodeURIComponent(e)),""))}function ug(t,r,i,e,o=!1){let s=ne(t,r,i,e,o),l=s.next();while(!l.done)l=s.next();return l.value}async function si(t,r,i,e,o=!1){let s=ne(t,r,i,e,o),l=s.next();while(!l.done)await R(),l=s.next();return l.value}function*ne(t,r,i,e,o=!1){let s=t,l=new Set(r.__stx_client_signal_names||[]);for(let c of wr(t))l.add(c);if(l.size)r={...r,__stx_client_signal_names:[...l]};s=le(s,r);function b(c){let h=/@foreach\s*\(/g,a;while((a=h.exec(c))!==null){let y=a.index,g=a.index+a[0].length-1,A=1,O=g+1,S=-1;while(O<c.length&&A>0){if(c[O]==="(")A++;else if(c[O]===")"){if(A--,A===0){S=O;break}}O++}if(S===-1)continue;let W=c.substring(g+1,S),I=Vt(W);if(!I)continue;let _=y,{arrayExpr:T,itemVar:K}=I,C=S+1,L=1,w=C,Z=/@foreach\s*\(/g,z=/@endforeach/g;while(L>0&&w<c.length){Z.lastIndex=w,z.lastIndex=w;let D=Z.exec(c),V=z.exec(c);if(!V)break;if(D&&D.index<V.index)L++,w=D.index+D[0].length;else{if(L--,L===0){let F=c.substring(C,V.index),E=V.index+11;return{start:_,end:E,arrayExpr:T,itemVar:K,content:F}}w=V.index+11}}}return null}function*x(c,h){let a=c;while(!0){let y=b(a);if(!y)break;let{start:g,end:A,arrayExpr:O,itemVar:S,content:W}=y;try{let I=O.trim(),_;if(m(I))_=p(I,Object.keys(h))(...Object.values(h));else _=d(I,h);let T=!1;if(!Array.isArray(_))if(_ instanceof Map)_=Array.from(_),T=!0;else if(_ instanceof Set)_=Array.from(_);else if(typeof _==="string")_=Array.from(_);else if(_&&typeof _==="object"&&!(_ instanceof Date)&&!(_ instanceof RegExp))_=Object.entries(_),T=!0;else{let E=$e(I,i)+u("Foreach",`Error in @foreach: ${I} is not iterable`,n.TYPE_ERROR);a=a.substring(0,g)+E+a.substring(A);continue}let K=e?.loops?.useAltLoopVariable??me,C=S.trim(),L=null,w,Z=!1;if(C.includes("=>")){let E=C.split("=>").map((j)=>j.trim());if(E.length===2&&E[0]&&E[1])L=E[0],w=E[1];else w=C}else if(!C.startsWith("[")&&!C.startsWith("{")&&C.includes(",")){let E=C.split(",").map((j)=>j.trim());if(E.length===2&&E[0]&&E[1])w=E[0],L=E[1],Z=!0;else w=C}else w=C;let z="",D=new Set(se(`${O} as ${S}`)),V=_,F=h[lo]??new WeakMap;for(let E=0;E<V.length;E++){if(E%16===0)yield;let j=V[E],te={index:E,iteration:E+1,first:E===0,last:E===V.length-1,count:V.length},M={...h,loop:te,$loop:te,[lo]:F};if(Array.isArray(h.__stx_client_signal_names))M.__stx_client_signal_names=h.__stx_client_signal_names.filter((H)=>!D.has(H));if(w.startsWith("[")&&w.endsWith("]")){let H=w.slice(1,-1).split(",").map((U)=>U.trim());if(Array.isArray(j))H.forEach((U,X)=>{if(U)M[U]=j[X]});else M[w]=j}else if(w.startsWith("{")&&w.endsWith("}")){let H=w.slice(1,-1).split(",").map((U)=>U.trim()).filter(Boolean);if(j!==null&&typeof j==="object")H.forEach((U)=>{let X=U.indexOf(":"),Y=(X===-1?U:U.slice(0,X)).trim(),re=X===-1?Y:U.slice(X+1).trim();if(Y&&re)M[re]=j[Y]});else M[w]=j}else M[w]=j;if(L)if(!Z&&T&&Array.isArray(j)&&j.length===2)M[L]=j[0],M[w]=j[1];else M[L]=E;let v=le(W,M);v=yield*ne(v,M,i,e,!0),v=fe(v,M,i),v=ae(v,M);let J=v.indexOf(Q),G=v.indexOf(ee),q=J<0?G:G<0?J:Math.min(J,G);if(q>=0)v=v.slice(0,q);if(v=P(v,M,i),v=ye(v,M),v=be(v,M),v=xe(v,M),z+=v,q>=0&&q===J)break}a=a.substring(0,g)+z+a.substring(A)}catch(I){let _=u("Foreach",`Error in @foreach(${O.trim()} as ${S.trim()}): ${I instanceof Error?I.message:String(I)}`,n.EVALUATION_ERROR);a=a.substring(0,g)+_+a.substring(A)}}return a}s=yield*x(s,r),s=we(s,r,i,e);let f=e?.loops?.maxWhileIterations??he;return s=Ie(s,r,f),o?s:Es(s)}function dg(t){let r=/^(\s*)([A-Za-z_$][\w$]*|\[[^\]]*\]|\{[^}]*\})(\s+(?:of|in)\s)/.exec(t);if(!r||/^(?:const|let|var)$/.test(r[2]))return t;return`${r[1]}let ${t.slice(r[1].length)}`}function pe(t){return uo(t)}function we(t,r,i,e){let o=t,s=!0;while(s){s=!1;let l=o.match(/@for\s*\(/);if(!l||l.index===void 0)break;let b=l.index,x=b+l[0].length-1,f=k(o,"(",")",x);if(f===-1)break;let c=dg(o.slice(x+1,f)),h=f+1,a=Is(o.slice(b),"for","endfor");if(a.length===0)break;let y=a[0].content,g=b+a[0].end;if(!pe(c)){let A=u("For",`Unsafe expression in @for: ${c}`,n.UNSAFE_EXPRESSION);o=o.substring(0,b)+A+o.substring(g),s=!0;continue}try{let A=Oe(c),O=/@(?:for|foreach|if|unless)\s*\(/.test(y);if(A.length>0&&O){let K=ke({forExpr:c,content:y,iterVarNames:A,context:r,filePath:i,options:e});o=o.substring(0,b)+K+o.substring(g),s=!0;continue}let S=Object.keys(r),W=Object.values(r),I=ue(y),T=Function(...S,"__stxRenderLoopValue",`
|
|
3
3
|
let result = '';
|
|
4
4
|
for (${c}) {
|
|
5
5
|
result += \`${I}\`;
|
|
@@ -9,7 +9,7 @@ import{R}from"./chunk-s29hp1qw.js";import{Re,Vt,se,B,Pn,ie,P}from"./chunk-a02gt4
|
|
|
9
9
|
for (${r}) {
|
|
10
10
|
if (!__renderIteration([${e.join(", ")}])) break;
|
|
11
11
|
}
|
|
12
|
-
`)(...x,(a)=>{let y={...o};e.forEach((W,I)=>{y[W]=a[I]});let g=
|
|
12
|
+
`)(...x,(a)=>{let y={...o};e.forEach((W,I)=>{y[W]=a[I]});let g=ug(i,y,f,l,!0);g=fe(g,y,f),g=ae(g,y);let A=g.indexOf(Q),O=g.indexOf(ee),S=A<0?O:O<0?A:Math.min(A,O);if(S>=0)g=g.slice(0,S);return c+=P(g,y,f),S<0||S!==A}),c}function Ie(t,r,i){let e=t,o=!0;while(o){o=!1;let s=e.match(/@while\s*\(/);if(!s||s.index===void 0)break;let l=s.index,b=l+s[0].length-1,x=k(e,"(",")",b);if(x===-1)break;let f=e.slice(b+1,x),c=Is(e.slice(l),"while","endwhile");if(c.length===0)break;let h=c[0].content,a=l+c[0].end;if(!pe(f)){let y=u("While",`Unsafe expression in @while: ${f}`,n.UNSAFE_EXPRESSION);e=e.substring(0,l)+y+e.substring(a),o=!0;continue}try{let y=Object.keys(r),g=Object.values(r),A=ue(h),S=Function(...y,"__stxRenderLoopValue",`
|
|
13
13
|
let result = '';
|
|
14
14
|
let maxIterations = ${i}; // Configurable safety limit
|
|
15
15
|
let counter = 0;
|
|
@@ -22,4 +22,4 @@ import{R}from"./chunk-s29hp1qw.js";import{Re,Vt,se,B,Pn,ie,P}from"./chunk-a02gt4
|
|
|
22
22
|
}
|
|
23
23
|
return result;
|
|
24
24
|
`)(...g,(W,I,_)=>ge(h,W,I,_));e=e.substring(0,l)+S+e.substring(a),o=!0}catch(y){let g=u("While",`Error in @while(${f}): ${y instanceof Error?y.message:String(y)}`,n.EVALUATION_ERROR);e=e.substring(0,l)+g+e.substring(a),o=!0}}return e}
|
|
25
|
-
export{Es,
|
|
25
|
+
export{Es,ug,si,dg};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var w={black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",brightRed:"\x1B[91m",brightGreen:"\x1B[92m",brightYellow:"\x1B[93m",brightBlue:"\x1B[94m",brightMagenta:"\x1B[95m",brightCyan:"\x1B[96m",brightWhite:"\x1B[97m"},R={bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",inverse:"\x1B[7m",strikethrough:"\x1B[9m"};function p(e,t){return`${w[t]}${e}\x1B[0m`}function C(e,t){return`${R[t]}${e}\x1B[0m`}var b=(e)=>p(e,"red"),S=(e)=>p(e,"green"),y=(e)=>p(e,"yellow"),O=(e)=>p(e,"blue");var c=(e)=>p(e,"cyan");var a=(e)=>C(e,"bold"),m=(e)=>C(e,"dim");function tn(){console.log(""),console.log(c(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557")),console.log(c(" \u2551")+a(" \uD83D\uDCD6 STX Story ")+c("\u2551")),console.log(c(" \u2551")+m(" Component Showcase & Testing ")+c("\u2551")),console.log(c(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D")),console.log("")}function vo(e,t){if(console.log(a(" Server running at:")),console.log(""),console.log(` ${m("\u279C")} ${a("Local:")} ${c(e)}`),t)console.log(` ${m("\u279C")} ${a("Network:")} ${c(t)}`);console.log("")}function nn(e){let t=e>0?"\u2713":"\u25CB",r=e>0?S:y;console.log(` ${r(t)} Found ${a(String(e))} story ${e===1?"file":"files"}`)}function
|
|
3
|
-
export{tn,vo,nn,
|
|
2
|
+
var w={black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",brightRed:"\x1B[91m",brightGreen:"\x1B[92m",brightYellow:"\x1B[93m",brightBlue:"\x1B[94m",brightMagenta:"\x1B[95m",brightCyan:"\x1B[96m",brightWhite:"\x1B[97m"},R={bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",inverse:"\x1B[7m",strikethrough:"\x1B[9m"};function p(e,t){return`${w[t]}${e}\x1B[0m`}function C(e,t){return`${R[t]}${e}\x1B[0m`}var b=(e)=>p(e,"red"),S=(e)=>p(e,"green"),y=(e)=>p(e,"yellow"),O=(e)=>p(e,"blue");var c=(e)=>p(e,"cyan");var a=(e)=>C(e,"bold"),m=(e)=>C(e,"dim");function tn(){console.log(""),console.log(c(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557")),console.log(c(" \u2551")+a(" \uD83D\uDCD6 STX Story ")+c("\u2551")),console.log(c(" \u2551")+m(" Component Showcase & Testing ")+c("\u2551")),console.log(c(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D")),console.log("")}function vo(e,t){if(console.log(a(" Server running at:")),console.log(""),console.log(` ${m("\u279C")} ${a("Local:")} ${c(e)}`),t)console.log(` ${m("\u279C")} ${a("Network:")} ${c(t)}`);console.log("")}function nn(e){let t=e>0?"\u2713":"\u25CB",r=e>0?S:y;console.log(` ${r(t)} Found ${a(String(e))} story ${e===1?"file":"files"}`)}function ma(e,t){if(console.log(""),console.log(` ${b("\u2717")} ${a(b("Error:"))} ${e}`),t)console.log(` ${m(t)}`);console.log("")}function vt(e){console.log(` ${y("\u26A0")} ${y("Warning:")} ${e}`)}function ha(e){console.log(` ${O("\u2139")} ${e}`)}function ya(e,t,r){console.log(""),console.log(c(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557")),console.log(c(" \u2551")+a(" Build Complete ")+c("\u2551")),console.log(c(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D")),console.log(""),console.log(` ${S("\u2713")} Stories: ${a(String(e))}`),console.log(` ${S("\u2713")} Output: ${a(t)}`),console.log(` ${S("\u2713")} Time: ${a(`${r}ms`)}`),console.log("")}function xo(){console.log(""),console.log(a(" Keyboard Shortcuts:")),console.log(""),console.log(` ${c("h")} Show this help`),console.log(` ${c("o")} Open in browser`),console.log(` ${c("r")} Restart server`),console.log(` ${c("c")} Clear console`),console.log(` ${c("q")} Quit`),console.log("")}import h from"fs";import d from"path";async function rn(e){let{root:t,config:r}=e,o=[],i=await P(t,r.storyMatch,r.storyIgnored);for(let s of i){let n=d.resolve(t,s),l=v(s,n);o.push(l)}return o}async function P(e,t,r){let o=[];async function i(s,n){let l=await h.promises.readdir(s,{withFileTypes:!0});for(let g of l){let f=d.join(s,g.name),u=d.relative(n,f);if(T(u,r))continue;if(g.isDirectory())await i(f,n);else if(g.isFile()){if(F(u,t))o.push(u)}}}return await i(e,e),o}function T(e,t){for(let r of t)if(E(e,r))return!0;return!1}function F(e,t){for(let r of t)if(E(e,r))return!0;return!1}function E(e,t){let r=e.replace(/\\/g,"/"),i=t.replace(/\\/g,"/").replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"{{GLOBSTAR}}").replace(/\*/g,"[^/]*").replace(/\?/g,".").replace(/\{\{GLOBSTAR\}\}/g,".*");return i=`^${i}$`,new RegExp(i).test(r)}function v(e,t){let r=d.basename(e,".story.stx");return{id:e.toLowerCase().replace(/\.story\.stx$/,"").replace(/[/\\]/g,"-").replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),path:t,relativePath:e,fileName:r,treeFile:{title:r,path:e}}}function ba(e,t){let{root:r,config:o}=e,i=[],s=h.watch(r,{recursive:!0},async(n,l)=>{if(!l)return;let g=l.replace(/\\/g,"/");if(!F(g,o.storyMatch))return;if(T(g,o.storyIgnored))return;let f=d.resolve(r,g);try{await h.promises.access(f);let u=v(g,f);t(n==="rename"?"add":"change",u)}catch{let u=v(g,f);t("unlink",u)}});return i.push(s),()=>{for(let n of i)n.close()}}function N(e,t){let r=t.treeFile||{title:t.fileName,path:t.relativePath};if(e.tree.file==="title")return r.title.split("/");if(e.tree.file==="path")return[...t.relativePath.split("/").slice(0,-1),r.title];if(typeof e.tree.file==="function")return e.tree.file(r);return[r.title]}function sn(e,t){for(let n of t)n.treePath=N(e,n);let r=(e.tree.groups||[]).map((n)=>({groupConfig:{id:n.id||n.title,title:n.title,include:n.include},treeObject:{}})),o={treeObject:{}};r.push(o);for(let n=0;n<t.length;n++){let l=t[n],g=j(l,r,o);k(l.treePath,n,g.treeObject)}let i=e.tree.order==="asc"?(n,l)=>n.localeCompare(l):e.tree.order,s=[];for(let n of r)if(n===o)s.push(...x(n.treeObject,i));else if(n.groupConfig&&Object.keys(n.treeObject).length>0)s.push({group:!0,id:n.groupConfig.id,title:n.groupConfig.title,children:x(n.treeObject,i)});return s}function j(e,t,r){let o=e.treeFile||{title:e.fileName,path:e.relativePath};for(let i of t)if(i.groupConfig?.include&&i.groupConfig.include(o))return i;return r}function k(e,t,r){let o=r;for(let i=0;i<e.length;i++){let s=e[i];if(i===e.length-1)if(o[s]!==void 0){let l=1;while(o[`${s}-${l}`]!==void 0)l++;o[`${s}-${l}`]=t}else o[s]=t;else{if(o[s]===void 0)o[s]={};else if(typeof o[s]==="number"){let l=o[s];o[s]={"":l}}o=o[s]}}}function x(e,t){let r=[];for(let[o,i]of Object.entries(e))if(typeof i==="number")r.push({title:o,index:i});else r.push({title:o,children:x(i,t)});return r.sort((o,i)=>t(o.title,i.title)),r}
|
|
3
|
+
export{tn,vo,nn,ma,vt,ha,ya,xo,rn,ba,sn};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Nn,F}from"./chunk-6t04tqvh.js";import m from"fs";import e from"path";async function On(r,o,i){if(r.__stx_runtime_config)return;let n=Nn();if(n||i){r.__stx_runtime_config=n??F(i);return}let t=e.dirname(e.resolve(o));while(!0){if(["stx.config.ts","stx.config.js",".config/stx.config.ts",".config/stx.config.js"].some((f)=>m.existsSync(e.join(t,f)))){let{loadStxConfig:f}=await import("./chunk-
|
|
2
|
+
import{Nn,F}from"./chunk-6t04tqvh.js";import m from"fs";import e from"path";async function On(r,o,i){if(r.__stx_runtime_config)return;let n=Nn();if(n||i){r.__stx_runtime_config=n??F(i);return}let t=e.dirname(e.resolve(o));while(!0){if(["stx.config.ts","stx.config.js",".config/stx.config.ts",".config/stx.config.js"].some((f)=>m.existsSync(e.join(t,f)))){let{loadStxConfig:f}=await import("./chunk-3zyzhcd9.js"),c=await f(t);if(c.runtimeConfig)r.__stx_runtime_config=F(c.runtimeConfig);return}let s=e.dirname(t);if(s===t)return;t=s}}async function Vi(r,o){function i(n){if(n===null)return"null";if(Array.isArray(n))return`Array<${n.length?[...new Set(n.map(i))].join(" | "):"unknown"}>`;if(typeof n==="object")return`{ ${Object.entries(n).map(([t,s])=>`readonly ${JSON.stringify(t)}: ${i(s)}`).join("; ")} }`;return typeof n}await Bun.write(e.join(r,".stx/runtime-config.d.ts"),`import '@stacksjs/stx/runtime-config'
|
|
3
3
|
declare module '@stacksjs/stx/runtime-config' { interface PublicRuntimeConfig ${i(o.public??{})} }
|
|
4
4
|
`),await Bun.write(e.join(r,".stx/runtime-config-server.d.ts"),`import '@stacksjs/stx/runtime-config-server'
|
|
5
5
|
declare module '@stacksjs/stx/runtime-config-server' { interface PrivateRuntimeConfig ${i(o.private??{})} }
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Er}from"./chunk-
|
|
2
|
+
import{Er}from"./chunk-b8528fra.js";import{Fr}from"./chunk-xw291tn7.js";import{a}from"./chunk-zje94z0k.js";import{U,ct}from"./chunk-care745q.js";import{Dc}from"./chunk-mbm3ma63.js";import{D,c}from"./chunk-b0jekg4c.js";var x=/<style\b[^>]*>/iy,R=/<\/style>/gi,b=/<script\b[^>]*>/iy,S=/<template(?=[\s>/])[^>]*>/iy,w=/<\/template\s*>/iy;function vr(e){let r=0,t=0,s=-1;while(r<e.length){let n=e.indexOf("<",r);if(n===-1)return-1;if(e.startsWith("<!--",n)){let g=e.indexOf("-->",n+4);r=g===-1?e.length:g+3;continue}x.lastIndex=n;let u=x.exec(e);if(u){R.lastIndex=n+u[0].length;let g=R.exec(e);r=g===null?e.length:g.index+8;continue}S.lastIndex=n;let o=S.exec(e);if(o){if(t===0)s=n;t++,r=n+o[0].length;continue}w.lastIndex=n;let d=w.exec(e);if(d){if(t>0)t--;r=n+d[0].length;continue}if(b.lastIndex=n,b.test(e))return t>0?s:n;r=n+1}return-1}function ne(e,r={}){return new Er(e,r).routes}import y from"path";var T=new Map;async function h(e,r){let t=e,s=r;if(!t||!s)try{let d=await a();t||=d?.pagesDir||"pages",s||=d?.root||"."}catch{t||="pages",s||="."}let n=y.isAbsolute(t)?t:y.join(s,t),u=T.get(n);if(u)return u;let o=[];try{o=ne(".",{pagesDir:n,emit:!1}).map((d)=>d.regex.source).filter(Boolean)}catch{o=[]}return T.set(n,o),o}function E(e){return e.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function l(e){return E(JSON.stringify(e))}function $e(e){return e.includes("data-stx-runtime")}function Nc(e){let r=/window\.stx\s*\.\s*[A-Za-z_$]|\}\s*=\s*window\.stx\s*;/g;for(let t=r.exec(e);t!==null;t=r.exec(e)){let s=e.slice(Math.max(0,t.index-80),t.index);if(/if\s*\(\s*window\.stx\s*\)|window\.stx\s*&&/.test(s))continue;return!0}return!1}function p(e,r){let t=vr(e),s=e.search(/<!doctype\b/i);if(t!==-1&&(s===-1||t>s))return e.slice(0,t)+r+`
|
|
3
3
|
`+e.slice(t);let n=Fr(e);if(n!==null)return`${e.slice(0,n)}
|
|
4
4
|
${r}${e.slice(n)}`;if(e.includes("</head>")){let o=D(e);return e.slice(0,o)+r+`
|
|
5
5
|
`+e.slice(o)}if(U(e))return ct(e,(o)=>`${o}
|
|
6
6
|
${r}`);return`${r}
|
|
7
|
-
${e}`}async function xr(e,r){if(e.includes("data-stx-runtime")||e.includes("window.stx.state")||e.includes("STX Signals Runtime"))return e;if(r.buildMode==="serve"){let{getServeClientAsset:n}=await import("./chunk-
|
|
7
|
+
${e}`}async function xr(e,r){if(e.includes("data-stx-runtime")||e.includes("window.stx.state")||e.includes("STX Signals Runtime"))return e;if(r.buildMode==="serve"){let{getServeClientAsset:n}=await import("./chunk-kz3mejc4.js"),{url:u}=await n("runtime",r.debug===!0);return p(e,`<script data-stx-runtime src="${u}"></script>`)}if(r.buildMode==="compile")return p(e,'<script data-stx-runtime src="/__stx/runtime.__STX_HASH__.js"></script>');let{getCachedSignalsRuntime:t}=await import("./chunk-kz3mejc4.js"),s=await t(r.debug);return p(e,`<script data-stx-scoped data-stx-runtime>${s}</script>`)}function O(e){return/<[a-z][^>]*?\sx-tooltip\s*=/i.test(e)}function Mc(e){if(e.includes("data-stx-tooltip-runtime")||!O(e))return e;let r=`<script data-stx-scoped data-stx-tooltip-runtime>${Dc()}</script>`,t=c(e);if(t===-1)return`${e}
|
|
8
8
|
${r}`;return`${e.slice(0,t)}${r}
|
|
9
|
-
${e.slice(t)}`}var C=/<script\b[^>]*\sdata-stx-router(?=[\s=>])/i;function M(e){return C.test(e)||e.includes("__stxRouter)return")||e.includes("__stxRouter=true")}async function
|
|
9
|
+
${e.slice(t)}`}var C=/<script\b[^>]*\sdata-stx-router(?=[\s=>])/i;function M(e){return C.test(e)||e.includes("__stxRouter)return")||e.includes("__stxRouter=true")}async function Re(e,r){if(!e.includes("</body>"))return e;if(M(e))return e;let t=r?.router,s="",n="";{let i={};if(t){if(t.container)i.container=t.container;if(t.interceptAllLinks!==void 0)i.interceptAllLinks=t.interceptAllLinks;if(t.progress!==void 0)i.progress=t.progress;if(t.viewTransitions!==void 0)i.viewTransitions=t.viewTransitions;if(t.viewTransitionDuration!==void 0)i.viewTransitionDuration=t.viewTransitionDuration;if(t.viewTransitionEasing!==void 0)i.viewTransitionEasing=t.viewTransitionEasing;if(t.scrollToTop!==void 0)i.scrollToTop=t.scrollToTop;if(t.scrollRestoration!==void 0)i.scrollRestoration=t.scrollRestoration;if(t.prefetch!==void 0)i.prefetch=t.prefetch;if(t.cache!==void 0)i.cache=t.cache;if(t.progressColor!==void 0)i.progressColor=t.progressColor;if(t.progressHeight!==void 0)i.progressHeight=t.progressHeight;if(t.prefetchVisible!==void 0)i.prefetchVisible=t.prefetchVisible;if(t.prefetchVisibleMax!==void 0)i.prefetchVisibleMax=t.prefetchVisibleMax;if(t.prefetchBudgetBytes!==void 0)i.prefetchBudgetBytes=t.prefetchBudgetBytes;if(t.keepOpening!==void 0)i.keepOpening=t.keepOpening}try{let f=await h(r?.pagesDir,r?.root);if(f.length>0)if(r?.buildMode==="serve"){let{registerServeModuleBundle:_}=await import("./chunk-kz3mejc4.js");n=`<script data-stx-owned-routes src="${_(`(window.__stxRouterConfig=window.__stxRouterConfig||{}).ownedRoutes=${l(f)};
|
|
10
10
|
`)}"></script>
|
|
11
11
|
`}else i.ownedRoutes=f}catch{}if(Object.keys(i).length>0)s=`<script>window.__stxRouterConfig=${l(i)};</script>
|
|
12
|
-
`}let{getCachedRouterScript:u,getServeClientAsset:o}=await import("./chunk-
|
|
12
|
+
`}let{getCachedRouterScript:u,getServeClientAsset:o}=await import("./chunk-kz3mejc4.js"),d=r?.buildMode==="compile"?'<script data-stx-router src="/__stx/router.__STX_HASH__.js"></script>':r?.buildMode==="serve"?`<script data-stx-router src="${(await o("router")).url}"></script>`:`<script data-stx-router>${await u()}</script>`,g=c(e);return e.slice(0,g)+s+n+d+`
|
|
13
13
|
</body>`+e.slice(g+7)}
|
|
14
|
-
export{vr,ne,
|
|
14
|
+
export{vr,ne,$e,Nc,xr,Mc,Re};
|