@stacksjs/stx 0.2.917 → 0.2.919
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/app-shell.js +3 -2
- package/dist/{chunk-frpsrv1e.js → chunk-09xqy448.js} +2 -2
- package/dist/chunk-0ebaf0pr.js +2 -0
- package/dist/chunk-0jjq552g.js +2 -0
- package/dist/chunk-0wctbtad.js +7 -0
- package/dist/{chunk-r7y1196g.js → chunk-0xyfs691.js} +4 -4
- package/dist/{chunk-w98yt4d4.js → chunk-14df2jzs.js} +2 -2
- package/dist/chunk-15rc8t28.js +2 -0
- package/dist/chunk-1a2c4pv8.js +54 -0
- package/dist/{chunk-ezqfrea9.js → chunk-1baxccfq.js} +18 -18
- package/dist/{chunk-0vyytd9v.js → chunk-1bf0grbf.js} +3 -3
- package/dist/chunk-1jrhjn2b.js +2 -0
- package/dist/chunk-1svffhzq.js +2 -0
- package/dist/{chunk-1hx6dyy9.js → chunk-1ts1pg90.js} +2 -2
- package/dist/{chunk-88fx8xc1.js → chunk-1vsjmwr1.js} +2 -2
- package/dist/{chunk-cxsc37fg.js → chunk-2f46pcg0.js} +2 -2
- package/dist/{chunk-ma5ptt4m.js → chunk-2jm7map2.js} +2 -2
- package/dist/chunk-2m4ydym0.js +33 -0
- package/dist/chunk-2mv29s6w.js +9 -0
- package/dist/{chunk-h0aw9hmc.js → chunk-2szhk8mh.js} +5 -5
- package/dist/{chunk-gg715pj6.js → chunk-2zb642qr.js} +6 -6
- package/dist/chunk-3aayrnbh.js +21 -0
- package/dist/chunk-3br07y64.js +20 -0
- package/dist/{chunk-2f5jjxcj.js → chunk-3efpqm1f.js} +2 -2
- package/dist/{chunk-fn1reean.js → chunk-3ftrv1f7.js} +7 -7
- package/dist/{chunk-yq2krsc9.js → chunk-3hfv217t.js} +6 -6
- package/dist/{chunk-eptzpvn0.js → chunk-3kpxkjgm.js} +3 -3
- package/dist/{chunk-mf5cqv1k.js → chunk-3tcy9r6r.js} +27 -27
- package/dist/{chunk-zv3rn0ch.js → chunk-40j2pmnb.js} +6 -6
- package/dist/chunk-426gq0g5.js +2 -0
- package/dist/chunk-4ge80k8j.js +2 -0
- package/dist/chunk-4vdfqr64.js +2 -0
- package/dist/chunk-4yz33vzb.js +2 -0
- package/dist/chunk-4zcswx6x.js +2 -0
- package/dist/{chunk-w6ydg43d.js → chunk-50zzar2c.js} +3 -3
- package/dist/{chunk-vayzmvf5.js → chunk-514yg4dr.js} +6 -6
- package/dist/{chunk-388xpdw5.js → chunk-5fdc8pej.js} +73 -33
- package/dist/chunk-5ht628zp.js +2 -0
- package/dist/chunk-67zy5p7x.js +2 -0
- package/dist/chunk-6bm7t0hm.js +3 -0
- package/dist/{chunk-wj9bqkc0.js → chunk-6n6kndk0.js} +1 -1
- package/dist/chunk-6x5a2w5a.js +3 -0
- package/dist/{chunk-xc5esqcb.js → chunk-6ybq9pfh.js} +2 -2
- package/dist/{chunk-23x3k751.js → chunk-7axtwg1f.js} +2 -2
- package/dist/chunk-8153bfpx.js +2 -0
- package/dist/{chunk-16sfjkc4.js → chunk-858p3hkz.js} +2 -2
- package/dist/chunk-86p0m920.js +2 -0
- package/dist/chunk-88texeh4.js +2 -0
- package/dist/chunk-8mye65n9.js +2 -0
- package/dist/chunk-8ycgk8w6.js +2 -0
- package/dist/{chunk-npj20tj9.js → chunk-9707zz6v.js} +2 -2
- package/dist/{chunk-pyyda92j.js → chunk-9gr7m3tb.js} +1 -1
- package/dist/{chunk-952dfmcb.js → chunk-9mack1g8.js} +3 -3
- package/dist/chunk-9xcsn4pb.js +2 -0
- package/dist/{chunk-3jc6yb02.js → chunk-9zwmfkfg.js} +9 -9
- package/dist/chunk-a5tg553d.js +2 -0
- package/dist/chunk-agxxqjjt.js +2 -0
- package/dist/{chunk-phzhmnnm.js → chunk-ayrd026n.js} +3 -3
- package/dist/chunk-b44pvac7.js +2 -0
- package/dist/chunk-b4yp16a2.js +2 -0
- package/dist/{chunk-95j8660f.js → chunk-cbqe84g3.js} +2 -2
- package/dist/{chunk-qsexsrw2.js → chunk-d4xjwebv.js} +5 -5
- package/dist/{chunk-0v7555tr.js → chunk-d69k67bn.js} +11 -11
- package/dist/chunk-ex6dne7e.js +3 -0
- package/dist/chunk-fb63xppz.js +2 -0
- package/dist/chunk-ffqqkeye.js +2 -0
- package/dist/chunk-fjpt8arw.js +3 -0
- package/dist/{chunk-mgj074y2.js → chunk-fn0y9z1t.js} +5 -5
- package/dist/{chunk-ar6jeqmm.js → chunk-ft34x0h1.js} +4 -4
- package/dist/{chunk-t65f98qv.js → chunk-fwxgzktt.js} +2 -2
- package/dist/chunk-g1v12bjm.js +2 -0
- package/dist/chunk-gg0kkn2e.js +2 -0
- package/dist/chunk-ggg8b8n1.js +2 -0
- package/dist/chunk-ggrcg7k7.js +2 -0
- package/dist/{chunk-11c7xg1z.js → chunk-gjyz5ma7.js} +1 -1
- package/dist/chunk-gmn9ba8f.js +3 -0
- package/dist/chunk-gqe574d9.js +2 -0
- package/dist/chunk-h4nqjks2.js +2 -0
- package/dist/chunk-hajamm16.js +2 -0
- package/dist/chunk-hg2n2264.js +2 -0
- package/dist/{chunk-wm24jx3t.js → chunk-hht7n4zd.js} +2 -2
- package/dist/chunk-hxabvt31.js +2 -0
- package/dist/chunk-j3sat6vn.js +2 -0
- package/dist/chunk-j9gbnqxq.js +2 -0
- package/dist/{chunk-1hbf5e1h.js → chunk-jgtn9t5n.js} +2 -2
- package/dist/chunk-jj2z4nxa.js +2 -0
- package/dist/{chunk-0jdz31q1.js → chunk-jjq7c8s2.js} +3 -3
- package/dist/chunk-k289127j.js +2 -0
- package/dist/{chunk-p3fepzt9.js → chunk-kk9h53xg.js} +3 -3
- package/dist/{chunk-xnp031ba.js → chunk-ktv65e3n.js} +7 -7
- package/dist/chunk-m1hfh2t4.js +2 -0
- package/dist/{chunk-ngqb22wj.js → chunk-m390z8w8.js} +9 -9
- package/dist/chunk-m3qwqhxp.js +2 -0
- package/dist/{chunk-da05660m.js → chunk-m6hrb7rm.js} +58 -58
- package/dist/{chunk-789yp1tg.js → chunk-m86sjbx7.js} +3 -3
- package/dist/chunk-m9smh7fs.js +2 -0
- package/dist/{chunk-1jvt9t3r.js → chunk-m9ta0640.js} +2 -2
- package/dist/chunk-mhnjtc42.js +2 -0
- package/dist/{chunk-hhspwfva.js → chunk-mn9t5fnv.js} +2 -2
- package/dist/{chunk-36cz2v8k.js → chunk-mnpfvxpa.js} +31 -31
- package/dist/{chunk-2vx2ben8.js → chunk-mr9pp5cf.js} +2 -2
- package/dist/{chunk-1jxkc6d0.js → chunk-mztjpp7m.js} +2 -2
- package/dist/chunk-n4bxb2hx.js +2 -0
- package/dist/chunk-n958bxm6.js +2 -0
- package/dist/{chunk-8wqhzzkn.js → chunk-neymp1bb.js} +3 -3
- package/dist/chunk-nkbnsbb0.js +3 -0
- package/dist/chunk-nkr1aa5z.js +2 -0
- package/dist/{chunk-nhyv3w4r.js → chunk-p0xqm2ne.js} +1 -1
- package/dist/chunk-p3vswt0f.js +2 -0
- package/dist/{chunk-z110bf2c.js → chunk-p3x7kwb5.js} +7 -7
- package/dist/chunk-p4twxjfs.js +6 -0
- package/dist/chunk-p8wnp4p1.js +2 -0
- package/dist/{chunk-bvqgq18r.js → chunk-p97h91zx.js} +2 -2
- package/dist/chunk-pjv4dskp.js +2 -0
- package/dist/{chunk-5jc9hmwg.js → chunk-pwg544dw.js} +2 -2
- package/dist/chunk-pxvp0cc9.js +3 -0
- package/dist/chunk-q3z252d9.js +2 -0
- package/dist/{chunk-p3x84jj0.js → chunk-qda8tmk9.js} +2 -2
- package/dist/chunk-qfkak3jb.js +2 -0
- package/dist/chunk-qnytvyy0.js +2 -0
- package/dist/{chunk-fznjm7qt.js → chunk-qsnw0qyp.js} +2 -2
- package/dist/{chunk-ftvpz1j4.js → chunk-qtzfbv7e.js} +5 -5
- package/dist/{chunk-dwt2drzf.js → chunk-qzqqzraq.js} +8 -8
- package/dist/{chunk-v78hjbz0.js → chunk-rk16391e.js} +3 -3
- package/dist/chunk-rt7xy537.js +2 -0
- package/dist/chunk-rwjye578.js +2 -0
- package/dist/{chunk-cwcmmgvz.js → chunk-s1x2pc9b.js} +2 -2
- package/dist/{chunk-n4m50dpk.js → chunk-sbr3wg75.js} +65 -65
- package/dist/chunk-sftznswb.js +2 -0
- package/dist/{chunk-cq4cwfqf.js → chunk-sxrcac01.js} +2 -2
- package/dist/{chunk-fzcqw147.js → chunk-tb4be5ct.js} +3 -3
- package/dist/{chunk-m8n14s3z.js → chunk-tnbzg7fd.js} +2 -2
- package/dist/{chunk-jr2r2nh5.js → chunk-txk2z7v0.js} +4 -4
- package/dist/chunk-tz5ktd6d.js +2 -0
- package/dist/{chunk-302nw40c.js → chunk-v060015m.js} +1 -1
- package/dist/chunk-v1a5h1tc.js +38 -0
- package/dist/{chunk-8b8az19t.js → chunk-v1x96kjr.js} +8 -8
- package/dist/chunk-vb609vbj.js +1323 -0
- package/dist/chunk-vf7tpgqz.js +70 -0
- package/dist/chunk-vtcyber4.js +2 -0
- package/dist/chunk-vtj3dwhh.js +4 -0
- package/dist/{chunk-bm6y085n.js → chunk-whnzf9hn.js} +5 -5
- package/dist/chunk-wq2bpt0w.js +2 -0
- package/dist/{chunk-sdmq09jw.js → chunk-wv0wsavj.js} +2 -2
- package/dist/chunk-wv8zt78c.js +2 -0
- package/dist/{chunk-nwef47nx.js → chunk-wxqay5c2.js} +1 -1
- package/dist/{chunk-gfp39bzr.js → chunk-x40j67z1.js} +2 -2
- package/dist/chunk-xakqpa4z.js +3 -0
- package/dist/{chunk-0asdv3hk.js → chunk-xap1f1bw.js} +2 -2
- package/dist/{chunk-ywrpmyzj.js → chunk-xk7hdpq5.js} +3 -3
- package/dist/{chunk-zkwkhesc.js → chunk-xmy75h5v.js} +2 -2
- package/dist/{chunk-0sj79ha5.js → chunk-xpsg91dh.js} +5 -5
- package/dist/{chunk-va4xam1q.js → chunk-xq5s4vc1.js} +1 -1
- package/dist/chunk-xy3ex6ht.js +2 -0
- package/dist/chunk-y899wtm8.js +2 -0
- package/dist/chunk-ye45znz5.js +2 -0
- package/dist/chunk-yegp50jb.js +2 -0
- package/dist/chunk-yq9aqpk8.js +2 -0
- package/dist/{chunk-f0sxbgbm.js → chunk-yvaqgdv1.js} +2 -2
- package/dist/{chunk-c13dv3wm.js → chunk-yye2pec5.js} +14 -14
- package/dist/{chunk-mt5ewkbg.js → chunk-yzqb7y45.js} +6 -6
- package/dist/{chunk-91p8p2cc.js → chunk-z6nyyt3n.js} +6 -6
- package/dist/{chunk-fs43342z.js → chunk-zaj3nnvv.js} +2 -2
- package/dist/{chunk-2qk2ppgm.js → chunk-zb6my502.js} +1 -1
- package/dist/{chunk-ra2tzsvz.js → chunk-zrxvj3zf.js} +5 -5
- package/dist/chunk-zt45dqfx.js +2 -0
- package/dist/cli.js +38 -38
- package/dist/color-mode-boot.d.ts +1 -8
- package/dist/color-mode-boot.js +46 -2
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/document-shell.d.ts +2 -0
- package/dist/document-shell.js +15 -3
- package/dist/document-tags.d.ts +2 -0
- package/dist/document-tags.js +9 -0
- package/dist/head-injection.d.ts +2 -0
- package/dist/head-injection.js +1 -0
- package/dist/head.d.ts +2 -0
- package/dist/head.js +2 -2
- package/dist/native/compiler/html-to-ir.js +1 -0
- package/dist/native/compiler/ir.d.ts +1 -0
- package/dist/native/components/primitives.d.ts +1 -0
- package/dist/native/event-names.js +2 -0
- package/dist/native/runtime/browser-renderer.d.ts +1 -0
- package/dist/native/runtime/browser-renderer.js +23 -6
- package/dist/native/testing.d.ts +1 -0
- package/dist/native/testing.js +33 -0
- package/dist/page-head.js +1 -9
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +13 -13
- package/dist/types/config-types.d.ts +1 -1
- package/dist/variable-extractor.js +6 -1
- package/package.json +5 -5
- package/dist/chunk-0adc8x2h.js +0 -9
- package/dist/chunk-0atz8fjx.js +0 -20
- package/dist/chunk-0fm6avxt.js +0 -3
- package/dist/chunk-11rnqey0.js +0 -2
- package/dist/chunk-1mx3j280.js +0 -2
- package/dist/chunk-20hy5p3p.js +0 -2
- package/dist/chunk-29v3b5ks.js +0 -2
- package/dist/chunk-2cay3heb.js +0 -2
- package/dist/chunk-31yx4sjh.js +0 -2
- package/dist/chunk-33fnbw33.js +0 -2
- package/dist/chunk-357qjcj1.js +0 -3
- package/dist/chunk-38kerh2r.js +0 -2
- package/dist/chunk-38y11q8x.js +0 -2
- package/dist/chunk-3h4db9yb.js +0 -33
- package/dist/chunk-3q80f7mt.js +0 -2
- package/dist/chunk-43kz6rx9.js +0 -2
- package/dist/chunk-43sgpy4e.js +0 -54
- package/dist/chunk-4e18r89n.js +0 -3
- package/dist/chunk-4pve3r5a.js +0 -2
- package/dist/chunk-4vz17ytv.js +0 -68
- package/dist/chunk-5afnyvw5.js +0 -2
- package/dist/chunk-5d5dxts6.js +0 -2
- package/dist/chunk-5fdsyyfe.js +0 -2
- package/dist/chunk-67yr4m5h.js +0 -2
- package/dist/chunk-6aqr0e6s.js +0 -2
- package/dist/chunk-6bw02d1t.js +0 -2
- package/dist/chunk-76mn123c.js +0 -2
- package/dist/chunk-7ar11ccn.js +0 -2
- package/dist/chunk-7fc0vrs5.js +0 -2
- package/dist/chunk-82fg5gp6.js +0 -2
- package/dist/chunk-89r7bbsk.js +0 -2
- package/dist/chunk-8egbh6z1.js +0 -2
- package/dist/chunk-8n9jd8cz.js +0 -2
- package/dist/chunk-8tfpv6zf.js +0 -6
- package/dist/chunk-8x3yaahc.js +0 -2
- package/dist/chunk-94qc4zwb.js +0 -2
- package/dist/chunk-9928zdej.js +0 -3
- package/dist/chunk-9ay18k46.js +0 -2
- package/dist/chunk-9kn81bmp.js +0 -2
- package/dist/chunk-9tv0tw7f.js +0 -3
- package/dist/chunk-9w9y84t5.js +0 -21
- package/dist/chunk-a5h9bwrc.js +0 -2
- package/dist/chunk-b5qzed8y.js +0 -1323
- package/dist/chunk-bej9kz05.js +0 -2
- package/dist/chunk-bh2khcet.js +0 -2
- package/dist/chunk-c6096ssb.js +0 -2
- package/dist/chunk-ccgabq3a.js +0 -2
- package/dist/chunk-e0tvd7jj.js +0 -2
- package/dist/chunk-e5rag6rh.js +0 -3
- package/dist/chunk-fvr3h2fr.js +0 -7
- package/dist/chunk-gmmqz698.js +0 -2
- package/dist/chunk-hxftzw0x.js +0 -2
- package/dist/chunk-js1wayhb.js +0 -2
- package/dist/chunk-jz37h2z0.js +0 -4
- package/dist/chunk-k2t0w8z1.js +0 -2
- package/dist/chunk-k8s3hyh2.js +0 -2
- package/dist/chunk-kcpxqsdj.js +0 -2
- package/dist/chunk-mjr5fkc2.js +0 -2
- package/dist/chunk-na0e3s88.js +0 -2
- package/dist/chunk-new89wh2.js +0 -2
- package/dist/chunk-nrap20qt.js +0 -2
- package/dist/chunk-p9bghe13.js +0 -2
- package/dist/chunk-q2cwzgd0.js +0 -2
- package/dist/chunk-q60afqr7.js +0 -2
- package/dist/chunk-q9yahsww.js +0 -2
- package/dist/chunk-qdwtemy1.js +0 -2
- package/dist/chunk-qp0ndbk6.js +0 -2
- package/dist/chunk-rzsvxjse.js +0 -2
- package/dist/chunk-s2c0ynn9.js +0 -2
- package/dist/chunk-senrtnx2.js +0 -2
- package/dist/chunk-v1wr2vdx.js +0 -2
- package/dist/chunk-v6gkjg5f.js +0 -3
- package/dist/chunk-wc10m4tp.js +0 -38
- package/dist/chunk-wcxa8xy2.js +0 -2
- package/dist/chunk-wgrj0cvs.js +0 -2
- package/dist/chunk-wpkwx3wq.js +0 -2
- package/dist/chunk-wq17dce6.js +0 -2
- package/dist/chunk-wvc6eayq.js +0 -2
- package/dist/chunk-xa98a901.js +0 -2
- package/dist/chunk-xjt5129x.js +0 -2
- package/dist/chunk-yc3frw0z.js +0 -3
- package/dist/chunk-yn02d599.js +0 -2
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{T}from"./chunk-jjq7c8s2.js";import{re}from"./chunk-gmn9ba8f.js";import{on,O}from"./chunk-p4twxjfs.js";import ut from"path";var n={UNCLOSED_DIRECTIVE:1001,UNCLOSED_EXPRESSION:1002,INVALID_DIRECTIVE_SYNTAX:1003,MALFORMED_EXPRESSION:1004,UNEXPECTED_TOKEN:1005,UNDEFINED_VARIABLE:1101,TYPE_ERROR:1102,EVALUATION_ERROR:1103,INFINITE_LOOP:1104,CIRCULAR_REFERENCE:1105,UNSAFE_EXPRESSION:1201,PATH_TRAVERSAL:1202,XSS_ATTEMPT:1203,CODE_INJECTION:1204,DOM_API_VIOLATION:1205,FILE_NOT_FOUND:1301,FILE_READ_ERROR:1302,INVALID_FILE_PATH:1303,PERMISSION_DENIED:1304,INVALID_CONFIG:1401,MISSING_REQUIRED_CONFIG:1402,DEPRECATED_CONFIG:1403,COMPONENT_NOT_FOUND:1501,INVALID_PROPS:1502,COMPONENT_RENDER_ERROR:1503,FILTER_NOT_FOUND:1601,INVALID_FILTER_ARGS:1602,EXPRESSION_TIMEOUT:1603};function fe(e){for(let[t,r]of Object.entries(n))if(r===e)return t;return}import zt from"path";var Ut={showRelativePaths:!1,enableAutoRecovery:re(),logRecoveryWarnings:!0},de={...Ut};function B(){return{...de}}function z(e){if(!de.showRelativePaths||!e)return e;let t=de.baseDir||process.cwd();try{let r=zt.relative(t,e);return r.startsWith("..")?e:r}catch{return e}}class P extends Error{code;filePath;line;column;context;numericCode;constructor(e,t,r,i,s,o,a){super(e);this.code=t;this.filePath=r;this.line=i;this.column=s;this.context=o;if(this.name="StxError",this.numericCode=a||n.EVALUATION_ERROR,this.filePath)this.filePath=z(this.filePath)}}class ce extends P{constructor(e,t,r,i,s,o){super(e,"stx_RUNTIME_ERROR",t,r,i,s,o||n.EVALUATION_ERROR);this.name="StxRuntimeError"}}class Kr extends P{constructor(e,t,r,i,s,o){super(e,"stx_FILE_ERROR",t,r,i,s,o||n.FILE_NOT_FOUND);this.name="StxFileError"}}class te extends P{isFatal=!0;constructor(e,t,r,i,s,o){super(e,"stx_VALIDATION_ERROR",t,r,i,s,o||n.DOM_API_VIOLATION);this.name="StxValidationError"}}function Ue(e){let{type:t,message:r,code:i,filePath:s,line:o,column:a,template:c,offset:f,snippet:l,suggestion:y,format:m="text"}=e,E=o,S=a;if(!E&&c&&f!==void 0){let pe=Gt(c,f);E=pe.line,S=pe.column}let b=s?z(s):void 0,w=i?fe(i):void 0,k={type:t,code:i,codeName:w,message:r,filePath:b,line:E,column:S,snippet:l,suggestion:y,timestamp:new Date().toISOString()},R;switch(m){case"html":R=Wt(k);break;case"json":R=JSON.stringify(k,null,2);break;case"console":R=Xt(k,c,f);break;case"text":default:R=Vt(k,c,f);break}return{formatted:R,data:k}}function Vt(e,t,r){let i=[],s=e.code?` [${e.codeName||e.code}]`:"";if(i.push(`[${e.type} Error${s}]`),e.filePath){let o=e.filePath;if(e.line){if(o+=`:${e.line}`,e.column)o+=`:${e.column}`}i.push(`at ${o}`)}if(i.push(`
|
|
3
|
+
${e.message}`),t&&e.line){let o=Kt(t,e.line,2);if(o)i.push(`
|
|
4
|
+
${o}`)}if(e.snippet)i.push(`
|
|
5
|
+
Snippet: ${e.snippet}`);if(e.suggestion)i.push(`
|
|
6
|
+
Suggestion: ${e.suggestion}`);return i.join(" ")}function Wt(e){let t=e.code?` [${e.code}]`:"",r=e.filePath?` in ${e.filePath}${e.line?`:${e.line}`:""}`:"",i=`<!-- [${e.type} Error${t}]${r}: ${ze(e.message)}`;if(e.suggestion)i+=` | Suggestion: ${ze(e.suggestion)}`;return i+=" -->",i}function Xt(e,t,r){let l=[],y=e.code?` [${e.codeName||e.code}]`:"";if(l.push(`\x1B[1m${"\x1B[31m"}\u2501\u2501\u2501 ${e.type} Error${y} \u2501\u2501\u2501${"\x1B[0m"}`),e.filePath){let m=`\x1B[36m${e.filePath}\x1B[0m`;if(e.line){if(m+=`\x1B[90m:${e.line}\x1B[0m`,e.column)m+=`\x1B[90m:${e.column}\x1B[0m`}l.push(`
|
|
7
|
+
\x1B[90mat\x1B[0m ${m}`)}if(l.push(`
|
|
8
|
+
|
|
9
|
+
${e.message}`),t&&e.line){let m=qt(t,e.line,2);if(m)l.push(`
|
|
10
|
+
|
|
11
|
+
\x1B[90mContext:\x1B[0m
|
|
12
|
+
${m}`)}if(e.suggestion)l.push(`
|
|
13
|
+
|
|
14
|
+
\x1B[33mSuggestion:\x1B[0m ${e.suggestion}`);return l.push(`
|
|
15
|
+
${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501${"\x1B[0m"}`),l.join("")}function Kt(e,t,r){let i=e.split(`
|
|
16
|
+
`),s=Math.max(0,t-r-1),o=Math.min(i.length-1,t+r-1),a=[];for(let c=s;c<=o;c++){let f=(c+1).toString().padStart(4),l=c===t-1?">":" ";a.push(`${l}${f} | ${i[c]}`)}return a.join(`
|
|
17
|
+
`)}function qt(e,t,r){let i=e.split(`
|
|
18
|
+
`),s=Math.max(0,t-r-1),o=Math.min(i.length-1,t+r-1),a="\x1B[90m",c="\x1B[31m",f="\x1B[0m",l=[];for(let y=s;y<=o;y++){let m=(y+1).toString().padStart(4),E=y===t-1,S=E?"\x1B[31m>\x1B[0m":" ",b=E?`\x1B[31m${i[y]}\x1B[0m`:`\x1B[90m${i[y]}\x1B[0m`;l.push(`${S}\x1B[90m${m}\x1B[0m | ${b}`)}return l.join(`
|
|
19
|
+
`)}function ze(e){return e.replace(/--/g,"- -").replace(/>/g,">")}function Gt(e,t){let i=e.substring(0,t).split(`
|
|
20
|
+
`);return{line:i.length,column:i[i.length-1].length}}function u(e,t,r){return Ue({type:e,message:t,code:r,format:"html"}).formatted}async function Me(e,t,r){try{return await e()}catch(i){if(r&&i instanceof Error)r(i);return t}}var ta={isEnabled(){return B().enableAutoRecovery},fixCommonSyntaxErrors(e){let t=B();if(!t.enableAutoRecovery)return{fixed:e,fixes:[]};let r=e,i=[],s=(r.match(/\{\{/g)||[]).length,o=(r.match(/\}\}/g)||[]).length;if(s>o){let c=s-o;r+="}}".repeat(c),i.push(`Added ${c} missing closing braces '}}'`)}let a=["if","foreach","for","switch","section"];for(let c of a){let f=(r.match(new RegExp(`@${c}\\b`,"g"))||[]).length,l=(r.match(new RegExp(`@end${c}\\b`,"g"))||[]).length;if(f>l){let y=f-l;for(let m=0;m<y;m++)r+=`
|
|
21
|
+
@end${c}`;i.push(`Added ${y} missing @end${c}`)}}if(i.length>0&&t.logRecoveryWarnings)console.warn("[stx] Auto-recovery applied fixes:"),i.forEach((c)=>console.warn(` - ${c}`)),console.warn(" Consider fixing these issues in your template.");return{fixed:r,fixes:i}},createFallbackContent(e,t){if(re())return`<!-- ${e} failed: ${t.message} -->`;return"<!-- stx rendering error -->"}};class me{errors=[];maxErrors;enableFileLogging;logFilePath;logFormat;maxFileSize;maxLogFiles;minLevel;writeQueue=Promise.resolve();constructor(e={}){this.maxErrors=e.maxErrors??1000,this.enableFileLogging=e.enableFileLogging??!1,this.logFilePath=e.logFilePath??".stx/errors.log",this.logFormat=e.logFormat??"json",this.maxFileSize=e.maxFileSize??10485760,this.maxLogFiles=e.maxLogFiles??5,this.minLevel=e.minLevel??"all"}configure(e){if(e.maxErrors!==void 0)this.maxErrors=e.maxErrors;if(e.enableFileLogging!==void 0)this.enableFileLogging=e.enableFileLogging;if(e.logFilePath!==void 0)this.logFilePath=e.logFilePath;if(e.logFormat!==void 0)this.logFormat=e.logFormat;if(e.maxFileSize!==void 0)this.maxFileSize=e.maxFileSize;if(e.maxLogFiles!==void 0)this.maxLogFiles=e.maxLogFiles;if(e.minLevel!==void 0)this.minLevel=e.minLevel}log(e,t,r="error"){let i={timestamp:new Date,error:e,context:t,level:r};if(this.errors.push(i),this.errors.length>this.maxErrors)this.errors=this.errors.slice(-this.maxErrors);if(this.enableFileLogging&&this.shouldLog(r))this.writeToFile(i)}shouldLog(e){if(this.minLevel==="all")return!0;if(this.minLevel==="warning")return e==="error"||e==="warning";if(this.minLevel==="error")return e==="error";return!0}formatEntry(e){if(this.logFormat==="json")return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level||"error",type:e.error.constructor.name,message:e.error.message,stack:e.error.stack,context:e.context});let t=[`[${e.timestamp.toISOString()}] [${(e.level||"error").toUpperCase()}] ${e.error.constructor.name}: ${e.error.message}`];if(e.error.stack)t.push(` Stack: ${e.error.stack.split(`
|
|
22
|
+
`).slice(1).join(`
|
|
23
|
+
`)}`);if(e.context)t.push(` Context: ${JSON.stringify(e.context)}`);return t.join(`
|
|
24
|
+
`)}writeToFile(e){this.writeQueue=this.writeQueue.then(async()=>{try{let t=await import("fs"),r=await import("path"),i=r.dirname(this.logFilePath);if(!t.existsSync(i))t.mkdirSync(i,{recursive:!0});await this.rotateIfNeeded(t);let s=`${this.formatEntry(e)}
|
|
25
|
+
`;t.appendFileSync(this.logFilePath,s,"utf-8")}catch(t){if(process.env.STX_DEBUG==="true")console.error("Failed to write to error log:",t)}})}async rotateIfNeeded(e){try{if(!e.existsSync(this.logFilePath))return;if(e.statSync(this.logFilePath).size<this.maxFileSize)return;for(let r=this.maxLogFiles-1;r>=1;r--){let i=`${this.logFilePath}.${r}`,s=`${this.logFilePath}.${r+1}`;if(e.existsSync(i))if(r>=this.maxLogFiles-1)e.unlinkSync(i);else e.renameSync(i,s)}if(this.maxLogFiles<=1)e.writeFileSync(this.logFilePath,"");else e.renameSync(this.logFilePath,`${this.logFilePath}.1`)}catch(t){if(process.env.STX_DEBUG==="true")console.error("Failed to rotate error logs:",t)}}getRecentErrors(e=10){return this.errors.slice(-e)}getErrorsByType(e){return this.errors.filter((t)=>t.error.constructor.name===e)}getErrorsByLevel(e){return this.errors.filter((t)=>t.level===e)}clear(){this.errors.length=0}async clearLogFile(){try{let e=await import("fs");if(e.existsSync(this.logFilePath))e.writeFileSync(this.logFilePath,"","utf-8")}catch(e){if(process.env.STX_DEBUG==="true")console.error("Failed to clear error log:",e)}}getStats(){let e={},t={error:0,warning:0,info:0};for(let r of this.errors){let i=r.error.constructor.name;e[i]=(e[i]||0)+1;let s=r.level||"error";t[s]=(t[s]||0)+1}return{total:this.errors.length,byType:e,byLevel:t}}async exportToFile(e,t="json"){let r=await import("fs"),i=await import("path"),s=i.dirname(e);if(!r.existsSync(s))r.mkdirSync(s,{recursive:!0});if(t==="json"){let o=this.errors.map((a)=>({timestamp:a.timestamp.toISOString(),level:a.level||"error",type:a.error.constructor.name,message:a.error.message,stack:a.error.stack,context:a.context}));r.writeFileSync(e,JSON.stringify(o,null,2),"utf-8")}else{let o=this.errors.map((a)=>this.formatEntry(a));r.writeFileSync(e,o.join(`
|
|
26
|
+
|
|
27
|
+
`),"utf-8")}}async flush(){await this.writeQueue}}var K=new me,Fn={isDevelopment(){return re()},logDetailedError(e,t){if(!this.isDevelopment())return;if(console.error("=== stx Detailed Error ==="),console.error("Error:",e.message),console.error("Stack:",e.stack),t)console.error("Context:",t);console.error("========================")},createErrorReport(e,t){let r=["=== stx Error Report ===",`Time: ${new Date().toISOString()}`,`Error: ${e.message}`,`Type: ${e.constructor.name}`,`Stack: ${e.stack}`];if(t)r.push(`Context: ${JSON.stringify(t,null,2)}`);return r.push("========================"),r.join(`
|
|
28
|
+
`)}};class be{context;source;pos=0;line=1;column=0;tokens=[];constructor(e,t="template"){this.context=t;this.source=e}tokenize(){this.tokens=[],this.pos=0,this.line=1,this.column=0;while(this.pos<this.source.length){let e=this.nextToken();if(e)this.tokens.push(e)}return this.tokens.push({type:"EOF",value:"",start:this.pos,end:this.pos,line:this.line,column:this.column}),this.tokens}nextToken(){if(this.pos>=this.source.length)return null;let e=this.pos,t=this.line,r=this.column,i=this.source[this.pos];if(/\s/.test(i))return this.readWhitespace(e,t,r);if(i==="/"&&this.peek(1)==="/")return this.readLineComment(e,t,r);if(i==="/"&&this.peek(1)==="*")return this.readBlockComment(e,t,r);if(i==='"'||i==="'")return this.readString(i,e,t,r);if(i==="`")return this.readTemplateString(e,t,r);if(/\d/.test(i)||i==="."&&/\d/.test(this.peek(1)||""))return this.readNumber(e,t,r);if(/[a-z_$]/i.test(i))return this.readIdentifier(e,t,r);if(this.context==="template"&&i==="{"){if(this.peek(1)==="{"&&this.peek(2)==="{")return this.advance(3),{type:"RAW_START",value:"{{{",start:e,end:this.pos,line:t,column:r};if(this.peek(1)==="{")return this.advance(2),{type:"EXPRESSION_START",value:"{{",start:e,end:this.pos,line:t,column:r};if(this.peek(1)==="!"&&this.peek(2)==="!")return this.advance(3),{type:"RAW_START",value:"{!!",start:e,end:this.pos,line:t,column:r}}if(this.context==="template"&&i==="}"){if(this.peek(1)==="}"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"}}}",start:e,end:this.pos,line:t,column:r};if(this.peek(1)==="}")return this.advance(2),{type:"EXPRESSION_END",value:"}}",start:e,end:this.pos,line:t,column:r}}if(this.context==="template"&&i==="!"&&this.peek(1)==="!"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"!!}",start:e,end:this.pos,line:t,column:r};if(i==="@"&&/[a-z]/i.test(this.peek(1)||""))return this.readDirective(e,t,r);let s=["===","!==","==","!=","<=",">=","&&","||","??","++","--","+=","-=","*=","/=","%=","**","=>","?.","...","<<",">>",">>>","&=","|=","^="];for(let o of s)if(this.source.slice(this.pos,this.pos+o.length)===o)return this.advance(o.length),{type:"OPERATOR",value:o,start:e,end:this.pos,line:t,column:r};if(/[+\-*/%<>=!&|^~?:]/.test(i))return this.advance(),{type:"OPERATOR",value:i,start:e,end:this.pos,line:t,column:r};if(/[()[\]{},;.]/.test(i))return this.advance(),{type:"PUNCTUATION",value:i,start:e,end:this.pos,line:t,column:r};return this.advance(),{type:"PUNCTUATION",value:i,start:e,end:this.pos,line:t,column:r}}readWhitespace(e,t,r){while(this.pos<this.source.length&&/\s/.test(this.source[this.pos]))this.advance();return{type:"WHITESPACE",value:this.source.slice(e,this.pos),start:e,end:this.pos,line:t,column:r}}readLineComment(e,t,r){this.advance(2);while(this.pos<this.source.length&&this.source[this.pos]!==`
|
|
29
|
+
`)this.advance();return{type:"COMMENT",value:this.source.slice(e,this.pos),start:e,end:this.pos,line:t,column:r}}readBlockComment(e,t,r){this.advance(2);while(this.pos<this.source.length-1){if(this.source[this.pos]==="*"&&this.source[this.pos+1]==="/"){this.advance(2);break}this.advance()}return{type:"COMMENT",value:this.source.slice(e,this.pos),start:e,end:this.pos,line:t,column:r}}readString(e,t,r,i){this.advance();while(this.pos<this.source.length){let s=this.source[this.pos];if(s==="\\"){this.advance(2);continue}if(s===e){this.advance();break}this.advance()}return{type:"STRING",value:this.source.slice(t,this.pos),start:t,end:this.pos,line:r,column:i}}readTemplateString(e,t,r){this.advance();let i=0,s=256;while(this.pos<this.source.length){let o=this.source[this.pos];if(o==="\\"){this.advance(2);continue}if(o==="$"&&this.peek(1)==="{"){if(i>=s){this.pos=this.source.length;break}this.advance(2),i++;continue}if(o==="{"&&i>0){i++,this.advance();continue}if(o==="}"&&i>0){i--,this.advance();continue}if(o==="`"&&i===0){this.advance();break}this.advance()}return{type:"TEMPLATE_STRING",value:this.source.slice(e,this.pos),start:e,end:this.pos,line:t,column:r}}readNumber(e,t,r){if(this.source[this.pos]==="0"){let i=this.peek(1)?.toLowerCase();if(i==="x"||i==="o"||i==="b"){this.advance(2);while(this.pos<this.source.length&&/[\da-f_]/i.test(this.source[this.pos]))this.advance();return{type:"NUMBER",value:this.source.slice(e,this.pos),start:e,end:this.pos,line:t,column:r}}}while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance();if(this.source[this.pos]==="."&&(this.context==="javascript"||/\d/.test(this.peek(1)||""))){this.advance();while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance()}if(/e/i.test(this.source[this.pos]||"")){if(this.advance(),/[+-]/.test(this.source[this.pos]||""))this.advance();while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance()}if(this.source[this.pos]==="n")this.advance();return{type:"NUMBER",value:this.source.slice(e,this.pos),start:e,end:this.pos,line:t,column:r}}readIdentifier(e,t,r){while(this.pos<this.source.length&&/[\w$]/.test(this.source[this.pos]))this.advance();return{type:"IDENTIFIER",value:this.source.slice(e,this.pos),start:e,end:this.pos,line:t,column:r}}readDirective(e,t,r){this.advance();while(this.pos<this.source.length&&/[a-z]/i.test(this.source[this.pos]))this.advance();return{type:"DIRECTIVE",value:this.source.slice(e,this.pos),start:e,end:this.pos,line:t,column:r}}advance(e=1){for(let t=0;t<e&&this.pos<this.source.length;t++){if(this.source[this.pos]===`
|
|
30
|
+
`)this.line++,this.column=0;else this.column++;this.pos++}}peek(e){return this.source[this.pos+e]}saveState(){return{pos:this.pos,line:this.line,column:this.column}}restoreState(e){this.pos=e.pos,this.line=e.line,this.column=e.column}}function _(e,t,r,i=0){let s=0,o=i,a=null,c=0,f=!1;while(o<e.length){let l=e[o];if(a&&f){f=!1,o++;continue}if(a&&l==="\\"){f=!0,o++;continue}if(f=!1,(l==='"'||l==="'"||l==="`")&&!a){a=l,o++;continue}if(l===a&&a!=="`"){a=null,o++;continue}if(a==="`"&&l==="$"&&e[o+1]==="{"){c++,o+=2;continue}if(c>0&&l==="}"){c--,o++;continue}if(l==="`"&&a==="`"&&c===0){a=null,o++;continue}if(a){o++;continue}if(l===t)s++;else if(l===r){if(s--,s===0)return o}o++}return-1}function Dl(e,t){let r=t,i={paren:0,bracket:0,brace:0},s=null,o=0;while(r<e.length){let a=e[r];if((r>0?e[r-1]:"")==="\\"&&s){r++;continue}if((a==='"'||a==="'")&&!s){s=a,r++;continue}if(a===s&&s!=="`"){s=null,r++;continue}if(a==="`"&&!s){s="`",r++;continue}if(a==="`"&&s==="`"&&o===0){s=null,r++;continue}if(s==="`"&&a==="$"&&e[r+1]==="{"){o++,r+=2;continue}if(o>0){if(a==="{")o++;else if(a==="}")o--;r++;continue}if(s){r++;continue}if(i.paren===0&&i.bracket===0&&i.brace===0){if(e.slice(r,r+2)==="}}"||e.slice(r,r+3)==="!!}")break;if(a===","||a===";")break}if(a==="(")i.paren++;else if(a===")"){if(i.paren--,i.paren<0)break}else if(a==="[")i.bracket++;else if(a==="]"){if(i.bracket--,i.bracket<0)break}else if(a==="{")i.brace++;else if(a==="}"){if(i.brace--,i.brace<0)break}r++}return{expression:e.slice(t,r),endPos:r}}var Jt={maxSanitizeDepth:10,allowBracketNotation:!1},Je={...Jt};var G=/\bnew\s+/,Y="__stx_safe_ctors",Ze=["Bun","Deno","Buffer","fetch","atob","btoa","console","Response","Request","Headers","WebAssembly","structuredClone","queueMicrotask","crypto","performance","navigator","Worker","WebSocket","BroadcastChannel","EventSource","XMLHttpRequest","localStorage","sessionStorage"],he=[...Ze,"Function","setTimeout","setInterval","setImmediate","process","require","exports","module","window","document","global","globalThis","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry"],Ve=he.map(()=>{return}),ye=Object.freeze(Object.assign(Object.create(null),{keys:Object.keys,values:Object.values,entries:Object.entries,fromEntries:Object.fromEntries,assign:Object.assign,hasOwn:Object.hasOwn,is:Object.is})),Se=[/\b(eval|Function|setTimeout|setInterval|setImmediate)\b/,/\b(process|require|import|exports|module)\b/,/\b(window|document|global|globalThis)\b/,/\b(constructor|prototype|__proto__)\b/,/\b(Reflect|Proxy)\b/,/\bSymbol\b/,/\b(WeakMap|WeakSet|WeakRef|FinalizationRegistry)\b/,/\b(Generator|AsyncGenerator)\b/,/__\w+__/,/\.(bind|call|apply)\s*\(/,G,/\bdelete\s+/,/\bthis\b/,/\\u(?:\{[\dA-Fa-f]+\}|[\dA-Fa-f]{4})/],ke=new Set([...Ze,"eval","Function","setTimeout","setInterval","setImmediate","process","require","import","exports","module","window","document","global","globalThis","constructor","prototype","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry","Generator","AsyncGenerator","delete","this",Y]),ve=new Set(["__proto__","constructor","prototype"]);function Qe(e){let t="",r=[],i=null,s=!1;for(let o=0;o<e.length;o++){let a=e[o];if(s){s=!1;continue}if(a==="\\"&&i){s=!0;continue}if(i){if(i==="`"&&a==="$"&&o+1<e.length&&e[o+1]==="{"){let c=1;o+=2;while(o<e.length&&c>0){if(e[o]==="{")c++;else if(e[o]==="}")c--;if(c>0)t+=e[o],r.push(o),o++}continue}if(a===i)i=null;continue}if(a==='"'||a==="'"||a==="`"){i=a;continue}t+=a,r.push(o)}return{text:t,map:r}}function it(e){return Qe(e).text}var st=["Collator","DateTimeFormat","DisplayNames","ListFormat","Locale","NumberFormat","PluralRules","RelativeTimeFormat","Segmenter"],ot=(()=>{let e={Date,URL,URLSearchParams},t=Intl;for(let r of st)if(typeof t[r]==="function")e[`Intl_${r}`]=t[r];return Object.freeze(Object.assign(Object.create(null),e))})(),rn=/^new(\s+)(Date|URLSearchParams|URL|Intl\s*\.\s*([A-Z_a-z]\w*))\s*\(/,We=/(?<![\w$])new(?![\w$])/g,Xe=`only new Date(), new URL(), new URLSearchParams() and new Intl.{${st.join(",")}}() are allowed`;function sn(e){let{text:t,map:r}=Qe(e),i=[];We.lastIndex=0;let s;while((s=We.exec(t))!==null){let a=s.index;if(/(?<!\.)\.\s*$/.test(t.slice(0,a)))continue;let c=rn.exec(t.slice(a)),f=c?.[3],l=!c?null:f?`Intl_${f}`:c[2];if(!c||!l||!(l in ot))throw new v(`matched /${G.source}/; ${Xe}`,e);let y=a+c[0].length,m=r[a],E=r[y-1]+1;if(e.slice(m,E)!==t.slice(a,y))throw new v(`matched /${G.source}/; ${Xe}`,e);let S=m+3+c[1].length;i.push({start:S,end:S+c[2].length,key:l})}let o=e;for(let a=i.length-1;a>=0;a--){let c=i[a];o=`${o.slice(0,c.start)}${Y}.${c.key}${o.slice(c.end)}`}return{source:o,usesSafeConstructors:i.length>0}}class v extends Error{rule;expression;constructor(e,t,r){super(r??`Potentially unsafe expression (${e}): ${t}`);this.name="UnsafeExpressionError",this.rule=e,this.expression=t}}function ho(e){try{return Re(e),null}catch(t){return t instanceof v?t.rule:t instanceof Error?t.message:String(t)}}function at(e,t){let r=/[$A-Z_a-z][$\w]*/g,i;while((i=r.exec(e))!==null){let s=i[0],o=e[i.index-1];if(ke.has(s))throw new v(`matched /\\b${s}\\b/; identifier ${s}`,t);if(o==="."&&ve.has(s))throw new v(`matched /.${s}/; property ${s}`,t)}}function ct(e,t=!0){let r=/(?:[$\w)\].]|\?\.)\s*\[([^\]]*)\]/g,i=new Set,s;while((s=r.exec(e))!==null){let o=s.index+s[0].indexOf("["),a=e.slice(0,o);if(/(?:^|[^$\w])(?:let|const|var)\s*$/.test(a))continue;let c=s[1].trim(),f=/^'(?:[^'\\]|\\.)*'$/.test(c),l=/^"(?:[^"\\]|\\.)*"$/.test(c);if(/^\d+$/.test(c))continue;if(f||l){let m=c.slice(1,-1);if(ve.has(m))throw new v(`bracket key ${m}`,e);if(!Je.allowBracketNotation)throw new v("bracket notation with a string key; enable with configureSafeEvaluator({ allowBracketNotation: true })",e,`Bracket notation with strings not allowed: ${e}. Enable with configureSafeEvaluator({ allowBracketNotation: true })`);continue}if(t&&/^[$A-Z_a-z][$\w]*$/.test(c)){i.add(c);continue}throw new v("dynamic bracket notation is not allowed",e)}return[...i]}function Re(e){let t=e.trim(),r=it(t);at(r,t);let i=ct(t);for(let s of Se){if(s===G)continue;if(s.test(r))throw new v(`matched /${s.source}/`,t)}return{...sn(t),dynamicKeys:i}}function ea(e){return Re(e),e.trim()}var yo=Symbol("stx.sanitizeCache"),an=4000,V=new Map;function cn(e){let t=V.get(e);if(t===void 0){if(t=Se.some((r)=>r.test(e)),V.size>=an)V.clear();V.set(e,t)}return t}function J(e){let t={},r=e[yo];t.Math=Math,t.JSON=JSON,t.Date=Date,t.String=String,t.Number=Number,t.Boolean=Boolean,t.Array=Array,t.Object=ye,t.parseInt=Number.parseInt,t.parseFloat=Number.parseFloat,t.isNaN=Number.isNaN,t.isFinite=Number.isFinite,t.encodeURIComponent=encodeURIComponent,t.decodeURIComponent=decodeURIComponent;for(let[i,s]of Object.entries(e)){if(i.startsWith("__")||cn(i))continue;if(s&&typeof s==="object"&&!Array.isArray(s)){let o=r?.get(s);if(o===void 0)o=xe(s),r?.set(s,o);t[i]=o}else t[i]=s}return t}function xe(e,t=0){if(t>=Je.maxSanitizeDepth)return"[Object too deep]";if(e===null||typeof e!=="object")return e;if(Array.isArray(e))return e.map((i)=>xe(i,t+1));if(e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error)return e;let r={};for(let[i,s]of Object.entries(e)){if(i.startsWith("__")||i==="constructor"||i==="prototype")continue;if(s&&typeof s==="object")r[i]=xe(s,t+1);else r[i]=s}return r}function d(e,t){try{let r=J(t),i=Object.keys(r),s=Object.values(r);return p(e,i)(...s)}catch{return}}function h(e){try{return ea(e),!0}catch{return!1}}var W=new Set;function ln(e,t,r){if(!t.startsWith("__")||!(t in r))return;let i=`${t}\x00${e}`;if(W.has(i))return;if(W.add(i),W.size>500)W.clear();console.warn(`[stx] a condition reads \`${t}\`, which conditions cannot see, so \`${e.trim()}\` is false and nothing it guards is rendered. Names starting with \`__\` are withheld from @if, @elseif and @unless. Derive a plain value in the server script (for example \`const hasRows = ${t}.length > 0\`) and test that instead.`)}function Ml(e,t){try{let r=J(t),i=Object.keys(r),s=Object.values(r),o=!1,c=p(e,i,(f)=>{o=!0,ln(e,f,t)})(...s);return!o&&Boolean(c)}catch{return!1}}function D(e,t){try{let r=d(e,t);if(r&&typeof r==="object"&&!Array.isArray(r))return r;return{}}catch{return{}}}var lt=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","yield","let","static","implements","interface","package","private","protected","public","arguments","eval","await"]),Ke=`stx-compile-probe:${globalThis.crypto.randomUUID()}`,un=0,gn=0;function pn(e,t){let r="__stx_compile_probe";while(e.includes(r))r+="_";let i=Array.from({length:e.length+1});i[e.length]=Ke;for(let s=0;s<16;s++){let o=`c${++un}`,a=`'use strict';if(${r}===${JSON.stringify(Ke)})return ${JSON.stringify(o)};`,c=Function(...e,r,a+t);if(c(...i)===o)return c;gn++}throw Error("[stx] the JavaScript runtime repeatedly returned code compiled from a different source; refusing to evaluate with it.")}var fn=2000,q=new Map;function qe(e,t){let r=`${e.join(",")}\x00${t}`,i=q.get(r);if(i)return i;let s=pn(e,t);if(q.size>=fn)q.clear();return q.set(r,s),s}function Ee(e){return e.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*`/g," ").replace(/\??\.\s*[a-zA-Z_$][\w$]*/g," ").replace(/([{,]\s*)[a-zA-Z_$][\w$]*(\s*:)/g,"$1$2").match(/\b[a-zA-Z_$][\w$]*\b/g)||[]}var dn=/^[A-Za-z_$][\w$]*$/;function qr(e){return dn.test(e)&&!lt.has(e)}var Ge=new T(2000,{maxBytes:2097152,sizeOf:(e)=>e.sourceBytes});function p(e,t,r){let i=JSON.stringify([e,t]),s=Ge.get(i);if(!s)s=mn(e,[...t]),s.sourceBytes+=i.length*2,Ge.set(i,s);return hn(yn(s.buildFunc,s.filteredKeys,s.contextKeys,s.validEntries,s.validIndices,r),s.contextKeys,s.dynamicKeys)}function mn(e,t){let{source:r,usesSafeConstructors:i,dynamicKeys:s}=Re(e),o=[];for(let m=0;m<t.length;m++){if(!qr(t[m]))continue;if(t[m]===Y||t[m]==="Object"||ke.has(t[m]))continue;o.push({key:t[m],index:m})}o.sort((m,E)=>m.key<E.key?-1:1);let a=o.map((m)=>m.key),c=o.map((m)=>m.index),f=`
|
|
31
|
+
'use strict';
|
|
32
|
+
try {
|
|
33
|
+
return ${r};
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
if (e instanceof TypeError) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
throw e;
|
|
40
|
+
}
|
|
41
|
+
`,l=i?(m)=>{let E=qe([Y,"Object",...he,...a,...m],f);return(...S)=>E(ot,ye,...Ve,...S)}:(m)=>{let E=qe(["Object",...he,...a,...m],f);return(...S)=>E(ye,...Ve,...S)},y=l([]);return{sourceBytes:e.length*2+t.reduce((m,E)=>m+E.length*2,0),contextKeys:t,filteredKeys:a,validEntries:o,validIndices:c,dynamicKeys:s,buildFunc:(m)=>m.length===0?y:l(m)}}function hn(e,t,r){if(r.length===0)return e;let i=r.map((s)=>t.indexOf(s));return(...s)=>{for(let o of i){if(o<0)continue;let a=s[o];if(typeof a==="string"&&ve.has(a))return}return e(...s)}}function yn(e,t,r,i,s,o){let a=e([]),c=i.every((l,y)=>l.index===y);if(t.length===r.length&&c)return Ye(a,t,e,void 0,o);return Ye((...l)=>{let y=Array(s.length);for(let m=0;m<s.length;m++)y[m]=l[s[m]];return a(...y)},t,e,(l)=>{a=e(l)},o)}function Ye(e,t,r,i,s){let a=/^(\w+) is not defined$/,c=e,f=[],l=new Set(t);return(...y)=>{for(let m=0;m<=8;m++)try{return c(...y)}catch(E){let S=E instanceof Error?E.message:"",b=a.exec(S);if(!(E instanceof ReferenceError)||!b)return;let w=b[1];if(l.has(w)||lt.has(w)||ke.has(w))return;if(s?.(w),l.add(w),f.push(w),i)i(f);else c=r(f)}return}}function bo(e){let t=e.trim();try{let r=it(t);if(/\b(?:eval|function|import|require|process|globalthis|window|document|fetch|bun|deno|buffer|console|reflect|proxy|prototype|constructor|this)\b/i.test(r))return!1;at(r,t),ct(t);for(let i of Se)if(i.test(r))return!1}catch{return!1}return!0}function na(e,t){let r=[];t.lastIndex=0;let i;while((i=t.exec(e))!==null){let s=i.index,o=s+i[0].length-1,a=_(e,"(",")",o);if(a===-1){r.push({start:s,end:-1,args:"",call:e.slice(s,Math.min(e.length,s+80))}),t.lastIndex=o+1;continue}r.push({start:s,end:a+1,args:e.slice(o+1,a),call:e.slice(s,a+1)}),t.lastIndex=a+1}return r}function Yt(e,t,r,i){let s="",o=0;for(let a of na(e,t)){if(s+=e.slice(o,a.start),a.end===-1){s+=i(a.call),o=a.start;continue}s+=r(a.args,a.call),o=a.end}return s+e.slice(o)}function Zt(e){let t=[],r=0,i=null,s="";for(let o=0;o<e.length;o++){let a=e[o];if(i){if(s+=a,a==="\\"&&o+1<e.length){s+=e[++o];continue}if(a===i)i=null;continue}if(a==="'"||a==='"'||a==="`")i=a;else if(a==="("||a==="["||a==="{")r++;else if(a===")"||a==="]"||a==="}")r--;else if(a===","&&r===0){t.push(s.trim()),s="";continue}s+=a}if(s.trim())t.push(s.trim());return t}function bt(e){let t=e.trim(),r=t[0];if(r!=="'"&&r!=='"'&&r!=="`"||t.length<2||t.at(-1)!==r)return null;let i="",s={b:"\b",f:"\f",n:`
|
|
42
|
+
`,r:"\r",t:"\t",v:"\v",0:"\x00"};for(let o=1;o<t.length-1;o++){let a=t[o];if(a==="\\"){if(++o>=t.length-1)return null;let c=t[o];if(/[1-9]/.test(c)||c==="0"&&/\d/.test(t[o+1]??""))return null;if(c===`
|
|
43
|
+
`||c==="\u2028"||c==="\u2029")continue;if(c==="\r"){if(t[o+1]===`
|
|
44
|
+
`)o++;continue}if(c==="x"||c==="u"){let f=c==="u"&&t[o+1]==="{",l=f?t.indexOf("}",o+2):o+(c==="x"?2:4)+1,y=t.slice(o+(f?2:1),l);if(l<0||l>=t.length||!/^[\da-f]+$/i.test(y)||!f&&y.length!==(c==="x"?2:4))return null;let m=Number.parseInt(y,16);if(m>1114111)return null;i+=String.fromCodePoint(m),o=f?l:l-1;continue}i+=Object.hasOwn(s,c)?s[c]:c;continue}if(a===r||r!=="`"&&(a===`
|
|
45
|
+
`||a==="\r"))return null;if(r==="`"&&a==="$"&&t[o+1]==="{")return null;if(r==="`"&&a==="\r"){if(t[o+1]===`
|
|
46
|
+
`)o++;i+=`
|
|
47
|
+
`}else i+=a}return i}var En=new Set(["true","false","null","undefined","typeof","void","new","in","of","instanceof","this","delete","await","async","function","return","NaN","Infinity"]);function Qt(e,t){let r=e.trim();if(!r)return{ok:!1,message:"the argument is empty",code:n.INVALID_DIRECTIVE_SYNTAX};let i=ho(r);if(i)return{ok:!1,message:`the expression is not allowed (${i})`,code:n.UNSAFE_EXPRESSION};let s=J(t),o;try{o=p(r,Object.keys(s))(...Object.values(s))}catch(c){return{ok:!1,message:`the expression could not be evaluated: ${c instanceof Error?c.message:String(c)}`,code:n.EVALUATION_ERROR}}if(o!==void 0&&o!==null)return{ok:!0,value:o};let a=[...new Set(Ee(r))].filter((c)=>!En.has(c)&&!(c in s)&&!(c in globalThis));if(a.length>0)return{ok:!1,message:`${a.map((f)=>`"${f}"`).join(", ")} ${a.length===1?"is":"are"} not defined here. Values a directive reads must come from <script server> or the render context; a plain <script> runs in the browser. To pass literal text, quote it.`,code:n.UNDEFINED_VARIABLE};if(o===void 0&&(r.startsWith("{")||r.startsWith("[")))return{ok:!1,message:"the expression threw while it was evaluated",code:n.EVALUATION_ERROR};return{ok:!0,value:o}}function et(e){if(e===null)return"null";if(Array.isArray(e))return"an array";if(typeof e==="object")return"an object";if(typeof e==="string")return`a string ("${e.length>40?`${e.slice(0,40)}...`:e}")`;return`${/^[aeiou]/.test(typeof e)?"an":"a"} ${typeof e}`}function wt(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function gt(e){if(!e)return"";return ut.isAbsolute(e)?ut.relative(process.cwd(),e)||e:e}function Ce(e){let t=e.replace(/\s+/g," ").trim();return t.length>80?`${t.slice(0,77)}...`:t}function H(e,t,r,i,s=n.EVALUATION_ERROR){let o=i?` in ${gt(i)}`:"";return console.warn(`[stx] ${Ce(t)}${o}: ${r}`),u(e,`${Ce(t)}: ${r}`,s)}function wo(e,t,r){let i=r?` in ${gt(r)}`:"";console.warn(`[stx] ${Ce(e)}${i}: ${t}`)}var en="data-stx-before-runtime";function ra(){return{afterOpen:[],beforeClose:[]}}function bn(e){return e.afterOpen.length>0||e.beforeClose.length>0}function Ll(e,t){if(!bn(t))return e;let r=t.afterOpen.join(""),i=t.beforeClose.join(""),s=O(e),o=r?zn(e):null,a=i&&s!==-1?s:null;if(o===null&&a===null)return e;if(o!==null&&a!==null)return`${e.slice(0,o)}${r}${e.slice(o,a)}${i}${e.slice(a)}`;if(o!==null)return`${e.slice(0,o)}${r}${e.slice(o)}`;return`${e.slice(0,a)}${i}${e.slice(a)}`}var pt=/\s*<meta\b[^>]*\bcharset\b[^>]*>/iy;function zn(e){let t=/<head\b[^>]*>/i.exec(e);if(!t)return null;let r=t.index+t[0].length;pt.lastIndex=r;let i=pt.exec(e);return i?r+i[0].length:r}var Te=/\s*/y,Ae=/\x00STX_HTML_COMMENT_\d+\x00/y;function vt(e){let t=0;while(t<e.length){if(Te.lastIndex=t,Te.exec(e),t=Te.lastIndex,e.startsWith("<!--",t)){let r=e.indexOf("-->",t+4);if(r===-1)return t;t=r+3;continue}if(Ae.lastIndex=t,Ae.test(e)){t=Ae.lastIndex;continue}return t}return t}var _e=/<(\/?)([a-zA-Z][a-zA-Z0-9-]*)\b/y,xn=new Map(["textarea","title","xmp","iframe","noembed","noframes"].map((e)=>[e,new RegExp(`</${e}\\s*>`,"ig")]));function De(e){let t=[],r=0;while(r<e.length){let i=e.indexOf("<",r);if(i===-1)break;if(e.startsWith("<!--",i)){let E=e.indexOf("-->",i+4);if(E===-1)break;r=E+3;continue}_e.lastIndex=i;let s=_e.exec(e);if(!s){r=i+1;continue}let o=_e.lastIndex,a=o,c=null;for(;a<e.length;a++){let E=e[a];if(c){if(E===c)c=null}else if(E==='"'||E==="'")c=E;else if(E===">")break}if(a===e.length)break;let f=s[1]==="/",l=e[a-1]==="/";t.push({start:i,end:a+1,name:s[2],attributes:e.slice(o,l?a-1:a),closing:f,selfClosing:l}),r=a+1;let y=s[2].toLowerCase();if(!f&&y==="plaintext")break;let m=xn.get(y);if(!f&&(y==="script"||y==="style"||m)){let E=m??(y==="script"?ie:se);E.lastIndex=r;let S=E.exec(e);if(!S)break;r=S.index}}return t}var Z=/<script\b[^>]*>/iy,ie=/<\/script\s*>/ig,ee=/<style\b[^>]*>/iy,se=/<\/style\s*>/ig;function ft(e,t,r,i){r.lastIndex=t;let s=r.exec(e);if(!s||s.index!==t)return-1;i.lastIndex=r.lastIndex;let o=i.exec(e);if(!o)return-1;return o.index+o[0].length}function U(e,t){return ft(e,t,Z,ie)}function tn(e,t){return ft(e,t,ee,se)}function tt(e,t){if(!e.startsWith("<!--",t))return-1;let r=e.indexOf("-->",t+4);if(r===-1)return-1;return r+3}function dt(e,t){if(e.startsWith("<!--",t)){let s=tt(e,t);return s===-1?e.length:s}if(Z.lastIndex=t,Z.exec(e)?.index===t){ie.lastIndex=Z.lastIndex;let s=ie.exec(e);return s?s.index+s[0].length:e.length}if(ee.lastIndex=t,ee.exec(e)?.index===t){se.lastIndex=ee.lastIndex;let s=se.exec(e);return s?s.index+s[0].length:e.length}return-1}function g(e,t){let r=[],i=0,s=e.length,o=!1,a=null;while(i<s){let c=e[i];if(o){if(a){if(c===a)a=null}else if(c==='"'||c==="'")a=c;else if(c===">")o=!1;i++;continue}if(c!=="<"){let m=e.indexOf("<",i+1);if(m===-1)break;i=m;continue}let f=t(e,i);if(f>i){r.push({start:i,end:f,token:e.slice(i,f)}),i=f;continue}let l=dt(e,i);if(l>i){i=l;continue}let y=e.charCodeAt(i+1);if(y>=65&&y<=90||y>=97&&y<=122)o=!0;i++}return r}function jl(e){let t=0,r=0,i=0,s=!1,o=null;while(i<e.length){if(s){let m=e[i];if(o){if(m===o)o=null}else if(m==='"'||m==="'")o=m;else if(m===">")s=!1;i++;continue}let a=e.indexOf("<",i),c=a===-1?e.length:a;while(i<c){let m=e[i++];if(m==="{")t++;else if(m==="}")r++;if(t>=2&&r>=2)return!0}if(a===-1)break;let f=dt(e,a);if(f>a){i=f;continue}let l=e.charCodeAt(a+1),y=l===47?e.charCodeAt(a+2):l;if(y>=65&&y<=90||y>=97&&y<=122)s=!0;i=a+1}return!1}function Bl(e,t){while(e.size>=t){let r=e.keys().next();if(r.done)return;e.delete(r.value)}}var Sn=1024,wn=16777216,L=new Map,$e=0;function kn(e,t){L.set(e,t),$e+=e.length+t.output.length;for(let[r,i]of L){if($e<=wn)break;L.delete(r),$e-=r.length+i.output.length}}function we(e,t,r,i){let s=i!==void 0&&e.length>=Sn,o=s?`${i}\x00${e}`:"";if(s){let y=L.get(o);if(y)return L.delete(o),L.set(o,y),{output:y.output,tokens:y.tokens.slice()}}let a=g(e,t);if(a.length===0)return{output:e,tokens:[]};let c=a.map((y)=>y.token),f="",l=0;for(let y=0;y<a.length;y++){let m=a[y];f+=e.slice(l,m.start),f+=r(m.token,y),l=m.end}if(f+=e.slice(l),s)return kn(o,{output:f,tokens:c}),{output:f,tokens:c.slice()};return{output:f,tokens:c}}var vn=1024,Rn=16777216,M=new Map,Ie=0;function Cn(e,t){M.set(e,t),Ie+=e.length+t.output.length;for(let[r,i]of M){if(Ie<=Rn)break;M.delete(r),Ie-=r.length+i.output.length}}function Oe(e,t,r){return{output:t,scripts:r,restore:(i)=>i===t?e:Hn(i,r)}}function ne(e){let t=e.length>=vn;if(t){let s=M.get(e);if(s)return M.delete(e),M.set(e,s),Oe(e,s.output,s.scripts.slice())}let{output:r,tokens:i}=we(e,U,(s,o)=>`\x00STX_SCRIPT_${o}\x00`);if(t)return Cn(e,{output:r,scripts:i}),Oe(e,r,i.slice());return Oe(e,r,i)}function Hn(e,t){if(t.length===0)return e;return e.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(r,i)=>t[+i]??"")}function Q(e){let t=De(e),r=[];for(let i=0;i<t.length;i++){let s=t[i],o=t[i+1];if(s.name.toLowerCase()!=="script"||s.closing||o?.name.toLowerCase()!=="script"||!o.closing)continue;r.push({start:s.start,end:o.end,bodyStart:s.end,bodyEnd:o.start,attrs:s.attributes})}return r}var nn="private, no-store";function nt(e){return e.replace(/&#(\d+);/g,(t,r)=>mt(Number(r),t)).replace(/&#x([0-9a-f]+);/gi,(t,r)=>mt(Number.parseInt(r,16),t)).replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&")}function mt(e,t){if(!Number.isInteger(e)||e<0||e>1114111)return t;try{return String.fromCodePoint(e)}catch{return t}}function Le(e){return e.headers.get("X-STX-Router")==="true"}function ht(e,t){if(!e)return t;return e.split(",").some((i)=>i.trim().toLowerCase()===t.toLowerCase())?e:`${e}, ${t}`}function X(e){let t=ht(e,"X-STX-Router");for(let r of vo)t=ht(t,r);return{Vary:t}}var vo=["X-STX-Have-Layout","X-STX-Have-Layout-Group"];var oe="data-stx-color-mode-boot",yt="__STX_COLOR_MODE__",Tn=new Set(["light","dark","auto","system"]),An=new Set(["auto","system"]),_n=/^[a-z][\w:-]*$/i,$n=/^[\w-]+$/;function In(e){let t=e.storageKey??"stx-color-mode",r=e.initialMode??"auto",i=e.darkClass===void 0?"dark":e.darkClass,s=e.attribute??null,o=e.autoValue??null,a=e.respectExisting===!0;if(typeof t!=="string"||t.length===0)throw Error("colorMode.storageKey must be a non-empty string");if(!Tn.has(r))throw Error(`colorMode.initialMode must be one of light, dark, auto, system \u2014 got ${JSON.stringify(r)}`);if(i!==null&&(typeof i!=="string"||!$n.test(i)))throw Error(`colorMode.darkClass must be a single CSS class name, or null to opt out \u2014 got ${JSON.stringify(i)}`);if(s!==null&&(typeof s!=="string"||!_n.test(s)))throw Error(`colorMode.attribute must be a valid HTML attribute name \u2014 got ${JSON.stringify(s)}`);if(o!==null&&!An.has(o))throw Error(`colorMode.autoValue must be 'auto' or 'system' \u2014 got ${JSON.stringify(o)}`);if(i===null&&s===null)throw Error("colorMode needs at least one of darkClass or attribute \u2014 with both null nothing would mark the mode on <html>");if(a&&s===null)throw Error("colorMode.respectExisting needs an attribute to read \u2014 the dark class alone cannot say whether a mode was chosen");return{storageKey:t,initialMode:r==="system"?"auto":r,darkClass:i,attribute:s,autoValue:o,respectExisting:a}}function On(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function Pe(e={}){let t=In(e),r=On(t),i=`(function(){"use strict";var o=window.${yt};if(o&&typeof o.sync==="function"){o.sync();return}var c=${r};var r=document.documentElement;function read(){var p=c.initialMode,a=c.autoValue;try{var v=localStorage.getItem(c.storageKey);if(v==="light"||v==="dark"){p=v}else if(v==="auto"||v==="system"){p="auto";if(!a)a=v}}catch(e){}return{p:p,a:a}}function sys(){try{return matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}catch(e){return"light"}}function stamp(m){if(c.attribute)r.setAttribute(c.attribute,m);if(c.darkClass){if(m==="dark")r.classList.add(c.darkClass);else r.classList.remove(c.darkClass)}}var s=read();var f=null;if(c.respectExisting&&c.attribute){var x=r.getAttribute(c.attribute);if(x==="light"||x==="dark")f=x}var m=f||(s.p==="auto"?sys():s.p);var p=s.p;stamp(m);var g=null;function sync(){var t=read(),n=f||(t.p==="auto"?sys():t.p);var moved=n!==m,chose=t.p!==p;if(moved){r.style.setProperty("transition","none","important");stamp(n);void r.offsetHeight;r.style.removeProperty("transition")}else stamp(n);m=n;p=t.p;if(g){g.mode=n;g.preference=t.p;if(t.a)g.autoValue=t.a}if(moved||chose){try{window.dispatchEvent(new CustomEvent("stx:color-mode",{detail:{mode:n,preference:t.p}}))}catch(e){}}}try{g=window.${yt}={storageKey:c.storageKey,initialMode:c.initialMode,darkClass:c.darkClass,attribute:c.attribute,autoValue:s.a||"auto",respectExisting:c.respectExisting,forced:f,preference:p,mode:m,watching:true,sync:sync}}catch(e){}try{var q=matchMedia("(prefers-color-scheme: dark)");if(q.addEventListener)q.addEventListener("change",sync);else if(q.addListener)q.addListener(sync)}catch(e){}try{addEventListener("pageshow",sync);addEventListener("storage",function(e){if(e.key===null||e.key===c.storageKey)sync()});document.addEventListener("visibilitychange",function(){if(document.visibilityState==="visible")sync()})}catch(e){}}());`;return`<script ${oe}>${i}</script>`}function Xr(e,t={}){if(e.includes(oe))return e;let r=Ne(e);if(r===null)return e;let i=Pe(t);return`${e.slice(0,r)}
|
|
48
|
+
${i}${e.slice(r)}`}var Ne=zn,Nn=new RegExp(`<script\\b[^>]*\\b${oe}\\b[^>]*>[\\s\\S]*?<\\/script>`,"i"),Et=/<meta\b[^>]*\bcharset\b[^>]*>/gi,St=/<\/head>/gi;function Ln(e){let t=/<head\b[^>]*>/i.exec(e);if(!t)return e;let r=t.index+t[0].length;St.lastIndex=r;let i=St.exec(e),s=i?i.index:e.length;Et.lastIndex=r;let o=Et.exec(e);if(!o||o.index>=s)return e;if(e.slice(r,o.index).trim()==="")return e;let a=o.index+o[0].length;return`${e.slice(0,r)}
|
|
49
|
+
${o[0]}${e.slice(r,o.index)}${e.slice(a,s)}${e.slice(s)}`}function Fl(e){return Pn(Dn(Ln(e)))}var kt=/<(?:base|meta)\b(?:"[^"]*"|'[^']*'|[^'">])*>/iy,Mn=/^<script\b(?:"[^"]*"|'[^']*'|[^'">])*>/i;function Pn(e){if(!e.includes(`${en}=""`))return e;let t=zn(e),r=O(e);if(t===null||r===-1)return e;let i=e.slice(t,r),s=g(i,U).map((b)=>({...b,attrs:on(Mn.exec(b.token)?.[0]??"")})),o=s.filter(({attrs:b})=>(en in b));if(!o.length)return e;let a=g(i,(b,w)=>{kt.lastIndex=w;let k=kt.exec(b)?.[0];if(!k)return-1;let R=nt(on(k)["http-equiv"]??"").toLowerCase();return/^<base\b/i.test(k)||R==="content-security-policy"?w+k.length:-1}),c=s.find(({attrs:b})=>(oe in b)),f=Math.max(a.at(-1)?.end??0,c?.end??0),l=f;if(o.every((b)=>{if(b.start<l||i.slice(l,b.start).trim())return!1;return l=b.end,!0}))return e;let y=[],m=f;l=0;for(let b of o)if(y.push(i.slice(l,b.start)),l=b.end,b.end<=f)m-=b.end-b.start;y.push(i.slice(l));let E=y.join(""),S=o.map((b)=>b.token).join(`
|
|
50
|
+
`);return e.slice(0,t)+E.slice(0,m)+`
|
|
51
|
+
`+S+E.slice(m)+e.slice(r)}function Dn(e){let t=Nn.exec(e);if(!t)return e;let r=Ne(e);if(r===null)return e;if(t.index<=r||e.slice(r,t.index).trim()==="")return e;let i=e.slice(0,t.index)+e.slice(t.index+t[0].length),s=Ne(i);if(s===null)return e;return`${i.slice(0,s)}
|
|
52
|
+
${t[0]}${i.slice(s)}`}var jn="[data-stx-component-wrapper]:not([stx-hydrate]){display:contents}",Tt=`<style data-stx-cloak>[x-cloak]{display:none !important}${jn}</style>`,ae="data-stx-html-attrs",le="data-stx-html-class",At=/^[A-Za-z_:][\w:.-]*$/;function C(e){return String(e).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Bn(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function xt(e){if(e.name)return`name="${e.name}"`;if(e.property)return`property="${e.property}"`;if(e.charset!=null)return"charset=";if(e["http-equiv"])return`http-equiv="${e["http-equiv"]}"`;return""}function Vn(e){let t=/^\s*<meta\b([^>]*)>/i.exec(e);if(!t)return null;let r={};for(let i of t[1].matchAll(/([\w:-]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g))r[i[1].toLowerCase()]=i[2]??i[3]??i[4]??"";return r}function I(e,t){return Object.entries(e).filter(([r])=>!t?.(r)).map(([r,i])=>`${r}="${C(String(i))}"`).join(" ")}function ue(e){let t=String(e.content),r=typeof e.type==="string"?e.type.trim().toLowerCase():"";return/json$|^importmap$/.test(r)?t.replace(/<\//g,"<\\/"):t}function F(e){let{content:t,beforeRuntime:r,...i}=e;if(r!==!0)return i;let s=String(i.type??"").trim().toLowerCase();if(typeof t!=="string"||!t.trim()||i.src||i.async||i.defer||s&&s!=="text/javascript"&&s!=="application/javascript")throw Error("A beforeRuntime head script must be synchronous inline JavaScript.");return delete i.async,delete i.defer,{...i,[en]:""}}function _t(e){let t=I(F(e));return`<script${t?` ${t}`:""}>${ue(e)}</script>`}function Wn(e={},t="en"){let r=[],i=[],s="",o=t;for(let[c,f]of Object.entries(e||{})){if(f==null)continue;let l=c.trim();if(!At.test(l))continue;let y=l.toLowerCase();if(y==="lang"){o=String(f);continue}if(y==="class"){s=String(f).trim();continue}r.push(` ${l}="${C(String(f))}"`),i.push(l)}let a=` lang="${C(o)}"`;if(s)a+=` class="${C(s)}"`;if(a+=r.join(""),s)a+=` ${le}="${C(s)}"`;if(i.length)a+=` ${ae}="${C(i.join(" "))}"`;return a}function zl(e={},t={}){let r={...e,...t};if(e.class&&t.class){let i=e.class.split(/\s+/).filter(Boolean);for(let s of t.class.split(/\s+/).filter(Boolean))if(!i.includes(s))i.push(s);r.class=i.join(" ")}return r}function Gr(e,t={}){if(!t||Object.keys(t).length===0)return e;let r=e.match(/<html\b([^>]*)>/i);if(!r)return e;let i={},s=[],o=/([A-Za-z_:][\w:.-]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g,a;while((a=o.exec(r[1]))!==null){let y=a[1];if(!(y in i))s.push(y);i[y]=a[2]??a[3]??a[4]??""}let c=[],f=[];for(let[y,m]of Object.entries(t)){if(m==null)continue;let E=y.trim();if(!At.test(E))continue;let S=E.toLowerCase();if(S==="class"){let b=(i.class||"").split(/\s+/).filter(Boolean);for(let w of String(m).split(/\s+/).filter(Boolean))if(!b.includes(w))b.push(w),c.push(w);if(!("class"in i))s.push("class");i.class=b.join(" ");continue}if(!(E in i))s.push(E);if(i[E]=String(m),S!=="lang")f.push(E)}if(c.length){if(!(le in i))s.push(le);i[le]=c.join(" ")}if(f.length){if(!(ae in i))s.push(ae);i[ae]=f.join(" ")}let l=s.map((y)=>` ${y}="${C(i[y])}"`).join("");return e.replace(r[0],()=>`<html${l}>`)}function Hl(e){if(e.includes("data-stx-cloak"))return null;if(O(e)===-1)return null;return`${Tt}
|
|
53
|
+
`}function Xn(e){let t=[],r=0;while(r<e.length){let o=e.slice(r),a=o.match(/^\s+/);if(a){r+=a[0].length;continue}if(o.startsWith("<!--")){let m=e.indexOf("-->",r);if(m===-1)break;r=m+3;continue}let c=o.match(/^<script\b[^>]*>/i);if(c){let m=e.toLowerCase().indexOf("</script>",r+c[0].length);if(m===-1)break;r=m+9;continue}let f=o.match(/^<link\b[^>]*>/i);if(f){t.push(f[0]),r+=f[0].length;continue}let l=o.match(/^<meta\b[^>]*>/i);if(l){t.push(l[0]),r+=l[0].length;continue}let y=o.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(y){t.push(y[0]),r+=y[0].length;continue}break}if(t.length===0)return{body:e,hoisted:t};let i="",s=0;while(s<e.length&&s<r){let o=e.slice(s),a=o.match(/^<link\b[^>]*>/i);if(a&&t.includes(a[0])){s+=a[0].length;continue}let c=o.match(/^<meta\b[^>]*>/i);if(c&&t.includes(c[0])){s+=c[0].length;continue}let f=o.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(f&&t.includes(f[0])){s+=f[0].length;continue}i+=e[s],s++}return i+=e.slice(r),{body:i,hoisted:t}}function Kn(e,t={},r={}){let{title:i="stx App",lang:s="en",meta:o=[],link:a=[],script:c=[],headRaw:f="",htmlAttrs:l={},bodyClass:y="",bodyAttrs:m={}}=t,E=r.title||i,S=[{charset:"UTF-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}],b=new Set(o.map(xt).filter(Boolean)),{body:w,hoisted:k}=Xn(e),R=new Set(k.flatMap((x)=>{let j=Vn(x);return j?[xt(j)].filter(Boolean):[]})),Lt=[...S.filter((x)=>!b.has(xt(x))),...o].filter((x)=>!R.has(xt(x))).map((x)=>` <meta ${I(x)}>`).join(`
|
|
54
|
+
`),Mt=a.map((x)=>` <link ${I(x)}>`).join(`
|
|
55
|
+
`),Pt=c.map((x)=>{if(x.src)return` <script ${I(F(x))}></script>`;if(x.content)return` ${_t(x)}`;return""}).filter(Boolean).join(`
|
|
56
|
+
`),Ft=Wn(l,s),Dt=Object.entries(m).map(([x,j])=>` ${x}="${C(String(j))}"`).join(""),jt=y?` class="${C(y)}"`:"",Ht=[Lt,r.colorMode?` ${Pe(r.colorMode)}`:"",` <title>${r.titleIsHtml?E:Bn(E)}</title>`,` ${Tt}`,Mt,Pt,f?` ${f}`:"",...(r.styles||[]).map((x)=>` ${x}`),...k.map((x)=>` ${x}`),...(r.headScripts||[]).map((x)=>` ${x}`),r.headStack||""].filter(Boolean),Bt=[w,...(r.bodyScripts||[]).map((x)=>x),r.bodyStack||""].filter(Boolean);return`<!DOCTYPE html>
|
|
57
|
+
<html${Ft}>
|
|
58
|
+
<head>
|
|
59
|
+
${Ht.join(`
|
|
60
|
+
`)}
|
|
61
|
+
</head>
|
|
62
|
+
<body${jt}${Dt}>
|
|
63
|
+
${Bt.join(`
|
|
64
|
+
`)}
|
|
65
|
+
</body>
|
|
66
|
+
</html>`}var Fe=/\s+/y,He=/<(script|style)\b[^>]*>/iy,qn=/<\/script>/gi,Gn=/<\/style>/gi,Rt=/<!DOCTYPE\b/iy,Ct=/<html[\s>]/iy;function Un(e){let t=0;while(t<e.length){if(Fe.lastIndex=t,Fe.exec(e)){t=Fe.lastIndex;continue}if(e.startsWith("<!--",t)){let s=e.indexOf("-->",t);if(s===-1)return!1;t=s+3;continue}He.lastIndex=t;let i=He.exec(e);if(i){let s=i[1].toLowerCase()==="script"?qn:Gn;s.lastIndex=He.lastIndex;let o=s.exec(e);if(o===null)return!1;t=o.index+o[0].length;continue}if(Rt.lastIndex=t,Rt.test(e))return!0;return Ct.lastIndex=t,Ct.test(e)}return!1}function sa(e){return Un(e)}function Ul(e,t={}){let r=O(e);if(r===-1)return e;let{meta:i=[],link:s=[],script:o=[],headRaw:a=""}=t,c=e.slice(0,r),f=[];for(let l of i){let y=xt(l);if(y&&c.includes(y))continue;f.push(` <meta ${I(l)}>`)}for(let l of s){if(l.href&&c.includes(`href="${l.href}"`))continue;f.push(` <link ${I(l)}>`)}for(let l of o)if(l.src){if(c.includes(`src="${l.src}"`))continue;f.push(` <script ${I(F(l))}></script>`)}else if(l.content){if(c.includes(ue(l)))continue;f.push(` ${_t(l)}`)}if(a&&!c.includes(a))f.push(` ${a}`);if(f.length===0)return e;return`${e.slice(0,r)}${f.join(`
|
|
67
|
+
`)}
|
|
68
|
+
${e.slice(r)}`}function Jr(e,t={},r={},i){if(i??sa(e))return e;return Kn(e,t,r)}var Yn=["og:","article:","book:","profile:","fb:","music:","video:"],Jn=/^[a-z][\w-]*(?::[\w:-]+)?$/i;function Yr(e,t){if(e.length<1)return{kind:"error",message:"meta directive requires at least the meta name",code:n.INVALID_DIRECTIVE_SYNTAX};if(e.length>2)return{kind:"error",message:`@meta takes a name and a value, got ${e.length} arguments`,code:n.INVALID_DIRECTIVE_SYNTAX};let r=Zn(e[0],t);if(typeof r!=="string")return r;let i;if(e.length===2){let o=Qn(e[1],t);if(typeof o!=="string")return o;i=o}else{let o=r.includes(":")?r.slice(r.indexOf(":")+1):r,a=t.openGraph,c=t[o]??(wt(a)?a[o]:void 0);i=c===void 0||c===null||typeof c==="object"?"":String(c)}if(!i)return{kind:"empty"};return{kind:"tag",tag:Yn.some((o)=>r.startsWith(o))?{property:r,content:i}:{name:r,content:i}}}function Zn(e,t){let r=bt(e);if(r!==null)return r.trim()?r:{kind:"error",message:"the meta name is empty",code:n.INVALID_DIRECTIVE_SYNTAX};if(Jn.test(e.trim()))return e.trim();let i=Qt(e,t);if(!i.ok)return{kind:"error",message:`meta name: ${i.message}`,code:i.code};if(typeof i.value!=="string"||!i.value.trim())return{kind:"error",message:`the meta name must be a non-empty string, got ${et(i.value)}`,code:n.TYPE_ERROR};return i.value}function Qn(e,t){let r=bt(e);if(r!==null)return r;let i=Qt(e,t);if(!i.ok)return{kind:"error",message:i.message,code:i.code};let s=i.value;if(s===void 0||s===null||s===!1)return"";if(Array.isArray(s))return s.filter((o)=>o!==void 0&&o!==null&&o!=="").map(String).join(", ");if(typeof s==="object"&&!(s instanceof Date))return{kind:"error",message:`the content must be text, got ${et(s)}`,code:n.TYPE_ERROR};return String(s)}var Zr=["title","lang","meta","link","script","headRaw","htmlAttrs","bodyClass","bodyAttrs"],xo=["title","titleTemplate","base","meta","link","script","style","htmlAttrs","bodyAttrs"],Ot={links:"link",metas:"meta",scripts:"script",styles:"style"},$t=new Set,It=new WeakMap;function Be(e){if($t.has(e))return;$t.add(e),console.warn(e)}function er(e,t){let r=Array.from({length:t.length+1},(i,s)=>s);for(let i=1;i<=e.length;i++){let s=r[0];r[0]=i;for(let o=1;o<=t.length;o++){let a=r[o];r[o]=Math.min(r[o]+1,r[o-1]+1,s+(e[i-1]===t[o-1]?0:1)),s=a}}return r[t.length]}function tr(e,t){let r=e.toLowerCase(),i=t.find((f)=>f.toLowerCase()===r);if(i)return i;let s=Ot[r];if(s&&t.includes(s))return s;let o,a=1/0;for(let f of t){let l=er(r,f.toLowerCase());if(l<a)o=f,a=l}let c=Math.min(e.length,o?.length??0)<=4?1:2;return a<=c?o:void 0}function je(e,t){if(!e||typeof e!=="object"||Array.isArray(e))return e||{};let r=It.get(e);if(r)return r;let{known:i,source:s}=t,o=e;for(let a of Object.keys(e)){if(i.includes(a))continue;let c=Ot[a];if(c&&i.includes(c)&&Array.isArray(e[a])){if(o===e)o={...e};let l=Array.isArray(o[c])?o[c]:[];o[c]=[...l,...e[a]],delete o[a],Be(`[stx] ${s}.${a} is not a head key; reading it as ${s}.${c}. Rename it to \`${c}\`.`);continue}if(/^styles?$/.test(a)&&!i.includes("style")){Be(`[stx] ${s}.${a} is not a head key and is ignored. Use \`link\` with rel: 'stylesheet', or \`headRaw\` for an inline <style>.`);continue}let f=tr(a,i);Be(f?`[stx] ${s}.${a} is not a head key and is ignored. Did you mean \`${f}\`?`:`[stx] ${s}.${a} is not a head key and is ignored. Known keys: ${i.join(", ")}.`)}return It.set(e,o),o}var A={},nr=[],ge={};function oa(){return A}function Uy(){return ge}function Vy(){A={},nr.length=0,ge={}}function Vl(e){A=rt(A,je(e,{known:xo,source:"useHead()"}))}function Nt(e,t,r){let i=[...e||[]];for(let s of t||[]){let o=r(s),a=o?i.findIndex((c)=>r(c)===o):-1;if(a<0)i.push(s);else i[a]=s}return i}function rt(e,t){return{title:t.title??e.title,titleTemplate:t.titleTemplate??e.titleTemplate,base:t.base??e.base,meta:Nt(e.meta,t.meta,(r)=>r.name||r.property||(r.httpEquiv?`http:${r.httpEquiv}`:void 0)),link:Nt(e.link,t.link,(r)=>["icon","apple-touch-icon","canonical"].includes(r.rel||"")?[r.rel,r.type,r.media,r.sizes].join(":"):void 0),script:[...e.script||[],...t.script||[]],style:[...e.style||[],...t.style||[]],htmlAttrs:{...e.htmlAttrs,...t.htmlAttrs},bodyAttrs:{...e.bodyAttrs,...t.bodyAttrs}}}function im(e){Vl(So(e))}function So(e){let t=[];if(e.description)t.push({name:"description",content:e.description});if(e.keywords){let f=Array.isArray(e.keywords)?e.keywords.join(", "):e.keywords;t.push({name:"keywords",content:f})}if(e.author)t.push({name:"author",content:e.author});if(e.robots)t.push({name:"robots",content:e.robots});let r=e.ogTitle??e.title,i=e.ogDescription??e.description;if(r)t.push({property:"og:title",content:r});if(i)t.push({property:"og:description",content:i});if(e.ogImage){if(t.push({property:"og:image",content:e.ogImage}),e.ogImageType)t.push({property:"og:image:type",content:e.ogImageType});if(e.ogImageWidth)t.push({property:"og:image:width",content:String(e.ogImageWidth)});if(e.ogImageHeight)t.push({property:"og:image:height",content:String(e.ogImageHeight)});if(e.ogImageAlt)t.push({property:"og:image:alt",content:e.ogImageAlt})}if(e.ogUrl)t.push({property:"og:url",content:e.ogUrl});if(e.ogType)t.push({property:"og:type",content:e.ogType});if(e.ogSiteName)t.push({property:"og:site_name",content:e.ogSiteName});if(e.ogLocale)t.push({property:"og:locale",content:e.ogLocale});if(e.profileFirstName)t.push({property:"profile:first_name",content:e.profileFirstName});if(e.profileLastName)t.push({property:"profile:last_name",content:e.profileLastName});if(e.profileUsername)t.push({property:"profile:username",content:e.profileUsername});let s=e.twitterTitle??e.title,o=e.twitterDescription??e.description,a=e.twitterImage??e.ogImage;if(e.twitterCard)t.push({name:"twitter:card",content:e.twitterCard});if(s)t.push({name:"twitter:title",content:s});if(o)t.push({name:"twitter:description",content:o});if(a){t.push({name:"twitter:image",content:a});let f=e.twitterImageAlt??(e.twitterImage?void 0:e.ogImageAlt);if(f)t.push({name:"twitter:image:alt",content:f})}if(e.twitterSite)t.push({name:"twitter:site",content:e.twitterSite});if(e.twitterCreator)t.push({name:"twitter:creator",content:e.twitterCreator});if(e.articleAuthor)t.push({property:"article:author",content:e.articleAuthor});if(e.articlePublishedTime)t.push({property:"article:published_time",content:e.articlePublishedTime});if(e.articleModifiedTime)t.push({property:"article:modified_time",content:e.articleModifiedTime});if(e.articleSection)t.push({property:"article:section",content:e.articleSection});if(e.articleTags)for(let f of e.articleTags)t.push({property:"article:tag",content:f});let c=[];if(e.canonical)c.push({rel:"canonical",href:e.canonical});return{title:e.title,titleTemplate:e.titleTemplate,meta:t,link:c}}function Wy(e){if(ge={...ge,...e},e.title||e.description)im({title:e.title,description:e.description})}function qy(e){let t=typeof e==="function"?e():e;Vl({title:t})}function Ky(e=A){let t=[];if(e.title){let r=e.title;if(e.titleTemplate)r=typeof e.titleTemplate==="function"?e.titleTemplate(r):e.titleTemplate.replace("%s",r);t.push(`<title>${N(r)}</title>`)}if(e.base){let r=Object.entries(e.base).map(([i,s])=>`${i}="${N(s)}"`).join(" ");t.push(`<base ${r}>`)}for(let r of e.meta||[]){let i=Object.entries(r).filter(([s,o])=>o!==void 0).map(([s,o])=>`${s==="httpEquiv"?"http-equiv":s}="${N(String(o))}"`).join(" ");t.push(`<meta ${i}>`)}for(let r of e.link||[]){let i=Object.entries(r).filter(([s,o])=>o!==void 0).map(([s,o])=>`${s}="${N(String(o))}"`).join(" ");t.push(`<link ${i}>`)}for(let r of e.script||[]){let{content:i}=r,s=F({...r}),o=Object.entries(s).filter(([a,c])=>c!==void 0).map(([a,c])=>{if(typeof c==="boolean")return c?a:"";return`${a}="${N(String(c))}"`}).filter(Boolean).join(" ");if(i)t.push(`<script ${o}>${ue(r)}</script>`);else t.push(`<script ${o}></script>`)}for(let r of e.style||[]){let i=r.type?` type="${r.type}"`:"";t.push(`<style${i}>${r.content}</style>`)}return t.join(`
|
|
69
|
+
`)}function Xy(e=A){if(!e.htmlAttrs)return"";return Object.entries(e.htmlAttrs).map(([t,r])=>`${t}="${N(r)}"`).join(" ")}function Gy(e=A){if(!e.bodyAttrs)return"";return Object.entries(e.bodyAttrs).map(([t,r])=>`${t}="${N(r)}"`).join(" ")}function N(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Jy(e=A){if(typeof document>"u")return;if(e.title){let t=e.title;if(e.titleTemplate)t=typeof e.titleTemplate==="function"?e.titleTemplate(t):e.titleTemplate.replace("%s",t);document.title=t}for(let t of e.meta||[]){let r=t.name?`meta[name="${t.name}"]`:t.property?`meta[property="${t.property}"]`:null;if(r){let i=document.querySelector(r);if(!i){if(i=document.createElement("meta"),t.name)i.setAttribute("name",t.name);if(t.property)i.setAttribute("property",t.property);document.head.appendChild(i)}i.setAttribute("content",t.content)}}for(let t of e.link||[]){let r=`link[rel="${t.rel}"]${t.href?`[href="${t.href}"]`:""}`,i=document.querySelector(r);if(!i)i=document.createElement("link"),document.head.appendChild(i);for(let[s,o]of Object.entries(t))if(o!==void 0)i.setAttribute(s,String(o))}if(e.htmlAttrs)for(let[t,r]of Object.entries(e.htmlAttrs))if(t==="class")for(let i of String(r).split(/\s+/).filter(Boolean))document.documentElement.classList.add(i);else document.documentElement.setAttribute(t,r);if(e.bodyAttrs)for(let[t,r]of Object.entries(e.bodyAttrs))document.body.setAttribute(t,r)}function Yy(e){let t="";return{content:e.replace(/@head\s*([\s\S]*?)@endhead/g,(i,s)=>(t+=s.trim()+`
|
|
70
|
+
`,"")),headContent:t.trim()}}function Zy(e,t){return e.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(r,i,s,o)=>{let a=i?s:t[(o||"").trim()]??o,c=t.__stx_runtime_head??{};return t.__stx_runtime_head=rt(c,{title:a}),""})}function Qy(e,t,r=""){if(!e.includes("@meta"))return e;return Yt(e,/(?<![\w$@])@meta\s*\(/g,(i,s)=>{let o=Yr(Zt(i),t);if(o.kind==="error")return H("Meta",s,o.message,r,o.code);if(o.kind==="tag"){let a=t.__stx_runtime_head??{};t.__stx_runtime_head=rt(a,{meta:[o.tag]})}return""},(i)=>H("Meta",i,"the call has no closing parenthesis",r,n.INVALID_DIRECTIVE_SYNTAX))}export{ho,ea,yo,d,h,Ml,D,Ee,qr,p,bo,n,ce,Kr,te,u,Me,ta,K,Fn,be,_,Dl,na,Yt,Zt,bt,Qt,et,wt,H,wo,en,ra,Ll,zn,vt,De,U,tn,tt,g,jl,Bl,we,ne,Hn,Q,nn,nt,Le,X,vo,Xr,Fl,xt,zl,Gr,Hl,Un,sa,Ul,Jr,Yr,Zr,xo,je,oa,Uy,Vy,Vl,rt,im,So,Wy,qy,Ky,Xy,Gy,Jy,Yy,Zy,Qy};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{uu,du}from"./chunk-m6hrb7rm.js";import"./chunk-cbqe84g3.js";import"./chunk-rk16391e.js";import"./chunk-xap1f1bw.js";import"./chunk-nkbnsbb0.js";import"./chunk-9zwmfkfg.js";import"./chunk-zrxvj3zf.js";import"./chunk-yye2pec5.js";import"./chunk-2jm7map2.js";import"./chunk-2m4ydym0.js";import"./chunk-3efpqm1f.js";import"./chunk-m9ta0640.js";import"./chunk-gjyz5ma7.js";import"./chunk-hht7n4zd.js";import"./chunk-1vsjmwr1.js";import"./chunk-09xqy448.js";import"./chunk-ft34x0h1.js";import"./chunk-d4xjwebv.js";import"./chunk-2zb642qr.js";import"./chunk-514yg4dr.js";import"./chunk-m86sjbx7.js";import"./chunk-qzqqzraq.js";import"./chunk-tnbzg7fd.js";import"./chunk-kk9h53xg.js";import"./chunk-fn0y9z1t.js";import"./chunk-qtzfbv7e.js";import"./chunk-3hfv217t.js";import"./chunk-v1a5h1tc.js";import"./chunk-p3x7kwb5.js";import"./chunk-2szhk8mh.js";import"./chunk-1bf0grbf.js";import"./chunk-xk7hdpq5.js";import{yn}from"./chunk-yvaqgdv1.js";import{ug}from"./chunk-3br07y64.js";import"./chunk-xpsg91dh.js";import"./chunk-s1x2pc9b.js";import{Ue,i}from"./chunk-sbr3wg75.js";import"./chunk-m390z8w8.js";import"./chunk-1a2c4pv8.js";import"./chunk-zaj3nnvv.js";import"./chunk-d69k67bn.js";import"./chunk-xakqpa4z.js";import"./chunk-whnzf9hn.js";import"./chunk-fjpt8arw.js";import"./chunk-3aayrnbh.js";import{Pe}from"./chunk-v1x96kjr.js";import"./chunk-p0xqm2ne.js";import{Ar,Pr}from"./chunk-fwxgzktt.js";import"./chunk-2mv29s6w.js";import{Hs,q,a}from"./chunk-3tcy9r6r.js";import"./chunk-50zzar2c.js";import"./chunk-mr9pp5cf.js";import"./chunk-txk2z7v0.js";import"./chunk-ktv65e3n.js";import"./chunk-5fdc8pej.js";import{B,b,Ge}from"./chunk-vb609vbj.js";import"./chunk-qda8tmk9.js";import"./chunk-14df2jzs.js";import"./chunk-vf7tpgqz.js";import"./chunk-ayrd026n.js";import"./chunk-ex6dne7e.js";import"./chunk-jjq7c8s2.js";import"./chunk-858p3hkz.js";import{da}from"./chunk-p4twxjfs.js";import"./chunk-9gr7m3tb.js";import"./chunk-9mack1g8.js";export{Hs as buildWebComponents,Pr as cacheTemplate,Ar as checkCache,yn as classifyAllScripts,uu as createMiddleware,du as createRoute,q as defaultConfig,b as extractVariables,B as findSfcTemplateBlock,Pe as injectRouterScript,da as insertBeforeBodyClose,a as loadStxConfig,Ge as processClientScript,i as processDirectives,Ue as readMarkdownFile,ug as withinBundlerCallback};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import a from"fs";function At(r){return o(r)}var g=1000,i=new Map;function cr(){i.clear()}function o(r){return[...r].sort().map((n)=>{try{let t=a.statSync(n);return`${n}:${t.size}:${t.mtimeMs}`}catch{return`${n}:missing`}}).join(`
|
|
3
|
+
`)}function fn(r,n,t){let e=r.get(n);return e!==void 0&&e.signature===t?e.value:void 0}function xe(r,n,t,e){return r.set(n,{signature:t,value:e}),e}
|
|
4
|
+
export{At,cr,fn,xe};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{R}from"./chunk-0jdz31q1.js";import{Ie,Wt,oe,F,Nn,ae,P}from"./chunk-b5qzed8y.js";import{Zi,ho,d,m,M,Ee,p,yo,n,u,_}from"./chunk-4vz17ytv.js";import{kr}from"./chunk-9w9y84t5.js";import{ge}from"./chunk-9tv0tw7f.js";import{js}from"./chunk-nhyv3w4r.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=_(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=M(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),w=g.match(/^\s*,\s*/);if(!w)continue;let k=g.slice(w[0].length).trim();if(!k)continue;try{let S=M(k,r),B=JSON.stringify(S),I=`@component('${y}', ${B})`;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 se(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(F(s,r.__stx_client_signal_names||[]))return e;let l=Object.keys(r),b=Object.values(r);Zi(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(!Ee(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 le(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):Ie(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=_(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 Nn(t,(o,s,l)=>(i+=ie(r(t.slice(e,l))),i+=`\${__stxRenderLoopValue(${l}, (${s}), ${o.length})}`,e=l+o.length,o)),i+ie(r(t.slice(e)))}function fe(t,r,i,e){return ae(t,r,i==null?"":String(i),!1,e)}function ie(t){let r=t;return r=se(r,"@break",(i)=>{let e=i.trim();if(!yo(e))return"";return`\`; if (${e}) { break; } result += \``}),r=se(r,"@continue",(i)=>{let e=i.trim();if(!yo(e))return"";return`\`; if (${e}) { continue; } result += \``}),r=r.replace(/@break(?!\()/g,"`; break; result += `"),r=r.replace(/@continue(?!\()/g,"`; continue; result += `"),r}function _e(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 w=t.substring(h+1,g),k=Wt(w);if(!k)continue;let{arrayExpr:S,itemVar:B}=k,I=g+1,A=1,T=I,K=/@forelse\s*\(/g,L=/@endforelse/g,V=-1;while(A>0&&T<t.length){K.lastIndex=T,L.lastIndex=T;let C=K.exec(t),E=L.exec(t);if(!E)break;if(C&&C.index<E.index)A++,T=C.index+C[0].length;else{if(A--,A===0){V=E.index;break}T=E.index+11}}if(V===-1)continue;let O=t.substring(I,V),Z=V+11,z=-1,D=0,N=0;while(N<O.length){let C=O.indexOf("@",N);if(C===-1)break;let E=O.substring(C);if(/^@forelse\s*\(/.test(E))D++,N=C+1;else if(E.startsWith("@endforelse"))D--,N=C+11;else if(D===0&&E.startsWith("@empty")){if(O.length<=C+6||!/[a-z]/i.test(O[C+6])){z=C;break}N=C+1}else N=C+1}if(z===-1)continue;return{start:c,end:Z,arrayExpr:S,itemVar:B,foreachContent:O.substring(0,z),emptyContent:O.substring(z+6)}}return null}function ce(t,r){let i=t;while(!0){let e=_e(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 Re(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 Is(t){if(!t.includes(de))return t;return t.replace($e,(r,i,e)=>(Ae(decodeURIComponent(i),decodeURIComponent(e)),""))}function yg(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 ui(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 kr(t))l.add(c);if(l.size)r={...r,__stx_client_signal_names:[...l]};s=ce(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,w=1,k=g+1,S=-1;while(k<c.length&&w>0){if(c[k]==="(")w++;else if(c[k]===")"){if(w--,w===0){S=k;break}}k++}if(S===-1)continue;let B=c.substring(g+1,S),I=Wt(B);if(!I)continue;let A=y,{arrayExpr:T,itemVar:K}=I,L=S+1,V=1,O=L,Z=/@foreach\s*\(/g,z=/@endforeach/g;while(V>0&&O<c.length){Z.lastIndex=O,z.lastIndex=O;let D=Z.exec(c),N=z.exec(c);if(!N)break;if(D&&D.index<N.index)V++,O=D.index+D[0].length;else{if(V--,V===0){let C=c.substring(L,N.index),E=N.index+11;return{start:A,end:E,arrayExpr:T,itemVar:K,content:C}}O=N.index+11}}}return null}function*x(c,h){let a=c;while(!0){let y=b(a);if(!y)break;let{start:g,end:w,arrayExpr:k,itemVar:S,content:B}=y;try{let I=k.trim(),A;if(m(I))A=p(I,Object.keys(h))(...Object.values(h));else A=d(I,h);let T=!1;if(!Array.isArray(A))if(A instanceof Map)A=Array.from(A),T=!0;else if(A instanceof Set)A=Array.from(A);else if(typeof A==="string")A=Array.from(A);else if(A&&typeof A==="object"&&!(A instanceof Date)&&!(A instanceof RegExp))A=Object.entries(A),T=!0;else{let E=Re(I,i)+u("Foreach",`Error in @foreach: ${I} is not iterable`,n.TYPE_ERROR);a=a.substring(0,g)+E+a.substring(w);continue}let K=e?.loops?.useAltLoopVariable??me,L=S.trim(),V=null,O,Z=!1;if(L.includes("=>")){let E=L.split("=>").map((W)=>W.trim());if(E.length===2&&E[0]&&E[1])V=E[0],O=E[1];else O=L}else if(!L.startsWith("[")&&!L.startsWith("{")&&L.includes(",")){let E=L.split(",").map((W)=>W.trim());if(E.length===2&&E[0]&&E[1])O=E[0],V=E[1],Z=!0;else O=L}else O=L;let z="",D=new Set(oe(`${k} as ${S}`)),N=A,C=h[ho]??new WeakMap;for(let E=0;E<N.length;E++){if(E%16===0)yield;let W=N[E],te={index:E,iteration:E+1,first:E===0,last:E===N.length-1,count:N.length},j={...h,loop:te,$loop:te,[ho]:C};if(Array.isArray(h.__stx_client_signal_names))j.__stx_client_signal_names=h.__stx_client_signal_names.filter((H)=>!D.has(H));if(O.startsWith("[")&&O.endsWith("]")){let H=O.slice(1,-1).split(",").map((U)=>U.trim());if(Array.isArray(W))H.forEach((U,X)=>{if(U)j[U]=W[X]});else j[O]=W}else if(O.startsWith("{")&&O.endsWith("}")){let H=O.slice(1,-1).split(",").map((U)=>U.trim()).filter(Boolean);if(W!==null&&typeof W==="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)j[re]=W[Y]});else j[O]=W}else j[O]=W;if(V)if(!Z&&T&&Array.isArray(W)&&W.length===2)j[V]=W[0],j[O]=W[1];else j[V]=E;let v=ce(B,j);v=yield*ne(v,j,i,e,!0),v=ge(v,j,i),v=le(v,j);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,j,i),v=ye(v,j),v=be(v,j),v=xe(v,j),z+=v,q>=0&&q===J)break}a=a.substring(0,g)+z+a.substring(w)}catch(I){let A=u("Foreach",`Error in @foreach(${k.trim()} as ${S.trim()}): ${I instanceof Error?I.message:String(I)}`,n.EVALUATION_ERROR);a=a.substring(0,g)+A+a.substring(w)}}return a}s=yield*x(s,r),s=we(s,r,i,e);let f=e?.loops?.maxWhileIterations??he;return s=Se(s,r,f),o?s:Is(s)}function bg(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 yo(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=_(o,"(",")",x);if(f===-1)break;let c=bg(o.slice(x+1,f)),h=f+1,a=js(o.slice(b),"for","endfor");if(a.length===0)break;let y=a[0].content,g=b+a[0].end;if(!pe(c)){let w=u("For",`Unsafe expression in @for: ${c}`,n.UNSAFE_EXPRESSION);o=o.substring(0,b)+w+o.substring(g),s=!0;continue}try{let w=Oe(c),k=/@(?:for|foreach|if|unless)\s*\(/.test(y);if(w.length>0&&k){let K=ke({forExpr:c,content:y,iterVarNames:w,context:r,filePath:i,options:e});o=o.substring(0,b)+K+o.substring(g),s=!0;continue}let S=Object.keys(r),B=Object.values(r),I=ue(y),T=Function(...S,"__stxRenderLoopValue",`
|
|
2
|
+
import{R}from"./chunk-jjq7c8s2.js";import{ea,yo,d,h,D,Ee,p,bo,n,u,_}from"./chunk-vf7tpgqz.js";import{Ie,Wt,oe,F,Dn,ae,P}from"./chunk-vb609vbj.js";import{Tr}from"./chunk-3aayrnbh.js";import{ge}from"./chunk-fjpt8arw.js";import{Bs}from"./chunk-p0xqm2ne.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=_(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 m;try{let a=D(f,r);if(!a||typeof a!=="object")continue;m=JSON.stringify(a)}catch{continue}e+=t.slice(o,l)+m,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),m=f+1,a=c.match(/^\s*['"]([^'"]+)['"]/);if(!a)continue;let y=a[1],g=c.slice(a[0].length),w=g.match(/^\s*,\s*/);if(!w)continue;let k=g.slice(w[0].length).trim();if(!k)continue;try{let S=D(k,r),W=JSON.stringify(S),I=`@component('${y}', ${W})`;s.push({start:l,end:m,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 se(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,m=!1;while(f<e.length&&x>0){let g=e[f];if(m){m=!1,f++;continue}if(g==="\\"&&c){m=!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(F(s,r.__stx_client_signal_names||[]))return e;let l=Object.keys(r),b=Object.values(r);ea(s);let x=!1,c=p(s,l,()=>{x=!0})(...b);if(x)return e;let m=JSON.stringify(c);if(m===void 0){if(!Ee(s).some((g)=>!(g in r)))return"";return e}let a=Buffer.from(m,"utf8").toString("base64");return`__stx_${o}="${a}"`}catch(l){return e}}),i}var Q="<!--__STX_BREAK__-->",ee="<!--__STX_CONTINUE__-->";function le(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):Ie(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=_(t,"(",")",f);if(c<0)break;l=c+1;try{let m=`!!(${t.slice(f+1,c).trim()})`;b=h(m)?Boolean(p(m,Object.keys(r))(...Object.values(r))):Boolean(d(m,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 Dn(t,(o,s,l)=>(i+=ie(r(t.slice(e,l))),i+=`\${__stxRenderLoopValue(${l}, (${s}), ${o.length})}`,e=l+o.length,o)),i+ie(r(t.slice(e)))}function fe(t,r,i,e){return ae(t,r,i==null?"":String(i),!1,e)}function ie(t){let r=t;return r=se(r,"@break",(i)=>{let e=i.trim();if(!bo(e))return"";return`\`; if (${e}) { break; } result += \``}),r=se(r,"@continue",(i)=>{let e=i.trim();if(!bo(e))return"";return`\`; if (${e}) { continue; } result += \``}),r=r.replace(/@break(?!\()/g,"`; break; result += `"),r=r.replace(/@continue(?!\()/g,"`; continue; result += `"),r}function _e(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,m)=>c.pos-m.pos);let b=[],x=0;for(let c of e)x+=c.delta,b.push({pos:c.pos,depth:x});function f(c){let m=0,a=b.length-1,y=0;while(m<=a){let g=m+a>>1;if(b[g].pos<=c)y=b[g].depth,m=g+1;else a=g-1}return y}while((i=r.exec(t))!==null){if(f(i.index)>0)continue;let c=i.index,m=i.index+i[0].length-1,a=1,y=m+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 w=t.substring(m+1,g),k=Wt(w);if(!k)continue;let{arrayExpr:S,itemVar:W}=k,I=g+1,A=1,B=I,K=/@forelse\s*\(/g,L=/@endforelse/g,V=-1;while(A>0&&B<t.length){K.lastIndex=B,L.lastIndex=B;let C=K.exec(t),E=L.exec(t);if(!E)break;if(C&&C.index<E.index)A++,B=C.index+C[0].length;else{if(A--,A===0){V=E.index;break}B=E.index+11}}if(V===-1)continue;let O=t.substring(I,V),Z=V+11,U=-1,z=0,N=0;while(N<O.length){let C=O.indexOf("@",N);if(C===-1)break;let E=O.substring(C);if(/^@forelse\s*\(/.test(E))z++,N=C+1;else if(E.startsWith("@endforelse"))z--,N=C+11;else if(z===0&&E.startsWith("@empty")){if(O.length<=C+6||!/[a-z]/i.test(O[C+6])){U=C;break}N=C+1}else N=C+1}if(U===-1)continue;return{start:c,end:Z,arrayExpr:S,itemVar:W,foreachContent:O.substring(0,U),emptyContent:O.substring(U+6)}}return null}function ce(t,r){let i=t;while(!0){let e=_e(i);if(!e)break;let{start:o,end:s,arrayExpr:l,itemVar:b,foreachContent:x,emptyContent:f}=e;try{let c;if(h(l))c=p(l,Object.keys(r))(...Object.values(r));else c=d(l,r);let m;if(!Array.isArray(c)||c.length===0)m=f;else m=`@foreach (${l} as ${b})${x}@endforeach`;i=i.substring(0,o)+m+i.substring(s)}catch(c){let m=c instanceof Error?c.message:String(c),a=u("Forelse",`Error in @forelse(${l} as ${b}): ${m}`,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 Re(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 Os(t){if(!t.includes(de))return t;return t.replace($e,(r,i,e)=>(Ae(decodeURIComponent(i),decodeURIComponent(e)),""))}function vg(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 pi(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 Tr(t))l.add(c);if(l.size)r={...r,__stx_client_signal_names:[...l]};s=ce(s,r);function b(c){let m=/@foreach\s*\(/g,a;while((a=m.exec(c))!==null){let y=a.index,g=a.index+a[0].length-1,w=1,k=g+1,S=-1;while(k<c.length&&w>0){if(c[k]==="(")w++;else if(c[k]===")"){if(w--,w===0){S=k;break}}k++}if(S===-1)continue;let W=c.substring(g+1,S),I=Wt(W);if(!I)continue;let A=y,{arrayExpr:B,itemVar:K}=I,L=S+1,V=1,O=L,Z=/@foreach\s*\(/g,U=/@endforeach/g;while(V>0&&O<c.length){Z.lastIndex=O,U.lastIndex=O;let z=Z.exec(c),N=U.exec(c);if(!N)break;if(z&&z.index<N.index)V++,O=z.index+z[0].length;else{if(V--,V===0){let C=c.substring(L,N.index),E=N.index+11;return{start:A,end:E,arrayExpr:B,itemVar:K,content:C}}O=N.index+11}}}return null}function*x(c,m){let a=c;while(!0){let y=b(a);if(!y)break;let{start:g,end:w,arrayExpr:k,itemVar:S,content:W}=y;try{let I=k.trim(),A;if(h(I))A=p(I,Object.keys(m))(...Object.values(m));else A=d(I,m);let B=!1;if(!Array.isArray(A))if(A instanceof Map)A=Array.from(A),B=!0;else if(A instanceof Set)A=Array.from(A);else if(typeof A==="string")A=Array.from(A);else if(A&&typeof A==="object"&&!(A instanceof Date)&&!(A instanceof RegExp))A=Object.entries(A),B=!0;else{let E=Re(I,i)+u("Foreach",`Error in @foreach: ${I} is not iterable`,n.TYPE_ERROR);a=a.substring(0,g)+E+a.substring(w);continue}let K=e?.loops?.useAltLoopVariable??me,L=S.trim(),V=null,O,Z=!1;if(L.includes("=>")){let E=L.split("=>").map((j)=>j.trim());if(E.length===2&&E[0]&&E[1])V=E[0],O=E[1];else O=L}else if(!L.startsWith("[")&&!L.startsWith("{")&&L.includes(",")){let E=L.split(",").map((j)=>j.trim());if(E.length===2&&E[0]&&E[1])O=E[0],V=E[1],Z=!0;else O=L}else O=L;let U="",z=new Set(oe(`${k} as ${S}`)),N=A,C=m[yo]??new WeakMap;for(let E=0;E<N.length;E++){if(E%16===0)yield;let j=N[E],te={index:E,iteration:E+1,first:E===0,last:E===N.length-1,count:N.length},M={...m,loop:te,$loop:te,[yo]:C};if(Array.isArray(m.__stx_client_signal_names))M.__stx_client_signal_names=m.__stx_client_signal_names.filter((H)=>!z.has(H));if(O.startsWith("[")&&O.endsWith("]")){let H=O.slice(1,-1).split(",").map((T)=>T.trim());if(Array.isArray(j))H.forEach((T,X)=>{if(T)M[T]=j[X]});else M[O]=j}else if(O.startsWith("{")&&O.endsWith("}")){let H=O.slice(1,-1).split(",").map((T)=>T.trim()).filter(Boolean);if(j!==null&&typeof j==="object")H.forEach((T)=>{let X=T.indexOf(":"),Y=(X===-1?T:T.slice(0,X)).trim(),re=X===-1?Y:T.slice(X+1).trim();if(Y&&re)M[re]=j[Y]});else M[O]=j}else M[O]=j;if(V)if(!Z&&B&&Array.isArray(j)&&j.length===2)M[V]=j[0],M[O]=j[1];else M[V]=E;let v=ce(W,M);v=yield*ne(v,M,i,e,!0),v=ge(v,M,i),v=le(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),U+=v,q>=0&&q===J)break}a=a.substring(0,g)+U+a.substring(w)}catch(I){let A=u("Foreach",`Error in @foreach(${k.trim()} as ${S.trim()}): ${I instanceof Error?I.message:String(I)}`,n.EVALUATION_ERROR);a=a.substring(0,g)+A+a.substring(w)}}return a}s=yield*x(s,r),s=we(s,r,i,e);let f=e?.loops?.maxWhileIterations??he;return s=Se(s,r,f),o?s:Os(s)}function xg(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 bo(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=_(o,"(",")",x);if(f===-1)break;let c=xg(o.slice(x+1,f)),m=f+1,a=Bs(o.slice(b),"for","endfor");if(a.length===0)break;let y=a[0].content,g=b+a[0].end;if(!pe(c)){let w=u("For",`Unsafe expression in @for: ${c}`,n.UNSAFE_EXPRESSION);o=o.substring(0,b)+w+o.substring(g),s=!0;continue}try{let w=Oe(c),k=/@(?:for|foreach|if|unless)\s*\(/.test(y);if(w.length>0&&k){let K=ke({forExpr:c,content:y,iterVarNames:w,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),B=Function(...S,"__stxRenderLoopValue",`
|
|
3
3
|
let result = '';
|
|
4
4
|
for (${c}) {
|
|
5
5
|
result += \`${I}\`;
|
|
6
6
|
}
|
|
7
7
|
return result;
|
|
8
|
-
`)(...
|
|
8
|
+
`)(...W,(K,L,V)=>fe(y,K,L,V));o=o.substring(0,b)+B+o.substring(g),s=!0}catch(w){let k=u("For",`Error in @for(${c}): ${w instanceof Error?w.message:String(w)}`,n.EVALUATION_ERROR);o=o.substring(0,b)+k+o.substring(g),s=!0}}return o}function Oe(t){let r=t.trim(),i=r.match(/^(?:const|let|var)\s+(\[[^\]]+\]|\{[^}]+\})\s+(?:of|in)\s+/);if(i){let s=i[1];return s.slice(1,-1).split(",").map((b)=>{let x=b.trim();if(!x)return"";let f=x.indexOf(":");if(f>=0&&s.startsWith("{")){let a=x.slice(f+1).trim(),y=a.indexOf("=");return(y>=0?a.slice(0,y):a).trim()}let c=x.indexOf("="),m=(c>=0?x.slice(0,c):x).trim();return/^[A-Za-z_$][\w$]*$/.test(m)?m:""}).filter(Boolean)}let e=r.match(/^(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s+(?:of|in)\s+/);if(e)return[e[1]];let o=r.match(/^(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=[^;]*;/);if(o)return[o[1]];return[]}function ke(t){let{forExpr:r,content:i,iterVarNames:e,context:o,filePath:s,options:l}=t,b=Object.keys(o),x=Object.values(o),f=s??"inline.stx",c="";return Function(...b,"__renderIteration",`
|
|
9
9
|
for (${r}) {
|
|
10
10
|
if (!__renderIteration([${e.join(", ")}])) break;
|
|
11
11
|
}
|
|
12
|
-
`)(...x,(a)=>{let y={...o};e.forEach((
|
|
12
|
+
`)(...x,(a)=>{let y={...o};e.forEach((W,I)=>{y[W]=a[I]});let g=vg(i,y,f,l,!0);g=ge(g,y,f),g=le(g,y);let w=g.indexOf(Q),k=g.indexOf(ee),S=w<0?k:k<0?w:Math.min(w,k);if(S>=0)g=g.slice(0,S);return c+=P(g,y,f),S<0||S!==w}),c}function Se(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=_(e,"(",")",b);if(x===-1)break;let f=e.slice(b+1,x),c=Bs(e.slice(l),"while","endwhile");if(c.length===0)break;let m=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),w=ue(m),S=Function(...y,"__stxRenderLoopValue",`
|
|
13
13
|
let result = '';
|
|
14
14
|
let maxIterations = ${i}; // Configurable safety limit
|
|
15
15
|
let counter = 0;
|
|
@@ -21,5 +21,5 @@ import{R}from"./chunk-0jdz31q1.js";import{Ie,Wt,oe,F,Nn,ae,P}from"./chunk-b5qzed
|
|
|
21
21
|
result += '<!-- [While Error [1104]]: Maximum iterations (${i}) exceeded in while loop. Configure via options.loops.maxWhileIterations -->';
|
|
22
22
|
}
|
|
23
23
|
return result;
|
|
24
|
-
`)(...g,(
|
|
25
|
-
export{
|
|
24
|
+
`)(...g,(W,I,A)=>fe(m,W,I,A));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{Os,vg,pi,xg};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
`),f=`${r}\x00${JSON.stringify(n)}`,o=g.get(f);if(o&&o.signature===d)return o.standIns;let a=new Map;for(let[e,t]of l){let c=s.relative(r,e);if(!m(e))throw Error(`webModules: ${c} does not exist`);if(!m(t))throw Error(`webModules: ${s.relative(r,t)}, the stand-in for ${c}, does not exist`);if(e===t)throw Error(`webModules: ${c} stands in for itself`);let p=await Bun.file(t).text(),u=new Bun.Transpiler({loader:M(t),target:"browser"});if(s.dirname(t)!==s.dirname(e)){let i=u.scanImports(p).find((h)=>/^\.\.?\//.test(h.path));if(i)throw Error(`webModules: ${s.relative(r,t)} imports ${i.path}, which would resolve from ${s.relative(r,s.dirname(e))||"."}; a stand-in imports relatively only from the directory of the module it replaces`)}let w=u.transformSync(p);for(let i of
|
|
2
|
+
import{is}from"./chunk-neymp1bb.js";import{existsSync as m,statSync as x}from"fs";import s from"path";var g=new Map;function M(r){let n=s.extname(r);if(n===".tsx")return"tsx";if(n===".jsx")return"jsx";if(n===".ts"||n===".mts"||n===".cts")return"ts";return"js"}async function j(r,n){let l=Object.entries(n).map(([e,t])=>[s.resolve(r,e),s.resolve(r,t)]),d=l.map(([e,t])=>{try{return`${e}\x00${t}\x00${x(t).mtimeMs}`}catch{return`${e}\x00${t}\x00-`}}).join(`
|
|
3
|
+
`),f=`${r}\x00${JSON.stringify(n)}`,o=g.get(f);if(o&&o.signature===d)return o.standIns;let a=new Map;for(let[e,t]of l){let c=s.relative(r,e);if(!m(e))throw Error(`webModules: ${c} does not exist`);if(!m(t))throw Error(`webModules: ${s.relative(r,t)}, the stand-in for ${c}, does not exist`);if(e===t)throw Error(`webModules: ${c} stands in for itself`);let p=await Bun.file(t).text(),u=new Bun.Transpiler({loader:M(t),target:"browser"});if(s.dirname(t)!==s.dirname(e)){let i=u.scanImports(p).find((h)=>/^\.\.?\//.test(h.path));if(i)throw Error(`webModules: ${s.relative(r,t)} imports ${i.path}, which would resolve from ${s.relative(r,s.dirname(e))||"."}; a stand-in imports relatively only from the directory of the module it replaces`)}let w=u.transformSync(p);for(let i of is(e))a.set(i,w)}return g.set(f,{signature:d,standIns:a}),a}export{j as loadWebModules};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Nu,Mu,Du,Lu,ju,Bu,Fu,zu,Hu,Uu,yh}from"./chunk-514yg4dr.js";export{Nu as createIslandRegistry,yh as default,Uu as generateIslandManifest,Du as generatePartialHydrationCSS,Bu as hydrateAll,ju as hydrateByStrategy,Lu as hydrateIsland,Fu as isHydrated,zu as onHydrated,Mu as processPartialHydrationDirectives,Hu as processStaticDirectives};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
2
|
+
import"./chunk-jjq7c8s2.js";import"./chunk-vf7tpgqz.js";import"./chunk-858p3hkz.js";import"./chunk-ayrd026n.js";import"./chunk-ex6dne7e.js";import"./chunk-vb609vbj.js";import"./chunk-14df2jzs.js";import"./chunk-qda8tmk9.js";import"./chunk-mr9pp5cf.js";import"./chunk-50zzar2c.js";import{l}from"./chunk-6x5a2w5a.js";import u from"fs";import m from"path";async function d(e,t={}){let s=Date.now(),n={total:0,passed:0,failed:0,new:0,failures:[],duration:0},i=t.snapshotDir||l(e.root,"story","snapshots");await u.promises.mkdir(i,{recursive:!0});let r=e.storyFiles;if(t.filter&&t.filter.length>0)r=r.filter((a)=>t.filter.some((o)=>a.fileName.toLowerCase().includes(o.toLowerCase())));for(let a of r)await h(a,i,t,n);return n.duration=Date.now()-s,n}async function h(e,t,s,n){let i=e.story;if(!i)return;for(let r of i.variants){n.total++;let a=m.join(t,`${e.id}-${r.id}.snap`),o=g(r.source||""),f=await w(a);if(s.update||!f){let p={storyId:e.id,variantId:r.id,component:e.fileName,timestamp:Date.now(),hash:o};if(await u.promises.writeFile(a,JSON.stringify(p,null,2)),!f)n.new++;n.passed++}else try{let p=await u.promises.readFile(a,"utf-8"),c=JSON.parse(p);if(c.hash===o)n.passed++;else n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:"Snapshot mismatch",difference:y(c.hash,o)})}catch(p){n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:`Error reading snapshot: ${p}`})}}}async function x(e,t={}){return(await d(e,{...t,update:!0})).total}function g(e){let t=0;for(let s=0;s<e.length;s++){let n=e.charCodeAt(s);t=(t<<5)-t+n,t=t&t}return t.toString(16)}function y(e,t){if(e===t)return 0;let s=Math.abs(Number.parseInt(e,16)-Number.parseInt(t,16));return Math.min(s/1e6,1)}async function w(e){try{return await u.promises.access(e),!0}catch{return!1}}function F(e){let t=[];if(t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(" STX Story Visual Regression Tests"),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),e.failures.length>0){t.push(" \u274C Failures:"),t.push("");for(let s of e.failures){if(t.push(` \u2022 ${s.component} / ${s.variantId}`),t.push(` ${s.message}`),s.difference!==void 0)t.push(` Difference: ${(s.difference*100).toFixed(2)}%`);t.push("")}}if(t.push(" Summary:"),t.push(` Total: ${e.total}`),t.push(` Passed: ${e.passed} \u2713`),t.push(` Failed: ${e.failed} \u2717`),e.new>0)t.push(` New: ${e.new} \u26A1`);return t.push(` Time: ${e.duration}ms`),t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),t.join(`
|
|
3
3
|
`)}export{F as formatTestResults,d as runVisualTests,x as updateSnapshots};
|
|
@@ -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
|
|
3
|
-
export{
|
|
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 an(){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 $o(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 cn(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 Sa(e,t){if(console.log(""),console.log(` ${b("\u2717")} ${a(b("Error:"))} ${e}`),t)console.log(` ${m(t)}`);console.log("")}function kt(e){console.log(` ${y("\u26A0")} ${y("Warning:")} ${e}`)}function ka(e){console.log(` ${O("\u2139")} ${e}`)}function _a(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 Ro(){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 ln(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 Ca(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 un(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{an,$o,cn,Sa,kt,ka,_a,Ro,ln,Ca,un};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{a}from"./chunk-
|
|
3
|
-
export{
|
|
2
|
+
import{a}from"./chunk-3tcy9r6r.js";import{Uo}from"./chunk-qsnw0qyp.js";import p from"path";async function Om(t={}){let l=performance.now(),s=t.root||process.cwd(),e=await a(s),o=t.ssr?.routeRules??e.routeRules??{};if(Uo(o),!e.ssr&&Object.keys(o).length)throw Error("routeRules require ssr: true and the production server; flat SSG output cannot apply request/cache policies");if(!e.ssr&&(t.ssr?.serverApi??e.serverApi))throw Error("serverApi requires ssr: true; flat SSG output cannot execute API endpoints");let r=e.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${r.toUpperCase()}${e.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let u,n;if(r==="ssg"){let{generateStaticSite:i}=await import("./ssg.js");u=await i({pagesDir:p.join(e.root||".",e.pagesDir||e.build?.pagesDir||"pages"),publicDir:e.publicDir||e.build?.publicDir||"public",outputDir:e.build?.outputDir||"dist",generate404:e.build?.generate404??!0,minify:e.build?.minify??!0,cleanOutput:e.build?.cleanOutput??!0,router:e.router,...t.ssg})}else{let{buildForProduction:i}=await import("./chunk-fb63xppz.js");n=await i({root:s,outputDir:".output",debug:t.debug,...t.ssr})}let d=Math.round(performance.now()-l);return{mode:r,ssg:u,ssr:n,duration:d}}
|
|
3
|
+
export{Om};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{g}from"./chunk-vf7tpgqz.js";import{createHash as j}from"crypto";function C(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var F=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function z(t){return Bun.hash(t).toString(16)}function $c(t,e={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let n=new Map,o=t.replace(F,(r,a,u,l)=>{let c=l.trim();if(!c)return r;if(/\bdata-stx-src=/.test(u))return r;if(e.minify)c=C(c);let i=z(c);if(!n.has(i))n.set(i,c);let f=e.integrity?` data-stx-integrity="sha384-${j("sha384").update(c).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${a}" data-stx-src="/_stx/islands/${i}.js"${f}${u}></script>`}),s=Array.from(n,([r,a])=>({hash:r,code:a}));return{html:o,chunks:s}}var L=new Set(["visible","idle"]);function Rc(t){if(!t.includes("data-stx-src="))return t;let e=new Map,n=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,o;while((o=n.exec(t))!==null)e.set(o[1],o[2]);let s=new Set,r=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,a;while((a=r.exec(t))!==null)if(L.has(e.get(a[1])||""))s.add(a[2]);let u=/<\/head\s*>/iy,l=g(t,(i,f)=>(u.lastIndex=f,u.exec(i)?u.lastIndex:-1))[0]?.start??-1;if(s.size===0||l===-1)return t;let c=Array.from(s).filter((i)=>!t.includes(`rel="prefetch" href="${i}"`)).map((i)=>`<link rel="prefetch" href="${i}" as="script">`).join("");if(!c)return t;return t.slice(0,l)+c+t.slice(l)}import y from"fs";import M from"path";var E="_stx";function _(t){return Bun.hash(t).toString(16).slice(0,8)}function N(t){let e=[],n=(o)=>{for(let s of y.readdirSync(o,{withFileTypes:!0})){let r=M.join(o,s.name);if(s.isDirectory())n(r);else if(s.isFile()&&r.endsWith(".html"))e.push(r)}};if(y.existsSync(t))n(t);return e}var B=[{pattern:/<script\b([^>]*\bdata-stx-runtime\b[^>]*)>([\s\S]*?)<\/script>/gi,prefix:"runtime",extension:"js",contentType:"text/javascript; charset=utf-8",replace:(t)=>`<script data-stx-runtime src="${t}"></script>`},{pattern:/<script\b([^>]*\bdata-stx-router\b[^>]*)>([\s\S]*?)<\/script>/gi,prefix:"router",extension:"js",contentType:"text/javascript; charset=utf-8",replace:(t)=>`<script data-stx-router src="${t}"></script>`},{pattern:/<style\b([^>]*\bdata-css=(?:"generated"|'generated')[^>]*)>([\s\S]*?)<\/style>/gi,prefix:"css",extension:"css",contentType:"text/css; charset=utf-8",replace:(t)=>`<link data-css="generated" rel="stylesheet" href="${t}">`}];function H(t,e=`/${E}`){let n=[],o=new Set,s=0,r=t;for(let a of B)r=r.replace(a.pattern,(u,l,c)=>{if(/(?:^|\s)stx-inline(?:\s|=|$)/i.test(l)||/\b(?:src|href)\s*=/.test(l)||!c.trim())return u;let i=`${a.prefix}.${_(c)}.${a.extension}`;if(!o.has(i))o.add(i),n.push({filename:i,contents:c,contentType:a.contentType});return s+=c.length,a.replace(`${e}/${i}`)});return{html:r,assets:n,bytesInlined:s}}function Ac(t){let e={pages:0,assets:0,bytesInlined:0},n=M.join(t,E),o=new Set;for(let s of N(t)){let r=y.readFileSync(s,"utf8"),{html:a,assets:u,bytesInlined:l}=H(r);if(a===r)continue;for(let c of u){if(o.has(c.filename))continue;o.add(c.filename),y.mkdirSync(n,{recursive:!0}),y.writeFileSync(M.join(n,c.filename),c.contents),e.assets++}y.writeFileSync(s,a),e.bytesInlined+=l,e.pages++}return e}import m from"fs";import T from"path";var O=1024,D=/<(script|style)\b([^>]*)>([\s\S]*?)<\/\1>/gi,P=new Set(["","module","text/javascript","application/javascript","module/javascript"]);function W(t){return Bun.hash(t).toString(16).slice(0,8)}function K(t){let e=[],n=(o)=>{for(let s of m.readdirSync(o,{withFileTypes:!0})){let r=T.join(o,s.name);if(s.isDirectory())n(r);else if(s.isFile()&&r.endsWith(".html"))e.push(r)}};if(m.existsSync(t))n(t);return e}function Y(t,e){let n=t.match(new RegExp(`\\b${e}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s>]+))`,"i"));if(!n)return;return n[2]??n[3]??n[4]??""}function G(t,e,n){if(/(?:^|\s)stx-inline(?:\s|=|$)|\bdata-stx-(?:color-mode-boot|appearance-bootstrap)\b/i.test(e))return!1;if(n.length<O)return!1;if(/\b(?:src|href)\s*=/i.test(e))return!1;if(t.toLowerCase()==="script"){if(!P.has((Y(e,"type")??"").trim().toLowerCase()))return!1;return!0}return!0}function X(t){let e=[];for(let n of t.matchAll(/<template\b[^>]*>[\s\S]*?<\/template>/gi))e.push([n.index,n.index+n[0].length]);return e}function Pc(t){let e={pages:0,assets:0,bytesInlined:0},n=K(t);if(n.length<2)return e;let o=new Map,s=new Map;for(let i of n){let f=m.readFileSync(i,"utf8");o.set(i,f);let R=X(f);for(let p of f.matchAll(D)){let[w,h,d,x]=p;if(!G(h,d,x))continue;if(R.some(([v,A])=>p.index>=v&&p.index<A))continue;let b=`${h.toLowerCase()}\x00${x}`,S=s.get(b);if(S)S.push({file:i,whole:w,tag:h,attrs:d,body:x});else s.set(b,[{file:i,whole:w,tag:h,attrs:d,body:x}])}}let r=[...s.values()].filter((i)=>new Set(i.map((f)=>f.file)).size>1);if(r.length===0)return e;let a=T.join(t,E),u=new Map(o),l=new Map,c=[];for(let i of r){let{tag:f,body:R}=i[0],p=f.toLowerCase()==="script",w=`${p?"chunk":"style"}.${W(R)}.${p?"js":"css"}`;c.push({filename:w,contents:R,contentType:p?"text/javascript; charset=utf-8":"text/css; charset=utf-8"});let h=`/${E}/${w}`;for(let d of i){let x=p?`<script${d.attrs} src="${h}"></script>`:`<link${d.attrs} rel="stylesheet" href="${h}">`,b=u.get(d.file),S=b.replace(d.whole,()=>x);if(S===b)continue;u.set(d.file,S),l.set(d.file,(l.get(d.file)??0)+d.body.length)}}m.mkdirSync(a,{recursive:!0});for(let i of c)m.writeFileSync(T.join(a,i.filename),i.contents),e.assets++;for(let[i,f]of u){if(f===o.get(i))continue;m.writeFileSync(i,f),e.pages++,e.bytesInlined+=l.get(i)??0}return e}import k from"fs";import I from"path";var Z="layout-types.d.ts";function J(t){let e=[],n=(o,s)=>{let r;try{r=k.readdirSync(o,{withFileTypes:!0})}catch{return}for(let a of r){if(a.name.startsWith("."))continue;let u=I.join(o,a.name);if(a.isDirectory())n(u,s?`${s}/${a.name}`:a.name);else if(a.isFile()&&a.name.endsWith(".stx")&&a.name!=="_layout.stx"){let l=a.name.slice(0,-4);e.push(s?`${s}/${l}`:l)}}};return n(t,""),e.sort()}function U(t){let e=["// Auto-generated by stx \u2014 do not edit.","//","// Makes `definePageMeta({ layout })` reject a name with no layout behind it.","// Include this file in your tsconfig (it lives in the stx state directory,","// `.stx/` by default) for the check to apply.",""];if(t.length===0)return e.push("// No layouts found \u2014 `layout` stays typed as `string`.","export {}",""),e.join(`
|
|
3
3
|
`);return e.push("declare module '@stacksjs/stx' {"," interface KnownLayouts {",...t.map((n)=>` '${n}': true`)," }","}","","export {}",""),e.join(`
|
|
4
|
-
`)}function
|
|
5
|
-
export{
|
|
4
|
+
`)}function Ic(t,e){if(!t)return[];let n=I.isAbsolute(t)?t:I.resolve(process.cwd(),t),o=J(n),s=U(o),r=I.join(e,Z);try{if(k.existsSync(r)&&k.readFileSync(r,"utf8")===s)return o;k.mkdirSync(e,{recursive:!0}),k.writeFileSync(r,s)}catch{}return o}
|
|
5
|
+
export{$c,Rc,Ac,Pc,Ic};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import n from"fs";import a from"path";import{fileURLToPath as s}from"url";var i;function
|
|
3
|
-
export{
|
|
2
|
+
import n from"fs";import a from"path";import{fileURLToPath as s}from"url";var i;function mt(){if(i)return i;let t="unknown";try{t=String(JSON.parse(n.readFileSync(new URL("../package.json",import.meta.url),"utf8")).version)}catch{}if(import.meta.url.endsWith(".ts"))try{let o=a.dirname(s(import.meta.url)),e=0;for(let r of n.readdirSync(o,{recursive:!0,withFileTypes:!0}))if(r.isFile()&&r.name.endsWith(".ts"))e=Math.max(e,n.statSync(a.join(r.parentPath,r.name)).mtimeMs);t+=`+src.${Math.trunc(e)}`}catch{}return i=t,t}
|
|
3
|
+
export{mt};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
`);if(!await Bun.file(o).exists()||await Bun.file(o).text()!==f)await Bun.write(o,f);return o}async function
|
|
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,...
|
|
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
|
|
6
|
-
export{
|
|
2
|
+
import{ke}from"./chunk-5fdc8pej.js";import{Qe,z}from"./chunk-14df2jzs.js";import{tl}from"./chunk-txk2z7v0.js";import{l}from"./chunk-6x5a2w5a.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 kn(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 ni(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}=ke(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
|
+
`);if(!await Bun.file(o).exists()||await Bun.file(o).text()!==f)await Bun.write(o,f);return o}async function ri(s,c,o={}){let i=kn(s,o);await ni(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,...ke(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 si(s,c){return E(c,async(o)=>(await import(I(m.resolve(s,o.filePath)).href)).default)}async function dy(s,c){if(!c)return async()=>null;let o=c===!0?{}:c,i=kn(s,o);return await ni(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=kn(s,o);await ni(s,t);let{loadStxConfig:e}=await import("./chunk-hxabvt31.js"),a=z((await e(s)).runtimeConfig);return await Qe(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 oi(s,c,o){if(tl(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{kn,ni,ri,si,dy,oi};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{c}from"./chunk-
|
|
2
|
+
import{c}from"./chunk-p4twxjfs.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
|
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{sg,og,$e,ig,Oc,bn,wn,ly,Nc,vn,vr,ag,cg,lg,Es,ug,dg,Mc,xn,pg,Sn,Dc,uy}from"./chunk-3br07y64.js";import"./chunk-xpsg91dh.js";import"./chunk-s1x2pc9b.js";import"./chunk-2mv29s6w.js";import"./chunk-3tcy9r6r.js";import"./chunk-50zzar2c.js";import"./chunk-mr9pp5cf.js";import"./chunk-txk2z7v0.js";import"./chunk-ktv65e3n.js";import"./chunk-5fdc8pej.js";import"./chunk-vb609vbj.js";import"./chunk-qda8tmk9.js";import"./chunk-14df2jzs.js";import"./chunk-vf7tpgqz.js";import"./chunk-ayrd026n.js";import"./chunk-ex6dne7e.js";import"./chunk-jjq7c8s2.js";import"./chunk-858p3hkz.js";export{vr as MODULE_SPECIFIER_PREFIX,Mc as assertBundleBuildCanSettle,sg as bundleCacheDir,og as bundleCacheEntryLimit,uy as bundleClientEntriesSplit,Sn as bundleClientScript,wn as clearBundleFailures,$e as clientBundleDependencies,bn as getBundleFailures,vn as hasUserImports,dg as isWithinBundlerCallback,xn as moduleSubstitutionKey,cg as normalizeRegistrySpecifiers,pg as queueClientBundleBuild,Oc as recordBundleFailure,ag as registryIdForPath,Nc as resolveBundlerFallback,lg as rewriteRegistryImports,ly as setBundlerFallbackMode,ig as shouldLogBundlerDiagnostics,Dc as tempBuildName,Es as withModuleSubstitutes,ug as withinBundlerCallback};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{nc,rc,sc,oc,cy}from"./chunk-1baxccfq.js";import"./chunk-mnpfvxpa.js";import"./chunk-2szhk8mh.js";import"./chunk-1bf0grbf.js";import"./chunk-sbr3wg75.js";import"./chunk-m390z8w8.js";import"./chunk-1a2c4pv8.js";import"./chunk-zaj3nnvv.js";import"./chunk-d69k67bn.js";import"./chunk-xakqpa4z.js";import"./chunk-whnzf9hn.js";import"./chunk-fjpt8arw.js";import"./chunk-3aayrnbh.js";import"./chunk-v1x96kjr.js";import"./chunk-p0xqm2ne.js";import"./chunk-fwxgzktt.js";import"./chunk-2mv29s6w.js";import"./chunk-3tcy9r6r.js";import"./chunk-50zzar2c.js";import"./chunk-mr9pp5cf.js";import"./chunk-txk2z7v0.js";import"./chunk-ktv65e3n.js";import"./chunk-5fdc8pej.js";import"./chunk-vb609vbj.js";import"./chunk-qda8tmk9.js";import"./chunk-14df2jzs.js";import"./chunk-vf7tpgqz.js";import"./chunk-ayrd026n.js";import"./chunk-ex6dne7e.js";import"./chunk-jjq7c8s2.js";import"./chunk-858p3hkz.js";export{nc as buildNative,cy as default,rc as findCraftBinary,oc as getAvailableFormats,sc as getAvailableTargets};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Sr,i}from"./chunk-sbr3wg75.js";import"./chunk-m390z8w8.js";import"./chunk-1a2c4pv8.js";import"./chunk-zaj3nnvv.js";import"./chunk-d69k67bn.js";import"./chunk-xakqpa4z.js";import"./chunk-whnzf9hn.js";import"./chunk-fjpt8arw.js";import"./chunk-3aayrnbh.js";import{Pe}from"./chunk-v1x96kjr.js";import"./chunk-p0xqm2ne.js";import"./chunk-fwxgzktt.js";import"./chunk-2mv29s6w.js";import"./chunk-3tcy9r6r.js";import"./chunk-50zzar2c.js";import"./chunk-mr9pp5cf.js";import"./chunk-txk2z7v0.js";import"./chunk-ktv65e3n.js";import"./chunk-5fdc8pej.js";import{Ke,uo,po}from"./chunk-vb609vbj.js";import"./chunk-qda8tmk9.js";import"./chunk-14df2jzs.js";import"./chunk-vf7tpgqz.js";import"./chunk-ayrd026n.js";import"./chunk-ex6dne7e.js";import"./chunk-jjq7c8s2.js";import"./chunk-858p3hkz.js";export{Sr as buildModulesTag,Pe as injectRouterScript,i as processDirectives,uo as processJsonDirective,po as processOnceDirective,Ke as validateClientScript};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
export{
|
|
2
|
+
import{U,tt}from"./chunk-vf7tpgqz.js";var o=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function u(t,e,r){let i={fullTag:r,content:e,attrs:t};if(/\bserver\b/.test(t))return{...i,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...i,type:"client"};if(o.test(e))return{...i,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...i,type:"client"};return{...i,type:"server"}}var S=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function yn(t){let e=[],r=[],i=[],c=0;while(c<t.length){let s=t.indexOf("<",c);if(s===-1)break;let p=tt(t,s);if(p>s){c=p;continue}let a=U(t,s);if(a>s){let f=t.slice(s,a),l=S.exec(f);if(l){let n=u(l[1],l[2],f);switch(n.type){case"signals":e.push(n);break;case"client":r.push(n);break;case"server":i.push(n);break}}c=a;continue}c=s+(t.startsWith("<!--",s)?4:1)}return{signals:e,client:r,server:i}}
|
|
3
|
+
export{yn};
|