@stacksjs/stx 0.2.216 → 0.2.217
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-2vdxfjxw.js → chunk-10yft4b7.js} +1 -1
- package/dist/{chunk-eva1mgf5.js → chunk-17atrbv2.js} +1 -1
- package/dist/{chunk-znsffkmk.js → chunk-1bvstnz4.js} +1 -1
- package/dist/{chunk-e4h9zd1m.js → chunk-23vxz3hp.js} +1 -1
- package/dist/{chunk-7jq78m57.js → chunk-2z6k7gsa.js} +1 -1
- package/dist/{chunk-yhn2saa7.js → chunk-3fxcwk6a.js} +1 -1
- package/dist/{chunk-xerx4bn9.js → chunk-74gc1x9x.js} +2 -2
- package/dist/{chunk-sgxjx75w.js → chunk-775fabj4.js} +1 -1
- package/dist/{chunk-1hx2z3m0.js → chunk-7md45k52.js} +1 -1
- package/dist/{chunk-hnrtw0rd.js → chunk-808qy9cq.js} +8 -8
- package/dist/{chunk-drzrf2t7.js → chunk-8cyv5316.js} +1 -1
- package/dist/{chunk-5ckn8vbq.js → chunk-9064gyt5.js} +1 -1
- package/dist/{chunk-cf6npetr.js → chunk-9db2f09j.js} +1 -1
- package/dist/{chunk-62gc6qg9.js → chunk-9h908knr.js} +1 -1
- package/dist/{chunk-nrksd914.js → chunk-a1ydhf5t.js} +1 -1
- package/dist/{chunk-amv1v5qf.js → chunk-bd0yv6a0.js} +1 -1
- package/dist/{chunk-sk8ybwpe.js → chunk-crmk2jzf.js} +1 -1
- package/dist/{chunk-zsfpwqrt.js → chunk-css1sfnr.js} +1 -1
- package/dist/{chunk-y8m9n9v6.js → chunk-d48tzd8c.js} +1 -1
- package/dist/{chunk-nvfawtpq.js → chunk-dcy8hg45.js} +1 -1
- package/dist/{chunk-0rpqx6xa.js → chunk-dmb6t0qj.js} +1 -1
- package/dist/{chunk-ejrtygcb.js → chunk-e6377wfq.js} +1 -1
- package/dist/{chunk-hq60td8b.js → chunk-fvpaf9v5.js} +1 -1
- package/dist/{chunk-9whrwhx4.js → chunk-gvm4dw6p.js} +1 -1
- package/dist/{chunk-6ndvtzpk.js → chunk-j3njy10j.js} +18 -7
- package/dist/{chunk-655pb2nj.js → chunk-jmnftb29.js} +1 -1
- package/dist/{chunk-yxefre1s.js → chunk-jnjxf5t2.js} +1 -1
- package/dist/{chunk-yvgjys59.js → chunk-mxqp7x07.js} +1 -1
- package/dist/{chunk-d8hzg54c.js → chunk-n4smz31k.js} +2 -2
- package/dist/{chunk-fc3g2z0p.js → chunk-njkv35c3.js} +1 -1
- package/dist/{chunk-srdwsrnj.js → chunk-pdh79z63.js} +1 -1
- package/dist/{chunk-yb6f8ey1.js → chunk-pezxve4a.js} +1 -1
- package/dist/{chunk-xgxjp647.js → chunk-q3ea7q6t.js} +1 -1
- package/dist/{chunk-t82z0cbv.js → chunk-qd1nadff.js} +1 -1
- package/dist/{chunk-c11nnxkg.js → chunk-qwzfdq8q.js} +1 -1
- package/dist/{chunk-66630av9.js → chunk-tg0w29j1.js} +1 -1
- package/dist/{chunk-em4wy7zv.js → chunk-tqhwzjj7.js} +1 -1
- package/dist/{chunk-1wfvhxjz.js → chunk-weajy31v.js} +1 -1
- package/dist/{chunk-3z8tp7v4.js → chunk-x9bsft57.js} +1 -1
- package/dist/{chunk-hz1jcwdb.js → chunk-xwc4pg5w.js} +1 -1
- package/dist/{chunk-s9pa2var.js → chunk-y05vd24g.js} +1 -1
- package/dist/{chunk-r7qzjt0h.js → chunk-yrqnsd3a.js} +1 -1
- package/dist/{chunk-mm0f84gm.js → chunk-zat2ndst.js} +16 -16
- package/dist/cli.js +8 -8
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/pwa.js +1 -1
- package/dist/signals.js +18 -7
- package/dist/ssg.js +2 -2
- package/dist/stx.d.ts +11 -1
- package/package.json +5 -5
- package/stx.d.ts +11 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ef as a}from"./chunk-
|
|
2
|
+
import{ef as a}from"./chunk-fvpaf9v5.js";import"./chunk-zat2ndst.js";import"./chunk-j0tfxbns.js";import"./chunk-khrtzbxd.js";import"./chunk-8anh6d36.js";import"./chunk-3fwn9edg.js";import"./chunk-pezxve4a.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"./chunk-trtm887x.js";export{a as startInteractive};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Zp as a,jq as b,kq as c,lq as d,mq as e}from"./chunk-
|
|
2
|
+
import{Zp as a,jq as b,kq as c,lq as d,mq as e}from"./chunk-zat2ndst.js";import"./chunk-j0tfxbns.js";import"./chunk-khrtzbxd.js";import"./chunk-8anh6d36.js";import"./chunk-3fwn9edg.js";import"./chunk-pezxve4a.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"./chunk-trtm887x.js";export{d as validateClientScript,c as processOnceDirective,b as processJsonDirective,e as processDirectives,a as injectRouterScript};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Bq as q,Fq as y}from"./chunk-
|
|
2
|
+
import{Bq as q,Fq as y}from"./chunk-zat2ndst.js";import{iu as L}from"./chunk-trtm887x.js";import M from"fs";import X from"path";var T=new Map,Q=new Map;async function A(j){let z;for(let K=0;K<3;K++)try{let V=(await M.promises.stat(j)).mtime.getTime(),J=Q.get(j);if(J&&J.mtime===V)return J.content;let W=await Bun.file(j).text(),U=(await M.promises.stat(j)).mtime.getTime();if(U!==V)continue;return Q.set(j,{content:W,mtime:U}),W}catch(I){z=I;break}throw Q.delete(j),Error(`File not found: ${j}${z?` (${z.message})`:""}`)}function H(j){Q.delete(j)}function v(j){for(let B of Q.keys())if(B.startsWith(j))Q.delete(B)}var Z=null,b=null,N=null;function E(j){N=j}async function F(j=!1){let B=N??await import("./chunk-pdh79z63.js");if(j)return B.generateSignalsRuntimeDev();if(Z===null)Z=B.generateSignalsRuntime();return Z}var $=null;async function R(){if($===null){let{getRouterScript:j}=await import("./chunk-aw9z3m10.js");$=j()}return $}function S(){Q.clear(),y(),Z=null,b=null,$=null}function k(j){let B={debug:j.debug===!0,middleware:(j.middleware??[]).map((z)=>({name:z.name,timing:z.timing,handler:String(z.handler)})),customDirectives:(j.customDirectives??[]).map((z)=>({name:z.name,hasEndTag:z.hasEndTag===!0,handler:String(z.handler)}))};return new Bun.CryptoHasher("sha1").update(JSON.stringify(B)).digest("hex")}async function _(j,B){try{if(!B.cachePath)return null;let z=X.resolve(B.cachePath),K=X.join(z,`${D(j)}.html`),I=X.join(z,`${D(j)}.meta.json`);if(!await q(K)||!await q(I))return null;let V=await Bun.file(I).text(),J=JSON.parse(V);if(J.cacheVersion!==B.cacheVersion)return null;if(J.optionsSignature!==k(B))return null;if((await M.promises.stat(j)).mtime.getTime()>J.mtime)return null;for(let Y of J.dependencies)if(await q(Y)){if((await M.promises.stat(Y)).mtime.getTime()>J.mtime)return null}else return null;return await Bun.file(K).text()}catch(z){return console.warn(`Cache error for ${j}:`,z),null}}async function g(j,B,z,K){try{if(!K.cachePath)return;let I=X.resolve(K.cachePath);await M.promises.mkdir(I,{recursive:!0});let V=X.join(I,`${D(j)}.html`),J=X.join(I,`${D(j)}.meta.json`),W=await M.promises.stat(j);await Bun.write(V,B);let Y={sourcePath:j,mtime:W.mtime.getTime(),dependencies:Array.from(z),cacheVersion:K.cacheVersion,optionsSignature:k(K),generatedAt:Date.now()};await Bun.write(J,JSON.stringify(Y,null,2)),T.set(j,{output:B,mtime:W.mtime.getTime(),dependencies:z})}catch(I){console.warn(`Failed to cache template ${j}:`,I)}}var G=16;function D(j){return new Bun.CryptoHasher("sha1").update(j).digest("hex").substring(0,G)}
|
|
3
3
|
export{T as Ji,A as Ki,H as Li,v as Mi,E as Ni,F as Oi,R as Pi,S as Qi,_ as Ri,g as Si,D as Ti};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Jo as a,Ko as b,Lo as c,Mo as d,No as e,Oo as f,Po as g,Qo as h,Ro as i,So as j}from"./chunk-
|
|
2
|
+
import{Jo as a,Ko as b,Lo as c,Mo as d,No as e,Oo as f,Po as g,Qo as h,Ro as i,So as j}from"./chunk-zat2ndst.js";import"./chunk-j0tfxbns.js";import"./chunk-khrtzbxd.js";import"./chunk-8anh6d36.js";import"./chunk-3fwn9edg.js";import"./chunk-pezxve4a.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"./chunk-trtm887x.js";export{b as stripTypeScript,h as splitDeclaration,c as isModuleResolutionFailure,d as isMissingBindingFailure,f as isCompleteImport,j as hasVariables,e as extractVariables,i as extractScriptFromTemplate,g as convertToCommonJS,a as STX_ENGINE_BINDING_NAMES};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$k as h,Uk as a,Vk as b,Wk as c,Xk as d,Yk as e,Zk as f,_k as g,al as i}from"./chunk-
|
|
2
|
+
import{$k as h,Uk as a,Vk as b,Wk as c,Xk as d,Yk as e,Zk as f,_k as g,al as i}from"./chunk-dmb6t0qj.js";import"./chunk-zgvga8rc.js";import"./chunk-zat2ndst.js";import"./chunk-j0tfxbns.js";import"./chunk-khrtzbxd.js";import"./chunk-8anh6d36.js";import"./chunk-3fwn9edg.js";import"./chunk-pezxve4a.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"./chunk-trtm887x.js";export{a as shouldLogBundlerDiagnostics,e as setBundlerFallbackMode,f as resolveBundlerFallback,b as recordBundleFailure,h as queueClientBundleBuild,g as hasUserImports,c as getBundleFailures,d as clearBundleFailures,i as bundleClientScript};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{gk as a,hk as b,ik as c,jk as d}from"./chunk-
|
|
2
|
+
import{gk as a,hk as b,ik as c,jk as d}from"./chunk-7md45k52.js";import"./chunk-n4smz31k.js";import"./chunk-zat2ndst.js";import"./chunk-j0tfxbns.js";import"./chunk-khrtzbxd.js";import"./chunk-8anh6d36.js";import"./chunk-3fwn9edg.js";import"./chunk-pezxve4a.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"./chunk-trtm887x.js";export{b as getAvailableTargets,c as getAvailableFormats,d as default,a as buildNative};
|
|
@@ -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{No as V}from"./chunk-
|
|
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-zat2ndst.js";import"./chunk-j0tfxbns.js";import"./chunk-khrtzbxd.js";import"./chunk-8anh6d36.js";import"./chunk-3fwn9edg.js";import"./chunk-pezxve4a.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-17atrbv2.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-17atrbv2.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"}">
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$p as b,_p as a,aq as c,bq as d,cq as e,dq as f,eq as g,fq as h,gq as i,hq as j,iq as k}from"./chunk-
|
|
2
|
+
import{$p as b,_p as a,aq as c,bq as d,cq as e,dq as f,eq as g,fq as h,gq as i,hq as j,iq as k}from"./chunk-zat2ndst.js";import"./chunk-j0tfxbns.js";import"./chunk-khrtzbxd.js";import"./chunk-8anh6d36.js";import"./chunk-3fwn9edg.js";import"./chunk-pezxve4a.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"./chunk-trtm887x.js";export{a as scanScriptTags,k as rewriteStxImportSpecifiers,i as processSignals,g as processScriptSetup,e as preEvalLiteralReactiveIfs,b as parseLoopExpression,c as hasSignalsSyntax,j as findMarkupIndexOutsideScripts,h as extractExports,f as convertSignalLoopsToAttributes,d as convertSignalDirectivesToAttributes};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{nk as m}from"./chunk-
|
|
2
|
+
import{nk as m}from"./chunk-n4smz31k.js";import{iu as z}from"./chunk-trtm887x.js";import{existsSync as s,mkdirSync as T,copyFileSync as F,chmodSync as A}from"fs";import{join as Z,basename as Yq}from"path";import{spawn as j,execSync as Zq}from"child_process";import{tmpdir as c,homedir as P,platform as Lq}from"os";var Iq=`
|
|
3
3
|
<script>
|
|
4
4
|
(function() {
|
|
5
5
|
'use strict';
|
|
@@ -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-a1ydhf5t.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-qd1nadff.js";import{Ri as t1,Si as e1}from"./chunk-1bvstnz4.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,Bq as A1,Cm as M6,Ep as V6,Fo as o1,Fp as E6,Fq as p0,Jr as H$,Km as f1,Lr as z1,Mr as A0,Nm as Z6,No as B0,Qr as q0,Ul as R7,Vm as p$,Vo as m0,Wl as i5,Wp as r$,Xm as c$,Yp as R6,Zp as J6,_m as h1,cn as l$,fn as n1,gn as Y6,km as u0,mq as L0,um as m$,wr as $$,xp as w7}from"./chunk-zat2ndst.js";import{Cs as X$,Ds as Q$,Hs as s,us as B}from"./chunk-pezxve4a.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';
|
|
@@ -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-bd0yv6a0.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-tqhwzjj7.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-em4wy7zv.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-em4wy7zv.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-em4wy7zv.js"),{checkCache:T0,cacheTemplate:S$,readFileCached:r,templateCache:S1}=await import("./chunk-cf6npetr.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-em4wy7zv.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-amv1v5qf.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-fc3g2z0p.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-fc3g2z0p.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-tqhwzjj7.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-tqhwzjj7.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-tqhwzjj7.js"),{checkCache:T0,cacheTemplate:S$,readFileCached:r,templateCache:S1}=await import("./chunk-9db2f09j.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-tqhwzjj7.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-bd0yv6a0.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-njkv35c3.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-njkv35c3.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-9db2f09j.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-9db2f09j.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-dcy8hg45.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-bd0yv6a0.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-css1sfnr.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
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ff as a}from"./chunk-
|
|
2
|
+
import{ff as a}from"./chunk-9064gyt5.js";import"./chunk-zat2ndst.js";import"./chunk-j0tfxbns.js";import"./chunk-khrtzbxd.js";import"./chunk-8anh6d36.js";import"./chunk-3fwn9edg.js";import"./chunk-pezxve4a.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"./chunk-trtm887x.js";export{a as buildApp};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Lr as E}from"./chunk-
|
|
2
|
+
import{Lr as E}from"./chunk-zat2ndst.js";import{iu as D}from"./chunk-trtm887x.js";import I from"path";async function M(q={}){let G=performance.now(),J=q.root||process.cwd(),j=await E(),y=j.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${y.toUpperCase()}${j.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let A,B;if(y==="ssg"){let{generateStaticSite:z}=await import("./ssg.js");A=await z({pagesDir:I.join(j.root||".",j.pagesDir||j.build?.pagesDir||"pages"),publicDir:j.publicDir||j.build?.publicDir||"public",outputDir:j.build?.outputDir||"dist",generate404:j.build?.generate404??!0,minify:j.build?.minify??!0,cleanOutput:j.build?.cleanOutput??!0,...q.ssg})}else{let{buildForProduction:z}=await import("./chunk-9h908knr.js");B=await z({outputDir:".output",debug:q.debug,...q.ssr})}let H=Math.round(performance.now()-G);return{mode:y,ssg:A,ssr:B,duration:H}}
|
|
3
3
|
export{M as ff};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ji as a,Ki as b,Li as c,Mi as d,Ni as e,Oi as f,Pi as g,Qi as h,Ri as i,Si as j,Ti as k}from"./chunk-
|
|
2
|
+
import{Ji as a,Ki as b,Li as c,Mi as d,Ni as e,Oi as f,Pi as g,Qi as h,Ri as i,Si as j,Ti as k}from"./chunk-1bvstnz4.js";import"./chunk-zat2ndst.js";import"./chunk-j0tfxbns.js";import"./chunk-khrtzbxd.js";import"./chunk-8anh6d36.js";import"./chunk-3fwn9edg.js";import"./chunk-pezxve4a.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"./chunk-trtm887x.js";export{a as templateCache,b as readFileCached,d as invalidateFileCacheByDir,c as invalidateFileCache,k as hashFilePath,f as getCachedSignalsRuntime,g as getCachedRouterScript,h as clearDevCaches,i as checkCache,j as cacheTemplate,e as __setSignalsGeneratorsForTest};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{xg as a}from"./chunk-
|
|
2
|
+
import{xg as a}from"./chunk-e6377wfq.js";import"./chunk-p7qqbw2k.js";import"./chunk-qd1nadff.js";import"./chunk-j3njy10j.js";import"./chunk-3es366z4.js";import"./chunk-yckd6ks5.js";import"./chunk-zat2ndst.js";import"./chunk-j0tfxbns.js";import"./chunk-khrtzbxd.js";import"./chunk-8anh6d36.js";import"./chunk-3fwn9edg.js";import"./chunk-pezxve4a.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"./chunk-trtm887x.js";export{a as buildForProduction};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Tg as n}from"./chunk-t82z0cbv.js";import{No as f,Yp as p,bm as b,cm as S,lm as k,sm as q}from"./chunk-mm0f84gm.js";import{Wt as c,_t as XG,tt as d}from"./chunk-z47tw39z.js";import{iu as T}from"./chunk-trtm887x.js";import l from"fs";import F from"path";var{serve:ZG}=globalThis.Bun;function R(G,J,K={}){let Q=`${encodeURIComponent(G)}=${encodeURIComponent(J)}`;if(K.maxAge!==void 0)Q+=`; Max-Age=${K.maxAge}`;if(K.expires)Q+=`; Expires=${K.expires.toUTCString()}`;if(K.path)Q+=`; Path=${K.path}`;if(K.domain)Q+=`; Domain=${K.domain}`;if(K.secure)Q+="; Secure";if(K.httpOnly)Q+="; HttpOnly";if(K.sameSite)Q+=`; SameSite=${K.sameSite}`;return Q}async function i(G){let J=G.headers.get("content-type")||"",K={},Q=(X,Z)=>{let $=K[X];if($===void 0)K[X]=Z;else if(Array.isArray($))$.push(Z);else K[X]=[$,Z]};if(J.includes("multipart/form-data")){let X=await G.formData();for(let[Z,$]of X.entries())if(typeof $==="string")Q(Z,$);return K}if(J.includes("application/x-www-form-urlencoded")){for(let[X,Z]of new URLSearchParams(await G.text()).entries())Q(X,Z);return K}return K}function C(G){if(!G)return!1;let J=G.toUpperCase();return J!=="GET"&&J!=="HEAD"}async function y(G,J={}){let K=J.request,Q=J.method??K?.method;if(!K||!C(Q))return{ran:!1};if(typeof G.action!=="function")return{ran:!1};let X={};try{X=await i(K)}catch{}let Z=await G.action({request:K,form:X,params:J.params??{},query:G.query??{},cookies:J.cookies??{}});if(Z&&typeof Z==="object"){let $=Z,U=a($.cookies),I=$.redirect;if(typeof I==="string"&&I)return{redirect:I,ran:!0,...U.length>0?{cookies:U}:{}};let{cookies:V,redirect:A,...O}=$;if(Object.assign(G,O),U.length>0)return{ran:!0,cookies:U}}return{ran:!0}}function a(G){if(!G||typeof G!=="object"||Array.isArray(G))return[];let J=[];for(let[K,Q]of Object.entries(G)){if(!K)continue;if(typeof Q==="string"){J.push(R(K,Q));continue}if(Q&&typeof Q==="object"){let X=Q;if(typeof X.value!=="string")continue;J.push(R(K,X.value,X))}}return J}function v(G,J=[]){let K=new Headers({Location:G,"Cache-Control":"no-store"});for(let Q of J)K.append("Set-Cookie",Q);return new Response(null,{status:303,headers:K})}async function LG(G,J={}){return(await x(G,J)).html}async function g(G,J={}){let{html:K,context:Q,redirect:X,cookies:Z}=await x(G,J);if(X)return{html:K,redirect:X,cookies:Z};let{extractStreamBoundaries:$}=await import("./chunk-fc3g2z0p.js"),U=$(Q),I=G.streamTemplates;if(I&&Object.keys(I).length>0){let{processDirectives:V}=await import("./chunk-eva1mgf5.js"),{defaultConfig:A}=await import("./chunk-nvfawtpq.js"),O=Q.streamBoundaries||{},D={...A,autoShell:!1},j=Object.keys(I).map((_)=>({id:_,render:async()=>{let M=typeof O[_]==="function"?await O[_]():void 0;return V(I[_],{...Q,$boundary:M},G.sourceFile,D,new Set)}})),N=new Set(j.map((_)=>_.id));U=[...(U||[]).filter((_)=>!N.has(_.id)),...j]}return{html:K,boundaries:U&&U.length>0?U:void 0,cookies:Z}}async function x(G,J){let K={__filename:G.sourceFile,__dirname:G.sourceFile.replace(/[/\\][^/\\]+$/,""),...J};if(!G.hasServerScripts&&!S(G.html))return{html:G.html,context:K};for(let Z of G.serverScriptContent)try{await f(Z,K,G.sourceFile)}catch($){console.warn(`[stx] Server script error in ${G.sourceFile}:`,$)}let Q=await y(K,{request:J.request,method:J.method,params:J.params??{},cookies:J.cookies??{}});if(Q.redirect)return{html:G.html,context:K,redirect:Q.redirect,cookies:Q.cookies};if(!S(G.html))return{html:G.html,context:K,cookies:Q.cookies};let X=new Map;for(let[Z,$]of Object.entries(G.placeholders))if($.expression)try{let U=q($.expression,K);if($.type==="raw")X.set(Z,U!==void 0&&U!==null?String(U):"");else X.set(Z,U!==void 0&&U!==null?k(String(U)):"")}catch{X.set(Z,"")}return{html:b(G.html,X),context:K,cookies:Q.cookies}}async function VG(G,J={}){if(!G.hasServerScripts&&!S(G.fragment))return G.fragment;let K={__filename:G.sourceFile,__dirname:G.sourceFile.replace(/[/\\][^/\\]+$/,""),...J};for(let X of G.serverScriptContent)try{await f(X,K,G.sourceFile)}catch(Z){console.warn(`[stx] Server script error in ${G.sourceFile}:`,Z)}if(!S(G.fragment))return G.fragment;let Q=new Map;for(let[X,Z]of Object.entries(G.placeholders))if(Z.expression)try{let $=q(Z.expression,K);if(Z.type==="raw")Q.set(X,$!==void 0&&$!==null?String($):"");else Q.set(X,$!==void 0&&$!==null?k(String($)):"")}catch{Q.set(X,"")}return b(G.fragment,Q)}XG();import E from"zlib";import{promisify as u}from"util";var s=u(E.brotliCompress),t=u(E.gzip),o=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],e=["text/event-stream","multipart/x-mixed-replace"],GG=1024;function JG(G){if(!G)return!1;let J=G.toLowerCase();if(e.some((K)=>J.startsWith(K)))return!1;return o.some((K)=>J.startsWith(K))}function KG(G){let J=new Map;for(let K of G.split(",")){let[Q,...X]=K.trim().split(";"),Z=Q.trim().toLowerCase();if(!Z)continue;let $=1;for(let U of X){let I=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(U);if(!I)continue;let V=Number.parseFloat(I[1]);if(Number.isFinite(V))$=V}J.set(Z,$)}return J}function QG(G){if(!G)return null;let J=KG(G),K=J.get("*"),Q=(X)=>J.get(X)??K??0;if(Q("br")>0)return"br";if(Q("gzip")>0)return"gzip";return null}async function m(G,J,K={}){if(J.headers.get("content-encoding"))return J;if(J.status===204||J.status===304||!J.body)return J;if(!JG(J.headers.get("content-type")))return J;let Q=QG(G.headers.get("accept-encoding"));if(!Q)return J;let X;try{X=new Uint8Array(await J.arrayBuffer())}catch{return J}let Z=()=>new Response(X,{status:J.status,statusText:J.statusText,headers:h(J.headers)});if(X.length<(K.threshold??GG))return Z();try{let $=Q==="br"?await s(X,{params:{[E.constants.BROTLI_PARAM_QUALITY]:K.quality??5,[E.constants.BROTLI_PARAM_SIZE_HINT]:X.length}}):await t(X);if($.length>=X.length)return Z();let U=h(J.headers);return U.set("Content-Encoding",Q),U.set("Content-Length",String($.length)),new Response($,{status:J.status,statusText:J.statusText,headers:U})}catch{return Z()}}function h(G){let J=new Headers(G),K=J.get("Vary");if(!K)return J.set("Vary","Accept-Encoding"),J;if(!K.split(",").some((X)=>X.trim().toLowerCase()==="accept-encoding"))J.set("Vary",`${K}, Accept-Encoding`);return J}var $G={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function bG(G={}){let J=F.resolve(G.outputDir||".output"),K=G.port||3000,Q=n(J);if(!Q)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${Q.routes.length} routes...`);let X=new Map,Z=new Map,$=new Map,U=new Map;for(let O of Q.routes)try{let D=F.join(J,O.compiledPath),j=JSON.parse(await Bun.file(D).text());X.set(O.pattern,j),$.set(O.pattern,c(j.html)),U.set(O.pattern,p(j.html));let N=F.join(J,O.fragmentPath);if(await Bun.file(N).exists())Z.set(O.pattern,await Bun.file(N).text())}catch(D){console.warn(`[stx] Failed to load route ${O.pattern}:`,D)}let I=new Map,V=[];for(let O of Q.routes)if(O.hasParams){let{regex:D,params:j}=d(O.pattern);V.push({regex:D,route:O,paramNames:j})}else I.set(O.pattern,O);let A=ZG({port:K,async fetch(O){return m(O,await(async()=>{let j=new URL(O.url).pathname;if(G.onRequest){let W=await G.onRequest(O);if(W)return W}if(G.apiRoutes?.[j])return G.apiRoutes[j](O);if((O.method==="GET"||O.method==="HEAD")&&j!=="/"){let W=F.resolve(J,"public"),Y;try{Y=decodeURIComponent(j)}catch{Y=j}if(!Y.includes("\x00")){let L=F.resolve(W,`.${Y}`);if(L===W||L.startsWith(`${W}${F.sep}`))try{if(l.existsSync(L)&&l.statSync(L).isFile()){let w=F.extname(L).toLowerCase(),H=$G[w]||"application/octet-stream",P=j.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(j);return new Response(Bun.file(L),{headers:{"Content-Type":H,"Cache-Control":P?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let N=O.headers.get("X-STX-Router")==="true",_=null,M={};if(_=I.get(j)||null,!_)for(let{regex:W,route:Y,paramNames:L}of V){let B=j.match(W);if(B){_=Y,L.forEach((w,H)=>{M[w]=B[H+1]});break}}if(!_){let W=I.get("/404")||null;if(W){let Y=X.get(W.pattern);if(Y)return new Response(Y.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}if(N){let W=Z.get(_.pattern);if(W){let Y=$.get(_.pattern);return new Response(W,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...U.has(_.pattern)?{"X-STX-Runtime":U.get(_.pattern)?"true":"false"}:{},...Y?{"X-STX-Layout":Y.layout,"X-STX-Layout-Group":Y.group}:{},"Cache-Control":"no-cache"}})}}let r=C(O.method),z=X.get(_.pattern);if(!z){let W=I.get("/500")||null;if(W){let Y=X.get(W.pattern);if(Y)return new Response(Y.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(!r&&!z.hasServerScripts&&Object.keys(z.placeholders).length===0)return new Response(z.html,{headers:{"Content-Type":"text/html","Cache-Control":"public, max-age=60"}});try{let{html:W,boundaries:Y,redirect:L,cookies:B}=await g(z,{params:M,request:O,method:O.method});if(L)return v(L,B);if(Y&&Y.length>0){let{renderStreamingPage:H,streamToResponse:P}=await import("./chunk-fc3g2z0p.js");return P(H(W,Y,{timeoutMs:30000}),{headers:{"Cache-Control":"no-cache"}})}let w=new Headers({"Content-Type":"text/html","Cache-Control":"no-cache"});for(let H of B??[])w.append("Set-Cookie",H);return new Response(W,{headers:w})}catch(W){return console.error(`[stx] Hydration error for ${j}:`,W),new Response(z.html,{headers:{"Content-Type":"text/html"}})}})())}});return console.log(`[stx] Production server running at http://localhost:${K}`),console.log(`[stx] Serving ${Q.routes.length} routes (${X.size} pre-loaded)`),{port:K,stop:()=>A.stop()}}
|
|
2
|
+
import{Tg as n}from"./chunk-qd1nadff.js";import{No as f,Yp as p,bm as b,cm as S,lm as k,sm as q}from"./chunk-zat2ndst.js";import{Wt as c,_t as XG,tt as d}from"./chunk-z47tw39z.js";import{iu as T}from"./chunk-trtm887x.js";import l from"fs";import F from"path";var{serve:ZG}=globalThis.Bun;function R(G,J,K={}){let Q=`${encodeURIComponent(G)}=${encodeURIComponent(J)}`;if(K.maxAge!==void 0)Q+=`; Max-Age=${K.maxAge}`;if(K.expires)Q+=`; Expires=${K.expires.toUTCString()}`;if(K.path)Q+=`; Path=${K.path}`;if(K.domain)Q+=`; Domain=${K.domain}`;if(K.secure)Q+="; Secure";if(K.httpOnly)Q+="; HttpOnly";if(K.sameSite)Q+=`; SameSite=${K.sameSite}`;return Q}async function i(G){let J=G.headers.get("content-type")||"",K={},Q=(X,Z)=>{let $=K[X];if($===void 0)K[X]=Z;else if(Array.isArray($))$.push(Z);else K[X]=[$,Z]};if(J.includes("multipart/form-data")){let X=await G.formData();for(let[Z,$]of X.entries())if(typeof $==="string")Q(Z,$);return K}if(J.includes("application/x-www-form-urlencoded")){for(let[X,Z]of new URLSearchParams(await G.text()).entries())Q(X,Z);return K}return K}function C(G){if(!G)return!1;let J=G.toUpperCase();return J!=="GET"&&J!=="HEAD"}async function y(G,J={}){let K=J.request,Q=J.method??K?.method;if(!K||!C(Q))return{ran:!1};if(typeof G.action!=="function")return{ran:!1};let X={};try{X=await i(K)}catch{}let Z=await G.action({request:K,form:X,params:J.params??{},query:G.query??{},cookies:J.cookies??{}});if(Z&&typeof Z==="object"){let $=Z,U=a($.cookies),I=$.redirect;if(typeof I==="string"&&I)return{redirect:I,ran:!0,...U.length>0?{cookies:U}:{}};let{cookies:V,redirect:A,...O}=$;if(Object.assign(G,O),U.length>0)return{ran:!0,cookies:U}}return{ran:!0}}function a(G){if(!G||typeof G!=="object"||Array.isArray(G))return[];let J=[];for(let[K,Q]of Object.entries(G)){if(!K)continue;if(typeof Q==="string"){J.push(R(K,Q));continue}if(Q&&typeof Q==="object"){let X=Q;if(typeof X.value!=="string")continue;J.push(R(K,X.value,X))}}return J}function v(G,J=[]){let K=new Headers({Location:G,"Cache-Control":"no-store"});for(let Q of J)K.append("Set-Cookie",Q);return new Response(null,{status:303,headers:K})}async function LG(G,J={}){return(await x(G,J)).html}async function g(G,J={}){let{html:K,context:Q,redirect:X,cookies:Z}=await x(G,J);if(X)return{html:K,redirect:X,cookies:Z};let{extractStreamBoundaries:$}=await import("./chunk-njkv35c3.js"),U=$(Q),I=G.streamTemplates;if(I&&Object.keys(I).length>0){let{processDirectives:V}=await import("./chunk-17atrbv2.js"),{defaultConfig:A}=await import("./chunk-dcy8hg45.js"),O=Q.streamBoundaries||{},D={...A,autoShell:!1},j=Object.keys(I).map((_)=>({id:_,render:async()=>{let M=typeof O[_]==="function"?await O[_]():void 0;return V(I[_],{...Q,$boundary:M},G.sourceFile,D,new Set)}})),N=new Set(j.map((_)=>_.id));U=[...(U||[]).filter((_)=>!N.has(_.id)),...j]}return{html:K,boundaries:U&&U.length>0?U:void 0,cookies:Z}}async function x(G,J){let K={__filename:G.sourceFile,__dirname:G.sourceFile.replace(/[/\\][^/\\]+$/,""),...J};if(!G.hasServerScripts&&!S(G.html))return{html:G.html,context:K};for(let Z of G.serverScriptContent)try{await f(Z,K,G.sourceFile)}catch($){console.warn(`[stx] Server script error in ${G.sourceFile}:`,$)}let Q=await y(K,{request:J.request,method:J.method,params:J.params??{},cookies:J.cookies??{}});if(Q.redirect)return{html:G.html,context:K,redirect:Q.redirect,cookies:Q.cookies};if(!S(G.html))return{html:G.html,context:K,cookies:Q.cookies};let X=new Map;for(let[Z,$]of Object.entries(G.placeholders))if($.expression)try{let U=q($.expression,K);if($.type==="raw")X.set(Z,U!==void 0&&U!==null?String(U):"");else X.set(Z,U!==void 0&&U!==null?k(String(U)):"")}catch{X.set(Z,"")}return{html:b(G.html,X),context:K,cookies:Q.cookies}}async function VG(G,J={}){if(!G.hasServerScripts&&!S(G.fragment))return G.fragment;let K={__filename:G.sourceFile,__dirname:G.sourceFile.replace(/[/\\][^/\\]+$/,""),...J};for(let X of G.serverScriptContent)try{await f(X,K,G.sourceFile)}catch(Z){console.warn(`[stx] Server script error in ${G.sourceFile}:`,Z)}if(!S(G.fragment))return G.fragment;let Q=new Map;for(let[X,Z]of Object.entries(G.placeholders))if(Z.expression)try{let $=q(Z.expression,K);if(Z.type==="raw")Q.set(X,$!==void 0&&$!==null?String($):"");else Q.set(X,$!==void 0&&$!==null?k(String($)):"")}catch{Q.set(X,"")}return b(G.fragment,Q)}XG();import E from"zlib";import{promisify as u}from"util";var s=u(E.brotliCompress),t=u(E.gzip),o=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],e=["text/event-stream","multipart/x-mixed-replace"],GG=1024;function JG(G){if(!G)return!1;let J=G.toLowerCase();if(e.some((K)=>J.startsWith(K)))return!1;return o.some((K)=>J.startsWith(K))}function KG(G){let J=new Map;for(let K of G.split(",")){let[Q,...X]=K.trim().split(";"),Z=Q.trim().toLowerCase();if(!Z)continue;let $=1;for(let U of X){let I=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(U);if(!I)continue;let V=Number.parseFloat(I[1]);if(Number.isFinite(V))$=V}J.set(Z,$)}return J}function QG(G){if(!G)return null;let J=KG(G),K=J.get("*"),Q=(X)=>J.get(X)??K??0;if(Q("br")>0)return"br";if(Q("gzip")>0)return"gzip";return null}async function m(G,J,K={}){if(J.headers.get("content-encoding"))return J;if(J.status===204||J.status===304||!J.body)return J;if(!JG(J.headers.get("content-type")))return J;let Q=QG(G.headers.get("accept-encoding"));if(!Q)return J;let X;try{X=new Uint8Array(await J.arrayBuffer())}catch{return J}let Z=()=>new Response(X,{status:J.status,statusText:J.statusText,headers:h(J.headers)});if(X.length<(K.threshold??GG))return Z();try{let $=Q==="br"?await s(X,{params:{[E.constants.BROTLI_PARAM_QUALITY]:K.quality??5,[E.constants.BROTLI_PARAM_SIZE_HINT]:X.length}}):await t(X);if($.length>=X.length)return Z();let U=h(J.headers);return U.set("Content-Encoding",Q),U.set("Content-Length",String($.length)),new Response($,{status:J.status,statusText:J.statusText,headers:U})}catch{return Z()}}function h(G){let J=new Headers(G),K=J.get("Vary");if(!K)return J.set("Vary","Accept-Encoding"),J;if(!K.split(",").some((X)=>X.trim().toLowerCase()==="accept-encoding"))J.set("Vary",`${K}, Accept-Encoding`);return J}var $G={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function bG(G={}){let J=F.resolve(G.outputDir||".output"),K=G.port||3000,Q=n(J);if(!Q)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${Q.routes.length} routes...`);let X=new Map,Z=new Map,$=new Map,U=new Map;for(let O of Q.routes)try{let D=F.join(J,O.compiledPath),j=JSON.parse(await Bun.file(D).text());X.set(O.pattern,j),$.set(O.pattern,c(j.html)),U.set(O.pattern,p(j.html));let N=F.join(J,O.fragmentPath);if(await Bun.file(N).exists())Z.set(O.pattern,await Bun.file(N).text())}catch(D){console.warn(`[stx] Failed to load route ${O.pattern}:`,D)}let I=new Map,V=[];for(let O of Q.routes)if(O.hasParams){let{regex:D,params:j}=d(O.pattern);V.push({regex:D,route:O,paramNames:j})}else I.set(O.pattern,O);let A=ZG({port:K,async fetch(O){return m(O,await(async()=>{let j=new URL(O.url).pathname;if(G.onRequest){let W=await G.onRequest(O);if(W)return W}if(G.apiRoutes?.[j])return G.apiRoutes[j](O);if((O.method==="GET"||O.method==="HEAD")&&j!=="/"){let W=F.resolve(J,"public"),Y;try{Y=decodeURIComponent(j)}catch{Y=j}if(!Y.includes("\x00")){let L=F.resolve(W,`.${Y}`);if(L===W||L.startsWith(`${W}${F.sep}`))try{if(l.existsSync(L)&&l.statSync(L).isFile()){let w=F.extname(L).toLowerCase(),H=$G[w]||"application/octet-stream",P=j.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(j);return new Response(Bun.file(L),{headers:{"Content-Type":H,"Cache-Control":P?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let N=O.headers.get("X-STX-Router")==="true",_=null,M={};if(_=I.get(j)||null,!_)for(let{regex:W,route:Y,paramNames:L}of V){let B=j.match(W);if(B){_=Y,L.forEach((w,H)=>{M[w]=B[H+1]});break}}if(!_){let W=I.get("/404")||null;if(W){let Y=X.get(W.pattern);if(Y)return new Response(Y.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}if(N){let W=Z.get(_.pattern);if(W){let Y=$.get(_.pattern);return new Response(W,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...U.has(_.pattern)?{"X-STX-Runtime":U.get(_.pattern)?"true":"false"}:{},...Y?{"X-STX-Layout":Y.layout,"X-STX-Layout-Group":Y.group}:{},"Cache-Control":"no-cache"}})}}let r=C(O.method),z=X.get(_.pattern);if(!z){let W=I.get("/500")||null;if(W){let Y=X.get(W.pattern);if(Y)return new Response(Y.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(!r&&!z.hasServerScripts&&Object.keys(z.placeholders).length===0)return new Response(z.html,{headers:{"Content-Type":"text/html","Cache-Control":"public, max-age=60"}});try{let{html:W,boundaries:Y,redirect:L,cookies:B}=await g(z,{params:M,request:O,method:O.method});if(L)return v(L,B);if(Y&&Y.length>0){let{renderStreamingPage:H,streamToResponse:P}=await import("./chunk-njkv35c3.js");return P(H(W,Y,{timeoutMs:30000}),{headers:{"Cache-Control":"no-cache"}})}let w=new Headers({"Content-Type":"text/html","Cache-Control":"no-cache"});for(let H of B??[])w.append("Set-Cookie",H);return new Response(W,{headers:w})}catch(W){return console.error(`[stx] Hydration error for ${j}:`,W),new Response(z.html,{headers:{"Content-Type":"text/html"}})}})())}});return console.log(`[stx] Production server running at http://localhost:${K}`),console.log(`[stx] Serving ${Q.routes.length} routes (${X.size} pre-loaded)`),{port:K,stop:()=>A.stop()}}
|
|
3
3
|
export{JG as gf,QG as hf,m as if,R as jf,i as kf,C as lf,y as mf,v as nf,LG as of,g as pf,VG as qf,bG as rf};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{fm as a,gm as b,hm as c,im as d,jm as e,km as f,lm as g,mm as h,nm as i,om as j,pm as k,qm as l,rm as m,sm as n,tm as o}from"./chunk-
|
|
2
|
+
import{fm as a,gm as b,hm as c,im as d,jm as e,km as f,lm as g,mm as h,nm as i,om as j,pm as k,qm as l,rm as m,sm as n,tm as o}from"./chunk-zat2ndst.js";import"./chunk-j0tfxbns.js";import"./chunk-khrtzbxd.js";import"./chunk-8anh6d36.js";import"./chunk-3fwn9edg.js";import"./chunk-pezxve4a.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"./chunk-trtm887x.js";export{h as usesSignalsInScript,o as unescapeHtml,c as registerFilters,b as registerFilter,l as processExpressions,k as interpolateScriptsInTemplate,i as interpolateScriptExpressions,j as interpolateScriptAttributes,d as getAllFilters,n as evaluateExpression,g as escapeHtmlValue,f as escapeHtml,a as defaultFilters,e as clearCustomFilters,m as applyFilters};
|