@stacksjs/stx 0.2.358 → 0.2.360
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-wkyt4j9e.js → chunk-0dkaztpp.js} +1 -1
- package/dist/{chunk-jmdxn2mq.js → chunk-0p52xkk9.js} +1 -1
- package/dist/{chunk-3y8vvkar.js → chunk-0ppgyq8q.js} +1 -1
- package/dist/{chunk-0dj2gne3.js → chunk-0vrn78j5.js} +1 -1
- package/dist/chunk-0vvqxeq3.js +2 -0
- package/dist/{chunk-2gtwha4k.js → chunk-0w12p79j.js} +1 -1
- package/dist/chunk-11hfa3kp.js +2 -0
- package/dist/{chunk-19m7hed6.js → chunk-135mme4g.js} +1 -1
- package/dist/{chunk-ms25gb16.js → chunk-175da6nh.js} +1 -1
- package/dist/{chunk-hy79zwyy.js → chunk-198fr2d4.js} +1 -1
- package/dist/{chunk-e48050x3.js → chunk-1c2k7713.js} +1 -1
- package/dist/{chunk-2s3wvns6.js → chunk-1e0jj83h.js} +1 -1
- package/dist/{chunk-f72c62s7.js → chunk-1hvxs7rh.js} +1 -1
- package/dist/chunk-1tfhw9c0.js +2 -0
- package/dist/{chunk-q4kgqqed.js → chunk-1tz8fb87.js} +2 -2
- package/dist/{chunk-3ssjb8cx.js → chunk-2119txb8.js} +201 -201
- package/dist/{chunk-mdbj7sq8.js → chunk-2c907a77.js} +1 -1
- package/dist/{chunk-ez003q74.js → chunk-2xpdcr8c.js} +1 -1
- package/dist/{chunk-qnptmtqh.js → chunk-3v63btq1.js} +1 -1
- package/dist/{chunk-7v1g7prf.js → chunk-3xspzgrq.js} +1 -1
- package/dist/{chunk-tf16jtj4.js → chunk-4arms0am.js} +1 -1
- package/dist/chunk-4qhhbzx9.js +2 -0
- package/dist/{chunk-rydb5n5b.js → chunk-5fzgdrfy.js} +1 -1
- package/dist/{chunk-nybn003d.js → chunk-5j3v0p6s.js} +1 -1
- package/dist/{chunk-x5b8az2h.js → chunk-5mjz2qgs.js} +1 -1
- package/dist/chunk-6nf5g9bh.js +2 -0
- package/dist/chunk-6pdfvpa6.js +2 -0
- package/dist/chunk-71gg4a7z.js +2 -0
- package/dist/chunk-7k7vqrj3.js +2 -0
- package/dist/{chunk-0smr2xjs.js → chunk-7kfv1q2r.js} +1 -1
- package/dist/chunk-7ppey2yt.js +2 -0
- package/dist/{chunk-aa8015mk.js → chunk-7racewc5.js} +1 -1
- package/dist/{chunk-t23kccpz.js → chunk-7rj4h2t2.js} +2 -2
- package/dist/{chunk-apbr1kb1.js → chunk-7wj5je2t.js} +1 -1
- package/dist/{chunk-284kattb.js → chunk-83af26bs.js} +1 -1
- package/dist/{chunk-qrvey4wk.js → chunk-84577w4y.js} +1 -1
- package/dist/{chunk-9qdn9y72.js → chunk-89xwdc1d.js} +1 -1
- package/dist/{chunk-f2jypsax.js → chunk-8akj7f4h.js} +1 -1
- package/dist/chunk-8e6fgnk5.js +2 -0
- package/dist/chunk-93z5qt1s.js +2 -0
- package/dist/{chunk-94dz7hrj.js → chunk-a5cybvfv.js} +1 -1
- package/dist/{chunk-a4jhcbsh.js → chunk-a68y9s2j.js} +2 -2
- package/dist/{chunk-m0eg86q3.js → chunk-b381xgvw.js} +1 -1
- package/dist/{chunk-dtdwjpvf.js → chunk-bab01mkf.js} +1 -1
- package/dist/{chunk-79fj9zem.js → chunk-benx1c4p.js} +1 -1
- package/dist/chunk-bqm306xw.js +2 -0
- package/dist/chunk-bxkr3ts9.js +2 -0
- package/dist/{chunk-hcf8399w.js → chunk-ct8tvahc.js} +1 -1
- package/dist/chunk-d0350ak9.js +2 -0
- package/dist/chunk-d5gzma79.js +2 -0
- package/dist/{chunk-kjd9hbg4.js → chunk-dj24n5n7.js} +3 -3
- package/dist/{chunk-hkrzv980.js → chunk-dnard9gp.js} +2 -2
- package/dist/{chunk-sa6cgj9h.js → chunk-dwyad9gb.js} +1 -1
- package/dist/{chunk-trva71am.js → chunk-e03m4har.js} +2 -2
- package/dist/{chunk-c17ybabd.js → chunk-enjfp0tp.js} +1 -1
- package/dist/chunk-erbyg322.js +2 -0
- package/dist/chunk-g6av70d6.js +2 -0
- package/dist/{chunk-j6kec9kp.js → chunk-g8k2zj4z.js} +1 -1
- package/dist/chunk-gzr4mcp2.js +2 -0
- package/dist/{chunk-awyyskad.js → chunk-hkq7d4t2.js} +1 -1
- package/dist/{chunk-ykevda74.js → chunk-jc6wrxrh.js} +2 -2
- package/dist/{chunk-rcbt11p8.js → chunk-k11mck47.js} +1 -1
- package/dist/{chunk-3kd0zn9c.js → chunk-k91ej0ts.js} +1 -1
- package/dist/{chunk-tv04k7gq.js → chunk-karkhcja.js} +1 -1
- package/dist/{chunk-5270fyk7.js → chunk-kd95t585.js} +1 -1
- package/dist/{chunk-emjmshj8.js → chunk-m8kem5ca.js} +1 -1
- package/dist/{chunk-n5tpqzcb.js → chunk-m8nmsr4g.js} +1 -1
- package/dist/{chunk-v1qm7p7t.js → chunk-masf0yq5.js} +2 -2
- package/dist/{chunk-czj6nq0b.js → chunk-met6wtbk.js} +2 -2
- package/dist/{chunk-ep034wt0.js → chunk-mzrejx5e.js} +1 -1
- package/dist/chunk-n6eg071x.js +2 -0
- package/dist/chunk-nabannen.js +2 -0
- package/dist/{chunk-wz4fnsat.js → chunk-necx4e30.js} +1 -1
- package/dist/chunk-p1ycxzwx.js +2 -0
- package/dist/{chunk-7jcntsp4.js → chunk-p41s1y4v.js} +1 -1
- package/dist/{chunk-j8wycqve.js → chunk-pf8575bx.js} +1 -1
- package/dist/{chunk-b8ywrx2w.js → chunk-pt74619a.js} +1 -1
- package/dist/{chunk-krt45cqy.js → chunk-pwctc0m1.js} +1 -1
- package/dist/{chunk-degz74nv.js → chunk-qg0w5tjb.js} +1 -1
- package/dist/{chunk-z50ex86m.js → chunk-r55bx7r8.js} +1 -1
- package/dist/chunk-r6sacvqn.js +2 -0
- package/dist/{chunk-6yfccnr7.js → chunk-r6xmsxaz.js} +1 -1
- package/dist/{chunk-3kyydhzt.js → chunk-r7q89mv2.js} +1 -1
- package/dist/{chunk-ec8jsqgm.js → chunk-rargfb5s.js} +2 -2
- package/dist/chunk-s3q7k0bf.js +2 -0
- package/dist/{chunk-6qhatdte.js → chunk-s4jbvdx3.js} +2 -2
- package/dist/chunk-sd57d9bq.js +2 -0
- package/dist/chunk-syxe0cyd.js +2 -0
- package/dist/{chunk-6gsgayq3.js → chunk-t9m81dj8.js} +1 -1
- package/dist/{chunk-zxfejz72.js → chunk-ta6z7k4p.js} +1 -1
- package/dist/chunk-tfjv0567.js +2 -0
- package/dist/{chunk-kyyt9xhs.js → chunk-v90kxg77.js} +1 -1
- package/dist/{chunk-czypgdc1.js → chunk-vcdd231w.js} +1 -1
- package/dist/{chunk-qbz6yn8c.js → chunk-vgx5077x.js} +2 -2
- package/dist/{chunk-gn2qc03b.js → chunk-vj5ywxmb.js} +1 -1
- package/dist/chunk-vnwzzw9j.js +2 -0
- package/dist/{chunk-rtfwn4cm.js → chunk-vsqx756d.js} +1 -1
- package/dist/{chunk-cf9gt3h9.js → chunk-vyhrzsnf.js} +10 -10
- package/dist/{chunk-ejwfnttb.js → chunk-w1asc0zd.js} +1 -1
- package/dist/{chunk-f11z7q5g.js → chunk-x0c5vqss.js} +1 -1
- package/dist/{chunk-zxnf0c9x.js → chunk-x6c2t5dv.js} +1 -1
- package/dist/{chunk-h99qxgbr.js → chunk-xb23pzwa.js} +1 -1
- package/dist/{chunk-eg8k598q.js → chunk-xb2fcf36.js} +1 -1
- package/dist/{chunk-1nnza3m6.js → chunk-xk402w4a.js} +1 -1
- package/dist/chunk-xn226qe0.js +2 -0
- package/dist/{chunk-aacfyyya.js → chunk-xnbbnbtm.js} +1 -1
- package/dist/{chunk-n1y0hjk1.js → chunk-ypgyhr2p.js} +1 -1
- package/dist/{chunk-hh0aaxxy.js → chunk-z2rvc8d5.js} +2 -2
- package/dist/chunk-za8wxkx6.js +2 -0
- package/dist/{chunk-8xjasa91.js → chunk-zd172hvg.js} +1 -1
- package/dist/{chunk-4gtsf1xw.js → chunk-zf66zyyy.js} +1 -1
- package/dist/chunk-zmvgsgtd.js +2 -0
- package/dist/{chunk-0c49cy69.js → chunk-zxf0deg6.js} +1 -1
- package/dist/{chunk-mere396d.js → chunk-zxptxz2b.js} +1 -1
- package/dist/cli.js +14 -14
- package/dist/client-declarations.d.ts +24 -0
- package/dist/client-declarations.js +33 -0
- package/dist/client-script.js +2 -33
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/database.js +1 -1
- package/dist/loop-binding.d.ts +23 -0
- package/dist/loop-binding.js +12 -0
- package/dist/loops.d.ts +20 -23
- package/dist/loops.js +9 -13
- package/dist/pwa.js +2 -2
- package/dist/ssg.js +2 -2
- package/dist/stx-virtual-ts.d.ts +27 -0
- package/dist/stx-virtual-ts.js +57 -10
- package/dist/visual-testing.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-0chkqvs1.js +0 -2
- package/dist/chunk-0d6qgbks.js +0 -2
- package/dist/chunk-2x3zy811.js +0 -2
- package/dist/chunk-38mpg3kn.js +0 -2
- package/dist/chunk-3f782ywp.js +0 -2
- package/dist/chunk-4mkqzhfh.js +0 -2
- package/dist/chunk-54w1tgzq.js +0 -2
- package/dist/chunk-5x0zjm34.js +0 -2
- package/dist/chunk-7nf8azjh.js +0 -2
- package/dist/chunk-8wgsjh65.js +0 -2
- package/dist/chunk-a6x0czvr.js +0 -2
- package/dist/chunk-abtxpqna.js +0 -2
- package/dist/chunk-c4rpdtvw.js +0 -2
- package/dist/chunk-cgs5xpsn.js +0 -2
- package/dist/chunk-dpyc7pht.js +0 -2
- package/dist/chunk-e0f3qs59.js +0 -2
- package/dist/chunk-f3eb1f6z.js +0 -2
- package/dist/chunk-fzq2n865.js +0 -2
- package/dist/chunk-g3cmkyk2.js +0 -2
- package/dist/chunk-gxgrzeeh.js +0 -2
- package/dist/chunk-p78b80dp.js +0 -2
- package/dist/chunk-pr3hz3ec.js +0 -2
- package/dist/chunk-skdfq4hq.js +0 -2
- package/dist/chunk-w1a8dwgx.js +0 -2
- package/dist/chunk-w9gserf7.js +0 -2
- package/dist/chunk-x131a0jq.js +0 -2
- package/dist/chunk-xk782v5z.js +0 -2
- package/dist/chunk-xxrv2p42.js +0 -2
- package/dist/chunk-ynj1y0qm.js +0 -2
- package/dist/chunk-z8gccz1q.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ye as z$}from"./chunk-
|
|
2
|
+
import{Ye as z$}from"./chunk-1hvxs7rh.js";import{Zf as i7,bg as j$,cg as c6,dg as T6,fg as B1,gg as l6,hg as K5,ig as O$,jg as A$,kg as i6,lg as a6,pg as z5}from"./chunk-a68y9s2j.js";import{bj as u5}from"./chunk-pwctc0m1.js";import{rj as l1,sj as I1,tj as R1,uj as a$,vj as s$,wj as n5,yj as o5}from"./chunk-0t1yyn1d.js";import{Vj as _$,Wj as U$}from"./chunk-k91ej0ts.js";import{xk as l5,yk as i5}from"./chunk-necx4e30.js";import{Ek as Z3,Fk as Q3}from"./chunk-frp9fc7j.js";import{Zk as U1}from"./chunk-qg0w5tjb.js";import{sl as M5,tl as j8}from"./chunk-7rj4h2t2.js";import{$m as C1,Bm as n0,Cr as T0,Io as M0,Lp as V0,Tm as d6,To as o0,Wl as V8,Xm as _5,_m as T1,_n as K$,hp as s7,ir as B$,jo as H$,lo as u6,mo as E6,mq as _6,nm as l7,nq as x1,op as m6,pp as p6,rq as t0,vr as C$,xr as r0,yr as w0}from"./chunk-2119txb8.js";import{Js as J5,bt as B,it as L$,jt as F$,nt as J0}from"./chunk-dj24n5n7.js";import{st as u0}from"./chunk-w1asc0zd.js";import{Iu as s1,Lu as M6,Tu as Z5,Vu as Q5,Yu as r1,av as Y5,dv as W$,ev as V6,qv as K6}from"./chunk-met6wtbk.js";import{Aw as g6,Bw as f6,Dw as h6,Iw as w6,bw as W5,cw as D6,gw as x6,hw as S6,ww as P6,xw as b6,yw as y6,zw as v6}from"./chunk-e03m4har.js";import{Sw as s}from"./chunk-m8kem5ca.js";var t5={read:($)=>{try{return JSON.parse($)}catch{return $}},write:($)=>{return JSON.stringify($)}};function U3($,X,Z={}){let{storage:Q="local",serializer:Y=t5,mergeDefaults:J=!1,listenToStorageChanges:G=!0}=Z,W=new Set,K=typeof window<"u",_=()=>{if(!K)return null;return Q==="session"?sessionStorage:localStorage},U=()=>{let L=_();if(!L)return X;try{let O=L.getItem($);if(O===null)return X;let A=Y.read(O);if(J&&typeof X==="object"&&X!==null)return{...X,...A};return A}catch{return X}},F=(L)=>{let O=_();if(!O)return;try{if(L===null||L===void 0)O.removeItem($);else O.setItem($,Y.write(L))}catch(A){console.warn(`[useStorage] Failed to write key "${$}":`,A)}},z=U(),j=(L,O)=>{for(let A of W)try{A(L,O)}catch(M){console.error("[useStorage] Subscriber error:",M)}};if(K&&G){let L=(A)=>{if(A.key===$&&A.storageArea===_()){let M=z;try{z=A.newValue?Y.read(A.newValue):X}catch(V){console.warn(`[useStorage] Failed to read key "${$}" from a cross-tab update:`,V);return}j(z,M)}};window.addEventListener("storage",L);let O=globalThis.onDestroy;if(typeof O==="function")O(()=>window.removeEventListener("storage",L))}let H={get value(){return z},set value(L){let O=z;z=L,F(L),j(L,O)},get:()=>z,set:(L)=>{H.value=L},remove:()=>{let L=_();if(L){L.removeItem($);let O=z;z=X,j(X,O)}},subscribe:(L)=>{return W.add(L),L(z,void 0),()=>W.delete(L)}};return H}function e5($,X,Z,Q,Y={}){let{serializer:J=t5,mergeDefaults:G=!1,listenToStorageChanges:W=!0}=Y,K=typeof window<"u",_=()=>{if(!K)return null;return $==="session"?sessionStorage:localStorage},U=(j)=>{if(j===null||j===void 0)return Q;try{let H=J.read(j);if(G&&typeof Q==="object"&&Q!==null)return{...Q,...H};return H}catch(H){return console.warn(`[${X}] Failed to read key "${Z}":`,H),Q}},z=n5((()=>{let j=_();if(!j)return Q;try{return U(j.getItem(Z))}catch(H){return console.warn(`[${X}] Cannot read "${Z}":`,H),Q}})());if(o5(()=>{let j=z(),H=_();if(!H)return;try{if(j===null||j===void 0)H.removeItem(Z);else H.setItem(Z,J.write(j))}catch(L){console.warn(`[${X}] Cannot persist "${Z}":`,L)}}),K&&W){let j=(L)=>{if(L.key!==Z)return;if(L.storageArea&&L.storageArea!==_())return;z.set(U(L.newValue))};window.addEventListener("storage",j);let H=globalThis.onDestroy;if(typeof H==="function")H(()=>window.removeEventListener("storage",j))}return z}function B3($,X,Z){return e5("local","useLocalStorage",$,X,Z)}function L3($,X,Z){return e5("session","useSessionStorage",$,X,Z)}function F3($="local"){if(typeof window>"u")return;($==="session"?sessionStorage:localStorage).clear()}function z3($="local"){if(typeof window>"u")return[];let X=$==="session"?sessionStorage:localStorage;return Object.keys(X)}function j3($="local"){if(typeof window>"u")return 0;let X=$==="session"?sessionStorage:localStorage,Z=0;for(let Q in X)if(Object.prototype.hasOwnProperty.call(X,Q))Z+=(Q.length+(X.getItem(Q)?.length||0))*2;return Z}var t=null;function c1($,X,Z=new WeakSet){if(Object.is($,X))return!0;if(typeof $!=="object"||typeof X!=="object"||$===null||X===null)return!1;if(Z.has($))return!0;if(Z.add($),$ instanceof Date&&X instanceof Date)return $.getTime()===X.getTime();if($ instanceof RegExp&&X instanceof RegExp)return $.source===X.source&&$.flags===X.flags;if(Array.isArray($)){if(!Array.isArray(X)||$.length!==X.length)return!1;for(let J=0;J<$.length;J++)if(!c1($[J],X[J],Z))return!1;return!0}if(Array.isArray(X))return!1;if($ instanceof Map){if(!(X instanceof Map)||$.size!==X.size)return!1;for(let[J,G]of $)if(!X.has(J)||!c1(G,X.get(J),Z))return!1;return!0}if(X instanceof Map)return!1;if($ instanceof Set){if(!(X instanceof Set)||$.size!==X.size)return!1;for(let J of $)if(!X.has(J))return!1;return!0}if(X instanceof Set)return!1;let Q=Object.keys($),Y=Object.keys(X);if(Q.length!==Y.length)return!1;for(let J of Q){if(!Object.prototype.hasOwnProperty.call(X,J))return!1;if(!c1($[J],X[J],Z))return!1}return!0}function UJ($){t=$}function BJ(){return t}function LJ(){return{isMounted:!1,isUnmounted:!1,hooks:{beforeMount:[],mounted:[],beforeUpdate:[],updated:[],beforeUnmount:[],unmounted:[]},effects:[],scope:H3()}}function H3(){return{refs:new Map,effects:new Set,cleanups:[]}}function FJ($){let X=new Set,Z=new Set,Q=$,Y=Symbol("ref"),J={get value(){let G=l1();if(G)Z.add(G);return Q},set value(G){if(!Object.is(G,Q)){let W=Q;Q=G;for(let K of X)K(G,W);for(let K of Z)if(a$())s$(K);else K()}},subscribe(G){return X.add(G),()=>{X.delete(G)}}};if(t)t.scope.refs.set(Y,J);return J}var $6=new WeakMap;function O3($){let X=$6.get($);if(X)return X;let Z=new Map,Q=(G)=>{let W=Z.get(G);if(!W)return;for(let K of[...W])if(a$())s$(K);else K()},Y=(G,W)=>{if(!Z.has(G))Z.set(G,new Set);return Z.get(G).add(W),()=>{Z.get(G)?.delete(W)}},J=new Proxy($,{get(G,W,K){let _=Reflect.get(G,W,K),U=l1();if(U)Y(W,U);if(_!==null&&typeof _==="object"&&!Array.isArray(_)){let F=Object.getPrototypeOf(_);if(F===Object.prototype||F===null)return O3(_)}return _},set(G,W,K,_){let U=Reflect.get(G,W,_),F=Reflect.set(G,W,K,_);if(!Object.is(K,U))Q(W);return F},deleteProperty(G,W){let K=Reflect.deleteProperty(G,W);return Q(W),K}});return $6.set($,J),J}function zJ($){let X,Z=!0,Q=new Set,Y=new Set,J=()=>{Z=!0,G()},G=()=>{if(Z){let K=X,_=I1(J);if(X=$(),R1(_),Z=!1,!Object.is(X,K)){for(let U of Q)U(X,K);for(let U of Y)U()}}},W=I1(J);return X=$(),Z=!1,R1(W),{get value(){let K=l1();if(K)Y.add(K);return G(),X},set value(K){console.warn("[stx] Computed properties are readonly")},subscribe(K){return Q.add(K),()=>{Q.delete(K)}}}}function A3($){if(typeof requestAnimationFrame==="function"){requestAnimationFrame(()=>{requestAnimationFrame($)});return}setTimeout($,0)}function jJ($,X,Z={}){let{immediate:Q=!1,deep:Y=!1,flush:J="post"}=Z,G,W,K=!1,_=()=>{if(K)return;let H=j();if((Y?!c1(H,G):!Object.is(H,G))||Q)if(X(H,G),Y&&H!==null&&typeof H==="object")try{G=structuredClone(H)}catch{G=H}else G=H},U=(H)=>{if(J==="sync")H();else if(J==="pre")Promise.resolve().then(H);else A3(H)},F=!1,z=()=>{if(K||F)return;F=!0,U(()=>{F=!1,_()})},j=()=>{if(typeof $==="function"){let H=I1(z);try{return $()}finally{R1(H)}}return $.value};if(typeof $!=="function"){let H=$.subscribe(()=>{U(_)});W=()=>{K=!0,H()}}else W=()=>{K=!0};if(G=j(),Q)U(_);if(t)t.scope.cleanups.push(()=>W?.());return()=>W?.()}function HJ($,X,Z={}){let Q=[],Y=$.map((J)=>J.value);for(let J of $){let G=J.subscribe(()=>{let W=$.map((K)=>K.value);X(W,Y),Y=[...W]});Q.push(G)}if(Z.immediate){let J=$.map((G)=>G.value);X(J,Y)}return()=>{for(let J of Q)J()}}function OJ($){let X,Z=!1,Q=()=>{if(Z)return;if(X)X();let Y=I1(Q);X=$(),R1(Y)};if(Q(),t)t.scope.cleanups.push(()=>{if(Z=!0,X)X()});return()=>{if(Z=!0,X)X()}}function AJ($){if(t)t.hooks.beforeMount.push($);else console.warn("[stx] onBeforeMount called outside of component setup")}function NJ($){if(t)t.hooks.mounted.push($);else console.warn("[stx] onMounted called outside of component setup")}function qJ($){if(t)t.hooks.beforeUpdate.push($);else console.warn("[stx] onBeforeUpdate called outside of component setup")}function MJ($){if(t)t.hooks.updated.push($);else console.warn("[stx] onUpdated called outside of component setup")}function VJ($){if(t)t.hooks.beforeUnmount.push($);else console.warn("[stx] onBeforeUnmount called outside of component setup")}function EJ($){if(t)t.hooks.unmounted.push($);else console.warn("[stx] onUnmounted called outside of component setup")}async function Y1($,X){let Z=$.hooks[X];for(let Q of Z)await Q()}async function IJ($){await Y1($,"beforeMount"),$.isMounted=!0,await Y1($,"mounted")}async function RJ($){if(!$.isMounted||$.isUnmounted)return;await Y1($,"beforeUpdate"),await Y1($,"updated")}async function DJ($){if($.isUnmounted)return;await Y1($,"beforeUnmount");for(let X of $.scope.cleanups)X();$.isUnmounted=!0,await Y1($,"unmounted")}function wJ(){return`
|
|
3
3
|
<script data-stx-client-runtime>
|
|
4
4
|
(function() {
|
|
5
5
|
'use strict';
|
|
@@ -697,7 +697,7 @@ else {
|
|
|
697
697
|
<span class="frontmatter-label">${X}:</span>
|
|
698
698
|
<span>${Array.isArray(Z)?Z.join(", "):String(Z)}</span>
|
|
699
699
|
</div>`).join("")}
|
|
700
|
-
</div>`}import N6 from"net";async function O4($){return new Promise((X)=>{let Z=N6.createServer();Z.once("error",()=>X(!1)),Z.once("listening",()=>{Z.close(()=>X(!0))}),Z.listen($,"0.0.0.0")})}async function A4($){return new Promise((X)=>{let Z=N6.createServer();Z.once("error",()=>X(!1)),Z.once("listening",()=>{Z.close(()=>X(!0))}),Z.listen($,"::")})}async function N4($){if(!await O4($))return!1;return await A4($)}async function h0($,X=20){$=Number($);for(let Z=0;Z<X;Z++){let Q=$+Z;if(await N4(Q))return Q}throw Error(`Could not find an available port between ${$} and ${$+X-1}`)}var q4={title:"stx Development",width:1400,height:900,darkMode:!0,hotReload:!0,titlebarHidden:!1,nativeSidebar:!1,sidebarWidth:260,sidebarConfig:void 0};async function M4(){try{let $=await import("./chunk-
|
|
700
|
+
</div>`}import N6 from"net";async function O4($){return new Promise((X)=>{let Z=N6.createServer();Z.once("error",()=>X(!1)),Z.once("listening",()=>{Z.close(()=>X(!0))}),Z.listen($,"0.0.0.0")})}async function A4($){return new Promise((X)=>{let Z=N6.createServer();Z.once("error",()=>X(!1)),Z.once("listening",()=>{Z.close(()=>X(!0))}),Z.listen($,"::")})}async function N4($){if(!await O4($))return!1;return await A4($)}async function h0($,X=20){$=Number($);for(let Z=0;Z<X;Z++){let Q=$+Z;if(await N4(Q))return Q}throw Error(`Could not find an available port between ${$} and ${$+X-1}`)}var q4={title:"stx Development",width:1400,height:900,darkMode:!0,hotReload:!0,titlebarHidden:!1,nativeSidebar:!1,sidebarWidth:260,sidebarConfig:void 0};async function M4(){try{let $=await import("./chunk-z2rvc8d5.js");if(typeof $.openDevWindow!=="function")return null;return $}catch{return null}}async function G1($,X={}){let Z={...q4,...X},Q=await M4();if(!Q)return console.log(`${B.yellow}\u26A0${B.reset} Native window requested, but @stacksjs/desktop is not available.`),console.log(" Install & build the desktop package to enable --native."),!1;try{let Y=await Q.openDevWindow($,{title:Z.title,width:Z.width,height:Z.height,darkMode:Z.darkMode,hotReload:Z.hotReload,titlebarHidden:Z.titlebarHidden,nativeSidebar:Z.nativeSidebar,sidebarWidth:Z.sidebarWidth,sidebarConfig:Z.sidebarConfig});if(Y&&Z.nativeSidebar)console.log(`${B.green}\u2713${B.reset} Native sidebar enabled (macOS Tahoe style)`);return Y}catch(Y){return console.log(`${B.red}\u2717${B.reset} Could not open native window:`,Y),!1}}function Z$($){if($.match(/<Sidebar[\s\S]*?variant=["'](?:tahoe|vibrancy|desktop)["'][\s\S]*?\/>/i)){let Y=$.match(/<script\s+server[^>]*>([\s\S]*?)<\/script>/i);if(Y){let J=Y[1];try{let G=`
|
|
701
701
|
${J}
|
|
702
702
|
return typeof sidebarConfig !== 'undefined' ? sidebarConfig : null;
|
|
703
703
|
`,K=Function(G)();if(K)return K}catch(G){console.warn("Invalid sidebarConfig:",G)}}return{sections:[]}}let Z=$.match(/@nativeSidebar\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(Z)try{return JSON.parse(Z[1])}catch{console.warn("Invalid @nativeSidebar configuration")}let Q=$.match(/<script\s+native-sidebar[^>]*>([\s\S]*?)<\/script>/i);if(Q)try{let Y=Q[1].match(/(?:export\s+(?:default\s+)?|const\s+\w+\s*=\s*)(\{[\s\S]*\})/m);if(Y)return Function(`return ${Y[1]}`)()}catch(Y){console.warn("Invalid native-sidebar script configuration:",Y)}return}function e$(){console.log(`
|
|
@@ -1069,7 +1069,7 @@ else {
|
|
|
1069
1069
|
};
|
|
1070
1070
|
})();
|
|
1071
1071
|
</script>
|
|
1072
|
-
`}function P0($,X,Z={}){let Q=w4(X,Z),Y=$.lastIndexOf("</body>");if(Y!==-1)return $.slice(0,Y)+Q+$.slice(Y);if($.includes("</html>"))return $.replace("</html>",`${Q}</html>`);return $+Q}function Q$($){let X=$.toLowerCase();return X.endsWith(".css")||X.endsWith(".scss")||X.endsWith(".sass")||X.endsWith(".less")}function Y$($){let X=$.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((Q)=>X.endsWith(Q))}function J$($){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((Z)=>Z.test($))}var K1=null;function G$($){if(!K1)K1=new q6($);return K1}function D1(){if(K1)K1.stop(),K1=null}import w1 from"path";var _1={name:"bun-plugin-stx",async setup($){let Z={...await r0(),...$.config?.stx},Q=new Set,Y=Z.webComponents?.enabled?`./${w1.relative(w1.dirname($.config?.outdir||"dist"),Z.webComponents.outputDir||"dist/web-components")}`:"/web-components",J=[];if(Z.webComponents?.enabled)try{let G=await B$(Z,Q);if(J.push(...G),Z.debug&&G.length>0)console.log(`Successfully built ${G.length} web components`)}catch(G){console.error("Failed to build web components:",G)}$.onLoad({filter:/\.stx$/},async({path:G})=>{try{let W=new Set;if(Z.cache&&Z.cachePath){let L=await _$(G,Z);if(L){if(Z.debug)console.log(`Using cached version of ${G}`);return{contents:L,loader:"html"}}}let K=await Y5(()=>Bun.file(G).text(),"",(L)=>{throw new Q5(`Failed to read stx file: ${G}`,G,void 0,void 0,`File read error: ${L.message}`)});if(!K)throw new Q5(`stx file is empty: ${G}`,G);let{scriptContent:_,templateContent:U,allScripts:F}=J5.time("script-extraction",()=>{let L=K,O=K$(K);if(O)L=O.content.trim();let A=K.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],M="",V=[];for(let q of A){let I=q.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",E=q.match(/<script\b([^>]*)>/i),w=E?E[1]:"";if(/\bserver\b/i.test(w))M=I;else V.push(q)}let N=L.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:M,templateContent:N,allScripts:V}}),z={__filename:G,__dirname:w1.dirname(G),__stx:{webComponentsPath:Y,builtComponents:J}};await Y5(()=>M0(_,z,G),void 0,(L)=>{let O=new Z5(`Script execution failed in ${G}: ${L.message}`,G,void 0,void 0,_.substring(0,100));if(W$.log(O,{filePath:G,scriptContent:_}),Z.debug)throw O});let H=await J5.timeAsync("directive-processing",async()=>{return await V0(U,z,G,Z,W)});if(F.length>0){let{interpolateScriptsInTemplate:L}=await import("./chunk-
|
|
1072
|
+
`}function P0($,X,Z={}){let Q=w4(X,Z),Y=$.lastIndexOf("</body>");if(Y!==-1)return $.slice(0,Y)+Q+$.slice(Y);if($.includes("</html>"))return $.replace("</html>",`${Q}</html>`);return $+Q}function Q$($){let X=$.toLowerCase();return X.endsWith(".css")||X.endsWith(".scss")||X.endsWith(".sass")||X.endsWith(".less")}function Y$($){let X=$.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((Q)=>X.endsWith(Q))}function J$($){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((Z)=>Z.test($))}var K1=null;function G$($){if(!K1)K1=new q6($);return K1}function D1(){if(K1)K1.stop(),K1=null}import w1 from"path";var _1={name:"bun-plugin-stx",async setup($){let Z={...await r0(),...$.config?.stx},Q=new Set,Y=Z.webComponents?.enabled?`./${w1.relative(w1.dirname($.config?.outdir||"dist"),Z.webComponents.outputDir||"dist/web-components")}`:"/web-components",J=[];if(Z.webComponents?.enabled)try{let G=await B$(Z,Q);if(J.push(...G),Z.debug&&G.length>0)console.log(`Successfully built ${G.length} web components`)}catch(G){console.error("Failed to build web components:",G)}$.onLoad({filter:/\.stx$/},async({path:G})=>{try{let W=new Set;if(Z.cache&&Z.cachePath){let L=await _$(G,Z);if(L){if(Z.debug)console.log(`Using cached version of ${G}`);return{contents:L,loader:"html"}}}let K=await Y5(()=>Bun.file(G).text(),"",(L)=>{throw new Q5(`Failed to read stx file: ${G}`,G,void 0,void 0,`File read error: ${L.message}`)});if(!K)throw new Q5(`stx file is empty: ${G}`,G);let{scriptContent:_,templateContent:U,allScripts:F}=J5.time("script-extraction",()=>{let L=K,O=K$(K);if(O)L=O.content.trim();let A=K.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],M="",V=[];for(let q of A){let I=q.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",E=q.match(/<script\b([^>]*)>/i),w=E?E[1]:"";if(/\bserver\b/i.test(w))M=I;else V.push(q)}let N=L.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:M,templateContent:N,allScripts:V}}),z={__filename:G,__dirname:w1.dirname(G),__stx:{webComponentsPath:Y,builtComponents:J}};await Y5(()=>M0(_,z,G),void 0,(L)=>{let O=new Z5(`Script execution failed in ${G}: ${L.message}`,G,void 0,void 0,_.substring(0,100));if(W$.log(O,{filePath:G,scriptContent:_}),Z.debug)throw O});let H=await J5.timeAsync("directive-processing",async()=>{return await V0(U,z,G,Z,W)});if(F.length>0){let{interpolateScriptsInTemplate:L}=await import("./chunk-0p52xkk9.js"),O=L(F.join(`
|
|
1073
1073
|
`),z),A=H.search(/<\/body>/i);if(A!==-1)H=H.slice(0,A)+O+`
|
|
1074
1074
|
`+H.slice(A);else H+=`
|
|
1075
1075
|
${O}`}if(H=await E6(H),W.forEach((L)=>Q.add(L)),Z.cache&&Z.cachePath){if(await U$(G,H,W,Z),Z.debug)console.log(`Cached template ${G} with ${W.size} dependencies`)}return{contents:H,loader:"html"}}catch(W){let K=W instanceof Error?W:new Z5(`Plugin processing failed: ${String(W)}`,G);if(W$.log(K,{filePath:G,buildConfig:$.config}),V6.logDetailedError(K,{filePath:G,plugin:"bun-plugin-stx"}),Z.debug)console.error("stx Plugin Error:",K);let _=K,U=_.line||null,F=_.context||null;return{contents:Z.debug||M6()?`<!DOCTYPE html>
|
|
@@ -1132,7 +1132,7 @@ ${O}`}if(H=await E6(H),W.forEach((L)=>Q.add(L)),Z.cache&&Z.cachePath){if(await U
|
|
|
1132
1132
|
<h1>Something went wrong</h1>
|
|
1133
1133
|
<p>An internal error occurred. Please try again later.</p>
|
|
1134
1134
|
</body>
|
|
1135
|
-
</html>`,loader:"html"}}})}};async function C4($,X={}){let Z=X.port||3000,Q=X.watch!==!1,Y=X.hotReload!==!1&&Q,J=null,G=X.hmrPort||Z+1,W=Q0.resolve($);if(!E0.existsSync(W))return console.error(`${B.red}Error: File not found: ${B.bright}${W}${B.reset}`),!1;if(W.endsWith(".md"))return X5(W,X);else if(!W.endsWith(".stx"))return console.error(`${B.red}Error: Unsupported file type: ${B.bright}${W}${B.reset}. Only .stx and .md files are supported.`),!1;let K=u0(process.cwd(),"output");E0.mkdirSync(K,{recursive:!0}),console.log(`${B.blue}Building ${B.bright}${$}${B.reset}...`);let _=null,U=async()=>{try{let I={name:"public-assets",setup(T){T.onResolve({filter:/^\/(images|fonts|assets|public)\//},(f)=>{return{path:f.path,external:!0}})}},E=await Bun.build({entrypoints:[W],outdir:K,plugins:[I,_1],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!E.success)return console.error(`${B.red}Build failed:${B.reset}`,E.logs),!1;let w=E.outputs.find((T)=>T.path.endsWith(".html"));if(!w)return console.error(`${B.red}No HTML output found${B.reset}`),!1;return _=await Bun.file(w.path).text(),!0}catch(I){return console.error(`${B.red}Error building stx file:${B.reset}`,I),!1}};if(!await U())return!1;let z=Q0.dirname(W);await L$(z);let j=Z;try{if(j=await h0(Z),j!==Z)console.log(`${B.yellow}Port ${Z} is busy, using port ${j} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}if(Y){let I=X.hmrPort||j+1;J=G$({wsPort:I,verbose:!1}),G=J.start(I)}let H={},L=null,O;try{let{loadStxConfig:I}=await import("./chunk-
|
|
1135
|
+
</html>`,loader:"html"}}})}};async function C4($,X={}){let Z=X.port||3000,Q=X.watch!==!1,Y=X.hotReload!==!1&&Q,J=null,G=X.hmrPort||Z+1,W=Q0.resolve($);if(!E0.existsSync(W))return console.error(`${B.red}Error: File not found: ${B.bright}${W}${B.reset}`),!1;if(W.endsWith(".md"))return X5(W,X);else if(!W.endsWith(".stx"))return console.error(`${B.red}Error: Unsupported file type: ${B.bright}${W}${B.reset}. Only .stx and .md files are supported.`),!1;let K=u0(process.cwd(),"output");E0.mkdirSync(K,{recursive:!0}),console.log(`${B.blue}Building ${B.bright}${$}${B.reset}...`);let _=null,U=async()=>{try{let I={name:"public-assets",setup(T){T.onResolve({filter:/^\/(images|fonts|assets|public)\//},(f)=>{return{path:f.path,external:!0}})}},E=await Bun.build({entrypoints:[W],outdir:K,plugins:[I,_1],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!E.success)return console.error(`${B.red}Build failed:${B.reset}`,E.logs),!1;let w=E.outputs.find((T)=>T.path.endsWith(".html"));if(!w)return console.error(`${B.red}No HTML output found${B.reset}`),!1;return _=await Bun.file(w.path).text(),!0}catch(I){return console.error(`${B.red}Error building stx file:${B.reset}`,I),!1}};if(!await U())return!1;let z=Q0.dirname(W);await L$(z);let j=Z;try{if(j=await h0(Z),j!==Z)console.log(`${B.yellow}Port ${Z} is busy, using port ${j} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}if(Y){let I=X.hmrPort||j+1;J=G$({wsPort:I,verbose:!1}),G=J.start(I)}let H={},L=null,O;try{let{loadStxConfig:I}=await import("./chunk-6pdfvpa6.js"),E=await I();if(O=X.stxOptions?.serverApi??E.serverApi,E?.apiRouter)L=E?.apiRouter,console.log(`${B.blue}Using custom router for API handling${B.reset}`);if(E?.apiRoutes){H=E.apiRoutes;let w=Object.keys(H).length;if(w>0)console.log(`${B.blue}Loaded ${B.bright}${w} API route${w>1?"s":""}${B.reset}`)}if(E?.broadcasting?.enabled)try{let{startBroadcasting:w,loadChannels:D}=await import("./chunk-0w12p79j.js"),T=E.broadcasting;await w(T);let f=T.port??6001;console.log(`${B.magenta}Broadcasting on ${B.cyan}ws://localhost:${f}/ws${B.reset}`);let c=Q0.join(process.cwd(),"channels.ts");if(E0.existsSync(c))try{let v=await D(c);console.log(`${B.blue}Loaded ${B.bright}${v} broadcast channel${v!==1?"s":""}${B.blue} from channels.ts${B.reset}`)}catch(v){console.warn(`${B.yellow}Failed to load channels.ts: ${v.message}${B.reset}`)}}catch(w){console.warn(`${B.yellow}Broadcasting failed to start: ${w.message}${B.reset}`)}}catch{}let{createServerApi:A,isServerApiSource:M}=await import("./chunk-x6c2t5dv.js"),V=await A(process.cwd(),O);if(console.log(`${B.blue}Starting server on ${B.cyan}http://localhost:${j}/${B.reset}...`),Y)console.log(`${B.magenta}Hot reload enabled on ws://localhost:${G}${B.reset}`);let N=T4({port:j,async fetch(I){return z$(I,await(async()=>{let E=new URL(I.url);if([K,Q0.dirname(W),Q0.join(process.cwd(),"public")].some((v)=>M(Q0.join(v,E.pathname),process.cwd(),O)))return new Response("Not Found",{status:404});if(L)try{let v=await L.handleRequest(I);if(v.status!==404)return v}catch{}if(H[E.pathname])try{return await H[E.pathname](I)}catch(v){return new Response(JSON.stringify({error:v.message}),{status:500,headers:{"Content-Type":"application/json"}})}let w=await V(I);if(w)return w;if(E.pathname==="/")return(async()=>{let S=await J0(_||"");if(Y)S=P0(S,G);if(X.native)if(S.includes("<head>"))S=S.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(S.includes("<html"))S=S.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else S="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+S;if(X.titlebarHidden)if(S.includes("<head>"))S=S.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(S.includes("<html"))S=S.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else S=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${S}`;return S})().then((S)=>new Response(S,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let D=Q0.join(K,E.pathname);if(E0.existsSync(D)&&E0.statSync(D).isFile()){let v=Bun.file(D),S=Q0.extname(D).toLowerCase(),k="text/plain";if(S===".ts"||S===".tsx"){let H0=new Bun.Transpiler({loader:S===".tsx"?"tsx":"ts"}),G0=await v.text(),s0=H0.transformSync(G0);return new Response(s0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(S){case".html":k="text/html";break;case".css":k="text/css";break;case".js":k="text/javascript";break;case".json":k="application/json";break;case".png":k="image/png";break;case".jpg":case".jpeg":k="image/jpeg";break;case".gif":k="image/gif";break;case".woff":k="font/woff";break;case".woff2":k="font/woff2";break;case".ttf":k="font/ttf";break;case".otf":k="font/otf";break;case".eot":k="application/vnd.ms-fontobject";break}return new Response(v,{headers:{"Content-Type":k}})}let T=Q0.dirname(W),f=Q0.join(T,E.pathname);if(E0.existsSync(f)&&E0.statSync(f).isFile()){let v=Bun.file(f),S=Q0.extname(f).toLowerCase(),k="text/plain";if(S===".ts"||S===".tsx"){let H0=new Bun.Transpiler({loader:S===".tsx"?"tsx":"ts"}),G0=await v.text(),s0=H0.transformSync(G0);return new Response(s0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(S){case".html":k="text/html";break;case".css":k="text/css";break;case".js":k="text/javascript";break;case".json":k="application/json";break;case".png":k="image/png";break;case".jpg":case".jpeg":k="image/jpeg";break;case".gif":k="image/gif";break;case".svg":k="image/svg+xml";break;case".ico":k="image/x-icon";break;case".woff":k="font/woff";break;case".woff2":k="font/woff2";break;case".ttf":k="font/ttf";break;case".otf":k="font/otf";break;case".eot":k="application/vnd.ms-fontobject";break}return new Response(v,{headers:{"Content-Type":k}})}let c=Q0.join(process.cwd(),"public",E.pathname);if(E0.existsSync(c)&&E0.statSync(c).isFile()){let v=Bun.file(c),S=Q0.extname(c).toLowerCase(),k="application/octet-stream";if(S===".ts"||S===".tsx"){let H0=new Bun.Transpiler({loader:S===".tsx"?"tsx":"ts"}),G0=await v.text(),s0=H0.transformSync(G0);return new Response(s0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(S){case".html":k="text/html";break;case".css":k="text/css";break;case".js":k="text/javascript";break;case".json":k="application/json";break;case".png":k="image/png";break;case".jpg":case".jpeg":k="image/jpeg";break;case".gif":k="image/gif";break;case".svg":k="image/svg+xml";break;case".ico":k="image/x-icon";break;case".woff":k="font/woff";break;case".woff2":k="font/woff2";break;case".ttf":k="font/ttf";break;case".otf":k="font/otf";break;case".eot":k="application/vnd.ms-fontobject";break}return new Response(v,{headers:{"Content-Type":k}})}return new Response("Not Found",{status:404})})())},error(I){return new Response(`<pre>${I}
|
|
1136
1136
|
${I.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
|
|
1137
1137
|
${B.blue}stx${B.reset} ${B.green}${process.env.stx_VERSION||"v0.0.10"}${B.reset} ${B.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${B.reset}`),console.log(`
|
|
1138
1138
|
${B.bright}\u2192 ${B.cyan}http://localhost:${j}/${B.reset}`),console.log(`
|
|
@@ -1619,12 +1619,12 @@ ${H.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),con
|
|
|
1619
1619
|
${B.blue}stx${B.reset} ${B.green}${process.env.stx_VERSION||"v0.0.10"}${B.reset} ${B.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${B.reset}`),console.log(`
|
|
1620
1620
|
${B.bright}\u2192 ${B.cyan}http://localhost:${U}/${B.reset}`),console.log(`
|
|
1621
1621
|
${B.yellow}Routes:${B.reset}`);let z=new Set(W.map((H)=>H.routeTemplate)),j=Object.entries(G).filter(([H])=>!z.has(H)).sort(([H],[L])=>H.localeCompare(L)).map(([H,L])=>({route:H==="/"?"/":H,filePath:B0.relative(process.cwd(),L.filePath),fileType:L.fileType}));for(let H of W){let L=H.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");j.push({route:L,filePath:B0.relative(process.cwd(),H.filePath),fileType:"stx"})}if(j.sort((H,L)=>H.route.localeCompare(L.route)),j.forEach((H,L)=>{let A=L===j.length-1?"\u2514\u2500 ":"\u251C\u2500 ",M=H.fileType==="md"?`${B.magenta}(markdown)${B.reset}`:"";console.log(` ${B.green}${A}${H.route}${B.reset} \u2192 ${B.bright}${H.filePath}${B.reset} ${M}`)}),console.log(`
|
|
1622
|
-
Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),d0(F.url.toString(),()=>{if(Q)m0.watch(J,{recursive:!0}).close();F.stop()}),Q){console.log(`${B.blue}Watching for changes...${B.reset}`);let H=m0.watch(J,{recursive:!0},async(L,O)=>{if(!O)return;if(O.endsWith(".stx")||O.endsWith(".js")||O.endsWith(".ts")||O.endsWith(".md"))console.log(`${B.yellow}File ${B.bright}${O}${B.yellow} changed, rebuilding...${B.reset}`),o0.clear(),t0(),await K()});process.on("SIGINT",()=>{H.close(),F.stop(),process.exit(0)})}return!0}function R6($){return String($??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var{serve:S4}=globalThis.Bun;import e from"fs";import m from"path";async function k6($){try{return _5(await Bun.file($).text())}catch{return}}function G5($){let X=Bun.file($),Z=m.extname($).toLowerCase(),Q={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},J=[".js",".css",".json"].includes(Z)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(X,{headers:{"Content-Type":Q[Z]||"application/octet-stream",...J}})}async function P4($=".",X={}){let Z=X.port||3000,Q=X.watch!==!1,Y=X.hotReload!==!1&&Q,J=null,G=X.hmrPort||Z+1,W=m.resolve($),{loadStxConfig:K}=await import("./chunk-e0f3qs59.js"),_=await K(W),{createServerApi:U,isServerApiSource:F}=await import("./chunk-zxnf0c9x.js"),z=X.stxOptions?.serverApi??_.serverApi,j=await U(W,z),H=_.root&&_.root!=="."?m.join(W,_.root):W,L=X.pagesDir||_.pagesDir||"pages",O=m.join(H,L);if(!e.existsSync(O)&&!_._layerPageDirs?.some((R)=>e.existsSync(R)))return console.error(`${B.red}Error: No '${L}' directory found${B.reset}`),console.log(`${B.dim}Looked in: ${B.bright}${O}${B.reset}`),console.log(`${B.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${B.reset}`),console.log(`${B.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${B.reset}`),console.log(`${B.dim}Starting fresh? Create ${L}/index.stx for the homepage.${B.reset}`),!1;let A=H$(H,{pagesDir:L,pagesDirs:_._layerPageDirs?[O,..._._layerPageDirs.slice(1)]:void 0});if(A.length===0)return console.error(`${B.red}Error: No page files found in ${B.bright}${O}${B.reset}`),!1;console.log(`${B.blue}Found ${B.bright}${A.length}${B.blue} routes${B.reset}`);let M=_?._pluginPageDirs||[],V=[];for(let{dir:R,prefix:x}of M)if(e.existsSync(R)){let P=H$(m.dirname(R),{pagesDir:m.basename(R)});for(let y of P){let Z0=x==="/"?y.pattern:`${x}${y.pattern==="/"?"":y.pattern}`;V.push({route:{...y,pattern:Z0},prefix:x})}if(P.length>0)console.log(`${B.blue}Plugin pages: ${B.bright}${P.length}${B.blue} routes at ${B.cyan}${x}${B.reset}`)}let N=new Map,q=null,I=null;if(X.stxOptions?.shell!==!1){if(I=await l6(W,X.stxOptions?.shell),I){if(q=await K5(I,X.stxOptions||{}),q)console.log(`${B.blue}Using app shell: ${B.bright}${m.relative(W,I)}${B.reset} ${B.dim}(deprecated: use layouts/default.stx instead)${B.reset}`)}}P6(),await y6(W);let E=b6();if(E.length>0)console.log(`${B.blue}Loaded ${B.bright}${E.length}${B.blue} middleware: ${B.dim}${E.join(", ")}${B.reset}`);let w={},D=null;try{let{loadStxConfig:R}=await import("./chunk-e0f3qs59.js"),x=await R(W);if(x?.apiRouter)D=x?.apiRouter,console.log(`${B.blue}Using custom router for API handling${B.reset}`);if(x?.apiRoutes){w=x.apiRoutes;let P=Object.keys(w).length;if(P>0)console.log(`${B.blue}Loaded ${B.bright}${P} API route${P>1?"s":""}${B.reset}`)}if(x?.broadcasting?.enabled)try{let{startBroadcasting:P,loadChannels:y}=await import("./chunk-2gtwha4k.js"),Z0=x.broadcasting;await P(Z0);let R0=Z0.port??6001;console.log(`${B.magenta}Broadcasting on ${B.cyan}ws://localhost:${R0}/ws${B.reset}`);let g0=m.join(process.cwd(),"channels.ts");if(e.existsSync(g0))try{let p=await y(g0);console.log(`${B.blue}Loaded ${B.bright}${p} broadcast channel${p!==1?"s":""}${B.blue} from channels.ts${B.reset}`)}catch(p){console.warn(`${B.yellow}Failed to load channels.ts: ${p.message}${B.reset}`)}}catch(P){console.warn(`${B.yellow}Broadcasting failed to start: ${P.message}${B.reset}`)}}catch{}let T=u0(W,"output");e.mkdirSync(T,{recursive:!0});let f=new Map,c=new Set,v=async(R)=>{let x=x6(O,R);if(!x)return null;try{let P=await Bun.build({entrypoints:[x],outdir:T,plugins:[_1],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!P.success)return null;let y=P.outputs.find((Z0)=>Z0.path.endsWith(".html"));if(!y)return null;return await Bun.file(y.path).text()}catch{return null}},S=new Map,k=async(R,x)=>{try{let{processDirectives:P,extractVariables:y,defaultConfig:Z0,loadStxConfig:R0,injectRouterScript:g0}=await import("./chunk-e0f3qs59.js"),{checkCache:p,cacheTemplate:u,readFileCached:g,templateCache:h}=await import("./chunk-8wgsjh65.js"),Y0=await R0(W),f0=(i)=>{if(!i)return i;if(m.isAbsolute(i))return i;return m.resolve(W,i)},C={...Z0,...Y0,...X.stxOptions,autoShell:!0};if(X.debugDirectives)C.debug=!0;C.partialsDir=f0(C.partialsDir),C.componentsDir=f0(C.componentsDir),C.layoutsDir=f0(C.layoutsDir),C.storesDir=f0(C.storesDir||"stores"),C.cachePath=f0(C.cachePath)??u0(W,"cache");let X0=!x&&!X.profile,a=C.cache!==!1;if(a&&X0){let i=h.get(R.filePath);if(i)try{if((await e.promises.stat(R.filePath)).mtime.getTime()<=i.mtime){let q0=!0;for(let _0 of i.dependencies){if(!e.existsSync(_0)){q0=!1;break}if((await e.promises.stat(_0)).mtime.getTime()>i.mtime){q0=!1;break}}if(q0){let _0=i.output;if(q)_0=A$(_0,{preserveHead:!0});let E1=S.get(R.filePath);return{route:R,content:_0,status:E1?.status??await k6(R.filePath),headers:E1?.headers}}}}catch{}let A0=await p(R.filePath,C);if(A0){let N0=A0;if(q)N0=A$(N0,{preserveHead:!0});let q0=S.get(R.filePath);return{route:R,content:N0,status:q0?.status??await k6(R.filePath),headers:q0?.headers}}}let o=a?await g(R.filePath):await Bun.file(R.filePath).text(),K0=_5(o),{classifyAllScripts:d}=await import("./chunk-e0f3qs59.js"),O0=d(o),D0=O0.server.map((i)=>i.content),r=o;for(let i of O0.server)r=r.replace(i.fullTag,"");let n={__filename:R.filePath,__dirname:m.dirname(R.filePath),__stx_options:C,params:x??{},__stx_runtime_head:{}};for(let i of D0)try{await y(i,n,R.filePath)}catch(A0){if(X.stxOptions?.debug)console.error("[stx] variable extraction error",R.filePath,A0?.message||A0)}let S0=new Set,j0;if(X.profile){let i=performance.now();j0=await P(r,n,R.filePath,C,S0);let A0=performance.now()-i,N0=m.relative(W,R.filePath)||R.filePath;console.log(`[stx:profile] ${N0} \u2192 ${A0.toFixed(2)}ms`)}else j0=await P(r,n,R.filePath,C,S0);if(!q)j0=await g0(j0,{router:C.router});{let{interpolateScriptExpressions:i}=await import("./chunk-jmdxn2mq.js");j0=j0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(A0,N0,q0)=>{if(!/function\s+__stx_setup_/.test(q0))return A0;return`<script${N0}>${i(q0,n)}</script>`})}if(q)j0=A$(j0,{preserveHead:!0});if(a&&X0)await u(R.filePath,j0,S0,C);let{extractStreamBoundaries:_3}=await import("./chunk-0d6qgbks.js"),Q1=_3(n),V1=n.__streamTemplates;if(V1&&typeof V1==="object"&&Object.keys(V1).length>0){let i=n.streamBoundaries||{},A0={...C,autoShell:!1},N0=Object.keys(V1).map((_0)=>({id:_0,render:async()=>{let E1=typeof i[_0]==="function"?await i[_0]():void 0;return P(V1[_0],{...n,$boundary:E1},R.filePath,A0,new Set)}})),q0=new Set(N0.map((_0)=>_0.id));Q1=[...(Q1||[]).filter((_0)=>!q0.has(_0.id)),...N0]}if(Q1&&Q1.length>0)c.add(R.pattern);else Q1=void 0;let s5=T1(n),r5=C1(n);if(X0)S.set(R.filePath,{status:s5,headers:r5});return{route:R,content:j0,status:s5??K0,headers:r5,boundaries:Q1}}catch(P){return console.error(`${B.red}Error building ${B.bright}${R.pattern}${B.reset}:`,P),null}},H0=8,G0=async()=>{f.clear(),N.clear();for(let R=0;R<A.length;R+=H0){let x=A.slice(R,R+H0),P=await Promise.all(x.map((y)=>k(y)));for(let y of P)if(y)f.set(y.route.pattern,y)}for(let R=0;R<V.length;R+=H0){let x=V.slice(R,R+H0),P=await Promise.all(x.map(({route:y})=>k(y)));for(let y of P)if(y)N.set(y.route.pattern,y)}return f.size>0};if(console.log(`${B.blue}Building pages...${B.reset}`),!await G0())return console.error(`${B.red}No pages were successfully built${B.reset}`),!1;await L$(W);let v0=Z;try{if(v0=await h0(Z),v0!==Z)console.log(`${B.yellow}Port ${Z} is busy, using port ${v0} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}if(Y){let R=X.hmrPort||v0+1;J=G$({wsPort:R,verbose:!1}),G=J.start(R)}let z0=(R,x)=>{let y=`<script data-stx-route-params>(function(){var p=${JSON.stringify(x).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(R.includes("</head>"))return R.replace("</head>",`${y}</head>`);if(R.includes("<body"))return R.replace(/<body([^>]*)>/,`<body$1>${y}`);return y+R};console.log(`${B.blue}Starting server...${B.reset}`);let Z1=S4({port:v0,async fetch(R){let x=new URL(R.url),P=_?.publicDir||"public",y=m.join(W,P,x.pathname),Z0=m.join(W,x.pathname),R0=m.join(T,x.pathname);if([y,Z0,R0].some((C)=>F(C,W,z)))return new Response("Not Found",{status:404});let[g0,p,u]=await Promise.all([e.promises.stat(y).catch(()=>null),e.promises.stat(Z0).catch(()=>null),e.promises.stat(R0).catch(()=>null)]);if(g0?.isFile()&&!F(y,W,z))return G5(y);if(p?.isFile()&&!F(Z0,W,z))return G5(Z0);if(u?.isFile()&&!F(R0,W,z))return G5(R0);if(x.pathname.startsWith("/_stx/component/")){let C=decodeURIComponent(x.pathname.slice(16));if(C)try{let X0=`<${C} />`,a={...buildConfig,autoShell:!1},o=await processDirectives(X0,{},m.join(W,"components",`${C}.stx`),a,new Set);return new Response(o,{headers:{"Content-Type":"text/html"}})}catch(X0){return new Response(`<div class="stx-async-error">${X0.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(x.pathname==="/_stx/img"){let{handleImageRequest:C}=await import("./chunk-p78b80dp.js"),X0=await C(R,{publicDir:m.join(W,P),cacheDir:u0(W,"cache","img")});if(X0)return X0}if(D)try{let C=await D.handleRequest(R);if(C.status!==404)return C}catch{}if(w[x.pathname])try{return await w[x.pathname](R)}catch(C){return new Response(JSON.stringify({error:C.message}),{status:500,headers:{"Content-Type":"application/json"}})}let g=await j(R);if(g)return g;let h=W5(x.pathname,A);if(h){let C=f.get(h.route.pattern),X0=c.has(h.route.pattern);if(h.route.isDynamic&&Object.keys(h.params).length>0||X0){let a=await k(h.route,h.params);if(a)C=a}if(C){let a=C.status??200,o=C.headers??{},K0=(h.route.filePath?d6(await Bun.file(h.route.filePath).text().catch(()=>"")):null)??{};if(K0.validate){if(!await K0.validate({params:h.params})){let D0=await v(404);if(D0){let r=D0;if(r=await J0(r,W),Y)r=P0(r,G);return new Response(r,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(K0.middleware){let O0=v6(x.pathname,h.params,K0,x.search),D0=g6(O0,null,R,{isServer:!0}),r=await f6(K0.middleware,D0);if(r.redirect){let n=r.redirect.path,S0=r.redirect.options.redirectCode||302,j0=new Headers(r.responseHeaders);return j0.set("Location",n),new Response(null,{status:S0,headers:j0})}if(r.abort){let{statusCode:n,message:S0}=r.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${n}</title></head><body><h1>Error ${n}</h1><p>${S0}</p></body></html>`,{status:n,headers:{"Content-Type":"text/html"}})}if(Object.keys(r.state).length>0){let n=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(r.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;C.content=C.content.replace("</head>",`${n}</head>`)}}let d=C.content;if(q&&i6(R)){let O0=h6(d),D0=u6(d),r=d.match(/<title[^>]*>([\s\S]*?)<\/title>/i),n=r?c6(r[1].trim()):"";if(Object.keys(h.params).length>0)d=z0(d,h.params);d=await J0(d,W);let S0=_?.router?.container||"main";return d=a6(d,S0),new Response(d,{status:a,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":O0.layout,"X-STX-Layout-Group":O0.group,"X-STX-Runtime":D0?"true":"false",...n&&{"X-STX-Title":encodeURIComponent(n)},[m6]:p6(),...B1(),"Cache-Control":j$}})}if(q)d=O$(q,d);if(Object.keys(h.params).length>0)d=z0(d,h.params);if(d=await J0(d,W),Y)d=P0(d,G);if(X.native)if(d.includes("<head>"))d=d.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else d="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+d;if(X.titlebarHidden)if(d.includes("<head>"))d=d.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else d=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${d}`;if(C.boundaries&&C.boundaries.length>0){let{renderStreamingPage:O0,streamToResponse:D0}=await import("./chunk-0d6qgbks.js");return D0(O0(d,C.boundaries,{timeoutMs:30000}),{status:a,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(d,{status:a,headers:{"Content-Type":"text/html",...B1(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...o}})}}if(V.length>0){let C=V.map((a)=>a.route),X0=W5(x.pathname,C);if(X0){let a=N.get(X0.route.pattern);if(a){let o=a.content;if(q)o=O$(q,o);if(Object.keys(X0.params).length>0)o=z0(o,X0.params);if(o=await J0(o,W),Y)o=P0(o,G);return new Response(o,{status:a.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:a}of M)if(a!=="/"&&x.pathname.startsWith(a)){let o=N.get(a)||N.get(a+"/");if(o){let K0=o.content;if(q)K0=O$(q,K0);if(K0=await J0(K0,W),Y)K0=P0(K0,G);return new Response(K0,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let Y0=f.get("/");if(Y0){let C=Y0.content;if(C=await J0(C,W),Y)C=P0(C,G);if(X.native)if(C.includes("<head>"))C=C.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else C="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+C;return new Response(C,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let f0=await v(404);if(f0){let C=f0;if(C=await J0(C,W),Y)C=P0(C,G);return new Response(C,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(R){let x=await v(500);if(x)return new Response(x,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${R}
|
|
1622
|
+
Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),d0(F.url.toString(),()=>{if(Q)m0.watch(J,{recursive:!0}).close();F.stop()}),Q){console.log(`${B.blue}Watching for changes...${B.reset}`);let H=m0.watch(J,{recursive:!0},async(L,O)=>{if(!O)return;if(O.endsWith(".stx")||O.endsWith(".js")||O.endsWith(".ts")||O.endsWith(".md"))console.log(`${B.yellow}File ${B.bright}${O}${B.yellow} changed, rebuilding...${B.reset}`),o0.clear(),t0(),await K()});process.on("SIGINT",()=>{H.close(),F.stop(),process.exit(0)})}return!0}function R6($){return String($??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var{serve:S4}=globalThis.Bun;import e from"fs";import m from"path";async function k6($){try{return _5(await Bun.file($).text())}catch{return}}function G5($){let X=Bun.file($),Z=m.extname($).toLowerCase(),Q={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},J=[".js",".css",".json"].includes(Z)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(X,{headers:{"Content-Type":Q[Z]||"application/octet-stream",...J}})}async function P4($=".",X={}){let Z=X.port||3000,Q=X.watch!==!1,Y=X.hotReload!==!1&&Q,J=null,G=X.hmrPort||Z+1,W=m.resolve($),{loadStxConfig:K}=await import("./chunk-6pdfvpa6.js"),_=await K(W),{createServerApi:U,isServerApiSource:F}=await import("./chunk-x6c2t5dv.js"),z=X.stxOptions?.serverApi??_.serverApi,j=await U(W,z),H=_.root&&_.root!=="."?m.join(W,_.root):W,L=X.pagesDir||_.pagesDir||"pages",O=m.join(H,L);if(!e.existsSync(O)&&!_._layerPageDirs?.some((R)=>e.existsSync(R)))return console.error(`${B.red}Error: No '${L}' directory found${B.reset}`),console.log(`${B.dim}Looked in: ${B.bright}${O}${B.reset}`),console.log(`${B.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${B.reset}`),console.log(`${B.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${B.reset}`),console.log(`${B.dim}Starting fresh? Create ${L}/index.stx for the homepage.${B.reset}`),!1;let A=H$(H,{pagesDir:L,pagesDirs:_._layerPageDirs?[O,..._._layerPageDirs.slice(1)]:void 0});if(A.length===0)return console.error(`${B.red}Error: No page files found in ${B.bright}${O}${B.reset}`),!1;console.log(`${B.blue}Found ${B.bright}${A.length}${B.blue} routes${B.reset}`);let M=_?._pluginPageDirs||[],V=[];for(let{dir:R,prefix:x}of M)if(e.existsSync(R)){let P=H$(m.dirname(R),{pagesDir:m.basename(R)});for(let y of P){let Z0=x==="/"?y.pattern:`${x}${y.pattern==="/"?"":y.pattern}`;V.push({route:{...y,pattern:Z0},prefix:x})}if(P.length>0)console.log(`${B.blue}Plugin pages: ${B.bright}${P.length}${B.blue} routes at ${B.cyan}${x}${B.reset}`)}let N=new Map,q=null,I=null;if(X.stxOptions?.shell!==!1){if(I=await l6(W,X.stxOptions?.shell),I){if(q=await K5(I,X.stxOptions||{}),q)console.log(`${B.blue}Using app shell: ${B.bright}${m.relative(W,I)}${B.reset} ${B.dim}(deprecated: use layouts/default.stx instead)${B.reset}`)}}P6(),await y6(W);let E=b6();if(E.length>0)console.log(`${B.blue}Loaded ${B.bright}${E.length}${B.blue} middleware: ${B.dim}${E.join(", ")}${B.reset}`);let w={},D=null;try{let{loadStxConfig:R}=await import("./chunk-6pdfvpa6.js"),x=await R(W);if(x?.apiRouter)D=x?.apiRouter,console.log(`${B.blue}Using custom router for API handling${B.reset}`);if(x?.apiRoutes){w=x.apiRoutes;let P=Object.keys(w).length;if(P>0)console.log(`${B.blue}Loaded ${B.bright}${P} API route${P>1?"s":""}${B.reset}`)}if(x?.broadcasting?.enabled)try{let{startBroadcasting:P,loadChannels:y}=await import("./chunk-0w12p79j.js"),Z0=x.broadcasting;await P(Z0);let R0=Z0.port??6001;console.log(`${B.magenta}Broadcasting on ${B.cyan}ws://localhost:${R0}/ws${B.reset}`);let g0=m.join(process.cwd(),"channels.ts");if(e.existsSync(g0))try{let p=await y(g0);console.log(`${B.blue}Loaded ${B.bright}${p} broadcast channel${p!==1?"s":""}${B.blue} from channels.ts${B.reset}`)}catch(p){console.warn(`${B.yellow}Failed to load channels.ts: ${p.message}${B.reset}`)}}catch(P){console.warn(`${B.yellow}Broadcasting failed to start: ${P.message}${B.reset}`)}}catch{}let T=u0(W,"output");e.mkdirSync(T,{recursive:!0});let f=new Map,c=new Set,v=async(R)=>{let x=x6(O,R);if(!x)return null;try{let P=await Bun.build({entrypoints:[x],outdir:T,plugins:[_1],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!P.success)return null;let y=P.outputs.find((Z0)=>Z0.path.endsWith(".html"));if(!y)return null;return await Bun.file(y.path).text()}catch{return null}},S=new Map,k=async(R,x)=>{try{let{processDirectives:P,extractVariables:y,defaultConfig:Z0,loadStxConfig:R0,injectRouterScript:g0}=await import("./chunk-6pdfvpa6.js"),{checkCache:p,cacheTemplate:u,readFileCached:g,templateCache:h}=await import("./chunk-7ppey2yt.js"),Y0=await R0(W),f0=(i)=>{if(!i)return i;if(m.isAbsolute(i))return i;return m.resolve(W,i)},C={...Z0,...Y0,...X.stxOptions,autoShell:!0};if(X.debugDirectives)C.debug=!0;C.partialsDir=f0(C.partialsDir),C.componentsDir=f0(C.componentsDir),C.layoutsDir=f0(C.layoutsDir),C.storesDir=f0(C.storesDir||"stores"),C.cachePath=f0(C.cachePath)??u0(W,"cache");let X0=!x&&!X.profile,a=C.cache!==!1;if(a&&X0){let i=h.get(R.filePath);if(i)try{if((await e.promises.stat(R.filePath)).mtime.getTime()<=i.mtime){let q0=!0;for(let _0 of i.dependencies){if(!e.existsSync(_0)){q0=!1;break}if((await e.promises.stat(_0)).mtime.getTime()>i.mtime){q0=!1;break}}if(q0){let _0=i.output;if(q)_0=A$(_0,{preserveHead:!0});let E1=S.get(R.filePath);return{route:R,content:_0,status:E1?.status??await k6(R.filePath),headers:E1?.headers}}}}catch{}let A0=await p(R.filePath,C);if(A0){let N0=A0;if(q)N0=A$(N0,{preserveHead:!0});let q0=S.get(R.filePath);return{route:R,content:N0,status:q0?.status??await k6(R.filePath),headers:q0?.headers}}}let o=a?await g(R.filePath):await Bun.file(R.filePath).text(),K0=_5(o),{classifyAllScripts:d}=await import("./chunk-6pdfvpa6.js"),O0=d(o),D0=O0.server.map((i)=>i.content),r=o;for(let i of O0.server)r=r.replace(i.fullTag,"");let n={__filename:R.filePath,__dirname:m.dirname(R.filePath),__stx_options:C,params:x??{},__stx_runtime_head:{}};for(let i of D0)try{await y(i,n,R.filePath)}catch(A0){if(X.stxOptions?.debug)console.error("[stx] variable extraction error",R.filePath,A0?.message||A0)}let S0=new Set,j0;if(X.profile){let i=performance.now();j0=await P(r,n,R.filePath,C,S0);let A0=performance.now()-i,N0=m.relative(W,R.filePath)||R.filePath;console.log(`[stx:profile] ${N0} \u2192 ${A0.toFixed(2)}ms`)}else j0=await P(r,n,R.filePath,C,S0);if(!q)j0=await g0(j0,{router:C.router});{let{interpolateScriptExpressions:i}=await import("./chunk-0p52xkk9.js");j0=j0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(A0,N0,q0)=>{if(!/function\s+__stx_setup_/.test(q0))return A0;return`<script${N0}>${i(q0,n)}</script>`})}if(q)j0=A$(j0,{preserveHead:!0});if(a&&X0)await u(R.filePath,j0,S0,C);let{extractStreamBoundaries:_3}=await import("./chunk-xn226qe0.js"),Q1=_3(n),V1=n.__streamTemplates;if(V1&&typeof V1==="object"&&Object.keys(V1).length>0){let i=n.streamBoundaries||{},A0={...C,autoShell:!1},N0=Object.keys(V1).map((_0)=>({id:_0,render:async()=>{let E1=typeof i[_0]==="function"?await i[_0]():void 0;return P(V1[_0],{...n,$boundary:E1},R.filePath,A0,new Set)}})),q0=new Set(N0.map((_0)=>_0.id));Q1=[...(Q1||[]).filter((_0)=>!q0.has(_0.id)),...N0]}if(Q1&&Q1.length>0)c.add(R.pattern);else Q1=void 0;let s5=T1(n),r5=C1(n);if(X0)S.set(R.filePath,{status:s5,headers:r5});return{route:R,content:j0,status:s5??K0,headers:r5,boundaries:Q1}}catch(P){return console.error(`${B.red}Error building ${B.bright}${R.pattern}${B.reset}:`,P),null}},H0=8,G0=async()=>{f.clear(),N.clear();for(let R=0;R<A.length;R+=H0){let x=A.slice(R,R+H0),P=await Promise.all(x.map((y)=>k(y)));for(let y of P)if(y)f.set(y.route.pattern,y)}for(let R=0;R<V.length;R+=H0){let x=V.slice(R,R+H0),P=await Promise.all(x.map(({route:y})=>k(y)));for(let y of P)if(y)N.set(y.route.pattern,y)}return f.size>0};if(console.log(`${B.blue}Building pages...${B.reset}`),!await G0())return console.error(`${B.red}No pages were successfully built${B.reset}`),!1;await L$(W);let v0=Z;try{if(v0=await h0(Z),v0!==Z)console.log(`${B.yellow}Port ${Z} is busy, using port ${v0} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}if(Y){let R=X.hmrPort||v0+1;J=G$({wsPort:R,verbose:!1}),G=J.start(R)}let z0=(R,x)=>{let y=`<script data-stx-route-params>(function(){var p=${JSON.stringify(x).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(R.includes("</head>"))return R.replace("</head>",`${y}</head>`);if(R.includes("<body"))return R.replace(/<body([^>]*)>/,`<body$1>${y}`);return y+R};console.log(`${B.blue}Starting server...${B.reset}`);let Z1=S4({port:v0,async fetch(R){let x=new URL(R.url),P=_?.publicDir||"public",y=m.join(W,P,x.pathname),Z0=m.join(W,x.pathname),R0=m.join(T,x.pathname);if([y,Z0,R0].some((C)=>F(C,W,z)))return new Response("Not Found",{status:404});let[g0,p,u]=await Promise.all([e.promises.stat(y).catch(()=>null),e.promises.stat(Z0).catch(()=>null),e.promises.stat(R0).catch(()=>null)]);if(g0?.isFile()&&!F(y,W,z))return G5(y);if(p?.isFile()&&!F(Z0,W,z))return G5(Z0);if(u?.isFile()&&!F(R0,W,z))return G5(R0);if(x.pathname.startsWith("/_stx/component/")){let C=decodeURIComponent(x.pathname.slice(16));if(C)try{let X0=`<${C} />`,a={...buildConfig,autoShell:!1},o=await processDirectives(X0,{},m.join(W,"components",`${C}.stx`),a,new Set);return new Response(o,{headers:{"Content-Type":"text/html"}})}catch(X0){return new Response(`<div class="stx-async-error">${X0.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(x.pathname==="/_stx/img"){let{handleImageRequest:C}=await import("./chunk-sd57d9bq.js"),X0=await C(R,{publicDir:m.join(W,P),cacheDir:u0(W,"cache","img")});if(X0)return X0}if(D)try{let C=await D.handleRequest(R);if(C.status!==404)return C}catch{}if(w[x.pathname])try{return await w[x.pathname](R)}catch(C){return new Response(JSON.stringify({error:C.message}),{status:500,headers:{"Content-Type":"application/json"}})}let g=await j(R);if(g)return g;let h=W5(x.pathname,A);if(h){let C=f.get(h.route.pattern),X0=c.has(h.route.pattern);if(h.route.isDynamic&&Object.keys(h.params).length>0||X0){let a=await k(h.route,h.params);if(a)C=a}if(C){let a=C.status??200,o=C.headers??{},K0=(h.route.filePath?d6(await Bun.file(h.route.filePath).text().catch(()=>"")):null)??{};if(K0.validate){if(!await K0.validate({params:h.params})){let D0=await v(404);if(D0){let r=D0;if(r=await J0(r,W),Y)r=P0(r,G);return new Response(r,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(K0.middleware){let O0=v6(x.pathname,h.params,K0,x.search),D0=g6(O0,null,R,{isServer:!0}),r=await f6(K0.middleware,D0);if(r.redirect){let n=r.redirect.path,S0=r.redirect.options.redirectCode||302,j0=new Headers(r.responseHeaders);return j0.set("Location",n),new Response(null,{status:S0,headers:j0})}if(r.abort){let{statusCode:n,message:S0}=r.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${n}</title></head><body><h1>Error ${n}</h1><p>${S0}</p></body></html>`,{status:n,headers:{"Content-Type":"text/html"}})}if(Object.keys(r.state).length>0){let n=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(r.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;C.content=C.content.replace("</head>",`${n}</head>`)}}let d=C.content;if(q&&i6(R)){let O0=h6(d),D0=u6(d),r=d.match(/<title[^>]*>([\s\S]*?)<\/title>/i),n=r?c6(r[1].trim()):"";if(Object.keys(h.params).length>0)d=z0(d,h.params);d=await J0(d,W);let S0=_?.router?.container||"main";return d=a6(d,S0),new Response(d,{status:a,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":O0.layout,"X-STX-Layout-Group":O0.group,"X-STX-Runtime":D0?"true":"false",...n&&{"X-STX-Title":encodeURIComponent(n)},[m6]:p6(),...B1(),"Cache-Control":j$}})}if(q)d=O$(q,d);if(Object.keys(h.params).length>0)d=z0(d,h.params);if(d=await J0(d,W),Y)d=P0(d,G);if(X.native)if(d.includes("<head>"))d=d.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else d="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+d;if(X.titlebarHidden)if(d.includes("<head>"))d=d.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else d=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${d}`;if(C.boundaries&&C.boundaries.length>0){let{renderStreamingPage:O0,streamToResponse:D0}=await import("./chunk-xn226qe0.js");return D0(O0(d,C.boundaries,{timeoutMs:30000}),{status:a,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(d,{status:a,headers:{"Content-Type":"text/html",...B1(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...o}})}}if(V.length>0){let C=V.map((a)=>a.route),X0=W5(x.pathname,C);if(X0){let a=N.get(X0.route.pattern);if(a){let o=a.content;if(q)o=O$(q,o);if(Object.keys(X0.params).length>0)o=z0(o,X0.params);if(o=await J0(o,W),Y)o=P0(o,G);return new Response(o,{status:a.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:a}of M)if(a!=="/"&&x.pathname.startsWith(a)){let o=N.get(a)||N.get(a+"/");if(o){let K0=o.content;if(q)K0=O$(q,K0);if(K0=await J0(K0,W),Y)K0=P0(K0,G);return new Response(K0,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let Y0=f.get("/");if(Y0){let C=Y0.content;if(C=await J0(C,W),Y)C=P0(C,G);if(X.native)if(C.includes("<head>"))C=C.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else C="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+C;return new Response(C,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let f0=await v(404);if(f0){let C=f0;if(C=await J0(C,W),Y)C=P0(C,G);return new Response(C,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(R){let x=await v(500);if(x)return new Response(x,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${R}
|
|
1623
1623
|
${R.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
|
|
1624
1624
|
${B.blue}stx${B.reset} ${B.green}${process.env.stx_VERSION||"v0.0.10"}${B.reset} ${B.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${B.reset}`),console.log(`
|
|
1625
1625
|
${B.bright}\u2192 ${B.cyan}http://localhost:${v0}/${B.reset}`),Y)console.log(`${B.dim} HMR: ws://localhost:${G}${B.reset}`);console.log(`
|
|
1626
1626
|
${B.yellow}Routes:${B.reset}`);let W0=[...S6(A,W)];for(let{route:R}of V)W0.push(`${R.pattern}`);if(W0.forEach((R,x)=>{let y=x===W0.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${B.green}${y}${B.reset}${R}`)}),console.log(`
|
|
1627
|
-
Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),d0(Z1.url.toString(),()=>{if(J)D1();Z1.stop()}),X.native){let R,x=m.join(O,"index.stx");if(e.existsSync(x)){let y=await Bun.file(x).text();R=Z$(y)}let P=_?.app?.window??{};await G1(v0,{title:_?.app?.head?.title||m.basename(W)||"stx App",width:P.width,height:P.height,darkMode:P.darkMode,hotReload:P.hotReload,titlebarHidden:P.titlebarHidden??X.titlebarHidden===!0,nativeSidebar:!!R,sidebarConfig:R})}if(Q){console.log(`${B.blue}Watching for changes...${B.reset}`);let R=(p)=>{return p.startsWith("public/")||p.startsWith("public\\")},x=(p)=>{let u=p.toLowerCase();return u.endsWith(".stx")||u.endsWith(".html")||u.endsWith(".md")},P=new Map,y=()=>{let p=new Set([W,..._._layerGraph?.layers.map((u)=>u.root)??[],..._._layerGraph?.configDependencies.map((u)=>m.dirname(u))??[]].filter((u)=>e.existsSync(u)).map((u)=>e.realpathSync(u)));for(let u of _._layerGraph?.layers??[])for(let g of Object.values(u.resources)){if(!e.existsSync(g))continue;let h=e.realpathSync(g);if(![...p].some((Y0)=>h===Y0||h.startsWith(`${Y0}${m.sep}`)))p.add(h)}for(let[u,g]of P)if(!p.has(u))g.close(),P.delete(u);for(let u of p)if(!P.has(u)&&e.existsSync(u))P.set(u,e.watch(u,{recursive:!0},(g,h)=>{R0(u,g,h).catch((Y0)=>console.error("[stx] Layer rebuild failed:",Y0))}))},Z0=Promise.resolve(),R0=(p,u,g)=>{return Z0=Z0.catch(()=>{}).then(()=>g0(p,u,g)),Z0},g0=async(p,u,g)=>{if(!g||J$(g))return;if(Y$(g)){if(_._layerGraph){let h=await K(W);Object.assign(_,h),A.splice(0,A.length,...H$(H,{pagesDir:L,pagesDirs:h._layerPageDirs?[O,...h._layerPageDirs.slice(1)]:void 0})),y()}if(R(g)){if(console.log(`${B.cyan}${g} changed${B.reset}`),Y&&J)J.reload(g)}else if(x(g)){console.log(`${B.yellow}${g} changed, rebuilding...${B.reset}`),o0.clear(),t0();try{let{invalidateFileCache:h,templateCache:Y0}=await import("./chunk-
|
|
1627
|
+
Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),d0(Z1.url.toString(),()=>{if(J)D1();Z1.stop()}),X.native){let R,x=m.join(O,"index.stx");if(e.existsSync(x)){let y=await Bun.file(x).text();R=Z$(y)}let P=_?.app?.window??{};await G1(v0,{title:_?.app?.head?.title||m.basename(W)||"stx App",width:P.width,height:P.height,darkMode:P.darkMode,hotReload:P.hotReload,titlebarHidden:P.titlebarHidden??X.titlebarHidden===!0,nativeSidebar:!!R,sidebarConfig:R})}if(Q){console.log(`${B.blue}Watching for changes...${B.reset}`);let R=(p)=>{return p.startsWith("public/")||p.startsWith("public\\")},x=(p)=>{let u=p.toLowerCase();return u.endsWith(".stx")||u.endsWith(".html")||u.endsWith(".md")},P=new Map,y=()=>{let p=new Set([W,..._._layerGraph?.layers.map((u)=>u.root)??[],..._._layerGraph?.configDependencies.map((u)=>m.dirname(u))??[]].filter((u)=>e.existsSync(u)).map((u)=>e.realpathSync(u)));for(let u of _._layerGraph?.layers??[])for(let g of Object.values(u.resources)){if(!e.existsSync(g))continue;let h=e.realpathSync(g);if(![...p].some((Y0)=>h===Y0||h.startsWith(`${Y0}${m.sep}`)))p.add(h)}for(let[u,g]of P)if(!p.has(u))g.close(),P.delete(u);for(let u of p)if(!P.has(u)&&e.existsSync(u))P.set(u,e.watch(u,{recursive:!0},(g,h)=>{R0(u,g,h).catch((Y0)=>console.error("[stx] Layer rebuild failed:",Y0))}))},Z0=Promise.resolve(),R0=(p,u,g)=>{return Z0=Z0.catch(()=>{}).then(()=>g0(p,u,g)),Z0},g0=async(p,u,g)=>{if(!g||J$(g))return;if(Y$(g)){if(_._layerGraph){let h=await K(W);Object.assign(_,h),A.splice(0,A.length,...H$(H,{pagesDir:L,pagesDirs:h._layerPageDirs?[O,...h._layerPageDirs.slice(1)]:void 0})),y()}if(R(g)){if(console.log(`${B.cyan}${g} changed${B.reset}`),Y&&J)J.reload(g)}else if(x(g)){console.log(`${B.yellow}${g} changed, rebuilding...${B.reset}`),o0.clear(),t0();try{let{invalidateFileCache:h,templateCache:Y0}=await import("./chunk-7ppey2yt.js");h(m.resolve(p,g)),Y0.delete(m.resolve(p,g))}catch{}if(I&&g){if(m.resolve(p,g)===I||m.basename(I)===g){let Y0=await K5(I,X.stxOptions||{});if(Y0)q=Y0}}if(await G0(),await F$(W),Y&&J)J.reload(g)}else{console.log(`${B.yellow}${g} changed, rebuilding...${B.reset}`),o0.clear(),t0();try{let{invalidateFileCache:h,templateCache:Y0}=await import("./chunk-7ppey2yt.js");h(m.resolve(p,g)),Y0.delete(m.resolve(p,g))}catch{}if(await G0(),Y&&J)J.reload(g)}}else if(Q$(g)){if(console.log(`${B.cyan}CSS ${g} changed${B.reset}`),Y&&J)J.updateCss(g)}};y(),process.on("SIGINT",()=>{for(let p of P.values())p.close();if(J)D1();Z1.stop(),process.exit(0)})}return!0}var b={enabled:!1,components:new Map,stores:new Map,events:[],performance:[],selectedComponent:null,selectedStore:null,maxEvents:1000,maxPerformance:500};function b4($={}){if(typeof window>"u")return;b.enabled=!0,b.maxEvents=$.maxEvents||1000,b.maxPerformance=$.maxPerformance||500,window.__STX_DEVTOOLS__={getState:()=>b,getComponents:()=>Array.from(b.components.values()),getComponent:(X)=>b.components.get(X),getStores:()=>Array.from(b.stores.values()),getStore:(X)=>b.stores.get(X),getEvents:()=>b.events,getPerformance:()=>b.performance,selectComponent:(X)=>B5(X),selectStore:(X)=>v4(X),inspectElement:(X)=>g4(X),highlightComponent:(X)=>t6(X),clearHighlight:()=>e6(),logComponentTree:()=>f4(),logStoreState:(X)=>h4(X),timeTravel:(X,Z)=>d4(X,Z)},m4(),u4(),console.log("%c[STX DevTools] Enabled","color: #10b981; font-weight: bold;")}function y4(){b.enabled=!1,delete window.__STX_DEVTOOLS__;let $=document.getElementById("stx-devtools-panel");if($)$.remove();console.log("%c[STX DevTools] Disabled","color: #ef4444;")}function s6($){if(!b.enabled)return;let X=b.components.get($);if(X){if(X.parentId){let Z=b.components.get(X.parentId);if(Z)Z.children=Z.children.filter((Q)=>Q!==$)}b.components.delete($),U5({timestamp:Date.now(),type:"component:unmounted",componentId:$,payload:{name:X.name}})}}function n6($,X,Z={},Q=[]){if(!b.enabled)return;let Y={id:$,state:X,getters:Z,actions:Q,history:[{timestamp:Date.now(),type:"state",name:"__init__",newValue:X}]};b.stores.set($,Y),U5({timestamp:Date.now(),type:"store:registered",payload:{id:$,state:X}})}function o6($,X,Z,Q,Y="state"){if(!b.enabled)return;let J=b.stores.get($);if(J){let G={timestamp:Date.now(),type:Y,name:X,oldValue:Z,newValue:Q,stack:Error().stack};if(J.history.push(G),J.history.length>100)J.history=J.history.slice(-100);if(Y==="state")J.state={...J.state,[X]:Q};U5({timestamp:Date.now(),type:`store:${Y}`,payload:{storeId:$,name:X,oldValue:Z,newValue:Q}})}}function U5($){if(!b.enabled)return;if(b.events.push($),b.events.length>b.maxEvents)b.events=b.events.slice(-b.maxEvents);if(typeof window<"u")window.dispatchEvent(new CustomEvent("stx:devtools:event",{detail:$}))}function B5($){b.selectedComponent=$;let X=b.components.get($);if(X)t6($),console.log("%c[STX DevTools] Selected component:","color: #3b82f6;",X);return X}function v4($){b.selectedStore=$;let X=b.stores.get($);if(X)console.log("%c[STX DevTools] Selected store:","color: #8b5cf6;",X);return X}function g4($){let X=$;while(X){let Z=X.getAttribute("data-stx-component-id");if(Z)return B5(Z);X=X.parentElement}console.log("%c[STX DevTools] No component found for element","color: #f59e0b;");return}function t6($){e6();let X=b.components.get($);if(X?.element){let Z=document.createElement("div");Z.id="stx-devtools-highlight",Z.style.cssText=`
|
|
1628
1628
|
position: absolute;
|
|
1629
1629
|
background: rgba(59, 130, 246, 0.2);
|
|
1630
1630
|
border: 2px solid #3b82f6;
|
|
@@ -2893,9 +2893,9 @@ describe('Example', () => {
|
|
|
2893
2893
|
</footer>
|
|
2894
2894
|
@yield('scripts')
|
|
2895
2895
|
</body>
|
|
2896
|
-
</html>`}function JZ(){return"<!-- Hero section -->"}function GZ(){return"<!-- Features -->"}function WZ(){return"<!-- Pricing -->"}function KZ(){return"<!-- Button -->"}function g1($){if(!v1($))A5($,{recursive:!0})}function _Z(){if(v1("bun.lockb"))return"bun";if(v1("pnpm-lock.yaml"))return"pnpm";if(v1("yarn.lock"))return"yarn";return"bun"}function N5($){return $.replace(/[-_\s]+(.)?/g,(X,Z)=>Z?Z.toUpperCase():"").replace(/^./,(X)=>X.toUpperCase())}function UZ($){return $.replace(/[-_\s]+(.)?/g,(X,Z)=>Z?Z.toUpperCase():"").replace(/^./,(X)=>X.toLowerCase())}function e0($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var{serve:BZ}=globalThis.Bun;import f1 from"fs";import I0 from"path";function a2($,X=200,Z={}){return new Response($,{status:X,headers:{"Content-Type":"text/html; charset=utf-8",...Z}})}async function q5($){let{loadStxConfig:X}=await import("./chunk-
|
|
2896
|
+
</html>`}function JZ(){return"<!-- Hero section -->"}function GZ(){return"<!-- Features -->"}function WZ(){return"<!-- Pricing -->"}function KZ(){return"<!-- Button -->"}function g1($){if(!v1($))A5($,{recursive:!0})}function _Z(){if(v1("bun.lockb"))return"bun";if(v1("pnpm-lock.yaml"))return"pnpm";if(v1("yarn.lock"))return"yarn";return"bun"}function N5($){return $.replace(/[-_\s]+(.)?/g,(X,Z)=>Z?Z.toUpperCase():"").replace(/^./,(X)=>X.toUpperCase())}function UZ($){return $.replace(/[-_\s]+(.)?/g,(X,Z)=>Z?Z.toUpperCase():"").replace(/^./,(X)=>X.toLowerCase())}function e0($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var{serve:BZ}=globalThis.Bun;import f1 from"fs";import I0 from"path";function a2($,X=200,Z={}){return new Response($,{status:X,headers:{"Content-Type":"text/html; charset=utf-8",...Z}})}async function q5($){let{loadStxConfig:X}=await import("./chunk-nabannen.js");return{...await X($.configDir??process.cwd()),...$.stxOptions??{}}}async function LZ($={}){let{port:X=3000,root:Z=".",watch:Q=!0,onRequest:Y,routes:J={},middleware:G=[],on404:W,onError:K}=$,_=I0.resolve(Z),U=await q5($),F=I0.resolve($.configDir??process.cwd()),z=await M5(F,U.serverApi),j=new Map;async function H(N){let q=f1.statSync(N),I=`${N}:${q.mtimeMs}`,E=j.get(I);if(E)return{content:E.content,status:E.status,headers:E.headers};for(let W0 of j.keys())if(W0.startsWith(`${N}:`)&&W0!==I)j.delete(W0);let w=await Bun.file(N).text(),D=w,T=K$(w);if(T)D=T.content.trim();let f=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,c=[],v=[],S;while((S=f.exec(w))!==null){let W0=S[1],R=S[2],x=S[0];if(W0.includes("server"))v.push(R);else c.push(x)}let k=w.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi)||[],H0=D.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),G0={__filename:N,__dirname:I0.dirname(N),__stx_options:U};for(let W0 of v)await M0(W0,G0,N);let z0=await V0(H0,G0,N,U,new Set);if(k.length>0){let W0=k.join(`
|
|
2897
2897
|
`);if(z0.match(/(<\/head>)/i))z0=z0.replace(/(<\/head>)/i,`${W0}
|
|
2898
|
-
$1`)}if(c.length>0){let{interpolateScriptsInTemplate:W0}=await import("./chunk-
|
|
2898
|
+
$1`)}if(c.length>0){let{interpolateScriptsInTemplate:W0}=await import("./chunk-0p52xkk9.js"),R=W0(c.join(`
|
|
2899
2899
|
`),G0);if(z0.match(/(<\/body>)/i))z0=z0.replace(/(<\/body>)/i,`${R}
|
|
2900
2900
|
$1`);else z0+=`
|
|
2901
2901
|
${R}`}let Z1=T1(G0),i$=C1(G0);return j.set(I,{content:z0,mtime:q.mtimeMs,status:Z1,headers:i$}),{content:z0,status:Z1,headers:i$}}async function L(N){let q=f1.statSync(N),I=`${N}:${q.mtimeMs}`,E=j.get(I);if(E)return E.content;let{content:w}=await T0(N,U);return j.set(I,{content:w,mtime:q.mtimeMs}),w}function O(N){let q=N.startsWith("/")?N.slice(1):N,I=[q,`${q}.stx`,`${q}.md`,`${q}.html`,I0.join(q,"index.stx"),I0.join(q,"index.md"),I0.join(q,"index.html")];for(let E of[_,...U._layerPageDirs??[]])for(let w of I){let D=I0.resolve(E,w);if(!D.startsWith(`${I0.resolve(E)}${I0.sep}`))continue;if(f1.existsSync(D)&&f1.statSync(D).isFile())return D}return null}async function A(N){if(U._layerGraph){let E=await q5($);if(E._layerGraph!==U._layerGraph)Object.assign(U,E),j.clear()}let q=new URL(N.url),I=async()=>{if(J[q.pathname])return await J[q.pathname](N);if(Y){let D=await Y(N);if(D)return D}if(U.apiRouter){let D=await U.apiRouter.handleRequest(N);if(D.status!==404)return D}if(U.apiRoutes?.[q.pathname])return U.apiRoutes[q.pathname](N);let E=await z(N);if(E)return E;let w=O(q.pathname);if(!w||j8(w,F,U.serverApi)){if(W)return await W(N);return new Response("Not Found",{status:404})}try{let D,T="text/html",f,c;if(w.endsWith(".stx")){let v=await H(w);D=v.content,f=v.status,c=v.headers}else if(w.endsWith(".md"))D=await L(w);else if(w.endsWith(".html"))D=await Bun.file(w).text();else if(w.endsWith(".css"))D=await Bun.file(w).text(),T="text/css";else if(w.endsWith(".js"))D=await Bun.file(w).text(),T="text/javascript";else if(w.endsWith(".json"))D=await Bun.file(w).text(),T="application/json";else return new Response(Bun.file(w));return new Response(D,{status:f??200,headers:{"Content-Type":T,...c}})}catch(D){if(K)return await K(D,N);let T=D instanceof Error?D.message:String(D),c=U?.debug===!0?`<h1>Error</h1><pre>${T}
|
|
@@ -4327,7 +4327,7 @@ else {
|
|
|
4327
4327
|
\u26A0\uFE0F Built ${Z.views.length} views with ${Z.errors.length} errors`);return Z}function K9($,X){let Z=T$.watch($.viewsDir,{recursive:!0},async(Q,Y)=>{if(!Y)return;if(Y.endsWith(".stx")||Y.endsWith(".ts")||Y.endsWith(".js")){if($.debug)console.log(`
|
|
4328
4328
|
File changed: ${Y}, rebuilding...`);let J=await yQ($);X?.(J)}});return{close:()=>Z.close()}}async function _9($,X={},Z={}){let Q={...Z,skipDefaultSeoTags:!0,skipSignalsRuntime:!0},Y=await P7($,X,Q);Y=await vQ(Y),Y=Y.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),Y=Y.replace(/<style\b([^>]*)>[\s\S]*?<\/style>/gi,(G,W)=>/\bdata-(?:css=["']generated["']|stx-)/i.test(W)?"":G),Y=Y.replace(/<!--\s*stx SEO Tags\s*-->/gi,""),Y=Y.replace(/\n\s*\n\s*\n/g,`
|
|
4329
4329
|
|
|
4330
|
-
`).trim();let J=hQ(Y);return{html:Y,text:J}}async function vQ($){try{let{generateCss:X,extractClassNames:Z}=await import("./chunk-
|
|
4330
|
+
`).trim();let J=hQ(Y);return{html:Y,text:J}}async function vQ($){try{let{generateCss:X,extractClassNames:Z}=await import("./chunk-r7q89mv2.js");if(Z($).size===0)return $;let Y=await X($);if(!Y)return $;let J=gQ(Y);if(J.size===0)return $;return $.replace(/(<[a-z][a-z0-9]*)((?:\s+[a-z][a-z0-9-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s+)class\s*=\s*"([^"]*)"((?:\s+[a-z][a-z0-9-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)(\/?>)/gi,(G,W,K,_,U,F)=>{let z=_.split(/\s+/).filter(Boolean),j=[];for(let A of z){let M=J.get(A);if(M)j.push(M)}if(j.length===0)return`${W}${K}class="${_}"${U}${F}`;let H=j.join("; "),O=`${K}${U}`.match(/style\s*=\s*"([^"]*)"/);if(O){let A=`${H}; ${O[1]}`,M=K.replace(/style\s*=\s*"[^"]*"/,`style="${A}"`),V=U.replace(/style\s*=\s*"[^"]*"/,`style="${A}"`);return`${W}${M}class="${_}"${V}${F}`}return`${W}${K}class="${_}" style="${H}"${U}${F}`})}catch{return $}}function gQ($){let X=new Map,Z=/\.([a-zA-Z0-9_-]+(?:\\:[a-zA-Z0-9_-]+)*)\s*\{([^}]+)\}/g,Q=Z.exec($);while(Q!==null){let Y=Q[1].replace(/\\/g,""),J=Q[2].split(";").map((G)=>G.trim()).filter(Boolean).join("; ");if(J)X.set(Y,J);Q=Z.exec($)}return X}function fQ($,X){let Z=X.replace(/<[^>]*>/g,"").replace(/\s+/g," ").trim(),Q=$.replace(/&/g,"&").trim();if(!Q||Q.startsWith("#")||/^javascript:/i.test(Q))return Z;let Y=Q.replace(/^mailto:/i,"").replace(/^https?:\/\//i,"").replace(/\/$/,"");if(!Z)return Q.replace(/^mailto:/i,"");if(Z.replace(/^https?:\/\//i,"").replace(/\/$/,"")===Y)return Z;return`${Z} (${Q.replace(/^mailto:/i,"")})`}function hQ($){return $.replace(/<head\b[\s\S]*?<\/head>/gi,"").replace(/<(style|script)\b[\s\S]*?<\/\1>/gi,"").replace(/<(div|span|p)\b[^>]*\bstyle="[^"]*display:\s*none[^"]*"[^>]*>[\s\S]*?<\/\1>/gi,"").replace(/<a\b[^>]*?\bhref\s*=\s*(?:"([^"]*)"|'([^']*)')[^>]*>([\s\S]*?)<\/a>/gi,(X,Z,Q,Y)=>fQ(Z??Q??"",Y)).replace(/<br\s*\/?>/gi,`
|
|
4331
4331
|
`).replace(/<\/(p|div|h[1-6]|li|tr)>/gi,`
|
|
4332
4332
|
`).replace(/<\/td>/gi,"\t").replace(/<[^>]*>/g,"").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/©/g,"(c)").replace(/·/g,"-").replace(/\n\s*\n\s*\n/g,`
|
|
4333
4333
|
|
|
@@ -4397,7 +4397,7 @@ ${I}`}function L0($){return $.replace(/&/g,"&").replace(/"/g,""").repla
|
|
|
4397
4397
|
`;let Z=$.sitemap!==!1?`Sitemap: ${$.url.replace(/\/$/,"")}/sitemap.xml
|
|
4398
4398
|
`:"";if(X==="disallow")return["User-agent: *","Disallow: /","",Z].filter(Boolean).join(`
|
|
4399
4399
|
`);return["User-agent: *","Allow: /","",Z].filter(Boolean).join(`
|
|
4400
|
-
`)}var M1=null;async function WY(){if(M1!==null)return M1;try{let $=await import("./chunk-
|
|
4400
|
+
`)}var M1=null;async function WY(){if(M1!==null)return M1;try{let $=await import("./chunk-t9m81dj8.js");if(typeof $.getRouterScript==="function")M1=$.getRouterScript();else M1=""}catch{M1=""}return M1}async function m5($,X){let Z=await WY();if(!Z)return $;let Q={interceptAllLinks:!0,container:"main",...X},J=`${`<script>window.__stxRouterConfig=${JSON.stringify(Q)};</script>
|
|
4401
4401
|
`}<script>${Z}</script>`;if(/<\/body>/i.test($))return $.replace(/<\/body>/i,`${J}
|
|
4402
4402
|
</body>`);return`${$}
|
|
4403
4403
|
${J}`}var KY=`window.__stxThemeIcon=function(isDark){try{var want=isDark?'dark':'light';var pick=document.querySelector('link[rel~="icon"][media*="prefers-color-scheme: '+want+'"]');if(!pick)return;var live=document.querySelector('link[rel~="icon"]:not([media])');if(!live){live=document.createElement('link');live.setAttribute('rel','icon');document.head.appendChild(live)}if(pick.type)live.setAttribute('type',pick.type);var href=pick.getAttribute('href');if(live.getAttribute('href')!==href)live.setAttribute('href',href)}catch(e){}};`,_Y=($,X,Z,Q)=>`(function(){${KY}function read(){try{var k=${JSON.stringify(X)};var t=localStorage.getItem(k);return t===null?(${JSON.stringify($)}==='dark'||(${JSON.stringify($)}==='auto'&&window.matchMedia('(prefers-color-scheme: dark)').matches)):t==='dark'}catch(e){return ${JSON.stringify($)}==='dark'}}function apply(){var isDark=read();var html=document.documentElement;html.classList[isDark?'add':'remove']('dark');var color=isDark?${JSON.stringify(Q)}:${JSON.stringify(Z)};if(!document.head)return;var tc=document.querySelector('meta[name="theme-color"]:not([media])');if(!tc){tc=document.createElement('meta');tc.setAttribute('name','theme-color');tc.setAttribute('data-stx-theme-meta','1')}tc.setAttribute('content',color);if(tc!==document.head.firstChild){document.head.insertBefore(tc,document.head.firstChild)}if(window.__stxThemeIcon)window.__stxThemeIcon(isDark)}apply();window.addEventListener('stx:navigate',apply);window.addEventListener('popstate',apply)})();`,UY=($,X,Z)=>`document.addEventListener('click',function(e){var t=e.target&&e.target.closest&&e.target.closest('#theme-toggle');if(!t)return;var html=document.documentElement;var isDark=html.classList.toggle('dark');try{localStorage.setItem(${JSON.stringify($)},isDark?'dark':'light')}catch(e){}var tc=document.querySelector('meta[name="theme-color"]:not([media])');if(tc)tc.setAttribute('content',isDark?${JSON.stringify(Z)}:${JSON.stringify(X)});if(window.__stxThemeIcon)window.__stxThemeIcon(isDark)});`;function b$($,X){if(X.theme===!1)return $;let Z=$.includes(s7),Q=typeof X.theme==="object"&&X.theme!==null?X.theme:{},Y=Q.default??"dark",J=Q.storageKey??"theme",G=Q.colors?.light??"#ffffff",W=Q.colors?.dark??"#000000";if(Y==="dark"&&!Z){if(!/<html\b[^>]*\bclass=/.test($))$=$.replace(/<html\b([^>]*)>/i,'<html$1 class="dark">');else if(!/<html\b[^>]*\bclass="[^"]*\bdark\b/.test($))$=$.replace(/<html\b([^>]*\bclass=")([^"]*)(")/i,"<html$1$2 dark$3")}if(!$.includes("data-stx-theme-meta")&&/<head\b[^>]*>/i.test($)){let K=['<meta name="color-scheme" content="dark light" data-stx-theme-meta="1">',`<meta name="theme-color" media="(prefers-color-scheme: light)" content="${G}" data-stx-theme-meta="1">`,`<meta name="theme-color" media="(prefers-color-scheme: dark)" content="${W}" data-stx-theme-meta="1">`].join(`
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import C from"path";var G=".stx",K="STX_DIR",J=null;function O(j){J=j?.trim()||null}function H(){return process.env[K]?.trim()||J||G}function Q(j=process.cwd(),...q){let B=H();return C.isAbsolute(B)?C.join(B,...q):C.join(j,B,...q)}function W(j){if(!j||C.isAbsolute(j))return j;let q=j.replace(/\\/g,"/");if(q!==G&&!q.startsWith(`${G}/`))return j;let B=q.slice(G.length+1);return B?C.join(H(),B):H()}
|
|
3
|
-
export{G as
|
|
3
|
+
export{G as ot,K as pt,O as qt,H as rt,Q as st,W as tt};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
2
|
+
import"./chunk-m8kem5ca.js";import v from"fs";import H from"path";import{gzipSync as z}from"zlib";import{createHash as g}from"crypto";var D={".js":"js",".mjs":"js",".cjs":"js",".ts":"js",".jsx":"js",".tsx":"js",".css":"css",".scss":"css",".sass":"css",".less":"css",".html":"html",".htm":"html",".png":"image",".jpg":"image",".jpeg":"image",".gif":"image",".svg":"image",".webp":"image",".avif":"image",".ico":"image",".woff":"font",".woff2":"font",".ttf":"font",".eot":"font",".otf":"font"},b=[/node_modules/,/vendor/,/bower_components/,/\.min\./],B=[/index\.(js|ts|html)$/,/main\.(js|ts)$/,/app\.(js|ts)$/,/entry\.(js|ts)$/];async function L(X,Z={}){let{includeSourceMaps:Q=!1,parseImports:$=!0,detectDuplicates:U=!0,topModulesCount:K=20}=Z;if(!v.existsSync(X))throw Error(`Build directory not found: ${X}`);if(!v.statSync(X).isDirectory())throw Error(`Not a directory: ${X}`);let q=await k(X,Q),J=[],F=[];for(let A of q)try{let O=await f(A,X,$);J.push(O)}catch(O){F.push(`Failed to process ${A}: ${O}`)}let Y=c(J,X),V=J.reduce((A,O)=>A+O.size,0),_=J.reduce((A,O)=>A+O.gzipSize,0),w=m(J),G=U?p(J):[],C=[...J].sort((A,O)=>O.size-A.size).slice(0,K);return{timestamp:Date.now(),buildDir:H.resolve(X),chunks:Y,totalSize:V,totalGzipSize:_,moduleCount:J.length,duplicates:G,byType:w,largestModules:C,warnings:F}}async function k(X,Z){let Q=[];async function $(U){let K=await v.promises.readdir(U,{withFileTypes:!0});for(let j of K){let q=H.join(U,j.name);if(j.isDirectory()){if(!j.name.startsWith(".")&&j.name!=="node_modules")await $(q)}else if(j.isFile()){if(!Z&&j.name.endsWith(".map"))continue;Q.push(q)}}}return await $(X),Q}async function f(X,Z,Q){let $=await v.promises.readFile(X),U=H.relative(Z,X),K=H.extname(X).toLowerCase(),j=$.length,q=y($),J=h($,K),F=g("md5").update($).digest("hex").slice(0,8),Y=D[K]||"other",V=[];if(Q&&Y==="js")V.push(...d($.toString("utf-8")));return{id:U,path:U,size:j,gzipSize:q,parsedSize:J,extension:K,type:Y,imports:V,importedBy:[],hash:F}}function y(X){try{let Z=z(X,{level:9}).length;return Math.min(Z,X.length)}catch{return X.length}}function h(X,Z){if(Z.includes(".min.")||X.length<1000)return X.length;let $=D[Z];if($==="js")return Math.round(X.length*0.6);if($==="css")return Math.round(X.length*0.7);return X.length}function d(X){let Z=[],Q=/import\s+(?:[\w*{}\s,]+\s+from\s+)?['"]([^'"]+)['"]/g,$;while(($=Q.exec(X))!==null)Z.push($[1]);let U=/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;while(($=U.exec(X))!==null)Z.push($[1]);let K=/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;while(($=K.exec(X))!==null)Z.push($[1]);return[...new Set(Z)]}function c(X,Z){let Q=new Map;for(let U of X){let K=U.path.split(H.sep),j;if(K.length===1)j=H.basename(U.path,U.extension);else j=K[0];let q=Q.get(j)||[];q.push(U),Q.set(j,q)}let $=[];for(let[U,K]of Q){let j=K.reduce((Y,V)=>Y+V.size,0),q=K.reduce((Y,V)=>Y+V.gzipSize,0),J=K.some((Y)=>B.some((V)=>V.test(Y.path))),F=K.some((Y)=>b.some((V)=>V.test(Y.path)));$.push({name:U,files:K.map((Y)=>Y.path),modules:K,size:j,gzipSize:q,isEntry:J,isVendor:F})}return $.sort((U,K)=>K.size-U.size)}function m(X){let Z={js:{count:0,size:0,gzipSize:0},css:{count:0,size:0,gzipSize:0},html:{count:0,size:0,gzipSize:0},image:{count:0,size:0,gzipSize:0},font:{count:0,size:0,gzipSize:0},other:{count:0,size:0,gzipSize:0}};for(let Q of X)Z[Q.type].count++,Z[Q.type].size+=Q.size,Z[Q.type].gzipSize+=Q.gzipSize;return Z}function p(X){let Z=new Map;for(let $ of X){let U=Z.get($.hash)||[];U.push($),Z.set($.hash,U)}let Q=[];for(let[,$]of Z)if($.length>1){let U=$[0];Q.push({path:U.path,count:$.length,wastedBytes:U.size*($.length-1),locations:$.map((K)=>K.path)})}return Q.sort(($,U)=>U.wastedBytes-$.wastedBytes)}function W(X){if(X<1024)return`${X} B`;if(X<1048576)return`${(X/1024).toFixed(2)} KB`;return`${(X/1048576).toFixed(2)} MB`}function I(X){let Z=X.match(/^([\d.]+)\s*(B|KB|MB|GB)?$/i);if(!Z)return 0;let Q=Number.parseFloat(Z[1]);switch((Z[2]||"B").toUpperCase()){case"KB":return Q*1024;case"MB":return Q*1024*1024;case"GB":return Q*1024*1024*1024;default:return Q}}function E(X,Z){if(Z===0)return"0%";return`${(X/Z*100).toFixed(1)}%`}function R(X,Z){switch(Z.format){case"json":return u(X,Z);case"markdown":return l(X,Z);case"text":default:return r(X,Z)}}function u(X,Z){let Q=N(X,Z);return JSON.stringify({timestamp:X.timestamp,buildDir:X.buildDir,summary:{totalSize:X.totalSize,totalSizeFormatted:W(X.totalSize),totalGzipSize:X.totalGzipSize,totalGzipSizeFormatted:W(X.totalGzipSize),moduleCount:X.moduleCount,chunkCount:X.chunks.length,duplicateCount:X.duplicates.length},byType:Object.fromEntries(Object.entries(X.byType).map(([$,U])=>[$,{...U,sizeFormatted:W(U.size),gzipSizeFormatted:W(U.gzipSize)}])),chunks:X.chunks.map(($)=>({name:$.name,size:$.size,sizeFormatted:W($.size),gzipSize:$.gzipSize,gzipSizeFormatted:W($.gzipSize),moduleCount:$.modules.length,isEntry:$.isEntry,isVendor:$.isVendor})),largestModules:X.largestModules.slice(0,Z.topModules||10).map(($)=>({path:$.path,size:$.size,sizeFormatted:W($.size),gzipSize:$.gzipSize,gzipSizeFormatted:W($.gzipSize),type:$.type})),duplicates:X.duplicates,analysis:Q,warnings:X.warnings},null,2)}function r(X,Z){let Q=[],$=Z.showGzip!==!1;if(Q.push(""),Q.push("Bundle Analysis Report"),Q.push("\u2550".repeat(50)),Q.push(""),Q.push("Summary"),Q.push("\u2500".repeat(50)),$)Q.push(`Total Size: ${W(X.totalSize)} (${W(X.totalGzipSize)} gzip)`);else Q.push(`Total Size: ${W(X.totalSize)}`);if(Q.push(`Modules: ${X.moduleCount}`),Q.push(`Chunks: ${X.chunks.length}`),X.duplicates.length>0)Q.push(`Duplicates: ${X.duplicates.length}`);if(Q.push(""),Z.threshold&&X.totalSize>Z.threshold)Q.push(`\u26A0\uFE0F Bundle exceeds threshold of ${W(Z.threshold)}!`),Q.push("");Q.push("Size by Type"),Q.push("\u2500".repeat(50));let U=["js","css","html","image","font","other"];for(let j of U){let q=X.byType[j];if(q.count>0){let J=E(q.size,X.totalSize),F=$?` (${W(q.gzipSize)} gzip)`:"";Q.push(` ${j.padEnd(8)} ${W(q.size).padStart(12)}${F} ${J.padStart(6)} (${q.count} files)`)}}Q.push(""),Q.push("Chunks"),Q.push("\u2500".repeat(50));for(let j of X.chunks.slice(0,10)){let q=[];if(j.isEntry)q.push("entry");if(j.isVendor)q.push("vendor");let J=q.length>0?` [${q.join(", ")}]`:"",F=$?` (${W(j.gzipSize)} gzip)`:"";Q.push(` ${j.name.padEnd(20)} ${W(j.size).padStart(12)}${F}${J}`)}if(X.chunks.length>10)Q.push(` ... and ${X.chunks.length-10} more chunks`);Q.push("");let K=Z.topModules||10;Q.push(`Largest Modules (Top ${K})`),Q.push("\u2500".repeat(50));for(let j=0;j<Math.min(K,X.largestModules.length);j++){let q=X.largestModules[j],J=$?` (${W(q.gzipSize)} gzip)`:"";Q.push(` ${(j+1).toString().padStart(2)}. ${q.path}`),Q.push(` ${W(q.size)}${J}`)}if(Q.push(""),X.duplicates.length>0){Q.push("Duplicate Modules"),Q.push("\u2500".repeat(50));for(let j of X.duplicates.slice(0,5))Q.push(` ${j.path}`),Q.push(` ${j.count} copies, wasting ${W(j.wastedBytes)}`);if(X.duplicates.length>5)Q.push(` ... and ${X.duplicates.length-5} more duplicates`);Q.push("")}if(Z.recommendations!==!1){let j=N(X,Z);if(j.recommendations.length>0){Q.push("Recommendations"),Q.push("\u2500".repeat(50));for(let q of j.recommendations.slice(0,5)){let J=q.impact==="high"?"\u26A1":q.impact==="medium"?"\uD83D\uDCCA":"\uD83D\uDCA1";Q.push(` ${J} ${q.title}`),Q.push(` ${q.description}`)}Q.push("")}}if(X.warnings.length>0){Q.push("Warnings"),Q.push("\u2500".repeat(50));for(let j of X.warnings)Q.push(` \u26A0\uFE0F ${j}`);Q.push("")}return Q.join(`
|
|
3
3
|
`)}function l(X,Z){let Q=[],$=Z.showGzip!==!1;if(Q.push("# Bundle Analysis Report"),Q.push(""),Q.push(`Generated: ${new Date(X.timestamp).toISOString()}`),Q.push(""),Q.push("## Summary"),Q.push(""),Q.push("| Metric | Value |"),Q.push("|--------|-------|"),Q.push(`| Total Size | ${W(X.totalSize)} |`),$)Q.push(`| Gzip Size | ${W(X.totalGzipSize)} |`);Q.push(`| Modules | ${X.moduleCount} |`),Q.push(`| Chunks | ${X.chunks.length} |`),Q.push(`| Duplicates | ${X.duplicates.length} |`),Q.push(""),Q.push("## Size by Type"),Q.push(""),Q.push("| Type | Size | Gzip | % | Files |"),Q.push("|------|------|------|---|-------|");let U=["js","css","html","image","font","other"];for(let j of U){let q=X.byType[j];if(q.count>0)Q.push(`| ${j} | ${W(q.size)} | ${W(q.gzipSize)} | ${E(q.size,X.totalSize)} | ${q.count} |`)}Q.push(""),Q.push("## Chunks"),Q.push(""),Q.push("| Name | Size | Gzip | Modules | Type |"),Q.push("|------|------|------|---------|------|");for(let j of X.chunks.slice(0,15)){let q=j.isEntry?"Entry":j.isVendor?"Vendor":"-";Q.push(`| ${j.name} | ${W(j.size)} | ${W(j.gzipSize)} | ${j.modules.length} | ${q} |`)}Q.push("");let K=Z.topModules||10;Q.push(`## Largest Modules (Top ${K})`),Q.push(""),Q.push("| # | Path | Size | Gzip |"),Q.push("|---|------|------|------|");for(let j=0;j<Math.min(K,X.largestModules.length);j++){let q=X.largestModules[j];Q.push(`| ${j+1} | \`${q.path}\` | ${W(q.size)} | ${W(q.gzipSize)} |`)}if(Q.push(""),X.duplicates.length>0){Q.push("## Duplicates"),Q.push(""),Q.push("| Path | Copies | Wasted |"),Q.push("|------|--------|--------|");for(let j of X.duplicates.slice(0,10))Q.push(`| \`${j.path}\` | ${j.count} | ${W(j.wastedBytes)} |`);Q.push("")}if(Z.recommendations!==!1){let j=N(X,Z);if(j.recommendations.length>0){Q.push("## Recommendations"),Q.push("");for(let q of j.recommendations)Q.push(`### ${q.title}`),Q.push(""),Q.push(q.description),Q.push(""),Q.push(`- **Impact:** ${q.impact}`),Q.push(`- **Effort:** ${q.effort}`),Q.push("")}}return Q.join(`
|
|
4
4
|
`)}function N(X,Z){let Q=[],$=[];if(Z.threshold&&X.totalSize>Z.threshold)Q.push({severity:"error",message:`Bundle size (${W(X.totalSize)}) exceeds threshold (${W(Z.threshold)})`});if(X.totalSize>1048576)Q.push({severity:"warning",message:`Bundle is over 1MB (${W(X.totalSize)})`,details:"Large bundles can significantly impact load time"});if(X.duplicates.length>0){let q=X.duplicates.reduce((J,F)=>J+F.wastedBytes,0);Q.push({severity:"warning",message:`${X.duplicates.length} duplicate modules found, wasting ${W(q)}`}),$.push({title:"Remove Duplicate Modules",description:"Consider using import aliases or ensuring consistent package versions to eliminate duplicates.",impact:"medium",effort:"low"})}if(X.byType.js.size/X.totalSize>0.8&&X.totalSize>512000)$.push({title:"Code Splitting",description:"Over 80% of your bundle is JavaScript. Consider splitting code by route or feature.",impact:"high",effort:"medium"});let K=X.largestModules.filter((q)=>q.size>102400);if(K.length>0){Q.push({severity:"info",message:`${K.length} modules are over 100KB`});for(let q of K){if(q.path.includes("lodash")&&!q.path.includes("lodash-es"))$.push({title:"Use lodash-es instead of lodash",description:"lodash-es supports tree-shaking and can significantly reduce bundle size.",impact:"high",effort:"low"});if(q.path.includes("moment"))$.push({title:"Replace moment.js",description:"Consider using date-fns or dayjs for smaller date handling libraries.",impact:"high",effort:"medium"})}}if(X.byType.image.size>512000)$.push({title:"Optimize Images",description:`Images account for ${W(X.byType.image.size)}. Consider using WebP/AVIF formats and responsive images.`,impact:"high",effort:"low"});let j=100;if(X.totalSize>1048576)j-=20;else if(X.totalSize>512000)j-=10;if(j-=Math.min(20,X.duplicates.length*2),j-=Math.min(15,K.length*3),Z.threshold&&X.totalSize>Z.threshold)j-=25;return{score:Math.max(0,j),issues:Q,recommendations:$}}var i={lodash:{alternative:"lodash-es or individual imports",savings:"~70%"},moment:{alternative:"date-fns or dayjs",savings:"~90%"},"chart.js":{alternative:"chart.js with tree-shaking",savings:"~50%"},"highlight.js":{alternative:"Selective language imports",savings:"~80%"},fontawesome:{alternative:"Individual icon imports",savings:"~90%"},"material-ui":{alternative:"Named imports from @mui/*",savings:"~60%"}};function n(X){for(let[Z,Q]of Object.entries(i))if(X.includes(Z))return{title:`Optimize ${Z}`,description:`Consider using ${Q.alternative}. Potential savings: ${Q.savings}`,impact:"high",effort:"low"};return null}var o={default:{js:"#f7df1e",css:"#264de4",html:"#e34c26",image:"#4caf50",font:"#9c27b0",other:"#607d8b",vendor:"#ff5722"},pastel:{js:"#fff3b0",css:"#b0d4ff",html:"#ffb0b0",image:"#b0ffb0",font:"#e0b0ff",other:"#d0d0d0",vendor:"#ffcfb0"},monochrome:{js:"#333333",css:"#555555",html:"#777777",image:"#999999",font:"#bbbbbb",other:"#dddddd",vendor:"#444444"}};function x(X,Z={}){let{title:Q="Bundle Analysis",gzip:$=!0,colorScheme:U="default"}=Z,K=o[U],j=a(X),q=JSON.stringify(j);return`<!DOCTYPE html>
|
|
5
5
|
<html lang="en">
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{nl as a,ol as b,pl as c,ql as d,rl as e,sl as f,tl as g}from"./chunk-
|
|
2
|
+
import{nl as a,ol as b,pl as c,ql as d,rl as e,sl as f,tl as g}from"./chunk-7rj4h2t2.js";import"./chunk-4arms0am.js";import"./chunk-w1asc0zd.js";import"./chunk-xk402w4a.js";import"./chunk-e03m4har.js";import"./chunk-m8kem5ca.js";export{e as productionApiDispatcher,g as isServerApiSource,b as generateApiTypes,a as discoverServerApi,f as createServerApi,d as createApiDispatcher,c as buildServerApi};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{qs as _}from"./chunk-v90kxg77.js";import"./chunk-m8kem5ca.js";function W(j,G,H=240){return j.slice(G,G+H)}var v=[{rule:"route-params",pattern:/\blocation\s*\.\s*pathname\s*\.\s*(?:match|split)\s*\(/g,primitive:"useRoute() / useRouteParams() / useRouteParam(name)",why:"parsing the URL by hand re-implements the router and does not update on SPA navigation"},{rule:"alert",pattern:/(?<![.#\w$])(?:(?:window|globalThis)\s*\.\s*)?alert\s*\(/g,primitive:"stxAlert(message)",why:"themed, focus-trapped and non-blocking \u2014 but `await` it if the code after it "+"depended on the native dialog blocking until dismissal",reject:(j)=>/\b(?:async\s+)?function\s+alert\s*\(/.test(j)||/\b(?:const|let|var)\s+alert\s*=/.test(j)},{rule:"search-params",pattern:/new\s+URLSearchParams\s*\(/g,primitive:"useSearchParams()",why:"reactive, and writes back through the router instead of history.replaceState",reject:(j,G)=>{let H=j.indexOf("(",G);if(H===-1)return!0;let Q=j.slice(H+1,j.indexOf(")",H)+1);return!/\b(?:location|search|href|url)\b/i.test(Q)}},{rule:"navigate",pattern:/\blocation\s*\.\s*(?:assign|replace)\s*\(|\blocation\s*\.\s*href\s*=/g,primitive:"navigate(path) / goBack()",why:"a full document load throws away every store and the scroll position; navigate() is an SPA transition",reject:(j,G)=>/^[^\n]*?(?:['"`]\s*)?(?:mailto:|tel:|sms:|https?:\/\/|\/\/)/.test(W(j,G,160))},{rule:"fetch",pattern:/new\s+AbortController\s*\(/g,primitive:"useFetch(url) / useAsyncData(key, fn)",why:"cancellation, loading and error state are already wired; hand-rolling them is where the races live"},{rule:"polling",pattern:/setInterval\s*\(/g,primitive:"useEventSource() / useSSE() / useWebSocket() / useChannel()",why:"polling burns requests and lags; the push primitives are delivered",reject:(j,G)=>!/\bfetch\s*\(|\$fetch\b|useFetch\b|\.get\s*\(|axios\b/.test(W(j,G))},{rule:"debounce",pattern:/\bclearTimeout\s*\(/g,primitive:"useDebounce(fn, ms) / useThrottle(fn, ms)",why:"a hand-held timer handle per call site is the usual source of stale-result bugs",requires:(j)=>/setTimeout\s*\(/.test(j)},{rule:"click-outside",pattern:/document\s*\.\s*addEventListener\s*\(\s*['"](?:click|mousedown|pointerdown)['"]/g,primitive:"useClickOutside(ref, fn)",why:"the document-level listener plus the blur race is exactly what this composable exists to remove"},{rule:"focus",pattern:/\.\s*(?:getElementById|querySelector)\s*\([^)]*\)\s*(?:\?\.)?\s*\.?focus\s*\(/g,primitive:"useFocus(ref) with x-ref",why:"a query by id breaks under nested scopes and SPA navigation; a ref does not"},{rule:"clipboard",pattern:/navigator\s*\.\s*(?:clipboard|share)\b/g,primitive:"useClipboard() / useShare()",why:"permission state, the copied flag and the unsupported-browser fallback are already handled"},{rule:"watch",pattern:/\beffect\s*\(\s*\(\s*\)\s*=>\s*\{[^}]*\bvoid\s+\w+\s*\(\s*\)/g,primitive:"watch(source, cb) / watchMultiple([...], cb)",why:"the `void a(); void b()` dance is a manual dependency list; watch takes one directly"}],U=["confirm","tooltip",...v.map((j)=>j.rule)];function N(j,G){let H=1;for(let Q=0;Q<G;Q++)if(j[Q]===`
|
|
3
3
|
`)H++;return H}function P(j,G){let H=j.lastIndexOf(`
|
|
4
4
|
`,G)+1,Q=j.indexOf(`
|
|
5
5
|
`,G);return j.slice(H,Q===-1?j.length:Q).trim().slice(0,120)}function q(j,G){let H=j.slice(0,G),Q=H.lastIndexOf("function"),X=H.lastIndexOf("=>"),M=Math.max(Q,X);if(M===-1)return!1;let z=j.slice(Math.max(0,M-120),M);return/\basync\b[^;{}]*$/.test(z)}function L(j){return/\b(?:async\s+)?function\s+confirm\s*\(/.test(j)||/\b(?:const|let|var)\s+confirm\s*=/.test(j)||/\bimport\s*\{[^}]*\bconfirm\b[^}]*\}/.test(j)}function O(j,G,H){if(L(j))return j;let Q=/(^|[^\w$.])(?:(?:window|globalThis)\s*\.\s*)?confirm\s*\(/g,X=F(j),M="",z=0,Y;while((Y=Q.exec(X))!==null){let Z=Y.index+Y[1].length,$=N(j,Z),J=P(j,Z);if(/stxConfirm\s*\($/.test(j.slice(0,Z+8)))continue;let D=q(j,Z);if(H.push({file:G,line:$,rule:"confirm",applied:D,snippet:J,reason:D?void 0:"stxConfirm() returns a Promise and native confirm() is synchronous, so this needs `await` inside an async function. Rewriting it here would make the condition always true."}),D)M+=j.slice(z,Z)+"await stxConfirm(",z=Z+(Y[0].length-Y[1].length)}return M+j.slice(z)}function w(j,G,H){let Q=/(<[a-z][\w-]*\b[^>]*?)\stitle=(["'])(.*?)\2/gis,X=C(j),M="",z=0,Y;while((Y=Q.exec(X))!==null){let[Z,$,J,D]=Y,K=N(j,Y.index),B=P(j,Y.index),V=$.match(/^<([A-Za-z][\w-]*)/)?.[1]??"";if(/^[A-Z]/.test(V)){H.push({file:G,line:K,rule:"tooltip",applied:!1,snippet:B,reason:`\`title\` on <${V}> is a component prop, not an HTML attribute \u2014 `+"adding x-tooltip here would put a tooltip on a component and may duplicate text it already renders."});continue}if(/\bx-tooltip[=\s]/.test($)||D.trim()===""){H.push({file:G,line:K,rule:"tooltip",applied:!1,snippet:B,reason:/\bx-tooltip[=\s]/.test($)?"already has x-tooltip":"empty title"});continue}H.push({file:G,line:K,rule:"tooltip",applied:!0,snippet:B}),M+=j.slice(z,Y.index)+`${$} x-tooltip=${J}${D}${J} title=${J}${D}${J}`,z=Y.index+Z.length}return M+j.slice(z)}function C(j){return j.replace(/<!--[\s\S]*?-->/g,(G)=>G.replace(/[^\n]/g," ")).replace(/\{\{--[\s\S]*?--\}\}/g,(G)=>G.replace(/[^\n]/g," "))}function E(j){let G=(H)=>H.replace(/[^\n]/g," ");return j.replace(/\/\*[\s\S]*?\*\//g,G).replace(/\/\/[^\n]*/g,G)}function F(j,G=!1){let H=C(j);return(G?E(H):_(H)).replace(/<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi,(X,M)=>/\bclient\b/i.test(M)?X:X.replace(/[^\n]/g," "))}function S(j,G,H,Q){let X=F(j),M=F(j,!0);for(let z of v){if(!H.includes(z.rule))continue;if(z.requires&&!z.requires(j))continue;z.pattern.lastIndex=0;let Y,Z=/['"]/.test(z.pattern.source)?M:X;z.pattern.lastIndex=0;while((Y=z.pattern.exec(Z))!==null){if(z.reject?.(j,Y.index))continue;Q.push({file:G,line:N(j,Y.index),rule:z.rule,applied:!1,snippet:P(j,Y.index),reason:`${z.primitive} \u2014 ${z.why}`})}}}function k(j,G={}){let H=G.rules??U,Q=G.file??"<source>",X=[];S(j,Q,H,X);let M=j;if(H.includes("confirm"))M=O(M,Q,X);if(H.includes("tooltip"))M=w(M,Q,X);X.sort((Z,$)=>Z.line-$.line);let z=new Set,Y=X.filter((Z)=>{let $=`${Z.rule}:${Z.line}`;if(z.has($))return!1;return z.add($),!0});return{code:M,findings:Y}}var I=new Set(["confirm","tooltip"]);function A(j,G){if(j.length===0)return"No hand-rolled equivalents found.";let H=j.filter((z)=>z.applied),Q=j.filter((z)=>!z.applied&&I.has(z.rule)),X=j.filter((z)=>!z.applied&&!I.has(z.rule)),M=[];if(H.length>0){M.push(G?`Rewrote ${H.length} site(s):`:`Would rewrite ${H.length} site(s) (pass --fix):`);for(let z of H)M.push(` ${z.file}:${z.line} [${z.rule}] ${z.snippet}`)}if(Q.length>0){M.push("",`Needs a human \u2014 ${Q.length} site(s):`);for(let z of Q)M.push(` ${z.file}:${z.line} [${z.rule}] ${z.snippet}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Rg as a,Sg as b,Tg as c,Ug as d,Vg as e,Wg as f,Xg as g,Yg as h,Zg as i}from"./chunk-
|
|
2
|
+
import{Rg as a,Sg as b,Tg as c,Ug as d,Vg as e,Wg as f,Xg as g,Yg as h,Zg as i}from"./chunk-karkhcja.js";import"./chunk-bcpjhcpn.js";import"./chunk-m8kem5ca.js";export{c as setCachedImageResult,e as processImage,f as optimizeImage,b as getCachedImageResult,i as generateSrcset,h as generateResponsiveVariants,d as clearImageCache,g as applyTransformations,a as ImageProcessorCache};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{AsyncLocalStorage as U}from"async_hooks";var V=Symbol.for("stx.runtime-config.scope"),W=globalThis,Q=W[V]??=new U;function b(x,H){return Q.run(x,H)}function A(){return Q.getStore()}function X(){let x=Q.getStore();if(!x)throw Error("useServerRuntimeConfig requires a server request or template render");return Object.freeze(Object.defineProperty({public:x.public},"private",{value:x.private}))}function N(){return X().public}function O(x={},H=process.env){let I=new Set;function E(j,z){if(z===null)return j===null;if(Array.isArray(z))return Array.isArray(j)&&(!z.length||j.every((B)=>z.some((F)=>E(B,F))));if(typeof z==="object")return j!==null&&typeof j==="object"&&!Array.isArray(j)&&Object.entries(z).every(([B,F])=>Object.hasOwn(j,B)&&E(j[B],F));return typeof j===typeof z}function J(j,z){if(j&&typeof j==="object"&&!Array.isArray(j)){if(Object.getPrototypeOf(j)!==Object.prototype&&Object.getPrototypeOf(j)!==null)throw TypeError(`Runtime config ${z.join(".")} must contain JSON values`);let q=Object.create(null);for(let[G,P]of Object.entries(j)){if(!/^[a-zA-Z][a-zA-Z0-9_]*$/.test(G)||["constructor","prototype","__proto__"].includes(G))throw TypeError(`Invalid runtime config key: ${G}`);q[G]=J(P,[...z,G])}return Object.freeze(q)}let B=`STX_RUNTIME_${z.map((q)=>q.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toUpperCase()).join("__")}`;if(I.has(B))throw TypeError(`Ambiguous runtime config environment key: ${B}`);I.add(B);let F=H[B],K=j;if(F!==void 0){try{K=typeof j==="string"?F:JSON.parse(F)}catch{throw TypeError(`Invalid runtime config override: ${B}`)}if(!E(K,j))throw TypeError(`Wrong runtime config override type: ${B}`)}function M(q){if(q===null||typeof q==="string"||typeof q==="boolean")return q;if(typeof q==="number"&&Number.isFinite(q))return q;if(Array.isArray(q))return Object.freeze(q.map(M));if(q&&typeof q==="object"&&(Object.getPrototypeOf(q)===Object.prototype||Object.getPrototypeOf(q)===null))return Object.freeze(Object.fromEntries(Object.entries(q).map(([G,P])=>[G,M(P)])));throw TypeError(`Runtime config ${z.join(".")} must contain JSON values`)}return M(K)}return Object.freeze({public:J(x.public??{},["public"]),private:J(x.private??{},["private"])})}function Z(x){return`<script data-stx-scoped data-stx-runtime-config type="application/json">${JSON.stringify(x.public).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}</script>`}function T(x,H){let I=x.replace(/<script\b[^>]*\bdata-stx-runtime-config\b[^>]*>[\s\S]*?<\/script>/gi,""),E=/<head\b[^>]*>/i.exec(I),J=E?E.index+E[0].length:0;return I.slice(0,J)+Z(H)+I.slice(J)}
|
|
3
|
-
export{b as
|
|
3
|
+
export{b as It,A as Jt,X as Kt,N as Lt,O as Mt,Z as Nt,T as Ot};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ni as a,Oi as b,Pi as c,Qi as d,Ri as e,Si as f,Ti as g,Ui as h,Vi as i,Wi as j,Xi as k,Yi as l,Zi as m,_i as n}from"./chunk-benx1c4p.js";import"./chunk-2119txb8.js";import"./chunk-jc6wrxrh.js";import"./chunk-2xpdcr8c.js";import"./chunk-v90kxg77.js";import"./chunk-4arms0am.js";import"./chunk-135mme4g.js";import"./chunk-dj24n5n7.js";import"./chunk-w1asc0zd.js";import"./chunk-kd95t585.js";import"./chunk-1tz8fb87.js";import"./chunk-xk402w4a.js";import"./chunk-dnard9gp.js";import"./chunk-vgx5077x.js";import"./chunk-met6wtbk.js";import"./chunk-ta6z7k4p.js";import"./chunk-zxptxz2b.js";import"./chunk-7racewc5.js";import"./chunk-e03m4har.js";import"./chunk-vsqx756d.js";import"./chunk-m8kem5ca.js";export{i as streamingSuspenseDirective,m as streamToResponse,g as streamTemplateSimple,a as streamTemplate,d as renderStreamingPage,k as registerStreamingDirectives,e as processStreamDirectives,l as processSectionDirectives,j as islandDirective,n as generateHydrationRuntime,f as extractStreamBoundaries,h as createStreamRenderer,b as buildSuspenseResolveScript,c as SUSPENSE_RESOLVER_RUNTIME};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$g as b,_g as a,ah as c,bh as d,ch as e,dh as f,eh as g,fh as h,gh as i,hh as j,ih as k}from"./chunk-
|
|
2
|
+
import{$g as b,_g as a,ah as c,bh as d,ch as e,dh as f,eh as g,fh as h,gh as i,hh as j,ih as k}from"./chunk-ypgyhr2p.js";import"./chunk-bcpjhcpn.js";import"./chunk-m8kem5ca.js";export{c as setCachedVideoResult,k as processVideo,b as getCachedVideoResult,f as generateThumbnails,g as generateSpriteSheet,e as generatePoster,h as generateHLSManifest,i as generateDASHManifest,d as clearVideoCache,j as analyzeVideo,a as VideoProcessorCache};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{jh as x,oh as B,ph as c,qh as u,rh as n}from"./chunk-bcpjhcpn.js";import{
|
|
2
|
+
import{jh as x,oh as B,ph as c,qh as u,rh as n}from"./chunk-bcpjhcpn.js";import{Sw as v}from"./chunk-m8kem5ca.js";import{resolve as JJ,basename as WJ,extname as _J,join as LJ}from"path";import{mkdir as QJ}from"fs/promises";var ZJ={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0};class V{config;constructor(K={}){this.config={...ZJ,...K}}async get(K,J){return c(K,J,"video",this.config)}async set(K,J,X){return u(K,J,X,"video",this.config)}async clear(){return n("video",this.config)}updateConfig(K){this.config={...this.config,...K}}}var S=null;function D(K){if(!S)S=new V(K);else if(K)S.updateConfig(K);return S}async function q(K,J,X){let N=X?{directory:`${X.outputDir}/../.cache`}:{};return D(N).get(K,J)}async function b(K,J,X,N){let Z=N?{directory:`${N.outputDir}/../.cache`}:{};return D(Z).set(K,J,X)}async function $J(){return D().clear()}import{resolve as y,basename as P,extname as f,join as U}from"path";import{mkdir as g}from"fs/promises";async function m(){try{return await import("ts-videos")}catch{return null}}async function h(K,J,X,N){let Z=await m();if(!Z)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let $=y(K);if(!await B($))return null;await g(X,{recursive:!0});let Y=await x($),z=P(K,f(K)),G=J.format||"webp",M=J.timestamp||0,E=`${z}-poster-${Y}.${G}`,W=U(X,E),Q=await Z.extractThumbnails($,{timestamps:[M],width:J.width||1280,height:J.height,format:G,quality:J.quality||85,outputDir:X,outputPattern:E.replace(`.${G}`,"")});if(Q&&Q.length>0){let _=Q[0];return{path:W,url:`${N}/${E}`,width:_.width||J.width||1280,height:_.height||720,timestamp:M,size:_.size||0}}return null}catch($){return console.warn(`[stx-media] Failed to generate poster: ${$}`),null}}async function d(K,J,X,N){let Z=await m();if(!Z)return[];try{let $=y(K);if(!await B($))return[];await g(X,{recursive:!0});let Y=await x($),z=P(K,f(K)),G=J.format||"webp",W=(await new Z.Input($).getInfo()).duration||60,Q=J.count||10,_=J.interval||W/Q,O=[];for(let w=0;w<Q&&w*_<W;w++)O.push(w*_);let L=await Z.extractThumbnails($,{timestamps:O,width:J.width||320,format:G,quality:J.quality||80,outputDir:X,outputPattern:`${z}-thumb-${Y}`});if(L&&L.length>0)return L.map((w,j)=>({path:w.path||U(X,`${z}-thumb-${Y}-${j}.${G}`),url:`${N}/${z}-thumb-${Y}-${j}.${G}`,width:w.width||J.width||320,height:w.height||180,timestamp:O[j],size:w.size||0}));return[]}catch($){return console.warn(`[stx-media] Failed to generate thumbnails: ${$}`),[]}}async function zJ(K,J,X,N){let Z=await m();if(!Z)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let $=y(K);if(!await B($))return null;await g(X,{recursive:!0});let Y=await x($),z=P(K,f(K)),E=(await new Z.Input($).getInfo()).duration||60,W=J.columns||10,Q=J.interval||5,_=J.thumbnailWidth||160,O=J.thumbnailHeight||90,L=J.format||"jpeg",w=Math.ceil(E/Q),j=Math.ceil(w/W),F=`${z}-sprite-${Y}.${L}`,k=U(X,F),T=[];for(let I=0;I<w;I++)T.push(I*Q);let A=await Z.extractThumbnails($,{timestamps:T,width:_,height:O,format:L,quality:J.quality||70,outputDir:U(X,".temp")});if(!A||A.length===0)return null;try{let I=await import("ts-images"),H=W*_,kJ=j*O,jJ=await I.createSprite({images:A.map((YJ)=>YJ.path),columns:W,padding:0,outputPath:k,format:L,quality:J.quality||70});return{url:`${N}/${F}`,path:k,columns:W,rows:j,thumbnailWidth:_,thumbnailHeight:O,interval:Q,totalFrames:w}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch($){return console.warn(`[stx-media] Failed to generate sprite sheet: ${$}`),null}}import{resolve as r,basename as e,extname as i,join as C}from"path";import{mkdir as R,writeFile as o}from"fs/promises";async function t(){try{return await import("ts-videos")}catch{return null}}var s=[{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},{label:"360p",width:640,height:360,bitrate:600000,audioBitrate:64000}];async function p(K,J,X,N,Z){let $=await t();if(!$)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let Y=r(K);if(!await B(Y))return null;let z=await x(Y),G=e(K,i(K)),M=C(X,`${G}-${z}-hls`);await R(M,{recursive:!0});let E=J.length>0?J:s,W=Z?.segmentDuration||6,O=(await new $.Input(Y).getInfo()).duration||0,L=[],w=0;for(let k of E){let T=C(M,k.label);await R(T,{recursive:!0});let A=`${k.label}.m3u8`,I=C(T,A);try{let H=await $.generateHLS(Y,{outputDir:T,segmentDuration:W,width:k.width,height:k.height,videoBitrate:k.bitrate,audioBitrate:k.audioBitrate,playlistName:k.label});if(H)L.push({quality:k,url:`${N}/${G}-${z}-hls/${k.label}/${A}`,path:I}),w+=H.segmentCount||Math.ceil(O/W)}catch(H){console.warn(`[stx-media] Failed to generate HLS for ${k.label}: ${H}`)}}if(L.length===0)return null;let j=C(M,"master.m3u8"),F=GJ(L,N,G,z);return await o(j,F),{manifestUrl:`${N}/${G}-${z}-hls/master.m3u8`,manifestPath:j,playlists:L,segmentCount:w,duration:O}}catch(Y){return console.warn(`[stx-media] Failed to generate HLS manifest: ${Y}`),null}}function GJ(K,J,X,N){let Z=["#EXTM3U","#EXT-X-VERSION:3"];for(let $ of K){let{quality:Y}=$,z=Y.bitrate+(Y.audioBitrate||128000),G=`${Y.width}x${Y.height||Math.round(Y.width*9/16)}`;Z.push(`#EXT-X-STREAM-INF:BANDWIDTH=${z},RESOLUTION=${G},NAME="${Y.label}"`,`${Y.label}/${Y.label}.m3u8`)}return Z.join(`
|
|
3
3
|
`)}async function l(K,J,X,N,Z){let $=await t();if(!$)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let Y=r(K);if(!await B(Y))return null;let z=await x(Y),G=e(K,i(K)),M=C(X,`${G}-${z}-dash`);await R(M,{recursive:!0});let E=J.length>0?J:s,W=Z?.segmentDuration||4,Q=Z?.minBufferTime||2,L=(await new $.Input(Y).getInfo()).duration||0,w=[],j=[];for(let A of E){let I=C(M,A.label);await R(I,{recursive:!0});try{if(await $.generateDASH(Y,{outputDir:I,segmentDuration:W,width:A.width,height:A.height,videoBitrate:A.bitrate,audioBitrate:A.audioBitrate})){if(w.push({bandwidth:A.bitrate,width:A.width,height:A.height||Math.round(A.width*9/16),url:`${N}/${G}-${z}-dash/${A.label}/video`}),A.audioBitrate)j.push({bandwidth:A.audioBitrate,url:`${N}/${G}-${z}-dash/${A.label}/audio`})}}catch(H){console.warn(`[stx-media] Failed to generate DASH for ${A.label}: ${H}`)}}if(w.length===0)return null;let F=C(M,"manifest.mpd"),k=NJ(w,j,L,W,Q);await o(F,k);let T=[{type:"video",representations:w}];if(j.length>0)T.push({type:"audio",representations:j});return{manifestUrl:`${N}/${G}-${z}-dash/manifest.mpd`,manifestPath:F,adaptationSets:T,duration:L}}catch(Y){return console.warn(`[stx-media] Failed to generate DASH manifest: ${Y}`),null}}function NJ(K,J,X,N,Z){let $=a(X),Y=a(Z),z=`<?xml version="1.0" encoding="UTF-8"?>
|
|
4
4
|
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011"
|
|
5
5
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|