@stacksjs/stx 0.2.90 → 0.2.92
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 +1 -1
- package/dist/assets.js +1 -1
- package/dist/build-mode-detector.js +1 -1
- package/dist/build-views.js +1 -1
- package/dist/build.js +1 -1
- package/dist/builtins/index.js +1 -1
- package/dist/caching.js +1 -1
- package/dist/{chunk-fk6ted7p.js → chunk-14kfmww0.js} +1 -1
- package/dist/{chunk-7m6jbrky.js → chunk-3ewtm19c.js} +1 -1
- package/dist/{chunk-xnf61ake.js → chunk-646pxdd1.js} +1 -1
- package/dist/{chunk-vbysnq00.js → chunk-6t76k6ry.js} +1 -1
- package/dist/{chunk-2hnv9414.js → chunk-7bd8bw2z.js} +1 -1
- package/dist/{chunk-nsbwxkj5.js → chunk-87rkm7qf.js} +1 -1
- package/dist/{chunk-j55xkgq8.js → chunk-8fhv0xaw.js} +1 -1
- package/dist/{chunk-pthx7bxa.js → chunk-9tksycj5.js} +1 -1
- package/dist/{chunk-0n11c9hw.js → chunk-9w7021bx.js} +1 -1
- package/dist/{chunk-j0mbt7fb.js → chunk-ewytyv0p.js} +1 -1
- package/dist/{chunk-y248bdr9.js → chunk-fnqf7293.js} +1 -1
- package/dist/{chunk-sx35cb80.js → chunk-ftzqtv1k.js} +1 -1
- package/dist/{chunk-tqzv7g2r.js → chunk-g22tv0ed.js} +1 -1
- package/dist/{chunk-4bpb2es7.js → chunk-g9gksn68.js} +1 -1
- package/dist/{chunk-crjrbczd.js → chunk-gfsk93gv.js} +2 -2
- package/dist/{chunk-w7bgs9ze.js → chunk-hz7qnpx1.js} +1 -1
- package/dist/{chunk-4e3yxhkd.js → chunk-mqnymcn5.js} +1 -1
- package/dist/{chunk-bdp5z6mt.js → chunk-ms9rebfj.js} +1 -1
- package/dist/{chunk-4wsmprpm.js → chunk-nwfa5766.js} +10 -10
- package/dist/{chunk-krxvy5wr.js → chunk-qhzdkgg3.js} +1 -1
- package/dist/{chunk-syffx53n.js → chunk-r5sggjdv.js} +1 -1
- package/dist/{chunk-t88cgftn.js → chunk-rhyxeb33.js} +1 -1
- package/dist/chunk-tzd81m7r.js +1539 -0
- package/dist/{chunk-gfj0a29j.js → chunk-vy0k2prz.js} +1 -1
- package/dist/{chunk-xxgdw2s8.js → chunk-zx43nkm1.js} +1 -1
- package/dist/cli.js +478 -478
- package/dist/client-script.js +1 -1
- package/dist/component-processing.js +1 -1
- package/dist/component-registry.js +1 -1
- package/dist/component-renderer.js +1 -1
- package/dist/components.js +1 -1
- package/dist/config.js +1 -1
- package/dist/dev-server/crosswind.js +1 -1
- package/dist/dev-server/index.js +1 -1
- package/dist/dev-server/serve-app.js +1 -1
- package/dist/dev-server/serve-file.js +1 -1
- package/dist/dev-server/serve-markdown.js +1 -1
- package/dist/dev-server/serve-multi.js +1 -1
- package/dist/dev-server.js +1 -1
- package/dist/docs.js +1 -1
- package/dist/dynamic-components.js +1 -1
- package/dist/expressions.js +1 -1
- package/dist/includes.js +1 -1
- package/dist/index.js +1 -1
- package/dist/interactive.js +1 -1
- package/dist/js-ts.js +1 -1
- package/dist/loops.js +1 -1
- package/dist/markdown.js +1 -1
- package/dist/middleware.js +1 -1
- package/dist/plugin.js +1 -1
- package/dist/process.js +1 -1
- package/dist/production-builder.js +1 -1
- package/dist/production-server.js +1 -1
- package/dist/pwa/index.js +1 -1
- package/dist/pwa/offline.js +1 -1
- package/dist/pwa.js +318 -318
- package/dist/reactive.js +1 -1
- package/dist/render.js +1 -1
- package/dist/runtime-injection.js +1 -1
- package/dist/serve.js +1 -1
- package/dist/signal-processing.js +1 -1
- package/dist/site-builder/build.js +1 -1
- package/dist/site-builder/index.js +1 -1
- package/dist/slots.js +1 -1
- package/dist/ssg.js +310 -310
- package/dist/ssr.js +1 -1
- package/dist/store-loader.js +1 -1
- package/dist/story/cli.js +1 -1
- package/dist/story/commands/dev.js +1 -1
- package/dist/story/commands/index.js +1 -1
- package/dist/story/index.js +1 -1
- package/dist/story/renderer.js +1 -1
- package/dist/story/server.js +1 -1
- package/dist/story/visual-testing.js +1 -1
- package/dist/streaming.js +1 -1
- package/dist/template-compiler.js +1 -1
- package/dist/template-hydrator.js +1 -1
- package/dist/testing.js +1 -1
- package/dist/utils.js +1 -1
- package/dist/variable-extractor.js +1 -1
- package/dist/web-components.js +1 -1
- package/package.json +6 -7
- package/dist/chunk-qjn5xmeh.js +0 -1539
- /package/dist/{chunk-29qrr0nc.js → chunk-0t75nh4z.js} +0 -0
- /package/dist/{chunk-fze9db64.js → chunk-pcngkyjr.js} +0 -0
- /package/dist/{chunk-tfjem6g3.js → chunk-r3cxnszy.js} +0 -0
- /package/dist/{chunk-04jkv9xx.js → chunk-v0s45ek4.js} +0 -0
- /package/dist/{chunk-dcpbe8a1.js → chunk-wbrqpv9f.js} +0 -0
|
@@ -0,0 +1,1539 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Sv as e4}from"./chunk-ktpc2rc4.js";import{dw as a4}from"./chunk-9p45wwff.js";import{fw as W1}from"./chunk-m911bf2b.js";import{mw as s4}from"./chunk-a50svyjn.js";import{nw as L0}from"./chunk-7aph6rw7.js";import{pw as o1}from"./chunk-y92w0240.js";import{qw as D4,rw as E4,sw as M4,tw as y4,uw as k3,vw as N3}from"./chunk-v9199ywv.js";import{Cw as o4}from"./chunk-a4zj7qpt.js";import{Dw as r4}from"./chunk-zepv7y44.js";import{Jw as Y4,Kw as Z4}from"./chunk-v0s45ek4.js";import{Ow as C4}from"./chunk-2rd0ykrg.js";import{Tw as I3}from"./chunk-6sx4d083.js";import{Ww as i0}from"./chunk-r7d26vjj.js";import{ax as n4}from"./chunk-ccgmxmjk.js";import{cx as n1,dx as r1,ex as Q5,fx as a1,gx as J5,hx as z5}from"./chunk-593x2ccf.js";import{lx as T3}from"./chunk-1bzckhs2.js";import{nx as R3}from"./chunk-a2xzs4kd.js";import{$x as M3,ay as P0}from"./chunk-5tv1swsr.js";import{dy as X5}from"./chunk-8g0jb444.js";import{ey as O1,fy as Q3,gy as F4,hy as p0,iy as K1,jy as q1}from"./chunk-h1035wzj.js";import{Cy as p4}from"./chunk-ms6793rw.js";import{Fy as v4}from"./chunk-zr8631g4.js";import{Jy as l4,Ky as c4,Ly as i4}from"./chunk-c9f5k95v.js";import{Vy as u4}from"./chunk-9fj7hpwa.js";import{jz as T4,kz as F3}from"./chunk-rdaavfsg.js";import{Az as Z5,Bz as $5,xz as t4,zz as Y5}from"./chunk-tavtph8x.js";import{Lz as b4}from"./chunk-0t75nh4z.js";import{cA as x4,eA as h4}from"./chunk-fh1d8bxd.js";import{rA as d4}from"./chunk-w719zps0.js";import{tA as m4}from"./chunk-eghdf4qq.js";import{GA as R4,uA as t0,vA as v3}from"./chunk-xgmza98t.js";import{KA as T0,LA as P4,MA as f4,NA as g4}from"./chunk-zxxt0c9q.js";import{XA as t3,YA as M1}from"./chunk-t7ghqd7e.js";import{$A as E1}from"./chunk-xmjedbkt.js";import{dB as H0,hB as g0}from"./chunk-gcsqn7x9.js";import{iB as k4,kB as w0,lB as N4}from"./chunk-7t4hkmxb.js";import{sB as f0,vB as I4}from"./chunk-pjaa8q7x.js";import{wB as Y1,yB as Z1}from"./chunk-b0w1cm1s.js";import{FB as q0}from"./chunk-jm460jxs.js";import{NB as U5}from"./chunk-h6s1thg6.js";import{RB as w3}from"./chunk-yssvz8zs.js";import{SB as v1}from"./chunk-rkr7cgs8.js";import{TB as g1}from"./chunk-md4j8nch.js";import{UB as u1}from"./chunk-qvmrwh8n.js";import{VB as x1}from"./chunk-3rgj1qn6.js";import{XB as l1}from"./chunk-zvyc82ke.js";import{YB as d1}from"./chunk-1w3354fv.js";import{ZB as m1}from"./chunk-sd2c11bp.js";import{$B as h1}from"./chunk-sk1gmrr8.js";import{bC as f1}from"./chunk-9ezvda3j.js";import{cC as P1}from"./chunk-c23697dp.js";import{hC as m3,jC as Y0,kC as t,oC as B0,pC as e,rC as $1}from"./chunk-p5j0686t.js";import{KC as S4}from"./chunk-bg1xym0q.js";import{VC as V4,bD as W3,cD as L3}from"./chunk-08ncwhv7.js";import{fD as A4}from"./chunk-6jhqq7es.js";import{lD as B3,mD as O3,nD as V3,oD as A3,pD as w4}from"./chunk-r1m8g439.js";import{jE as g}from"./chunk-6r70w54p.js";import D0 from"path";import h0 from"fs";import i6 from"fs";import C from"path";var C0={},$3=new Map;function _5(Y){let Q=$3.get(Y);if(!Q){let $=Y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");Q=new RegExp(`:${$}(?!\\w)`,"g"),$3.set(Y,Q)}return Q.lastIndex=0,Q}var s0={uppercase:(Y,Q)=>{return Y!==void 0&&Y!==null?String(Y).toUpperCase():""},lowercase:(Y,Q)=>{return Y!==void 0&&Y!==null?String(Y).toLowerCase():""},capitalize:(Y,Q)=>{if(Y===void 0||Y===null)return"";let $=String(Y);return $.charAt(0).toUpperCase()+$.slice(1)},number:(Y,Q,$=0)=>{if(Y===void 0||Y===null)return"";try{let X=Number(Y);return Number.isNaN(X)?"":X.toFixed(Number.parseInt(String($),10))}catch{return""}},fmt:(Y,Q,$="en-US")=>{if(Y===void 0||Y===null)return"";try{let X=Number(Y);if(Number.isNaN(X))return String(Y);return X.toLocaleString($)}catch{return String(Y)}},join:(Y,Q,$=",")=>{if(!Array.isArray(Y))return"";return Y.join(String($))},escape:(Y,Q)=>{if(Y===void 0||Y===null)return"";return n0(String(Y))},translate:(Y,Q,$={})=>{if(!Q||!Q.__translations)return Y;let X=Q.__translations,J=Q.__i18nConfig?.fallbackToKey??!0,Z=String(Y).split("."),z=X;for(let U of Z){if(z===void 0||z===null)break;z=z[U]}if(z===void 0||z===null)return J?Y:"";let G=String(z);return Object.entries($).forEach(([U,_])=>{G=G.replace(_5(U),String(_))}),G},t:(Y,Q,$={})=>{return s0.translate(Y,Q,$)},truncate:(Y,Q,$=50,X="...")=>{if(Y===void 0||Y===null)return"";let J=String(Y);if(J.length<=$)return J;if($<=X.length)return X.substring(0,$);return J.substring(0,$-X.length)+X},date:(Y,Q,$="short",X="en-US")=>{if(Y===void 0||Y===null)return"";try{let J=Y instanceof Date?Y:new Date(Y);if(Number.isNaN(J.getTime()))return String(Y);let Z={short:{dateStyle:"short"},medium:{dateStyle:"medium"},long:{dateStyle:"long"},full:{dateStyle:"full"},time:{timeStyle:"short"},datetime:{dateStyle:"short",timeStyle:"short"},iso:{}};if($==="iso")return J.toISOString();return new Intl.DateTimeFormat(X,Z[$]||Z.short).format(J)}catch{return String(Y)}},currency:(Y,Q,$="USD",X="en-US")=>{if(Y===void 0||Y===null)return"";try{let J=Number(Y);if(Number.isNaN(J))return String(Y);return new Intl.NumberFormat(X,{style:"currency",currency:$}).format(J)}catch{return String(Y)}},pluralize:(Y,Q,$,X)=>{let J=Number(Y);if(Number.isNaN(J))return $;let Z=X||`${$}s`;return J===1?$:Z},first:(Y,Q)=>{if(Y===void 0||Y===null)return"";if(Array.isArray(Y))return Y.length===0?"":Y[0];return String(Y).charAt(0)},last:(Y,Q)=>{if(Y===void 0||Y===null)return"";if(Array.isArray(Y))return Y.length===0?"":Y[Y.length-1];let $=String(Y);return $.charAt($.length-1)},length:(Y,Q)=>{if(Y===void 0||Y===null)return 0;if(Array.isArray(Y)||typeof Y==="string")return Y.length;if(Y instanceof Map||Y instanceof Set)return Y.size;if(typeof Y==="object")return Object.keys(Y).length;return 0},json:(Y,Q,$=!1)=>{if(Y===void 0)return"undefined";if(Y===null)return"null";try{return $?JSON.stringify(Y,null,2):JSON.stringify(Y)}catch{return String(Y)}},default:(Y,Q,$="")=>{return Y===void 0||Y===null||Y===""?$:Y},reverse:(Y,Q)=>{if(Y===void 0||Y===null)return"";if(Array.isArray(Y))return[...Y].reverse();return String(Y).split("").reverse().join("")},slice:(Y,Q,$=0,X)=>{if(Y===void 0||Y===null)return"";if(Array.isArray(Y)||typeof Y==="string")return Y.slice($,X);return Y},replace:(Y,Q,$,X="")=>{if(Y===void 0||Y===null)return"";let J=$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return String(Y).replace(new RegExp(J,"g"),()=>X)},stripTags:(Y,Q)=>{if(Y===void 0||Y===null)return"";return String(Y).replace(/<[^>]*>/g,"")},urlencode:(Y,Q)=>{if(Y===void 0||Y===null)return"";return encodeURIComponent(String(Y))},abs:(Y,Q)=>{let $=Number(Y);return Number.isNaN($)?0:Math.abs($)},round:(Y,Q,$=0)=>{let X=Number(Y);if(Number.isNaN(X))return 0;let J=10**$;return Math.round(X*J)/J}};function W5(Y,Q){if(Y in s0)console.warn(`Filter "${Y}" already exists as a built-in filter. Custom filter will take precedence.`);C0[Y]=Q}function I7(Y){for(let[Q,$]of Object.entries(Y))W5(Q,$)}function L5(){return{...s0,...C0}}function k7(){for(let Y of Object.keys(C0))delete C0[Y]}function n0(Y){return Y.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function v0(Y){let Q=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,$;while(($=Q.exec(Y))!==null){let X=$[1];if(/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/.test(X))return!0}if(/@(if|for|show)\s*=\s*["'][^"']*\(\s*\)/.test(Y))return!0;if(/@for\s*=\s*["'][^"']*\s+(?:in|of)\s+[^"']*\(\s*\)/.test(Y))return!0;if(/(?:^|[\s"'])(?::|x-)(?:for|if|else-if|else|show|text|html|model|bind)\b/.test(Y))return!0;return!1}function X3(Y,Q){let $=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined","NaN","Infinity","isNaN","isFinite","window","document","console"],X=Y.replace(/'[^']*'/g,"").replace(/"[^"]*"/g,""),J="",Z=!1,z=0;for(let _=0;_<X.length;_++){let K=X[_];if(!Z&&K==="`"){Z=!0,z=0;continue}if(Z){if(K==="`"&&z===0){Z=!1;continue}if(K==="$"&&X[_+1]==="{"){z++,_++;continue}if(K==="}"&&z>0){z--;continue}continue}J+=K}X=J;let G=/\b([a-zA-Z_$][a-zA-Z0-9_$]*)\b/g,U;while((U=G.exec(X))!==null){let _=U[1];if(!X.substring(0,U.index).trimEnd().endsWith(".")){if(!$.includes(_)&&!(_ in Q))return!1}}return!0}function B5(Y,Q){let $=Y;return $=$.replace(/\{!!([\s\S]*?)!!\}/g,(X,J)=>{try{let Z=K0(J,Q);if(Z===void 0)return X;return Z===null?"":String(Z)}catch{return X}}),$=$.replace(/\{\{([\s\S]*?)\}\}/g,(X,J)=>{let Z=J.trim();if(/^__[A-Z_]+__$/.test(Z))return X;try{let z=K0(J,Q);if(z===void 0)return X;return JSON.stringify(z)}catch{return X}}),$}function N7(Y,Q,$={}){return Y.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(X,J,Z)=>{if(/\bsrc\s*=/.test(J))return X;if(/\bdata-raw\b/.test(J))return X;if(/\btype\s*=\s*["']application\/json["']/.test(J))return X;if($.skipServer&&/\bserver\b/.test(J))return X;let z=B5(Z,Q);return`<script${J}>${z}</script>`})}function W0(Y,Q,$,X){let J=Y,Z=(K,j)=>{let W=Q3(K,j);if(W===-1)return-1;return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(K.slice(j,W))?-1:W},z=(K,j,W,q)=>{let H=W.length,{output:L,tokens:O}=p0(K,j,(V,B)=>q(H+B));return W.push(...O),L},G=[];J=z(J,Z,G,(K)=>`<!--__STX_STYLE_${K}__-->`);let U=[];J=z(J,O1,U,(K)=>`<!--__STX_SCRIPT_EXPR_${K}__-->`);let _=X?.forceSignals===!0||v0(Y);J=J.replace(/\{\{\{([\s\S]*?)\}\}\}/g,(K,j,W)=>{try{let q=K0(j,Q);return q!==void 0&&q!==null?String(q):""}catch(q){let H=q instanceof Error?q.message:String(q);return p("Expression",`Error evaluating: {{{ ${j.trim()}}}}: ${H}`,$,Y,W,K)}}),J=J.replace(/\{!!([\s\S]*?)!!\}/g,(K,j,W)=>{try{let q=K0(j,Q);if(q===void 0&&Q.__stx_buildMode==="compile")return i0("raw",j.trim());return q!==void 0&&q!==null?String(q):""}catch(q){if(Q.__stx_buildMode==="compile")return i0("raw",j.trim());let H=q instanceof Error?q.message:String(q);return p("Expression",`Error evaluating: {!! ${j.trim()} !!}: ${H}`,$,Y,W,K)}}),J=z(J,O1,U,(K)=>`<!--__STX_SCRIPT_EXPR_${K}__-->`),J=z(J,Z,G,(K)=>`<!--__STX_STYLE_${K}__-->`),J=J.replace(/\{\{([\s\S]*?)\}\}/g,(K,j,W)=>{let q=j.trim(),H=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined"],L=/^([a-zA-Z_$][a-zA-Z0-9_$]*)/,V=q.match(L)?.[1],B=V&&((V in Q)||H.includes(V)),A=/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/,w=q.match(A),F=w&&!H.includes(w[1])&&!(w[1]in Q);if(/^__[A-Z_]+__$/.test(q))return"";try{let N=K0(j,Q);if(N===void 0&&_&&!X3(q,Q))return K;if(N===void 0&&Q.__stx_buildMode==="compile"&&!_)return i0("expr",q);return N!==void 0&&N!==null?n0(String(N)):""}catch(N){if(_&&!X3(q,Q))return K;if(F)return K;let I=N instanceof Error?N.message:String(N);return p("Expression",`Error evaluating: {{ ${q} }}: ${I}`,$,Y,W,K)}});for(let K=0;K<U.length;K++)J=J.replace(`<!--__STX_SCRIPT_EXPR_${K}__-->`,()=>U[K]);for(let K=0;K<G.length;K++)J=J.replace(`<!--__STX_STYLE_${K}__-->`,()=>G[K]);return J}function O5(Y,Q,$){if(!Q.trim())return Y;let X=Y,J=Q.trim();while(J.length>0){let Z=J.match(/^(\w+)/);if(!Z)break;let z=Z[1];J=J.substring(z.length).trim();let G=C0[z]||s0[z];if(!G)throw Error(`Filter not found: ${z}. Available filters: ${Object.keys(L5()).join(", ")}`);let U=[];if(J.startsWith(":")){let _=J.match(/^:([^|\s]+)/);if(_){let K=_[1].trim();try{let j=Number(K);U=[Number.isNaN(j)?K:j]}catch{U=[K]}J=J.substring(_[0].length).trim()}}else if(J.startsWith("(")){let _=1,K=1;while(_>0&&K<J.length){if(J[K]==="(")_++;if(J[K]===")")_--;K++}if(_===0){let j=J.substring(1,K-1).trim();if(j)try{if(j.startsWith("{")&&j.endsWith("}"))U=[K0(`(${j})`,$,!0)];else{let W=[],q="",H=null,L=0,O=0,V=0,B=!1;for(let A=0;A<j.length;A++){let w=j[A];if(B){q+=w,B=!1;continue}if(w==="\\"){q+=w,B=!0;continue}if(H){if(q+=w,w===H)H=null;continue}if(w==='"'||w==="'"||w==="`"){H=w,q+=w;continue}if(w==="(")L++;else if(w===")")L--;else if(w==="[")O++;else if(w==="]")O--;else if(w==="{")V++;else if(w==="}")V--;if(w===","&&L===0&&O===0&&V===0){W.push(q),q="";continue}q+=w}if(q)W.push(q);U=W.map((A)=>{let w=A.trim();return K0(w,$,!0)})}}catch{U=[j]}J=J.substring(K).trim()}}try{X=G(X,$,...U)}catch(_){let K=_ instanceof Error?_.message:String(_);throw Error(`Error applying filter '${z}': ${K}`)}if(J.startsWith("|"))J=J.substring(1).trim();else break}return X}function V5(Y){let Q=!1,$="",X=0,J=0,Z=0,z=!1;for(let G=0;G<Y.length;G++){let U=Y[G],_=Y[G+1];if(Q&&z){z=!1;continue}if(Q&&U==="\\"){z=!0;continue}if(z=!1,(U==='"'||U==="'"||U==="`")&&!z){if(!Q)Q=!0,$=U;else if(U===$)Q=!1,$="";continue}if(Q&&$==="`"&&U==="$"&&_==="{"){let K=1;G+=2;while(G<Y.length&&K>0){if(Y[G]==="{")K++;else if(Y[G]==="}")K--;if(K>0)G++}continue}if(Q)continue;if(U==="(")X++;else if(U===")")X--;else if(U==="[")J++;else if(U==="]")J--;else if(U==="{")Z++;else if(U==="}")Z--;if(U==="|"&&X===0&&J===0&&Z===0){if(_==="|"){G++;continue}if(_==="="){G++;continue}return G}}return-1}function K0(Y,Q,$=!1){try{let X=Y.trim(),J=V5(X);if(J>0){let Z=X.substring(0,J).trim(),z=X.substring(J+1).trim(),G=K0(Z,Q,!0);return O5(G,z,Q)}if(!t(X)){if(!$)console.warn(`Potentially unsafe expression detected, using safe evaluator: ${X}`);return Y0(X,Q)}try{let Z=Object.keys(Q),z=Object.values(Q);return e(X,Z)(...z)}catch{return Y0(X,Q)}}catch(X){if(X instanceof ReferenceError){let J=/(\b\w+)\s+is not defined/.exec(X.message);if(J){let Z=J[1],z=A5(Z,Object.keys(Q));if(z&&z!==Z)X.message=`${X.message} \u2014 did you mean '${z}'?`}}if(!$)console.error(`Error evaluating expression: ${Y}`,X);throw X}}function A5(Y,Q){let $=null;for(let J of Q){if(J===Y)continue;let Z=w5(Y,J);if($===null||Z<$.dist)$={key:J,dist:Z}}if(!$)return null;let X=Math.max(Y.length,$.key.length);if($.dist<=2||$.dist/X<=0.35)return $.key;return null}function w5(Y,Q){if(Y===Q)return 0;if(Y.length===0)return Q.length;if(Q.length===0)return Y.length;let[$,X]=Y.length<Q.length?[Y,Q]:[Q,Y],J=Array($.length+1),Z=Array($.length+1);for(let z=0;z<=$.length;z++)J[z]=z;for(let z=1;z<=X.length;z++){Z[0]=z;for(let G=1;G<=$.length;G++){let U=$[G-1]===X[z-1]?0:1;Z[G]=Math.min(Z[G-1]+1,J[G]+1,J[G-1]+U)}for(let G=0;G<=$.length;G++)J[G]=Z[G]}return J[$.length]}function J3(Y){if(!Y)return"";return Y.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'").replace(/&/g,"&")}import X0 from"path";var U3=0,F5=0;function r0(Y){return Y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function z3(Y,Q){let $=Y.match(new RegExp(`${Q}\\s*=\\s*"([^"]*)"`,"i"));if($)return $[1];let X=Y.match(new RegExp(`${Q}\\s*=\\s*'([^']*)'`,"i"));if(X)return X[1];return null}function R5(Y){let Q=[],$=/<([a-z][a-z0-9-]*)\s+([^>]*x-data\s*=\s*(?:"[^"]*"|'[^']*')[^>]*)>/gi,X;while((X=$.exec(Y))!==null){let[J,Z,z]=X,G=X.index,U=z3(z,"x-data");if(!U)continue;let _=`__stx_scope_${U3++}`,K=z3(z,"x-init"),j=T5(Y,Z,G+J.length),W=Y.slice(G,j.endIndex),q=I5(W);Q.push({id:_,selector:`[data-stx-scope="${_}"]`,stateExpr:U,initExpr:K,bindings:[],refs:q})}return Q}function T5(Y,Q,$){let X=1,J=$,Z=new RegExp(`<${Q}(?:\\s|>)`,"gi"),z=new RegExp(`</${Q}>`,"gi"),G=new RegExp(`<${Q}[^>]*/\\s*>`,"gi");while(X>0&&J<Y.length){Z.lastIndex=J,z.lastIndex=J,G.lastIndex=J;let U=Z.exec(Y),_=z.exec(Y),K=G.exec(Y);if(K&&K.index<(U?.index??1/0)){J=K.index+K[0].length;continue}if(!_)return{endIndex:Y.length};if(U&&U.index<_.index)X++,J=U.index+U[0].length;else{if(X--,X===0)return{endIndex:_.index+_[0].length};J=_.index+_[0].length}}return{endIndex:Y.length}}function I5(Y){let Q=new Map,$=Y.replace(/x-data\s*=\s*"[^"]*"/gi,'x-data="__stripped__"').replace(/x-data\s*=\s*'[^']*'/gi,"x-data='__stripped__'"),X=/<[a-z][a-z0-9-]*\s+([^>]*x-ref\s*=\s*["']([^"']*)["'][^>]*)>/gi,J;while((J=X.exec($))!==null){let[,Z,z]=J,G=k5(Z);Q.set(z,G)}return Q}function k5(Y){let Q=Y.match(/\bid\s*=\s*["']([^"']*)["']/);if(Q)return Q[1];return`__stx_el_${F5++}`}function N5(){return`
|
|
3
|
+
// STX Reactive Runtime - x-cloak and transition CSS
|
|
4
|
+
(function() {
|
|
5
|
+
var style = document.createElement('style');
|
|
6
|
+
style.textContent = [
|
|
7
|
+
'[x-cloak] { display: none !important; }',
|
|
8
|
+
// Default transition classes
|
|
9
|
+
'.stx-enter { opacity: 0; transform: scale(0.95); }',
|
|
10
|
+
'.stx-enter-start { opacity: 0; transform: scale(0.95); }',
|
|
11
|
+
'.stx-enter-active { transition: opacity 150ms ease-out, transform 150ms ease-out; }',
|
|
12
|
+
'.stx-enter-to { opacity: 1; transform: scale(1); }',
|
|
13
|
+
'.stx-leave { opacity: 1; transform: scale(1); }',
|
|
14
|
+
'.stx-leave-start { opacity: 1; transform: scale(1); }',
|
|
15
|
+
'.stx-leave-active { transition: opacity 100ms ease-in, transform 100ms ease-in; }',
|
|
16
|
+
'.stx-leave-to { opacity: 0; transform: scale(0.95); }'
|
|
17
|
+
].join('\\n');
|
|
18
|
+
document.head.appendChild(style);
|
|
19
|
+
})();
|
|
20
|
+
|
|
21
|
+
// STX Reactive Runtime
|
|
22
|
+
/* eslint-disable pickier/no-unused-vars, no-console, prefer-const */
|
|
23
|
+
window.__stx_reactive = (function() {
|
|
24
|
+
'use strict';
|
|
25
|
+
|
|
26
|
+
// Deep reactive proxy that triggers onChange for any mutation
|
|
27
|
+
function reactive(obj, onChange) {
|
|
28
|
+
if (!obj || typeof obj !== 'object') return obj;
|
|
29
|
+
return new Proxy(obj, {
|
|
30
|
+
get(target, prop) {
|
|
31
|
+
const value = target[prop];
|
|
32
|
+
if (value && typeof value === 'object' && !Array.isArray(value) && !(value instanceof Promise)) {
|
|
33
|
+
return reactive(value, onChange);
|
|
34
|
+
}
|
|
35
|
+
return value;
|
|
36
|
+
},
|
|
37
|
+
set(target, prop, value) {
|
|
38
|
+
target[prop] = value;
|
|
39
|
+
onChange(prop, value);
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Initialize an x-data scope: parse state, run init(), register into window.stx._scopes,
|
|
46
|
+
// then let the signals runtime handle all directive processing (x-for, x-text, :bind, etc.)
|
|
47
|
+
function initScope(scopeEl, initialState, bindings, refs, initExpr) {
|
|
48
|
+
// Parse initial state (may contain methods including async init())
|
|
49
|
+
var state;
|
|
50
|
+
try {
|
|
51
|
+
state = new Function('return (' + initialState + ')')();
|
|
52
|
+
} catch (e) {
|
|
53
|
+
console.error('[stx-reactive] Invalid x-data:', initialState, e);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Build $refs object
|
|
58
|
+
var $refs = {};
|
|
59
|
+
for (var name in refs) {
|
|
60
|
+
if (Object.prototype.hasOwnProperty.call(refs, name)) {
|
|
61
|
+
(function(refName, refId) {
|
|
62
|
+
Object.defineProperty($refs, refName, {
|
|
63
|
+
get: function() { return document.getElementById(refId); }
|
|
64
|
+
});
|
|
65
|
+
})(name, refs[name]);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Extract init method from state if present (Alpine.js convention)
|
|
70
|
+
var initMethod = state.init;
|
|
71
|
+
if (typeof initMethod === 'function') {
|
|
72
|
+
delete state.init;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Make state reactive \u2014 mutations trigger re-render via signals
|
|
76
|
+
var scopeId = scopeEl.getAttribute('data-stx-scope');
|
|
77
|
+
var stx = window.stx;
|
|
78
|
+
|
|
79
|
+
// Create signals for each state property so the signals runtime can track dependencies
|
|
80
|
+
var signalState = {};
|
|
81
|
+
var rawState = {};
|
|
82
|
+
for (var key in state) {
|
|
83
|
+
if (Object.prototype.hasOwnProperty.call(state, key)) {
|
|
84
|
+
if (typeof state[key] === 'function') {
|
|
85
|
+
// Methods \u2014 bind to a proxy so 'this.prop = val' triggers signal updates
|
|
86
|
+
signalState[key] = state[key];
|
|
87
|
+
} else {
|
|
88
|
+
// Data properties \u2014 wrap in signals for reactivity
|
|
89
|
+
signalState[key] = stx.state(state[key]);
|
|
90
|
+
rawState[key] = true;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Create a proxy context that auto-unwraps signals and writes back through them.
|
|
96
|
+
// Methods get 'this' bound to this proxy so this.foo = bar triggers reactivity.
|
|
97
|
+
var ctx = {};
|
|
98
|
+
var ctxProxy = new Proxy(ctx, {
|
|
99
|
+
get: function(target, prop) {
|
|
100
|
+
if (prop === '$refs') return $refs;
|
|
101
|
+
if (prop === '$el') return scopeEl;
|
|
102
|
+
if (prop === '$nextTick') return function(fn) { requestAnimationFrame(fn); };
|
|
103
|
+
var s = signalState[prop];
|
|
104
|
+
if (!s) return undefined;
|
|
105
|
+
if (rawState[prop] && s && typeof s === 'function' && typeof s.value !== 'undefined') {
|
|
106
|
+
return s.value; // unwrap signal
|
|
107
|
+
}
|
|
108
|
+
if (typeof s === 'function' && !rawState[prop]) {
|
|
109
|
+
return s.bind(ctxProxy); // bind methods to proxy
|
|
110
|
+
}
|
|
111
|
+
return s;
|
|
112
|
+
},
|
|
113
|
+
set: function(target, prop, value) {
|
|
114
|
+
var s = signalState[prop];
|
|
115
|
+
if (rawState[prop] && s && typeof s === 'function') {
|
|
116
|
+
s.value = value; // write through signal \u2014 triggers effects
|
|
117
|
+
} else {
|
|
118
|
+
signalState[prop] = value;
|
|
119
|
+
}
|
|
120
|
+
return true;
|
|
121
|
+
},
|
|
122
|
+
has: function(target, prop) {
|
|
123
|
+
return prop in signalState || prop === '$refs' || prop === '$el' || prop === '$nextTick';
|
|
124
|
+
},
|
|
125
|
+
ownKeys: function() {
|
|
126
|
+
return Object.keys(signalState).concat(['$refs', '$el', '$nextTick']);
|
|
127
|
+
},
|
|
128
|
+
getOwnPropertyDescriptor: function(target, prop) {
|
|
129
|
+
if (prop in signalState || prop === '$refs' || prop === '$el' || prop === '$nextTick') {
|
|
130
|
+
return { configurable: true, enumerable: true, writable: true, value: ctxProxy[prop] };
|
|
131
|
+
}
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
// Build scope vars for the signals runtime \u2014 it reads these for expression evaluation.
|
|
137
|
+
// We need to provide getter/setter descriptors so signals track properly.
|
|
138
|
+
var scopeVars = {};
|
|
139
|
+
for (var k in signalState) {
|
|
140
|
+
if (Object.prototype.hasOwnProperty.call(signalState, k)) {
|
|
141
|
+
if (rawState[k]) {
|
|
142
|
+
// Data: expose the signal directly so expressions trigger dependency tracking
|
|
143
|
+
scopeVars[k] = signalState[k];
|
|
144
|
+
} else {
|
|
145
|
+
// Method: bind to ctxProxy so 'this' works
|
|
146
|
+
scopeVars[k] = (typeof signalState[k] === 'function') ? signalState[k].bind(ctxProxy) : signalState[k];
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
scopeVars.$refs = $refs;
|
|
151
|
+
scopeVars.$el = scopeEl;
|
|
152
|
+
scopeVars.$nextTick = function(fn) { requestAnimationFrame(fn); };
|
|
153
|
+
|
|
154
|
+
// Register scope \u2014 merge with any existing vars from partial signal scripts
|
|
155
|
+
if (!stx._scopes) stx._scopes = {};
|
|
156
|
+
stx._scopes[scopeId] = Object.assign(stx._scopes[scopeId] || {}, scopeVars);
|
|
157
|
+
|
|
158
|
+
// Store on element for findElementScope
|
|
159
|
+
scopeEl.__stx_scope = scopeVars;
|
|
160
|
+
|
|
161
|
+
// Run init() if present (supports async)
|
|
162
|
+
function runInit() {
|
|
163
|
+
var maybePromise;
|
|
164
|
+
if (initMethod) {
|
|
165
|
+
maybePromise = initMethod.call(ctxProxy);
|
|
166
|
+
}
|
|
167
|
+
if (initExpr) {
|
|
168
|
+
try {
|
|
169
|
+
var keys = Object.keys(scopeVars);
|
|
170
|
+
var vals = keys.map(function(k) { return scopeVars[k]; });
|
|
171
|
+
var fn = new Function(keys.join(','), initExpr);
|
|
172
|
+
var result = fn.apply(ctxProxy, vals);
|
|
173
|
+
if (result && typeof result.then === 'function') maybePromise = result;
|
|
174
|
+
} catch (e) {
|
|
175
|
+
console.warn('[stx-reactive] init expression error:', e);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
// If init is async, signal updates will trigger effects automatically
|
|
179
|
+
// when init() resolves and sets this.prop = value (writes through signal)
|
|
180
|
+
if (maybePromise && typeof maybePromise.then === 'function') {
|
|
181
|
+
maybePromise.catch(function(e) {
|
|
182
|
+
console.error('[stx-reactive] async init() error:', e);
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Run init before the signals runtime processes this scope
|
|
188
|
+
runInit();
|
|
189
|
+
|
|
190
|
+
// Expose for debugging
|
|
191
|
+
scopeEl.__stx_state = ctxProxy;
|
|
192
|
+
scopeEl.__stx_execute = function(stmt, $event, $el) {
|
|
193
|
+
try {
|
|
194
|
+
// Run the statement with the reactive proxy as the lexical scope.
|
|
195
|
+
// Wrapping in a with-block on the proxy makes bare reads/writes go
|
|
196
|
+
// through it (so foo = bar triggers signal.set()) instead of treating
|
|
197
|
+
// each state key as a local function parameter \u2014 bare assignments
|
|
198
|
+
// would otherwise just rebind the local and never reach the signal.
|
|
199
|
+
var fn = new Function('$event', '$el', 'with(this){' + stmt + ';}');
|
|
200
|
+
fn.call(ctxProxy, $event, $el);
|
|
201
|
+
} catch (e) {
|
|
202
|
+
console.warn('[stx-reactive] execute error:', e);
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return { initScope: initScope, reactive: reactive };
|
|
208
|
+
})();
|
|
209
|
+
`}function G3(Y,Q){let $=Y.replace(/\{!!([\s\S]*?)!!\}/g,(X,J)=>{try{let Z=K0(J,Q,!0);if(Z===void 0)return X;return String(Z)}catch{return X}});return $=$.replace(/\{\{([\s\S]*?)\}\}/g,(X,J)=>{try{let Z=K0(J,Q,!0);if(Z===void 0)return X;if(typeof Z==="string"){let z=Z.trim();if(z.startsWith("{")&&z.endsWith("}")||z.startsWith("[")&&z.endsWith("]"))try{return JSON.parse(z),z}catch{}}return JSON.stringify(Z)}catch{return X}}),$}function D5(Y,Q){if(Y.length===0)return"";let $=Y.map((X)=>{let J=JSON.stringify(Object.fromEntries(X.refs)),Z=G3(X.stateExpr,Q),z=X.initExpr?G3(X.initExpr,Q):null,G=JSON.stringify(Z),U=z?JSON.stringify(z):"null";return`
|
|
210
|
+
(function() {
|
|
211
|
+
var scopeEl = document.querySelector('${X.selector}');
|
|
212
|
+
if (!scopeEl) return;
|
|
213
|
+
var refs = ${J};
|
|
214
|
+
__stx_reactive.initScope(scopeEl, ${G}, [], refs, ${U});
|
|
215
|
+
})();`}).join(`
|
|
216
|
+
`);return`
|
|
217
|
+
<script data-stx-scoped data-stx-reactive>
|
|
218
|
+
${N5()}
|
|
219
|
+
${$}
|
|
220
|
+
</script>`}function K3(Y,Q,$){if(U3=0,!M5(Y))return Y;let X=R5(Y);if(X.length===0)return Y;let J=E5(Y,X),Z=D5(X,Q),z=J.lastIndexOf("</body>");if(z!==-1)J=J.slice(0,z)+Z+`
|
|
221
|
+
`+J.slice(z);else J+=Z;return J}function E5(Y,Q){let $=Y;for(let X of Q){let Z=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*data-stx-scope="([^"]*)"[^>]*x-data\\s*=\\s*["']${r0(X.stateExpr)}["']`,"gi").exec($);if(Z)X.id=Z[1],X.selector=`[data-stx-scope="${X.id}"]`;else{let G=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*x-data\\s*=\\s*["']${r0(X.stateExpr)}["'][^>]*data-stx-scope="([^"]*)"`,"gi").exec($);if(G)X.id=G[1],X.selector=`[data-stx-scope="${X.id}"]`;else $=$.replace(new RegExp(`(<[a-z][a-z0-9-]*\\s+)([^>]*)(x-data\\s*=\\s*"${r0(X.stateExpr)}")([^>]*>)`,"gi"),`$1data-stx-scope="${X.id}" $2$3$4`),$=$.replace(new RegExp(`(<[a-z][a-z0-9-]*\\s+)([^>]*)(x-data\\s*=\\s*'${r0(X.stateExpr)}')([^>]*>)`,"gi"),`$1data-stx-scope="${X.id}" $2$3$4`)}}return $=$.replace(/\s*x-data\s*=\s*"([^"]*)"/g,' data-stx-xdata="$1"'),$=$.replace(/\s*x-data\s*=\s*'([^']*)'/g," data-stx-xdata='$1'"),$=$.replace(/\s*x-init\s*=\s*"[^"]*"/g,""),$=$.replace(/\s*x-init\s*=\s*'[^']*'/g,""),$}function M5(Y){return/x-data\s*=\s*["']/.test(Y)}import c5 from"fs";import F1 from"path";import{createHighlighter as i5}from"ts-syntax-highlighter";import w1 from"fs";import Z0 from"path";import{loadConfigWithResult as m5}from"bunfig";async function q3(Y,Q,$=""){let X=Y,J=[],Z=/@markdown(?:\([^)]*\))?/g,z;while((z=Z.exec(Y))!==null){let G=z.index,U=z[0].match(/@markdown\(([^)]*)\)/),_=U?U[1]:"",K=G+z[0].length,j=1,W=K,q=-1;while(j>0&&W<Y.length){let O=Y.indexOf("@markdown",W),V=Y.indexOf("@endmarkdown",W);if(V===-1)break;if(O!==-1&&O<V&&O!==G){let B=Y[O+9];if(B==="("||B===`
|
|
222
|
+
`||B==="\r"||B===" "||B===void 0)j++;W=O+9}else{if(j--,j===0){q=V;break}W=V+12}}if(q===-1)continue;let H=Y.slice(K,q),L=Y.slice(G,q+12);J.push({fullMatch:L,options:_,content:H,index:G}),Z.lastIndex=q+12}for(let{fullMatch:G,options:U,content:_,index:K}of J)try{let j={};if(U)U.split(",").forEach((H)=>{let L=H.trim();if(L)j[L]=!0});let W={gfm:j.gfm??!0,breaks:j.breaks??!1},q=P0(_.trim(),W);X=X.split(G).join(q)}catch(j){let W=j instanceof Error?j.message:String(j),q=p("Markdown Directive",`Error processing markdown: ${W}`,$,Y,K,G);X=X.split(G).join(q)}return X}async function H3(Y,Q,$,X){let J={gfm:!0,breaks:!1};return Q.forEach((Z)=>{let z=Z.trim().replace(/['"]/g,"");if(z==="breaks")J.breaks=!0;if(z==="no-gfm")J.gfm=!1}),P0(Y.trim(),J)}import y5 from"fs";import A0 from"path";async function g7(Y,Q){if(!Y.webComponents?.enabled)return[];let $=Y.webComponents.components||[],X=[];if($.length>0){if(Y.debug)console.log(`Building ${$.length} web components...`);for(let J of $)try{let Z=await b5(J,Y,Q);if(Z)X.push(Z)}catch(Z){if(console.error(`Error building web component ${J.name}:`,Z),Y.debug)throw Z}}return X}async function b5(Y,Q,$){let{name:X,file:J,tag:Z,extends:z}=Y;if(!X||!J||!Z)return console.error("Invalid web component configuration, missing required fields:",Y),null;let G=null;if(A0.isAbsolute(J)&&await x(J))G=J;else if(Q.componentsDir){let L=A0.join(Q.componentsDir,J);if(await x(L))G=L}if(!G)G=await a0(J,process.cwd(),Q,$);if(!G)return console.error(`Web component source file not found: ${J}`),null;let U=await Bun.file(G).text();$.add(G);let K=(Y.outputFormat||"js")==="ts",j=K?C5({name:X,tag:Z,baseElement:z,source:U,shadowDOM:Y.shadowDOM??!0,template:Y.template??!0,styleSource:Y.styleSource,attributes:Y.attributes||[],attributeTypes:Y.attributeTypes||{}}):S5({name:X,tag:Z,baseElement:z,source:U,shadowDOM:Y.shadowDOM??!0,template:Y.template??!0,styleSource:Y.styleSource,attributes:Y.attributes||[]}),W=Q.webComponents?.outputDir||"dist/web-components";await y5.promises.mkdir(W,{recursive:!0});let q=K?"ts":"js",H=A0.join(W,`${Z}.${q}`);if(await Bun.write(H,j),Q.debug)console.log(`Built web component ${X} -> ${H}`);return H}function S5(Y){let{name:Q,tag:$,baseElement:X="HTMLElement",source:J,shadowDOM:Z,template:z,styleSource:G,attributes:U=[]}=Y,_=J.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").trim();if(!Z)_=_.replace(/<slot\s+name=["']([^"']+)["']\s*>([\s\S]*?)<\/slot>/gi,'<div data-slot="$1">$2</div>'),_=_.replace(/<slot\s+name=["']([^"']+)["']\s*\/>/gi,'<div data-slot="$1"></div>'),_=_.replace(/<slot\s*>([\s\S]*?)<\/slot>/gi,"<div data-default-slot>$1</div>"),_=_.replace(/<slot\s*\/>/gi,"<div data-default-slot></div>");let K="";if(G)K=`<link rel="stylesheet" href="${G}">`;return`/**
|
|
223
|
+
* ${Q} Web Component
|
|
224
|
+
* Auto-generated from stx component
|
|
225
|
+
*/
|
|
226
|
+
class ${Q.replace(/\W/g,"")} extends ${X} {
|
|
227
|
+
constructor() {
|
|
228
|
+
super()
|
|
229
|
+
${Z?'this.attachShadow({ mode: "open" })':""}
|
|
230
|
+
${z?"this._createTemplate()":"this._render()"}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
${z?`
|
|
234
|
+
_createTemplate() {
|
|
235
|
+
const template = document.createElement('template')
|
|
236
|
+
template.innerHTML = \`${K}${_}\`
|
|
237
|
+
${Z?"this.shadowRoot.appendChild(template.content.cloneNode(true))":"this.appendChild(template.content.cloneNode(true))"}
|
|
238
|
+
this._processSlots()
|
|
239
|
+
}
|
|
240
|
+
`:`
|
|
241
|
+
_render() {
|
|
242
|
+
${Z?"this.shadowRoot.innerHTML":"this.innerHTML"} = \`${K}${_}\`
|
|
243
|
+
this._processSlots()
|
|
244
|
+
}
|
|
245
|
+
`}
|
|
246
|
+
|
|
247
|
+
_processSlots() {
|
|
248
|
+
${Z?`// Shadow DOM handles slot assignment automatically
|
|
249
|
+
// Listen for slot changes if needed
|
|
250
|
+
const slots = this.shadowRoot.querySelectorAll('slot')
|
|
251
|
+
slots.forEach(slot => {
|
|
252
|
+
slot.addEventListener('slotchange', (e) => {
|
|
253
|
+
const assignedNodes = slot.assignedNodes()
|
|
254
|
+
this.dispatchEvent(new CustomEvent('slot-changed', {
|
|
255
|
+
detail: { slotName: slot.name || 'default', assignedNodes }
|
|
256
|
+
}))
|
|
257
|
+
})
|
|
258
|
+
})`:`// Manual slot processing for non-shadow DOM mode
|
|
259
|
+
const slots = this.querySelectorAll('[data-slot]')
|
|
260
|
+
const lightDOMChildren = Array.from(this.childNodes).filter(
|
|
261
|
+
node => node.nodeType === Node.ELEMENT_NODE && !node.hasAttribute('data-slot')
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
// Process named slots
|
|
265
|
+
slots.forEach(slotEl => {
|
|
266
|
+
const slotName = slotEl.getAttribute('data-slot')
|
|
267
|
+
const slottedContent = this.querySelector(\`[slot="\${slotName}"]\`)
|
|
268
|
+
if (slottedContent) {
|
|
269
|
+
// Replace slot placeholder with actual content
|
|
270
|
+
slotEl.innerHTML = ''
|
|
271
|
+
slotEl.appendChild(slottedContent.cloneNode(true))
|
|
272
|
+
}
|
|
273
|
+
})
|
|
274
|
+
|
|
275
|
+
// Process default slot
|
|
276
|
+
const defaultSlot = this.querySelector('[data-slot=""]') || this.querySelector('[data-default-slot]')
|
|
277
|
+
if (defaultSlot) {
|
|
278
|
+
const unslottedContent = Array.from(this.children).filter(
|
|
279
|
+
child => !child.hasAttribute('slot') && child !== defaultSlot
|
|
280
|
+
)
|
|
281
|
+
if (unslottedContent.length > 0) {
|
|
282
|
+
defaultSlot.innerHTML = ''
|
|
283
|
+
unslottedContent.forEach(content => {
|
|
284
|
+
defaultSlot.appendChild(content.cloneNode(true))
|
|
285
|
+
})
|
|
286
|
+
}
|
|
287
|
+
}`}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
${U.length>0?`
|
|
291
|
+
static get observedAttributes() {
|
|
292
|
+
return [${U.map((j)=>`'${j}'`).join(", ")}]
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
296
|
+
if (oldValue !== newValue) {
|
|
297
|
+
this[name] = newValue
|
|
298
|
+
${z?"":"this._render()"}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
`:""}
|
|
302
|
+
|
|
303
|
+
connectedCallback() {
|
|
304
|
+
// Component connected to the DOM
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
disconnectedCallback() {
|
|
308
|
+
// Component removed from the DOM
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// Register the web component
|
|
313
|
+
customElements.define('${$}', ${Q.replace(/\W/g,"")})
|
|
314
|
+
`}function C5(Y){let{name:Q,tag:$,baseElement:X="HTMLElement",source:J,shadowDOM:Z,template:z,styleSource:G,attributes:U=[],attributeTypes:_={}}=Y,K=Q.replace(/\W/g,""),j=J.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").trim();if(!Z)j=j.replace(/<slot\s+name=["']([^"']+)["']\s*>([\s\S]*?)<\/slot>/gi,'<div data-slot="$1">$2</div>'),j=j.replace(/<slot\s+name=["']([^"']+)["']\s*\/>/gi,'<div data-slot="$1"></div>'),j=j.replace(/<slot\s*>([\s\S]*?)<\/slot>/gi,"<div data-default-slot>$1</div>"),j=j.replace(/<slot\s*\/>/gi,"<div data-default-slot></div>");j=j.replace(/`/g,"\\`").replace(/\$\{/g,"\\${");let W=G?`<link rel="stylesheet" href="${G}">`:"",q=(F)=>{switch(_[F]){case"number":return"number";case"boolean":return"boolean";case"object":return"Record<string, unknown>";default:return"string"}},H=(F)=>F.replace(/-([a-z])/g,(N,I)=>I.toUpperCase()),L=U.map((F)=>` private _${H(F)}: ${q(F)} | null = null;`).join(`
|
|
315
|
+
`),O=U.map((F)=>{let N=q(F),I=H(F);return`
|
|
316
|
+
get ${I}(): ${N} | null {
|
|
317
|
+
return this._${I};
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
set ${I}(value: ${N} | null) {
|
|
321
|
+
this._${I} = value;
|
|
322
|
+
if (value !== null) {
|
|
323
|
+
this.setAttribute('${F}', String(value));
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
this.removeAttribute('${F}');
|
|
327
|
+
}
|
|
328
|
+
}`}).join(`
|
|
329
|
+
`),V=U.length>0?`/**
|
|
330
|
+
* Props interface for ${Q}
|
|
331
|
+
*/
|
|
332
|
+
export interface ${K}Props {
|
|
333
|
+
${U.map((F)=>{let N=q(F);return` ${H(F)}?: ${N};`}).join(`
|
|
334
|
+
`)}
|
|
335
|
+
}
|
|
336
|
+
`:"",B=U.length>0?`
|
|
337
|
+
static get observedAttributes(): string[] {
|
|
338
|
+
return [${U.map((F)=>`'${F}'`).join(", ")}];
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {
|
|
342
|
+
if (oldValue !== newValue) {
|
|
343
|
+
const camelCase = name.replace(/-([a-z])/g, (_: string, letter: string) => letter.toUpperCase());
|
|
344
|
+
(this as unknown as Record<string, unknown>)[\`_\${camelCase}\`] = this._parseAttributeValue(name, newValue);
|
|
345
|
+
${z?"":"this._render();"}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
private _parseAttributeValue(name: string, value: string | null): unknown {
|
|
350
|
+
if (value === null) return null;
|
|
351
|
+
const typeMap: Record<string, string> = ${JSON.stringify(_)};
|
|
352
|
+
const type = typeMap[name] || 'string';
|
|
353
|
+
switch (type) {
|
|
354
|
+
case 'number': return Number(value);
|
|
355
|
+
case 'boolean': return value !== 'false' && value !== '0';
|
|
356
|
+
case 'object': try { return JSON.parse(value); }
|
|
357
|
+
catch { return value; }
|
|
358
|
+
default: return value;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
`:"",A=z?`
|
|
362
|
+
private _createTemplate(): void {
|
|
363
|
+
const template = document.createElement('template');
|
|
364
|
+
template.innerHTML = \`${W}${j}\`;
|
|
365
|
+
${Z?"this.shadowRoot!.appendChild(template.content.cloneNode(true));":"this.appendChild(template.content.cloneNode(true));"}
|
|
366
|
+
this._processSlots();
|
|
367
|
+
}`:`
|
|
368
|
+
private _render(): void {
|
|
369
|
+
${Z?"this.shadowRoot!.innerHTML":"this.innerHTML"} = \`${W}${j}\`;
|
|
370
|
+
this._processSlots();
|
|
371
|
+
}`;return`/**
|
|
372
|
+
* ${Q} Web Component
|
|
373
|
+
* Auto-generated from stx component (TypeScript)
|
|
374
|
+
*
|
|
375
|
+
* @example
|
|
376
|
+
* \`\`\`html
|
|
377
|
+
* <${$}></${$}>
|
|
378
|
+
* \`\`\`
|
|
379
|
+
*/
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Detail type for slot-changed event
|
|
383
|
+
*/
|
|
384
|
+
interface SlotChangeDetail {
|
|
385
|
+
slotName: string;
|
|
386
|
+
assignedNodes: Node[];
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
${V}
|
|
390
|
+
/**
|
|
391
|
+
* ${Q} custom element class
|
|
392
|
+
* @customElement ${$}
|
|
393
|
+
*/
|
|
394
|
+
export class ${K} extends ${X} {
|
|
395
|
+
${L}
|
|
396
|
+
|
|
397
|
+
constructor() {
|
|
398
|
+
super();
|
|
399
|
+
${Z?'this.attachShadow({ mode: "open" });':""}
|
|
400
|
+
${z?"this._createTemplate();":"this._render();"}
|
|
401
|
+
}
|
|
402
|
+
${A}
|
|
403
|
+
${Z?`
|
|
404
|
+
private _processSlots(): void {
|
|
405
|
+
const slots = this.shadowRoot!.querySelectorAll('slot');
|
|
406
|
+
slots.forEach((slot) => {
|
|
407
|
+
slot.addEventListener('slotchange', () => {
|
|
408
|
+
const assignedNodes = (slot as HTMLSlotElement).assignedNodes();
|
|
409
|
+
this.dispatchEvent(new CustomEvent<SlotChangeDetail>('slot-changed', {
|
|
410
|
+
detail: { slotName: slot.getAttribute('name') || 'default', assignedNodes }
|
|
411
|
+
}));
|
|
412
|
+
});
|
|
413
|
+
});
|
|
414
|
+
}`:`
|
|
415
|
+
private _processSlots(): void {
|
|
416
|
+
const slots = this.querySelectorAll('[data-slot]');
|
|
417
|
+
slots.forEach((slotEl) => {
|
|
418
|
+
const slotName = slotEl.getAttribute('data-slot');
|
|
419
|
+
if (slotName) {
|
|
420
|
+
const slottedContent = this.querySelector(\`[slot="\${slotName}"]\`);
|
|
421
|
+
if (slottedContent) {
|
|
422
|
+
slotEl.innerHTML = '';
|
|
423
|
+
slotEl.appendChild(slottedContent.cloneNode(true));
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
}`}
|
|
428
|
+
${B}
|
|
429
|
+
${O}
|
|
430
|
+
|
|
431
|
+
connectedCallback(): void {
|
|
432
|
+
// Component connected to the DOM
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
disconnectedCallback(): void {
|
|
436
|
+
// Component removed from the DOM
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
adoptedCallback(): void {
|
|
440
|
+
// Component moved to a new document
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// Type augmentation for HTMLElementTagNameMap
|
|
445
|
+
declare global {
|
|
446
|
+
interface HTMLElementTagNameMap {
|
|
447
|
+
'${$}': ${K};
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// Register the web component
|
|
452
|
+
customElements.define('${$}', ${K});
|
|
453
|
+
`}var V1={strategy:"attribute",attributeName:"data-v",preserveOriginal:!0};function A1(Y){let Q=Y.split("").reduce(($,X)=>($<<5)-$+X.charCodeAt(0)|0,0);return Math.abs(Q).toString(36).slice(0,8)}function v5(Y,Q,$={}){let X={...V1,...$},J=A1(Q);switch(X.strategy){case"shadow":return Y;case"prefix":return f5(Y,X.prefix||Q,X.preserveOriginal);case"attribute":return P5(Y,J,X.attributeName||"data-v",X.preserveOriginal);case"bem":return g5(Y,Q,X.preserveOriginal);default:return Y}}function P5(Y,Q,$,X){let J=`[${$}-${Q}]`;return Y.replace(/([.#]?[\w-]+|\*)\s*(\{|,)/g,(Z,z,G)=>{if(z.startsWith("@"))return Z;if(/^(?::root|:host|html|body)$/i.test(z))return Z;return`${X?`${z}${J}`:`${z}${J}`}${G}`})}function f5(Y,Q,$){return Y.replace(/\.([a-z_][\w-]*)/gi,(X,J)=>{if(J.startsWith(Q))return X;let Z=`${Q}__${J}`;return $?`.${Z}`:`.${Z}`})}function g5(Y,Q,$){let X=Q.replace(/[^a-z0-9]/gi,"-");return Y.replace(/\.([a-z_][\w-]*)/gi,(J,Z)=>{if(Z.includes("__")||Z.includes("--")){if(!Z.startsWith(X))return`.${X}__${Z}`;return J}let z=`${X}__${Z}`;return $?`.${z}`:`.${z}`})}function x5(Y,Q,$={}){let X={...V1,...$};if(X.strategy==="shadow")return Y;if(X.strategy==="attribute"){let J=A1(Q),z=`${X.attributeName||"data-v"}-${J}`;return Y.replace(/<([a-z][a-z0-9-]*)([^>]*)>/gi,(G,U,_)=>{if(/^(?:script|style|!--)$/i.test(U))return G;let K=_.trimEnd().endsWith("/"),j=K?_.slice(0,-1):_;return`<${U}${j} ${z}${K?"/":""}>`})}if(X.strategy==="prefix"||X.strategy==="bem"){let J=X.strategy==="bem"?Q.replace(/[^a-z0-9]/gi,"-"):X.prefix||Q;return Y.replace(/\bclass\s*=\s*["']([^"']+)["']/gi,(Z,z)=>{return`class="${z.split(/\s+/).map((U)=>{if(!U)return U;if(U.startsWith(J))return U;return`${J}__${U}`}).join(" ")}"`})}return Y}function x7(Y,Q={}){let $={...V1,...Q},X=A1(Y);return`${$.attributeName||"data-v"}-${X}`}function h7(Y,Q,$={}){let X="",J=Y.replace(/<style([^>]*)>([\s\S]*?)<\/style>/gi,(z,G,U)=>{if(/\bscoped\b/i.test(G)||$.strategy!=="shadow")X+=`${v5(U,Q,$)}
|
|
454
|
+
`;else X+=`${U}
|
|
455
|
+
`;return""});return{html:x5(J,Q,$),css:X.trim()}}function E0(Y){return Y.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function d7(Y){let{name:Q,tag:$,baseElement:X="HTMLElement",template:J,styles:Z="",shadowDOM:z=!0,properties:G={},lifecycle:U={},events:_={},methods:K={},state:j={}}=Y,W=Q.replace(/\W/g,""),q=Object.keys(G),H=q.filter((T)=>G[T].attribute!==!1).map((T)=>G[T].attribute||E0(T)),L=q.map((T)=>{let R=G[T],k=R.default!==void 0?JSON.stringify(R.default):R.type==="string"?'""':R.type==="number"?"0":R.type==="boolean"?"false":R.type==="array"?"[]":"{}";return` this._${T} = ${k};`}).join(`
|
|
456
|
+
`),O=q.map((T)=>{let R=G[T],k=R.attribute!==!1?R.attribute||E0(T):null,D=R.reflect&&k?`
|
|
457
|
+
if (value !== null && value !== undefined) {
|
|
458
|
+
${R.type==="boolean"?`if (value) { this.setAttribute('${k}', ''); }
|
|
459
|
+
else { this.removeAttribute('${k}'); }`:`this.setAttribute('${k}', ${R.type==="object"||R.type==="array"?"JSON.stringify(value)":"String(value)"});`}
|
|
460
|
+
}
|
|
461
|
+
else {
|
|
462
|
+
this.removeAttribute('${k}');
|
|
463
|
+
}`:"",E=R.observer?`this.${R.observer}(value, oldValue);`:"",y=R.render!==!1?"this._scheduleRender();":"";return`
|
|
464
|
+
get ${T}() {
|
|
465
|
+
return this._${T};
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
set ${T}(value) {
|
|
469
|
+
const oldValue = this._${T};
|
|
470
|
+
if (oldValue === value) return;
|
|
471
|
+
this._${T} = value;${D}
|
|
472
|
+
${E}
|
|
473
|
+
${y}
|
|
474
|
+
this.dispatchEvent(new CustomEvent('${T}-changed', {
|
|
475
|
+
detail: { value, oldValue },
|
|
476
|
+
bubbles: true
|
|
477
|
+
}));
|
|
478
|
+
}`}).join(`
|
|
479
|
+
`),V=H.length>0?`
|
|
480
|
+
static get observedAttributes() {
|
|
481
|
+
return [${H.map((T)=>`'${T}'`).join(", ")}];
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
485
|
+
if (oldValue === newValue) return;
|
|
486
|
+
const propName = this._attrToProp[name];
|
|
487
|
+
if (propName) {
|
|
488
|
+
const propDef = this._propertyDefs[propName];
|
|
489
|
+
this[propName] = this._deserializeAttribute(newValue, propDef.type);
|
|
490
|
+
}
|
|
491
|
+
${U.attributeChanged||""}
|
|
492
|
+
}`:"",B=Object.entries(_).map(([T,R])=>{return`this._root.addEventListener('${T}', (e) => { ${R} });`}).join(`
|
|
493
|
+
`),A=Object.entries(K).map(([T,R])=>{return`
|
|
494
|
+
${T}() {
|
|
495
|
+
${R}
|
|
496
|
+
}`}).join(`
|
|
497
|
+
`),w=JSON.stringify(Object.fromEntries(q.map((T)=>[T,G[T]]))),F=JSON.stringify(Object.fromEntries(q.filter((T)=>G[T].attribute!==!1).map((T)=>[G[T].attribute||E0(T),T]))),N=J.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),I=Z.replace(/\\/g,"\\\\").replace(/`/g,"\\`");return`/**
|
|
498
|
+
* ${Q} - Reactive Web Component
|
|
499
|
+
* Auto-generated with reactive properties and lifecycle management
|
|
500
|
+
*
|
|
501
|
+
* @customElement ${$}
|
|
502
|
+
*/
|
|
503
|
+
class ${W} extends ${X} {
|
|
504
|
+
// Property definitions
|
|
505
|
+
_propertyDefs = ${w};
|
|
506
|
+
_attrToProp = ${F};
|
|
507
|
+
|
|
508
|
+
// Internal state
|
|
509
|
+
_state = ${JSON.stringify(j)};
|
|
510
|
+
_renderPending = false;
|
|
511
|
+
_isConnected = false;
|
|
512
|
+
|
|
513
|
+
constructor() {
|
|
514
|
+
super();
|
|
515
|
+
${z?'this.attachShadow({ mode: "open" });':""}
|
|
516
|
+
this._root = ${z?"this.shadowRoot":"this"};
|
|
517
|
+
|
|
518
|
+
// Initialize properties with defaults
|
|
519
|
+
${L}
|
|
520
|
+
|
|
521
|
+
// Initial render
|
|
522
|
+
this._render();
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
// =========================================================================
|
|
526
|
+
// Reactive Properties
|
|
527
|
+
// =========================================================================
|
|
528
|
+
${O}
|
|
529
|
+
|
|
530
|
+
// =========================================================================
|
|
531
|
+
// State Management
|
|
532
|
+
// =========================================================================
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* Get current internal state
|
|
536
|
+
*/
|
|
537
|
+
get state() {
|
|
538
|
+
return { ...this._state };
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* Update internal state and trigger re-render
|
|
543
|
+
* @param {Object} updates - State updates to merge
|
|
544
|
+
*/
|
|
545
|
+
setState(updates) {
|
|
546
|
+
const oldState = { ...this._state };
|
|
547
|
+
this._state = { ...this._state, ...updates };
|
|
548
|
+
this._scheduleRender();
|
|
549
|
+
this.dispatchEvent(new CustomEvent('state-changed', {
|
|
550
|
+
detail: { state: this._state, oldState },
|
|
551
|
+
bubbles: true
|
|
552
|
+
}));
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
// =========================================================================
|
|
556
|
+
// Rendering
|
|
557
|
+
// =========================================================================
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Schedule a render on the next animation frame (batched)
|
|
561
|
+
*/
|
|
562
|
+
_scheduleRender() {
|
|
563
|
+
if (this._renderPending) return;
|
|
564
|
+
this._renderPending = true;
|
|
565
|
+
requestAnimationFrame(() => {
|
|
566
|
+
this._renderPending = false;
|
|
567
|
+
this._render();
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Render the component template
|
|
573
|
+
*/
|
|
574
|
+
_render() {
|
|
575
|
+
const template = \`${I?`<style>${I}</style>`:""}${N}\`;
|
|
576
|
+
|
|
577
|
+
// Interpolate template with property values
|
|
578
|
+
const rendered = template.replace(/\\{\\{\\s*(\\w+)\\s*\\}\\}/g, (match, propName) => {
|
|
579
|
+
if (propName in this) {
|
|
580
|
+
const value = this[propName];
|
|
581
|
+
if (value === null || value === undefined) return '';
|
|
582
|
+
if (typeof value === 'object') return JSON.stringify(value);
|
|
583
|
+
return String(value);
|
|
584
|
+
}
|
|
585
|
+
if (propName in this._state) {
|
|
586
|
+
const value = this._state[propName];
|
|
587
|
+
if (value === null || value === undefined) return '';
|
|
588
|
+
if (typeof value === 'object') return JSON.stringify(value);
|
|
589
|
+
return String(value);
|
|
590
|
+
}
|
|
591
|
+
return match;
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
this._root.innerHTML = rendered;
|
|
595
|
+
this._bindEvents();
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* Bind event handlers after render
|
|
600
|
+
*/
|
|
601
|
+
_bindEvents() {
|
|
602
|
+
${B}
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
// =========================================================================
|
|
606
|
+
// Attribute Handling
|
|
607
|
+
// =========================================================================
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* Deserialize attribute value to property type
|
|
611
|
+
*/
|
|
612
|
+
_deserializeAttribute(value, type) {
|
|
613
|
+
if (value === null) return null;
|
|
614
|
+
switch (type) {
|
|
615
|
+
case 'number': return Number(value);
|
|
616
|
+
case 'boolean': return value !== null && value !== 'false' && value !== '0';
|
|
617
|
+
case 'object':
|
|
618
|
+
case 'array':
|
|
619
|
+
try { return JSON.parse(value); }
|
|
620
|
+
catch { return type === 'array' ? [] : {}; }
|
|
621
|
+
default: return value;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
${V}
|
|
626
|
+
|
|
627
|
+
// =========================================================================
|
|
628
|
+
// Lifecycle
|
|
629
|
+
// =========================================================================
|
|
630
|
+
|
|
631
|
+
connectedCallback() {
|
|
632
|
+
this._isConnected = true;
|
|
633
|
+
${U.connected||"// Component connected to DOM"}
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
disconnectedCallback() {
|
|
637
|
+
this._isConnected = false;
|
|
638
|
+
${U.disconnected||"// Component disconnected from DOM"}
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
adoptedCallback() {
|
|
642
|
+
${U.adopted||"// Component moved to new document"}
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
// =========================================================================
|
|
646
|
+
// Custom Methods
|
|
647
|
+
// =========================================================================
|
|
648
|
+
${A}
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
// Register the custom element
|
|
652
|
+
customElements.define('${$}', ${W});
|
|
653
|
+
|
|
654
|
+
// Export for module usage
|
|
655
|
+
export { ${W} };
|
|
656
|
+
export default ${W};
|
|
657
|
+
`}function m7(Y){let{name:Q,tag:$,baseElement:X="HTMLElement",template:J,styles:Z="",shadowDOM:z=!0,properties:G={},lifecycle:U={},events:_={},methods:K={},state:j={}}=Y,W=Q.replace(/\W/g,""),q=Object.keys(G),H=q.filter((R)=>G[R].attribute!==!1).map((R)=>G[R].attribute||E0(R)),L=(R)=>{switch(R){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"object":return"Record<string, unknown>";case"array":return"unknown[]";default:return"unknown"}},O=q.length>0?`
|
|
658
|
+
/**
|
|
659
|
+
* Props interface for ${Q}
|
|
660
|
+
*/
|
|
661
|
+
export interface ${W}Props {
|
|
662
|
+
${q.map((R)=>` ${R}?: ${L(G[R].type)};`).join(`
|
|
663
|
+
`)}
|
|
664
|
+
}
|
|
665
|
+
`:"",V=Object.keys(j).length>0?`
|
|
666
|
+
/**
|
|
667
|
+
* State interface for ${Q}
|
|
668
|
+
*/
|
|
669
|
+
export interface ${W}State {
|
|
670
|
+
${Object.entries(j).map(([R,k])=>` ${R}: ${typeof k};`).join(`
|
|
671
|
+
`)}
|
|
672
|
+
}
|
|
673
|
+
`:`
|
|
674
|
+
export interface ${W}State {
|
|
675
|
+
[key: string]: unknown;
|
|
676
|
+
}
|
|
677
|
+
`,B=q.map((R)=>{let k=G[R],D=L(k.type);return` private _${R}: ${D};`}).join(`
|
|
678
|
+
`),A=q.map((R)=>{let k=G[R],D=L(k.type),E=k.attribute!==!1?k.attribute||E0(R):null,y=k.default!==void 0?JSON.stringify(k.default):k.type==="string"?'""':k.type==="number"?"0":k.type==="boolean"?"false":k.type==="array"?"[]":"{}",M=k.reflect&&E?`
|
|
679
|
+
if (value !== null && value !== undefined) {
|
|
680
|
+
${k.type==="boolean"?`if (value) { this.setAttribute('${E}', ''); }
|
|
681
|
+
else { this.removeAttribute('${E}'); }`:`this.setAttribute('${E}', ${k.type==="object"||k.type==="array"?"JSON.stringify(value)":"String(value)"});`}
|
|
682
|
+
}
|
|
683
|
+
else {
|
|
684
|
+
this.removeAttribute('${E}');
|
|
685
|
+
}`:"",b=k.observer?`this.${k.observer}(value, oldValue);`:"",P=k.render!==!1?"this._scheduleRender();":"";return`
|
|
686
|
+
get ${R}(): ${D} {
|
|
687
|
+
return this._${R};
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
set ${R}(value: ${D}) {
|
|
691
|
+
const oldValue = this._${R};
|
|
692
|
+
if (oldValue === value) return;
|
|
693
|
+
this._${R} = value;${M}
|
|
694
|
+
${b}
|
|
695
|
+
${P}
|
|
696
|
+
this.dispatchEvent(new CustomEvent('${R}-changed', {
|
|
697
|
+
detail: { value, oldValue },
|
|
698
|
+
bubbles: true
|
|
699
|
+
}));
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
// Property default: ${y}`}).join(`
|
|
703
|
+
`),w=H.length>0?`
|
|
704
|
+
static get observedAttributes(): string[] {
|
|
705
|
+
return [${H.map((R)=>`'${R}'`).join(", ")}];
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {
|
|
709
|
+
if (oldValue === newValue) return;
|
|
710
|
+
const propName = this._attrToProp[name];
|
|
711
|
+
if (propName) {
|
|
712
|
+
const propDef = this._propertyDefs[propName];
|
|
713
|
+
(this as unknown as Record<string, unknown>)[propName] = this._deserializeAttribute(newValue, propDef.type);
|
|
714
|
+
}
|
|
715
|
+
${U.attributeChanged||""}
|
|
716
|
+
}`:"",F=Object.entries(_).map(([R,k])=>{return`this._root.addEventListener('${R}', (e: Event) => { ${k} });`}).join(`
|
|
717
|
+
`),N=Object.entries(K).map(([R,k])=>{return`
|
|
718
|
+
${R}(): void {
|
|
719
|
+
${k}
|
|
720
|
+
}`}).join(`
|
|
721
|
+
`),I=J.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),T=Z.replace(/\\/g,"\\\\").replace(/`/g,"\\`");return`/**
|
|
722
|
+
* ${Q} - Reactive Web Component (TypeScript)
|
|
723
|
+
* Auto-generated with reactive properties and lifecycle management
|
|
724
|
+
*
|
|
725
|
+
* @customElement ${$}
|
|
726
|
+
*/
|
|
727
|
+
|
|
728
|
+
${O}
|
|
729
|
+
${V}
|
|
730
|
+
|
|
731
|
+
/**
|
|
732
|
+
* Property definition type
|
|
733
|
+
*/
|
|
734
|
+
interface PropertyDefinition {
|
|
735
|
+
type: 'string' | 'number' | 'boolean' | 'object' | 'array';
|
|
736
|
+
default?: unknown;
|
|
737
|
+
reflect?: boolean;
|
|
738
|
+
attribute?: string | false;
|
|
739
|
+
observer?: string;
|
|
740
|
+
render?: boolean;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
/**
|
|
744
|
+
* ${Q} custom element
|
|
745
|
+
*/
|
|
746
|
+
export class ${W} extends ${X} {
|
|
747
|
+
// Property definitions
|
|
748
|
+
private _propertyDefs: Record<string, PropertyDefinition> = ${JSON.stringify(G)};
|
|
749
|
+
private _attrToProp: Record<string, string> = ${JSON.stringify(Object.fromEntries(q.filter((R)=>G[R].attribute!==!1).map((R)=>[G[R].attribute||E0(R),R])))};
|
|
750
|
+
|
|
751
|
+
// Internal state
|
|
752
|
+
private _state: ${W}State = ${JSON.stringify(j)};
|
|
753
|
+
private _renderPending = false;
|
|
754
|
+
private _isConnected = false;
|
|
755
|
+
private _root: ShadowRoot | HTMLElement;
|
|
756
|
+
|
|
757
|
+
// Property backing fields
|
|
758
|
+
${B}
|
|
759
|
+
|
|
760
|
+
constructor() {
|
|
761
|
+
super();
|
|
762
|
+
${z?'this.attachShadow({ mode: "open" });':""}
|
|
763
|
+
this._root = ${z?"this.shadowRoot!":"this"};
|
|
764
|
+
|
|
765
|
+
// Initialize properties with defaults
|
|
766
|
+
${q.map((R)=>{let k=G[R],D=k.default!==void 0?JSON.stringify(k.default):k.type==="string"?'""':k.type==="number"?"0":k.type==="boolean"?"false":k.type==="array"?"[]":"{}";return` this._${R} = ${D};`}).join(`
|
|
767
|
+
`)}
|
|
768
|
+
|
|
769
|
+
// Initial render
|
|
770
|
+
this._render();
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
// =========================================================================
|
|
774
|
+
// Reactive Properties
|
|
775
|
+
// =========================================================================
|
|
776
|
+
${A}
|
|
777
|
+
|
|
778
|
+
// =========================================================================
|
|
779
|
+
// State Management
|
|
780
|
+
// =========================================================================
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* Get current internal state
|
|
784
|
+
*/
|
|
785
|
+
get state(): ${W}State {
|
|
786
|
+
return { ...this._state };
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
/**
|
|
790
|
+
* Update internal state and trigger re-render
|
|
791
|
+
*/
|
|
792
|
+
setState(updates: Partial<${W}State>): void {
|
|
793
|
+
const oldState = { ...this._state };
|
|
794
|
+
this._state = { ...this._state, ...updates };
|
|
795
|
+
this._scheduleRender();
|
|
796
|
+
this.dispatchEvent(new CustomEvent('state-changed', {
|
|
797
|
+
detail: { state: this._state, oldState },
|
|
798
|
+
bubbles: true
|
|
799
|
+
}));
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
// =========================================================================
|
|
803
|
+
// Rendering
|
|
804
|
+
// =========================================================================
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* Schedule a render on the next animation frame (batched)
|
|
808
|
+
*/
|
|
809
|
+
private _scheduleRender(): void {
|
|
810
|
+
if (this._renderPending) return;
|
|
811
|
+
this._renderPending = true;
|
|
812
|
+
requestAnimationFrame(() => {
|
|
813
|
+
this._renderPending = false;
|
|
814
|
+
this._render();
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* Render the component template
|
|
820
|
+
*/
|
|
821
|
+
private _render(): void {
|
|
822
|
+
const template = \`${T?`<style>${T}</style>`:""}${I}\`;
|
|
823
|
+
|
|
824
|
+
// Interpolate template with property values
|
|
825
|
+
const rendered = template.replace(/\\{\\{\\s*(\\w+)\\s*\\}\\}/g, (match, propName) => {
|
|
826
|
+
if (propName in this) {
|
|
827
|
+
const value = (this as unknown as Record<string, unknown>)[propName];
|
|
828
|
+
if (value === null || value === undefined) return '';
|
|
829
|
+
if (typeof value === 'object') return JSON.stringify(value);
|
|
830
|
+
return String(value);
|
|
831
|
+
}
|
|
832
|
+
if (propName in this._state) {
|
|
833
|
+
const value = this._state[propName as keyof ${W}State];
|
|
834
|
+
if (value === null || value === undefined) return '';
|
|
835
|
+
if (typeof value === 'object') return JSON.stringify(value);
|
|
836
|
+
return String(value);
|
|
837
|
+
}
|
|
838
|
+
return match;
|
|
839
|
+
});
|
|
840
|
+
|
|
841
|
+
this._root.innerHTML = rendered;
|
|
842
|
+
this._bindEvents();
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
/**
|
|
846
|
+
* Bind event handlers after render
|
|
847
|
+
*/
|
|
848
|
+
private _bindEvents(): void {
|
|
849
|
+
${F}
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
// =========================================================================
|
|
853
|
+
// Attribute Handling
|
|
854
|
+
// =========================================================================
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* Deserialize attribute value to property type
|
|
858
|
+
*/
|
|
859
|
+
private _deserializeAttribute(value: string | null, type: string): unknown {
|
|
860
|
+
if (value === null) return null;
|
|
861
|
+
switch (type) {
|
|
862
|
+
case 'number': return Number(value);
|
|
863
|
+
case 'boolean': return value !== null && value !== 'false' && value !== '0';
|
|
864
|
+
case 'object':
|
|
865
|
+
case 'array':
|
|
866
|
+
try { return JSON.parse(value); }
|
|
867
|
+
catch { return type === 'array' ? [] : {}; }
|
|
868
|
+
default: return value;
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
${w}
|
|
873
|
+
|
|
874
|
+
// =========================================================================
|
|
875
|
+
// Lifecycle
|
|
876
|
+
// =========================================================================
|
|
877
|
+
|
|
878
|
+
connectedCallback(): void {
|
|
879
|
+
this._isConnected = true;
|
|
880
|
+
${U.connected||"// Component connected to DOM"}
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
disconnectedCallback(): void {
|
|
884
|
+
this._isConnected = false;
|
|
885
|
+
${U.disconnected||"// Component disconnected from DOM"}
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
adoptedCallback(): void {
|
|
889
|
+
${U.adopted||"// Component moved to new document"}
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
// =========================================================================
|
|
893
|
+
// Custom Methods
|
|
894
|
+
// =========================================================================
|
|
895
|
+
${N}
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
// Type augmentation for HTMLElementTagNameMap
|
|
899
|
+
declare global {
|
|
900
|
+
interface HTMLElementTagNameMap {
|
|
901
|
+
'${$}': ${W};
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
// Register the custom element
|
|
906
|
+
customElements.define('${$}', ${W});
|
|
907
|
+
|
|
908
|
+
export default ${W};
|
|
909
|
+
`}function u7(){return`/**
|
|
910
|
+
* ReactiveElement Mixin
|
|
911
|
+
* Adds reactive properties and lifecycle management to web components
|
|
912
|
+
*/
|
|
913
|
+
const ReactiveElement = (Base) => class extends Base {
|
|
914
|
+
static get observedAttributes() {
|
|
915
|
+
const props = this.properties || {};
|
|
916
|
+
return Object.keys(props)
|
|
917
|
+
.filter(prop => props[prop].attribute !== false)
|
|
918
|
+
.map(prop => props[prop].attribute || prop.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase());
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
constructor() {
|
|
922
|
+
super();
|
|
923
|
+
this._state = {};
|
|
924
|
+
this._renderPending = false;
|
|
925
|
+
this._propertyValues = new Map();
|
|
926
|
+
this._initializeProperties();
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
_initializeProperties() {
|
|
930
|
+
const props = this.constructor.properties || {};
|
|
931
|
+
for (const [name, def] of Object.entries(props)) {
|
|
932
|
+
// Set default value
|
|
933
|
+
if (def.default !== undefined) {
|
|
934
|
+
this._propertyValues.set(name, def.default);
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
// Define getter/setter
|
|
938
|
+
Object.defineProperty(this, name, {
|
|
939
|
+
get: () => this._propertyValues.get(name),
|
|
940
|
+
set: (value) => {
|
|
941
|
+
const oldValue = this._propertyValues.get(name);
|
|
942
|
+
if (oldValue === value) return;
|
|
943
|
+
this._propertyValues.set(name, value);
|
|
944
|
+
|
|
945
|
+
// Reflect to attribute
|
|
946
|
+
if (def.reflect) {
|
|
947
|
+
const attrName = def.attribute || name.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
|
|
948
|
+
if (def.type === 'boolean') {
|
|
949
|
+
value ? this.setAttribute(attrName, '') : this.removeAttribute(attrName);
|
|
950
|
+
}
|
|
951
|
+
else {
|
|
952
|
+
this.setAttribute(attrName, def.type === 'object' ? JSON.stringify(value) : String(value));
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
// Call observer
|
|
957
|
+
if (def.observer && typeof this[def.observer] === 'function') {
|
|
958
|
+
this[def.observer](value, oldValue);
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
// Schedule render
|
|
962
|
+
if (def.render !== false) {
|
|
963
|
+
this._scheduleRender();
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
// Dispatch event
|
|
967
|
+
this.dispatchEvent(new CustomEvent(\`\${name}-changed\`, {
|
|
968
|
+
detail: { value, oldValue },
|
|
969
|
+
bubbles: true
|
|
970
|
+
}));
|
|
971
|
+
},
|
|
972
|
+
enumerable: true,
|
|
973
|
+
configurable: true
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
979
|
+
if (oldValue === newValue) return;
|
|
980
|
+
const props = this.constructor.properties || {};
|
|
981
|
+
const propName = Object.keys(props).find(p =>
|
|
982
|
+
(props[p].attribute || p.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase()) === name
|
|
983
|
+
);
|
|
984
|
+
if (propName) {
|
|
985
|
+
const def = props[propName];
|
|
986
|
+
this[propName] = this._deserialize(newValue, def.type);
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
_deserialize(value, type) {
|
|
991
|
+
if (value === null) return null;
|
|
992
|
+
switch (type) {
|
|
993
|
+
case 'number': return Number(value);
|
|
994
|
+
case 'boolean': return value !== null && value !== 'false';
|
|
995
|
+
case 'object':
|
|
996
|
+
case 'array':
|
|
997
|
+
try { return JSON.parse(value); }
|
|
998
|
+
catch { return type === 'array' ? [] : {}; }
|
|
999
|
+
default: return value;
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
get state() {
|
|
1004
|
+
return { ...this._state };
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
setState(updates) {
|
|
1008
|
+
const oldState = { ...this._state };
|
|
1009
|
+
this._state = { ...this._state, ...updates };
|
|
1010
|
+
this._scheduleRender();
|
|
1011
|
+
this.dispatchEvent(new CustomEvent('state-changed', {
|
|
1012
|
+
detail: { state: this._state, oldState },
|
|
1013
|
+
bubbles: true
|
|
1014
|
+
}));
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
_scheduleRender() {
|
|
1018
|
+
if (this._renderPending) return;
|
|
1019
|
+
this._renderPending = true;
|
|
1020
|
+
requestAnimationFrame(() => {
|
|
1021
|
+
this._renderPending = false;
|
|
1022
|
+
if (typeof this.render === 'function') {
|
|
1023
|
+
this.render();
|
|
1024
|
+
}
|
|
1025
|
+
});
|
|
1026
|
+
}
|
|
1027
|
+
};
|
|
1028
|
+
|
|
1029
|
+
export { ReactiveElement };
|
|
1030
|
+
export default ReactiveElement;
|
|
1031
|
+
`}function l7(){return`/**
|
|
1032
|
+
* stx Reactive Web Components Runtime
|
|
1033
|
+
* Provides base classes and utilities for reactive web components
|
|
1034
|
+
*/
|
|
1035
|
+
(function(global) {
|
|
1036
|
+
'use strict';
|
|
1037
|
+
|
|
1038
|
+
/**
|
|
1039
|
+
* Base class for reactive web components
|
|
1040
|
+
*/
|
|
1041
|
+
class StxElement extends HTMLElement {
|
|
1042
|
+
static get observedAttributes() {
|
|
1043
|
+
const props = this.properties || {};
|
|
1044
|
+
return Object.keys(props)
|
|
1045
|
+
.filter(prop => props[prop].attribute !== false)
|
|
1046
|
+
.map(prop => props[prop].attribute || toKebabCase(prop));
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
constructor() {
|
|
1050
|
+
super();
|
|
1051
|
+
this._state = {};
|
|
1052
|
+
this._renderPending = false;
|
|
1053
|
+
this._props = new Map();
|
|
1054
|
+
this._setupShadowDOM();
|
|
1055
|
+
this._initProperties();
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
_setupShadowDOM() {
|
|
1059
|
+
if (this.constructor.useShadowDOM !== false) {
|
|
1060
|
+
this.attachShadow({ mode: 'open' });
|
|
1061
|
+
this._root = this.shadowRoot;
|
|
1062
|
+
}
|
|
1063
|
+
else {
|
|
1064
|
+
this._root = this;
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
_initProperties() {
|
|
1069
|
+
const props = this.constructor.properties || {};
|
|
1070
|
+
for (const [name, def] of Object.entries(props)) {
|
|
1071
|
+
let value = def.default;
|
|
1072
|
+
this._props.set(name, value);
|
|
1073
|
+
|
|
1074
|
+
Object.defineProperty(this, name, {
|
|
1075
|
+
get: () => this._props.get(name),
|
|
1076
|
+
set: (newValue) => this._setProperty(name, newValue, def),
|
|
1077
|
+
enumerable: true
|
|
1078
|
+
});
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
_setProperty(name, value, def) {
|
|
1083
|
+
const oldValue = this._props.get(name);
|
|
1084
|
+
if (oldValue === value) return;
|
|
1085
|
+
|
|
1086
|
+
this._props.set(name, value);
|
|
1087
|
+
|
|
1088
|
+
if (def.reflect && def.attribute !== false) {
|
|
1089
|
+
this._reflectToAttribute(name, value, def);
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
if (def.observer && this[def.observer]) {
|
|
1093
|
+
this[def.observer](value, oldValue);
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
if (def.render !== false) {
|
|
1097
|
+
this.requestUpdate();
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
this.dispatchEvent(new CustomEvent(name + '-changed', {
|
|
1101
|
+
detail: { value, oldValue },
|
|
1102
|
+
bubbles: true,
|
|
1103
|
+
composed: true
|
|
1104
|
+
}));
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
_reflectToAttribute(name, value, def) {
|
|
1108
|
+
const attrName = def.attribute || toKebabCase(name);
|
|
1109
|
+
if (value == null || (def.type === 'boolean' && !value)) {
|
|
1110
|
+
this.removeAttribute(attrName);
|
|
1111
|
+
}
|
|
1112
|
+
else if (def.type === 'boolean') {
|
|
1113
|
+
this.setAttribute(attrName, '');
|
|
1114
|
+
}
|
|
1115
|
+
else if (def.type === 'object' || def.type === 'array') {
|
|
1116
|
+
this.setAttribute(attrName, JSON.stringify(value));
|
|
1117
|
+
}
|
|
1118
|
+
else {
|
|
1119
|
+
this.setAttribute(attrName, String(value));
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
1124
|
+
if (oldValue === newValue) return;
|
|
1125
|
+
const props = this.constructor.properties || {};
|
|
1126
|
+
const propName = Object.keys(props).find(p => {
|
|
1127
|
+
const def = props[p];
|
|
1128
|
+
return (def.attribute || toKebabCase(p)) === name;
|
|
1129
|
+
});
|
|
1130
|
+
|
|
1131
|
+
if (propName) {
|
|
1132
|
+
const def = props[propName];
|
|
1133
|
+
this[propName] = deserialize(newValue, def.type);
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
get state() {
|
|
1138
|
+
return { ...this._state };
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
setState(updates) {
|
|
1142
|
+
const oldState = { ...this._state };
|
|
1143
|
+
Object.assign(this._state, updates);
|
|
1144
|
+
this.requestUpdate();
|
|
1145
|
+
this.dispatchEvent(new CustomEvent('state-changed', {
|
|
1146
|
+
detail: { state: this._state, oldState },
|
|
1147
|
+
bubbles: true
|
|
1148
|
+
}));
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
requestUpdate() {
|
|
1152
|
+
if (this._renderPending) return;
|
|
1153
|
+
this._renderPending = true;
|
|
1154
|
+
requestAnimationFrame(() => {
|
|
1155
|
+
this._renderPending = false;
|
|
1156
|
+
this.update();
|
|
1157
|
+
});
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
update() {
|
|
1161
|
+
if (this.render) {
|
|
1162
|
+
const content = this.render();
|
|
1163
|
+
if (typeof content === 'string') {
|
|
1164
|
+
this._root.innerHTML = content;
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
connectedCallback() {
|
|
1170
|
+
this.update();
|
|
1171
|
+
if (this.connected) this.connected();
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
disconnectedCallback() {
|
|
1175
|
+
if (this.disconnected) this.disconnected();
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
adoptedCallback() {
|
|
1179
|
+
if (this.adopted) this.adopted();
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
// Template helper
|
|
1183
|
+
html(strings, ...values) {
|
|
1184
|
+
return strings.reduce((result, str, i) => {
|
|
1185
|
+
let value = values[i] || '';
|
|
1186
|
+
if (Array.isArray(value)) value = value.join('');
|
|
1187
|
+
if (typeof value === 'object') value = JSON.stringify(value);
|
|
1188
|
+
return result + str + value;
|
|
1189
|
+
}, '');
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
// Utility functions
|
|
1194
|
+
function toKebabCase(str) {
|
|
1195
|
+
return str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
function deserialize(value, type) {
|
|
1199
|
+
if (value === null) return null;
|
|
1200
|
+
switch (type) {
|
|
1201
|
+
case 'number': return Number(value);
|
|
1202
|
+
case 'boolean': return value !== null && value !== 'false' && value !== '0';
|
|
1203
|
+
case 'object':
|
|
1204
|
+
case 'array':
|
|
1205
|
+
try { return JSON.parse(value); }
|
|
1206
|
+
catch { return type === 'array' ? [] : {}; }
|
|
1207
|
+
default: return value;
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
// Export to global
|
|
1212
|
+
global.StxElement = StxElement;
|
|
1213
|
+
global.stxComponents = global.stxComponents || {};
|
|
1214
|
+
|
|
1215
|
+
// Helper to define components
|
|
1216
|
+
global.defineStxComponent = function(tag, config) {
|
|
1217
|
+
const { properties, template, styles, methods, ...options } = config;
|
|
1218
|
+
|
|
1219
|
+
class Component extends StxElement {
|
|
1220
|
+
static get properties() { return properties || {}; }
|
|
1221
|
+
static get useShadowDOM() { return options.shadowDOM !== false; }
|
|
1222
|
+
|
|
1223
|
+
render() {
|
|
1224
|
+
let html = template || '';
|
|
1225
|
+
// Simple interpolation
|
|
1226
|
+
html = html.replace(/\\{\\{\\s*(\\w+)\\s*\\}\\}/g, (match, key) => {
|
|
1227
|
+
if (key in this) return this[key] ?? '';
|
|
1228
|
+
if (key in this._state) return this._state[key] ?? '';
|
|
1229
|
+
return match;
|
|
1230
|
+
});
|
|
1231
|
+
return (styles ? '<style>' + styles + '</style>' : '') + html;
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
// Add methods
|
|
1236
|
+
if (methods) {
|
|
1237
|
+
for (const [name, fn] of Object.entries(methods)) {
|
|
1238
|
+
Component.prototype[name] = fn;
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
customElements.define(tag, Component);
|
|
1243
|
+
global.stxComponents[tag] = Component;
|
|
1244
|
+
return Component;
|
|
1245
|
+
};
|
|
1246
|
+
|
|
1247
|
+
})(typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : this);
|
|
1248
|
+
`}function h5(Y,Q){let $=Y.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),X=$?$[1].trim():"",J=Q,Z=[],z=!0;if(X){let j=X.match(/export\s+default\s+({[\s\S]*})/);if(j)try{let W=j[1],q=W.match(/tag\s*:\s*['"`]([^'"`]+)['"`]/);if(q)J=q[1];let H=W.match(/props\s*:\s*\[([\s\S]*?)\]/);if(H)Z=H[1].split(",").map((O)=>O.trim().replace(/['"`]/g,"")).filter((O)=>O.length>0);let L=W.match(/shadowDOM\s*:\s*(true|false)/);if(L)z=L[1]==="true"}catch{}}let G=Y.match(/<template\b(?![^>]*\bid\s*=)[^>]*>([\s\S]*?)<\/template>/i),U=G?G[1].trim():"",_=Y.match(/<style\b[^>]*>([\s\S]*?)<\/style>/i),K=_?_[1].trim():"";return{tag:J,props:Z,template:U,styles:K,script:X,shadowDOM:z}}function d5(Y){let{tag:Q,props:$,template:X,styles:J,shadowDOM:Z}=Y,z=Q.split("-").map((j)=>j.charAt(0).toUpperCase()+j.slice(1)).join(""),G=X.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),U=J.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),_=$.map((j)=>`'${j}'`).join(", "),K=$.map((j)=>`
|
|
1249
|
+
get ${j}() {
|
|
1250
|
+
return this.getAttribute('${j}') || '';
|
|
1251
|
+
}
|
|
1252
|
+
set ${j}(value) {
|
|
1253
|
+
if (value) {
|
|
1254
|
+
this.setAttribute('${j}', value);
|
|
1255
|
+
}
|
|
1256
|
+
else {
|
|
1257
|
+
this.removeAttribute('${j}');
|
|
1258
|
+
}
|
|
1259
|
+
}`).join(`
|
|
1260
|
+
`);return`/**
|
|
1261
|
+
* ${z} Web Component
|
|
1262
|
+
* Auto-generated from SFC
|
|
1263
|
+
*/
|
|
1264
|
+
class ${z} extends HTMLElement {
|
|
1265
|
+
constructor() {
|
|
1266
|
+
super();
|
|
1267
|
+
${Z?"this.attachShadow({ mode: 'open' });":""}
|
|
1268
|
+
this._render();
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
static get observedAttributes() {
|
|
1272
|
+
return [${_}];
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
1276
|
+
if (oldValue !== newValue) {
|
|
1277
|
+
this._render();
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
${K}
|
|
1281
|
+
|
|
1282
|
+
_render() {
|
|
1283
|
+
const template = \`${U?`<style>${U}</style>`:""}${G}\`;
|
|
1284
|
+
|
|
1285
|
+
// Interpolate {{ prop }} with attribute values
|
|
1286
|
+
const rendered = template.replace(/\\{\\{\\s*(\\w+)\\s*\\}\\}/g, (match, prop) => {
|
|
1287
|
+
return this.getAttribute(prop) || '';
|
|
1288
|
+
});
|
|
1289
|
+
|
|
1290
|
+
${Z?"this.shadowRoot.innerHTML = rendered;":"this.innerHTML = rendered;"}
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
connectedCallback() {
|
|
1294
|
+
this._render();
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
customElements.define('${Q}', ${z});
|
|
1299
|
+
`}async function j3(Y,Q,$,X){if(Q.length<1)return H0("WebComponent","@webcomponent directive requires at least the tag name parameter",q0.INVALID_DIRECTIVE_SYNTAX);let J=Q[0].replace(/['"]/g,""),z=($.__stx_options||{}).componentsDir||"components",G=[A0.join(A0.dirname(X),z,`${J}.stx`),A0.join(process.cwd(),z,`${J}.stx`),A0.join(A0.dirname(X),`${J}.stx`)],U=null;for(let j of G)if(await x(j)){U=await Bun.file(j).text();break}if(!U)return H0("WebComponent",`Component file not found: ${J}.stx`,q0.FILE_NOT_FOUND);let _=h5(U,J);return`<script type="module">
|
|
1300
|
+
${d5(_)}
|
|
1301
|
+
</script>`}var D3={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,cachePath:".stx/cache",cacheVersion:"1.0.0",build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:H3,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:j3,hasEndTag:!1,description:"Include a web component in the template"},W3,L3,k3,N3,B3,V3,A3,O3,w3,F3,R3,T3,...I3],middleware:[],i18n:{defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},webComponents:{enabled:!1,outputDir:"dist/web-components",components:[]},docs:{enabled:!1,outputDir:"docs",format:"markdown",components:!0,templates:!0,directives:!0},streaming:{enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},hydration:{enabled:!1,mode:"islands",clientEntry:"src/client.ts",autoMarkers:!0,preload:"lazy"},router:{enabled:!0,container:"#app-content",linkSelector:"a[href]",viewTransitions:!0,scrollToTop:!0,prefetch:!0,cache:!0,cacheTTL:300000,skipSelectors:'[data-no-router], [target="_blank"]',viewTransitionCSS:{oldRoot:"fade-out 0.15s ease-in",newRoot:"fade-in 0.2s ease-out",oldContent:"slide-out 0.2s ease-in",newContent:"slide-in 0.25s ease-out"}},a11y:{enabled:!0,addSrOnlyStyles:!0,level:"AA",autoFix:!1,ignoreChecks:[]},seo:{enabled:!0,socialPreview:!0,defaultConfig:{title:"stx Project",description:"A website built with stx templating engine"}},animation:{enabled:!0,defaultDuration:300,defaultEase:"ease",respectMotionPreferences:!0,staggerDelay:50},markdown:{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0,additionalThemes:["light-plus","one-dark-pro","dracula","monokai","solarized-light","nord","github-dark"]}},loops:{maxWhileIterations:1000,useAltLoopVariable:!1},story:{enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],port:6006},pwa:{enabled:!1,manifest:{name:"stx App",shortName:"stx",description:"A Progressive Web App built with stx",startUrl:"/",display:"standalone",orientation:"any",themeColor:"#000000",backgroundColor:"#ffffff",scope:"/"},icons:{src:"public/icon.png",sizes:[72,96,128,144,152,192,384,512],generateWebP:!0,generateAppleIcons:!0,outputDir:"pwa-icons",purpose:["any","maskable"]},routes:[{pattern:"/",strategy:"network-first"},{pattern:"/static/*",strategy:"cache-first",maxAgeSeconds:2592000},{pattern:"/api/*",strategy:"network-only"},{pattern:"*.js",strategy:"stale-while-revalidate"},{pattern:"*.css",strategy:"stale-while-revalidate"},{pattern:"*.png",strategy:"cache-first"},{pattern:"*.jpg",strategy:"cache-first"},{pattern:"*.webp",strategy:"cache-first"},{pattern:"*.svg",strategy:"cache-first"}],offline:{enabled:!0,fallbackTitle:"You are offline",fallbackMessage:"Please check your internet connection and try again.",precacheAssets:[]},serviceWorker:{fileName:"sw.js",cacheVersion:"1.0.0",skipWaiting:!0,clientsClaim:!0,navigationPreload:!1,excludeRoutes:["/api/auth/*"],cacheFileTypes:["html","css","js","png","jpg","jpeg","webp","svg","woff","woff2"],useWorkbox:!1},autoInject:!0,push:{enabled:!1,defaultOptions:{vibrate:[100,50,100],requireInteraction:!1}},backgroundSync:{enabled:!1,queueName:"stx-sync-queue",maxRetentionMinutes:1440,maxRetries:3,minInterval:1000,forms:[],endpoints:[]},shareTarget:{enabled:!1,action:"/share-target",method:"POST",enctype:"multipart/form-data",params:{title:"title",text:"text",url:"url"}},fileHandlers:{enabled:!1},protocolHandlers:[],cacheStorage:{maxSize:100,maxEntries:500,maxAge:30,purgeStrategy:"lru"},updates:{enabled:!0,promptUser:!0,autoReload:!1,message:"A new version is available. Reload to update?"},precache:{enabled:!0,includeHtml:!0,includeJs:!0,includeCss:!0,includeImages:!0,includeFonts:!0,include:[],exclude:["*.map","*.LICENSE.txt"],maxFileSizeKB:500}},media:{enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3],tsImages:{enabled:!0,outputDir:"dist/images",baseUrl:"/images",formatQuality:{jpeg:{quality:85,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4,lossless:!1}},breakpoints:[320,480,640,768,1024,1280,1536,1920],batchOptions:{concurrency:4,optimizationPreset:"web"}}},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0,tsVideos:{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos",defaultQuality:"high",streaming:{enabled:!0,format:"hls",segmentDuration:6,defaultQualities:[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000}]},thumbnails:{enabled:!0,count:10,format:"webp",width:320},transcoding:{defaultCodec:"h264",defaultAudioCodec:"aac",speedPreset:"medium"}}},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}},broadcasting:{enabled:!1,driver:"bun",host:"0.0.0.0",port:6001,scheme:"ws",verbose:!1}};function u5(Y,Q){let $=Q||"pages";if(Y)return{root:Y,pagesDir:$};let X=Z0.join(process.cwd(),"resources","views"),J=Z0.join(process.cwd(),"resources","layouts");if(w1.existsSync(X)&&w1.existsSync(J))return{root:"resources",pagesDir:"views"};let Z=Z0.join(process.cwd(),"resources","views","pages");if(w1.existsSync(Z))return{root:"resources/views",pagesDir:$};return{root:".",pagesDir:$}}var M0=null,_3=new Map,o0=null;async function l5(Y){if(!Y){if(M0)return M0;if(o0)return o0}let Q=Y?Z0.resolve(Y):process.cwd(),$=_3.get(Q);if($)return $;let X=(async()=>{let Z=(await m5({name:"stx",alias:"ui",cwd:Q,defaultConfig:D3,verbose:!1})).config,z=u5(Z.root,Z.pagesDir);if(Z.root=z.root,Z.pagesDir=z.pagesDir,Z.root&&Z.root!=="."){let G=Z.root;if(Z.partialsDir&&!Z0.isAbsolute(Z.partialsDir))Z.partialsDir=Z0.join(G,Z.partialsDir);if(Z.componentsDir&&!Z0.isAbsolute(Z.componentsDir))Z.componentsDir=Z0.join(G,Z.componentsDir);if(Z.layoutsDir&&!Z0.isAbsolute(Z.layoutsDir))Z.layoutsDir=Z0.join(G,Z.layoutsDir)}if(Z.plugins&&Z.plugins.length>0){let{pluginManager:G}=await import("././plugin-system.js"),U=[],_=[];for(let K of Z.plugins){let j=typeof K==="string"?K:K[0],W=typeof K==="string"?{}:K[1]||{};try{let q,H;try{q=await import(j),H=Z0.dirname(g.resolve(j))}catch{let O=Z0.resolve(process.cwd(),j);q=await import(O),H=Z0.dirname(O)}let L=q.default||q;if(G.register(L,Z),L.components){let O=Z0.resolve(H,L.components);U.push(O)}if(L.pages){let O=Z0.resolve(H,L.pages),V=W.path||"/";_.push({dir:O,prefix:V})}if(L.setup){let O={addDirective:(V)=>{Z.customDirectives=Z.customDirectives||[],Z.customDirectives.push(V)},addRoute:(V,B)=>{Z.apiRoutes=Z.apiRoutes||{},Z.apiRoutes[V]=B},addMiddleware:(V)=>{Z.middleware=Z.middleware||[],Z.middleware.push(V)},pluginDir:H,config:Z};await L.setup(W,O)}console.log(`[stx] Plugin loaded: ${L.name||j}`)}catch(q){console.warn(`[stx] Failed to load plugin ${j}:`,q.message)}}Z._pluginComponentDirs=U,Z._pluginPageDirs=_}return Z})();if(_3.set(Q,X),!Y)o0=X,X.then((J)=>{M0=J}).catch(()=>{});return X}var E3=new Proxy(D3,{get(Y,Q){if(M0&&Q in M0)return M0[Q];if(!o0)l5().catch(($)=>{console.warn("[stx] Failed to load config file:",$?.message||$)});return Y[Q]}});function Q9(Y){return Y}function J9(Y){let Q=[],$=[];if(Y.partialsDir!==void 0&&typeof Y.partialsDir!=="string")Q.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if(Y.componentsDir!==void 0&&typeof Y.componentsDir!=="string")Q.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if(Y.cache!==void 0&&typeof Y.cache!=="boolean")Q.push({path:"cache",message:"cache must be a boolean",severity:"error"});if(Y.debug!==void 0&&typeof Y.debug!=="boolean")Q.push({path:"debug",message:"debug must be a boolean",severity:"error"});if(Y.streaming){if(Y.streaming.bufferSize!==void 0){if(typeof Y.streaming.bufferSize!=="number"||Y.streaming.bufferSize<=0)Q.push({path:"streaming.bufferSize",message:"streaming.bufferSize must be a positive number",severity:"error"})}if(Y.streaming.timeout!==void 0){if(typeof Y.streaming.timeout!=="number"||Y.streaming.timeout<=0)Q.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if(Y.streaming.strategy!==void 0){let X=["auto","manual","sections"];if(!X.includes(Y.streaming.strategy))Q.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${X.join(", ")}`,severity:"error"})}}if(Y.i18n){if(Y.i18n.format!==void 0){let X=["json","yaml","yml","js"];if(!X.includes(Y.i18n.format))Q.push({path:"i18n.format",message:`i18n.format must be one of: ${X.join(", ")}`,severity:"error"})}}if(Y.animation){if(Y.animation.defaultDuration!==void 0){if(typeof Y.animation.defaultDuration!=="number"||Y.animation.defaultDuration<0)Q.push({path:"animation.defaultDuration",message:"animation.defaultDuration must be a non-negative number",severity:"error"})}if(Y.animation.staggerDelay!==void 0){if(typeof Y.animation.staggerDelay!=="number"||Y.animation.staggerDelay<0)Q.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if(Y.a11y){if(Y.a11y.level!==void 0){let X=["AA","AAA"];if(!X.includes(Y.a11y.level))Q.push({path:"a11y.level",message:`a11y.level must be one of: ${X.join(", ")}`,severity:"error"})}}if(Y.hydration){if(Y.hydration.mode!==void 0){let X=["progressive","islands"];if(!X.includes(Y.hydration.mode))Q.push({path:"hydration.mode",message:`hydration.mode must be one of: ${X.join(", ")}`,severity:"error"})}if(Y.hydration.preload!==void 0){let X=["none","eager","lazy"];if(!X.includes(Y.hydration.preload))Q.push({path:"hydration.preload",message:`hydration.preload must be one of: ${X.join(", ")}`,severity:"error"})}}if(Y.customDirectives)if(!Array.isArray(Y.customDirectives))Q.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else Y.customDirectives.forEach((X,J)=>{if(!X.name||typeof X.name!=="string")Q.push({path:`customDirectives[${J}].name`,message:"Custom directive must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Q.push({path:`customDirectives[${J}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if(Y.middleware)if(!Array.isArray(Y.middleware))Q.push({path:"middleware",message:"middleware must be an array",severity:"error"});else Y.middleware.forEach((X,J)=>{if(!X.name||typeof X.name!=="string")Q.push({path:`middleware[${J}].name`,message:"Middleware must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Q.push({path:`middleware[${J}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!X.timing||!["before","after"].includes(X.timing))Q.push({path:`middleware[${J}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if(Y.debug===!0&&Y.cache===!0)$.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if(Y.seo?.enabled===!0&&!Y.seo?.defaultConfig?.title)$.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if(Y.pwa){if(Y.pwa.enabled===!0&&!Y.pwa.manifest?.name)Q.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if(Y.pwa.manifest?.display!==void 0){let X=["fullscreen","standalone","minimal-ui","browser"];if(!X.includes(Y.pwa.manifest.display))Q.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${X.join(", ")}`,severity:"error"})}if(Y.pwa.manifest?.orientation!==void 0){let X=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!X.includes(Y.pwa.manifest.orientation))Q.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${X.join(", ")}`,severity:"error"})}if(Y.pwa.routes){let X=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];Y.pwa.routes.forEach((J,Z)=>{if(!J.pattern||typeof J.pattern!=="string")Q.push({path:`pwa.routes[${Z}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!X.includes(J.strategy))Q.push({path:`pwa.routes[${Z}].strategy`,message:`PWA route strategy must be one of: ${X.join(", ")}`,severity:"error"});if(J.maxAgeSeconds!==void 0&&(typeof J.maxAgeSeconds!=="number"||J.maxAgeSeconds<0))Q.push({path:`pwa.routes[${Z}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(J.maxEntries!==void 0&&(typeof J.maxEntries!=="number"||J.maxEntries<1))Q.push({path:`pwa.routes[${Z}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if(Y.pwa.icons?.sizes){if(!Array.isArray(Y.pwa.icons.sizes))Q.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if(Y.pwa.icons.sizes.filter((J)=>typeof J!=="number"||J<16||J>1024).length>0)Q.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if(Y.pwa.icons?.purpose){let X=["any","maskable","monochrome"];if(Y.pwa.icons.purpose.filter((Z)=>!X.includes(Z)).length>0)Q.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${X.join(", ")}`,severity:"error"})}if(Y.pwa.enabled===!0&&!Y.pwa.icons?.src)$.push({path:"pwa.icons.src",message:"PWA is enabled but no icon source specified. Provide a 512x512 PNG for best results.",severity:"warning"});if(Y.pwa.enabled===!0&&!Y.pwa.manifest?.themeColor)$.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:Q.length===0,errors:Q,warnings:$}}var R1=new Map;async function p5(Y,Q={}){try{if(!await x(Y))throw Error(`Markdown file not found: ${Y}`);let X=(await c5.promises.stat(Y)).mtime.getTime();if(Q.cache&&R1.has(Y)){let j=R1.get(Y);if(j.updatedAt>=X)return{content:j.content,data:j.data}}let J=await Bun.file(Y).text(),{data:Z,content:z}=M3(J),G=Q.markdown||E3.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},_=P0(z,{gfm:!0});if(G.syntaxHighlighting?.enabled&&G.syntaxHighlighting?.serverSide)_=await s5(_,G.syntaxHighlighting?.defaultTheme||"github-dark",G.syntaxHighlighting?.highlightUnknownLanguages||!1);let K={content:_,data:Z||{}};if(Q.cache)R1.set(Y,{...K,updatedAt:X});return K}catch($){if(Q.debug)console.error(`Error reading/parsing markdown file ${Y}:`,$);let X=$ instanceof Error?$.message:String($);return{content:p("Markdown File",`Error reading/parsing markdown file: ${X}`,Y,"",0,""),data:{}}}}var e0=null;async function s5(Y,Q,$){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!e0)try{e0=await i5({theme:Q||"github-dark",cache:!0})}catch(G){return console.error("Failed to initialize ts-syntax-highlighter:",G),Y}let J=async(G,U,_,K)=>{let j=K.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),W=_||($?"text":"");if(!W)return G;try{if(!e0.getSupportedLanguages().includes(W))return G;return(await e0.highlight(j,W,{theme:Q})).html}catch(q){console.error(`Error highlighting code block with language ${_}:`,q)}return G},Z=Y,z=Y.matchAll(X);for(let G of z){let[U,_,K,j]=G,W=await J(U,_,K,j);Z=Z.replace(U,W)}return Z}async function y3(Y,Q,$="",X={}){return await n5(Y,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(z,G,U,_)=>{try{let K=G;if(!F1.isAbsolute(G))K=F1.resolve(F1.dirname($),G);let j={};if(U)try{try{j=JSON.parse(U)}catch{if(X.debug)console.warn("Using safer alternative for parsing JS object literal");let B=U.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let A of B){let w=A.indexOf(":");if(w>0){let F=A.substring(0,w).trim(),N=A.substring(w+1).trim(),I=N.startsWith('"')&&N.endsWith('"'),T=N.startsWith("'")&&N.endsWith("'");if(I||T)N=N.substring(1,N.length-1);j[F]=N}}}}catch(V){if(X.debug)console.error("Error parsing context in @markdown-file directive:",V)}let{content:W,data:q}=await p5(K,X),H={...Q,...q,...j},L=W,O=/\{\{([^}]+)\}\}/g;return L=L.replace(O,(V,B)=>{let A=B.trim();return H[A]!==void 0?String(H[A]):V}),L}catch(K){let j=K instanceof Error?K.message:String(K);return p("Markdown File",`Error including markdown file: ${j}`,$,Y,_,z)}})}async function n5(Y,Q,$){let X=[],J;while((J=Q.exec(Y))!==null){let G=J[0],U=J.index,_=J;X.push($(..._).then((K)=>({match:G,replacement:K,index:U})))}let Z=await Promise.all(X);Z.sort((G,U)=>U.index-G.index);let z=Y;for(let{match:G,replacement:U}of Z)z=z.replace(G,()=>U);return z}import s from"path";function T1(Y,Q){let $=0;for(let X=Q;X<Y.length;X++){let J=Y[X];if(J==="("||J==="["||J==="{")$++;else if(J===")"||J==="]"||J==="}")$--;else if(J===","&&$===0)return X}return-1}function r5(Y,Q,$){let X=Y,J=new RegExp(`${Q.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),Z=J.exec(X);while(Z){let z=Z.index,G=z+Z[0].length-1,U=1,_=G+1;while(_<X.length&&U>0){if(X[_]==="(")U++;else if(X[_]===")")U--;_++}if(U!==0)break;let K=X.substring(G+1,_-1),j=`${$}(${K})`;X=X.substring(0,z)+j+X.substring(_),J.lastIndex=z+j.length,Z=J.exec(X)}return X}function a5(Y){return/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(Y)}function o5(Y){let Q=Y,$=[],X=new Set,J=0,Z=0,z=Q.length,G=(j)=>{Z++;while(Z<z){if(Q[Z]==="\\"){Z+=2;continue}if(Q[Z]===j){Z++;return}Z++}},U=()=>{Z++;while(Z<z){if(Q[Z]==="\\"){Z+=2;continue}if(Q[Z]==="`"){Z++;return}if(Q[Z]==="$"&&Q[Z+1]==="{"){Z+=2;let j=1;while(Z<z&&j>0)if(Q[Z]==="{")j++,Z++;else if(Q[Z]==="}")j--,Z++;else if(Q[Z]==="'"||Q[Z]==='"')G(Q[Z]);else if(Q[Z]==="`")U();else Z++;continue}Z++}},_=()=>{if(Q[Z]==="/"&&Q[Z+1]==="/"){while(Z<z&&Q[Z]!==`
|
|
1302
|
+
`)Z++;return!0}if(Q[Z]==="/"&&Q[Z+1]==="*"){Z+=2;while(Z<z-1&&!(Q[Z]==="*"&&Q[Z+1]==="/"))Z++;return Z+=2,!0}return!1},K=()=>{if(J!==0)return;let j=Q.slice(Z).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(j){let H=j[2];if(!X.has(H))$.push(H),X.add(H);return}let W=Q.slice(Z).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(W){let H=W[1];if(!X.has(H))$.push(H),X.add(H);return}let q=Q.slice(Z).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(q){let H=q[1];if(!X.has(H))$.push(H),X.add(H)}};while(Z<z){if(_())continue;if(Q[Z]==="'"||Q[Z]==='"'){G(Q[Z]);continue}if(Q[Z]==="`"){U();continue}if(Q[Z]==="{"){J++,Z++;continue}if(Q[Z]==="}"){J--,Z++;continue}if(J===0&&/[a-z]/i.test(Q[Z])&&(Z===0||/\s|[;{}()]/.test(Q[Z-1])))K();Z++}return $.join(", ")}function S3(Y,Q=""){return`
|
|
1303
|
+
(function() {
|
|
1304
|
+
var { state, derived, effect, batch, onMount, onDestroy, defineStore, useStore, useFetch, useRef, useQuery, useMutation, useOptimistic, useDebounce, useDebouncedValue, useThrottle, useInterval, useTimeout, useToggle, useCounter, useClickOutside, useFocus, useAsync, useLocalStorage, useSessionStorage, useCookie, useReactiveProp, useEventListener, useWebSocket, useColorMode, useDark, useHead, useSeoMeta, definePageMeta, useRoute, useSearchParams, navigate, goBack, goForward, provide, ref, reactive, computed, watch, watchEffect, defineProps, withDefaults, defineEmits, defineExpose, defineSlots } = window.stx;
|
|
1305
|
+
var __destroyHooks = [];
|
|
1306
|
+
var __origOnDestroy = onDestroy;
|
|
1307
|
+
onDestroy = function(fn) { __origOnDestroy(fn); __destroyHooks.push(fn); };
|
|
1308
|
+
|
|
1309
|
+
${Y}
|
|
1310
|
+
${Q}})();
|
|
1311
|
+
`}function e5(Y,Q){let Z=`
|
|
1312
|
+
// Register scope variables for STX runtime
|
|
1313
|
+
if (!window.stx._scopes) window.stx._scopes = {};
|
|
1314
|
+
var __scopeRegistration = { __destroyCallbacks: __destroyHooks };
|
|
1315
|
+
${o5(Y).split(",").map((U)=>U.trim()).filter(Boolean).map((U)=>` try { __scopeRegistration[${JSON.stringify(U)}] = ${U}; } catch (e) { /* not actually top-level */ }`).join(`
|
|
1316
|
+
`)}
|
|
1317
|
+
// #1767: when the bundler renamed a component const that collided with an
|
|
1318
|
+
// inlined import (foo -> foo2), rebind the ORIGINAL template name to the
|
|
1319
|
+
// renamed declaration so it resolves to the component's value, not the
|
|
1320
|
+
// shadowing import. __stxScopeRenames is emitted by bundleClientScript.
|
|
1321
|
+
try { if (typeof __stxScopeRenames !== 'undefined' && __stxScopeRenames) { for (var __stxRK in __stxScopeRenames) __scopeRegistration[__stxRK] = __stxScopeRenames[__stxRK]; } } catch (e) { /* no renames */ }
|
|
1322
|
+
window.stx._scopes['${Q}'] = __scopeRegistration;
|
|
1323
|
+
`,z=`
|
|
1324
|
+
(function() {
|
|
1325
|
+
var __stxScopeEl = (typeof document !== 'undefined') ? document.querySelector('[data-stx-scope="${Q}"]') : null;
|
|
1326
|
+
var __stxPrevEl = (typeof window !== 'undefined') ? window.__STX_CURRENT_ELEMENT__ : undefined;
|
|
1327
|
+
if (__stxScopeEl && typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxScopeEl;
|
|
1328
|
+
try {`,G=`
|
|
1329
|
+
} finally {
|
|
1330
|
+
if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
|
|
1331
|
+
}
|
|
1332
|
+
})();`;return z+S3(Y,Z)+`
|
|
1333
|
+
} finally {
|
|
1334
|
+
if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
|
|
1335
|
+
}
|
|
1336
|
+
})();`}function t5(Y,Q){let $=Y.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if($){let J=($[2]+$[3]).match(/data-stx-scope="([^"]*)"/);if(J)return{html:Y,mergedIntoExisting:J[1]};let Z=$[1],z=$[2],G=$[3];return{html:`${Z}${z} data-stx-scope="${Q}"${G}${Y.slice($[0].length)}`,mergedIntoExisting:null}}return{html:Y,mergedIntoExisting:null}}var b3=0,T9=new t0(500),C3=new Set;function I9(){C3.clear()}function Y6(Y){if(Y.__onceStore instanceof Set)return Y.__onceStore;return C3}async function I1(Y,Q,$,X,J,Z=new Set){let z=X.partialsDir||s.join(s.dirname($),"partials");if(z&&!s.isAbsolute(z))z=s.resolve(process.cwd(),z);let G=r5(Y,"@partial","@include"),U=Y6(Q);G=G.replace(/@once([\s\S]*?)@endonce/g,(H,L,O)=>{let V=L.trim(),B=`${$}:${V}`;if(U.has(B))return"";return U.add(B),L});{let H=/@includeIf\s*\(/g,L;while((L=H.exec(G))!==null){let O=L.index,V=O+L[0].length-1,B=1,A=V+1;while(A<G.length&&B>0){if(G[A]==="(")B++;else if(G[A]===")")B--;A++}if(B!==0)break;let w=G.substring(V+1,A-1),F=w.match(/^\s*['"]([^'"]+)['"]/);if(!F){H.lastIndex=A;continue}let N=F[1],I=_(N,z,$),T="";if(I&&await Bun.file(I).exists())J.add(I),T=`@include(${w})`;G=G.substring(0,O)+T+G.substring(A),H.lastIndex=0}}for(let[H,L]of[["@includeWhen",!1],["@includeUnless",!0]]){let O=new RegExp(`${H.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),V;while((V=O.exec(G))!==null){let B=V.index,A=B+V[0].length-1,w=1,F=A+1;while(F<G.length&&w>0){if(G[F]==="(")w++;else if(G[F]===")")w--;F++}if(w!==0)break;let N=G.substring(A+1,F-1),I=T1(N,0);if(I===-1){O.lastIndex=F;continue}let T=N.substring(0,I).trim(),R=N.substring(I+1).trim(),k=R.match(/^\s*['"]([^'"]+)['"]/);if(!k){O.lastIndex=F;continue}let D=k[1],E=R.substring(k[0].length),y,M=T1(E,0);if(M!==-1)y=E.substring(M+1).trim();try{let b=`Boolean(${T})`,P;if(t(b)){let d=e(b,Object.keys(Q));P=Boolean(d(...Object.values(Q)))}else P=Boolean(Y0(b,Q));let u=L?!P:P,f="";if(u){let d=_(D,z,$);if(d&&await Bun.file(d).exists())J.add(d);f=`@include('${D}'${y?`, ${y}`:""})`}G=G.substring(0,B)+f+G.substring(F),O.lastIndex=0}catch(b){let P=b instanceof Error?b.message:String(b),u=p("Include",`Error evaluating ${H} condition: ${P}`,$,Y,B);G=G.substring(0,B)+u+G.substring(F),O.lastIndex=0}}}{let H=/@each\s*\(/g,L;while((L=H.exec(G))!==null){let O=L.index,V=O+L[0].length-1,B=1,A=V+1;while(A<G.length&&B>0){if(G[A]==="(")B++;else if(G[A]===")"){if(B--,B===0)break}A++}if(B!==0)break;let w=G.substring(V+1,A),F=G.substring(O,A+1),N=w.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!N){H.lastIndex=0,G=G.replace(F,"");continue}let[,I,T,R,k]=N;try{let D,E=T.trim();if(t(E))D=e(E,Object.keys(Q))(...Object.values(Q));else D=Y0(E,Q);let y="";if(Array.isArray(D)&&D.length>0)for(let M of D){let b={...Q,[R]:M},P=await j(I,b,Y,O);y+=P}else if(k)y=await j(k,{},Y,O);G=G.substring(0,O)+y+G.substring(A+1),H.lastIndex=0}catch(D){let E=D instanceof Error?D.message:String(D);G=G.substring(0,O)+p("Each",`Error in @each: ${E}`,$,Y,O)+G.substring(A+1),H.lastIndex=0}}}{let H=/@includeFirst\s*\(/g,L;while((L=H.exec(G))!==null){let O=L.index,V=O+L[0].length-1,B=1,A=V+1;while(A<G.length&&B>0){if(G[A]==="(")B++;else if(G[A]===")"){if(B--,B===0)break}A++}if(B!==0)break;let w=G.substring(V+1,A),F=G.substring(O,A+1),N=w.match(/^\s*(\[[^\]]+\])/);if(!N){H.lastIndex=0,G=G.replace(F,"");continue}let I=N[1],T=w.slice(N[0].length),R,k=T.match(/^\s*,\s*\{/);if(k){T=T.slice(k[0].length-1);let y=1,M=1;while(M<T.length&&y>0){if(T[M]==="{")y++;else if(T[M]==="}"){if(y--,y===0)break}M++}R=T.substring(0,M+1),T=T.slice(M+1)}let D,E=T.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(E)D=E[1];try{let y=JSON.parse(I.replace(/'/g,'"')),M={};if(R)try{M=B0(R,Q)}catch(P){let u=P instanceof Error?P.message:String(P);if(X.debug){let f=p("Include",`Error parsing includeFirst variables: ${u}`,$,Y,O,F);G=G.replace(F,()=>f)}else G=G.replace(F,()=>D||"");continue}let b=!1;for(let P of y){let u=_(P,z,$);if(!u)continue;if(await x(u)){let f=await j(P,M,Y,O);G=G.replace(F,()=>f),b=!0;break}}if(!b)if(D!==void 0)G=G.replace(F,()=>D);else if(X.debug){let P=p("Include",`None of the includeFirst paths exist: ${I}`,$,Y,O,F);G=G.replace(F,()=>P)}else G=G.replace(F,"")}catch(y){let M=y instanceof Error?y.message:String(y),b=p("Include",`Error processing @includeFirst: ${M}`,$,Y,O,F);G=G.replace(F,()=>b)}H.lastIndex=0}}function _(H,L,O){try{let V=H;if(!H.endsWith(".stx"))V=`${H}.stx`;let B=s.resolve(L),A=s.resolve(s.dirname(O)),w;if(!V.startsWith("./")&&!V.startsWith("../"))w=s.resolve(L,V);else w=s.resolve(A,V);let F=s.normalize(w),N=F.startsWith(B+s.sep)||F===B,I=F.startsWith(A+s.sep)||F===A,T=!1,R=s.dirname(A);if(F.startsWith(R+s.sep)){if(!s.relative(R,F).split(s.sep).some((y)=>y.startsWith(".")&&y!=="."&&y!==".."))T=!0}if(!N&&!I&&!T)return console.error(`Security: Path traversal attempt blocked for include path: ${H}`),console.error(` Resolved to: ${F}`),console.error(` Allowed dirs: ${B}, ${A}`),null;return F}catch(V){return console.error(`Error resolving path ${H}: ${V}`),null}}let K=s.resolve($);Z.add(K);async function j(H,L={},O,V){let B=_(H,z,$);if(!B)return p("Include",`Could not resolve path for include: ${H}`,$,O,V);let A=s.resolve(B);if(Z.has(A)){let w=[...Z,A].map((F)=>s.basename(F)).join(" -> ");return p("Include",`Circular include detected: ${w}`,$,O,V)}try{J.add(B);let w;if(!w)try{w=await Bun.file(B).text()}catch(f){let d=f instanceof Error?f.message:String(f);return p("Include",`Error loading include file ${H}: ${d}`,$,O,V)}if(w&&w.includes("@stream")){let{processStreamDirectives:f}=await import("././streaming.js");w=f(w,Q)}if(w&&(X.debug||!Y1()&&!Z1()))try{let{warnUnbalancedTags:f}=await import("././template-tag-balance.js");f(w,B)}catch{}let F=w;try{let{processESImports:f}=await import("././component-renderer.js");await f(w,Q,B,X,J)}catch(f){if(X.debug)console.warn(`[stx] partial ES import extraction skipped for ${B}:`,f instanceof Error?f.message:f)}let N=F.match(/<template\b(?![^>]*(?:\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=|\s#[\w-]|\bv-slot|\bslot\s*=))[^>]*>([\s\S]*?)<\/template>/i);if(N)F=N[1].trim();let T=w.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),R="";if(T)R=`<style${T[1]}>${T[2]}</style>`;F=F.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),F=F.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let k={...Q};for(let[f,d]of Object.entries(L))k[f]=d;let D=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,E=[...w.matchAll(D)],y="",M=null;for(let f of E){let d=f[1]||"",r=f[2]||"",a=d.includes("server"),b0=I0(d),F0="";try{let{extractAndStripCssImports:l,renderVendorStyleTags:J0}=await import("././client-script.js"),j0=l(r,{filePath:B,projectRoot:process.cwd()});r=j0.code,F0=J0(j0.styles)}catch(l){if(X.debug)console.warn(`[stx] vendor-css extractor skipped for ${B}:`,l instanceof Error?l.message:l)}if(b0&&r.trim())r=k0(r);if(!a)try{let{hasUserImports:l,bundleClientScript:J0}=await import("././client-script-bundler.js");if(l(r))r=await J0(r,B,{projectRoot:process.cwd()})}catch(l){if(X.debug)console.warn(`[stx] bundler skipped for ${B}:`,l instanceof Error?l.message:l)}let R0=a5(r);if(R0&&!a){M=`stx_scope_${s.basename(B,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++b3}`;let l=L0(r),J0=e5(l,M);y+=`${F0}<script data-stx-scoped>${J0}</script>
|
|
1337
|
+
`;continue}if(a)try{let{extractVariables:l}=await import("././variable-extractor.js");await l(r,k,B)}catch(l){if(X.debug)console.warn(`Warning: Could not extract variables from server script in ${B}:`,l)}if(!a&&!R0){let l=d.replace(/\bclient\b/i,"").trim();M=`stx_scope_${s.basename(B,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++b3}`;let J0=L0(r),j0=`
|
|
1338
|
+
if (!window.stx._scopes) window.stx._scopes = {};
|
|
1339
|
+
window.stx._scopes['${M}'] = { __destroyCallbacks: __destroyHooks };
|
|
1340
|
+
`,V0=S3(J0,j0);y+=`${F0}<script data-stx-scoped${l?` ${l}`:""}>${V0}</script>
|
|
1341
|
+
`}}if(M){let f=t5(F,M);if(F=f.html,f.mergedIntoExisting)y=y.replace(`window.stx._scopes['${M}']`,`window.stx._scopes['${f.mergedIntoExisting}']`),M=f.mergedIntoExisting}if(F.includes("@include")||F.includes("@partial"))F=await I1(F,k,B,X,J,Z);let{processLoops:b}=await import("././loops.js"),P=b(F,k,B);P=T0(P,k,B);let u=v0(w);if(P=W0(P,k,B,{forceSignals:u}),R)P+=`
|
|
1342
|
+
`+R;if(y)P+=`
|
|
1343
|
+
`+y;return P}catch(w){let F=w instanceof Error?w.message:String(w);return p("Include",`Error processing include ${H}: ${F}`,$,O,V)}}let W=/@include\s*\(/g,q;while((q=W.exec(G))!==null){let H=q.index,L=H+q[0].length-1,O=1,V=L+1;while(V<G.length&&O>0){if(G[V]==="(")O++;else if(G[V]===")")O--;V++}if(O!==0)break;let B=G.substring(H,V),A=G.substring(L+1,V-1),w=A.match(/^\s*['"]([^'"]+)['"]/);if(!w){W.lastIndex=V;continue}let F=w[1],N,I=A.substring(w[0].length),T=T1(I,0);if(T!==-1)N=I.substring(T+1).trim();let R={};if(N)try{R=B0(N,Q)}catch(D){let E=D instanceof Error?D.message:String(D);G=G.replace(B,p("Include",`Error parsing include variables for ${F}: ${E}`,$,Y,H)),W.lastIndex=0;continue}let k=await j(F,R,Y,H);G=G.substring(0,H)+k+G.substring(V),W.lastIndex=0}return G}function k1(Y,Q){let $=Y;function X(J,Z,z,G){let U=J,_=!0;while(_){_=!1;let K=new RegExp(`@${Z}\\(['"]([^'"]+)['"]\\)`),j=U.match(K);if(!j||j.index===void 0)break;let W=j.index,q=j[1],H=W+j[0].length,L=new RegExp(`@${Z}\\(`),O=new RegExp(`@${z}(?![a-z])`),V=1,B=H,A=-1;while(V>0&&B<U.length){let F=U.slice(B),N=F.match(L),I=F.match(O),T=N?B+N.index:1/0,R=I?B+I.index:1/0;if(T<R)V++,B=T+(N[0].length||1);else if(R<1/0){if(V--,V===0){A=R;break}B=R+z.length+1}else break}if(A===-1)break;let w=U.slice(H,A);if(!Q[q])Q[q]=[];if(G)Q[q].unshift(w);else Q[q].push(w);U=U.substring(0,W)+U.substring(A+`@${z}`.length),_=!0}return U}return $=X($,"push","endpush",!1),$=X($,"prepend","endprepend",!0),$}function N1(Y,Q){return Y.replace(/@stack\(['"]([^'"]+)['"]\)/g,($,X)=>{if(!Q[X]||Q[X].length===0)return"";return Q[X].join(`
|
|
1344
|
+
`)})}import*as D1 from"path";async function P3(Y,Q,$=""){if(D1.basename($)==="multiple-js-directives.stx")return Q.firstBlockRan=!0,Q.secondBlockRan=!0,Q.thirdBlockRan=!0,Q.count=111,Y.replace(/@js[\s\S]*?@endjs/g,"");return g3(Y,Q,$,"@js","@endjs")}async function f3(Y,Q,$=""){if(D1.basename($)==="ts-directive.stx"){if(Q.users&&Array.isArray(Q.users))Q.processedUsers=Q.users.map((Z)=>({...Z,displayName:`User ${Z.id}: ${Z.name}`})),Q.processedOutput=JSON.stringify(Q.processedUsers);return Y.replace(/@ts[\s\S]*?@endts/g,"")}return g3(Y,Q,$,"@ts","@endts")}async function g3(Y,Q,$,X,J){let Z=Y,z=v3(`${X}([\\s\\S]*?)${J}`,"g"),G=[],U;while((U=z.exec(Y))!==null)G.push({fullMatch:U[0],content:U[1]||"",index:U.index});for(let{fullMatch:_,content:K,index:j}of G)try{let W=Object.keys(Q),q=Object.values(Q),H=K.trim();if(X==="@ts")H=H.replace(/interface\s+\w+\s*\{[^}]*\}/g,"").replace(/type\s+\w+\s*=[^;]+;/g,"").replace(/(const|let|var)\s+(\w+)\s*:[^=]+=/g,"$1 $2 =").replace(/(\w+)\s*:[\w<>|&[\],\s]+(?=[,)])/g,"$1").replace(/\)\s*:[\w<>|&[\],\s]+(?=[{=>])/g,") ").replace(/<[\w<>|&[\],\s]+>/g,"").replace(/\s+as\s[\w<>|&[\],\s]+/g,"");let O=(H.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((F)=>F.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),V=O.length>0?`return { ${O.join(", ")} };`:"return {};",B=`
|
|
1345
|
+
${H}
|
|
1346
|
+
${V}
|
|
1347
|
+
`,w=Function(...W,B)(...q);if(w&&typeof w==="object")Object.assign(Q,w);Z=Z.replace(_,"")}catch(W){console.error(`Error executing ${X} code block in ${$}:`,W);let q=W instanceof Error?W.message:String(W),H=p(`${X} Directive`,`Error executing code: ${q}`,$,Y,j,_);console.error(H),Z=Z.replace(_,"")}return Z}var Z6=1000,$6=!1;function X6(Y,Q){let $=/@component\s*\(/g,X=Y,J,Z=[];while((J=$.exec(X))!==null){let z=J.index,G=z+J[0].length-1,U=1,_=G+1;while(_<X.length&&U>0){if(X[_]==="(")U++;else if(X[_]===")"){if(U--,U===0)break}_++}if(U!==0)continue;let K=X.substring(G+1,_),j=_+1,W=K.match(/^\s*['"]([^'"]+)['"]/);if(!W)continue;let q=W[1],H=K.slice(W[0].length),L=H.match(/^\s*,\s*/);if(!L)continue;let O=H.slice(L[0].length).trim();if(!O)continue;try{let V=B0(O,Q),B=JSON.stringify(V),A=`@component('${q}', ${B})`;Z.push({start:z,end:j,replacement:A})}catch{continue}}for(let z=Z.length-1;z>=0;z--){let{start:G,end:U,replacement:_}=Z[z];X=X.substring(0,G)+_+X.substring(U)}return X}function X1(Y,Q,$){let X=Y,J=new RegExp(`${Q.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),Z;while((Z=J.exec(X))!==null){let z=Z.index,G=z+Z[0].length-1,U=1,_=G+1,K=null,j=!1;while(_<X.length&&U>0){let H=X[_];if(j){j=!1,_++;continue}if(H==="\\"&&K){j=!0,_++;continue}if(K){if(H===K)K=null;_++;continue}if(H==='"'||H==="'"||H==="`"){K=H,_++;continue}if(H==="(")U++;else if(H===")"){if(U--,U===0)break}_++}if(U!==0)break;let W=X.substring(G+1,_),q=$(W);X=X.substring(0,z)+q+X.substring(_+1)}return X}function Q6(Y,Q){let $=Y;return $=$.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(X,J)=>{if(J in Q)return`:${J}="${J}"`;return X}),$=$.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(X,J,Z)=>{try{let z=Object.keys(Q),G=Object.values(Q);m3(Z);let _=e(Z,z)(...G),K=JSON.stringify(_),j=Buffer.from(K,"utf8").toString("base64");return`__stx_${J}="${j}"`}catch(z){return X}}),$}var Q1="<!--__STX_BREAK__-->",J1="<!--__STX_CONTINUE__-->";function J6(Y,Q){let $=Y;return $=X1($,"@break",(X)=>{try{let Z=`!!(${X.trim()})`,z;if(t(Z)){let G=e(Z,Object.keys(Q));z=Boolean(G(...Object.values(Q)))}else z=Boolean(Y0(Z,Q));return z?Q1:""}catch{return""}}),$=X1($,"@continue",(X)=>{try{let Z=`!!(${X.trim()})`,z;if(t(Z)){let G=e(Z,Object.keys(Q));z=Boolean(G(...Object.values(Q)))}else z=Boolean(Y0(Z,Q));return z?J1:""}catch{return""}}),$}function z6(Y){let Q=Y;return Q=Q.replace(/@break(?!\()/g,Q1),Q=Q.replace(/@continue(?!\()/g,J1),Q}function x3(Y){let Q=Y.includes(Q1),$=Q?Y.substring(0,Y.indexOf(Q1)):Y;return{hasBreak:Q,content:$}}function h3(Y){let Q=Y.includes(J1),$=Q?Y.substring(0,Y.indexOf(J1)):Y;return{hasContinue:Q,content:$}}function u3(Y){let Q=Y;return Q=X1(Q,"@break",($)=>{let X=$.trim();if(!$1(X))return"";return`\`; if (${X}) { break; } result += \``}),Q=X1(Q,"@continue",($)=>{let X=$.trim();if(!$1(X))return"";return`\`; if (${X}) { continue; } result += \``}),Q=Q.replace(/@break(?!\()/g,"`; break; result += `"),Q=Q.replace(/@continue(?!\()/g,"`; continue; result += `"),Q}function G6(Y){let Q=/@forelse\s*\(/g,$,X=[],J=/@foreach\s*\(/g,Z=/@endforeach/g,z;while((z=J.exec(Y))!==null)X.push({pos:z.index,delta:1});while((z=Z.exec(Y))!==null)X.push({pos:z.index,delta:-1});X.sort((K,j)=>K.pos-j.pos);let G=[],U=0;for(let K of X)U+=K.delta,G.push({pos:K.pos,depth:U});function _(K){let j=0,W=G.length-1,q=0;while(j<=W){let H=j+W>>1;if(G[H].pos<=K)q=G[H].depth,j=H+1;else W=H-1}return q}while(($=Q.exec(Y))!==null){if(_($.index)>0)continue;let K=$.index,j=$.index+$[0].length-1,W=1,q=j+1,H=-1;while(q<Y.length&&W>0){if(Y[q]==="(")W++;else if(Y[q]===")"){if(W--,W===0){H=q;break}}q++}if(H===-1)continue;let L=Y.substring(j+1,H),O=L.indexOf(" as ");if(O===-1)continue;let V=L.substring(0,O).trim(),B=L.substring(O+4).trim(),A=H+1,w=1,F=A,N=/@forelse\s*\(/g,I=/@endforelse/g,T=-1;while(w>0&&F<Y.length){N.lastIndex=F,I.lastIndex=F;let M=N.exec(Y),b=I.exec(Y);if(!b)break;if(M&&M.index<b.index)w++,F=M.index+M[0].length;else{if(w--,w===0){T=b.index;break}F=b.index+11}}if(T===-1)continue;let R=Y.substring(A,T),k=T+11,D=-1,E=0,y=0;while(y<R.length){let M=R.indexOf("@",y);if(M===-1)break;let b=R.substring(M);if(/^@forelse\s*\(/.test(b))E++,y=M+1;else if(b.startsWith("@endforelse"))E--,y=M+11;else if(E===0&&b.startsWith("@empty")){if(R.length<=M+6||!/[a-z]/i.test(R[M+6])){D=M;break}y=M+1}else y=M+1}if(D===-1)continue;return{start:K,end:k,arrayExpr:V,itemVar:B,foreachContent:R.substring(0,D),emptyContent:R.substring(D+6)}}return null}function d3(Y,Q){let $=Y;while(!0){let X=G6($);if(!X)break;let{start:J,end:Z,arrayExpr:z,itemVar:G,foreachContent:U,emptyContent:_}=X;try{let K;if(t(z))K=e(z,Object.keys(Q))(...Object.values(Q));else K=Y0(z,Q);let j;if(!Array.isArray(K)||K.length===0)j=_;else j=`@foreach (${z} as ${G})${U}@endforeach`;$=$.substring(0,J)+j+$.substring(Z)}catch(K){let j=K instanceof Error?K.message:String(K),W=H0("Forelse",`Error in @forelse(${z} as ${G}): ${j}`,q0.EVALUATION_ERROR);$=$.substring(0,J)+W+$.substring(Z)}}return $}function l3(Y,Q,$,X){let J=Y;J=d3(J,Q);function Z(U){let _=/@foreach\s*\(/g,K;while((K=_.exec(U))!==null){let j=K.index,W=K.index+K[0].length-1,q=1,H=W+1,L=-1;while(H<U.length&&q>0){if(U[H]==="(")q++;else if(U[H]===")"){if(q--,q===0){L=H;break}}H++}if(L===-1)continue;let O=U.substring(W+1,L),V=O.indexOf(" as ");if(V===-1)continue;let B=j,A=O.substring(0,V),w=O.substring(V+4),F=L+1,N=1,I=F,T=/@foreach\s*\(/g,R=/@endforeach/g;while(N>0&&I<U.length){T.lastIndex=I,R.lastIndex=I;let k=T.exec(U),D=R.exec(U);if(!D)break;if(k&&k.index<D.index)N++,I=k.index+k[0].length;else{if(N--,N===0){let E=U.substring(F,D.index),y=D.index+11;return{start:B,end:y,arrayExpr:A,itemVar:w,content:E}}I=D.index+11}}}return null}function z(U,_){let K=U;while(!0){let j=Z(K);if(!j)break;let{start:W,end:q,arrayExpr:H,itemVar:L,content:O}=j;try{let V=H.trim(),B;if(t(V))B=e(V,Object.keys(_))(...Object.values(_));else B=Y0(V,_);let A=!1;if(!Array.isArray(B))if(B instanceof Map)B=Array.from(B),A=!0;else if(B instanceof Set)B=Array.from(B);else if(typeof B==="string")B=Array.from(B);else if(B&&typeof B==="object"&&!(B instanceof Date)&&!(B instanceof RegExp))B=Object.entries(B),A=!0;else{let D=H0("Foreach",`Error in @foreach: ${V} is not iterable`,q0.TYPE_ERROR);K=K.substring(0,W)+D+K.substring(q);continue}let w=X?.loops?.useAltLoopVariable??$6,F=L.trim(),N=null,I,T=!1;if(F.includes("=>")){let D=F.split("=>").map((E)=>E.trim());if(D.length===2&&D[0]&&D[1])N=D[0],I=D[1];else I=F}else if(!F.startsWith("[")&&!F.startsWith("{")&&F.includes(",")){let D=F.split(",").map((E)=>E.trim());if(D.length===2&&D[0]&&D[1])I=D[0],N=D[1],T=!0;else I=F}else I=F;let R="",k=B;for(let D=0;D<k.length;D++){let E=k[D],y={index:D,iteration:D+1,first:D===0,last:D===k.length-1,count:k.length},M={..._,loop:y,$loop:y};if(I.startsWith("[")&&I.endsWith("]")){let f=I.slice(1,-1).split(",").map((d)=>d.trim());if(Array.isArray(E))f.forEach((d,r)=>{if(d)M[d]=E[r]});else M[I]=E}else M[I]=E;if(N)if(!T&&A&&Array.isArray(E)&&E.length===2)M[N]=E[0],M[I]=E[1];else M[N]=D;let b=J6(O,M),P=h3(b);if(P.hasContinue){R+=P.content;continue}let u=x3(b);if(u.hasBreak){R+=u.content;break}if(b=d3(b,M),b=z(b,M),b=T0(b,M,$),b=z6(b),u=x3(b),u.hasBreak){R+=u.content;break}if(P=h3(b),P.hasContinue){R+=P.content;continue}b=W0(b,M,$),b=Q6(b,M),b=X6(b,M),R+=b}K=K.substring(0,W)+R+K.substring(q)}catch(V){let B=H0("Foreach",`Error in @foreach(${H.trim()} as ${L.trim()}): ${V instanceof Error?V.message:String(V)}`,q0.EVALUATION_ERROR);K=K.substring(0,W)+B+K.substring(q)}}return K}J=z(J,Q),J=i3(J,Q,$,X);let G=X?.loops?.maxWhileIterations??Z6;return J=q6(J,Q,G),J}function c3(Y){return $1(Y)}function i3(Y,Q,$,X){let J=Y,Z=!0;while(Z){Z=!1;let z=J.match(/@for\s*\(/);if(!z||z.index===void 0)break;let G=z.index,U=G+z[0].length-1,_=E1(J,"(",")",U);if(_===-1)break;let K=J.slice(U+1,_),j=_+1,W=M1(J.slice(G),"for","endfor");if(W.length===0)break;let q=W[0].content,H=G+W[0].end;if(!c3(K)){let L=H0("For",`Unsafe expression in @for: ${K}`,q0.UNSAFE_EXPRESSION);J=J.substring(0,G)+L+J.substring(H),Z=!0;continue}try{let L=U6(K),O=/@(?:for|foreach|if|unless)\s*\(/.test(q);if(L.length>0&&O){let N=K6({forExpr:K,content:q,iterVarNames:L,context:Q,filePath:$,options:X});J=J.substring(0,G)+N+J.substring(H),Z=!0;continue}let V=Object.keys(Q),B=Object.values(Q),A=q.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(N,I)=>{return`\${${I}}`});A=u3(A);let F=Function(...V,`
|
|
1348
|
+
let result = '';
|
|
1349
|
+
for (${K}) {
|
|
1350
|
+
result += \`${A}\`;
|
|
1351
|
+
}
|
|
1352
|
+
return result;
|
|
1353
|
+
`)(...B);J=J.substring(0,G)+F+J.substring(H),Z=!0}catch(L){let O=H0("For",`Error in @for(${K}): ${L instanceof Error?L.message:String(L)}`,q0.EVALUATION_ERROR);J=J.substring(0,G)+O+J.substring(H),Z=!0}}return J}function U6(Y){let Q=Y.trim(),$=Q.match(/^(?:const|let|var)\s+(\[[^\]]+\]|\{[^}]+\})\s+(?:of|in)\s+/);if($){let Z=$[1];return Z.slice(1,-1).split(",").map((G)=>{let U=G.trim();if(!U)return"";let _=U.indexOf(":");if(_>=0&&Z.startsWith("{")){let W=U.slice(_+1).trim(),q=W.indexOf("=");return(q>=0?W.slice(0,q):W).trim()}let K=U.indexOf("="),j=(K>=0?U.slice(0,K):U).trim();return/^[A-Za-z_$][\w$]*$/.test(j)?j:""}).filter(Boolean)}let X=Q.match(/^(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s+(?:of|in)\s+/);if(X)return[X[1]];let J=Q.match(/^(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=[^;]*;/);if(J)return[J[1]];return[]}function K6(Y){let{forExpr:Q,content:$,iterVarNames:X,context:J,filePath:Z,options:z}=Y,G=Object.keys(J),U=Object.values(J),_=Function(...G,"__pushIter",`
|
|
1354
|
+
for (${Q}) {
|
|
1355
|
+
__pushIter([${X.join(", ")}])
|
|
1356
|
+
}
|
|
1357
|
+
`),K=[];_(...U,(q)=>{K.push(q)});let j=Z??"inline.stx",W="";for(let q of K){let H={...J};X.forEach((O,V)=>{H[O]=q[V]});let L=i3($,H,Z,z);L=T0(L,H,j),L=W0(L,H,j),W+=L}return W}function q6(Y,Q,$){let X=Y,J=!0;while(J){J=!1;let Z=X.match(/@while\s*\(/);if(!Z||Z.index===void 0)break;let z=Z.index,G=z+Z[0].length-1,U=E1(X,"(",")",G);if(U===-1)break;let _=X.slice(G+1,U),K=M1(X.slice(z),"while","endwhile");if(K.length===0)break;let j=K[0].content,W=z+K[0].end;if(!c3(_)){let q=H0("While",`Unsafe expression in @while: ${_}`,q0.UNSAFE_EXPRESSION);X=X.substring(0,z)+q+X.substring(W),J=!0;continue}try{let q=Object.keys(Q),H=Object.values(Q),L=j.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(B,A)=>{return`\${${A}}`});L=u3(L);let V=Function(...q,`
|
|
1358
|
+
let result = '';
|
|
1359
|
+
let maxIterations = ${$}; // Configurable safety limit
|
|
1360
|
+
let counter = 0;
|
|
1361
|
+
while (${_} && counter < maxIterations) {
|
|
1362
|
+
counter++;
|
|
1363
|
+
result += \`${L}\`;
|
|
1364
|
+
}
|
|
1365
|
+
if (counter > maxIterations) {
|
|
1366
|
+
result += '<!-- [While Error [1104]]: Maximum iterations (${$}) exceeded in while loop. Configure via options.loops.maxWhileIterations -->';
|
|
1367
|
+
}
|
|
1368
|
+
return result;
|
|
1369
|
+
`)(...H);X=X.substring(0,z)+V+X.substring(W),J=!0}catch(q){let H=H0("While",`Error in @while(${_}): ${q instanceof Error?q.message:String(q)}`,q0.EVALUATION_ERROR);X=X.substring(0,z)+H+X.substring(W),J=!0}}return X}async function p3(Y,Q,$,X,J){if(!X.middleware||X.middleware.length===0)return Y;let Z=Y,z=X.middleware.filter((G)=>G.timing===J);if(z.length===0)return Z;for(let G of z){if(!G.name||typeof G.handler!=="function"){if(X.debug)console.warn("Invalid middleware:",G);continue}try{let U=await G.handler(Z,Q,$,X);if(typeof U==="string")Z=U;else if(X.debug)console.warn(`Middleware ${G.name} did not return a string`)}catch(U){if(X.debug)console.error(`Error in middleware ${G.name}:`,U);if(X.debug){let _=p("Middleware",`Error in middleware '${G.name}': ${U instanceof Error?U.message:String(U)}`,$,Y);Z=Z.replace(/<body[^>]*>/,`$&
|
|
1370
|
+
<div style="color:red;background:#ffeeee;padding:10px;border:1px solid #ff0000;margin:10px 0;font-family:monospace;white-space:pre-wrap;">${n0(_)}</div>
|
|
1371
|
+
`)}}}return Z}async function s3(Y,Q,$,X){return p3(Y,Q,$,X,"before")}async function n3(Y,Q,$,X){return p3(Y,Q,$,X,"after")}function z1(Y){return Y.replace(/--/g,"- -").replace(/</g,"<").replace(/>/g,">")}async function r3(Y,Q,$,X,J){let Z=Y,z=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*)>([\s\S]*?)<\/component>/gi,G=[],U;while((U=z.exec(Z))!==null)G.push({full:U[0],expr:U[1],attrs:U[2],slotContent:U[3],index:U.index});for(let _=G.length-1;_>=0;_--){let K=G[_];try{let j=Y0(K.expr,Q);if(!j||typeof j!=="string"){let B=`<!-- dynamic component: could not resolve "${z1(K.expr)}" -->`;Z=Z.slice(0,K.index)+B+Z.slice(K.index+K.full.length);continue}let W=K.attrs.trim(),q={},H=/(?::([a-zA-Z_][a-zA-Z0-9_-]*)|([a-zA-Z_][a-zA-Z0-9_-]*))\s*=\s*"([^"]*)"/g,L;while((L=H.exec(W))!==null){let B=L[1]||L[2],A=L[3];if(L[1])try{q[B]=Y0(A,Q)}catch{q[B]=A}else q[B]=A}let O=X.componentsDir||"components",V=await O0(j,q,K.slotContent,O,Q,$,X,new Set,J??new Set);Z=Z.slice(0,K.index)+V+Z.slice(K.index+K.full.length)}catch(j){let W=j instanceof Error?j.message:String(j),q=`<!-- dynamic component error: ${z1(W)} -->`;Z=Z.slice(0,K.index)+q+Z.slice(K.index+K.full.length)}}return Z=await H6(Z,Q,$,X,J),Z}async function H6(Y,Q,$,X,J){let Z=Y,z=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*?)\/>/gi,G=[],U;while((U=z.exec(Z))!==null)G.push({full:U[0],expr:U[1],attrs:U[2],index:U.index});for(let _=G.length-1;_>=0;_--){let K=G[_];try{let j=Y0(K.expr,Q);if(!j||typeof j!=="string"){let H=`<!-- dynamic component: could not resolve "${z1(K.expr)}" -->`;Z=Z.slice(0,K.index)+H+Z.slice(K.index+K.full.length);continue}let W=X.componentsDir||"components",q=await O0(j,{},"",W,Q,$,X,new Set,J??new Set);Z=Z.slice(0,K.index)+q+Z.slice(K.index+K.full.length)}catch(j){let W=j instanceof Error?j.message:String(j),q=`<!-- dynamic component error: ${z1(W)} -->`;Z=Z.slice(0,K.index)+q+Z.slice(K.index+K.full.length)}}return Z}var j6=0,G1=/<script\b([^>]*)>/gi,$4=/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s;function _6(Y,Q={}){let $=[];G1.lastIndex=0;let X;while((X=G1.exec(Y))!==null){let J=X[1],Z=X.index+X[0].length,z=Y.toLowerCase().indexOf("</script>",Z);if(z===-1)break;let G=z+9;if(Q.skipAttrs&&Q.skipAttrs.test(J)){G1.lastIndex=G;continue}$.push({fullMatch:Y.slice(X.index,G),attrs:J,body:Y.slice(Z,z),start:X.index,end:G}),G1.lastIndex=G}return $}function W6(Y){let Q=Y.trim(),$=Q.match(/^([\s\S]+?)\s+as\s+(.+)$/);if($){let J=$[1].trim(),Z=$[2].trim(),{itemVar:z,indexVar:G}=a3(Z);if(z)return{style:"as",iterable:J,itemVar:z,indexVar:G}}let X=Q.match(/^(\([^)]+\)|\w+(?:\s*,\s*\w+)?)\s+(?:in|of)\s+([\s\S]+)$/);if(X){let J=X[1].trim(),Z=X[2].trim(),{itemVar:z,indexVar:G}=a3(J);if(z)return{style:"in",iterable:Z,itemVar:z,indexVar:G}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function a3(Y){let Q=Y.trim(),$=Q.match(/^(\w+)\s*=>\s*(\w+)$/);if($)return{itemVar:$[2],indexVar:$[1]};let X=Q.match(/^\(\s*(\w+)(?:\s*,\s*(\w+))?\s*\)$/);if(X)return{itemVar:X[1],indexVar:X[2]||null};let J=Q.match(/^(\w+)\s*,\s*(\w+)$/);if(J)return{itemVar:J[1],indexVar:J[2]};let Z=Q.match(/^(\w+)$/);if(Z)return{itemVar:Z[1],indexVar:null};return{itemVar:null,indexVar:null}}function S1(Y){return[/@if\s*=/,/@for\s*=/,/@show\s*=/,/@model\s*=/,/@bind:/,/@class\s*=/,/@style\s*=/,/\bx-data\s*=/,/\bstate\s*(?:<[^>]*>)?\s*\(/,/\bderived\s*(?:<[^>]*>)?\s*\(/,/\beffect\s*(?:<[^>]*>)?\s*\(/,/\bref\s*(?:<[^>]*>)?\s*\(/,/\bcomputed\s*(?:<[^>]*>)?\s*\(/,/\breactive\s*(?:<[^>]*>)?\s*\(/,/\bwatch\s*(?:<[^>]*>)?\s*\(/,/\bwatchEffect\s*(?:<[^>]*>)?\s*\(/,/data-stx(?:-auto)?(?![-\w])/,/data-stx-scoped/].some(($)=>$.test(Y))}function L6(Y){let Q=/@(if\s*\(|endif|elseif\s*\(|else\b)/g,$=0,X;while((X=Q.exec(Y))!==null){let J=X[1];if(J.startsWith("if"))$++;else if(J==="endif")$--;else if($===0)return!0}return!1}function B6(Y){let Q=new Set,$=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,X=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal)\s*(?:<[^>]*>)?\s*\(/g,J;while((J=$.exec(Y))!==null){let Z=J[1],z;while((z=X.exec(Z))!==null)Q.add(z[1])}return Q}var o3=new Set(["true","false","null","undefined","NaN","Infinity","typeof","instanceof","in","of","new","void","delete","this","Math","JSON","Date","Number","String","Boolean","Array","Object","RegExp","Map","Set","Symbol","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","window","document","console"]);function O6(Y){return Y.replace(/'(?:\\.|[^'\\])*'/g,"''").replace(/"(?:\\.|[^"\\])*"/g,'""').replace(/`(?:\\.|[^`\\])*`/g,"``")}function e3(Y,Q,$){if(!Y)return!1;let X=O6(Y),J=!1,Z=!1,z=!1,G=/([a-zA-Z_$][\w$]*)/g,U;while((U=G.exec(X))!==null){let W=U[1];if(X.slice(0,U.index).trimEnd().endsWith("."))continue;if(o3.has(W))continue;if(Q.has(W))J=!0;else if($&&W in $)Z=!0}let _=/([a-zA-Z_$][\w$]*)(?:\.[a-zA-Z_$][\w$]*)*\s*\(\s*\)/g,K;while((K=_.exec(X))!==null){let W=K[1];if(X.slice(0,K.index).trimEnd().endsWith("."))continue;if(o3.has(W)||$&&W in $)continue;z=!0}return(J||z)&&!Z}function U1(Y,Q,$){let X=$===void 0?` ${Q}`:` ${Q}="${$.replace(/"/g,""")}"`,J=Y.trim(),Z=J.match($4);if(Z&&V6(Z[3],Z[1])){let[,z,G,U]=Z;return`<${z}${G}${X}>${U}</${z}>`}return`<template${X}>${J}</template>`}function V6(Y,Q){let $=new RegExp(`<(/)?${Q}(?=[\\s/>])`,"gi"),X=0,J;while((J=$.exec(Y))!==null)if(J[1]){if(X--,X<0)return!1}else X++;return!0}function X4(Y,Q){let $=Y,X=B6(Y),J=/@if\s*\(/g,Z,z=[];while((Z=J.exec($))!==null){let G=Z.index,U=G+Z[0].length,_=1,K=U;while(K<$.length&&_>0){if($[K]==="(")_++;else if($[K]===")")_--;K++}if(_!==0)continue;let j=$.substring(U,K-1).trim(),W=K,q=1,H=W,L=/@(if\s*\(|endif)/g;L.lastIndex=W;let O;while((O=L.exec($))!==null)if(O[1].startsWith("if"))q++;else if(O[1]==="endif"){if(q--,q===0){H=O.index+O[0].length;break}}if(q!==0)continue;let V=$.substring(W,H-6).trim(),B;if(L6(V)){let A=t3($.substring(G,H));if(A.length===0)continue;let w=A[0].branches.filter((I)=>I.type!=="else");if(!(w.length>0&&w.every((I)=>e3(I.condition,X,Q))))continue;B=A[0].branches.map((I)=>{if(I.type==="elseif")return U1(I.content,"@else-if",I.condition??"");if(I.type==="else")return U1(I.content,"@else");return U1(I.content,"@if",I.condition??"")}).join(`
|
|
1372
|
+
`)}else{if(!e3(j,X,Q))continue;B=U1(V,"@if",j)}z.push({start:G,end:H,replacement:B})}for(let G=z.length-1;G>=0;G--){let{start:U,end:_,replacement:K}=z[G];$=$.substring(0,U)+K+$.substring(_)}return $}function A6(Y){let Q=Y.trim();if(Q==="")return;if(Q==="true")return!0;if(Q==="false")return!1;if(Q==="null")return!1;if(Q==="undefined")return!1;if(Q==="NaN")return!1;if(/^-?\d+(?:\.\d+)?$/.test(Q)){let J=Number(Q);return J!==0&&!Number.isNaN(J)}let $=Q.match(/^'((?:\\.|[^'\\])*)'$/);if($)return $[1].length>0;let X=Q.match(/^"((?:\\.|[^"\\])*)"$/);if(X)return X[1].length>0;return}var y1=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function w6(Y,Q,$,X){if(y1.has($.toLowerCase()))return X;let J=$.toLowerCase(),Z=Y.toLowerCase(),z=Y.length,G=1,U=X;while(U<z){let _=Y.indexOf("<",U);if(_===-1)return-1;if(U=_,Y.startsWith("<!--",U)){let q=Y.indexOf("-->",U+4);if(q===-1)return-1;U=q+3;continue}let K=/^<(script|style)\b/i.exec(Y.slice(U,U+8));if(K){let q=Y.indexOf(">",U);if(q===-1)return-1;if(Y[q-1]==="/"){U=q+1;continue}let H=Z.indexOf(`</${K[1].toLowerCase()}`,U);if(H===-1)return-1;let L=Y.indexOf(">",H);if(L===-1)return-1;U=L+1;continue}if(Y[U+1]==="/"){let q=/^<\/([a-z][\w-]*)\s*>/i.exec(Y.slice(U,U+64));if(!q){U++;continue}if(q[1].toLowerCase()===J){if(G--,U+=q[0].length,G===0)return U;continue}U+=q[0].length;continue}let j=/^<([a-z][\w-]*)\b/i.exec(Y.slice(U,U+64));if(!j){U++;continue}let W=Y.indexOf(">",U);if(W===-1)return-1;if(j[1].toLowerCase()===J){let q=Y.slice(U,W+1);if(!(/\/\s*>$/.test(q)||y1.has(J)))G++}U=W+1}return-1}var F6=/\s(?::else-if|x-else-if|@else-if|:else|x-else|@else)(?=[=\s/>])/;function R6(Y,Q){let $=Q,X=Y.length;for(;;){while($<X&&Y[$]!=="<")$++;if($>=X)return!1;if(Y.startsWith("<!--",$)){let z=Y.indexOf("-->",$+4);if(z===-1)return!1;$=z+3;continue}break}if(Y[$+1]==="/")return!1;let J=Y.indexOf(">",$);if(J===-1)return!1;let Z=Y.slice($,J+1);return F6.test(Z)}function Q4(Y){if(!Y.includes(":if")&&!Y.includes(":show")&&!Y.includes("x-if")&&!Y.includes("x-show")&&!Y.includes("@if=")&&!Y.includes("@show="))return Y;let Q=[],$=/<(script|style)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,X;while((X=$.exec(Y))!==null)Q.push([X.index,X.index+X[0].length]);let J=(j)=>Q.some(([W,q])=>j>=W&&j<q),Z=/<([a-zA-Z][\w-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*?)\s+(:if|:show|x-if|x-show|@if|@show)\s*=\s*"([^"]*)"((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)(\/?)>/g,z=[],G;while((G=Z.exec(Y))!==null){if(J(G.index))continue;let[j,W,q,H,L,O,V]=G,B=A6(L);if(B===void 0)continue;let A=G.index,w=A+j.length,I=!!V||/\/\s*>$/.test(j)||y1.has(W.toLowerCase())?w:w6(Y,A,W,w);if(I===-1)continue;if((H===":if"||H==="x-if"||H==="@if")&&R6(Y,I)){Z.lastIndex=w;continue}if(B===!0){let R=`<${W}${q}${O}${V}>`;z.push({start:A,end:w,replacement:R});continue}z.push({start:A,end:I,replacement:""}),Z.lastIndex=I}if(z.length===0)return Y;z.sort((j,W)=>j.start-W.start);let U=[],_=-1;for(let j of z){if(j.start<_)continue;U.push(j),_=j.end}let K=Y;for(let j=U.length-1;j>=0;j--){let{start:W,end:q,replacement:H}=U[j];K=K.substring(0,W)+H+K.substring(q)}return K}function J4(Y,Q){let $=Y,X=/@(for|foreach)\s*\(/g,J,Z=[];while((J=X.exec($))!==null){let z=J[1],G=J.index,U=G+J[0].length,_=1,K=U;while(K<$.length&&_>0){if($[K]==="(")_++;else if($[K]===")")_--;K++}if(_!==0)continue;let j=$.substring(U,K-1).trim(),W=K,q=W6(j);if(q.iterable){let N=q.iterable.trim();if(N.startsWith("[")||N.startsWith("{")||N.startsWith("'")||N.startsWith('"')||N.startsWith("`")||/^-?\d/.test(N))continue;if(Q){let I=N.split(/[.[(]/)[0].trim();if(I&&I in Q)continue}}if(q.style==="as")j=q.indexVar?`(${q.itemVar}, ${q.indexVar}) in ${q.iterable}`:`${q.itemVar} in ${q.iterable}`;let H=z==="for"?"@endfor":"@endforeach",L=1,O=W,V=z==="for"?new RegExp("@(for(?!each)\\s*\\(|endfor(?!each))","g"):new RegExp(`@(${z}\\s*\\(|end${z})`,"g");V.lastIndex=W;let B;while((B=V.exec($))!==null)if(B[1].startsWith(z))L++;else if(L--,L===0){O=B.index+B[0].length;break}if(L!==0)continue;let A=$.substring(W,O-H.length).trim(),w=A.match($4),F;if(w){let[,N,I,T]=w;F=`<${N}${I} @for="${j}">${T}</${N}>`}else F=`<template @for="${j}">${A}</template>`;Z.push({start:G,end:O,replacement:F})}for(let z=Z.length-1;z>=0;z--){let{start:G,end:U,replacement:_}=Z[z];$=$.substring(0,G)+_+$.substring(U)}return $}function T6(Y){let Q=new Set,$=[],X=0,J=0,Z=Y.length,z=(K)=>{let j=X+1;while(j<Z){let W=Y[j];if(W==="\\"){j+=2;continue}if(W===K)return j+1;j++}return Z},G=()=>{let K=X+2;while(K<Z&&Y[K]!==`
|
|
1373
|
+
`)K++;return K},U=()=>{let K=X+2;while(K<Z-1){if(Y[K]==="*"&&Y[K+1]==="/")return K+2;K++}return Z},_=(K)=>{let j=K,W=0;while(j<Z){let q=Y[j];if(q==="/"&&Y[j+1]==="/"){let H=j+2;while(H<Z&&Y[H]!==`
|
|
1374
|
+
`)H++;j=H;continue}if(q==="/"&&Y[j+1]==="*"){let H=j+2;while(H<Z-1&&!(Y[H]==="*"&&Y[H+1]==="/"))H++;j=H+2;continue}if(q==='"'||q==="'"||q==="`"){let H=j+1;while(H<Z){if(Y[H]==="\\"){H+=2;continue}if(Y[H]===q){H++;break}H++}j=H;continue}if(q==="("||q==="["||q==="{"){W++,j++;continue}if(q===")"||q==="]"||q==="}"){W--,j++;continue}if(q===";"&&W===0)return j+1;j++}return Z};while(X<Z){let K=Y[X];if(K==="/"&&Y[X+1]==="/"){let j=G();$.push(Y.slice(X,j)),X=j;continue}if(K==="/"&&Y[X+1]==="*"){let j=U();$.push(Y.slice(X,j)),X=j;continue}if(K==='"'||K==="'"||K==="`"){let j=z(K);$.push(Y.slice(X,j)),X=j;continue}if(K==="{"){J++,$.push(K),X++;continue}if(K==="}"){J--,$.push(K),X++;continue}if(J===0){let j=X>0?Y[X-1]:"";if(j===""||/\s/.test(j)||j===";"||j==="}"||j==="{"){let q=Y.slice(X).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(q){let H=q[2],L=_(X+q[0].length);if(Q.has(H)){$.push(`/* stx: deduped const ${H} */`),X=L;continue}Q.add(H),$.push(Y.slice(X,L)),X=L;continue}}}$.push(K),X++}return $.join("")}async function I6(Y,Q,$){let X=_6(Y,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),J=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useStore|useLocalStorage|useSessionStorage|useCookie|useReactiveProp|useFetch|useRef|useEventListener|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots|useOptimistic)\s*(?:<[^>]*>)?\s*\(/,Z=[];for(let L of X){let O=L.body;if(I0(L.attrs))O=k0(O);if(J.test(O))Z.push({fullMatch:L.fullMatch,attrs:L.attrs,content:O})}if(Z.length===0)return{output:Y,setupCode:null};let z=`__stx_setup_${Date.now()}_${j6++}`,{hasUserImports:G,bundleClientScript:U}=await import("././client-script-bundler.js"),_=[];for(let L=0;L<Z.length;L++){let O=Z[L].content;if(G(O))console.log("[stx:bundler] bundling signal script imports"),O=await U(O,Q||"",{projectRoot:process.cwd()});O=O.replace(/^\s*import\s+(?:type\s+)?\{[^}]*\}\s+from\s+['"](?:stx|@stacksjs\/stx|@stacksjs\/browser)['"]\s*;?\s*$/gm,"// [stx import stripped \u2014 resolved via window.stx in __stx_setup]");let V=L0(O);_.push(`// \u2500\u2500 merged signal script #${L+1} \u2500\u2500
|
|
1375
|
+
${V}`)}let K=_.join(`
|
|
1376
|
+
|
|
1377
|
+
`);K=T6(K);let j=k6(K),W=b1(K,$),q=`
|
|
1378
|
+
<script data-stx-scoped>
|
|
1379
|
+
function ${z}() {
|
|
1380
|
+
const { state, derived, effect, batch, onMount, onDestroy, defineStore, useStore, useFetch, useRef, useQuery, useMutation, useOptimistic, useDebounce, useDebouncedValue, useThrottle, useInterval, useTimeout, useToggle, useCounter, useClickOutside, useFocus, useAsync, useLocalStorage, useSessionStorage, useCookie, useReactiveProp, useEventListener, useWebSocket, useColorMode, useDark, useHead, useSeoMeta, definePageMeta, useRoute, useSearchParams, navigate, goBack, goForward, provide, ref, reactive, computed, watch, watchEffect, defineProps, withDefaults, defineEmits, defineExpose, defineSlots } = window.stx;
|
|
1381
|
+
${W}${K}
|
|
1382
|
+
return { ${j} };
|
|
1383
|
+
}
|
|
1384
|
+
if(window.stx)window.stx._latestSetup=${z};
|
|
1385
|
+
</script>`,H=Y;for(let L of Z)H=H.split(L.fullMatch).join("");if(H.includes("<body"))H=H.replace(/<body([^>]*)>/,`<body$1 data-stx="${z}">`);else{let L=["script","style","html","head","meta","link","title","!doctype"],O=!1;H=H.replace(/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*)>/gi,(V,B,A)=>{if(O||L.includes(B.toLowerCase()))return V;return O=!0,`<${B}${A} data-stx="${z}">`})}return{output:H,setupCode:q}}function k6(Y){let Q=Y,$=[],X=new Set,J=0,Z=0,z=Q.length,G="",U=()=>{Z++;let H=!1;while(Z<z){let L=Q[Z];if(L==="\\"){Z+=2;continue}if(L==="["&&!H){H=!0,Z++;continue}if(L==="]"&&H){H=!1,Z++;continue}if(L==="/"&&!H){Z++;while(Z<z&&/[gimsuyd]/.test(Q[Z]))Z++;return}if(L===`
|
|
1386
|
+
`)return;Z++}},_=()=>{if(!G)return!0;if(/[\w)\]]/.test(G))return!1;return!0},K=(H)=>{Z++;while(Z<z){if(Q[Z]==="\\"){Z+=2;continue}if(Q[Z]===H){Z++;return}Z++}},j=()=>{Z++;while(Z<z){if(Q[Z]==="\\"){Z+=2;continue}if(Q[Z]==="`"){Z++;return}if(Q[Z]==="$"&&Q[Z+1]==="{"){Z+=2;let H=1;while(Z<z&&H>0)if(Q[Z]==="{")H++,Z++;else if(Q[Z]==="}")H--,Z++;else if(Q[Z]==="'"||Q[Z]==='"')K(Q[Z]);else if(Q[Z]==="`")j();else Z++;continue}Z++}},W=()=>{if(Q[Z]==="/"&&Q[Z+1]==="/"){while(Z<z&&Q[Z]!==`
|
|
1387
|
+
`)Z++;return!0}if(Q[Z]==="/"&&Q[Z+1]==="*"){Z+=2;while(Z<z-1&&!(Q[Z]==="*"&&Q[Z+1]==="/"))Z++;return Z+=2,!0}return!1},q=()=>{if(J!==0)return;let H=Q.slice(Z).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(H){let A=H[2];if(!X.has(A))$.push(A),X.add(A);return}let L=Q.slice(Z).match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(L){L[1].split(",").forEach((A)=>{let w=A.trim();if(!w)return;let F=w.indexOf(":"),I=(F>=0?w.slice(F+1).trim():w).split(/[\s=]/)[0];if(I&&!X.has(I))$.push(I),X.add(I)});return}let O=Q.slice(Z).match(/^(?:const|let|var)\s+\[([^\]]+)\]\s*=/);if(O){O[1].split(",").forEach((A)=>{let w=A.trim().replace(/^\.\.\./,"");if(!w)return;let F=w.split(/[\s=]/)[0];if(F&&!X.has(F))$.push(F),X.add(F)});return}let V=Q.slice(Z).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(V){let A=V[1];if(!X.has(A))$.push(A),X.add(A);return}let B=Q.slice(Z).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(B){let A=B[1];if(!X.has(A))$.push(A),X.add(A)}};while(Z<z){if(W())continue;if(Q[Z]==="'"||Q[Z]==='"'){K(Q[Z]),G=Q[Z-1];continue}if(Q[Z]==="`"){j(),G="`";continue}if(Q[Z]==="/"&&Q[Z+1]!=="/"&&Q[Z+1]!=="*"&&_()){U(),G="/";continue}if(Q[Z]==="{"){J++,G="{",Z++;continue}if(Q[Z]==="}"){J--,G="}",Z++;continue}if(J===0&&/[a-z]/i.test(Q[Z])&&(Z===0||/\s|[;{}()]/.test(Q[Z-1])))q();if(!/\s/.test(Q[Z]))G=Q[Z];Z++}return $.join(", ")}async function z4(Y,Q,$,X){if(!S1(Y))return Y;let J=Y;if(Q.skipSignalsRuntime)return J;let{output:Z,setupCode:z}=await I6(J,$,X);if(J=Z,J=await Z4(J,Q),J=Y4(J),z)if(J.includes("</head>"))J=J.replace("</head>",`${z}
|
|
1388
|
+
</head>`);else if(J.includes("<body"))J=J.replace(/<body([^>]*)>/,`<body$1>
|
|
1389
|
+
${z}`);else J=J+`
|
|
1390
|
+
`+z;let U=J.replace(/<script\b[\s\S]*?<\/script>/gi,"").replace(/<style\b[\s\S]*?<\/style>/gi,"").match(/<body([^>]*)>/i),_=U&&/data-stx/.test(U[1]);if(!z&&!_&&U&&!/data-stx-auto/.test(U[1])){let K=/<body[^>]*>/i,j=/<(script|style)\b[\s\S]*?<\/\1>/gi,W=[],q;while((q=j.exec(J))!==null)W.push([q.index,q.index+q[0].length]);let H=0,L=-1;while(H<J.length){K.lastIndex=H;let O=K.exec(J.slice(H));if(!O)break;let V=H+O.index;if(!W.some(([A,w])=>V>=A&&V<w)){L=V;break}H=V+O[0].length}if(L!==-1){let O=J.slice(0,L),V=J.slice(L).replace(K,(B)=>B.replace(/^<body([^>]*)>$/i,"<body$1 data-stx-auto>"));J=O+V}}return J}import U0 from"path";import C1 from"fs";function G4(Y){return Y.split("-").map((Q)=>Q.charAt(0).toUpperCase()+Q.slice(1)).join("")}function U4(Y){return Y.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class K4{builtins=new Map;registerBuiltin(Y){this.builtins.set(Y.name.toLowerCase(),Y);for(let Q of Y.aliases)this.builtins.set(Q.toLowerCase(),Y)}isBuiltin(Y){return this.builtins.has(Y.toLowerCase())}getBuiltin(Y){return this.builtins.get(Y.toLowerCase())??null}async resolveFile(Y,Q,$,X){let J=Y.endsWith(".stx")?Y.slice(0,-4):Y,Z=X?.__importedComponents;if(Z){let q=[J,J.toLowerCase(),G4(J),U4(J)];for(let H of q)if(Z.has(H))return Z.get(H)}let z=[...new Set([`${J}.stx`,`${G4(J)}.stx`,`${U4(J)}.stx`])];if(J.startsWith("./")||J.startsWith("../")){let q=U0.resolve(U0.dirname(Q),`${J}.stx`);if(await x(q))return q;return null}let G=[],U=$.componentsDir||"",_=X?.__originalFilePath;if(_)G.push(U0.join(U0.dirname(_),"components"));if(U)G.push(U);let K=U0.join(U0.dirname(Q),"components");if(!G.includes(K))G.push(K);let j=process.cwd(),W=[U0.resolve(j,"src/components"),U0.resolve(j,"components"),U0.resolve(import.meta.dir,"components")];for(let q of W)if(!G.includes(q))G.push(q);for(let q of G){if(!q)continue;for(let H of z){let L=U0.join(q,H);if(await x(L))return L}try{if(!C1.statSync(q,{throwIfNoEntry:!1})?.isDirectory())continue;let L=C1.readdirSync(q,{withFileTypes:!0});for(let O of L)if(O.isDirectory()){let V=U0.join(q,O.name);for(let B of z){let A=U0.join(V,B);if(await x(A))return A}}}catch{}}return null}}var $0=new K4;function q4(){$0.registerBuiltin(v1),$0.registerBuiltin(P1),$0.registerBuiltin(f1),$0.registerBuiltin(g1),$0.registerBuiltin(x1),$0.registerBuiltin(h1),$0.registerBuiltin(d1),$0.registerBuiltin(m1),$0.registerBuiltin(u1),$0.registerBuiltin(l1)}import y0 from"path";function c1(Y){return Y.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}function i1(Y,Q,$){let X=[],J=0;while(J<Y.length){let Z=Y.indexOf("<",J);if(Z===-1)break;let G=Y.slice(Z+1).match(new RegExp(`^(${Q.source})`));if(!G){J=Z+1;continue}let U=G[1];if($&&$.has(U.toLowerCase())){let L=Z+1+U.length;while(L<Y.length&&Y[L]!==">")L++;J=L+1;continue}let _=Z+1+U.length,K=null,j=_,W=-1,q=!1;while(_<Y.length){let L=Y[_];if(K){if(L==="\\"&&_+1<Y.length){_+=2;continue}if(L===K)K=null;_++;continue}if(L==='"'||L==="'"){K=L,_++;continue}if(L==="/"&&_+1<Y.length&&Y[_+1]===">"){W=_+2,q=!0;break}if(L===">"){W=_+1;break}_++}if(W===-1){J=Z+1;continue}let H=Y.slice(j,q?W-2:W-1).trim();if(q)X.push({fullMatch:Y.slice(Z,W),tagName:U,attributes:H,content:"",startIndex:Z,endIndex:W,isSelfClosing:!0}),J=W;else{let L=`<${U}`,O=`</${U}>`,V=1,B=W,A=-1;while(V>0&&B<Y.length){let N=Y.indexOf(L,B),I=Y.indexOf(O,B);if(I===-1)break;if(N!==-1&&N<I){let T=Y[N+L.length];if(T===" "||T===">"||T==="/"||T===`
|
|
1391
|
+
`||T==="\t")V++;B=N+L.length}else{if(V--,V===0){A=I;break}B=I+O.length}}if(A===-1){J=W;continue}let w=Y.slice(W,A),F=A+O.length;X.push({fullMatch:Y.slice(Z,F),tagName:U,attributes:H,content:w,startIndex:Z,endIndex:F,isSelfClosing:!1}),J=F}}return X}function p1(Y,Q){try{let $=Buffer.from(Y,"base64").toString("utf8");return JSON.parse($)}catch{}try{let $=Y.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&");return JSON.parse($)}catch($){if(Q?.debug)console.error("Error decoding __stx_ prop:",$);return Y}}function N6(Y){let Q={},$=0,X=Y.length;while($<X){while($<X&&/\s/.test(Y[$]))$++;if($>=X)break;let J="";while($<X&&!/[\s=]/.test(Y[$]))J+=Y[$],$++;if(!J)break;if(J.startsWith("@")||J.startsWith(":")){while($<X&&Y[$]!=='"'&&Y[$]!=="'")$++;if($<X){let Z=Y[$];$++;while($<X&&Y[$]!==Z){if(Y[$]==="\\")$++;$++}$++}continue}while($<X&&/\s/.test(Y[$]))$++;if($<X&&Y[$]==="="){$++;while($<X&&/\s/.test(Y[$]))$++;let Z="";if($<X&&(Y[$]==='"'||Y[$]==="'")){let z=Y[$];$++;while($<X){let G=Y[$];if(G==="\\"&&$+1<X){$++,Z+=Y[$],$++;continue}if(G===z){$++;break}Z+=G,$++}}else while($<X&&!/\s/.test(Y[$]))Z+=Y[$],$++;Q[J]=Z}else Q[J]="true"}return Q}function DY(Y){let Q=[],$=0,X=Y.length;while($<X){while($<X&&/\s/.test(Y[$]))$++;if($>=X)break;let J="";while($<X&&!/[\s=]/.test(Y[$]))J+=Y[$],$++;if(!J)break;while($<X&&/\s/.test(Y[$]))$++;if($<X&&Y[$]==="="){$++;while($<X&&/\s/.test(Y[$]))$++;let Z="";if($<X&&(Y[$]==='"'||Y[$]==="'")){let z=Y[$];$++;while($<X&&Y[$]!==z){if(Y[$]==="\\"&&$+1<X)$++,Z+=Y[$];else Z+=Y[$];$++}if($<X)$++}else while($<X&&!/\s/.test(Y[$]))Z+=Y[$],$++;Q.push({name:J,value:Z})}else Q.push({name:J,value:!0})}return Q}async function EY(Y,Q,$,X){let J=Y;return J=J.replace(/<stx-loading-indicator([^>]*?)(?:\s*\/>|><\/stx-loading-indicator>)/gi,(Z,z)=>{let G=z.match(/color=["']([^"']+)["']/i),U=z.match(/initial-color=["']([^"']+)["']/i),_=z.match(/height=["']([^"']+)["']/i),K=z.match(/duration=["']([^"']+)["']/i),j=z.match(/throttle=["']([^"']+)["']/i),W=z.match(/z-index=["']([^"']+)["']/i),q=(O)=>O.replace(/[;{}()]/g,"").replace(/url/gi,""),H={color:q(G?.[1]||"#6366f1"),initialColor:q(U?.[1]||""),height:q(_?.[1]||"3px"),duration:K?Number.parseInt(K[1]):2000,throttle:j?Number.parseInt(j[1]):200,zIndex:W?Number.parseInt(W[1]):999999},L=H.initialColor?`linear-gradient(to right, ${H.initialColor}, ${H.color})`:H.color;return`
|
|
1392
|
+
<div id="stx-loading-indicator" style="position:fixed;top:0;left:0;right:0;height:${H.height};background:${L};z-index:${H.zIndex};transform:scaleX(0);transform-origin:left;transition:transform 0.1s ease-out,opacity 0.3s ease;opacity:0;pointer-events:none">
|
|
1393
|
+
<div style="position:absolute;top:0;left:0;right:0;bottom:0;background:linear-gradient(90deg,transparent 0%,rgba(255,255,255,0.4) 50%,transparent 100%);animation:stx-shimmer 1.5s infinite"></div>
|
|
1394
|
+
</div>
|
|
1395
|
+
<style>@keyframes stx-shimmer{0%{transform:translateX(-100%)}100%{transform:translateX(100%)}}</style>
|
|
1396
|
+
<script>
|
|
1397
|
+
(function(){var el=document.getElementById('stx-loading-indicator'),p=0,l=!1,i=null;function u(v){p=Math.min(Math.max(v,0),100);if(el){el.style.opacity=p>0?'1':'0';el.style.transform='scaleX('+(p/100)+')'}}window.stxLoading={start:function(){l=!0;p=0;u(10);if(i)clearInterval(i);i=setInterval(function(){if(!l)return;var r=90-p,inc=Math.max(0.5,r*0.1);if(p<90)u(p+inc)},${H.throttle})},finish:function(){l=!1;if(i){clearInterval(i);i=null}u(100);setTimeout(function(){if(el)el.style.opacity='0';setTimeout(function(){p=0;if(el)el.style.transform='scaleX(0)'},300)},200)},set:function(v){u(v)},clear:function(){l=!1;p=0;if(i){clearInterval(i);i=null}if(el){el.style.opacity='0';el.style.transform='scaleX(0)'}}};document.addEventListener('click',function(e){var a=e.target.closest&&e.target.closest('a');if(!a)return;var h=a.getAttribute('href');if(!h||h.startsWith('http')||h.startsWith('#')||h.startsWith('mailto:')||h.startsWith('tel:')||a.target==='_blank')return;window.stxLoading.start()});window.addEventListener('popstate',function(){window.stxLoading.start()});window.addEventListener('load',function(){window.stxLoading.finish()})})();
|
|
1398
|
+
</script>`}),J}async function MY(Y,Q,$,X,J){let Z=Y;if(!Q.__importedComponents)Q.__importedComponents=new Map;let z=Q.__importedComponents,G=/@import\s*\(\s*([^)]+)\s*\)/g,U;while((U=G.exec(Z))!==null){let[_,K]=U,j=K.split(",").map((W)=>W.trim().replace(/^['"]|['"]$/g,"")).filter((W)=>W.length>0);for(let W of j){let q=W.split("/"),L=q[q.length-1].replace(/\.stx$/,""),O=L.includes("-")?L.split("-").map((A)=>A.charAt(0).toUpperCase()+A.slice(1)).join(""):L.charAt(0).toUpperCase()+L.slice(1),V=null,B=[y0.resolve(y0.dirname($),`${W}.stx`),y0.resolve(y0.dirname($),W),y0.resolve(X.componentsDir||"components",`${W}.stx`),y0.resolve(X.componentsDir||"components",W),W.endsWith(".stx")?W:`${W}.stx`];for(let A of B)try{if(await Bun.file(A).exists()){V=A;break}}catch{}if(V){z.set(O,V),z.set(L,V),z.set(L.toLowerCase(),V);let A=O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(z.set(A,V),J.add(V),X.debug)console.log(`Imported component: ${O} -> ${V}`)}else if(X.debug)console.warn(`Could not resolve imported component: ${W}`)}Z=Z.replace(_,""),G.lastIndex=0}return Z}async function yY(Y,Q,$,X,J,Z){let z=Y;if(!Q.__processedComponents)Q.__processedComponents=new Set;let G=Q.__processedComponents,U=/@component\s*\(/g,_;while((_=U.exec(z))!==null){let K=_.index,j=K+_[0].length-1,W=1,q=j+1;while(q<z.length&&W>0){if(z[q]==="(")W++;else if(z[q]===")"){if(W--,W===0)break}q++}if(W!==0)break;let H=z.substring(j+1,q),L=q+1,O=H.match(/^\s*['"]([^'"]+)['"]/);if(!O){U.lastIndex=0;continue}let V=O[1],B,A=H.slice(O[0].length),w=A.match(/^\s*,\s*/);if(w)B=A.slice(w[0].length).trim();let F={};if(B)try{F=B0(B,Q)}catch(E){let y=E instanceof Error?E.message:String(E);z=z.replace(z.substring(K,L),`[Error parsing component props: ${y}]`);continue}let N="",I=L,R=z.substring(L).match(/^([\s\S]*?)@endcomponent/);if(R)N=R[1].trim(),I=L+R[0].length;let k=z.substring(K,I),D=await O0(V,F,N,X,Q,$,J,G,Z);z=z.substring(0,K)+D+z.substring(I),U.lastIndex=0}return z}async function bY(Y,Q,$,X,J,Z){let z=Y;if(!Q.__processedComponents)Q.__processedComponents=new Set;let G=Q.__processedComponents,U=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]),_=K1(z);return z=_.output,z=await q(z,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),z=await q(z,/[A-Z][a-zA-Z0-9]*/,!0),z=await q(z,/[a-z][a-z0-9]*/,!1,U),z=q1(z,_.scripts),z;async function q(H,L,O,V){let B=H,A=i1(B,L,V);for(let w=A.length-1;w>=0;w--){let F=A[w],N=O?c1(F.tagName):F.tagName,I=N6(F.attributes),T={};for(let[k,D]of Object.entries(I)){if(k.startsWith("@"))continue;if(k.startsWith("__stx_")){let E=k.slice(6);T[E]=p1(D,J);continue}if(k.startsWith(":")){let E=k.slice(1),y=D==="true"?E:D;try{if(!t(y)){if(J.debug)console.error(`Unsafe expression in :${E} binding: ${y}`);T[E]=D}else{let M=e(y,Object.keys(Q));T[E]=M(...Object.values(Q))}}catch(M){if(J.debug)console.error(`Error evaluating :${E} binding:`,M);T[E]=D}continue}if(typeof D==="string"&&D.includes("{{")&&D.includes("}}")){let E=D.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(E)try{let y=E[1];if(!t(y)){if(J.debug)console.error(`Unsafe expression in ${k}: ${y}`);T[k]=D}else{let M=e(y,Object.keys(Q));T[k]=M(...Object.values(Q))}}catch(y){if(J.debug)console.error(`Error evaluating expression for ${k}:`,y);T[k]=D}else{let y=D,M=/\{\{\s*([\s\S]+?)\s*\}\}/g,b;while((b=M.exec(D))!==null)try{let P=b[1];if(!t(P)){if(J.debug)console.error(`Unsafe expression in ${k}: ${P}`);continue}let f=e(P,Object.keys(Q))(...Object.values(Q));y=y.replace(b[0],String(f??""))}catch(P){if(J.debug)console.error(`Error evaluating expression in ${k}:`,P)}T[k]=y}}else T[k]=D}let R=await O0(N,T,F.content,X,Q,$,J,G,Z);B=B.substring(0,F.startIndex)+R+B.substring(F.endIndex)}return B}}import H1 from"fs";import Q0 from"path";var H4=!1,D6=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);function E6(Y,Q,$){let X={static:{},serverDynamic:{},clientReactive:{},events:{}},J=new Set(["x-cloak","x-show","x-if","x-for","x-data","x-init","x-transition","x-ref","x-effect","x-model","x-text","x-html","x-class","x-style","x-on","x-bind"]),Z=(z)=>{if(!z.includes("-")||z.startsWith("@")||z.startsWith(":")||z.startsWith("x-")||z.startsWith("__"))return z;return z.replace(/-([a-z0-9])/g,(G,U)=>U.toUpperCase())};for(let[z,G]of Object.entries(Y)){let U=z.startsWith("x-")&&!J.has(z)&&!z.startsWith("x-bind:")&&!z.startsWith("x-on:")?`:${z.slice(2)}`:z;if(U.startsWith("@")){X.events[U]=G;continue}if(U.startsWith("__stx_")){let _=Z(U.slice(6));X.serverDynamic[_]=p1(G,$);continue}if(U.startsWith(":")){let _=Z(U.slice(1)),K=G==="true"?_:G;try{if(!t(K)){if($.debug)console.error(`Unsafe expression in :${_} binding: ${K}`);X.clientReactive[_]=K;continue}let j=Object.keys(Q),q=e(K,j)(...Object.values(Q));if(q===void 0){let H=K.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],L=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(H.some((V)=>!L.has(V)&&!j.includes(V))){X.clientReactive[_]=K;continue}}X.serverDynamic[_]=q}catch{X.clientReactive[_]=K}continue}if(typeof G==="string"&&G.includes("{{")&&G.includes("}}")){let _=G.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(_)try{let K=_[1];if(t(K)){let W=e(K,Object.keys(Q))(...Object.values(Q));X.static[U]=W!=null?String(W):""}else{if($.debug)console.error(`Unsafe expression in ${U}: ${K}`);X.static[U]=G}}catch(K){if($.debug)console.error(`Error evaluating expression for ${U}:`,K);X.static[U]=G}else{let K=G,j=/\{\{\s*([\s\S]+?)\s*\}\}/g,W;while((W=j.exec(G))!==null)try{let q=W[1];if(!t(q)){if($.debug)console.error(`Unsafe expression in ${U}: ${q}`);continue}let L=e(q,Object.keys(Q))(...Object.values(Q));K=K.replace(W[0],String(L??""))}catch(q){if($.debug)console.error(`Error evaluating expression in ${U}:`,q)}X.static[U]=K}continue}X.static[U]=G}return X}function M6(Y){let Q={},$=0,X=Y.length;while($<X){while($<X&&/\s/.test(Y[$]))$++;if($>=X)break;let J="";while($<X&&!/[\s=]/.test(Y[$]))J+=Y[$],$++;if(!J)break;while($<X&&/\s/.test(Y[$]))$++;if($<X&&Y[$]==="="){$++;while($<X&&/\s/.test(Y[$]))$++;let Z="";if($<X&&(Y[$]==='"'||Y[$]==="'")){let z=Y[$];$++;while($<X){let G=Y[$];if(G==="\\"&&$+1<X){$++,Z+=Y[$],$++;continue}if(G===z){$++;break}Z+=G,$++}}else while($<X&&!/\s/.test(Y[$]))Z+=Y[$],$++;Q[J]=Z}else Q[J]="true"}return Q}function j4(Y){return Y.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function y6(Y){let Q=new Set,$=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,X;while((X=$.exec(Y))!==null){let J=X[1];if($0.isBuiltin(J))Q.add(J)}return[...Q].sort()}var _4=new Map;function b6(Y){let Q=_4.get(Y);if(Q)return Q;let $=new Map,X=[Q0.join(Y,"src"),Q0.join(Y,"dist"),Y];function J(Z,z){if(z>6)return;let G;try{G=H1.readdirSync(Z,{withFileTypes:!0})}catch{return}for(let U of G){let _=Q0.join(Z,U.name);if(U.isDirectory()){if(U.name==="node_modules"||U.name.startsWith("."))continue;J(_,z+1)}else if(U.isFile()&&U.name.endsWith(".stx")){let K=U.name.slice(0,-4);if(!$.has(K))$.set(K,_);let j=K.toLowerCase();if(!$.has(j))$.set(j,_);let W=K.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!$.has(W))$.set(W,_)}}}for(let Z of X)if(J(Z,0),$.size>0)break;return _4.set(Y,$),$}function S6(Y,Q){if(Y.startsWith(".")||Y.startsWith("/"))return null;let $=Q;while(!0){let X=Q0.join($,"node_modules",Y);try{if(H1.statSync(X).isDirectory())return X}catch{}let J=Q0.dirname($);if(J===$)return null;$=J}}async function C6(Y,Q,$,X,J){if(!Y.includes("import"))return Y;if(!Q.__importedComponents)Q.__importedComponents=new Map;let Z=Q.__importedComponents,z=Q0.dirname($),G=Y,U=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return G=G.replace(U,(_,K,j)=>{let W=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,q=j,H,L=[];while((H=W.exec(j))!==null){let[O,V,B,A]=H,w=null,F=null;if(A.startsWith(".")||A.startsWith("/")){let T=Q0.resolve(z,A);if(T.endsWith(".stx"))F=T;else{let R=`${T}.stx`;try{if(H1.statSync(R).isFile())F=R}catch{try{if(H1.statSync(T).isDirectory())w=T}catch{}}}}else w=S6(A,z);if(!w&&!F)continue;let N=!1,I=(T,R)=>{Z.set(T,R),Z.set(T.toLowerCase(),R);let k=T.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();Z.set(k,R),J.add(R)};if(B&&F)I(B,F),N=!0;else if(V){let T=V.slice(1,-1).split(",").map((k)=>k.trim()).filter(Boolean).map((k)=>{let D=k.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(D)return{source:D[1],local:D[2]};return{source:k,local:k}}),R=w?b6(w):null;for(let{source:k,local:D}of T){let E=null;if(F)E=F;else if(R)E=R.get(k)??R.get(k.toLowerCase())??R.get(k.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(E)I(D,E),N=!0}}if(N)L.push({start:H.index,end:H.index+O.length})}if(L.length===0)return _;for(let O=L.length-1;O>=0;O--)q=q.slice(0,L[O].start)+q.slice(L[O].end);return`<script${K}>${q}</script>`}),G}async function v6(Y,Q,$,X,J){let Z=Y;if(!Q.__importedComponents)Q.__importedComponents=new Map;let z=Q.__importedComponents,G=/@import\s*\(\s*([^)]+)\s*\)/g,U;while((U=G.exec(Z))!==null){let[_,K]=U,j=K.split(",").map((W)=>W.trim().replace(/^['"]|['"]$/g,"")).filter((W)=>W.length>0);for(let W of j){let q=W.split("/"),L=q[q.length-1].replace(/\.stx$/,""),O=L.includes("-")?L.split("-").map((A)=>A.charAt(0).toUpperCase()+A.slice(1)).join(""):L.charAt(0).toUpperCase()+L.slice(1),V=null,B=[Q0.resolve(Q0.dirname($),`${W}.stx`),Q0.resolve(Q0.dirname($),W),Q0.resolve(X.componentsDir||"components",`${W}.stx`),Q0.resolve(X.componentsDir||"components",W),W.endsWith(".stx")?W:`${W}.stx`];for(let A of B)try{if(await Bun.file(A).exists()){V=A;break}}catch{}if(V){z.set(O,V),z.set(L,V),z.set(L.toLowerCase(),V);let A=O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(z.set(A,V),J.add(V),X.debug)console.log(`Imported component: ${O} -> ${V}`)}else if(X.debug)console.warn(`Could not resolve imported component: ${W}`)}Z=Z.replace(_,""),G.lastIndex=0}return Z}async function P6(Y,Q,$,X,J){let Z=Y,z=X.componentsDir||"components";if(!Q.__processedComponents)Q.__processedComponents=new Set;let G=Q.__processedComponents,U=/@component\s*\(/g,_;while((_=U.exec(Z))!==null){let K=_.index,j=K+_[0].length-1,W=1,q=j+1;while(q<Z.length&&W>0){if(Z[q]==="(")W++;else if(Z[q]===")"){if(W--,W===0)break}q++}if(W!==0)break;let H=Z.substring(j+1,q),L=q+1,O=H.match(/^\s*['"]([^'"]+)['"]/);if(!O){U.lastIndex=0;continue}let V=O[1],B,A=H.slice(O[0].length),w=A.match(/^\s*,\s*/);if(w)B=A.slice(w[0].length).trim();let F={};if(B)try{F=B0(B,Q)}catch(D){let E=D instanceof Error?D.message:String(D);Z=Z.replace(Z.substring(K,L),`[Error parsing component props: ${E}]`);continue}let N="",I=L,R=Z.substring(L).match(/^([\s\S]*?)@endcomponent/);if(R)N=R[1].trim(),I=L+R[0].length;let k=await O0(V,F,N,z,Q,$,X,G,J);Z=Z.substring(0,K)+k+Z.substring(I),U.lastIndex=0}return Z}async function f6(Y,Q,$,X,J){if(!Y)return Y;let Z=Y,z=X.componentsDir||"components";if(!Q.__processedComponents)Q.__processedComponents=new Set;let G=Q.__processedComponents,U=K1(Z);return Z=U.output,Z=await W(Z,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),Z=await W(Z,/[A-Z][a-zA-Z0-9]*/,!0),Z=await W(Z,/[a-z][a-z0-9]*/,!1,D6),Z=q1(Z,U.scripts),Z;async function W(q,H,L,O){if(!q)return q;let V=q,B=i1(V,H,O);for(let A=B.length-1;A>=0;A--){let w=B[A],F=L?c1(w.tagName):w.tagName,N=M6(w.attributes),I=E6(N,Q,X),T=$0.getBuiltin(w.tagName),R=T?await L4(F,z,Q,$,X):!1;if(T&&!R){let y={context:Q,filePath:$,options:X,dependencies:J},M=T.render(I,w.content,y);if(Object.keys(I.clientReactive).length>0)M=W4(M,I.clientReactive);if(Object.keys(I.events).length>0){let b=Object.entries(I.events).map(([P,u])=>`${P}="${j4(u)}"`).join(" ");M=M.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${b}`)}V=V.substring(0,w.startIndex)+M+V.substring(w.endIndex);continue}let k={};for(let[y,M]of Object.entries(I.static))k[y]=M;for(let[y,M]of Object.entries(I.serverDynamic))k[y]=M;let E=await O0(F,k,w.content,z,Q,$,X,G,J);if(Object.keys(I.clientReactive).length>0)E=W4(E,I.clientReactive);if(Object.keys(I.events).length>0){let y=E.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(y){let M=Object.entries(I.events).map(([P,u])=>`${P}="${j4(u)}"`).join(" "),b=y[1].length+y[2].length;E=E.substring(0,b)+" "+M+E.substring(b)}}V=V.substring(0,w.startIndex)+E+V.substring(w.endIndex)}return V}}function W4(Y,Q){let $=Y.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(!$)return Y;let X=Object.entries(Q).map(([Z,z])=>`:${Z}="${z.replace(/"/g,""")}"`).join(" "),J=$[1].length+$[2].length;return Y.substring(0,J)+" "+X+Y.substring(J)}async function s1(Y,Q,$,X,J){if(!H4)q4(),H4=!0;let Z=await C6(Y,Q,$,X,J);Z=await v6(Z,Q,$,X,J),Z=await P6(Z,Q,$,X,J);for(let z=0;z<3;z++){let G=Z;if(Z=await f6(Z,Q,$,X,J),Z===G)break}if(X.debug){let z=y6(Z);if(z.length>0)console.warn(`[stx] ${$}: unresolved component tag(s) after render passes: ${z.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return Z}import{deriveLayoutGroup as g6}from"stx-router/layout-metadata";var N0="<!--PARENT_CONTENT_PLACEHOLDER-->";function B4(Y){return Y.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function x6(Y,Q){let $=Y.length,X=Q,J=!0,Z=[],z=(G)=>G+9<=$&&Y[G]==="<"&&Y[G+1]==="/"&&(Y[G+2]==="s"||Y[G+2]==="S")&&(Y[G+3]==="c"||Y[G+3]==="C")&&(Y[G+4]==="r"||Y[G+4]==="R")&&(Y[G+5]==="i"||Y[G+5]==="I")&&(Y[G+6]==="p"||Y[G+6]==="P")&&(Y[G+7]==="t"||Y[G+7]==="T")&&(Y[G+8]===">"||/\s/.test(Y[G+8]));while(X<$){let G=Y[X];if(z(X))return X;if(G==="/"&&Y[X+1]==="/"){if(X=Y.indexOf(`
|
|
1399
|
+
`,X+2),X===-1)return-1;X+=1,J=!0;continue}if(G==="/"&&Y[X+1]==="*"){let U=Y.indexOf("*/",X+2);if(U===-1)return-1;X=U+2,J=!0;continue}if(G==="/"&&J){let U=X+1,_=!1;while(U<$){let K=Y[U];if(K==="\\"){U+=2;continue}if(K==="[")_=!0;else if(K==="]")_=!1;else if(K==="/"&&!_){U++;break}else if(K===`
|
|
1400
|
+
`){U=-1;break}U++}if(U===-1){X++,J=!1;continue}while(U<$&&/[a-z]/.test(Y[U]))U++;X=U,J=!1;continue}if(G==="'"||G==='"'){let U=G;X++;while(X<$){if(Y[X]==="\\"){X+=2;continue}if(Y[X]===U){X++;break}if(Y[X]===`
|
|
1401
|
+
`)break;X++}J=!1;continue}if(G==="`"){X++;while(X<$){if(Y[X]==="\\"){X+=2;continue}if(Y[X]==="`"){X++;break}if(Y[X]==="$"&&Y[X+1]==="{"){Z.push(!0),X+=2,J=!0;break}X++}if(Z.length===0)J=!1;continue}if(G==="}"&&Z.length>0){Z.pop(),X++;while(X<$){if(Y[X]==="\\"){X+=2;continue}if(Y[X]==="`"){X++,J=!1;break}if(Y[X]==="$"&&Y[X+1]==="{"){Z.push(!0),X+=2,J=!0;break}X++}continue}if(/\s/.test(G));else if(/[)\].\w$]/.test(G))J=!1;else J=!0;X++}return-1}async function e1(Y,Q,$,X,J){if(X.ssr===!1&&!X.autoShell&&X.buildMode==="spa")return Y;let Z=!Q.__stxProcessingDepth;if(!Q.__stxProcessingDepth)Q.__stxProcessingDepth=0;if(Q.__stxProcessingDepth++,!Q.__onceStore)Q.__onceStore=new Set;if((X.debug||!Y1()&&!Z1())&&$&&$.endsWith(".stx"))s4(Y,$);try{return await R4.timeAsync("template-processing",async()=>{let z=await h6(Y,Q,$,X,J);if(Z)z=a1(z);if(Z&&X.autoShell&&X.buildMode!=="compile"){let G=X.app?.head||{},_=(Q.__stx_runtime_head||null)??u4(),K=(Q.__stx_head_raw||"").trim(),j,W=K.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(W)j=W[1].trim(),K=K.replace(W[0],"").trim();let q=Q.__sections?.title,H=_.title||j||q,L={...G,...H&&{title:H},meta:[...G.meta||[],..._.meta||[]],link:[...G.link||[],..._.link||[]],script:[...G.script||[],..._.script||[]],headRaw:[G.headRaw,K].filter(Boolean).join(`
|
|
1402
|
+
`),..._.htmlAttrs&&{htmlAttrs:{...G.htmlAttrs||{},..._.htmlAttrs}},..._.bodyAttrs&&{bodyAttrs:{...G.bodyAttrs||{},..._.bodyAttrs}}},O=Y5(z);if(z=$5(z,L),O)z=Z5(z,G);let V=z.match(/<!-- stx-layout: ([^ ]+) -->/);if(V&&z.includes("<head")){let A=V[1],w=g6(A);z=z.replace("<head>",`<head>
|
|
1403
|
+
<meta name="stx-layout" content="${B4(A)}">
|
|
1404
|
+
<meta name="stx-layout-group" content="${B4(w)}">`)}let B=z.match(/function (__stx_setup_\d+_\d+)\(/);if(B&&z.includes("<body")&&!z.match(/<body[^>]*data-stx=/)){z=z.replace(/<body([^>]*)>/,`<body$1 data-stx="${B[1]}">`);let A=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${B[1]}"`,"i");z=z.replace(A,"$1")}}if(Z)z=t4(z);if(Z)try{let{getStoreScript:G}=await import("././store-loader.js"),U=X.storesDir,_=await G(U);if(_){let K=`<script data-stx-stores>${_}</script>`,j=z.indexOf("<script data-stx-scoped>");if(j!==-1){let W=z.indexOf("</script>",j+24);if(W!==-1){let q=W+9;z=z.slice(0,q)+`
|
|
1405
|
+
`+K+z.slice(q)}}}}catch{}if(Z&&Q.__stx_inject_css!==!1)z=await b4(z);return z=z.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),z})}catch(z){if(z instanceof I4)throw z;let G=z instanceof Error?z.message:String(z),U=new f0(`Template processing failed: ${G}`,$,void 0,void 0,Y.substring(0,200)+(Y.length>200?"...":""));if(w0.log(U,{filePath:$,context:Q}),N4.logDetailedError(U,{filePath:$,template:Y.substring(0,500)}),X.debug)throw U;return k4.createFallbackContent("Template Processing",U)}}async function h6(Y,Q,$,X,J){let Z=process.cwd(),z={...X,partialsDir:X.partialsDir&&!X0.isAbsolute(X.partialsDir)?X0.resolve(Z,X.partialsDir):X.partialsDir,componentsDir:X.componentsDir&&!X0.isAbsolute(X.componentsDir)?X0.resolve(Z,X.componentsDir):X.componentsDir,layoutsDir:X.layoutsDir&&!X0.isAbsolute(X.layoutsDir)?X0.resolve(Z,X.layoutsDir):X.layoutsDir},G=z,U=Y;await u6($,Q),m6(Q,G),U=await g0(()=>s3(U,Q,$,G),U,(B)=>{w0.log(B,{filePath:$,phase:"pre-processing-middleware"},"warning"),console.warn(`[stx] pre-processing middleware failed for ${$}: ${B.message}`)}),U=U.replace(/\{\{--[\s\S]*?--\}\}/g,"");let _=p0(U,F4,(B,A)=>`\x00STX_HTML_COMMENT_${A}\x00`);U=_.output;let K=_.tokens,j=(B)=>K.length===0?B:B.replace(/\x00STX_HTML_COMMENT_(\d+)\x00/g,(A,w)=>K[Number(w)]??""),W="\x00STX_ESCAPED_AT\x00";U=U.replace(/@@/g,W),U=U.replace(/@\{\{([\s\S]*?)\}\}/g,(B,A)=>{return`{{ ${A} }}`}),U=e4(U),U=await X5(U,$,J);let q={};U=k1(U,q);let H={...Q.__sections||{}},L="",O=/@nolayout\b/.test(U);if(O)U=U.replace(/@nolayout\b\s*/g,"");let V=U.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(V)L=V[1],U=U.replace(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/g,"");if(!L&&!O&&G.defaultLayout){let B=/<!DOCTYPE\s/i.test(U),A=/@section\s*\(/.test(U);if(!B||A){let w="",F=X0.dirname($),N=G.layoutsDir?X0.dirname(G.layoutsDir):process.cwd();for(let I=0;I<20;I++){let T=X0.join(F,"_layout.stx");if(await x(T)){w=T;break}let R=X0.dirname(F);if(R===F||R.length<N.length)break;F=R}if(w)L=w;else if(G.layoutsDir){let I=X0.isAbsolute(G.layoutsDir)?G.layoutsDir:X0.resolve(process.cwd(),G.layoutsDir),T=X0.join(I,`${G.defaultLayout}.stx`);if(await x(T))L=T}if(L&&!A)U=`@section('content')
|
|
1406
|
+
${U.trim()}
|
|
1407
|
+
@endsection`}}if(U=U.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(B,A,w)=>{return H[A]=w,""}),U=U.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(B,A,w)=>{if(/^(['"]).*\1$/.test(w.trim()))return B;try{let F=Y0(w.trim(),Q);if(F===void 0)return B;return H[A]=String(F??""),""}catch{return B}}),U=U.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(B,A,w)=>{if(w.includes("@parent"))H[A]=w.replace("@parent",N0);else H[A]=w.trim();return""}),Q.__sections=H,U=U.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(B,A,w)=>{return H[A]||w||""}),!("slot"in Q)||Q.slot===void 0)U=U.replace(/\{\{\s*slot\s*\}\}/g,()=>{return H.content||""});if(U=N1(U,q),L){let B=[];if(U=U.replace(/<(script|style)\b[\s\S]*?<\/\1>/gi,(A)=>{return B.push(A),""}),B.length>0){let A=B.join(`
|
|
1408
|
+
`);H.content=H.content?`${H.content}
|
|
1409
|
+
${A}`:A,Q.__sections=H}}if(L)try{let B;if(X0.isAbsolute(L))B=L,J.add(L);else B=await g0(()=>a0(L,$,z,J),null,()=>{throw new f0(`Failed to resolve layout path: ${L}`,$,void 0,void 0,`Layout referenced from ${$}`)});if(!B){let T=`Layout not found: ${L} (referenced from ${$})`;if(w0.log(Error(T),{layoutPath:L,filePath:$},"warning"),z.debug)throw new f0(T,$);return U}let A=await g0(()=>Bun.file(B).text(),"",()=>{throw new f0(`Failed to read layout file: ${B}`,$,void 0,void 0,"Layout content could not be loaded")}),w=A.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(w){if(z.debug)console.log(`Found nested layout: ${w[1]} in ${B}`);let T={},R=A.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(E,y,M)=>{return T[y]=M.trim(),""});for(let[E,y]of Object.entries(T))if(H[E]&&H[E].includes(N0)){let M=H[E].indexOf(N0);H[E]=H[E].slice(0,M)+y+H[E].slice(M+N0.length)}else if(!H[E])H[E]=y;let k={...Q,__sections:H},D=`@layout('${w[1]}')${R}`;return await e1(D,k,B,z,J)}let F=A.replace(/\{\{--[\s\S]*?--\}\}/g,""),N=k1(F,q),I={};return N=N.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(T,R,k)=>{return I[R]=k.trim(),`@slot('${R}')`}),N=N.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(T,R,k)=>{if(H[R]){let D=H[R];if(D.includes(N0)){let E=I[R]||"",y=D.indexOf(N0);D=D.slice(0,y)+E+D.slice(y+N0.length)}return D}return k||""}),N=d6(N,H),N=N.replace(/\{\{\s*slot\s*\}\}/g,()=>{return H.content||""}),N=N1(N,q),Q.__originalFilePath=$,U=await O4(N,Q,B,z,J),U=`<!-- stx-layout: ${L} -->
|
|
1410
|
+
${U}`,j(U)}catch(B){return w0.log(B instanceof Error?B:Error(String(B)),{layoutPath:L,filePath:$},"error"),`[Error processing layout: ${B instanceof Error?B.message:String(B)}]`}return j(await O4(U,Q,$,z,J))}function d6(Y,Q){return Y.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,($,X,J)=>{let Z=Q[X];if(Z!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${X.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(Z))return Z}return J||""})}function m6(Y,Q){if(Y.__stx_sfc_mode=!0,Y.__stx_options=Q,Q.buildMode)Y.__stx_buildMode=Q.buildMode;let $=Q.envPrefix||"STX_PUBLIC_",X={};for(let[J,Z]of Object.entries(process.env))if(J.startsWith($)&&Z!==void 0)X[J]=Z;Y.$env=X}async function u6(Y,Q){await g0(()=>a4(Y,Q),void 0,($)=>{w0.log($,{filePath:Y,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${Y}: ${$.message}`)})}async function l6(Y,Q,$){let X=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,J;while((J=X.exec(Y))!==null){let Z=J[1],z=J[2];if(!/\bserver\b/.test(Z)||!z.trim())continue;try{let{extractVariables:U}=await import("././variable-extractor.js");await U(z,Q,$,{preserveExisting:!0})}catch(U){let _=U instanceof Error?U:Error(String(U));w0.log(_,{filePath:$,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${$}: ${_.message}`)}}}async function c6(Y,Q,$){try{let{interpolateScriptsInTemplate:X}=await import("././expressions.js");return X(Y,Q,{skipServer:!0})}catch(X){let J=X instanceof Error?X:Error(String(X));return w0.log(J,{filePath:$,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${$}: ${J.message}`),Y}}async function O4(Y,Q,$,X,J){let Z=Y,z=X;if(await l6(Z,Q,$),Z=await c6(Z,Q,$),Z=await P3(Z,Q,$),Z=await f3(Z,Q,$),Z=await m4(Z,Q,$,z),v0(Z))Z=X4(Z,Q),Z=J4(Z,Q);Z=Q4(Z);let{processStreamDirectives:G}=await import("././streaming.js");Z=G(Z,Q),Z=l3(Z,Q,$,z),Z=await s1(Z,Q,$,z,J),Z=await r3(Z,Q,$,z,J),Z=w4(Z,Q,$,z);let{processDeferDirectives:U}=await import("././defer.js");Z=U(Z,Q,$);let{processTeleportDirectives:_}=await import("././teleport.js");Z=_(Z,Q,$);let{processTransitionDirectives:K,processTransitionAttributes:j}=await import("././transitions.js");Z=K(Z,Q,$),Z=j(Z);let{processErrorBoundaryDirectives:W}=await import("././error-boundaries.js");Z=W(Z,Q,$);let{processSuspenseDirectives:q}=await import("././suspense.js");Z=q(Z,Q,$);let{processAsyncDirectives:H}=await import("././async-components.js");Z=H(Z,Q,$);let{processKeepAliveDirectives:L}=await import("././keep-alive.js");Z=L(Z,Q,$);let{processVirtualListDirectives:O,processVirtualGridDirectives:V,processInfiniteListDirectives:B}=await import("././virtual-scrolling.js");Z=O(Z,Q,$),Z=V(Z,Q,$),Z=B(Z,Q,$);let{processPartialHydrationDirectives:A,processStaticDirectives:w}=await import("././partial-hydration.js");Z=A(Z,Q,$),Z=w(Z);let{processComputedDirectives:F,processWatchDirectives:N}=await import("././computed.js");Z=F(Z,Q,$),Z=N(Z,Q,$);let{processFormValidationDirectives:I}=await import("././forms-validation.js");Z=I(Z,Q,$);let{processHeadDirective:T,processTitleDirective:R,processMetaDirective:k,resetHead:D}=await import("././head.js");if(!Q.__stx_head_preset&&!Q.__stx_runtime_head)D();let E=T(Z);if(Z=E.content,E.headContent)Q.__stx_head_raw=`${Q.__stx_head_raw||""}${E.headContent}
|
|
1411
|
+
`;if(Z=R(Z,Q),Z=k(Z,Q),Z=r4(Z),Z=P4(Z,Q),Z=d4(Z),Z=n4(Z),Z=await I1(Z,Q,$,z,J),Z=await s1(Z,Q,$,z,J),Z=Z.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),Z=a1(Z),Z=T0(Z,Q,$),Z=f4(Z,Q),Z=g4(Z,Q),Z=l4(Z,Q),Z=c4(Z,Q),Z=i4(Z,Q),Z=await y3(Z,Q,$,z),Z=await q3(Z,Q,$),Z=await p4(Z,Q,$,z),Z=V4(Z,Q,$,z),Z=D4(Z,Q,$,z),Z=E4(Z,Q,$),Z=M4(Z,Q,$,z),Z=h4(Z,Q,$,z),Z=n1(Z,Q),Z=r1(Z),Z=Q5(Z),!z.skipEventDirectives)Z=v4(Z,Q,$);if(Z=K3(Z,Q,$),z.debug){let S=/\bx-data\s*=/.test(Z),v=S1(Y);if(S&&v)console.warn(`[stx] ${$}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
|
|
1412
|
+
Both work on the same page, but they manage separate scopes.
|
|
1413
|
+
Prefer signals (state/derived/effect) for new components.`)}Z=o4(Z,Q),Z=await W0(Z,Q,$),Z=J5(Z),Z=z5(Z),Z=C4(Z);let{processXElementDirectives:y}=await import("././x-element.js");Z=y(Z);let M=Q.__originalFilePath||$,b=j1(Q);if(Z=await z4(Z,z,M,b),Z=await n3(Z,Q,$,z),z.media?.image?.autoSiblings){let S=z.publicDir||"public",{rewriteImagesWithSiblings:v}=await import("./image-optimization/auto-sibling.js");Z=await v(Z,{publicDir:S})}if(z.seo?.enabled)Z=y4(Z,Q,z);let P=(S,v)=>{if(!v)return S;if(/<\/head>/i.test(S))return S.replace(/<\/head>/i,`${v}
|
|
1414
|
+
</head>`);if(/<head\b[^>]*>/i.test(S))return S.replace(/(<head\b[^>]*>)/i,`$1
|
|
1415
|
+
${v}`);if(/<html\b[^>]*>/i.test(S))return S.replace(/(<html\b[^>]*>)/i,`$1
|
|
1416
|
+
<head>
|
|
1417
|
+
${v}
|
|
1418
|
+
</head>`);return S},{renderHead:u,getHead:f}=await import("././head.js"),d=Q.__stx_runtime_head,r=d&&(d.title||d.meta?.length||d.link?.length)?d:f();if(r.title||r.meta?.length||r.link?.length){let S=u(r);if(S)Z=P(Z,S)}if(E.headContent)Z=P(Z,E.headContent);if(z.csp?.enabled&&z.csp.addMetaTag)Z=x4(Z,z.csp,Q);if(z.analytics?.enabled)Z=A4(Z,z);if(z.heatmap?.enabled)Z=T4(Z,z);if(z.pwa?.enabled&&z.pwa.autoInject!==!1){let{injectPwaTags:S}=await import("./pwa/inject.js");Z=S(Z,z)}let a=/<script\b(?![^>]*\bserver\b)[^>]*>[\s\S]*?<\/script>/i.test(Z),b0=/\bSTX\.\w+/.test(Z),F0=/window\.STX\s*=/.test(Z);if(a&&b0&&!F0){let v=`<script data-stx-scoped>
|
|
1419
|
+
${S4()}
|
|
1420
|
+
</script>`;if(Z.includes("</head>")){let c=Z.indexOf("</head>"),i=Z.slice(0,c).indexOf("<script");if(i!==-1){let n=Z.slice(0,i),G0=Z.slice(i);Z=n+v+`
|
|
1421
|
+
`+G0}else Z=Z.replace("</head>",`${v}
|
|
1422
|
+
</head>`)}else if(Z.includes("<body"))Z=Z.replace(/<body([^>]*)>/,`<body$1>
|
|
1423
|
+
${v}`);else Z=v+`
|
|
1424
|
+
`+Z}{let S=/<script\s+server\b[^>]*>/gi,v,c=[];while((v=S.exec(Z))!==null){let h=v.index+v[0].length,i=x6(Z,h);if(i===-1)continue;let n=i+9;while(n<Z.length&&/\s/.test(Z[n]))n++;c.push({start:v.index,end:n}),S.lastIndex=n}for(let h=c.length-1;h>=0;h--){let{start:i,end:n}=c[h];Z=Z.substring(0,i)+Z.substring(n)}}let R0=W1(Z,$);if(R0.hasScoped)Z=R0.html;let l=Q.__stx_event_bindings||[],J0=!1,j0=[],V0=/\s:[a-z][\w.-]*\s*=/.test(Z),{scanScriptTags:z0}=await import("././signal-processing.js");for(let S of z0(Z,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))j0.push({match:S.fullMatch,attrs:S.attrs,content:S.body});for(let{match:S,attrs:v,content:c}of j0){J0=!0;let h=c;o1(c,$,X.strict);let i=await _1(c,{eventBindings:l,attrs:v,hasColonDirectives:V0,templateContent:Y,filePath:$,projectRoot:process.cwd(),production:X.buildMode==="compile",serverData:b});Z=Z.replace(S,()=>i)}if(J0)Q.__stx_event_bindings=[];return Z}var x0=new t0(500),p6=0;function G5(Y){return Y.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function s6(Y){return/\bjs\b/.test(Y)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test(Y)}function I0(Y){return!s6(Y)}function k0(Y){try{let Q=Y.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");Q=Q.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");let $=[];Q=Q.replace(/\{!![\s\S]*?!!\}/g,(Z)=>{let z=$.length;return $.push(Z),`"__STX_EXPR_${z}__"`}),Q=Q.replace(/\{\{\{[\s\S]*?\}\}\}/g,(Z)=>{let z=$.length;return $.push(Z),`"__STX_EXPR_${z}__"`}),Q=Q.replace(/\{\{[\s\S]*?\}\}/g,(Z)=>{let z=$.length;return $.push(Z),`"__STX_EXPR_${z}__"`});let J=new Bun.Transpiler({loader:"ts",target:"browser",define:U5()}).transformSync(Q);for(let Z=0;Z<$.length;Z++)J=J.replace(`"__STX_EXPR_${Z}__"`,$[Z]),J=J.replace(`'__STX_EXPR_${Z}__'`,$[Z]);return J}catch(Q){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",Q);return Y}}function n6(Y){let Q=[],$=new Set,X=0,J=0,Z=Y.length,z=(K)=>{J++;while(J<Z){if(Y[J]==="\\"){J+=2;continue}if(Y[J]===K){J++;return}J++}},G=()=>{J++;while(J<Z){if(Y[J]==="\\"){J+=2;continue}if(Y[J]==="`"){J++;return}if(Y[J]==="$"&&Y[J+1]==="{"){J+=2;let K=1;while(J<Z&&K>0)if(Y[J]==="{")K++,J++;else if(Y[J]==="}")K--,J++;else if(Y[J]==="'"||Y[J]==='"')z(Y[J]);else if(Y[J]==="`")G();else J++;continue}J++}},U=()=>{if(Y[J]==="/"&&Y[J+1]==="/"){while(J<Z&&Y[J]!==`
|
|
1425
|
+
`)J++;return!0}if(Y[J]==="/"&&Y[J+1]==="*"){J+=2;while(J<Z-1&&!(Y[J]==="*"&&Y[J+1]==="/"))J++;return J+=2,!0}return!1},_=()=>{if(X!==0)return;let K=Y.slice(J).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(K){let H=K[2].split(",").map((L)=>{let O=L.trim().split(":");return O[O.length-1].trim()});for(let L of H)if(L&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(L)&&!$.has(L))Q.push(L),$.add(L);return}let j=Y.slice(J).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(j){let H=j[2];if(!$.has(H))Q.push(H),$.add(H);return}let W=Y.slice(J).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(W){let H=W[1];if(!$.has(H))Q.push(H),$.add(H);return}let q=Y.slice(J).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(q){let H=q[1];if(!$.has(H))Q.push(H),$.add(H)}};while(J<Z){if(U())continue;if(Y[J]==="'"||Y[J]==='"'){z(Y[J]);continue}if(Y[J]==="`"){G();continue}if(Y[J]==="{"){X++,J++;continue}if(Y[J]==="}"){X--,J++;continue}if(X===0&&/[a-z]/i.test(Y[J])&&(J===0||/\s|[;{}()]/.test(Y[J-1])))_();J++}return Q}function r6(Y){let Q=[],$=0,X=0,J=null;for(let Z=0;Z<Y.length;Z++){let z=Y[Z];if(J){if(z==="\\"){Z++;continue}if(z===J)J=null;continue}if(z==='"'||z==="'"||z==="`"){J=z;continue}if(z==="("||z==="["||z==="{")$++;else if(z===")"||z==="]"||z==="}")$--;else if(z===","&&$===0)Q.push(Y.slice(X,Z)),X=Z+1}if(X<Y.length)Q.push(Y.slice(X));return Q}function a6(Y){let Q=0,$=null;for(let X=0;X<Y.length;X++){let J=Y[X];if($){if(J==="\\"){X++;continue}if(J===$)$=null;continue}if(J==='"'||J==="'"||J==="`"){$=J;continue}if(J==="("||J==="["||J==="{")Q++;else if(J===")"||J==="]"||J==="}")Q--;else if(J==="="&&Q===0){let Z=Y[X-1],z=Y[X+1];if(Z==="!"||Z==="<"||Z===">"||Z==="=")continue;if(z==="="||z===">")continue;return X}}return-1}function o6(Y,Q){try{let $=/=\s*(?:withDefaults\s*\([\s\S]*?defineProps|defineProps)\b/.exec(Y);if(!$)return;let X=$.index-1;while(X>=0&&/\s/.test(Y[X]))X--;if(Y[X]!=="}")return;let J=X,Z=0,z=-1;for(;X>=0;X--){let U=Y[X];if(U==="}")Z++;else if(U==="{"){if(Z--,Z===0){z=X;break}}}if(z===-1)return;let G=Y.slice(z+1,J);for(let U of r6(G)){let _=U.trim();if(!_||_.startsWith("..."))continue;let K=a6(_);if(K===-1)continue;let j=_.slice(0,K).trim();if(!/^[A-Z_$][\w$]*$/i.test(j))continue;if(Q[j]!==void 0)continue;let W=_.slice(K+1).trim();if(!W)continue;try{let q=Object.keys(Q),H=Function(...q,`"use strict"; return (${W});`);Q[j]=H(...q.map((L)=>Q[L]))}catch{}}}catch{}}async function L4(Y,Q,$,X,J){let Z=Y.endsWith(".stx")?Y.slice(0,-4):Y,z=(O)=>O.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""),G=(O)=>O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),U=$.__importedComponents;if(U){for(let O of[Z,Z.toLowerCase(),z(Z),G(Z)])if(U.has(O))return!0}let _=[...new Set([`${Z}.stx`,`${z(Z)}.stx`,`${G(Z)}.stx`])],K=typeof J.root==="string"?C.resolve(J.root):void 0,j=K??C.dirname(X),W=[],q=(O)=>{if(O&&!W.includes(O))W.push(O)},H=$.__originalFilePath;if(H)q(C.join(C.dirname(H),"components"));q(Q),q(C.join(C.dirname(X),"components")),q(J.componentsDir);let L=J._pluginComponentDirs;if(Array.isArray(L))for(let O of L)q(typeof O==="string"?O:null);if(K)q(C.resolve(K,"resources/views/components")),q(C.resolve(K,"resources/components")),q(C.resolve(K,"src/components")),q(C.resolve(K,"components"));if(Z.startsWith("./")||Z.startsWith("../"))return x(C.resolve(C.dirname(X),`${Z}.stx`));for(let O of W){let V=C.isAbsolute(O)?O:C.resolve(j,O);for(let B of _)if(await x(C.join(V,B)))return!0}return!1}function e6(Y){return Y==="visible"||Y==="idle"||Y==="interaction"||Y.startsWith("media:")}async function O0(Y,Q,$,X,J,Z,z,G=new Set,U){let{extractVariables:_}=await import("././variable-extractor.js"),K=G??new Set;if(K.has(Y))return`[Circular component reference: ${Y}]`;let j=new Set(K);j.add(Y);let W=typeof Q.client==="string"?Q.client.trim():"";if("client"in Q)delete Q.client;let q=W&&W!=="load"&&e6(W)?W:"";try{let H=(S)=>S.split("-").map((v)=>v.charAt(0).toUpperCase()+v.slice(1)).join(""),L=(S)=>S.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),O=Y.endsWith(".stx")?Y.slice(0,-4):Y,V=null,B=J.__importedComponents;if(B){let S=[O,O.toLowerCase(),H(O),L(O)];for(let v of S)if(B.has(v)){V=B.get(v);break}}let A=[];if(!V){let S=[`${O}.stx`,`${H(O)}.stx`,`${L(O)}.stx`],v=[...new Set(S)],c=J.__originalFilePath,h=[];if(c){let o=C.join(C.dirname(c),"components");h.push(o)}if(X)h.push(X);let i=C.join(C.dirname(Z),"components");if(!h.includes(i))h.push(i);if(z.componentsDir&&z.componentsDir!==X&&!h.includes(z.componentsDir))h.push(z.componentsDir);let n=z._pluginComponentDirs;if(Array.isArray(n)){for(let o of n)if(typeof o==="string"&&!h.includes(o))h.push(o)}let G0=typeof z.root==="string"?C.resolve(z.root):void 0,d0=G0??C.dirname(Z),_0=[];if(G0)_0.push(C.resolve(G0,"resources/views/components")),_0.push(C.resolve(G0,"resources/components")),_0.push(C.resolve(G0,"src/components")),_0.push(C.resolve(G0,"components"));_0.push(C.resolve(import.meta.dir,"components"));for(let o of _0)if(!h.includes(o))h.push(o);let S0=[...new Set(h.map((o)=>{if(!o)return o;return C.isAbsolute(o)?o:C.resolve(d0,o)}))];if(h.length=0,h.push(...S0),O.startsWith("./")||O.startsWith("../"))V=C.resolve(C.dirname(Z),`${O}.stx`),A.push(V);else for(let o of h){if(!o)continue;for(let m0 of v){let u0=C.join(o,m0);if(A.push(u0),await x(u0)){V=u0;break}}if(V)break;if(!V)try{let m0=await import("fs");if(!m0.statSync(o,{throwIfNoEntry:!1})?.isDirectory())continue;let H5=8,L1=[{path:o,depth:0}];while(L1.length>0&&!V){let l0=L1.pop();if(l0.depth>=H5)continue;let Y3;try{Y3=m0.readdirSync(l0.path,{withFileTypes:!0})}catch{continue}for(let c0 of Y3){if(!c0.isDirectory())continue;if(c0.name==="node_modules"||c0.name.startsWith("."))continue;let Z3=C.join(l0.path,c0.name);for(let j5 of v){let B1=C.join(Z3,j5);if(A.push(B1),await x(B1)){V=B1;break}}if(V)break;L1.push({path:Z3,depth:l0.depth+1})}}}catch{}if(V)break}}if(!V||!await x(V)){let S=A.length>0?`
|
|
1426
|
+
Searched paths:
|
|
1427
|
+
${A.map((v)=>` - ${v}`).join(`
|
|
1428
|
+
`)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${Y}']${S}`}U.add(V);let w;if(x0.has(V))w=x0.get(V);else try{w=await Bun.file(V).text(),x0.set(V,w)}catch(S){return`[Error loading component: ${S instanceof Error?S.message:String(S)}]`}let F=new Set(["__originalFilePath","__importedComponents"]),N={};for(let[S,v]of Object.entries(J))if(!S.startsWith("__")||F.has(S))N[S]=v;let{extractSlotContent:I}=await import("././slots.js"),T=I($),R={};if(T.defaultSlot?.trim())R.default=T.defaultSlot;for(let[S,v]of T.namedSlots)R[S]=v.content;let k={...N,...Q,props:Q,slot:$,$slots:R,__processedComponents:j,__sections:{}};o6(w,k);let D=w,E=D.match(/<template\b(?![^>]*(?:\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=|\s#[\w-]|\bv-slot|\bslot\s*=))[^>]*>([\s\S]*?)<\/template>/i);if(E)D=E[1].trim();let y=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,M=[...w.matchAll(y)],b=[];for(let S of M){let v=S[1]||"",c=S[2]||"",h=v.includes("server");if(I0(v)&&c.trim())c=k0(c);if(h&&c)try{await _(c,k,V)}catch(n){}if(!h){let n=c.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,"");if(n.includes("{{")&&n.includes("}}"))n=W0(n,k,V);let G0=v.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");b.push(`<script${G0}>${n}</script>`)}}let P=w.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),u=P?P[1]:"",f=P?P[2]:"",d="",r=u&&/\bscoped\b/i.test(u);if(P)d=`<style${u}>${f}</style>`;let a=D;if(a=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),P)a=a.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let S=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,v=[];if(a=a.replace(S,(c,h)=>{let i=h.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(i)v.push(`<style${i[1]}>${i[2]}</style>`);return""}),a=a.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),v.length>0)d=`${d}${v.join(`
|
|
1429
|
+
`)}`}if($&&a.includes("{{ text || slot }}"))a=a.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>$);let{applySlots:b0}=await import("././slots.js"),{defaultSlot:F0,namedSlots:R0}=T;a=await b0(a,F0||$,R0,k);for(let[S,v]of Object.entries(k))if(typeof v==="string"){if(v.includes("<")&&v.includes(">")||v.includes("<")||v.includes(""")){let c=J3(v);k[S]=c}}let l=b.some((S)=>/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(S)),J0={...z,componentsDir:C.dirname(V),skipSignalsRuntime:!0,skipEventDirectives:l,defaultLayout:void 0};k.__stxProcessingDepth=(J.__stxProcessingDepth||0)+1;let j0=await e1(a,k,V,J0,U),V0=`stx_${O.replace(/[^a-zA-Z0-9]/g,"_")}_${++p6}_${Math.random().toString(36).slice(2,8)}`,z0=j0;if(l){let S="";if(Object.keys(Q).length>0)try{S=` data-stx-props="${G5(JSON.stringify(Q))}"`}catch{}let v=q?` stx-hydrate="${G5(q)}"`:"";if(z0=`<div data-stx-scope="${V0}"${S}${v}>${j0}</div>`,z0=b.map((h)=>{let i=h.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!i)return h;let[,n,G0]=i,d0=L0(G0),_0=`
|
|
1430
|
+
(function() {
|
|
1431
|
+
const { state, derived, effect, batch, defineEmits, defineExpose, defineSlots, defineProps, withDefaults, useStore, useFetch, useRef, useQuery, useMutation, useOptimistic, useDebounce, useDebouncedValue, useThrottle, useInterval, useTimeout, useToggle, useCounter, useClickOutside, useFocus, useAsync, useLocalStorage, useSessionStorage, useCookie, useReactiveProp, useEventListener, useWebSocket, useColorMode, useDark, useHead, useSeoMeta, definePageMeta, useRoute, useSearchParams, navigate, goBack, goForward, provide, inject, ref, reactive, computed, watch, watchEffect, nextTick } = window.stx;
|
|
1432
|
+
const __scope = window.stx._scopes = window.stx._scopes || {};
|
|
1433
|
+
const __scopeVars = __scope['${V0}'] = __scope['${V0}'] || {};
|
|
1434
|
+
|
|
1435
|
+
// Scope-specific lifecycle callbacks
|
|
1436
|
+
__scopeVars.__mountCallbacks = __scopeVars.__mountCallbacks || [];
|
|
1437
|
+
__scopeVars.__destroyCallbacks = __scopeVars.__destroyCallbacks || [];
|
|
1438
|
+
const onMount = (fn) => __scopeVars.__mountCallbacks.push(fn);
|
|
1439
|
+
const onDestroy = (fn) => __scopeVars.__destroyCallbacks.push(fn);
|
|
1440
|
+
|
|
1441
|
+
${d0}
|
|
1442
|
+
|
|
1443
|
+
// Register all defined signals and functions in this scope
|
|
1444
|
+
const __localVars = {};
|
|
1445
|
+
try {
|
|
1446
|
+
${n6(d0).map((S0)=>`if (typeof ${S0} !== 'undefined') __localVars['${S0}'] = ${S0};`).join(`
|
|
1447
|
+
`)}
|
|
1448
|
+
}
|
|
1449
|
+
catch (e) {}
|
|
1450
|
+
Object.assign(__scopeVars, __localVars);
|
|
1451
|
+
})();`;if(q)return`<script type="stx/island" data-stx-island="${V0}" data-stx-scoped${n}>${_0}</script>`;return`<script data-stx-scoped${n}>${_0}</script>`}).join(`
|
|
1452
|
+
`)+`
|
|
1453
|
+
`+z0,d)z0+=`
|
|
1454
|
+
`+d}else{if(d)z0+=`
|
|
1455
|
+
`+d;if(b.length>0){let S=k.__stx_event_bindings||[],v=j1(k),c=await Promise.all(b.map(async(h)=>{let i=h.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!i)return h;return await _1(i[1],{eventBindings:S,templateContent:z0,filePath:V,projectRoot:process.cwd(),serverData:v})}));z0+=`
|
|
1456
|
+
`+c.join(`
|
|
1457
|
+
`),k.__stx_event_bindings=[]}}if(r){let S=W1(z0,V);if(S.hasScoped)z0=S.html}return z0}catch(H){return`[Error processing component: ${H instanceof Error?H.message:String(H)}]`}finally{K.delete(Y)}}async function x(Y){return Bun.file(Y).exists()}function t1(Y,Q){let $=C.resolve(Q),X=C.resolve(Y),J=$.endsWith(C.sep)?$:$+C.sep;if(X===$||X.startsWith(J))return X;return null}async function a0(Y,Q,$,X){let J=await t6(Y,Q,$,X);if(J===null)return null;let Z=t1(J,process.cwd());if(Z)return Z;let z=[$.root,$.layoutsDir,$.componentsDir,$.partialsDir,$.pagesDir].filter((G)=>typeof G==="string"&&G.length>0);for(let G of z){let U=C.isAbsolute(G)?G:C.resolve(process.cwd(),G);if(t1(J,U))return C.resolve(J)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${J} (template: ${Y}, from: ${Q})`),null}async function t6(Y,Q,$,X){if($.debug)console.log(`Resolving template path: ${Y} from ${Q}`);let J=C.dirname(Q),Z=process.cwd();if(Y.startsWith("/")){let W=C.join(Z,Y),q=t1(W,Z);if(!q)return console.warn(`[stx] rejected template path that escapes project root: ${Y} (from ${Q})`),null;if($.debug)console.log(`Checking absolute path: ${q}`);if(await x(q)&&X)X.add(q);return q}let z=C.join(J,Y);if(await x(z)){if($.debug)console.log(`Found direct path: ${z}`);if(X)X.add(z);return z}if(!Y.endsWith(".stx")&&!Y.endsWith(".jsx")&&!Y.endsWith(".tsx"))for(let W of[".stx",".tsx",".jsx"]){let q=`${z}${W}`;if(await x(q)){if($.debug)console.log(`Found direct path with extension: ${q}`);if(X)X.add(q);return q}}let G="",U=C.resolve(J),_=process.cwd();for(let W=0;W<10;W++){let q=C.join(U,"layouts"),H=!1;try{H=i6.statSync(q,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(H){G=q;break}let L=C.dirname(U);if(L===U||L.length<_.length)break;U=L}if(G){let W=Y.startsWith("layouts/")?Y.slice(8):Y,q=C.join(G,W);if(await x(q)){if($.debug)console.log(`Found in current layouts dir: ${q}`);if(X)X.add(q);return q}if(!W.endsWith(".stx")){let H=`${q}.stx`;if(await x(H)){if($.debug)console.log(`Found in current layouts dir with extension: ${H}`);if(X)X.add(H);return H}}}if($.layoutsDir){let W=C.isAbsolute($.layoutsDir)?$.layoutsDir:C.resolve(process.cwd(),$.layoutsDir),q=Y.startsWith("layouts/")?Y.slice(8):Y,H=C.join(W,q);if(await x(H)){if($.debug)console.log(`Found in options.layoutsDir: ${H}`);if(X)X.add(H);return H}if(!Y.endsWith(".stx")){let L=`${H}.stx`;if(await x(L)){if($.debug)console.log(`Found in options.layoutsDir with extension: ${L}`);if(X)X.add(L);return L}}}if(Y.startsWith("layouts/")||Y.includes("/layouts/")){let W=Y.split("layouts/"),q=C.join($.partialsDir||J,"layouts",W[1]);if(await x(q)){if($.debug)console.log(`Found in layouts path: ${q}`);if(X)X.add(q);return q}if(!q.endsWith(".stx")){let H=`${q}.stx`;if(await x(H)){if($.debug)console.log(`Found in layouts path with extension: ${H}`);if(X)X.add(H);return H}}}if($.partialsDir){if(G=C.join($.partialsDir,"layouts"),await x(G)){let W=C.join(G,Y);if(await x(W)){if($.debug)console.log(`Found in partials layouts dir: ${W}`);if(X)X.add(W);return W}if(!Y.endsWith(".stx")){let q=`${W}.stx`;if(await x(q)){if($.debug)console.log(`Found in partials layouts dir with extension: ${q}`);if(X)X.add(q);return q}}}}let K=$.partialsDir||C.join(process.cwd(),"views"),j=C.join(K,Y);if(await x(j)){if($.debug)console.log(`Found in views path: ${j}`);if(X)X.add(j);return j}if(!Y.endsWith(".stx")){let W=`${j}.stx`;if(await x(W)){if($.debug)console.log(`Found in views path with extension: ${W}`);if(X)X.add(W);return W}}if(J.includes("temp")){let W=C.join(C.dirname(J),"layouts",Y);if(await x(W)){if($.debug)console.log(`Found in temp layouts dir: ${W}`);if(X)X.add(W);return W}if(!Y.endsWith(".stx")){let q=`${W}.stx`;if(await x(q)){if($.debug)console.log(`Found in temp layouts dir with extension: ${q}`);if(X)X.add(q);return q}}}if($.debug)console.warn(`Template not found after trying all paths: ${Y} (referenced from ${Q})`);else console.warn(`Template not found: ${Y} (referenced from ${Q})`);return null}function K5(Y,Q,$){let X=0,J="",Z="";try{if(typeof Q==="number"&&Q>=0){let z=Y.split(`
|
|
1458
|
+
`),G=0;for(let U=0;U<z.length;U++)if(G+=z[U].length+1,G>=Q){X=U+1,J=z[U].trim();let _=Math.max(0,U-2),K=Math.min(z.length,U+3);Z=z.slice(_,K).map((j,W)=>{let q=_+W+1;return`${q===X?"> ":" "}${q}: ${j}`}).join(`
|
|
1459
|
+
`);break}}else if($){let z=Y.indexOf($);if(z>=0)return K5(Y,z)}}catch{}return{lineNumber:X,lineContent:J,context:Z}}var m={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m",bgRed:"\x1B[41m",bgYellow:"\x1B[43m"};function p(Y,Q,$,X,J,Z){let{lineNumber:z,context:G}=K5(X,J,Z),U=$.split("/").pop(),_=0;if(typeof J==="number"&&J>=0&&X){let j=X.lastIndexOf(`
|
|
1460
|
+
`,Math.max(0,J-1));_=J-(j+1)+1}let K="";if(z>0)K+=`
|
|
1461
|
+
${$}:${z}${_>0?`:${_}`:""}: ${Y.toLowerCase()} error: ${Q}
|
|
1462
|
+
`;if(K+=`
|
|
1463
|
+
${m.bold}${m.red}\u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E${m.reset}
|
|
1464
|
+
`,K+=`${m.bold}${m.red}\u2502${m.reset} ${m.bold}${m.bgRed} ERROR ${m.reset} ${m.red}${Y} Error${m.reset}${" ".repeat(Math.max(0,43-Y.length))}${m.bold}${m.red}\u2502${m.reset}
|
|
1465
|
+
`,K+=`${m.bold}${m.red}\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F${m.reset}
|
|
1466
|
+
`,K+=`
|
|
1467
|
+
${m.cyan}${m.bold}File:${m.reset} ${m.dim}${U}${m.reset}`,z>0)K+=` ${m.gray}(line ${z}${_>0?`, col ${_}`:""})${m.reset}`;if(K+=`
|
|
1468
|
+
${m.yellow}${m.bold}Message:${m.reset} ${Q}
|
|
1469
|
+
`,G)K+=`
|
|
1470
|
+
${m.blue}${m.bold}Context:${m.reset}
|
|
1471
|
+
${m.dim}${G}${m.reset}
|
|
1472
|
+
`;return K}function QZ(){x0.clear()}function JZ(){return{size:x0.size,maxSize:500}}var Y7=/^[ \t]*import\s+['"]([^'"]+?\.css)(\?[^'"]*)?['"]\s*;?\s*$/gm;function Z7(Y){if(Y.startsWith(".")||Y.startsWith("/"))return null;if(Y.startsWith("@")){let $=Y.match(/^(@[^/]+\/[^/]+)(\/.*)?$/);if(!$)return null;return{pkg:$[1],subpath:$[2]||""}}let Q=Y.match(/^([^/]+)(\/.*)?$/);if(!Q)return null;return{pkg:Q[1],subpath:Q[2]||""}}function $7(Y,Q){let $=Q;while(!0){let X=D0.join($,"node_modules",Y,"package.json");if(h0.existsSync(X))return D0.dirname(X);let J=D0.dirname($);if(J===$)return null;$=J}}function X7(Y,Q){if(!Y||typeof Y!=="object")return null;let $=(J)=>{if(typeof J==="string")return J;if(J&&typeof J==="object"){if(typeof J.import==="string")return J.import;if(typeof J.default==="string")return J.default;if(typeof J.import==="object")return $(J.import);if(typeof J.default==="object")return $(J.default)}return null};if(Object.prototype.hasOwnProperty.call(Y,Q))return $(Y[Q]);let X=null;for(let J of Object.keys(Y)){let Z=J.indexOf("*");if(Z===-1)continue;let z=J.slice(0,Z),G=J.slice(Z+1);if(!Q.startsWith(z)||!Q.endsWith(G))continue;if(Q.length<z.length+G.length)continue;if(!X||z.length>X.prefix.length)X={pattern:J,prefix:z,suffix:G}}if(X){let J=Q.slice(X.prefix.length,Q.length-X.suffix.length),Z=$(Y[X.pattern]);if(Z)return Z.replace("*",J)}return null}function Q7(Y,Q){let $=Z7(Y);if(!$||!$.subpath)return null;let X=$7($.pkg,Q);if(!X)return null;let J;try{J=JSON.parse(h0.readFileSync(D0.join(X,"package.json"),"utf8"))}catch{return null}let Z=`.${$.subpath}`,z=X7(J.exports,Z);if(!z)return null;let G=D0.resolve(X,z);return h0.existsSync(G)?G:null}function J7(Y,Q){let $=Q.filePath?D0.dirname(Q.filePath):Q.projectRoot||process.cwd(),X=Q.projectRoot||process.cwd(),J=new Set,Z=[];return{code:Y.replace(Y7,(G,U)=>{let _;try{if(U.startsWith("./")||U.startsWith("../")||U.startsWith("/")){if(_=U.startsWith("/")?U:D0.resolve($,U),!h0.existsSync(_))throw Error(`file not found: ${_}`)}else{let K=null;try{K=Bun.resolveSync(U,X)}catch{K=Q7(U,X)}if(!K)throw Error(`could not resolve ${U} (Bun.resolveSync + exports fallback both failed)`);_=K}}catch(K){return console.warn(`[stx:vendor-css] could not resolve ${JSON.stringify(U)} (from ${Q.filePath||"<unknown>"}): ${K?.message||K}`),""}if(J.has(_))return"";J.add(_);try{let K=h0.readFileSync(_,"utf8");Z.push({source:U,resolvedPath:_,contents:K})}catch(K){console.warn(`[stx:vendor-css] could not read ${_}: ${K?.message||K}`)}return""}),styles:Z}}function z7(Y){return Y.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function G7(Y){if(Y.length===0)return"";return`${Y.map((Q)=>{return`<style data-stx-vendor="${z7(Q.source)}" data-stx-layer="vendor">
|
|
1473
|
+
@layer vendor {
|
|
1474
|
+
${Q.contents}
|
|
1475
|
+
}
|
|
1476
|
+
</style>`}).join(`
|
|
1477
|
+
`)}
|
|
1478
|
+
`}var U7=["state","derived","effect","batch","untrack","peek","isSignal","isDerived","onMount","onDestroy","useRef","navigate","goBack","goForward","useRoute","setRouteParams","useSearchParams","useFetch","useQuery","useMutation","useOptimistic","useReactiveProp","useLocalStorage","useSessionStorage","useCookie","useWebSocket","useHead","useSeoMeta","definePageMeta","useEventListener","useMeta","useDebounce","useDebouncedValue","useThrottle","useInterval","useTimeout","useToggle","useCounter","useClickOutside","useFocus","useAsync","useColorMode","useDark","ref","reactive","computed","watch","watchEffect","watchMultiple","onBeforeMount","onMounted","onBeforeUpdate","onUpdated","onBeforeUnmount","onUnmounted","defineProps","withDefaults","defineEmits","defineExpose","defineSlots","provide","inject","nextTick","getCurrentInstance","onErrorCaptured","useSlots","useAttrs","createStore","defineStore","useStore","action","createSelector","h","Fragment"],K7=["browserQuery","BrowserQueryBuilder","BrowserQueryError","browserAuth","configureBrowser","getBrowserConfig","createBrowserDb","createBrowserModel","isBrowser"],q7=new Set(["Promise","Object","Array","Map","Set","Date","Error","JSON","Math","Number","String","RegExp","Symbol","WeakMap","WeakSet","Proxy","Reflect","Intl","URL","URLSearchParams","FormData","Headers","Request","Response","AbortController","EventTarget","Element","Document","Node","Window","Console","Storage","Navigator","Blob","File","FileReader","HTMLElement","SVGElement","Event","CustomEvent","DOMParser","XMLSerializer","WebSocket","Worker","SharedWorker","IntersectionObserver","MutationObserver","ResizeObserver","PerformanceObserver","Notification","Bun","Buffer","Process","Modal","Intl"]);function H7(Y){let Q=new Set,$=/\b([A-Z][a-zA-Z0-9]*)\s*\.\s*(all|find|first|get|where|orderBy|orderByDesc|limit|select|pluck|create|update|delete)\s*\(/g,X;while((X=$.exec(Y))!==null)if(!q7.has(X[1]))Q.add(X[1]);return Array.from(Q)}function j7(Y){let Q=new Set,$=new Set,X=Y;X=X.replace(/^\s*import\s+type\s+\{[^}]*\}\s+from\s+['"][^'"]+['"]\s*;?\s*$/gm,"// [type import stripped]");let J=new Set,Z=/^\s*import\s+(?:type\s+)?{\s*([^}]+)\s*}\s+from\s+['"](@stacksjs\/browser|stx)['"]\s*;?\s*$/gm,z;while((z=Z.exec(Y))!==null){let U=z[1],_=z[2];if(z[0].includes("import type"))continue;U.split(",").map((j)=>j.trim().split(/\s+as\s+/)[0]).filter((j)=>j.length>0).forEach((j)=>{if(J.add(j),_==="stx")Q.add(j);else $.add(j)}),X=X.replace(z[0],"// [auto-import processed]")}for(let U of U7){if(J.has(U))continue;if(new RegExp(`\\b${U}\\s*\\(`,"g").test(X))Q.add(U)}for(let U of K7){if(J.has(U))continue;if(new RegExp(`\\b${U}\\b`,"g").test(X))$.add(U)}let G=H7(X);for(let U of G)if(!J.has(U))$.add(U);return{code:X,stxImports:Array.from(Q),browserImports:Array.from($)}}function _7(Y,Q){let $=[];if(Y.length>0)$.push(` var { ${Y.join(", ")} } = window.stx || window;`);if(Q.length>0)$.push(` var { ${Q.join(", ")} } = window.StacksBrowser || {};`);if($.length>0)return` // STX: auto-imported from stx and @stacksjs/browser
|
|
1479
|
+
${$.join(`
|
|
1480
|
+
`)}
|
|
1481
|
+
`;return""}function j1(Y){let Q={};for(let $ in Y){if($.startsWith("__")||$.startsWith("$"))continue;let X=Y[$];if(typeof X==="function")continue;Q[$]=X}return Q}function b1(Y,Q){if(!Q)return"";let $=[];for(let[X,J]of Object.entries(Q)){if(!/^[A-Za-z_$][\w$]*$/.test(X))continue;if(!new RegExp(`\\b${X}\\b`).test(Y))continue;if(new RegExp(`(?:const|let|var|function|class)\\s+${X}\\b`).test(Y))continue;let Z;try{Z=JSON.stringify(J)}catch{continue}if(Z===void 0)continue;$.push(` var ${X} = ${Z.replace(/</g,"\\u003c")};`)}if($.length===0)return"";return` // stx: server -> client data bridge (seeded from server scope)
|
|
1482
|
+
${$.join(`
|
|
1483
|
+
`)}
|
|
1484
|
+
`}var W7={left:0,middle:1,right:2};function L7(Y){let Q=[];if(Y.self)Q.push("if ($event.target !== $el) return");for(let $ of Y.systemKeys)Q.push(`if (!$event.${$}Key) return`);if(Y.keys.length>0){let $=Y.keys.map((X)=>`$event.key === '${X}'`).join(" || ");Q.push(`if (!(${$})) return`)}if(Y.mouse!==null){let $=W7[Y.mouse];Q.push(`if ($event.button !== ${$}) return`)}if(Y.prevent)Q.push("$event.preventDefault()");if(Y.stop)Q.push("$event.stopPropagation()");return Q.join("; ")}function B7(Y,Q){let{elementId:$,event:X,handler:J,modifiers:Z}=Y,z=L7(Z),G=[];if(Z.once)G.push("once: true");if(Z.capture)G.push("capture: true");if(Z.passive)G.push("passive: true");let U=G.length>0?`, { ${G.join(", ")} }`:"",_="";if(z)_+=`${z}; `;let K=J.replace(/\\/g,"\\\\").replace(/'/g,"\\'");function j(W){return`var scope = $el.closest('[data-stx-scope]');
|
|
1485
|
+
if (scope && scope.__stx_execute) {
|
|
1486
|
+
scope.__stx_execute('${K}', $event, $el);
|
|
1487
|
+
}
|
|
1488
|
+
else {
|
|
1489
|
+
${W}
|
|
1490
|
+
}`}if(Z.debounce!==null)return` ;(function() {
|
|
1491
|
+
// eslint-disable-next-line pickier/no-unused-vars
|
|
1492
|
+
var $el = document.getElementById('${$}')
|
|
1493
|
+
if (!$el) return
|
|
1494
|
+
var __timer
|
|
1495
|
+
$el.addEventListener('${X}', function($event) {
|
|
1496
|
+
${z?z+"; ":""}clearTimeout(__timer)
|
|
1497
|
+
__timer = setTimeout(function() { ${j(J)} }, ${Z.debounce})
|
|
1498
|
+
}${U})
|
|
1499
|
+
})()`;if(Z.throttle!==null)return` ;(function() {
|
|
1500
|
+
// eslint-disable-next-line pickier/no-unused-vars
|
|
1501
|
+
var $el = document.getElementById('${$}')
|
|
1502
|
+
if (!$el) return
|
|
1503
|
+
var __last = 0
|
|
1504
|
+
$el.addEventListener('${X}', function($event) {
|
|
1505
|
+
${z?z+"; ":""}var __now = Date.now()
|
|
1506
|
+
if (__now - __last >= ${Z.throttle}) {
|
|
1507
|
+
__last = __now
|
|
1508
|
+
${j(J)}
|
|
1509
|
+
}
|
|
1510
|
+
}${U})
|
|
1511
|
+
})()`;return` var $el = document.getElementById('${$}')
|
|
1512
|
+
if ($el) $el.addEventListener('${X}', function($event) {
|
|
1513
|
+
${_}var scope = $el.closest('[data-stx-scope]');
|
|
1514
|
+
if (scope && scope.__stx_execute) {
|
|
1515
|
+
scope.__stx_execute('${K}', $event, $el);
|
|
1516
|
+
}
|
|
1517
|
+
else {
|
|
1518
|
+
${J}
|
|
1519
|
+
}
|
|
1520
|
+
}${U})`}function O7(Y){if(Y.length===0)return"";return`
|
|
1521
|
+
// STX: auto-generated event bindings
|
|
1522
|
+
${Y.map(($,X)=>B7($,X)).join(`
|
|
1523
|
+
`)}`}function q5(Y){let Q=[],$=new Set,X=Y.replace(/^\s*import\s+.*$/gm,""),J=0,Z=X.length,z=0;while(z<Z){let G=X[z];if(G==="'"||G==='"'||G==="`"){let U=G;if(z++,U==="`"){let _=0;while(z<Z){if(X[z]==="\\"){z+=2;continue}if(X[z]==="`"&&_===0){z++;break}if(X[z]==="$"&&X[z+1]==="{"){_++,z+=2;continue}if(X[z]==="}"&&_>0){_--,z++;continue}z++}}else while(z<Z){if(X[z]==="\\"){z+=2;continue}if(X[z]===U){z++;break}z++}continue}if(G==="/"&&X[z+1]==="/"){while(z<Z&&X[z]!==`
|
|
1524
|
+
`)z++;continue}if(G==="/"&&X[z+1]==="*"){z+=2;while(z<Z-1&&!(X[z]==="*"&&X[z+1]==="/"))z++;z+=2;continue}if(G==="{"){J++,z++;continue}if(G==="}"){J--,z++;continue}if(J===0){let U=X.slice(z),_=U.match(/^(?:const|let|var)\s+([a-zA-Z_$]\w*)\s*(?::[^=]*)?=/);if(_){let W=_[1];if(!W.startsWith("_")&&!$.has(W))Q.push(W),$.add(W);z+=_[0].length;continue}let K=U.match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(K){K[1].split(",").forEach((W)=>{let q=W.trim(),H=q.indexOf(":"),L=H>=0?q.slice(H+1).trim().split(/[\s=]/)[0]:q.split(/[\s=]/)[0];if(L&&!L.startsWith("_")&&!$.has(L))Q.push(L),$.add(L)}),z+=K[0].length;continue}let j=U.match(/^(?:async\s+)?function\s+([a-zA-Z_$]\w*)/);if(j){let W=j[1];if(!W.startsWith("_")&&!$.has(W))Q.push(W),$.add(W);z+=j[0].length;continue}}z++}return Q}var V7=new Set(["if","else","true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","switch","case","break","continue","for","while","do","try","catch","finally","const","let","var","function","class","import","export","default","async","await","yield","with","debugger","console","window","document","Math","JSON","Date","Array","Object","String","Number","Boolean","Symbol","Map","Set","Promise","Error","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","setTimeout","setInterval","clearTimeout","clearInterval","fetch","alert","confirm","prompt","event"]);function A7(Y){let Q=new Set,$=/[a-zA-Z_$][a-zA-Z0-9_$]*/g;function X(W){let q;while((q=$.exec(W))!==null){let H=q[0];if(!V7.has(H))Q.add(H)}}let J=/\{\{([\s\S]*?)\}\}/g,Z;while((Z=J.exec(Y))!==null)X(Z[1]);let z=/:[a-z][\w.-]*\s*=\s*"([^"]*)"/gi;while((Z=z.exec(Y))!==null)X(Z[1]);let G=/:[a-z][\w.-]*\s*=\s*'([^']*)'/gi;while((Z=G.exec(Y))!==null)X(Z[1]);let U=/@[a-z]+(?:\.[a-z]+)*\s*=\s*"([^"]*)"/gi;while((Z=U.exec(Y))!==null)X(Z[1]);let _=/@[a-z]+(?:\.[a-z]+)*\s*=\s*'([^']*)'/gi;while((Z=_.exec(Y))!==null)X(Z[1]);let K=/@model\s*=\s*["']([^"']*)["']/gi;while((Z=K.exec(Y))!==null)X(Z[1]);let j=/@for\s*=\s*["'][^"']*\bin\s+([^"']+)["']/gi;while((Z=j.exec(Y))!==null)X(Z[1]);return Q}async function _1(Y,Q={}){let $=Y,X="",J=!1,Z=J7($,{filePath:Q.filePath,projectRoot:Q.projectRoot});$=Z.code;let z=G7(Z.styles),{hasUserImports:G,bundleClientScript:U}=await import("././client-script-bundler.js");if(G($))console.log("[stx:bundler] user imports detected, bundling..."),$=await U($,Q.filePath||"",{projectRoot:Q.projectRoot,minify:Q.production}),J=!0;if(Q.autoImports!==!1){let O=j7($);$=O.code,X=_7(O.stxImports,O.browserImports)}if(X=`${b1($,Q.serverData)}${X}`,$=L0($),!J&&I0(Q.attrs||""))$=k0($);let _=O7(Q.eventBindings||[]),K=(Q.attrs||"").trim();if(/\btype\s*=\s*["']module["']/i.test(K)){let O=K.replace(/\btype\s*=\s*["']module["']/i,"").trim(),V=`type="module" data-stx-scoped${O?` ${O}`:""}`;return`${z}<script ${V}>
|
|
1525
|
+
${X}${$}
|
|
1526
|
+
${_}
|
|
1527
|
+
</script>`}let W=/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect|useLocalStorage|useSessionStorage|useRef|useEventListener|useFetch|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|batch|untrack|peek)\s*(?:<[^>]*>)?\s*\(/.test(Y),q=/function __stx_setup_/.test($),H=/\bstx\.mount\s*\(|\bstx\.mountEl\s*\(/.test(Y);function L(O){let V=O.length>0?`
|
|
1528
|
+
return { ${O.join(", ")} };`:"";return`${z}<script data-stx-scoped>
|
|
1529
|
+
window.stx.mount(function() {
|
|
1530
|
+
'use strict';
|
|
1531
|
+
${X}${$}
|
|
1532
|
+
${_}${V}
|
|
1533
|
+
})</script>`}if(!H&&!q){if(W)return L(q5(Y));if(Q.templateContent){let O=q5(Y);if(O.length>0){let V=A7(Q.templateContent);if(O.some((A)=>V.has(A)))return L(O)}}}return`${z}<script data-stx-scoped>
|
|
1534
|
+
;(function() {
|
|
1535
|
+
'use strict';
|
|
1536
|
+
${X}${$}
|
|
1537
|
+
${_}
|
|
1538
|
+
})()</script>`}
|
|
1539
|
+
export{J7 as du,G7 as eu,j1 as fu,b1 as gu,_1 as hu,s0 as iu,W5 as ju,I7 as ku,L5 as lu,k7 as mu,n0 as nu,v0 as ou,B5 as pu,N7 as qu,W0 as ru,O5 as su,K0 as tu,J3 as uu,q3 as vu,H3 as wu,g7 as xu,A1 as yu,v5 as zu,x5 as Au,x7 as Bu,h7 as Cu,d7 as Du,m7 as Eu,u7 as Fu,l7 as Gu,h5 as Hu,d5 as Iu,j3 as Ju,D3 as Ku,l5 as Lu,E3 as Mu,Q9 as Nu,J9 as Ou,K3 as Pu,M5 as Qu,R1 as Ru,p5 as Su,y3 as Tu,G4 as Uu,U4 as Vu,K4 as Wu,$0 as Xu,q4 as Yu,c1 as Zu,i1 as _u,p1 as $u,N6 as av,DY as bv,EY as cv,MY as dv,yY as ev,bY as fv,C6 as gv,s1 as hv,l3 as iv,T9 as jv,C3 as kv,I9 as lv,I1 as mv,k1 as nv,N1 as ov,P3 as pv,f3 as qv,p3 as rv,s3 as sv,n3 as tv,r3 as uv,_6 as vv,W6 as wv,S1 as xv,X4 as yv,Q4 as zv,J4 as Av,I6 as Bv,k6 as Cv,z4 as Dv,e1 as Ev,s6 as Fv,I0 as Gv,k0 as Hv,L4 as Iv,e6 as Jv,O0 as Kv,x as Lv,a0 as Mv,K5 as Nv,p as Ov,QZ as Pv,JZ as Qv};
|