@stacksjs/stx 0.2.209 → 0.2.211
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-7ry55nms.js → chunk-1306tswx.js} +1 -1
- package/dist/{chunk-1bq2xyax.js → chunk-1jeyh1e2.js} +1 -1
- package/dist/{chunk-kjr22neh.js → chunk-1nm2xrvq.js} +1 -1
- package/dist/{chunk-ycn1vnv2.js → chunk-1nnpwrqj.js} +1 -1
- package/dist/{chunk-syy7d9w2.js → chunk-1qkk4mrm.js} +1 -1
- package/dist/chunk-2bkqbmkn.js +2 -0
- package/dist/chunk-2kjp90p2.js +2 -0
- package/dist/chunk-2md83wew.js +2 -0
- package/dist/{chunk-mjt5e2jy.js → chunk-2me28xee.js} +1 -1
- package/dist/{chunk-jr5tp4ks.js → chunk-2w5d5tw1.js} +1 -1
- package/dist/chunk-2xeq5xnf.js +2 -0
- package/dist/chunk-3bgyqx5b.js +2 -0
- package/dist/{chunk-nye9brje.js → chunk-3fwn9edg.js} +1 -1
- package/dist/{chunk-zda3hvde.js → chunk-3twce5kp.js} +1 -1
- package/dist/{chunk-dtmwr674.js → chunk-3wd9kfyz.js} +1 -1
- package/dist/chunk-47mx5vng.js +2 -0
- package/dist/{chunk-wnaddtv3.js → chunk-47pge5gz.js} +1 -1
- package/dist/chunk-4vwxgmg0.js +2 -0
- package/dist/{chunk-x0ks1fer.js → chunk-53ajah3v.js} +1 -1
- package/dist/{chunk-e0bk1mqp.js → chunk-591jpt6f.js} +1 -1
- package/dist/chunk-5gb8d966.js +2 -0
- package/dist/{chunk-a2899x2t.js → chunk-5gr4vv7m.js} +1 -1
- package/dist/chunk-5ya35fex.js +2 -0
- package/dist/{chunk-whq99ytc.js → chunk-6ndvtzpk.js} +1 -1
- package/dist/{chunk-bmpkpgx2.js → chunk-6xd5p5v3.js} +10 -10
- package/dist/{chunk-x0zh76yv.js → chunk-6xg3j487.js} +1 -1
- package/dist/{chunk-h2wpnxrh.js → chunk-7mst8kqm.js} +1 -1
- package/dist/{chunk-r41nsgym.js → chunk-7zk48rd8.js} +1 -1
- package/dist/{chunk-44423f7c.js → chunk-81w2xqas.js} +1 -1
- package/dist/{chunk-n35c984x.js → chunk-85144680.js} +2 -2
- package/dist/{chunk-xp3fp266.js → chunk-8anh6d36.js} +1 -1
- package/dist/{chunk-n9eahkjg.js → chunk-8bmsw6gq.js} +85 -85
- package/dist/chunk-8xtvmwpr.js +2 -0
- package/dist/{chunk-ryjpp51z.js → chunk-96kpqgh3.js} +1 -1
- package/dist/{chunk-ygr11tgz.js → chunk-a2rj5ce0.js} +1 -1
- package/dist/{chunk-3nmpfsw5.js → chunk-aw9z3m10.js} +1 -1
- package/dist/chunk-ba18hn7n.js +2 -0
- package/dist/{chunk-cm0ykjs1.js → chunk-ba6v2wh0.js} +1 -1
- package/dist/{chunk-abpw3b39.js → chunk-bsr7yrxh.js} +1 -1
- package/dist/{chunk-5n0dt838.js → chunk-c0p9kf53.js} +1 -1
- package/dist/{chunk-5xpp3z95.js → chunk-c18nh1et.js} +1 -1
- package/dist/{chunk-dhpy0h9y.js → chunk-c7pvwvse.js} +1 -1
- package/dist/{chunk-vr3qtsj4.js → chunk-cqt6ry1e.js} +1 -1
- package/dist/{chunk-rs2fa3g1.js → chunk-cr7s8q08.js} +1 -1
- package/dist/{chunk-gcns5vw5.js → chunk-d12xfcjd.js} +1 -1
- package/dist/chunk-d9b00zcd.js +2 -0
- package/dist/{chunk-m0sd10cs.js → chunk-dt787jv4.js} +1 -1
- package/dist/chunk-evjs9zqm.js +2 -0
- package/dist/{chunk-wtengj6h.js → chunk-f6jm4hy3.js} +1 -1
- package/dist/chunk-f7fhjvbe.js +2 -0
- package/dist/{chunk-evxg9pe7.js → chunk-gyxe9fzm.js} +1 -1
- package/dist/chunk-hdg7t3zs.js +2 -0
- package/dist/{chunk-8src5smc.js → chunk-j0tfxbns.js} +2 -2
- package/dist/{chunk-nsjyn31z.js → chunk-j5vyt8wd.js} +1 -1
- package/dist/{chunk-gcnrdgrq.js → chunk-khrtzbxd.js} +1 -1
- package/dist/chunk-kjw1ha92.js +2 -0
- package/dist/chunk-kmgs48jy.js +2 -0
- package/dist/chunk-kregsntr.js +2 -0
- package/dist/{chunk-cbc56wpd.js → chunk-m2mhtpwy.js} +1 -1
- package/dist/chunk-mghyceb1.js +2 -0
- package/dist/chunk-mpt8ed9w.js +2 -0
- package/dist/{chunk-mkm91b6w.js → chunk-msjzqne1.js} +1 -1
- package/dist/{chunk-7w4c5w2b.js → chunk-ne8sygmy.js} +1 -1
- package/dist/{chunk-ndnc7k2n.js → chunk-p7qqbw2k.js} +1 -1
- package/dist/{chunk-xfp10a23.js → chunk-p8pyqr7p.js} +1 -1
- package/dist/{chunk-0ae6chzd.js → chunk-q4se9rtw.js} +1 -1
- package/dist/{chunk-jvqjh17y.js → chunk-qfsgw9by.js} +3 -3
- package/dist/{chunk-910sy8sk.js → chunk-qph3esct.js} +1 -1
- package/dist/chunk-r153ybwd.js +2 -0
- package/dist/{chunk-vydqh4xr.js → chunk-r5hnhtp1.js} +1 -1
- package/dist/{chunk-va9k88da.js → chunk-rczpw37w.js} +1 -1
- package/dist/{chunk-jpbk42j7.js → chunk-rg6v68ya.js} +1 -1
- package/dist/{chunk-1e25ksp6.js → chunk-s7dqawk0.js} +1 -1
- package/dist/{chunk-hb83d0qc.js → chunk-srdwsrnj.js} +1 -1
- package/dist/{chunk-jsndbe2q.js → chunk-td1cz8ms.js} +1 -1
- package/dist/{chunk-pw0rzgpv.js → chunk-trtm887x.js} +1 -1
- package/dist/{chunk-qz75kx6n.js → chunk-tryt2h85.js} +1 -1
- package/dist/{chunk-xm6kwq2r.js → chunk-v1v3fxq1.js} +2 -2
- package/dist/{chunk-4fe1ypxz.js → chunk-v5x6c698.js} +1 -1
- package/dist/chunk-vgr8kykv.js +2 -0
- package/dist/chunk-vhvfja74.js +2 -0
- package/dist/{chunk-vpwjr05r.js → chunk-vkpmnn26.js} +1 -1
- package/dist/{chunk-5gb0zjx0.js → chunk-vtqej9yr.js} +1 -1
- package/dist/{chunk-5s2y052b.js → chunk-w670sde5.js} +1 -1
- package/dist/{chunk-4pf61rcb.js → chunk-wbq7cp57.js} +1 -1
- package/dist/{chunk-nenge2m2.js → chunk-whxregkn.js} +1 -1
- package/dist/{chunk-12n9mz15.js → chunk-x2t441ge.js} +1 -1
- package/dist/{chunk-qpcwahse.js → chunk-x8b16v5q.js} +1 -1
- package/dist/{chunk-abzhv6v3.js → chunk-xcf62bdq.js} +1 -1
- package/dist/{chunk-q02jg1pk.js → chunk-xkd164zg.js} +1 -1
- package/dist/{chunk-e0460y7f.js → chunk-y2jr10y8.js} +1 -1
- package/dist/{chunk-9kf4q3ec.js → chunk-y8mg8dem.js} +1 -1
- package/dist/{chunk-5hpp0vzz.js → chunk-yk1smsev.js} +1 -1
- package/dist/{chunk-spn8e3b3.js → chunk-z0hkt5sk.js} +1 -1
- package/dist/{chunk-3952ykhb.js → chunk-z47tw39z.js} +2 -2
- package/dist/{chunk-nngpktr2.js → chunk-zj44h5kk.js} +1 -1
- package/dist/chunk-ztz7tdb0.js +2 -0
- package/dist/{chunk-1mhc4g86.js → chunk-zxb128xa.js} +1 -1
- package/dist/cli.js +14 -14
- package/dist/component-renderer.d.ts +22 -0
- package/dist/component-renderer.js +5 -2
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/database.js +1 -1
- package/dist/pwa.js +2 -2
- package/dist/ssg.js +2 -2
- package/dist/visual-testing.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-00a028s3.js +0 -2
- package/dist/chunk-02n7khen.js +0 -2
- package/dist/chunk-0kdc3x7v.js +0 -2
- package/dist/chunk-2z6br22w.js +0 -2
- package/dist/chunk-3acgbcv6.js +0 -2
- package/dist/chunk-3vy1q9da.js +0 -2
- package/dist/chunk-5dxctm6h.js +0 -2
- package/dist/chunk-66081bkn.js +0 -2
- package/dist/chunk-6bxcjdp4.js +0 -2
- package/dist/chunk-8sx4vf6p.js +0 -2
- package/dist/chunk-bpvp21dd.js +0 -2
- package/dist/chunk-btgrvrxy.js +0 -2
- package/dist/chunk-ehfzp7xe.js +0 -2
- package/dist/chunk-g9kvpgha.js +0 -2
- package/dist/chunk-k03erdj7.js +0 -2
- package/dist/chunk-k25mqtht.js +0 -2
- package/dist/chunk-me5h5mkq.js +0 -2
- package/dist/chunk-mtr2f82n.js +0 -2
- package/dist/chunk-mz5hjxjv.js +0 -2
- package/dist/chunk-nd9d80gb.js +0 -2
- package/dist/chunk-sry9atvv.js +0 -2
- package/dist/chunk-t98920tc.js +0 -2
- package/dist/chunk-xz019t7t.js +0 -2
- package/dist/chunk-z21qzyh1.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{if as Z$,jf as $5}from"./chunk-
|
|
2
|
+
import{if as Z$,jf as $5}from"./chunk-1qkk4mrm.js";import{Kg as I7,Lg as I6,Mg as s$,Ng as Y$,Og as J$,Pg as D6,Qg as w6}from"./chunk-vtqej9yr.js";import{Ri as t1,Si as e1}from"./chunk-gyxe9fzm.js";import{Aj as y1,Bj as L1,Cj as F1,Dj as b$,Ej as y$,Fj as b5,Hj as y5}from"./chunk-3es366z4.js";import{sk as x5,tk as k5}from"./chunk-1nnpwrqj.js";import{Ak as v7,zk as y7}from"./chunk-yckd6ks5.js";import{cl as $1}from"./chunk-zgvga8rc.js";import{Aq as a5,Bm as M6,Bq as A1,Eo as o1,Ep as V6,Fp as E6,Fq as p0,Jm as f1,Jr as H$,Lr as z1,Mm as Z6,Mr as A0,No as B0,Qr as q0,Ul as R7,Um as p$,Vo as m0,Wl as i5,Wm as c$,Wp as r$,Yp as R6,Zm as h1,Zp as J6,bn as l$,en as n1,fn as Y6,jm as u0,mq as L0,tm as m$,wr as $$,xp as w7}from"./chunk-8bmsw6gq.js";import{Cs as X$,Ds as Q$,Hs as s,us as B}from"./chunk-qfsgw9by.js";import{Ms as S0}from"./chunk-m2mhtpwy.js";import{At as F6,Pt as z6,Qt as j6,Rt as H6,St as O6,Tt as A6,Ut as q6,Wt as N6,_t as _6,ut as a$,vt as K6,zt as L6}from"./chunk-z47tw39z.js";import{iu as c}from"./chunk-trtm887x.js";var v5={read:($)=>{try{return JSON.parse($)}catch{return $}},write:($)=>{return JSON.stringify($)}};function c7($,X,Q={}){let{storage:Z="local",serializer:Y=v5,mergeDefaults:J=!1,listenToStorageChanges:G=!0}=Q,W=new Set,K=typeof window<"u",_=()=>{if(!K)return null;return Z==="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}},z=(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)}},F=U(),H=(L,O)=>{for(let A of W)try{A(L,O)}catch(q){console.error("[useStorage] Subscriber error:",q)}};if(K&&G){let L=(A)=>{if(A.key===$&&A.storageArea===_()){let q=F;try{F=A.newValue?Y.read(A.newValue):X}catch(M){console.warn(`[useStorage] Failed to read key "${$}" from a cross-tab update:`,M);return}H(F,q)}};window.addEventListener("storage",L);let O=globalThis.onDestroy;if(typeof O==="function")O(()=>window.removeEventListener("storage",L))}let j={get value(){return F},set value(L){let O=F;F=L,z(L),H(L,O)},get:()=>F,set:(L)=>{j.value=L},remove:()=>{let L=_();if(L){L.removeItem($);let O=F;F=X,H(X,O)}},subscribe:(L)=>{return W.add(L),L(F,void 0),()=>W.delete(L)}};return j}function g5($,X,Q,Z,Y={}){let{serializer:J=v5,mergeDefaults:G=!1,listenToStorageChanges:W=!0}=Y,K=typeof window<"u",_=()=>{if(!K)return null;return $==="session"?sessionStorage:localStorage},U=(H)=>{if(H===null||H===void 0)return Z;try{let j=J.read(H);if(G&&typeof Z==="object"&&Z!==null)return{...Z,...j};return j}catch(j){return console.warn(`[${X}] Failed to read key "${Q}":`,j),Z}},F=b5((()=>{let H=_();if(!H)return Z;try{return U(H.getItem(Q))}catch(j){return console.warn(`[${X}] Cannot read "${Q}":`,j),Z}})());if(y5(()=>{let H=F(),j=_();if(!j)return;try{if(H===null||H===void 0)j.removeItem(Q);else j.setItem(Q,J.write(H))}catch(L){console.warn(`[${X}] Cannot persist "${Q}":`,L)}}),K&&W){let H=(L)=>{if(L.key!==Q)return;if(L.storageArea&&L.storageArea!==_())return;F.set(U(L.newValue))};window.addEventListener("storage",H);let j=globalThis.onDestroy;if(typeof j==="function")j(()=>window.removeEventListener("storage",H))}return F}function l7($,X,Q){return g5("local","useLocalStorage",$,X,Q)}function i7($,X,Q){return g5("session","useSessionStorage",$,X,Q)}function a7($="local"){if(typeof window>"u")return;($==="session"?sessionStorage:localStorage).clear()}function r7($="local"){if(typeof window>"u")return[];let X=$==="session"?sessionStorage:localStorage;return Object.keys(X)}function s7($="local"){if(typeof window>"u")return 0;let X=$==="session"?sessionStorage:localStorage,Q=0;for(let Z in X)if(Object.prototype.hasOwnProperty.call(X,Z))Q+=(Z.length+(X.getItem(Z)?.length||0))*2;return Q}var i=null;function b1($,X,Q=new WeakSet){if(Object.is($,X))return!0;if(typeof $!=="object"||typeof X!=="object"||$===null||X===null)return!1;if(Q.has($))return!0;if(Q.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(!b1($[J],X[J],Q))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)||!b1(G,X.get(J),Q))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 Z=Object.keys($),Y=Object.keys(X);if(Z.length!==Y.length)return!1;for(let J of Z){if(!Object.prototype.hasOwnProperty.call(X,J))return!1;if(!b1($[J],X[J],Q))return!1}return!0}function eY($){i=$}function $J(){return i}function XJ(){return{isMounted:!1,isUnmounted:!1,hooks:{beforeMount:[],mounted:[],beforeUpdate:[],updated:[],beforeUnmount:[],unmounted:[]},effects:[],scope:n7()}}function n7(){return{refs:new Map,effects:new Set,cleanups:[]}}function QJ($){let X=new Set,Q=new Set,Z=$,Y=Symbol("ref"),J={get value(){let G=y1();if(G)Q.add(G);return Z},set value(G){if(!Object.is(G,Z)){let W=Z;Z=G;for(let K of X)K(G,W);for(let K of Q)if(b$())y$(K);else K()}},subscribe(G){return X.add(G),()=>{X.delete(G)}}};if(i)i.scope.refs.set(Y,J);return J}var f5=new WeakMap;function o7($){let X=f5.get($);if(X)return X;let Q=new Map,Z=(G)=>{let W=Q.get(G);if(!W)return;for(let K of[...W])if(b$())y$(K);else K()},Y=(G,W)=>{if(!Q.has(G))Q.set(G,new Set);return Q.get(G).add(W),()=>{Q.get(G)?.delete(W)}},J=new Proxy($,{get(G,W,K){let _=Reflect.get(G,W,K),U=y1();if(U)Y(W,U);if(_!==null&&typeof _==="object"&&!Array.isArray(_)){let z=Object.getPrototypeOf(_);if(z===Object.prototype||z===null)return o7(_)}return _},set(G,W,K,_){let U=Reflect.get(G,W,_),z=Reflect.set(G,W,K,_);if(!Object.is(K,U))Z(W);return z},deleteProperty(G,W){let K=Reflect.deleteProperty(G,W);return Z(W),K}});return f5.set($,J),J}function ZJ($){let X,Q=!0,Z=new Set,Y=new Set,J=()=>{Q=!0,G()},G=()=>{if(Q){let K=X,_=L1(J);if(X=$(),F1(_),Q=!1,!Object.is(X,K)){for(let U of Z)U(X,K);for(let U of Y)U()}}},W=L1(J);return X=$(),Q=!1,F1(W),{get value(){let K=y1();if(K)Y.add(K);return G(),X},set value(K){console.warn("[stx] Computed properties are readonly")},subscribe(K){return Z.add(K),()=>{Z.delete(K)}}}}function t7($){if(typeof requestAnimationFrame==="function"){requestAnimationFrame(()=>{requestAnimationFrame($)});return}setTimeout($,0)}function YJ($,X,Q={}){let{immediate:Z=!1,deep:Y=!1,flush:J="post"}=Q,G,W,K=!1,_=()=>{if(K)return;let j=H();if((Y?!b1(j,G):!Object.is(j,G))||Z)if(X(j,G),Y&&j!==null&&typeof j==="object")try{G=structuredClone(j)}catch{G=j}else G=j},U=(j)=>{if(J==="sync")j();else if(J==="pre")Promise.resolve().then(j);else t7(j)},z=!1,F=()=>{if(K||z)return;z=!0,U(()=>{z=!1,_()})},H=()=>{if(typeof $==="function"){let j=L1(F);try{return $()}finally{F1(j)}}return $.value};if(typeof $!=="function"){let j=$.subscribe(()=>{U(_)});W=()=>{K=!0,j()}}else W=()=>{K=!0};if(G=H(),Z)U(_);if(i)i.scope.cleanups.push(()=>W?.());return()=>W?.()}function JJ($,X,Q={}){let Z=[],Y=$.map((J)=>J.value);for(let J of $){let G=J.subscribe(()=>{let W=$.map((K)=>K.value);X(W,Y),Y=[...W]});Z.push(G)}if(Q.immediate){let J=$.map((G)=>G.value);X(J,Y)}return()=>{for(let J of Z)J()}}function GJ($){let X,Q=!1,Z=()=>{if(Q)return;if(X)X();let Y=L1(Z);X=$(),F1(Y)};if(Z(),i)i.scope.cleanups.push(()=>{if(Q=!0,X)X()});return()=>{if(Q=!0,X)X()}}function WJ($){if(i)i.hooks.beforeMount.push($);else console.warn("[stx] onBeforeMount called outside of component setup")}function KJ($){if(i)i.hooks.mounted.push($);else console.warn("[stx] onMounted called outside of component setup")}function _J($){if(i)i.hooks.beforeUpdate.push($);else console.warn("[stx] onBeforeUpdate called outside of component setup")}function UJ($){if(i)i.hooks.updated.push($);else console.warn("[stx] onUpdated called outside of component setup")}function BJ($){if(i)i.hooks.beforeUnmount.push($);else console.warn("[stx] onBeforeUnmount called outside of component setup")}function LJ($){if(i)i.hooks.unmounted.push($);else console.warn("[stx] onUnmounted called outside of component setup")}async function r0($,X){let Q=$.hooks[X];for(let Z of Q)await Z()}async function FJ($){await r0($,"beforeMount"),$.isMounted=!0,await r0($,"mounted")}async function zJ($){if(!$.isMounted||$.isUnmounted)return;await r0($,"beforeUpdate"),await r0($,"updated")}async function jJ($){if($.isUnmounted)return;await r0($,"beforeUnmount");for(let X of $.scope.cleanups)X();$.isUnmounted=!0,await r0($,"unmounted")}function HJ(){return`
|
|
3
3
|
<script data-stx-client-runtime>
|
|
4
4
|
(function() {
|
|
5
5
|
'use strict';
|
|
@@ -685,7 +685,7 @@ else {
|
|
|
685
685
|
<span class="frontmatter-label">${X}:</span>
|
|
686
686
|
<span>${Array.isArray(Q)?Q.join(", "):String(Q)}</span>
|
|
687
687
|
</div>`).join("")}
|
|
688
|
-
</div>`}import X6 from"net";async function s3($){return new Promise((X)=>{let Q=X6.createServer();Q.once("error",()=>X(!1)),Q.once("listening",()=>{Q.close(()=>X(!0))}),Q.listen($,"0.0.0.0")})}async function n3($){return new Promise((X)=>{let Q=X6.createServer();Q.once("error",()=>X(!1)),Q.once("listening",()=>{Q.close(()=>X(!0))}),Q.listen($,"::")})}async function o3($){if(!await s3($))return!1;return await n3($)}async function x0($,X=20){$=Number($);for(let Q=0;Q<X;Q++){let Z=$+Q;if(await o3(Z))return Z}throw Error(`Could not find an available port between ${$} and ${$+X-1}`)}var t3={title:"stx Development",width:1400,height:900,darkMode:!0,hotReload:!0,titlebarHidden:!1,nativeSidebar:!1,sidebarWidth:260,sidebarConfig:void 0};async function e3(){try{let $=await import("./chunk-
|
|
688
|
+
</div>`}import X6 from"net";async function s3($){return new Promise((X)=>{let Q=X6.createServer();Q.once("error",()=>X(!1)),Q.once("listening",()=>{Q.close(()=>X(!0))}),Q.listen($,"0.0.0.0")})}async function n3($){return new Promise((X)=>{let Q=X6.createServer();Q.once("error",()=>X(!1)),Q.once("listening",()=>{Q.close(()=>X(!0))}),Q.listen($,"::")})}async function o3($){if(!await s3($))return!1;return await n3($)}async function x0($,X=20){$=Number($);for(let Q=0;Q<X;Q++){let Z=$+Q;if(await o3(Z))return Z}throw Error(`Could not find an available port between ${$} and ${$+X-1}`)}var t3={title:"stx Development",width:1400,height:900,darkMode:!0,hotReload:!0,titlebarHidden:!1,nativeSidebar:!1,sidebarWidth:260,sidebarConfig:void 0};async function e3(){try{let $=await import("./chunk-yk1smsev.js");if(typeof $.openDevWindow!=="function")return null;return $}catch{return null}}async function n0($,X={}){let Q={...t3,...X},Z=await e3();if(!Z)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 Z.openDevWindow($,{title:Q.title,width:Q.width,height:Q.height,darkMode:Q.darkMode,hotReload:Q.hotReload,titlebarHidden:Q.titlebarHidden,nativeSidebar:Q.nativeSidebar,sidebarWidth:Q.sidebarWidth,sidebarConfig:Q.sidebarConfig});if(Y&&Q.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 l1($){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=`
|
|
689
689
|
${J}
|
|
690
690
|
return typeof sidebarConfig !== 'undefined' ? sidebarConfig : null;
|
|
691
691
|
`,K=Function(G)();if(K)return K}catch(G){console.warn("Invalid sidebarConfig:",G)}}return{sections:[]}}let Q=$.match(/@nativeSidebar\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(Q)try{return JSON.parse(Q[1])}catch{console.warn("Invalid @nativeSidebar configuration")}let Z=$.match(/<script\s+native-sidebar[^>]*>([\s\S]*?)<\/script>/i);if(Z)try{let Y=Z[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 h$(){console.log(`
|
|
@@ -1057,7 +1057,7 @@ else {
|
|
|
1057
1057
|
};
|
|
1058
1058
|
})();
|
|
1059
1059
|
</script>
|
|
1060
|
-
`}function I0($,X,Q={}){let Z=J4(X,Q),Y=$.lastIndexOf("</body>");if(Y!==-1)return $.slice(0,Y)+Z+$.slice(Y);if($.includes("</html>"))return $.replace("</html>",`${Z}</html>`);return $+Z}function i1($){let X=$.toLowerCase();return X.endsWith(".css")||X.endsWith(".scss")||X.endsWith(".sass")||X.endsWith(".less")}function a1($){let X=$.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((Z)=>X.endsWith(Z))}function r1($){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((Q)=>Q.test($))}var t0=null;function s1($){if(!t0)t0=new Q6($);return t0}function j1(){if(t0)t0.stop(),t0=null}import H1 from"path";var e0={name:"bun-plugin-stx",async setup($){let Q={...await z1(),...$.config?.stx},Z=new Set,Y=Q.webComponents?.enabled?`./${H1.relative(H1.dirname($.config?.outdir||"dist"),Q.webComponents.outputDir||"dist/web-components")}`:"/web-components",J=[];if(Q.webComponents?.enabled)try{let G=await $$(Q,Z);if(J.push(...G),Q.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(Q.cache&&Q.cachePath){let L=await t1(G,Q);if(L){if(Q.debug)console.log(`Using cached version of ${G}`);return{contents:L,loader:"html"}}}let K=await l$(()=>Bun.file(G).text(),"",(L)=>{throw new c$(`Failed to read stx file: ${G}`,G,void 0,void 0,`File read error: ${L.message}`)});if(!K)throw new c$(`stx file is empty: ${G}`,G);let{scriptContent:_,templateContent:U,allScripts:z}=m$.time("script-extraction",()=>{let L=K,O=o1(K);if(O)L=O.content.trim();let A=K.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],q="",M=[];for(let N of A){let E=N.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",w=N.match(/<script\b([^>]*)>/i),C=w?w[1]:"";if(/\bserver\b/i.test(C))q=E;else M.push(N)}let V=L.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:q,templateContent:V,allScripts:M}}),F={__filename:G,__dirname:H1.dirname(G),__stx:{webComponentsPath:Y,builtComponents:J}};await l$(()=>B0(_,F,G),void 0,(L)=>{let O=new p$(`Script execution failed in ${G}: ${L.message}`,G,void 0,void 0,_.substring(0,100));if(n1.log(O,{filePath:G,scriptContent:_}),Q.debug)throw O});let j=await m$.timeAsync("directive-processing",async()=>{return await L0(U,F,G,Q,W)});if(z.length>0){let{interpolateScriptsInTemplate:L}=await import("./chunk-
|
|
1060
|
+
`}function I0($,X,Q={}){let Z=J4(X,Q),Y=$.lastIndexOf("</body>");if(Y!==-1)return $.slice(0,Y)+Z+$.slice(Y);if($.includes("</html>"))return $.replace("</html>",`${Z}</html>`);return $+Z}function i1($){let X=$.toLowerCase();return X.endsWith(".css")||X.endsWith(".scss")||X.endsWith(".sass")||X.endsWith(".less")}function a1($){let X=$.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((Z)=>X.endsWith(Z))}function r1($){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((Q)=>Q.test($))}var t0=null;function s1($){if(!t0)t0=new Q6($);return t0}function j1(){if(t0)t0.stop(),t0=null}import H1 from"path";var e0={name:"bun-plugin-stx",async setup($){let Q={...await z1(),...$.config?.stx},Z=new Set,Y=Q.webComponents?.enabled?`./${H1.relative(H1.dirname($.config?.outdir||"dist"),Q.webComponents.outputDir||"dist/web-components")}`:"/web-components",J=[];if(Q.webComponents?.enabled)try{let G=await $$(Q,Z);if(J.push(...G),Q.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(Q.cache&&Q.cachePath){let L=await t1(G,Q);if(L){if(Q.debug)console.log(`Using cached version of ${G}`);return{contents:L,loader:"html"}}}let K=await l$(()=>Bun.file(G).text(),"",(L)=>{throw new c$(`Failed to read stx file: ${G}`,G,void 0,void 0,`File read error: ${L.message}`)});if(!K)throw new c$(`stx file is empty: ${G}`,G);let{scriptContent:_,templateContent:U,allScripts:z}=m$.time("script-extraction",()=>{let L=K,O=o1(K);if(O)L=O.content.trim();let A=K.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],q="",M=[];for(let N of A){let E=N.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",w=N.match(/<script\b([^>]*)>/i),C=w?w[1]:"";if(/\bserver\b/i.test(C))q=E;else M.push(N)}let V=L.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:q,templateContent:V,allScripts:M}}),F={__filename:G,__dirname:H1.dirname(G),__stx:{webComponentsPath:Y,builtComponents:J}};await l$(()=>B0(_,F,G),void 0,(L)=>{let O=new p$(`Script execution failed in ${G}: ${L.message}`,G,void 0,void 0,_.substring(0,100));if(n1.log(O,{filePath:G,scriptContent:_}),Q.debug)throw O});let j=await m$.timeAsync("directive-processing",async()=>{return await L0(U,F,G,Q,W)});if(z.length>0){let{interpolateScriptsInTemplate:L}=await import("./chunk-c18nh1et.js"),O=L(z.join(`
|
|
1061
1061
|
`),F),A=j.search(/<\/body>/i);if(A!==-1)j=j.slice(0,A)+O+`
|
|
1062
1062
|
`+j.slice(A);else j+=`
|
|
1063
1063
|
${O}`}if(j=await J6(j),W.forEach((L)=>Z.add(L)),Q.cache&&Q.cachePath){if(await e1(G,j,W,Q),Q.debug)console.log(`Cached template ${G} with ${W.size} dependencies`)}return{contents:j,loader:"html"}}catch(W){let K=W instanceof Error?W:new p$(`Plugin processing failed: ${String(W)}`,G);if(n1.log(K,{filePath:G,buildConfig:$.config}),Y6.logDetailedError(K,{filePath:G,plugin:"bun-plugin-stx"}),Q.debug)console.error("stx Plugin Error:",K);let _=K,U=_.line||null,z=_.context||null;return{contents:Q.debug||Z6()?`<!DOCTYPE html>
|
|
@@ -1120,7 +1120,7 @@ ${O}`}if(j=await J6(j),W.forEach((L)=>Z.add(L)),Q.cache&&Q.cachePath){if(await e
|
|
|
1120
1120
|
<h1>Something went wrong</h1>
|
|
1121
1121
|
<p>An internal error occurred. Please try again later.</p>
|
|
1122
1122
|
</body>
|
|
1123
|
-
</html>`,loader:"html"}}})}};async function W4($,X={}){let Q=X.port||3000,Z=X.watch!==!1,Y=X.hotReload!==!1&&Z,J=null,G=X.hmrPort||Q+1,W=$0.resolve($);if(!F0.existsSync(W))return console.error(`${B.red}Error: File not found: ${B.bright}${W}${B.reset}`),!1;if(W.endsWith(".md"))return u$(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=S0(process.cwd(),"output");F0.mkdirSync(K,{recursive:!0}),console.log(`${B.blue}Building ${B.bright}${$}${B.reset}...`);let _=null,U=async()=>{try{let q={name:"public-assets",setup(E){E.onResolve({filter:/^\/(images|fonts|assets|public)\//},(w)=>{return{path:w.path,external:!0}})}},M=await Bun.build({entrypoints:[W],outdir:K,plugins:[q,e0],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!M.success)return console.error(`${B.red}Build failed:${B.reset}`,M.logs),!1;let V=M.outputs.find((E)=>E.path.endsWith(".html"));if(!V)return console.error(`${B.red}No HTML output found${B.reset}`),!1;return _=await Bun.file(V.path).text(),!0}catch(q){return console.error(`${B.red}Error building stx file:${B.reset}`,q),!1}};if(!await U())return!1;let F=$0.dirname(W);await X$(F);let H=Q;try{if(H=await x0(Q),H!==Q)console.log(`${B.yellow}Port ${Q} is busy, using port ${H} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}if(Y){let q=X.hmrPort||H+1;J=s1({wsPort:q,verbose:!1}),G=J.start(q)}let j={},L=null;try{let{loadStxConfig:q}=await import("./chunk-
|
|
1123
|
+
</html>`,loader:"html"}}})}};async function W4($,X={}){let Q=X.port||3000,Z=X.watch!==!1,Y=X.hotReload!==!1&&Z,J=null,G=X.hmrPort||Q+1,W=$0.resolve($);if(!F0.existsSync(W))return console.error(`${B.red}Error: File not found: ${B.bright}${W}${B.reset}`),!1;if(W.endsWith(".md"))return u$(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=S0(process.cwd(),"output");F0.mkdirSync(K,{recursive:!0}),console.log(`${B.blue}Building ${B.bright}${$}${B.reset}...`);let _=null,U=async()=>{try{let q={name:"public-assets",setup(E){E.onResolve({filter:/^\/(images|fonts|assets|public)\//},(w)=>{return{path:w.path,external:!0}})}},M=await Bun.build({entrypoints:[W],outdir:K,plugins:[q,e0],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!M.success)return console.error(`${B.red}Build failed:${B.reset}`,M.logs),!1;let V=M.outputs.find((E)=>E.path.endsWith(".html"));if(!V)return console.error(`${B.red}No HTML output found${B.reset}`),!1;return _=await Bun.file(V.path).text(),!0}catch(q){return console.error(`${B.red}Error building stx file:${B.reset}`,q),!1}};if(!await U())return!1;let F=$0.dirname(W);await X$(F);let H=Q;try{if(H=await x0(Q),H!==Q)console.log(`${B.yellow}Port ${Q} is busy, using port ${H} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}if(Y){let q=X.hmrPort||H+1;J=s1({wsPort:q,verbose:!1}),G=J.start(q)}let j={},L=null;try{let{loadStxConfig:q}=await import("./chunk-d12xfcjd.js"),M=await q();if(M?.apiRouter)L=M?.apiRouter,console.log(`${B.blue}Using custom router for API handling${B.reset}`);if(M?.apiRoutes){j=M.apiRoutes;let V=Object.keys(j).length;if(V>0)console.log(`${B.blue}Loaded ${B.bright}${V} API route${V>1?"s":""}${B.reset}`)}if(M?.broadcasting?.enabled)try{let{startBroadcasting:V,loadChannels:N}=await import("./chunk-whxregkn.js"),E=M.broadcasting;await V(E);let w=E.port??6001;console.log(`${B.magenta}Broadcasting on ${B.cyan}ws://localhost:${w}/ws${B.reset}`);let C=$0.join(process.cwd(),"channels.ts");if(F0.existsSync(C))try{let R=await N(C);console.log(`${B.blue}Loaded ${B.bright}${R} broadcast channel${R!==1?"s":""}${B.blue} from channels.ts${B.reset}`)}catch(R){console.warn(`${B.yellow}Failed to load channels.ts: ${R.message}${B.reset}`)}}catch(V){console.warn(`${B.yellow}Broadcasting failed to start: ${V.message}${B.reset}`)}}catch{}if(console.log(`${B.blue}Starting server on ${B.cyan}http://localhost:${H}/${B.reset}...`),Y)console.log(`${B.magenta}Hot reload enabled on ws://localhost:${G}${B.reset}`);let O=G4({port:H,async fetch(q){return Z$(q,await(async()=>{let M=new URL(q.url);if(L)try{let C=await L.handleRequest(q);if(C.status!==404)return C}catch{}if(j[M.pathname])try{return await j[M.pathname](q)}catch(C){return new Response(JSON.stringify({error:C.message}),{status:500,headers:{"Content-Type":"application/json"}})}if(M.pathname==="/")return(async()=>{let R=await s(_||"");if(Y)R=I0(R,G);if(X.native)if(R.includes("<head>"))R=R.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(R.includes("<html"))R=R.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 R="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+R;if(X.titlebarHidden)if(R.includes("<head>"))R=R.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(R.includes("<html"))R=R.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 R=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${R}`;return R})().then((R)=>new Response(R,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let V=$0.join(K,M.pathname);if(F0.existsSync(V)&&F0.statSync(V).isFile()){let C=Bun.file(V),R=$0.extname(V).toLowerCase(),I="text/plain";if(R===".ts"||R===".tsx"){let m=new Bun.Transpiler({loader:R===".tsx"?"tsx":"ts"}),h=await C.text(),E0=m.transformSync(h);return new Response(E0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(R){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(C,{headers:{"Content-Type":I}})}let N=$0.dirname(W),E=$0.join(N,M.pathname);if(F0.existsSync(E)&&F0.statSync(E).isFile()){let C=Bun.file(E),R=$0.extname(E).toLowerCase(),I="text/plain";if(R===".ts"||R===".tsx"){let m=new Bun.Transpiler({loader:R===".tsx"?"tsx":"ts"}),h=await C.text(),E0=m.transformSync(h);return new Response(E0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(R){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".svg":I="image/svg+xml";break;case".ico":I="image/x-icon";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(C,{headers:{"Content-Type":I}})}let w=$0.join(process.cwd(),"public",M.pathname);if(F0.existsSync(w)&&F0.statSync(w).isFile()){let C=Bun.file(w),R=$0.extname(w).toLowerCase(),I="application/octet-stream";if(R===".ts"||R===".tsx"){let m=new Bun.Transpiler({loader:R===".tsx"?"tsx":"ts"}),h=await C.text(),E0=m.transformSync(h);return new Response(E0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(R){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".svg":I="image/svg+xml";break;case".ico":I="image/x-icon";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(C,{headers:{"Content-Type":I}})}return new Response("Not Found",{status:404})})())},error(q){return new Response(`<pre>${q}
|
|
1124
1124
|
${q.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
|
|
1125
1125
|
${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(`
|
|
1126
1126
|
${B.bright}\u2192 ${B.cyan}http://localhost:${H}/${B.reset}`),console.log(`
|
|
@@ -1607,12 +1607,12 @@ ${j.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),con
|
|
|
1607
1607
|
${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(`
|
|
1608
1608
|
${B.bright}\u2192 ${B.cyan}http://localhost:${U}/${B.reset}`),console.log(`
|
|
1609
1609
|
${B.yellow}Routes:${B.reset}`);let F=new Set(W.map((j)=>j.routeTemplate)),H=Object.entries(G).filter(([j])=>!F.has(j)).sort(([j],[L])=>j.localeCompare(L)).map(([j,L])=>({route:j==="/"?"/":j,filePath:t.relative(process.cwd(),L.filePath),fileType:L.fileType}));for(let j of W){let L=j.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");H.push({route:L,filePath:t.relative(process.cwd(),j.filePath),fileType:"stx"})}if(H.sort((j,L)=>j.route.localeCompare(L.route)),H.forEach((j,L)=>{let A=L===H.length-1?"\u2514\u2500 ":"\u251C\u2500 ",q=j.fileType==="md"?`${B.magenta}(markdown)${B.reset}`:"";console.log(` ${B.green}${A}${j.route}${B.reset} \u2192 ${B.bright}${j.filePath}${B.reset} ${q}`)}),console.log(`
|
|
1610
|
-
Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),k0(z.url.toString(),()=>{if(Z)P0.watch(J,{recursive:!0}).close();z.stop()}),Z){console.log(`${B.blue}Watching for changes...${B.reset}`);let j=P0.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}`),m0.clear(),p0(),await K()});process.on("SIGINT",()=>{j.close(),z.stop(),process.exit(0)})}return!0}function W6($){return String($??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var{serve:U4}=globalThis.Bun;import X0 from"fs";import g from"path";async function B6($){try{return v$(await Bun.file($).text())}catch{return}}function i$($){let X=Bun.file($),Q=g.extname($).toLowerCase(),Z={".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(Q)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(X,{headers:{"Content-Type":Z[Q]||"application/octet-stream",...J}})}async function B4($=".",X={}){let Q=X.port||3000,Z=X.watch!==!1,Y=X.hotReload!==!1&&Z,J=null,G=X.hmrPort||Q+1,W=g.resolve($),{loadStxConfig:K}=await import("./chunk-gcns5vw5.js"),_=await K(W),U=_.root&&_.root!=="."?g.join(W,_.root):W,z=X.pagesDir||_.pagesDir||"pages",F=g.join(U,z);if(!X0.existsSync(F))return console.error(`${B.red}Error: No '${z}' directory found${B.reset}`),console.log(`${B.dim}Looked in: ${B.bright}${F}${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 ${z}/index.stx for the homepage.${B.reset}`),!1;let H=r$(U,{pagesDir:z});if(H.length===0)return console.error(`${B.red}Error: No page files found in ${B.bright}${F}${B.reset}`),!1;console.log(`${B.blue}Found ${B.bright}${H.length}${B.blue} routes${B.reset}`);let j=_?._pluginPageDirs||[],L=[];for(let{dir:D,prefix:T}of j)if(X0.existsSync(D)){let b=r$(g.dirname(D),{pagesDir:g.basename(D)});for(let S of b){let y=T==="/"?S.pattern:`${T}${S.pattern==="/"?"":S.pattern}`;L.push({route:{...S,pattern:y},prefix:T})}if(b.length>0)console.log(`${B.blue}Plugin pages: ${B.bright}${b.length}${B.blue} routes at ${B.cyan}${T}${B.reset}`)}let O=new Map,A=null,q=null;if(X.stxOptions?.shell!==!1){if(q=await I6(W,X.stxOptions?.shell),q){if(A=await s$(q,X.stxOptions||{}),A)console.log(`${B.blue}Using app shell: ${B.bright}${g.relative(W,q)}${B.reset} ${B.dim}(deprecated: use layouts/default.stx instead)${B.reset}`)}}z6(),await H6(W);let M=j6();if(M.length>0)console.log(`${B.blue}Loaded ${B.bright}${M.length}${B.blue} middleware: ${B.dim}${M.join(", ")}${B.reset}`);let V={},N=null;try{let{loadStxConfig:D}=await import("./chunk-gcns5vw5.js"),T=await D(W);if(T?.apiRouter)N=T?.apiRouter,console.log(`${B.blue}Using custom router for API handling${B.reset}`);if(T?.apiRoutes){V=T.apiRoutes;let b=Object.keys(V).length;if(b>0)console.log(`${B.blue}Loaded ${B.bright}${b} API route${b>1?"s":""}${B.reset}`)}if(T?.broadcasting?.enabled)try{let{startBroadcasting:b,loadChannels:S}=await import("./chunk-nenge2m2.js"),y=T.broadcasting;await b(y);let G0=y.port??6001;console.log(`${B.magenta}Broadcasting on ${B.cyan}ws://localhost:${G0}/ws${B.reset}`);let Y0=g.join(process.cwd(),"channels.ts");if(X0.existsSync(Y0))try{let T0=await S(Y0);console.log(`${B.blue}Loaded ${B.bright}${T0} broadcast channel${T0!==1?"s":""}${B.blue} from channels.ts${B.reset}`)}catch(T0){console.warn(`${B.yellow}Failed to load channels.ts: ${T0.message}${B.reset}`)}}catch(b){console.warn(`${B.yellow}Broadcasting failed to start: ${b.message}${B.reset}`)}}catch{}let E=S0(W,"output");X0.mkdirSync(E,{recursive:!0});let w=new Map,C=new Set,R=async(D)=>{let T=L6(F,D);if(!T)return null;try{let b=await Bun.build({entrypoints:[T],outdir:E,plugins:[e0],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!b.success)return null;let S=b.outputs.find((y)=>y.path.endsWith(".html"));if(!S)return null;return await Bun.file(S.path).text()}catch{return null}},I=async(D,T)=>{try{let{processDirectives:b,extractVariables:S,defaultConfig:y,loadStxConfig:G0,injectRouterScript:Y0}=await import("./chunk-gcns5vw5.js"),{checkCache:T0,cacheTemplate:S$,readFileCached:r,templateCache:S1}=await import("./chunk-00a028s3.js"),P1=await G0(W),x=(u)=>{if(!u)return u;if(g.isAbsolute(u))return u;return g.resolve(W,u)},v={...y,...P1,...X.stxOptions,autoShell:!0};if(X.debugDirectives)v.debug=!0;v.partialsDir=x(v.partialsDir),v.componentsDir=x(v.componentsDir),v.layoutsDir=x(v.layoutsDir),v.storesDir=x(v.storesDir||"stores"),v.cachePath=x(v.cachePath)??S0(W,"cache");let p=!T&&!X.profile,d=v.cache!==!1;if(d&&p){let u=S1.get(D.filePath);if(u)try{if((await X0.promises.stat(D.filePath)).mtime.getTime()<=u.mtime){let C0=!0;for(let n of u.dependencies){if(!X0.existsSync(n)){C0=!1;break}if((await X0.promises.stat(n)).mtime.getTime()>u.mtime){C0=!1;break}}if(C0){let n=u.output;if(A)n=J$(n,{preserveHead:!0});return{route:D,content:n,status:await B6(D.filePath)}}}}catch{}let _0=await T0(D.filePath,v);if(_0){let U0=_0;if(A)U0=J$(U0,{preserveHead:!0});return{route:D,content:U0,status:await B6(D.filePath)}}}let k=d?await r(D.filePath):await Bun.file(D.filePath).text(),W0=v$(k),{classifyAllScripts:j0}=await import("./chunk-gcns5vw5.js"),l=j0(k),J0=l.server.map((u)=>u.content),H0=k;for(let u of l.server)H0=H0.replace(u.fullTag,"");let K0={__filename:D.filePath,__dirname:g.dirname(D.filePath),params:T??{},__stx_runtime_head:{}};for(let u of J0)try{await S(u,K0,D.filePath)}catch(_0){if(X.stxOptions?.debug)console.error("[stx] variable extraction error",D.filePath,_0?.message||_0)}let P$=new Set,O0;if(X.profile){let u=performance.now();O0=await b(H0,K0,D.filePath,v,P$);let _0=performance.now()-u,U0=g.relative(W,D.filePath)||D.filePath;console.log(`[stx:profile] ${U0} \u2192 ${_0.toFixed(2)}ms`)}else O0=await b(H0,K0,D.filePath,v,P$);if(!A)O0=await Y0(O0,{router:v.router});{let{interpolateScriptExpressions:u}=await import("./chunk-5xpp3z95.js");O0=O0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(_0,U0,C0)=>{if(!/function\s+__stx_setup_/.test(C0))return _0;return`<script${U0}>${u(C0,K0)}</script>`})}if(A)O0=J$(O0,{preserveHead:!0});if(d&&p)await S$(D.filePath,O0,P$,v);let{extractStreamBoundaries:p7}=await import("./chunk-vpwjr05r.js"),a0=p7(K0),B1=K0.__streamTemplates;if(B1&&typeof B1==="object"&&Object.keys(B1).length>0){let u=K0.streamBoundaries||{},_0={...v,autoShell:!1},U0=Object.keys(B1).map((n)=>({id:n,render:async()=>{let P5=typeof u[n]==="function"?await u[n]():void 0;return b(B1[n],{...K0,$boundary:P5},D.filePath,_0,new Set)}})),C0=new Set(U0.map((n)=>n.id));a0=[...(a0||[]).filter((n)=>!C0.has(n.id)),...U0]}if(a0&&a0.length>0)C.add(D.pattern);else a0=void 0;return{route:D,content:O0,status:W0,boundaries:a0}}catch(b){return console.error(`${B.red}Error building ${B.bright}${D.pattern}${B.reset}:`,b),null}},m=8,h=async()=>{w.clear(),O.clear();for(let D=0;D<H.length;D+=m){let T=H.slice(D,D+m),b=await Promise.all(T.map((S)=>I(S)));for(let S of b)if(S)w.set(S.route.pattern,S)}for(let D=0;D<L.length;D+=m){let T=L.slice(D,D+m),b=await Promise.all(T.map(({route:S})=>I(S)));for(let S of b)if(S)O.set(S.route.pattern,S)}return w.size>0};if(console.log(`${B.blue}Building pages...${B.reset}`),!await h())return console.error(`${B.red}No pages were successfully built${B.reset}`),!1;await X$(W);let R0=Q;try{if(R0=await x0(Q),R0!==Q)console.log(`${B.yellow}Port ${Q} is busy, using port ${R0} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}if(Y){let D=X.hmrPort||R0+1;J=s1({wsPort:D,verbose:!1}),G=J.start(D)}let d0=(D,T)=>{let S=`<script data-stx-route-params>(function(){var p=${JSON.stringify(T).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(D.includes("</head>"))return D.replace("</head>",`${S}</head>`);if(D.includes("<body"))return D.replace(/<body([^>]*)>/,`<body$1>${S}`);return S+D};console.log(`${B.blue}Starting server...${B.reset}`);let k1=U4({port:R0,async fetch(D){let T=new URL(D.url),b=_?.publicDir||"public",S=g.join(W,b,T.pathname),y=g.join(W,T.pathname),G0=g.join(E,T.pathname),[Y0,T0,S$]=await Promise.all([X0.promises.stat(S).catch(()=>null),X0.promises.stat(y).catch(()=>null),X0.promises.stat(G0).catch(()=>null)]);if(Y0?.isFile())return i$(S);if(T0?.isFile())return i$(y);if(S$?.isFile())return i$(G0);if(T.pathname.startsWith("/_stx/component/")){let x=decodeURIComponent(T.pathname.slice(16));if(x)try{let v=`<${x} />`,p={...buildConfig,autoShell:!1},d=await processDirectives(v,{},g.join(W,"components",`${x}.stx`),p,new Set);return new Response(d,{headers:{"Content-Type":"text/html"}})}catch(v){return new Response(`<div class="stx-async-error">${v.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(T.pathname==="/_stx/img"){let{handleImageRequest:x}=await import("./chunk-xz019t7t.js"),v=await x(D,{publicDir:g.join(W,b),cacheDir:S0(W,"cache","img")});if(v)return v}if(N)try{let x=await N.handleRequest(D);if(x.status!==404)return x}catch{}if(V[T.pathname])try{return await V[T.pathname](D)}catch(x){return new Response(JSON.stringify({error:x.message}),{status:500,headers:{"Content-Type":"application/json"}})}let r=a$(T.pathname,H);if(r){let x=w.get(r.route.pattern),v=C.has(r.route.pattern);if(r.route.isDynamic&&Object.keys(r.params).length>0||v){let p=await I(r.route,r.params);if(p)x=p}if(x){let p=x.status??200,d=(r.route.filePath?M6(await Bun.file(r.route.filePath).text().catch(()=>"")):null)??{};if(d.validate){if(!await d.validate({params:r.params})){let j0=await R(404);if(j0){let l=j0;if(l=await s(l,W),Y)l=I0(l,G);return new Response(l,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(d.middleware){let W0=O6(T.pathname,r.params,d,T.search),j0=A6(W0,null,D,{isServer:!0}),l=await q6(d.middleware,j0);if(l.redirect){let J0=l.redirect.path,H0=l.redirect.options.redirectCode||302,K0=new Headers(l.responseHeaders);return K0.set("Location",J0),new Response(null,{status:H0,headers:K0})}if(l.abort){let{statusCode:J0,message:H0}=l.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${J0}</title></head><body><h1>Error ${J0}</h1><p>${H0}</p></body></html>`,{status:J0,headers:{"Content-Type":"text/html"}})}if(Object.keys(l.state).length>0){let J0=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(l.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;x.content=x.content.replace("</head>",`${J0}</head>`)}}let k=x.content;if(A&&D6(D)){let W0=N6(k),j0=R6(k),l=k.match(/<title[^>]*>([\s\S]*?)<\/title>/i),J0=l?l[1].trim():"";if(Object.keys(r.params).length>0)k=d0(k,r.params);k=await s(k,W);let H0=_?.router?.container||"main";return k=w6(k,H0),new Response(k,{status:p,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":W0.layout,"X-STX-Layout-Group":W0.group,"X-STX-Runtime":j0?"true":"false",...J0&&{"X-STX-Title":encodeURIComponent(J0)},[V6]:E6(),"Cache-Control":"no-store, no-cache, must-revalidate"}})}if(A)k=Y$(A,k);if(Object.keys(r.params).length>0)k=d0(k,r.params);if(k=await s(k,W),Y)k=I0(k,G);if(X.native)if(k.includes("<head>"))k=k.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 k="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+k;if(X.titlebarHidden)if(k.includes("<head>"))k=k.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 k=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${k}`;if(x.boundaries&&x.boundaries.length>0){let{renderStreamingPage:W0,streamToResponse:j0}=await import("./chunk-vpwjr05r.js");return j0(W0(k,x.boundaries,{timeoutMs:30000}),{status:p,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(k,{status:p,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}if(L.length>0){let x=L.map((p)=>p.route),v=a$(T.pathname,x);if(v){let p=O.get(v.route.pattern);if(p){let d=p.content;if(A)d=Y$(A,d);if(Object.keys(v.params).length>0)d=d0(d,v.params);if(d=await s(d,W),Y)d=I0(d,G);return new Response(d,{status:p.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:p}of j)if(p!=="/"&&T.pathname.startsWith(p)){let d=O.get(p)||O.get(p+"/");if(d){let k=d.content;if(A)k=Y$(A,k);if(k=await s(k,W),Y)k=I0(k,G);return new Response(k,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let S1=w.get("/");if(S1){let x=S1.content;if(x=await s(x,W),Y)x=I0(x,G);if(X.native)if(x.includes("<head>"))x=x.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 x="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+x;return new Response(x,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let P1=await R(404);if(P1){let x=P1;if(x=await s(x,W),Y)x=I0(x,G);return new Response(x,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(D){let T=await R(500);if(T)return new Response(T,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${D}
|
|
1610
|
+
Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),k0(z.url.toString(),()=>{if(Z)P0.watch(J,{recursive:!0}).close();z.stop()}),Z){console.log(`${B.blue}Watching for changes...${B.reset}`);let j=P0.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}`),m0.clear(),p0(),await K()});process.on("SIGINT",()=>{j.close(),z.stop(),process.exit(0)})}return!0}function W6($){return String($??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var{serve:U4}=globalThis.Bun;import X0 from"fs";import g from"path";async function B6($){try{return v$(await Bun.file($).text())}catch{return}}function i$($){let X=Bun.file($),Q=g.extname($).toLowerCase(),Z={".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(Q)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(X,{headers:{"Content-Type":Z[Q]||"application/octet-stream",...J}})}async function B4($=".",X={}){let Q=X.port||3000,Z=X.watch!==!1,Y=X.hotReload!==!1&&Z,J=null,G=X.hmrPort||Q+1,W=g.resolve($),{loadStxConfig:K}=await import("./chunk-d12xfcjd.js"),_=await K(W),U=_.root&&_.root!=="."?g.join(W,_.root):W,z=X.pagesDir||_.pagesDir||"pages",F=g.join(U,z);if(!X0.existsSync(F))return console.error(`${B.red}Error: No '${z}' directory found${B.reset}`),console.log(`${B.dim}Looked in: ${B.bright}${F}${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 ${z}/index.stx for the homepage.${B.reset}`),!1;let H=r$(U,{pagesDir:z});if(H.length===0)return console.error(`${B.red}Error: No page files found in ${B.bright}${F}${B.reset}`),!1;console.log(`${B.blue}Found ${B.bright}${H.length}${B.blue} routes${B.reset}`);let j=_?._pluginPageDirs||[],L=[];for(let{dir:D,prefix:T}of j)if(X0.existsSync(D)){let b=r$(g.dirname(D),{pagesDir:g.basename(D)});for(let S of b){let y=T==="/"?S.pattern:`${T}${S.pattern==="/"?"":S.pattern}`;L.push({route:{...S,pattern:y},prefix:T})}if(b.length>0)console.log(`${B.blue}Plugin pages: ${B.bright}${b.length}${B.blue} routes at ${B.cyan}${T}${B.reset}`)}let O=new Map,A=null,q=null;if(X.stxOptions?.shell!==!1){if(q=await I6(W,X.stxOptions?.shell),q){if(A=await s$(q,X.stxOptions||{}),A)console.log(`${B.blue}Using app shell: ${B.bright}${g.relative(W,q)}${B.reset} ${B.dim}(deprecated: use layouts/default.stx instead)${B.reset}`)}}z6(),await H6(W);let M=j6();if(M.length>0)console.log(`${B.blue}Loaded ${B.bright}${M.length}${B.blue} middleware: ${B.dim}${M.join(", ")}${B.reset}`);let V={},N=null;try{let{loadStxConfig:D}=await import("./chunk-d12xfcjd.js"),T=await D(W);if(T?.apiRouter)N=T?.apiRouter,console.log(`${B.blue}Using custom router for API handling${B.reset}`);if(T?.apiRoutes){V=T.apiRoutes;let b=Object.keys(V).length;if(b>0)console.log(`${B.blue}Loaded ${B.bright}${b} API route${b>1?"s":""}${B.reset}`)}if(T?.broadcasting?.enabled)try{let{startBroadcasting:b,loadChannels:S}=await import("./chunk-whxregkn.js"),y=T.broadcasting;await b(y);let G0=y.port??6001;console.log(`${B.magenta}Broadcasting on ${B.cyan}ws://localhost:${G0}/ws${B.reset}`);let Y0=g.join(process.cwd(),"channels.ts");if(X0.existsSync(Y0))try{let T0=await S(Y0);console.log(`${B.blue}Loaded ${B.bright}${T0} broadcast channel${T0!==1?"s":""}${B.blue} from channels.ts${B.reset}`)}catch(T0){console.warn(`${B.yellow}Failed to load channels.ts: ${T0.message}${B.reset}`)}}catch(b){console.warn(`${B.yellow}Broadcasting failed to start: ${b.message}${B.reset}`)}}catch{}let E=S0(W,"output");X0.mkdirSync(E,{recursive:!0});let w=new Map,C=new Set,R=async(D)=>{let T=L6(F,D);if(!T)return null;try{let b=await Bun.build({entrypoints:[T],outdir:E,plugins:[e0],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!b.success)return null;let S=b.outputs.find((y)=>y.path.endsWith(".html"));if(!S)return null;return await Bun.file(S.path).text()}catch{return null}},I=async(D,T)=>{try{let{processDirectives:b,extractVariables:S,defaultConfig:y,loadStxConfig:G0,injectRouterScript:Y0}=await import("./chunk-d12xfcjd.js"),{checkCache:T0,cacheTemplate:S$,readFileCached:r,templateCache:S1}=await import("./chunk-kregsntr.js"),P1=await G0(W),x=(u)=>{if(!u)return u;if(g.isAbsolute(u))return u;return g.resolve(W,u)},v={...y,...P1,...X.stxOptions,autoShell:!0};if(X.debugDirectives)v.debug=!0;v.partialsDir=x(v.partialsDir),v.componentsDir=x(v.componentsDir),v.layoutsDir=x(v.layoutsDir),v.storesDir=x(v.storesDir||"stores"),v.cachePath=x(v.cachePath)??S0(W,"cache");let p=!T&&!X.profile,d=v.cache!==!1;if(d&&p){let u=S1.get(D.filePath);if(u)try{if((await X0.promises.stat(D.filePath)).mtime.getTime()<=u.mtime){let C0=!0;for(let n of u.dependencies){if(!X0.existsSync(n)){C0=!1;break}if((await X0.promises.stat(n)).mtime.getTime()>u.mtime){C0=!1;break}}if(C0){let n=u.output;if(A)n=J$(n,{preserveHead:!0});return{route:D,content:n,status:await B6(D.filePath)}}}}catch{}let _0=await T0(D.filePath,v);if(_0){let U0=_0;if(A)U0=J$(U0,{preserveHead:!0});return{route:D,content:U0,status:await B6(D.filePath)}}}let k=d?await r(D.filePath):await Bun.file(D.filePath).text(),W0=v$(k),{classifyAllScripts:j0}=await import("./chunk-d12xfcjd.js"),l=j0(k),J0=l.server.map((u)=>u.content),H0=k;for(let u of l.server)H0=H0.replace(u.fullTag,"");let K0={__filename:D.filePath,__dirname:g.dirname(D.filePath),params:T??{},__stx_runtime_head:{}};for(let u of J0)try{await S(u,K0,D.filePath)}catch(_0){if(X.stxOptions?.debug)console.error("[stx] variable extraction error",D.filePath,_0?.message||_0)}let P$=new Set,O0;if(X.profile){let u=performance.now();O0=await b(H0,K0,D.filePath,v,P$);let _0=performance.now()-u,U0=g.relative(W,D.filePath)||D.filePath;console.log(`[stx:profile] ${U0} \u2192 ${_0.toFixed(2)}ms`)}else O0=await b(H0,K0,D.filePath,v,P$);if(!A)O0=await Y0(O0,{router:v.router});{let{interpolateScriptExpressions:u}=await import("./chunk-c18nh1et.js");O0=O0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(_0,U0,C0)=>{if(!/function\s+__stx_setup_/.test(C0))return _0;return`<script${U0}>${u(C0,K0)}</script>`})}if(A)O0=J$(O0,{preserveHead:!0});if(d&&p)await S$(D.filePath,O0,P$,v);let{extractStreamBoundaries:p7}=await import("./chunk-vkpmnn26.js"),a0=p7(K0),B1=K0.__streamTemplates;if(B1&&typeof B1==="object"&&Object.keys(B1).length>0){let u=K0.streamBoundaries||{},_0={...v,autoShell:!1},U0=Object.keys(B1).map((n)=>({id:n,render:async()=>{let P5=typeof u[n]==="function"?await u[n]():void 0;return b(B1[n],{...K0,$boundary:P5},D.filePath,_0,new Set)}})),C0=new Set(U0.map((n)=>n.id));a0=[...(a0||[]).filter((n)=>!C0.has(n.id)),...U0]}if(a0&&a0.length>0)C.add(D.pattern);else a0=void 0;return{route:D,content:O0,status:W0,boundaries:a0}}catch(b){return console.error(`${B.red}Error building ${B.bright}${D.pattern}${B.reset}:`,b),null}},m=8,h=async()=>{w.clear(),O.clear();for(let D=0;D<H.length;D+=m){let T=H.slice(D,D+m),b=await Promise.all(T.map((S)=>I(S)));for(let S of b)if(S)w.set(S.route.pattern,S)}for(let D=0;D<L.length;D+=m){let T=L.slice(D,D+m),b=await Promise.all(T.map(({route:S})=>I(S)));for(let S of b)if(S)O.set(S.route.pattern,S)}return w.size>0};if(console.log(`${B.blue}Building pages...${B.reset}`),!await h())return console.error(`${B.red}No pages were successfully built${B.reset}`),!1;await X$(W);let R0=Q;try{if(R0=await x0(Q),R0!==Q)console.log(`${B.yellow}Port ${Q} is busy, using port ${R0} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}if(Y){let D=X.hmrPort||R0+1;J=s1({wsPort:D,verbose:!1}),G=J.start(D)}let d0=(D,T)=>{let S=`<script data-stx-route-params>(function(){var p=${JSON.stringify(T).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(D.includes("</head>"))return D.replace("</head>",`${S}</head>`);if(D.includes("<body"))return D.replace(/<body([^>]*)>/,`<body$1>${S}`);return S+D};console.log(`${B.blue}Starting server...${B.reset}`);let k1=U4({port:R0,async fetch(D){let T=new URL(D.url),b=_?.publicDir||"public",S=g.join(W,b,T.pathname),y=g.join(W,T.pathname),G0=g.join(E,T.pathname),[Y0,T0,S$]=await Promise.all([X0.promises.stat(S).catch(()=>null),X0.promises.stat(y).catch(()=>null),X0.promises.stat(G0).catch(()=>null)]);if(Y0?.isFile())return i$(S);if(T0?.isFile())return i$(y);if(S$?.isFile())return i$(G0);if(T.pathname.startsWith("/_stx/component/")){let x=decodeURIComponent(T.pathname.slice(16));if(x)try{let v=`<${x} />`,p={...buildConfig,autoShell:!1},d=await processDirectives(v,{},g.join(W,"components",`${x}.stx`),p,new Set);return new Response(d,{headers:{"Content-Type":"text/html"}})}catch(v){return new Response(`<div class="stx-async-error">${v.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(T.pathname==="/_stx/img"){let{handleImageRequest:x}=await import("./chunk-8xtvmwpr.js"),v=await x(D,{publicDir:g.join(W,b),cacheDir:S0(W,"cache","img")});if(v)return v}if(N)try{let x=await N.handleRequest(D);if(x.status!==404)return x}catch{}if(V[T.pathname])try{return await V[T.pathname](D)}catch(x){return new Response(JSON.stringify({error:x.message}),{status:500,headers:{"Content-Type":"application/json"}})}let r=a$(T.pathname,H);if(r){let x=w.get(r.route.pattern),v=C.has(r.route.pattern);if(r.route.isDynamic&&Object.keys(r.params).length>0||v){let p=await I(r.route,r.params);if(p)x=p}if(x){let p=x.status??200,d=(r.route.filePath?M6(await Bun.file(r.route.filePath).text().catch(()=>"")):null)??{};if(d.validate){if(!await d.validate({params:r.params})){let j0=await R(404);if(j0){let l=j0;if(l=await s(l,W),Y)l=I0(l,G);return new Response(l,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(d.middleware){let W0=O6(T.pathname,r.params,d,T.search),j0=A6(W0,null,D,{isServer:!0}),l=await q6(d.middleware,j0);if(l.redirect){let J0=l.redirect.path,H0=l.redirect.options.redirectCode||302,K0=new Headers(l.responseHeaders);return K0.set("Location",J0),new Response(null,{status:H0,headers:K0})}if(l.abort){let{statusCode:J0,message:H0}=l.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${J0}</title></head><body><h1>Error ${J0}</h1><p>${H0}</p></body></html>`,{status:J0,headers:{"Content-Type":"text/html"}})}if(Object.keys(l.state).length>0){let J0=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(l.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;x.content=x.content.replace("</head>",`${J0}</head>`)}}let k=x.content;if(A&&D6(D)){let W0=N6(k),j0=R6(k),l=k.match(/<title[^>]*>([\s\S]*?)<\/title>/i),J0=l?l[1].trim():"";if(Object.keys(r.params).length>0)k=d0(k,r.params);k=await s(k,W);let H0=_?.router?.container||"main";return k=w6(k,H0),new Response(k,{status:p,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":W0.layout,"X-STX-Layout-Group":W0.group,"X-STX-Runtime":j0?"true":"false",...J0&&{"X-STX-Title":encodeURIComponent(J0)},[V6]:E6(),"Cache-Control":"no-store, no-cache, must-revalidate"}})}if(A)k=Y$(A,k);if(Object.keys(r.params).length>0)k=d0(k,r.params);if(k=await s(k,W),Y)k=I0(k,G);if(X.native)if(k.includes("<head>"))k=k.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 k="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+k;if(X.titlebarHidden)if(k.includes("<head>"))k=k.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 k=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${k}`;if(x.boundaries&&x.boundaries.length>0){let{renderStreamingPage:W0,streamToResponse:j0}=await import("./chunk-vkpmnn26.js");return j0(W0(k,x.boundaries,{timeoutMs:30000}),{status:p,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(k,{status:p,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}if(L.length>0){let x=L.map((p)=>p.route),v=a$(T.pathname,x);if(v){let p=O.get(v.route.pattern);if(p){let d=p.content;if(A)d=Y$(A,d);if(Object.keys(v.params).length>0)d=d0(d,v.params);if(d=await s(d,W),Y)d=I0(d,G);return new Response(d,{status:p.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:p}of j)if(p!=="/"&&T.pathname.startsWith(p)){let d=O.get(p)||O.get(p+"/");if(d){let k=d.content;if(A)k=Y$(A,k);if(k=await s(k,W),Y)k=I0(k,G);return new Response(k,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let S1=w.get("/");if(S1){let x=S1.content;if(x=await s(x,W),Y)x=I0(x,G);if(X.native)if(x.includes("<head>"))x=x.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 x="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+x;return new Response(x,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let P1=await R(404);if(P1){let x=P1;if(x=await s(x,W),Y)x=I0(x,G);return new Response(x,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(D){let T=await R(500);if(T)return new Response(T,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${D}
|
|
1611
1611
|
${D.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
|
|
1612
1612
|
${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(`
|
|
1613
1613
|
${B.bright}\u2192 ${B.cyan}http://localhost:${R0}/${B.reset}`),Y)console.log(`${B.dim} HMR: ws://localhost:${G}${B.reset}`);console.log(`
|
|
1614
1614
|
${B.yellow}Routes:${B.reset}`);let Z0=[...F6(H,W)];for(let{route:D}of L)Z0.push(`${D.pattern}`);if(Z0.forEach((D,T)=>{let S=T===Z0.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${B.green}${S}${B.reset}${D}`)}),console.log(`
|
|
1615
|
-
Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),k0(k1.url.toString(),()=>{if(J)j1();k1.stop()}),X.native){let D,T=g.join(F,"index.stx");if(X0.existsSync(T)){let S=await Bun.file(T).text();D=l1(S)}let b=_?.app?.window??{};await n0(R0,{title:_?.app?.head?.title||g.basename(W)||"stx App",width:b.width,height:b.height,darkMode:b.darkMode,hotReload:b.hotReload,titlebarHidden:b.titlebarHidden??X.titlebarHidden===!0,nativeSidebar:!!D,sidebarConfig:D})}if(Z){console.log(`${B.blue}Watching for changes...${B.reset}`);let D=(S)=>{return S.startsWith("public/")||S.startsWith("public\\")},T=(S)=>{let y=S.toLowerCase();return y.endsWith(".stx")||y.endsWith(".html")||y.endsWith(".md")},b=X0.watch(W,{recursive:!0},async(S,y)=>{if(!y||r1(y))return;if(a1(y))if(D(y)){if(console.log(`${B.cyan}${y} changed${B.reset}`),Y&&J)J.reload(y)}else if(T(y)){console.log(`${B.yellow}${y} changed, rebuilding...${B.reset}`),m0.clear(),p0();try{let{invalidateFileCache:G0,templateCache:Y0}=await import("./chunk-
|
|
1615
|
+
Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),k0(k1.url.toString(),()=>{if(J)j1();k1.stop()}),X.native){let D,T=g.join(F,"index.stx");if(X0.existsSync(T)){let S=await Bun.file(T).text();D=l1(S)}let b=_?.app?.window??{};await n0(R0,{title:_?.app?.head?.title||g.basename(W)||"stx App",width:b.width,height:b.height,darkMode:b.darkMode,hotReload:b.hotReload,titlebarHidden:b.titlebarHidden??X.titlebarHidden===!0,nativeSidebar:!!D,sidebarConfig:D})}if(Z){console.log(`${B.blue}Watching for changes...${B.reset}`);let D=(S)=>{return S.startsWith("public/")||S.startsWith("public\\")},T=(S)=>{let y=S.toLowerCase();return y.endsWith(".stx")||y.endsWith(".html")||y.endsWith(".md")},b=X0.watch(W,{recursive:!0},async(S,y)=>{if(!y||r1(y))return;if(a1(y))if(D(y)){if(console.log(`${B.cyan}${y} changed${B.reset}`),Y&&J)J.reload(y)}else if(T(y)){console.log(`${B.yellow}${y} changed, rebuilding...${B.reset}`),m0.clear(),p0();try{let{invalidateFileCache:G0,templateCache:Y0}=await import("./chunk-kregsntr.js");G0(g.resolve(W,y)),Y0.delete(g.resolve(W,y))}catch{}if(q&&y){if(g.resolve(W,y)===q||g.basename(q)===y){let Y0=await s$(q,X.stxOptions||{});if(Y0)A=Y0}}if(await h(),await Q$(W),Y&&J)J.reload(y)}else{console.log(`${B.yellow}${y} changed, rebuilding...${B.reset}`),m0.clear(),p0();try{let{invalidateFileCache:G0,templateCache:Y0}=await import("./chunk-kregsntr.js");G0(g.resolve(W,y)),Y0.delete(g.resolve(W,y))}catch{}if(await h(),Y&&J)J.reload(y)}else if(i1(y)){if(console.log(`${B.cyan}CSS ${y} changed${B.reset}`),Y&&J)J.updateCss(y)}});process.on("SIGINT",()=>{if(b.close(),J)j1();k1.stop(),process.exit(0)})}return!0}var L4=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function F4($){let X=($||"").trim();if(!X)return null;if(/[\s>+~,:]/.test(X))return null;let Q={},Z=X,Y=Z.match(/^[a-z][\w-]*/i);if(Y)Q.tag=Y[0].toLowerCase(),Z=Z.slice(Y[0].length);while(Z.length>0){let J=Z.match(/^\[([\w-]+)(?:=(["']?)([^\]"']*)\2)?\]/);if(J){if(Q.attr=J[1],J[3]!==void 0&&J[3]!=="")Q.attrValue=J[3];Z=Z.slice(J[0].length);continue}let G=Z.match(/^#([\w-]+)/);if(G){Q.id=G[1],Z=Z.slice(G[0].length);continue}let W=Z.match(/^\.([\w-]+)/);if(W){Q.className=W[1],Z=Z.slice(W[0].length);continue}return null}if(!Q.tag&&!Q.attr&&!Q.id&&!Q.className)return null;return Q}function z4($,X){if(X.attr){if(!(X.attrValue===void 0?new RegExp(`\\b${X.attr}(?=[\\s=>/]|$)`,"i"):new RegExp(`\\b${X.attr}\\s*=\\s*(["'])\\s*${X.attrValue}\\s*\\1`,"i")).test($))return!1}if(X.id){if(!new RegExp(`\\bid\\s*=\\s*(["'])\\s*${X.id}\\s*\\1`,"i").test($))return!1}if(X.className){let Q=$.match(/\bclass\s*=\s*(["'])([\s\S]*?)\1/i);if(!Q)return!1;if(!Q[2].split(/\s+/).includes(X.className))return!1}return!0}function IW($,X="main"){let Q=F4(X);if(!Q)return null;let Z=/<([a-z][\w-]*)\b([^>]*)>/gi,Y;while((Y=Z.exec($))!==null){let J=Y[1].toLowerCase(),G=Y[2]||"";if(G.trimEnd().endsWith("/")||L4.has(J))continue;if(Q.tag&&Q.tag!==J)continue;if(!z4(G,Q))continue;let W=Y[0],K=Y.index+W.length,_=new RegExp(`<(/?)${J}\\b([^>]*)>`,"gi");_.lastIndex=K;let U=1,z;while((z=_.exec($))!==null){let F=z[1]==="/";if(!F&&(z[2]||"").trimEnd().endsWith("/"))continue;if(U+=F?-1:1,U===0)return{openTag:W,openIndex:Y.index,start:K,end:z.index,tagName:J}}return null}return null}var P={enabled:!1,components:new Map,stores:new Map,events:[],performance:[],selectedComponent:null,selectedStore:null,maxEvents:1000,maxPerformance:500};function j4($={}){if(typeof window>"u")return;P.enabled=!0,P.maxEvents=$.maxEvents||1000,P.maxPerformance=$.maxPerformance||500,window.__STX_DEVTOOLS__={getState:()=>P,getComponents:()=>Array.from(P.components.values()),getComponent:(X)=>P.components.get(X),getStores:()=>Array.from(P.stores.values()),getStore:(X)=>P.stores.get(X),getEvents:()=>P.events,getPerformance:()=>P.performance,selectComponent:(X)=>o$(X),selectStore:(X)=>O4(X),inspectElement:(X)=>A4(X),highlightComponent:(X)=>S6(X),clearHighlight:()=>P6(),logComponentTree:()=>q4(),logStoreState:(X)=>N4(X),timeTravel:(X,Q)=>M4(X,Q)},E4(),V4(),console.log("%c[STX DevTools] Enabled","color: #10b981; font-weight: bold;")}function H4(){P.enabled=!1,delete window.__STX_DEVTOOLS__;let $=document.getElementById("stx-devtools-panel");if($)$.remove();console.log("%c[STX DevTools] Disabled","color: #ef4444;")}function T6($){if(!P.enabled)return;let X=P.components.get($);if(X){if(X.parentId){let Q=P.components.get(X.parentId);if(Q)Q.children=Q.children.filter((Z)=>Z!==$)}P.components.delete($),n$({timestamp:Date.now(),type:"component:unmounted",componentId:$,payload:{name:X.name}})}}function x6($,X,Q={},Z=[]){if(!P.enabled)return;let Y={id:$,state:X,getters:Q,actions:Z,history:[{timestamp:Date.now(),type:"state",name:"__init__",newValue:X}]};P.stores.set($,Y),n$({timestamp:Date.now(),type:"store:registered",payload:{id:$,state:X}})}function k6($,X,Q,Z,Y="state"){if(!P.enabled)return;let J=P.stores.get($);if(J){let G={timestamp:Date.now(),type:Y,name:X,oldValue:Q,newValue:Z,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]:Z};n$({timestamp:Date.now(),type:`store:${Y}`,payload:{storeId:$,name:X,oldValue:Q,newValue:Z}})}}function n$($){if(!P.enabled)return;if(P.events.push($),P.events.length>P.maxEvents)P.events=P.events.slice(-P.maxEvents);if(typeof window<"u")window.dispatchEvent(new CustomEvent("stx:devtools:event",{detail:$}))}function o$($){P.selectedComponent=$;let X=P.components.get($);if(X)S6($),console.log("%c[STX DevTools] Selected component:","color: #3b82f6;",X);return X}function O4($){P.selectedStore=$;let X=P.stores.get($);if(X)console.log("%c[STX DevTools] Selected store:","color: #8b5cf6;",X);return X}function A4($){let X=$;while(X){let Q=X.getAttribute("data-stx-component-id");if(Q)return o$(Q);X=X.parentElement}console.log("%c[STX DevTools] No component found for element","color: #f59e0b;");return}function S6($){P6();let X=P.components.get($);if(X?.element){let Q=document.createElement("div");Q.id="stx-devtools-highlight",Q.style.cssText=`
|
|
1616
1616
|
position: absolute;
|
|
1617
1617
|
background: rgba(59, 130, 246, 0.2);
|
|
1618
1618
|
border: 2px solid #3b82f6;
|
|
@@ -2881,9 +2881,9 @@ describe('Example', () => {
|
|
|
2881
2881
|
</footer>
|
|
2882
2882
|
@yield('scripts')
|
|
2883
2883
|
</body>
|
|
2884
|
-
</html>`}function hX(){return"<!-- Hero section -->"}function dX(){return"<!-- Features -->"}function uX(){return"<!-- Pricing -->"}function mX(){return"<!-- Button -->"}function R1($){if(!E1($))Y5($,{recursive:!0})}function pX(){if(E1("bun.lockb"))return"bun";if(E1("pnpm-lock.yaml"))return"pnpm";if(E1("yarn.lock"))return"yarn";return"bun"}function J5($){return $.replace(/[-_\s]+(.)?/g,(X,Q)=>Q?Q.toUpperCase():"").replace(/^./,(X)=>X.toUpperCase())}function cX($){return $.replace(/[-_\s]+(.)?/g,(X,Q)=>Q?Q.toUpperCase():"").replace(/^./,(X)=>X.toLowerCase())}function c0($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var{serve:lX}=globalThis.Bun;import I1 from"fs";import y0 from"path";function b2($,X=200,Q={}){return new Response($,{status:X,headers:{"Content-Type":"text/html; charset=utf-8",...Q}})}async function s6($){let{loadStxConfig:X}=await import("./chunk-
|
|
2884
|
+
</html>`}function hX(){return"<!-- Hero section -->"}function dX(){return"<!-- Features -->"}function uX(){return"<!-- Pricing -->"}function mX(){return"<!-- Button -->"}function R1($){if(!E1($))Y5($,{recursive:!0})}function pX(){if(E1("bun.lockb"))return"bun";if(E1("pnpm-lock.yaml"))return"pnpm";if(E1("yarn.lock"))return"yarn";return"bun"}function J5($){return $.replace(/[-_\s]+(.)?/g,(X,Q)=>Q?Q.toUpperCase():"").replace(/^./,(X)=>X.toUpperCase())}function cX($){return $.replace(/[-_\s]+(.)?/g,(X,Q)=>Q?Q.toUpperCase():"").replace(/^./,(X)=>X.toLowerCase())}function c0($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var{serve:lX}=globalThis.Bun;import I1 from"fs";import y0 from"path";function b2($,X=200,Q={}){return new Response($,{status:X,headers:{"Content-Type":"text/html; charset=utf-8",...Q}})}async function s6($){let{loadStxConfig:X}=await import("./chunk-evjs9zqm.js");return{...await X($.configDir??process.cwd()).catch(()=>({})),...$.stxOptions??{}}}async function iX($={}){let{port:X=3000,root:Q=".",watch:Z=!0,onRequest:Y,routes:J={},middleware:G=[],on404:W,onError:K}=$,_=y0.resolve(Q),U=await s6($),z=new Map;async function F(q){let M=I1.statSync(q),V=`${q}:${M.mtimeMs}`,N=z.get(V);if(N)return N.content;for(let D of z.keys())if(D.startsWith(`${q}:`)&&D!==V)z.delete(D);let E=await Bun.file(q).text(),w=E,C=o1(E);if(C)w=C.content.trim();let R=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,I=[],m=[],h;while((h=R.exec(E))!==null){let D=h[1],T=h[2],b=h[0];if(D.includes("server"))m.push(T);else I.push(b)}let E0=E.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi)||[],R0=w.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),d0={__filename:q,__dirname:y0.dirname(q)};for(let D of m)await B0(D,d0,q);let Z0=await L0(R0,d0,q,U,new Set);if(E0.length>0){let D=E0.join(`
|
|
2885
2885
|
`);if(Z0.match(/(<\/head>)/i))Z0=Z0.replace(/(<\/head>)/i,`${D}
|
|
2886
|
-
$1`)}if(I.length>0){let{interpolateScriptsInTemplate:D}=await import("./chunk-
|
|
2886
|
+
$1`)}if(I.length>0){let{interpolateScriptsInTemplate:D}=await import("./chunk-c18nh1et.js"),T=D(I.join(`
|
|
2887
2887
|
`),d0);if(Z0.match(/(<\/body>)/i))Z0=Z0.replace(/(<\/body>)/i,`${T}
|
|
2888
2888
|
$1`);else Z0+=`
|
|
2889
2889
|
${T}`}return z.set(V,{content:Z0,mtime:M.mtimeMs}),Z0}async function H(q){let M=I1.statSync(q),V=`${q}:${M.mtimeMs}`,N=z.get(V);if(N)return N.content;let{content:E}=await q0(q,U);return z.set(V,{content:E,mtime:M.mtimeMs}),E}function j(q){let M=q.startsWith("/")?q.slice(1):q,V=[M,`${M}.stx`,`${M}.md`,`${M}.html`,y0.join(M,"index.stx"),y0.join(M,"index.md"),y0.join(M,"index.html")];for(let N of V){let E=y0.join(_,N);if(I1.existsSync(E)&&I1.statSync(E).isFile())return E}return null}async function L(q){let M=new URL(q.url),V=async()=>{if(J[M.pathname])return await J[M.pathname](q);if(Y){let E=await Y(q);if(E)return E}let N=j(M.pathname);if(!N){if(W)return await W(q);return new Response("Not Found",{status:404})}try{let E,w="text/html";if(N.endsWith(".stx"))E=await F(N);else if(N.endsWith(".md"))E=await H(N);else if(N.endsWith(".html"))E=await Bun.file(N).text();else if(N.endsWith(".css"))E=await Bun.file(N).text(),w="text/css";else if(N.endsWith(".js"))E=await Bun.file(N).text(),w="text/javascript";else if(N.endsWith(".json"))E=await Bun.file(N).text(),w="application/json";else return new Response(Bun.file(N));return new Response(E,{headers:{"Content-Type":w}})}catch(E){if(K)return await K(E,q);let w=E instanceof Error?E.message:String(E),R=U?.debug===!0?`<h1>Error</h1><pre>${w}
|
|
@@ -4315,7 +4315,7 @@ else {
|
|
|
4315
4315
|
\u26A0\uFE0F Built ${Q.views.length} views with ${Q.errors.length} errors`);return Q}function r_($,X){let Q=j$.watch($.viewsDir,{recursive:!0},async(Z,Y)=>{if(!Y)return;if(Y.endsWith(".stx")||Y.endsWith(".ts")||Y.endsWith(".js")){if($.debug)console.log(`
|
|
4316
4316
|
File changed: ${Y}, rebuilding...`);let J=await zZ($);X?.(J)}});return{close:()=>Q.close()}}async function s_($,X={},Q={}){let Z={...Q,skipDefaultSeoTags:!0,skipSignalsRuntime:!0},Y=await L7($,X,Z);Y=await jZ(Y),Y=Y.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),Y=Y.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),Y=Y.replace(/<!--\s*stx SEO Tags\s*-->/gi,""),Y=Y.replace(/\n\s*\n\s*\n/g,`
|
|
4317
4317
|
|
|
4318
|
-
`).trim();let J=OZ(Y);return{html:Y,text:J}}async function jZ($){try{let{generateCrosswindCSS:X,extractClassNames:Q}=await import("./chunk-
|
|
4318
|
+
`).trim();let J=OZ(Y);return{html:Y,text:J}}async function jZ($){try{let{generateCrosswindCSS:X,extractClassNames:Q}=await import("./chunk-dt787jv4.js");if(Q($).size===0)return $;let Y=await X($);if(!Y)return $;let J=HZ(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,z)=>{let F=_.split(/\s+/).filter(Boolean),H=[];for(let A of F){let q=J.get(A);if(q)H.push(q)}if(H.length===0)return`${W}${K}class="${_}"${U}${z}`;let j=H.join("; "),O=`${K}${U}`.match(/style\s*=\s*"([^"]*)"/);if(O){let A=`${j}; ${O[1]}`,q=K.replace(/style\s*=\s*"[^"]*"/,`style="${A}"`),M=U.replace(/style\s*=\s*"[^"]*"/,`style="${A}"`);return`${W}${q}class="${_}"${M}${z}`}return`${W}${K}class="${_}" style="${j}"${U}${z}`})}catch{return $}}function HZ($){let X=new Map,Q=/\.([a-zA-Z0-9_-]+(?:\\:[a-zA-Z0-9_-]+)*)\s*\{([^}]+)\}/g,Z=Q.exec($);while(Z!==null){let Y=Z[1].replace(/\\/g,""),J=Z[2].split(";").map((G)=>G.trim()).filter(Boolean).join("; ");if(J)X.set(Y,J);Z=Q.exec($)}return X}function OZ($){return $.replace(/<br\s*\/?>/gi,`
|
|
4319
4319
|
`).replace(/<\/(p|div|h[1-6]|li|tr)>/gi,`
|
|
4320
4320
|
`).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,`
|
|
4321
4321
|
|
|
@@ -4450,7 +4450,7 @@ ${N}`}function e($){return $.replace(/&/g,"&").replace(/"/g,""").replac
|
|
|
4450
4450
|
`;let Q=$.sitemap!==!1?`Sitemap: ${$.url.replace(/\/$/,"")}/sitemap.xml
|
|
4451
4451
|
`:"";if(X==="disallow")return["User-agent: *","Disallow: /","",Q].filter(Boolean).join(`
|
|
4452
4452
|
`);return["User-agent: *","Allow: /","",Q].filter(Boolean).join(`
|
|
4453
|
-
`)}var U1=null;async function nZ(){if(U1!==null)return U1;try{let $=await import("./chunk-
|
|
4453
|
+
`)}var U1=null;async function nZ(){if(U1!==null)return U1;try{let $=await import("./chunk-aw9z3m10.js");if(typeof $.getRouterScript==="function")U1=$.getRouterScript();else U1=""}catch{U1=""}return U1}async function D5($,X){let Q=await nZ();if(!Q)return $;let Z={interceptAllLinks:!0,container:"main",...X},J=`${`<script>window.__stxRouterConfig=${JSON.stringify(Z)};</script>
|
|
4454
4454
|
`}<script>${Q}</script>`;if(/<\/body>/i.test($))return $.replace(/<\/body>/i,`${J}
|
|
4455
4455
|
</body>`);return`${$}
|
|
4456
4456
|
${J}`}var oZ=`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){}};`,tZ=($,X,Q,Z)=>`(function(){${oZ}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(Z)}:${JSON.stringify(Q)};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)})();`,eZ=($,X,Q)=>`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(Q)}:${JSON.stringify(X)});if(window.__stxThemeIcon)window.__stxThemeIcon(isDark)});`;function V$($,X){if(X.theme===!1)return $;let Q=$.includes(w7),Z=typeof X.theme==="object"&&X.theme!==null?X.theme:{},Y=Z.default??"dark",J=Z.storageKey??"theme",G=Z.colors?.light??"#ffffff",W=Z.colors?.dark??"#000000";if(Y==="dark"&&!Q){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,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
var K={},Y=[],O={};function I(){return K}function h(){return O}function D(){K={},Y.length=0,O={}}function U(j){K=Q(K,j)}function Q(j,z){return{title:z.title??j.title,titleTemplate:z.titleTemplate??j.titleTemplate,base:z.base??j.base,meta:[...j.meta||[],...z.meta||[]],link:[...j.link||[],...z.link||[]],script:[...j.script||[],...z.script||[]],style:[...j.style||[],...z.style||[]],htmlAttrs:{...j.htmlAttrs,...z.htmlAttrs},bodyAttrs:{...j.bodyAttrs,...z.bodyAttrs}}}function Z(j){U(_(j))}function _(j){let z=[];if(j.description)z.push({name:"description",content:j.description});if(j.keywords){let L=Array.isArray(j.keywords)?j.keywords.join(", "):j.keywords;z.push({name:"keywords",content:L})}if(j.author)z.push({name:"author",content:j.author});if(j.robots)z.push({name:"robots",content:j.robots});let A=j.ogTitle??j.title,B=j.ogDescription??j.description;if(A)z.push({property:"og:title",content:A});if(B)z.push({property:"og:description",content:B});if(j.ogImage)z.push({property:"og:image",content:j.ogImage});if(j.ogUrl)z.push({property:"og:url",content:j.ogUrl});if(j.ogType)z.push({property:"og:type",content:j.ogType});if(j.ogSiteName)z.push({property:"og:site_name",content:j.ogSiteName});if(j.ogLocale)z.push({property:"og:locale",content:j.ogLocale});let E=j.twitterTitle??j.title,F=j.twitterDescription??j.description,J=j.twitterImage??j.ogImage;if(j.twitterCard)z.push({name:"twitter:card",content:j.twitterCard});if(E)z.push({name:"twitter:title",content:E});if(F)z.push({name:"twitter:description",content:F});if(J)z.push({name:"twitter:image",content:J});if(j.twitterSite)z.push({name:"twitter:site",content:j.twitterSite});if(j.twitterCreator)z.push({name:"twitter:creator",content:j.twitterCreator});if(j.articleAuthor)z.push({property:"article:author",content:j.articleAuthor});if(j.articlePublishedTime)z.push({property:"article:published_time",content:j.articlePublishedTime});if(j.articleModifiedTime)z.push({property:"article:modified_time",content:j.articleModifiedTime});if(j.articleSection)z.push({property:"article:section",content:j.articleSection});if(j.articleTags)for(let L of j.articleTags)z.push({property:"article:tag",content:L});let G=[];if(j.canonical)G.push({rel:"canonical",href:j.canonical});return{title:j.title,titleTemplate:j.titleTemplate,meta:z,link:G}}function S(j){if(O={...O,...j},j.title||j.description)Z({title:j.title,description:j.description})}function P(j){let z=typeof j==="function"?j():j;U({title:z})}function C(j=K){let z=[];if(j.title){let A=j.title;if(j.titleTemplate)A=typeof j.titleTemplate==="function"?j.titleTemplate(A):j.titleTemplate.replace("%s",A);z.push(`<title>${N(A)}</title>`)}if(j.base){let A=Object.entries(j.base).map(([B,E])=>`${B}="${N(E)}"`).join(" ");z.push(`<base ${A}>`)}for(let A of j.meta||[]){let B=Object.entries(A).filter(([E,F])=>F!==void 0).map(([E,F])=>{return`${E==="httpEquiv"?"http-equiv":E}="${N(String(F))}"`}).join(" ");z.push(`<meta ${B}>`)}for(let A of j.link||[]){let B=Object.entries(A).filter(([E,F])=>F!==void 0).map(([E,F])=>`${E}="${N(String(F))}"`).join(" ");z.push(`<link ${B}>`)}for(let A of j.script||[]){let{content:B,...E}=A,F=Object.entries(E).filter(([J,G])=>G!==void 0).map(([J,G])=>{if(typeof G==="boolean")return G?J:"";return`${J}="${N(String(G))}"`}).filter(Boolean).join(" ");if(B)z.push(`<script ${F}>${B}</script>`);else z.push(`<script ${F}></script>`)}for(let A of j.style||[]){let B=A.type?` type="${A.type}"`:"";z.push(`<style${B}>${A.content}</style>`)}return z.join(`
|
|
3
3
|
`)}function M(j=K){if(!j.htmlAttrs)return"";return Object.entries(j.htmlAttrs).map(([z,A])=>`${z}="${N(A)}"`).join(" ")}function V(j=K){if(!j.bodyAttrs)return"";return Object.entries(j.bodyAttrs).map(([z,A])=>`${z}="${N(A)}"`).join(" ")}function N(j){return j.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function w(j=K){if(typeof document>"u")return;if(j.title){let z=j.title;if(j.titleTemplate)z=typeof j.titleTemplate==="function"?j.titleTemplate(z):j.titleTemplate.replace("%s",z);document.title=z}for(let z of j.meta||[]){let A=z.name?`meta[name="${z.name}"]`:z.property?`meta[property="${z.property}"]`:null;if(A){let B=document.querySelector(A);if(!B){if(B=document.createElement("meta"),z.name)B.setAttribute("name",z.name);if(z.property)B.setAttribute("property",z.property);document.head.appendChild(B)}B.setAttribute("content",z.content)}}for(let z of j.link||[]){let A=`link[rel="${z.rel}"]${z.href?`[href="${z.href}"]`:""}`,B=document.querySelector(A);if(!B)B=document.createElement("link"),document.head.appendChild(B);for(let[E,F]of Object.entries(z))if(F!==void 0)B.setAttribute(E,String(F))}if(j.htmlAttrs)for(let[z,A]of Object.entries(j.htmlAttrs))if(z==="class")for(let B of String(A).split(/\s+/).filter(Boolean))document.documentElement.classList.add(B);else document.documentElement.setAttribute(z,A);if(j.bodyAttrs)for(let[z,A]of Object.entries(j.bodyAttrs))document.body.setAttribute(z,A)}function y(j){let z="";return{content:j.replace(/@head\s*([\s\S]*?)@endhead/g,(B,E)=>{return z+=E.trim()+`
|
|
4
|
-
`,""}),headContent:z.trim()}}function x(j,z){return j.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(A,B,E,F)=>{let J=B?E:z[(F||"").trim()]??F,G=z.__stx_runtime_head??{};return z.__stx_runtime_head=Q(G,{title:J}),""})}function T(j,z){return j.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(A,B,E,F,J,G)=>{let L=F?J:G,R=F?L:z[(L||"").trim()]??L,W=E.includes(":")?{property:E,content:R}:{name:E,content:R},X=z.__stx_runtime_head??{};return z.__stx_runtime_head=Q(X,{meta:[W]}),""})}export{I as
|
|
4
|
+
`,""}),headContent:z.trim()}}function x(j,z){return j.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(A,B,E,F)=>{let J=B?E:z[(F||"").trim()]??F,G=z.__stx_runtime_head??{};return z.__stx_runtime_head=Q(G,{title:J}),""})}function T(j,z){return j.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(A,B,E,F,J,G)=>{let L=F?J:G,R=F?L:z[(L||"").trim()]??L,W=E.includes(":")?{property:E,content:R}:{name:E,content:R},X=z.__stx_runtime_head??{};return z.__stx_runtime_head=Q(X,{meta:[W]}),""})}export{I as Os,h as Ps,D as Qs,U as Rs,Q as Ss,Z as Ts,_ as Us,S as Vs,P as Ws,C as Xs,M as Ys,V as Zs,w as _s,y as $s,x as at,T as bt};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{is as _}from"./chunk-8anh6d36.js";import"./chunk-trtm887x.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,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{a as N,c as R,e as W,g as j,i as H,k as J}from"./chunk-0y46fbkx.js";import{l as k,m as w,n as B}from"./chunk-q9n5swx7.js";import"./chunk-
|
|
2
|
+
import{a as N,c as R,e as W,g as j,i as H,k as J}from"./chunk-0y46fbkx.js";import{l as k,m as w,n as B}from"./chunk-q9n5swx7.js";import"./chunk-trtm887x.js";import E from"fs";import K from"path";var V=[];function _(U){V=[];for(let A of U.storyFiles)if(V.push({text:A.fileName.toLowerCase(),original:A.fileName,type:"story",storyId:A.id}),V.push({text:A.relativePath.toLowerCase(),original:A.relativePath,type:"story",storyId:A.id}),A.story)for(let z of A.story.variants)V.push({text:z.title.toLowerCase(),original:z.title,type:"story",storyId:A.id,variantId:z.id})}function $(){return JSON.stringify(V)}async function O(U={}){let A=Date.now();N();let z=await k({mode:"build"});if(!z.config.enabled){W("Story feature is disabled in config.");return}let P=await H(z);w(z,P);let Y=J(z.config,P);B(z,Y),R(P.length);let X=U.outDir??z.config.outDir,Q=K.resolve(z.root,X);await E.promises.mkdir(Q,{recursive:!0}),console.log(` Building to ${X}...`);let M=F(z);await E.promises.writeFile(K.join(Q,"index.html"),M);let v={files:P.map((G)=>({id:G.id,fileName:G.fileName,relativePath:G.relativePath,treePath:G.treePath})),tree:Y};await E.promises.writeFile(K.join(Q,"stories.json"),JSON.stringify(v,null,2));let L={theme:z.config.theme,responsivePresets:z.config.responsivePresets,backgroundPresets:z.config.backgroundPresets};await E.promises.writeFile(K.join(Q,"config.json"),JSON.stringify(L,null,2));let Z=K.join(Q,"stories");await E.promises.mkdir(Z,{recursive:!0});for(let G of P){let g=await E.promises.readFile(G.path,"utf-8");await E.promises.writeFile(K.join(Z,`${G.id}.stx`),g)}_(z);let T=$();await E.promises.writeFile(K.join(Q,"search-index.json"),T);let C=Date.now()-A;j(P.length,X,C)}function F(U){let{theme:A}=U.config,z=A.title||"STX Story";return`<!DOCTYPE html>
|
|
3
3
|
<html lang="en">
|
|
4
4
|
<head>
|
|
5
5
|
<meta charset="UTF-8">
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Cg as a}from"./chunk-
|
|
2
|
+
import{Cg as a}from"./chunk-p7qqbw2k.js";import{Og as n,Qg as FF,Rg as YF,Sg as ZF}from"./chunk-vtqej9yr.js";import{xj as C,yj as D}from"./chunk-6ndvtzpk.js";import{Ak as XF,yk as JF,zk as QF}from"./chunk-yckd6ks5.js";import{Ap as r,Jr as c,Lr as N,Op as o,Vp as e,Wp as t,Yl as l,_l as d,mq as u}from"./chunk-8bmsw6gq.js";import{Hs as s}from"./chunk-qfsgw9by.js";import{Yt as S,_t as zF}from"./chunk-z47tw39z.js";import G from"fs";import Z from"path";import{createHash as WF}from"crypto";zF();function g(J){return WF("sha256").update(J).digest("hex").slice(0,8)}function f(J=!1){let q=J?D():C(),z=g(q);return{content:q,filename:`runtime.${z}.js`,hash:z}}function m(){let J=S(),q=g(J);return{content:J,filename:`router.${q}.js`,hash:q}}function KF(J){return{runtimeTag:J.runtime?`<script src="/__stx/${J.runtime.filename}"></script>`:"",routerTag:J.router?`<script src="/__stx/${J.router.filename}"></script>`:"",cssTag:J.css?`<link rel="stylesheet" href="/__stx/${J.css.filename}">`:""}}import h from"path";import{createHash as $F}from"crypto";function GF(J={}){let q=new Set;return{context:new Proxy(J,{get(Q,X){if(X in Q)return Q[X];if(typeof X==="string"&&!X.startsWith("__"))q.add(X);return},has(Q,X){if(X in Q)return!0;if(typeof X==="string"&&!X.startsWith("__"))q.add(X);return!1}}),accessedKeys:q}}async function p(J,q,z={}){let Q=h.resolve(J),X=await Bun.file(Q).text(),I=$F("sha256").update(X).digest("hex").slice(0,16);l();let K={};try{K=await N()}catch{}let B=[],V=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,k;while((k=V.exec(X))!==null){let $=k[1];if(/\bserver\b/.test($))B.push(k[2])}let W=new Set(B.flatMap(($)=>a($))),{context:E}=GF({__filename:Q,__dirname:h.dirname(Q),__stx_serverDeclared:W}),L=new Set,_={...c,...K,...z,buildMode:"compile",strict:!1},w=await u(X,E,Q,_,L),U=n(w),H=d();return{route:q,sourceFile:J,html:w,fragment:U,placeholders:H,hasServerScripts:B.length>0,serverScriptContent:B,dependencies:Array.from(L),contentHash:I,streamTemplates:E.__streamTemplates}}var VF=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function i(J,q){let z=0,Q=0;if(!G.existsSync(J))return{copied:z,bytes:Q};G.mkdirSync(q,{recursive:!0});function X(I,K){let B=G.readdirSync(I,{withFileTypes:!0});for(let V of B){if(VF.has(V.name))continue;let k=Z.join(I,V.name),W=Z.join(K,V.name);if(V.isDirectory())G.mkdirSync(W,{recursive:!0}),X(k,W);else if(V.isFile()){if(G.existsSync(W))continue;G.copyFileSync(k,W),z++,Q+=G.statSync(W).size}}}return X(J,q),{copied:z,bytes:Q}}async function mF(J={}){let q=Date.now(),z=Z.resolve(J.root||process.cwd()),Q=Z.resolve(z,J.outputDir||".output");console.log("[stx build] Starting production build...");let X={};try{X=await N()}catch{}let I=J.componentsDir??X.componentsDir??"components",K=J.partialsDir??X.partialsDir??"partials",B=J.layoutsDir??X.layoutsDir??"layouts",V=J.publicDir??X.publicDir??"public",k=X.app?.head||{},W=X.app?.colorMode,E=X.router?.container||"main";if(G.existsSync(Q))G.rmSync(Q,{recursive:!0});let L=[Z.join(Q,"public","__stx"),Z.join(Q,"public","assets"),Z.join(Q,"server","pages"),Z.join(Q,"server","fragments")];for(let Y of L)G.mkdirSync(Y,{recursive:!0});console.log("[stx build] Discovering routes...");let _=t(z),w=["components","layouts","partials"],U=_.filter((Y)=>{return!w.some((F)=>Y.pattern.startsWith(`/${F}/`)||Y.pattern===`/${F}`)});console.log(`[stx build] Found ${U.length} page routes (${_.length-U.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let H=f(J.debug),$=m();await Bun.write(Z.join(Q,"public","__stx",H.filename),H.content),await Bun.write(Z.join(Q,"public","__stx",$.filename),$.content),console.log(`[stx build] Runtime: ${H.filename} (${(H.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${$.filename} (${($.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let O=[],j=[];for(let Y of U)try{let F=await p(Y.filePath,Y.pattern,{componentsDir:I,partialsDir:K,layoutsDir:B,debug:J.debug});if(O.push(F),F.html=F.html.replace(/runtime\.__STX_HASH__\.js/g,H.filename).replace(/router\.__STX_HASH__\.js/g,$.filename),F.html=e(F.html,k,{bodyScripts:[`<script src="/__stx/${$.filename}"></script>`],...W&&{colorMode:W}}),W)F.html=r(F.html,W);if(k.htmlAttrs)F.html=o(F.html,k.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(F.html)){let T=F.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(T&&T[1]){let P=T[1];F.html=F.html.replace(" "+P,""),F.html=F.html.replace(/<body([^>]*)>/,`<body$1 ${P}>`)}}F.html=F.html.replace(/<style data-crosswind="generated">[\s\S]*?<\/style>\s*/g,""),F.html=await s(F.html),F.fragment=FF(F.html,E);let y=Y.pattern==="/"?"index":Y.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),b=Z.join("server","pages",`${y}.compiled.json`),A=Z.join("server","fragments",`${y}.html`);await Bun.write(Z.join(Q,b),JSON.stringify(F,null,2)),await Bun.write(Z.join(Q,A),F.fragment),j.push({pattern:Y.pattern,compiledPath:b,fragmentPath:A,isDynamic:F.hasServerScripts,hasParams:Y.pattern.includes(":")||Y.pattern.includes("[")}),console.log(`[stx build] \u2713 ${Y.pattern}`)}catch(F){console.error(`[stx build] \u2717 ${Y.pattern}:`,F instanceof Error?F.message:F)}let M=Z.resolve(z,V);if(G.existsSync(M)){let{copied:Y,bytes:F}=i(M,Z.join(Q,"public"));if(Y>0)console.log(`[stx build] Copied ${Y} public asset${Y===1?"":"s"} (${(F/1024).toFixed(1)}KB) from ${V}/`)}let v=XF(z);if(v){let{copied:Y,bytes:F}=i(v,Z.join(Q,"public",QF));if(Y>0)console.log(`[stx build] Copied ${Y} asset${Y===1?"":"s"} (${(F/1024).toFixed(1)}KB) from ${JF}/`)}let R={runtime:H.filename,router:$.filename},qF=YF(j,R,Q);ZF(qF,Q);let x=Date.now()-q;return console.log(`
|
|
3
3
|
[stx build] Done in ${x}ms \u2014 ${O.length} pages compiled`),{pageCount:O.length,assets:R,outputDir:Q,duration:x}}
|
|
4
4
|
export{g as sg,f as tg,m as ug,KF as vg,p as wg,mF as xg};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{a as x,b as u,c as b,d as Az,e as G,f as d,h as y,i as I,j as Uz,k as v}from"./chunk-0y46fbkx.js";import{l as h,m as f,n as g}from"./chunk-q9n5swx7.js";import{
|
|
2
|
+
import{a as x,b as u,c as b,d as Az,e as G,f as d,h as y,i as I,j as Uz,k as v}from"./chunk-0y46fbkx.js";import{l as h,m as f,n as g}from"./chunk-q9n5swx7.js";import{No as V}from"./chunk-8bmsw6gq.js";import"./chunk-j0tfxbns.js";import"./chunk-khrtzbxd.js";import"./chunk-8anh6d36.js";import"./chunk-3fwn9edg.js";import"./chunk-qfsgw9by.js";import"./chunk-m2mhtpwy.js";import"./chunk-6xg3j487.js";import"./chunk-q4se9rtw.js";import"./chunk-1nm2xrvq.js";import"./chunk-z47tw39z.js";import"./chunk-3wd9kfyz.js";import{iu as F}from"./chunk-trtm887x.js";import l from"fs";import R from"path";function m(z,J){let Z=[R.join(z.root,"stx.config.ts"),R.join(z.root,"stx.config.js"),R.join(z.root,"stx.config.mjs")],K=J.debounceMs??300,$=null,X=[];for(let B of Z)try{if(!l.existsSync(B))continue;let Y=l.watch(B,(W)=>{if(W==="change"){if($)clearTimeout($);$=setTimeout(async()=>{d("Config file changed, restarting...");try{await J.onChange()}catch(j){G(`Failed to restart: ${j}`)}},K)}});X.push(Y)}catch{}return{stop(){if($)clearTimeout($);for(let B of X)B.close()}}}import E from"fs";import i from"path";var Gz=".stx/story/analytics.json",Nz=1,c=1e4;class M{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(z){this.storagePath=i.join(z,Gz),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let z=E.readFileSync(this.storagePath,"utf-8");return JSON.parse(z)}catch{return{version:Nz,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let z=i.dirname(this.storagePath);if(await E.promises.mkdir(z,{recursive:!0}),this.storage.events.length>c)this.storage.events=this.storage.events.slice(-c);await E.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:Hz(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(z){this.storage.events.push({...z,timestamp:Date.now()}),this.dirty=!0}trackView(z,J){if(this.endViewTiming(z),this.viewStartTimes.set(z,Date.now()),this.track({type:"view",componentId:z,variantId:J}),this.currentSession&&!this.currentSession.componentViews.includes(z))this.currentSession.componentViews.push(z)}endViewTiming(z){let J=this.viewStartTimes.get(z);if(J){let Z=Date.now()-J;this.track({type:"view",componentId:z,metadata:{duration:Z,endView:!0}}),this.viewStartTimes.delete(z)}}trackPropChange(z,J,Z){this.track({type:"prop_change",componentId:z,propName:J,metadata:{value:Z}})}trackVariantSwitch(z,J){this.track({type:"variant_switch",componentId:z,variantId:J})}trackSearch(z,J){this.track({type:"search",query:z,metadata:{resultCount:J}})}getComponentAnalytics(z,J){let Z=this.storage.events.filter((Q)=>Q.componentId===z),K=Z.filter((Q)=>Q.type==="view"&&!Q.metadata?.endView),$=Z.filter((Q)=>Q.type==="prop_change"),X=Z.filter((Q)=>Q.type==="variant_switch"),B={};for(let Q of $)if(Q.propName)B[Q.propName]=(B[Q.propName]||0)+1;let Y={};for(let Q of X)if(Q.variantId)Y[Q.variantId]=(Y[Q.variantId]||0)+1;let W=new Set(this.storage.sessions.filter((Q)=>Q.componentViews.includes(z)).map((Q)=>Q.id)),j=Z.filter((Q)=>Q.metadata?.duration).map((Q)=>Q.metadata.duration),U=j.length>0?j.reduce((Q,D)=>Q+D,0)/j.length:0,_=Object.entries(B).sort((Q,D)=>D[1]-Q[1]).slice(0,5).map(([Q])=>Q);return{componentId:z,componentName:J,viewCount:K.length,uniqueViews:W.size,lastViewed:K[K.length-1]?.timestamp,propChanges:B,topChangedProps:_,variantViews:Y,avgTimeSpent:U}}getMostViewedComponents(z=10){let J=new Map;for(let Z of this.storage.events)if(Z.type==="view"&&Z.componentId&&!Z.metadata?.endView)J.set(Z.componentId,(J.get(Z.componentId)||0)+1);return Array.from(J.entries()).map(([Z,K])=>({componentId:Z,viewCount:K})).sort((Z,K)=>K.viewCount-Z.viewCount).slice(0,z)}getMostChangedProps(z=10){let J=new Map;for(let Z of this.storage.events)if(Z.type==="prop_change"&&Z.propName)J.set(Z.propName,(J.get(Z.propName)||0)+1);return Array.from(J.entries()).map(([Z,K])=>({propName:Z,changeCount:K})).sort((Z,K)=>K.changeCount-Z.changeCount).slice(0,z)}getSearchAnalytics(){let z=this.storage.events.filter(($)=>$.type==="search"),J=new Map,Z=0;for(let $ of z){if($.query)J.set($.query,(J.get($.query)||0)+1);if($.metadata?.resultCount!==void 0)Z+=$.metadata.resultCount}let K=Array.from(J.entries()).map(([$,X])=>({query:$,count:X})).sort(($,X)=>X.count-$.count).slice(0,10);return{totalSearches:z.length,topQueries:K,avgResultCount:z.length>0?Z/z.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function Hz(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import P from"fs";import p from"path";var Fz=".stx/story/bookmarks.json",Vz=1;class T{storage;storagePath;dirty=!1;constructor(z){this.storagePath=p.join(z,Fz),this.storage=this.loadStorage()}loadStorage(){try{let z=P.readFileSync(this.storagePath,"utf-8");return JSON.parse(z)}catch{return{version:Vz,bookmarks:[]}}}async save(){if(!this.dirty)return;let z=p.dirname(this.storagePath);await P.promises.mkdir(z,{recursive:!0}),await P.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(z,J,Z,K={}){let $={id:Rz(),name:K.name||`${z}/${J}`,storyId:z,variantId:J,props:Z,created:Date.now(),notes:K.notes,color:K.color};return this.storage.bookmarks.push($),this.dirty=!0,$}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(z){return this.storage.bookmarks.filter((J)=>J.storyId===z)}getBookmark(z){return this.storage.bookmarks.find((J)=>J.id===z)}isBookmarked(z,J){return this.storage.bookmarks.some((Z)=>Z.storyId===z&&Z.variantId===J)}updateBookmark(z,J){let Z=this.getBookmark(z);if(!Z)return;return Object.assign(Z,J),this.dirty=!0,Z}deleteBookmark(z){let J=this.storage.bookmarks.findIndex((Z)=>Z.id===z);if(J===-1)return!1;return this.storage.bookmarks.splice(J,1),this.dirty=!0,!0}toggleBookmark(z,J,Z){let K=this.storage.bookmarks.find((X)=>X.storyId===z&&X.variantId===J);if(K)return this.deleteBookmark(K.id),{added:!1};return{added:!0,bookmark:this.addBookmark(z,J,Z)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(z,J=!0){let Z=JSON.parse(z),K=0;for(let $ of Z.bookmarks){if(J){let X=this.storage.bookmarks.find((B)=>B.id===$.id);if(X)Object.assign(X,$);else this.storage.bookmarks.push($)}else this.storage.bookmarks.push($);K++}if(K>0)this.dirty=!0;return K}}function Rz(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var N=new Set;function s(){return{open(z){N.add(z),z.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(z){N.delete(z)},message(z,J){}}}function q(z){let J=JSON.stringify({...z,timestamp:z.timestamp||Date.now()});for(let Z of N)try{Z.send(J)}catch{N.delete(Z)}}function n(z,J){q({type:"story-update",data:{storyId:z,...J}})}function a(z,J){q({type:"story-add",data:{storyId:z,...J}})}function o(z){q({type:"story-remove",data:{storyId:z}})}function r(z){return`
|
|
3
3
|
<script>
|
|
4
4
|
(function() {
|
|
5
5
|
const ws = new WebSocket('${z}');
|
|
@@ -556,7 +556,7 @@ window.__stxPerformance = {
|
|
|
556
556
|
|
|
557
557
|
window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
|
|
558
558
|
</script>
|
|
559
|
-
`}import w from"fs";import Xz from"path";var Mz=".stx/story/presets.json",C=1,Pz=10;class k{storage;storagePath;dirty=!1;constructor(z){this.storagePath=Xz.join(z,Mz),this.storage=this.loadStorage()}loadStorage(){try{let z=w.readFileSync(this.storagePath,"utf-8"),J=JSON.parse(z);if(J.version!==C)return this.migrateStorage(J);return J}catch{return{version:C,presets:[],recentIds:[]}}}migrateStorage(z){return{version:C,presets:z.presets||[],recentIds:z.recentIds||[]}}async save(){if(!this.dirty)return;let z=Xz.dirname(this.storagePath);await w.promises.mkdir(z,{recursive:!0}),await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(z,J,Z={}){let K={id:Tz(),name:z,description:Z.description,props:J,componentId:Z.componentId,created:Date.now(),usageCount:0,tags:Z.tags};return this.storage.presets.push(K),this.dirty=!0,K}getPreset(z){return this.storage.presets.find((J)=>J.id===z)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(z){return this.storage.presets.filter((J)=>!J.componentId||J.componentId===z)}getRecentPresets(){return this.storage.recentIds.map((z)=>this.getPreset(z)).filter((z)=>z!==void 0)}usePreset(z){let J=this.getPreset(z);if(!J)return;return J.lastUsed=Date.now(),J.usageCount++,this.storage.recentIds=[z,...this.storage.recentIds.filter((Z)=>Z!==z)].slice(0,Pz),this.dirty=!0,J}updatePreset(z,J){let Z=this.getPreset(z);if(!Z)return;return Object.assign(Z,J),this.dirty=!0,Z}deletePreset(z){let J=this.storage.presets.findIndex((Z)=>Z.id===z);if(J===-1)return!1;return this.storage.presets.splice(J,1),this.storage.recentIds=this.storage.recentIds.filter((Z)=>Z!==z),this.dirty=!0,!0}searchPresets(z){let J=z.toLowerCase();return this.storage.presets.filter((Z)=>{if(Z.name.toLowerCase().includes(J))return!0;if(Z.description?.toLowerCase().includes(J))return!0;if(Z.tags?.some((K)=>K.toLowerCase().includes(J)))return!0;return!1})}getMostUsedPresets(z=5){return[...this.storage.presets].sort((J,Z)=>Z.usageCount-J.usageCount).slice(0,z)}exportPresets(z){let J=z?this.storage.presets.filter((Z)=>z.includes(Z.id)):this.storage.presets;return JSON.stringify({presets:J},null,2)}importPresets(z,J=!1){let Z=JSON.parse(z),K=0;for(let $ of Z.presets){let X=this.storage.presets.find((B)=>B.id===$.id);if(X&&!J)continue;if(X)Object.assign(X,$);else this.storage.presets.push($);K++}if(K>0)this.dirty=!0;return K}}function Tz(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";var Qz=new Map;async function H(z,J,Z={}){let K=performance.now(),$=[];try{let X=await S.promises.stat(J),B=Qz.get(J),Y;if(B&&B.mtime===X.mtimeMs)Y=B.content;else Y=await S.promises.readFile(J,"utf-8"),Qz.set(J,{content:Y,mtime:X.mtimeMs,analyzed:null});let{processDirectives:W}=await import("./chunk-
|
|
559
|
+
`}import w from"fs";import Xz from"path";var Mz=".stx/story/presets.json",C=1,Pz=10;class k{storage;storagePath;dirty=!1;constructor(z){this.storagePath=Xz.join(z,Mz),this.storage=this.loadStorage()}loadStorage(){try{let z=w.readFileSync(this.storagePath,"utf-8"),J=JSON.parse(z);if(J.version!==C)return this.migrateStorage(J);return J}catch{return{version:C,presets:[],recentIds:[]}}}migrateStorage(z){return{version:C,presets:z.presets||[],recentIds:z.recentIds||[]}}async save(){if(!this.dirty)return;let z=Xz.dirname(this.storagePath);await w.promises.mkdir(z,{recursive:!0}),await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(z,J,Z={}){let K={id:Tz(),name:z,description:Z.description,props:J,componentId:Z.componentId,created:Date.now(),usageCount:0,tags:Z.tags};return this.storage.presets.push(K),this.dirty=!0,K}getPreset(z){return this.storage.presets.find((J)=>J.id===z)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(z){return this.storage.presets.filter((J)=>!J.componentId||J.componentId===z)}getRecentPresets(){return this.storage.recentIds.map((z)=>this.getPreset(z)).filter((z)=>z!==void 0)}usePreset(z){let J=this.getPreset(z);if(!J)return;return J.lastUsed=Date.now(),J.usageCount++,this.storage.recentIds=[z,...this.storage.recentIds.filter((Z)=>Z!==z)].slice(0,Pz),this.dirty=!0,J}updatePreset(z,J){let Z=this.getPreset(z);if(!Z)return;return Object.assign(Z,J),this.dirty=!0,Z}deletePreset(z){let J=this.storage.presets.findIndex((Z)=>Z.id===z);if(J===-1)return!1;return this.storage.presets.splice(J,1),this.storage.recentIds=this.storage.recentIds.filter((Z)=>Z!==z),this.dirty=!0,!0}searchPresets(z){let J=z.toLowerCase();return this.storage.presets.filter((Z)=>{if(Z.name.toLowerCase().includes(J))return!0;if(Z.description?.toLowerCase().includes(J))return!0;if(Z.tags?.some((K)=>K.toLowerCase().includes(J)))return!0;return!1})}getMostUsedPresets(z=5){return[...this.storage.presets].sort((J,Z)=>Z.usageCount-J.usageCount).slice(0,z)}exportPresets(z){let J=z?this.storage.presets.filter((Z)=>z.includes(Z.id)):this.storage.presets;return JSON.stringify({presets:J},null,2)}importPresets(z,J=!1){let Z=JSON.parse(z),K=0;for(let $ of Z.presets){let X=this.storage.presets.find((B)=>B.id===$.id);if(X&&!J)continue;if(X)Object.assign(X,$);else this.storage.presets.push($);K++}if(K>0)this.dirty=!0;return K}}function Tz(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";var Qz=new Map;async function H(z,J,Z={}){let K=performance.now(),$=[];try{let X=await S.promises.stat(J),B=Qz.get(J),Y;if(B&&B.mtime===X.mtimeMs)Y=B.content;else Y=await S.promises.readFile(J,"utf-8"),Qz.set(J,{content:Y,mtime:X.mtimeMs,analyzed:null});let{processDirectives:W}=await import("./chunk-mghyceb1.js"),j={},U=A(Y);if(U)try{await V(U,j,J)}catch(O){$.push(`Warning: Could not extract script variables: ${O instanceof Error?O.message:String(O)}`)}if(Z.props)Object.assign(j,Z.props);let Q=await W(Y,j,J,{},new Set),D=Wz(Y),L=A(Y);return Q=jz(Q),Q=Dz(Q,j),{html:Q,css:D,js:L,errors:$,duration:performance.now()-K}}catch(X){return $.push(X instanceof Error?X.message:String(X)),{html:`<div class="stx-render-error">${Lz($[0])}</div>`,css:"",js:"",errors:$,duration:performance.now()-K}}}async function qz(z){try{let J=await S.promises.readFile(z,"utf-8"),Z=A(J);if(!Z)return null;let K={};if(await V(Z,K,z),Array.isArray(K.variants))return K.variants;return null}catch{return null}}async function Bz(z,J,Z,K){let $=J.story?.variants;if(!$){let Y=await qz(J.path);if(Y)$=Y}if(!$&&Z==="default")return H(z,J.path,{props:K||{}});if(!$)return H(z,J.path,{props:K||{}});let X=$.find((Y)=>Y.id===Z);if(!X&&Z==="default")return H(z,J.path,{props:K||{}});if(!X)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${Z}' not found`],duration:0};let B={...X.state,...K};if(X.source)return wz(z,X.source,B);return H(z,J.path,{props:B})}async function wz(z,J,Z={}){let K=performance.now(),$=[];try{let{processDirectives:X}=await import("./chunk-mghyceb1.js"),B={...Z},Y=A(J);if(Y)try{await V(Y,B,"inline-template.stx")}catch{}let j=await X(J,B,"inline-template.stx",{},new Set);return j=jz(j),j=Dz(j,B),{html:j,css:Wz(J),js:A(J),errors:$,duration:performance.now()-K}}catch(X){return $.push(X instanceof Error?X.message:String(X)),{html:`<div class="stx-render-error">${Lz($[0])}</div>`,css:"",js:"",errors:$,duration:performance.now()-K}}}function Wz(z){let J=[],Z=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,K=Z.exec(z);while(K!==null)J.push(K[1].trim()),K=Z.exec(z);return J.join(`
|
|
560
560
|
`)}function jz(z){return z.replace(/<!--[\s\S]*?-->/g,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/^\s*\n/gm,"").trim()}function A(z){let J=[],Z=/<script\b[^>]*>([\s\S]*?)<\/script>/gi,K=Z.exec(z);while(K!==null)J.push(K[1].trim()),K=Z.exec(z);return J.join(`
|
|
561
561
|
`)}function Dz(z,J){let Z=`<script>window.__stxProps = ${JSON.stringify(J)};</script>`;return z+Z}function Lz(z){return z.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}async function Oz(z,J){let Z=await I(z);f(z,Z);let K=v(z.config,Z);g(z,K),console.log(` Found ${Z.length} story files`);let $=typeof J.host==="string"?J.host:J.host===!0?"0.0.0.0":"localhost",X=new k(z.root),B=new T(z.root),Y=new M(z.root),W=s(),j=Bun.serve({port:J.port,hostname:$,fetch:async(Q,D)=>{let O=new URL(Q.url).pathname;if(O==="/__hmr"){if(D.upgrade(Q,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(O.startsWith("/api/"))return Cz(z,O,Q,{presetsManager:X,bookmarksManager:B,analyticsTracker:Y});return kz(z,O,J.port)},websocket:{open(Q){W.open(Q)},close(Q){W.close(Q)},message(Q,D){W.message(Q,D)}}}),U=`http://${$}:${J.port}`,_=Uz(z,async(Q,D)=>{console.log(` [${Q}] ${D.relativePath}`);let L=await I(z);f(z,L);let O=v(z.config,L);if(g(z,O),Q==="add")a(D.id,{fileName:D.fileName});else if(Q==="unlink")o(D.id);else n(D.id,{fileName:D.fileName})});if(J.open){let Q=U;try{let{exec:D}=await import("child_process"),L=process.platform;D(`${L==="darwin"?"open":L==="win32"?"start":"xdg-open"} ${Q}`)}catch{}}return{server:j,url:U,close:async()=>{_(),j.stop()}}}async function Cz(z,J,Z,K){let{presetsManager:$,bookmarksManager:X,analyticsTracker:B}=K;if(J==="/api/stories")return Response.json({files:z.storyFiles.map((Y)=>({id:Y.id,fileName:Y.fileName,relativePath:Y.relativePath,treePath:Y.treePath})),tree:z.tree});if(J.startsWith("/api/story/")){let Y=J.slice(11),W=z.storyFiles.find((j)=>j.id===Y);if(!W)return new Response("Story not found",{status:404});try{let j=await Bun.file(W.path).text();return Response.json({id:W.id,fileName:W.fileName,relativePath:W.relativePath,content:j})}catch{return new Response("Error reading story",{status:500})}}if(J==="/api/config")return Response.json({theme:z.config.theme,responsivePresets:z.config.responsivePresets,backgroundPresets:z.config.backgroundPresets});if(J.startsWith("/api/render/")){let Y=new URL(Z.url),W=J.slice(12).split("/"),j=W[0],U=W[1]||"default",_,Q=Y.searchParams.get("props");if(Q)try{_=JSON.parse(Q)}catch{}let D=z.storyFiles.find((L)=>L.id===j);if(!D)return new Response("Story not found",{status:404});try{let L=await Bz(z,D,U,_);return Response.json({html:L.html,css:L.css,js:L.js,errors:L.errors,duration:L.duration})}catch(L){return Response.json({html:"",css:"",js:"",errors:[L instanceof Error?L.message:String(L)],duration:0},{status:500})}}if(J==="/api/presets"&&Z.method==="GET")return Response.json({presets:$.getAllPresets()});if(J==="/api/presets"&&Z.method==="POST")try{let Y=await Z.json(),W=$.createPreset(Y.name,Y.props,{componentId:Y.componentId,description:Y.description});return await $.save(),Response.json(W)}catch(Y){return Response.json({error:String(Y)},{status:400})}if(J.startsWith("/api/presets/")&&!J.includes("/use")&&Z.method==="GET"){let Y=J.slice(13),W=$.getPreset(Y);if(!W)return new Response("Preset not found",{status:404});return Response.json(W)}if(J.endsWith("/use")&&Z.method==="POST"){let Y=J.slice(13,-4),W=$.usePreset(Y);if(!W)return new Response("Preset not found",{status:404});return await $.save(),Response.json(W)}if(J.startsWith("/api/presets/")&&Z.method==="DELETE"){let Y=J.slice(13);if(!$.deletePreset(Y))return new Response("Preset not found",{status:404});return await $.save(),Response.json({success:!0})}if(J==="/api/bookmarks"&&Z.method==="GET")return Response.json({bookmarks:X.getAllBookmarks()});if(J==="/api/bookmarks"&&Z.method==="POST")try{let Y=await Z.json(),W=X.addBookmark(Y.storyId,Y.variantId,Y.props,{name:Y.name,notes:Y.notes,color:Y.color});return await X.save(),Response.json(W)}catch(Y){return Response.json({error:String(Y)},{status:400})}if(J==="/api/bookmarks/toggle"&&Z.method==="POST")try{let Y=await Z.json(),W=X.toggleBookmark(Y.storyId,Y.variantId,Y.props);return await X.save(),Response.json(W)}catch(Y){return Response.json({error:String(Y)},{status:400})}if(J.startsWith("/api/bookmarks/")&&J!=="/api/bookmarks/toggle"&&Z.method==="GET"){let Y=J.slice(15),W=X.getBookmark(Y);if(!W)return new Response("Bookmark not found",{status:404});return Response.json(W)}if(J.startsWith("/api/bookmarks/")&&Z.method==="DELETE"){let Y=J.slice(15);if(!X.deleteBookmark(Y))return new Response("Bookmark not found",{status:404});return await X.save(),Response.json({success:!0})}if(J==="/api/analytics/track"&&Z.method==="POST")try{let Y=await Z.json();if(Y.type==="view"&&Y.componentId)B.trackView(Y.componentId,Y.variantId);else if(Y.type==="prop_change"&&Y.componentId&&Y.propName)B.trackPropChange(Y.componentId,Y.propName,null);else if(Y.type==="variant_switch"&&Y.componentId&&Y.variantId)B.trackVariantSwitch(Y.componentId,Y.variantId);else if(Y.type==="search"&&Y.query)B.trackSearch(Y.query,0);return await B.save(),Response.json({success:!0})}catch(Y){return Response.json({error:String(Y)},{status:400})}if(J==="/api/analytics/summary"&&Z.method==="GET")return Response.json({mostViewed:B.getMostViewedComponents(10),mostChangedProps:B.getMostChangedProps(10),searchAnalytics:B.getSearchAnalytics()});if(J.startsWith("/api/analytics/component/")&&Z.method==="GET"){let Y=J.slice(25),W=z.storyFiles.find((U)=>U.id===Y),j=B.getComponentAnalytics(Y,W?.fileName||Y);return Response.json(j)}return new Response("Not found",{status:404})}function kz(z,J,Z){let K=Sz(z,Z);return new Response(K,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function Sz(z,J){let{theme:Z}=z.config,K=Z.title||"STX Story",$=`ws://localhost:${J}/__hmr`,X=r($);return`<!DOCTYPE html>
|
|
562
562
|
<html lang="en" class="${Z.darkClass||"dark"}">
|
|
@@ -8,4 +8,4 @@ function G(j,x){let g=j[x],v=x+1;while(v<j.length){if(j[v]==="\\"){v+=2;continue
|
|
|
8
8
|
`:" ",g++}x+=" ",g++;continue}if(z==="`"){x+=" ",g++;while(g<j.length&&j[g]!=="`"){if(j[g]==="\\"){x+=" ",g+=2;continue}if(j[g]==="$"&&j[g+1]==="{"){let B=g+2,D=F(j,B);if(x+=" ",x+=J(j.slice(B,D)),D<j.length)x+=" ";g=D+1;continue}x+=j[g]===`
|
|
9
9
|
`?`
|
|
10
10
|
`:" ",g++}x+=" ",g++;continue}x+=z,g++}return x}
|
|
11
|
-
export{F as
|
|
11
|
+
export{F as hs,J as is};
|