@stacksjs/stx 0.2.685 → 0.2.687
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-2ajbhefk.js → chunk-078as147.js} +1 -1
- package/dist/{chunk-jrche9k7.js → chunk-1b526cba.js} +1 -1
- package/dist/{chunk-718rkxa7.js → chunk-1zjn5p5c.js} +1 -1
- package/dist/chunk-2s1c7g5r.js +2 -0
- package/dist/{chunk-eykbcntx.js → chunk-3svg41sb.js} +1 -1
- package/dist/{chunk-qjmvcqfh.js → chunk-3vjzezn1.js} +1 -1
- package/dist/{chunk-6qn368e7.js → chunk-3zcc0w5e.js} +2 -2
- package/dist/{chunk-qgs69nds.js → chunk-52g5q984.js} +1 -1
- package/dist/chunk-5j1bb675.js +2 -0
- package/dist/chunk-5m6ja6mx.js +2 -0
- package/dist/chunk-5rn0k6kq.js +2 -0
- package/dist/{chunk-r8cn9qhr.js → chunk-68wa4bf0.js} +1 -1
- package/dist/{chunk-7st0prz9.js → chunk-71sawjg8.js} +2 -2
- package/dist/chunk-7z5sp09n.js +2 -0
- package/dist/{chunk-fbdmsw5j.js → chunk-95yt1gxa.js} +1 -1
- package/dist/{chunk-zhcb33s1.js → chunk-9h46mvew.js} +1 -1
- package/dist/{chunk-zf6kmw9q.js → chunk-9m1agnnx.js} +1 -1
- package/dist/{chunk-km6ggz8n.js → chunk-9s8471tv.js} +1 -1
- package/dist/{chunk-9xp9hs7t.js → chunk-agx8pbg4.js} +1 -1
- package/dist/chunk-aprvds2c.js +2 -0
- package/dist/{chunk-gn98ha90.js → chunk-ay9bwfbj.js} +1 -1
- package/dist/{chunk-w6frg42f.js → chunk-b2cfg8d1.js} +1 -1
- package/dist/{chunk-d0g4zndy.js → chunk-bkk6xq8p.js} +1 -1
- package/dist/{chunk-xpch3mq8.js → chunk-bm6yhhew.js} +1 -1
- package/dist/{chunk-7grjwpdq.js → chunk-bzzye361.js} +1 -1
- package/dist/chunk-c0fkhe6t.js +2 -0
- package/dist/{chunk-bnggav14.js → chunk-cz0p258g.js} +1 -1
- package/dist/{chunk-dpghx4z6.js → chunk-d26nb6zy.js} +1 -1
- package/dist/{chunk-qz314za9.js → chunk-dztv0p4y.js} +1 -1
- package/dist/chunk-e25r7baw.js +2 -0
- package/dist/{chunk-8x34g2ad.js → chunk-f178pm4d.js} +1 -1
- package/dist/{chunk-4ht54p3j.js → chunk-fbj9b0p6.js} +4 -4
- package/dist/{chunk-w3q5czk5.js → chunk-ff7pvv0p.js} +2 -2
- package/dist/{chunk-ppxfsqwh.js → chunk-fvxvd48v.js} +1 -1
- package/dist/{chunk-6nhsvb9x.js → chunk-g3jg4mcw.js} +1 -1
- package/dist/chunk-gcy2prwj.js +2 -0
- package/dist/chunk-gpk0ew71.js +2 -0
- package/dist/{chunk-4rj9746b.js → chunk-h1bnge85.js} +1 -1
- package/dist/{chunk-kgcwx6nt.js → chunk-haq3cg76.js} +1 -1
- package/dist/{chunk-9wd31tc6.js → chunk-hr3m2h4n.js} +1 -1
- package/dist/{chunk-wt6f9pk9.js → chunk-hx787tfa.js} +1 -1
- package/dist/{chunk-5t9ndqfm.js → chunk-jgxzbthg.js} +1 -1
- package/dist/{chunk-mxbp4vyy.js → chunk-jhr08gjs.js} +2 -2
- package/dist/chunk-jk16vj3c.js +2 -0
- package/dist/{chunk-6e60jp4a.js → chunk-kq1hmpgb.js} +1 -1
- package/dist/chunk-kz9xs9gn.js +2 -0
- package/dist/chunk-m5y0tgax.js +2 -0
- package/dist/{chunk-nqvex98n.js → chunk-m62xkpek.js} +3 -3
- package/dist/{chunk-gwqw8r2e.js → chunk-mf7r2gd0.js} +1 -1
- package/dist/chunk-mpgf9zbd.js +2 -0
- package/dist/{chunk-4r8c96a0.js → chunk-mpvekbzr.js} +5 -5
- package/dist/{chunk-49c5v5fh.js → chunk-n93krbsx.js} +1 -1
- package/dist/{chunk-4k3jx9mm.js → chunk-nm7b8cmr.js} +6 -6
- package/dist/{chunk-t3e5tv4h.js → chunk-pe9ry4mj.js} +6 -6
- package/dist/{chunk-mf8yzpyy.js → chunk-pfc2h65d.js} +1 -1
- package/dist/{chunk-jsac71cy.js → chunk-q0v0cs2j.js} +1 -1
- package/dist/chunk-qk34p70z.js +2 -0
- package/dist/{chunk-bxr4c8rg.js → chunk-qkr7epna.js} +1 -1
- package/dist/{chunk-fb84n8kz.js → chunk-qy26afdn.js} +2 -2
- package/dist/{chunk-3tp7r57c.js → chunk-r0ys9aqa.js} +1 -1
- package/dist/{chunk-cnvwrv5a.js → chunk-r16cej66.js} +1 -1
- package/dist/{chunk-9wa3t87n.js → chunk-r21m7gsd.js} +1 -1
- package/dist/{chunk-nsvnxkyb.js → chunk-rtfyx54t.js} +2 -2
- package/dist/{chunk-px7ryjd9.js → chunk-t2twa7wy.js} +1 -1
- package/dist/{chunk-f5s2h2y8.js → chunk-trzanjcp.js} +1 -1
- package/dist/{chunk-gccwjjzw.js → chunk-vnnwp1cg.js} +1 -1
- package/dist/{chunk-244tyyhx.js → chunk-xszbpnaa.js} +1 -1
- package/dist/{chunk-yhba2f9d.js → chunk-xzffh9aj.js} +1 -1
- package/dist/{chunk-6zzg889q.js → chunk-y8f59j6z.js} +1 -1
- package/dist/{chunk-gkmh0xys.js → chunk-ydad3kq5.js} +1 -1
- package/dist/{chunk-r7csb300.js → chunk-ygb33q5w.js} +1 -1
- package/dist/chunk-yxg5na8z.js +2 -0
- package/dist/{chunk-01bd9hrj.js → chunk-z6enp6s3.js} +1 -1
- package/dist/{chunk-e5kz0y03.js → chunk-zff3cb1e.js} +4 -4
- package/dist/cli.js +7 -7
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/env.d.ts +1 -1
- package/dist/env.js +2 -2
- package/dist/native/runtime/native-host.js +4 -0
- package/dist/process.js +2 -2
- package/dist/pwa.js +2 -2
- package/dist/ssg.js +5 -5
- package/dist/types/config-types.d.ts +1 -0
- package/package.json +5 -5
- package/dist/chunk-42c308vk.js +0 -2
- package/dist/chunk-8y7tpjfs.js +0 -2
- package/dist/chunk-bhm9sdnv.js +0 -2
- package/dist/chunk-bpk0qy53.js +0 -2
- package/dist/chunk-cxvka6g3.js +0 -2
- package/dist/chunk-fzfa35ft.js +0 -2
- package/dist/chunk-kxqvfdm9.js +0 -2
- package/dist/chunk-m1cwgzqy.js +0 -2
- package/dist/chunk-mn9xw0fe.js +0 -2
- package/dist/chunk-sy19th0w.js +0 -2
- package/dist/chunk-t8djd28a.js +0 -2
- package/dist/chunk-tfhhxpda.js +0 -2
- package/dist/chunk-v3mmxk1y.js +0 -2
- package/dist/chunk-x519ewtq.js +0 -2
- package/dist/chunk-xe40yhcw.js +0 -2
- package/dist/chunk-xs8228sa.js +0 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
function C(){let{NODE_ENV:n}=process.env;return n==="production"}function W(){let{STX_DEBUG:n}=process.env;return!C()||n==="true"}function wn(){let{NODE_ENV:n}=process.env;return n==="test"}function Yo(n){return n==="compile"||C()}function wr(n){if(!n)return n;try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(n).trim()}catch{return n}}
|
|
2
|
+
function C(){let{NODE_ENV:n}=process.env;return n==="production"}function W(){let{STX_DEBUG:n}=process.env;return!C()||n==="true"}function wn(){let{NODE_ENV:n}=process.env;return n==="test"}function Yo(n,t){return t??(n==="compile"||C())}function wr(n){if(!n)return n;try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(n).trim()}catch{return n}}
|
|
3
3
|
export{C,W,wn,Yo,wr};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{S}from"./chunk-gtktv6nn.js";import{T,xn}from"./chunk-6beg47t4.js";import{k,J}from"./chunk-
|
|
2
|
+
import{S}from"./chunk-gtktv6nn.js";import{T,xn}from"./chunk-6beg47t4.js";import{k,J}from"./chunk-pe9ry4mj.js";import{i}from"./chunk-jhr08gjs.js";import{Ee,Yt,Zt,Qt}from"./chunk-y8f59j6z.js";import{ht}from"./chunk-71sawjg8.js";import{pt,Nn,qt,ae}from"./chunk-2pga7zzb.js";import{C,wr}from"./chunk-078as147.js";import p from"path";var a=new Map;function _(c,n){for(let s of c.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(s[1])n.add(s[1]);for(let s of c.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let o of(s[1]??"").split(",")){let l=((o.includes(":")?o.split(":").pop():o)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(l))n.add(l)}for(let s of c.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let o of(s[1]??"").split(",")){let r=o.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(r))n.add(r)}}async function Ud(c){let n;if(c)n=p.resolve(c);else{let t=await i();n=p.resolve(t.root||process.cwd(),t.storesDir||"stores")}let s=`${n}\x00${Zt()}`,o=new Bun.Glob("*.ts"),r=[];try{for await(let t of o.scan({cwd:n,absolute:!0})){let e=p.basename(t,".ts");if(["index","types"].includes(e))continue;if(t.includes(".d.ts"))continue;r.push(t)}}catch{return ae(a,s,"",""),null}let l=()=>[...new Set([...r,...r.flatMap((t)=>Ee(t))])],f=pt(l()),d=qt(a,s,f);if(d!==void 0)return d||null;if(r.length===0)return ae(a,s,f,""),null;let u=[];for(let t of r){let e=await Bun.file(t).text();u.push({file:t,hasUseStore:/useStore\s*\(/.test(e)})}u.sort((t,e)=>{if(t.hasUseStore===e.hasUseStore)return 0;return t.hasUseStore?1:-1});let x=u.map((t)=>t.file),m=[],g=new Set,y=J({loader:"ts",target:"browser",define:k()});for(let t of x)try{let e=await Bun.file(t).text(),v=p.basename(t,".ts");if(_(e,g),Yt(e))e=await Qt(e,t,{projectRoot:process.cwd(),externalizeUserModules:C()});e=ht(e),e=T(e),e=xn(e),e=e.replace(/^export\s+(default\s+)?/gm,""),e=y.transformSync(e),m.push(`// Store: ${v}
|
|
3
3
|
${e.trim()}`)}catch(e){console.warn(`[stx] Failed to load store ${t}:`,e)}if(m.length===0)return ae(a,s,f,""),null;let h=m.join(`
|
|
4
4
|
|
|
5
5
|
`),w=`;(function(){
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{g,Mo,Ka,Ga,eu,tu,nu,ru,su,vs,ou,Me,J,Le,iu,pr,au,Ya,Fo,je,n,gn,Za,m,pe,Np}from"./chunk-
|
|
2
|
+
import{g,Mo,Ka,Ga,eu,tu,nu,ru,su,vs,ou,Me,J,Le,iu,pr,au,Ya,Fo,je,n,gn,Za,m,pe,Np}from"./chunk-pe9ry4mj.js";import"./chunk-f178pm4d.js";import"./chunk-t6m5d64b.js";import"./chunk-r0ys9aqa.js";import"./chunk-6beg47t4.js";import"./chunk-gtktv6nn.js";export{pe as clearComponentCache,Fo as componentClientSignalNames,Mo as convertToCommonJS,m as createDetailedErrorMessage,su as extractDirectiveNames,Ka as extractScriptFromTemplate,g as extractVariables,n as fileExists,Np as getComponentCacheStats,tu as getPositionInfo,J as getSharedTranspiler,Za as getSourceLineInfo,ru as hasDirectives,Ga as hasVariables,au as isHydrateTrigger,ou as isJavaScriptScript,je as renderComponentWithSlot,gn as resolveTemplatePath,iu as scopeOnRootElement,vs as scopeSequenceKey,Me as shouldTranspileTypeScript,Ya as slotContentHasExpressions,Le as transpileTypeScript,pr as userComponentFileExists,nu as validateDirective,eu as validateTemplate};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{$l,Vr}from"./chunk-h1bnge85.js";import"./chunk-hx787tfa.js";import"./chunk-jgxzbthg.js";import{ur}from"./chunk-pe9ry4mj.js";import"./chunk-f178pm4d.js";import"./chunk-t6m5d64b.js";import{tt}from"./chunk-r0ys9aqa.js";import"./chunk-6beg47t4.js";import"./chunk-gtktv6nn.js";export{tt as freeIdentifiers,Vr as processComponents,$l as processESImports,ur as rendersAsElement};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{so,oo,io,hp,Hr,yp}from"./chunk-
|
|
2
|
+
import{so,oo,io,hp,Hr,yp}from"./chunk-h1bnge85.js";export{Hr as clearImageDeliveryCatalog,hp as deliveredImage,io as efficientDeliverySources,so as getImageDelivery,oo as isTransparentImage,yp as prepareImageDelivery};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{be,ws,cu,Dp,lu,Mp,Ot,d,V,Y,mn,we,uu,Ho,du,Lp,x,pu,jp,_,Bp}from"./chunk-
|
|
2
|
+
import{be,ws,cu,Dp,lu,Mp,Ot,d,V,Y,mn,we,uu,Ho,du,Lp,x,pu,jp,_,Bp}from"./chunk-pe9ry4mj.js";import"./chunk-f178pm4d.js";import"./chunk-t6m5d64b.js";import"./chunk-r0ys9aqa.js";import"./chunk-6beg47t4.js";import"./chunk-gtktv6nn.js";export{pu as applyFilters,Mp as clearCustomFilters,uu as clientLoopScopes,ws as defaultFilters,mn as escapeAttributeValue,d as escapeHtml,V as escapeHtmlValue,Y as escapeInterpolatedHtmlValue,_ as evaluateExpression,be as findMustacheEnd,lu as getAllFilters,du as interpolateScriptAttributes,Ho as interpolateScriptExpressions,Lp as interpolateScriptsInTemplate,x as processExpressions,cu as registerFilter,Dp as registerFilters,Ot as replaceInterpolations,jp as resetRejectedExpressionWarnings,Bp as unescapeHtml,we as usesSignalsInScript};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{it,at,ct}from"./chunk-tp4eqfxq.js";import"./chunk-gtktv6nn.js";import"./chunk-6beg47t4.js";import{g}from"./chunk-
|
|
2
|
+
import{it,at,ct}from"./chunk-tp4eqfxq.js";import"./chunk-gtktv6nn.js";import"./chunk-6beg47t4.js";import{g}from"./chunk-pe9ry4mj.js";import"./chunk-r0ys9aqa.js";import"./chunk-t6m5d64b.js";import"./chunk-f178pm4d.js";import{Ft,Is,zt,pi,ot,fi,Os,Ht,mi,Vt}from"./chunk-vxnf3xab.js";import M from"fs";import x from"path";function E(t,e){let r=[x.join(t.root,"stx.config.ts"),x.join(t.root,"stx.config.js"),x.join(t.root,"stx.config.mjs")],s=e.debounceMs??300,o=null,a=[];for(let c of r)try{if(!M.existsSync(c))continue;let n=M.watch(c,(d)=>{if(d==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{fi("Config file changed, restarting...");try{await e.onChange()}catch(p){ot(`Failed to restart: ${p}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var st=".stx/story/analytics.json",dt=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,st),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:dt,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:pt(),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(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let d=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),p=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),u=p.length>0?p.reduce((i,l)=>i+l,0)/p.length:0,y=Object.entries(c).sort((i,l)=>l[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:d.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:y,variantViews:n,avgTimeSpent:u}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.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 pt(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var lt=".stx/story/bookmarks.json",mt=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,lt),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:mt,bookmarks:[]}}}async save(){if(!this.dirty)return;let t=B.dirname(this.storagePath);await S.promises.mkdir(t,{recursive:!0}),await S.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(t,e,r,s={}){let o={id:ut(),name:s.name||`${t}/${e}`,storyId:t,variantId:e,props:r,created:Date.now(),notes:s.notes,color:s.color};return this.storage.bookmarks.push(o),this.dirty=!0,o}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(t){return this.storage.bookmarks.filter((e)=>e.storyId===t)}getBookmark(t){return this.storage.bookmarks.find((e)=>e.id===t)}isBookmarked(t,e){return this.storage.bookmarks.some((r)=>r.storyId===t&&r.variantId===e)}updateBookmark(t,e){let r=this.getBookmark(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deleteBookmark(t){let e=this.storage.bookmarks.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.bookmarks.splice(e,1),this.dirty=!0,!0}toggleBookmark(t,e,r){let s=this.storage.bookmarks.find((a)=>a.storyId===t&&a.variantId===e);if(s)return this.deleteBookmark(s.id),{added:!1};return{added:!0,bookmark:this.addBookmark(t,e,r)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(t,e=!0){let r=JSON.parse(t),s=0;for(let o of r.bookmarks){if(e){let a=this.storage.bookmarks.find((c)=>c.id===o.id);if(a)Object.assign(a,o);else this.storage.bookmarks.push(o)}else this.storage.bookmarks.push(o);s++}if(s>0)this.dirty=!0;return s}}function ut(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var v=new Set;function N(){return{open(t){v.add(t),t.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(t){v.delete(t)},message(t,e){}}}function C(t){let e=JSON.stringify({...t,timestamp:t.timestamp||Date.now()});for(let r of v)try{r.send(e)}catch{v.delete(r)}}function V(t,e){C({type:"story-update",data:{storyId:t,...e}})}function H(t,e){C({type:"story-add",data:{storyId:t,...e}})}function O(t){C({type:"story-remove",data:{storyId:t}})}function F(t){return`
|
|
3
3
|
<script>
|
|
4
4
|
(function() {
|
|
5
5
|
const ws = new WebSocket('${t}');
|
|
@@ -556,7 +556,7 @@ window.__stxPerformance = {
|
|
|
556
556
|
|
|
557
557
|
window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
|
|
558
558
|
</script>
|
|
559
|
-
`}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-
|
|
559
|
+
`}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-kz9xs9gn.js"),p={},u=h(n);if(u)try{await g(u,p,e)}catch(f){o.push(`Warning: Could not extract script variables: ${f instanceof Error?f.message:String(f)}`)}if(r.props)Object.assign(p,r.props);let i=await d(n,p,e,{},new Set),l=Z(n),m=h(n);return i=Q(i),i=tt(i,p),{html:i,css:l,js:m,errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}async function vt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=h(e);if(!r)return null;let s={};if(await g(r,s,t),Array.isArray(s.variants))return s.variants;return null}catch{return null}}async function Y(t,e,r,s){let o=e.story?.variants;if(!o){let n=await vt(e.path);if(n)o=n}if(!o&&r==="default")return b(t,e.path,{props:s||{}});if(!o)return b(t,e.path,{props:s||{}});let a=o.find((n)=>n.id===r);if(!a&&r==="default")return b(t,e.path,{props:s||{}});if(!a)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${r}' not found`],duration:0};let c={...a.state,...s};if(a.source)return bt(t,a.source,c);return b(t,e.path,{props:c})}async function bt(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-kz9xs9gn.js"),c={...r},n=h(e);if(n)try{await g(n,c,"inline-template.stx")}catch{}let p=await a(e,c,"inline-template.stx",{},new Set);return p=Q(p),p=tt(p,c),{html:p,css:Z(e),js:h(e),errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}function Z(t){let e=[],r=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
|
|
560
560
|
`)}function Q(t){return t.replace(/<!--[\s\S]*?-->/g,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/^\s*\n/gm,"").trim()}function h(t){let e=[],r=/<script\b[^>]*>([\s\S]*?)<\/script>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
|
|
561
561
|
`)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}async function rt(t,e){let r=await Ht(t);at(t,r);let s=Vt(t.config,r);ct(t,s),console.log(` Found ${r.length} story files`);let o=typeof e.host==="string"?e.host:e.host===!0?"0.0.0.0":"localhost",a=new I(t.root),c=new P(t.root),n=new k(t.root),d=N(),p=Bun.serve({port:e.port,hostname:o,fetch:async(i,l)=>{let f=new URL(i.url).pathname;if(f==="/__hmr"){if(l.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(f.startsWith("/api/"))return xt(t,f,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return wt(t,f,e.port)},websocket:{open(i){d.open(i)},close(i){d.close(i)},message(i,l){d.message(i,l)}}}),u=`http://${o}:${e.port}`,y=mi(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let m=await Ht(t);at(t,m);let f=Vt(t.config,m);if(ct(t,f),i==="add")H(l.id,{fileName:l.fileName});else if(i==="unlink")O(l.id);else V(l.id,{fileName:l.fileName})});if(e.open){let i=u;try{let{exec:l}=await import("child_process"),m=process.platform;l(`${m==="darwin"?"open":m==="win32"?"start":"xdg-open"} ${i}`)}catch{}}return{server:p,url:u,close:async()=>{y(),p.stop()}}}async function xt(t,e,r,s){let{presetsManager:o,bookmarksManager:a,analyticsTracker:c}=s;if(e==="/api/stories")return Response.json({files:t.storyFiles.map((n)=>({id:n.id,fileName:n.fileName,relativePath:n.relativePath,treePath:n.treePath})),tree:t.tree});if(e.startsWith("/api/story/")){let n=e.slice(11),d=t.storyFiles.find((p)=>p.id===n);if(!d)return new Response("Story not found",{status:404});try{let p=await Bun.file(d.path).text();return Response.json({id:d.id,fileName:d.fileName,relativePath:d.relativePath,content:p})}catch{return new Response("Error reading story",{status:500})}}if(e==="/api/config")return Response.json({theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets});if(e.startsWith("/api/render/")){let n=new URL(r.url),d=e.slice(12).split("/"),p=d[0],u=d[1]||"default",y,i=n.searchParams.get("props");if(i)try{y=JSON.parse(i)}catch{}let l=t.storyFiles.find((m)=>m.id===p);if(!l)return new Response("Story not found",{status:404});try{let m=await Y(t,l,u,y);return Response.json({html:m.html,css:m.css,js:m.js,errors:m.errors,duration:m.duration})}catch(m){return Response.json({html:"",css:"",js:"",errors:[m instanceof Error?m.message:String(m)],duration:0},{status:500})}}if(e==="/api/presets"&&r.method==="GET")return Response.json({presets:o.getAllPresets()});if(e==="/api/presets"&&r.method==="POST")try{let n=await r.json(),d=o.createPreset(n.name,n.props,{componentId:n.componentId,description:n.description});return await o.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/presets/")&&!e.includes("/use")&&r.method==="GET"){let n=e.slice(13),d=o.getPreset(n);if(!d)return new Response("Preset not found",{status:404});return Response.json(d)}if(e.endsWith("/use")&&r.method==="POST"){let n=e.slice(13,-4),d=o.usePreset(n);if(!d)return new Response("Preset not found",{status:404});return await o.save(),Response.json(d)}if(e.startsWith("/api/presets/")&&r.method==="DELETE"){let n=e.slice(13);if(!o.deletePreset(n))return new Response("Preset not found",{status:404});return await o.save(),Response.json({success:!0})}if(e==="/api/bookmarks"&&r.method==="GET")return Response.json({bookmarks:a.getAllBookmarks()});if(e==="/api/bookmarks"&&r.method==="POST")try{let n=await r.json(),d=a.addBookmark(n.storyId,n.variantId,n.props,{name:n.name,notes:n.notes,color:n.color});return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/bookmarks/toggle"&&r.method==="POST")try{let n=await r.json(),d=a.toggleBookmark(n.storyId,n.variantId,n.props);return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/bookmarks/")&&e!=="/api/bookmarks/toggle"&&r.method==="GET"){let n=e.slice(15),d=a.getBookmark(n);if(!d)return new Response("Bookmark not found",{status:404});return Response.json(d)}if(e.startsWith("/api/bookmarks/")&&r.method==="DELETE"){let n=e.slice(15);if(!a.deleteBookmark(n))return new Response("Bookmark not found",{status:404});return await a.save(),Response.json({success:!0})}if(e==="/api/analytics/track"&&r.method==="POST")try{let n=await r.json();if(n.type==="view"&&n.componentId)c.trackView(n.componentId,n.variantId);else if(n.type==="prop_change"&&n.componentId&&n.propName)c.trackPropChange(n.componentId,n.propName,null);else if(n.type==="variant_switch"&&n.componentId&&n.variantId)c.trackVariantSwitch(n.componentId,n.variantId);else if(n.type==="search"&&n.query)c.trackSearch(n.query,0);return await c.save(),Response.json({success:!0})}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/analytics/summary"&&r.method==="GET")return Response.json({mostViewed:c.getMostViewedComponents(10),mostChangedProps:c.getMostChangedProps(10),searchAnalytics:c.getSearchAnalytics()});if(e.startsWith("/api/analytics/component/")&&r.method==="GET"){let n=e.slice(25),d=t.storyFiles.find((u)=>u.id===n),p=c.getComponentAnalytics(n,d?.fileName||n);return Response.json(p)}return new Response("Not found",{status:404})}function wt(t,e,r){let s=kt(t,r);return new Response(s,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function kt(t,e){let{theme:r}=t.config,s=r.title||"STX Story",o=`ws://localhost:${e}/__hmr`,a=F(o);return`<!DOCTYPE html>
|
|
562
562
|
<html lang="en" class="${r.darkClass||"dark"}">
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Wo,ks,l,p,E,tt,u,_s,t,a,y}from"./chunk-3tp7r57c.js";import{be,$t,X,H,Ot,Y,x}from"./chunk-t3e5tv4h.js";import{Xn}from"./chunk-7st0prz9.js";import{re}from"./chunk-wt6f9pk9.js";import{Gr}from"./chunk-5t9ndqfm.js";var de=1000,pe=!1;function he(n,r){let c=/@(include|partial)\s*\(\s*(['"])([^'"]+)\2\s*,\s*/g,e="",o=0,i;while((i=c.exec(n))!==null){let g=i.index+i[0].length,_=i.index+i[0].indexOf("("),b=y(n,"(",")",_);if(b===-1)continue;let d=n.slice(g,b).trim();if(!d)continue;if(!Object.keys(r).some((f)=>new RegExp(`(?:^|[^\\w$.])${f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w$])`).test(d)))continue;let m;try{let f=E(d,r);if(!f||typeof f!=="object")continue;m=JSON.stringify(f)}catch{continue}e+=n.slice(o,g)+m,o=b,c.lastIndex=b}return o===0?n:e+n.slice(o)}function me(n,r){let c=/@component\s*\(/g,e=n,o,i=[];while((o=c.exec(e))!==null){let g=o.index,_=g+o[0].length-1,b=1,d=_+1;while(d<e.length&&b>0){if(e[d]==="(")b++;else if(e[d]===")"){if(b--,b===0)break}d++}if(b!==0)continue;let s=e.substring(_+1,d),m=d+1,f=s.match(/^\s*['"]([^'"]+)['"]/);if(!f)continue;let A=f[1],h=s.slice(f[0].length),O=h.match(/^\s*,\s*/);if(!O)continue;let I=h.slice(O[0].length).trim();if(!I)continue;try{let F=E(I,r),j=JSON.stringify(F),S=`@component('${A}', ${j})`;i.push({start:g,end:m,replacement:S})}catch{continue}}for(let g=i.length-1;g>=0;g--){let{start:_,end:b,replacement:d}=i[g];e=e.substring(0,_)+d+e.substring(b)}return e}function oe(n,r,c){let e=n,o=new RegExp(`${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),i;while((i=o.exec(e))!==null){let g=i.index,_=g+i[0].length-1,b=1,d=_+1,s=null,m=!1;while(d<e.length&&b>0){let h=e[d];if(m){m=!1,d++;continue}if(h==="\\"&&s){m=!0,d++;continue}if(s){if(h===s)s=null;d++;continue}if(h==='"'||h==="'"||h==="`"){s=h,d++;continue}if(h==="(")b++;else if(h===")"){if(b--,b===0)break}d++}if(b!==0)break;let f=e.substring(_+1,d),A=c(f);e=e.substring(0,g)+A+e.substring(d+1)}return e}function xe(n,r){let c=n;return c=c.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(e,o)=>{if(o in r)return`:${o}="${o}"`;return e}),c=c.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(e,o,i)=>{try{if(H(i,r.__stx_client_signal_names||[]))return e;let g=Object.keys(r),_=Object.values(r);Wo(i);let b=!1,s=u(i,g,()=>{b=!0})(..._);if(b)return e;let m=JSON.stringify(s);if(m===void 0){if(!tt(i).some((h)=>!(h in r)))return"";return e}let f=Buffer.from(m,"utf8").toString("base64");return`__stx_${o}="${f}"`}catch(g){return e}}),c}var ee="<!--__STX_BREAK__-->",ne="<!--__STX_CONTINUE__-->";function le(n,r){let c=/\{\{\{?|\{!!|@(break|continue)(?![\w$])/g,e="",o=0;for(let i=c.exec(n);i;i=c.exec(n)){if(!i[1]){let d=i[0].length===3&&i[0]==="{{{"?3:2,s=i[0]==="{!!"?n.indexOf("!!}",c.lastIndex):be(n,i.index,d);if(s<0)break;c.lastIndex=s+(i[0]==="{!!"?3:d);continue}let g=c.lastIndex,_=!0,b=/^\s*\(/.exec(n.slice(g));if(b){let d=g+b[0].length-1,s=y(n,"(",")",d);if(s<0)break;g=s+1;try{let m=`!!(${n.slice(d+1,s).trim()})`;_=p(m)?Boolean(u(m,Object.keys(r))(...Object.values(r))):Boolean(l(m,r))}catch{_=!1}}if(e+=n.slice(o,i.index),_)return e+(i[1]==="break"?ee:ne);o=g,c.lastIndex=g}return e+n.slice(o)}function ae(n){let r=(o)=>o.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),c="",e=0;return Ot(n,(o,i,g)=>(c+=ie(r(n.slice(e,g))),c+=`\${__stxRenderLoopValue(${g}, (${i}), ${o.length})}`,e=g+o.length,o)),c+ie(r(n.slice(e)))}function ue(n,r,c,e){return Y(n,r,c==null?"":String(c),!1,e)}function ie(n){let r=n;return r=oe(r,"@break",(c)=>{let e=c.trim();if(!_s(e))return"";return`\`; if (${e}) { break; } result += \``}),r=oe(r,"@continue",(c)=>{let e=c.trim();if(!_s(e))return"";return`\`; if (${e}) { continue; } result += \``}),r=r.replace(/@break(?!\()/g,"`; break; result += `"),r=r.replace(/@continue(?!\()/g,"`; continue; result += `"),r}function ye(n){let r=/@forelse\s*\(/g,c,e=[],o=/@foreach\s*\(/g,i=/@endforeach/g,g;while((g=o.exec(n))!==null)e.push({pos:g.index,delta:1});while((g=i.exec(n))!==null)e.push({pos:g.index,delta:-1});e.sort((s,m)=>s.pos-m.pos);let _=[],b=0;for(let s of e)b+=s.delta,_.push({pos:s.pos,depth:b});function d(s){let m=0,f=_.length-1,A=0;while(m<=f){let h=m+f>>1;if(_[h].pos<=s)A=_[h].depth,m=h+1;else f=h-1}return A}while((c=r.exec(n))!==null){if(d(c.index)>0)continue;let s=c.index,m=c.index+c[0].length-1,f=1,A=m+1,h=-1;while(A<n.length&&f>0){if(n[A]==="(")f++;else if(n[A]===")"){if(f--,f===0){h=A;break}}A++}if(h===-1)continue;let O=n.substring(m+1,h),I=$t(O);if(!I)continue;let{arrayExpr:F,itemVar:j}=I,S=h+1,w=1,W=S,z=/@forelse\s*\(/g,P=/@endforelse/g,L=-1;while(w>0&&W<n.length){z.lastIndex=W,P.lastIndex=W;let C=z.exec(n),R=P.exec(n);if(!R)break;if(C&&C.index<R.index)w++,W=C.index+C[0].length;else{if(w--,w===0){L=R.index;break}W=R.index+11}}if(L===-1)continue;let k=n.substring(S,L),D=L+11,T=-1,U=0,V=0;while(V<k.length){let C=k.indexOf("@",V);if(C===-1)break;let R=k.substring(C);if(/^@forelse\s*\(/.test(R))U++,V=C+1;else if(R.startsWith("@endforelse"))U--,V=C+11;else if(U===0&&R.startsWith("@empty")){if(k.length<=C+6||!/[a-z]/i.test(k[C+6])){T=C;break}V=C+1}else V=C+1}if(T===-1)continue;return{start:s,end:D,arrayExpr:F,itemVar:j,foreachContent:k.substring(0,T),emptyContent:k.substring(T+6)}}return null}function ce(n,r){let c=n;while(!0){let e=ye(c);if(!e)break;let{start:o,end:i,arrayExpr:g,itemVar:_,foreachContent:b,emptyContent:d}=e;try{let s;if(p(g))s=u(g,Object.keys(r))(...Object.values(r));else s=l(g,r);let m;if(!Array.isArray(s)||s.length===0)m=d;else m=`@foreach (${g} as ${_})${b}@endforeach`;c=c.substring(0,o)+m+c.substring(i)}catch(s){let m=s instanceof Error?s.message:String(s),f=a("Forelse",`Error in @forelse(${g} as ${_}): ${m}`,t.EVALUATION_ERROR);c=c.substring(0,o)+f+c.substring(i)}}return c}var fe="<!--stx:foreach-not-iterable:",Ee=/<!--stx:foreach-not-iterable:([^|>]*)\|([^>]*?)-->/g;function _e(n,r){return`${fe}${encodeURIComponent(n)}|${encodeURIComponent(r)}-->`}function $e(n,r){console.warn(`[stx] @foreach(${n}) in ${r}: ${n} is not iterable server-side, so the loop rendered nothing. `+"Values a server loop reads must come from <script server> or the page context \u2014 "+"a plain <script> runs in the browser.")}function jr(n){if(!n.includes(fe))return n;return n.replace(Ee,(r,c,e)=>($e(decodeURIComponent(c),decodeURIComponent(e)),""))}function Gn(n,r,c,e,o=!1){let i=n,g=new Set(r.__stx_client_signal_names||[]);for(let s of Xn(n))g.add(s);if(g.size)r={...r,__stx_client_signal_names:[...g]};i=ce(i,r);function _(s){let m=/@foreach\s*\(/g,f;while((f=m.exec(s))!==null){let A=f.index,h=f.index+f[0].length-1,O=1,I=h+1,F=-1;while(I<s.length&&O>0){if(s[I]==="(")O++;else if(s[I]===")"){if(O--,O===0){F=I;break}}I++}if(F===-1)continue;let j=s.substring(h+1,F),S=$t(j);if(!S)continue;let w=A,{arrayExpr:W,itemVar:z}=S,P=F+1,L=1,k=P,D=/@foreach\s*\(/g,T=/@endforeach/g;while(L>0&&k<s.length){D.lastIndex=k,T.lastIndex=k;let U=D.exec(s),V=T.exec(s);if(!V)break;if(U&&U.index<V.index)L++,k=U.index+U[0].length;else{if(L--,L===0){let C=s.substring(P,V.index),R=V.index+11;return{start:w,end:R,arrayExpr:W,itemVar:z,content:C}}k=V.index+11}}}return null}function b(s,m){let f=s;while(!0){let A=_(f);if(!A)break;let{start:h,end:O,arrayExpr:I,itemVar:F,content:j}=A;try{let S=I.trim(),w;if(p(S))w=u(S,Object.keys(m))(...Object.values(m));else w=l(S,m);let W=!1;if(!Array.isArray(w))if(w instanceof Map)w=Array.from(w),W=!0;else if(w instanceof Set)w=Array.from(w);else if(typeof w==="string")w=Array.from(w);else if(w&&typeof w==="object"&&!(w instanceof Date)&&!(w instanceof RegExp))w=Object.entries(w),W=!0;else{let R=_e(S,c)+a("Foreach",`Error in @foreach: ${S} is not iterable`,t.TYPE_ERROR);f=f.substring(0,h)+R+f.substring(O);continue}let z=e?.loops?.useAltLoopVariable??pe,P=F.trim(),L=null,k,D=!1;if(P.includes("=>")){let R=P.split("=>").map((M)=>M.trim());if(R.length===2&&R[0]&&R[1])L=R[0],k=R[1];else k=P}else if(!P.startsWith("[")&&!P.startsWith("{")&&P.includes(",")){let R=P.split(",").map((M)=>M.trim());if(R.length===2&&R[0]&&R[1])k=R[0],L=R[1],D=!0;else k=P}else k=P;let T="",U=new Set(X(`${I} as ${F}`)),V=w,C=m[ks]??new WeakMap;for(let R=0;R<V.length;R++){let M=V[R],te={index:R,iteration:R+1,first:R===0,last:R===V.length-1,count:V.length},N={...m,loop:te,$loop:te,[ks]:C};if(Array.isArray(m.__stx_client_signal_names))N.__stx_client_signal_names=m.__stx_client_signal_names.filter((Z)=>!U.has(Z));if(k.startsWith("[")&&k.endsWith("]")){let Z=k.slice(1,-1).split(",").map((B)=>B.trim());if(Array.isArray(M))Z.forEach((B,K)=>{if(B)N[B]=M[K]});else N[k]=M}else if(k.startsWith("{")&&k.endsWith("}")){let Z=k.slice(1,-1).split(",").map((B)=>B.trim()).filter(Boolean);if(M!==null&&typeof M==="object")Z.forEach((B)=>{let K=B.indexOf(":"),Q=(K===-1?B:B.slice(0,K)).trim(),se=K===-1?Q:B.slice(K+1).trim();if(Q&&se)N[se]=M[Q]});else N[k]=M}else N[k]=M;if(L)if(!D&&W&&Array.isArray(M)&&M.length===2)N[L]=M[0],N[k]=M[1];else N[L]=R;let v=ce(j,N);v=Gn(v,N,c,e,!0),v=re(v,N,c),v=le(v,N);let J=v.indexOf(ee),G=v.indexOf(ne),q=J<0?G:G<0?J:Math.min(J,G);if(q>=0)v=v.slice(0,q);if(v=x(v,N,c),v=xe(v,N),v=me(v,N),v=he(v,N),T+=v,q>=0&&q===J)break}f=f.substring(0,h)+T+f.substring(O)}catch(S){let w=a("Foreach",`Error in @foreach(${I.trim()} as ${F.trim()}): ${S instanceof Error?S.message:String(S)}`,t.EVALUATION_ERROR);f=f.substring(0,h)+w+f.substring(O)}}return f}i=b(i,r),i=Ae(i,r,c,e);let d=e?.loops?.maxWhileIterations??de;return i=Oe(i,r,d),o?i:jr(i)}function El(n){let r=/^(\s*)([A-Za-z_$][\w$]*|\[[^\]]*\]|\{[^}]*\})(\s+(?:of|in)\s)/.exec(n);if(!r||/^(?:const|let|var)$/.test(r[2]))return n;return`${r[1]}let ${n.slice(r[1].length)}`}function ge(n){return _s(n)}function Ae(n,r,c,e){let o=n,i=!0;while(i){i=!1;let g=o.match(/@for\s*\(/);if(!g||g.index===void 0)break;let _=g.index,b=_+g[0].length-1,d=y(o,"(",")",b);if(d===-1)break;let s=El(o.slice(b+1,d)),m=d+1,f=Gr(o.slice(_),"for","endfor");if(f.length===0)break;let A=f[0].content,h=_+f[0].end;if(!ge(s)){let O=a("For",`Unsafe expression in @for: ${s}`,t.UNSAFE_EXPRESSION);o=o.substring(0,_)+O+o.substring(h),i=!0;continue}try{let O=Re(s),I=/@(?:for|foreach|if|unless)\s*\(/.test(A);if(O.length>0&&I){let z=we({forExpr:s,content:A,iterVarNames:O,context:r,filePath:c,options:e});o=o.substring(0,_)+z+o.substring(h),i=!0;continue}let F=Object.keys(r),j=Object.values(r),S=ae(A),W=Function(...F,"__stxRenderLoopValue",`
|
|
2
|
+
import{Wo,ks,l,p,E,tt,u,_s,t,a,y}from"./chunk-r0ys9aqa.js";import{be,$t,X,H,Ot,Y,x}from"./chunk-pe9ry4mj.js";import{Xn}from"./chunk-71sawjg8.js";import{re}from"./chunk-hx787tfa.js";import{Gr}from"./chunk-jgxzbthg.js";var de=1000,pe=!1;function he(n,r){let c=/@(include|partial)\s*\(\s*(['"])([^'"]+)\2\s*,\s*/g,e="",o=0,i;while((i=c.exec(n))!==null){let g=i.index+i[0].length,_=i.index+i[0].indexOf("("),b=y(n,"(",")",_);if(b===-1)continue;let d=n.slice(g,b).trim();if(!d)continue;if(!Object.keys(r).some((f)=>new RegExp(`(?:^|[^\\w$.])${f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w$])`).test(d)))continue;let m;try{let f=E(d,r);if(!f||typeof f!=="object")continue;m=JSON.stringify(f)}catch{continue}e+=n.slice(o,g)+m,o=b,c.lastIndex=b}return o===0?n:e+n.slice(o)}function me(n,r){let c=/@component\s*\(/g,e=n,o,i=[];while((o=c.exec(e))!==null){let g=o.index,_=g+o[0].length-1,b=1,d=_+1;while(d<e.length&&b>0){if(e[d]==="(")b++;else if(e[d]===")"){if(b--,b===0)break}d++}if(b!==0)continue;let s=e.substring(_+1,d),m=d+1,f=s.match(/^\s*['"]([^'"]+)['"]/);if(!f)continue;let A=f[1],h=s.slice(f[0].length),O=h.match(/^\s*,\s*/);if(!O)continue;let I=h.slice(O[0].length).trim();if(!I)continue;try{let F=E(I,r),j=JSON.stringify(F),S=`@component('${A}', ${j})`;i.push({start:g,end:m,replacement:S})}catch{continue}}for(let g=i.length-1;g>=0;g--){let{start:_,end:b,replacement:d}=i[g];e=e.substring(0,_)+d+e.substring(b)}return e}function oe(n,r,c){let e=n,o=new RegExp(`${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),i;while((i=o.exec(e))!==null){let g=i.index,_=g+i[0].length-1,b=1,d=_+1,s=null,m=!1;while(d<e.length&&b>0){let h=e[d];if(m){m=!1,d++;continue}if(h==="\\"&&s){m=!0,d++;continue}if(s){if(h===s)s=null;d++;continue}if(h==='"'||h==="'"||h==="`"){s=h,d++;continue}if(h==="(")b++;else if(h===")"){if(b--,b===0)break}d++}if(b!==0)break;let f=e.substring(_+1,d),A=c(f);e=e.substring(0,g)+A+e.substring(d+1)}return e}function xe(n,r){let c=n;return c=c.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(e,o)=>{if(o in r)return`:${o}="${o}"`;return e}),c=c.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(e,o,i)=>{try{if(H(i,r.__stx_client_signal_names||[]))return e;let g=Object.keys(r),_=Object.values(r);Wo(i);let b=!1,s=u(i,g,()=>{b=!0})(..._);if(b)return e;let m=JSON.stringify(s);if(m===void 0){if(!tt(i).some((h)=>!(h in r)))return"";return e}let f=Buffer.from(m,"utf8").toString("base64");return`__stx_${o}="${f}"`}catch(g){return e}}),c}var ee="<!--__STX_BREAK__-->",ne="<!--__STX_CONTINUE__-->";function le(n,r){let c=/\{\{\{?|\{!!|@(break|continue)(?![\w$])/g,e="",o=0;for(let i=c.exec(n);i;i=c.exec(n)){if(!i[1]){let d=i[0].length===3&&i[0]==="{{{"?3:2,s=i[0]==="{!!"?n.indexOf("!!}",c.lastIndex):be(n,i.index,d);if(s<0)break;c.lastIndex=s+(i[0]==="{!!"?3:d);continue}let g=c.lastIndex,_=!0,b=/^\s*\(/.exec(n.slice(g));if(b){let d=g+b[0].length-1,s=y(n,"(",")",d);if(s<0)break;g=s+1;try{let m=`!!(${n.slice(d+1,s).trim()})`;_=p(m)?Boolean(u(m,Object.keys(r))(...Object.values(r))):Boolean(l(m,r))}catch{_=!1}}if(e+=n.slice(o,i.index),_)return e+(i[1]==="break"?ee:ne);o=g,c.lastIndex=g}return e+n.slice(o)}function ae(n){let r=(o)=>o.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),c="",e=0;return Ot(n,(o,i,g)=>(c+=ie(r(n.slice(e,g))),c+=`\${__stxRenderLoopValue(${g}, (${i}), ${o.length})}`,e=g+o.length,o)),c+ie(r(n.slice(e)))}function ue(n,r,c,e){return Y(n,r,c==null?"":String(c),!1,e)}function ie(n){let r=n;return r=oe(r,"@break",(c)=>{let e=c.trim();if(!_s(e))return"";return`\`; if (${e}) { break; } result += \``}),r=oe(r,"@continue",(c)=>{let e=c.trim();if(!_s(e))return"";return`\`; if (${e}) { continue; } result += \``}),r=r.replace(/@break(?!\()/g,"`; break; result += `"),r=r.replace(/@continue(?!\()/g,"`; continue; result += `"),r}function ye(n){let r=/@forelse\s*\(/g,c,e=[],o=/@foreach\s*\(/g,i=/@endforeach/g,g;while((g=o.exec(n))!==null)e.push({pos:g.index,delta:1});while((g=i.exec(n))!==null)e.push({pos:g.index,delta:-1});e.sort((s,m)=>s.pos-m.pos);let _=[],b=0;for(let s of e)b+=s.delta,_.push({pos:s.pos,depth:b});function d(s){let m=0,f=_.length-1,A=0;while(m<=f){let h=m+f>>1;if(_[h].pos<=s)A=_[h].depth,m=h+1;else f=h-1}return A}while((c=r.exec(n))!==null){if(d(c.index)>0)continue;let s=c.index,m=c.index+c[0].length-1,f=1,A=m+1,h=-1;while(A<n.length&&f>0){if(n[A]==="(")f++;else if(n[A]===")"){if(f--,f===0){h=A;break}}A++}if(h===-1)continue;let O=n.substring(m+1,h),I=$t(O);if(!I)continue;let{arrayExpr:F,itemVar:j}=I,S=h+1,w=1,W=S,z=/@forelse\s*\(/g,P=/@endforelse/g,L=-1;while(w>0&&W<n.length){z.lastIndex=W,P.lastIndex=W;let C=z.exec(n),R=P.exec(n);if(!R)break;if(C&&C.index<R.index)w++,W=C.index+C[0].length;else{if(w--,w===0){L=R.index;break}W=R.index+11}}if(L===-1)continue;let k=n.substring(S,L),D=L+11,T=-1,U=0,V=0;while(V<k.length){let C=k.indexOf("@",V);if(C===-1)break;let R=k.substring(C);if(/^@forelse\s*\(/.test(R))U++,V=C+1;else if(R.startsWith("@endforelse"))U--,V=C+11;else if(U===0&&R.startsWith("@empty")){if(k.length<=C+6||!/[a-z]/i.test(k[C+6])){T=C;break}V=C+1}else V=C+1}if(T===-1)continue;return{start:s,end:D,arrayExpr:F,itemVar:j,foreachContent:k.substring(0,T),emptyContent:k.substring(T+6)}}return null}function ce(n,r){let c=n;while(!0){let e=ye(c);if(!e)break;let{start:o,end:i,arrayExpr:g,itemVar:_,foreachContent:b,emptyContent:d}=e;try{let s;if(p(g))s=u(g,Object.keys(r))(...Object.values(r));else s=l(g,r);let m;if(!Array.isArray(s)||s.length===0)m=d;else m=`@foreach (${g} as ${_})${b}@endforeach`;c=c.substring(0,o)+m+c.substring(i)}catch(s){let m=s instanceof Error?s.message:String(s),f=a("Forelse",`Error in @forelse(${g} as ${_}): ${m}`,t.EVALUATION_ERROR);c=c.substring(0,o)+f+c.substring(i)}}return c}var fe="<!--stx:foreach-not-iterable:",Ee=/<!--stx:foreach-not-iterable:([^|>]*)\|([^>]*?)-->/g;function _e(n,r){return`${fe}${encodeURIComponent(n)}|${encodeURIComponent(r)}-->`}function $e(n,r){console.warn(`[stx] @foreach(${n}) in ${r}: ${n} is not iterable server-side, so the loop rendered nothing. `+"Values a server loop reads must come from <script server> or the page context \u2014 "+"a plain <script> runs in the browser.")}function jr(n){if(!n.includes(fe))return n;return n.replace(Ee,(r,c,e)=>($e(decodeURIComponent(c),decodeURIComponent(e)),""))}function Gn(n,r,c,e,o=!1){let i=n,g=new Set(r.__stx_client_signal_names||[]);for(let s of Xn(n))g.add(s);if(g.size)r={...r,__stx_client_signal_names:[...g]};i=ce(i,r);function _(s){let m=/@foreach\s*\(/g,f;while((f=m.exec(s))!==null){let A=f.index,h=f.index+f[0].length-1,O=1,I=h+1,F=-1;while(I<s.length&&O>0){if(s[I]==="(")O++;else if(s[I]===")"){if(O--,O===0){F=I;break}}I++}if(F===-1)continue;let j=s.substring(h+1,F),S=$t(j);if(!S)continue;let w=A,{arrayExpr:W,itemVar:z}=S,P=F+1,L=1,k=P,D=/@foreach\s*\(/g,T=/@endforeach/g;while(L>0&&k<s.length){D.lastIndex=k,T.lastIndex=k;let U=D.exec(s),V=T.exec(s);if(!V)break;if(U&&U.index<V.index)L++,k=U.index+U[0].length;else{if(L--,L===0){let C=s.substring(P,V.index),R=V.index+11;return{start:w,end:R,arrayExpr:W,itemVar:z,content:C}}k=V.index+11}}}return null}function b(s,m){let f=s;while(!0){let A=_(f);if(!A)break;let{start:h,end:O,arrayExpr:I,itemVar:F,content:j}=A;try{let S=I.trim(),w;if(p(S))w=u(S,Object.keys(m))(...Object.values(m));else w=l(S,m);let W=!1;if(!Array.isArray(w))if(w instanceof Map)w=Array.from(w),W=!0;else if(w instanceof Set)w=Array.from(w);else if(typeof w==="string")w=Array.from(w);else if(w&&typeof w==="object"&&!(w instanceof Date)&&!(w instanceof RegExp))w=Object.entries(w),W=!0;else{let R=_e(S,c)+a("Foreach",`Error in @foreach: ${S} is not iterable`,t.TYPE_ERROR);f=f.substring(0,h)+R+f.substring(O);continue}let z=e?.loops?.useAltLoopVariable??pe,P=F.trim(),L=null,k,D=!1;if(P.includes("=>")){let R=P.split("=>").map((M)=>M.trim());if(R.length===2&&R[0]&&R[1])L=R[0],k=R[1];else k=P}else if(!P.startsWith("[")&&!P.startsWith("{")&&P.includes(",")){let R=P.split(",").map((M)=>M.trim());if(R.length===2&&R[0]&&R[1])k=R[0],L=R[1],D=!0;else k=P}else k=P;let T="",U=new Set(X(`${I} as ${F}`)),V=w,C=m[ks]??new WeakMap;for(let R=0;R<V.length;R++){let M=V[R],te={index:R,iteration:R+1,first:R===0,last:R===V.length-1,count:V.length},N={...m,loop:te,$loop:te,[ks]:C};if(Array.isArray(m.__stx_client_signal_names))N.__stx_client_signal_names=m.__stx_client_signal_names.filter((Z)=>!U.has(Z));if(k.startsWith("[")&&k.endsWith("]")){let Z=k.slice(1,-1).split(",").map((B)=>B.trim());if(Array.isArray(M))Z.forEach((B,K)=>{if(B)N[B]=M[K]});else N[k]=M}else if(k.startsWith("{")&&k.endsWith("}")){let Z=k.slice(1,-1).split(",").map((B)=>B.trim()).filter(Boolean);if(M!==null&&typeof M==="object")Z.forEach((B)=>{let K=B.indexOf(":"),Q=(K===-1?B:B.slice(0,K)).trim(),se=K===-1?Q:B.slice(K+1).trim();if(Q&&se)N[se]=M[Q]});else N[k]=M}else N[k]=M;if(L)if(!D&&W&&Array.isArray(M)&&M.length===2)N[L]=M[0],N[k]=M[1];else N[L]=R;let v=ce(j,N);v=Gn(v,N,c,e,!0),v=re(v,N,c),v=le(v,N);let J=v.indexOf(ee),G=v.indexOf(ne),q=J<0?G:G<0?J:Math.min(J,G);if(q>=0)v=v.slice(0,q);if(v=x(v,N,c),v=xe(v,N),v=me(v,N),v=he(v,N),T+=v,q>=0&&q===J)break}f=f.substring(0,h)+T+f.substring(O)}catch(S){let w=a("Foreach",`Error in @foreach(${I.trim()} as ${F.trim()}): ${S instanceof Error?S.message:String(S)}`,t.EVALUATION_ERROR);f=f.substring(0,h)+w+f.substring(O)}}return f}i=b(i,r),i=Ae(i,r,c,e);let d=e?.loops?.maxWhileIterations??de;return i=Oe(i,r,d),o?i:jr(i)}function El(n){let r=/^(\s*)([A-Za-z_$][\w$]*|\[[^\]]*\]|\{[^}]*\})(\s+(?:of|in)\s)/.exec(n);if(!r||/^(?:const|let|var)$/.test(r[2]))return n;return`${r[1]}let ${n.slice(r[1].length)}`}function ge(n){return _s(n)}function Ae(n,r,c,e){let o=n,i=!0;while(i){i=!1;let g=o.match(/@for\s*\(/);if(!g||g.index===void 0)break;let _=g.index,b=_+g[0].length-1,d=y(o,"(",")",b);if(d===-1)break;let s=El(o.slice(b+1,d)),m=d+1,f=Gr(o.slice(_),"for","endfor");if(f.length===0)break;let A=f[0].content,h=_+f[0].end;if(!ge(s)){let O=a("For",`Unsafe expression in @for: ${s}`,t.UNSAFE_EXPRESSION);o=o.substring(0,_)+O+o.substring(h),i=!0;continue}try{let O=Re(s),I=/@(?:for|foreach|if|unless)\s*\(/.test(A);if(O.length>0&&I){let z=we({forExpr:s,content:A,iterVarNames:O,context:r,filePath:c,options:e});o=o.substring(0,_)+z+o.substring(h),i=!0;continue}let F=Object.keys(r),j=Object.values(r),S=ae(A),W=Function(...F,"__stxRenderLoopValue",`
|
|
3
3
|
let result = '';
|
|
4
4
|
for (${s}) {
|
|
5
5
|
result += \`${S}\`;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Iu}from"./chunk-pfc2h65d.js";import"./chunk-nm7b8cmr.js";import"./chunk-qy26afdn.js";import"./chunk-9bgb9n12.js";import"./chunk-52g5q984.js";import"./chunk-zff3cb1e.js";import"./chunk-h1bnge85.js";import"./chunk-hx787tfa.js";import"./chunk-71sawjg8.js";import"./chunk-fbj9b0p6.js";import"./chunk-jgxzbthg.js";import"./chunk-95yt1gxa.js";import"./chunk-jhr08gjs.js";import"./chunk-hr3m2h4n.js";import"./chunk-tenbwcts.js";import"./chunk-912r15hr.js";import"./chunk-ygb33q5w.js";import"./chunk-kypwg2ws.js";import"./chunk-pe9ry4mj.js";import"./chunk-f178pm4d.js";import"./chunk-t6m5d64b.js";import"./chunk-r0ys9aqa.js";import"./chunk-6beg47t4.js";import"./chunk-gtktv6nn.js";export{Iu as startInteractive};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{N,Nl,yo,i,R,Ep,Tp}from"./chunk-jhr08gjs.js";import"./chunk-hr3m2h4n.js";import"./chunk-tenbwcts.js";import"./chunk-912r15hr.js";import"./chunk-ygb33q5w.js";import"./chunk-kypwg2ws.js";import"./chunk-pe9ry4mj.js";import"./chunk-f178pm4d.js";import"./chunk-t6m5d64b.js";import"./chunk-r0ys9aqa.js";import"./chunk-6beg47t4.js";import"./chunk-gtktv6nn.js";export{R as config,N as defaultConfig,Ep as defineStxConfig,yo as discoverConfig,i as loadStxConfig,Nl as resolveStxDirectories,Tp as validateConfig};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{jr,Gn,El}from"./chunk-52g5q984.js";import"./chunk-hx787tfa.js";import"./chunk-71sawjg8.js";import"./chunk-fbj9b0p6.js";import"./chunk-jgxzbthg.js";import"./chunk-jhr08gjs.js";import"./chunk-hr3m2h4n.js";import"./chunk-tenbwcts.js";import"./chunk-912r15hr.js";import"./chunk-ygb33q5w.js";import"./chunk-kypwg2ws.js";import{$t}from"./chunk-pe9ry4mj.js";import"./chunk-f178pm4d.js";import"./chunk-t6m5d64b.js";import"./chunk-r0ys9aqa.js";import"./chunk-6beg47t4.js";import"./chunk-gtktv6nn.js";export{El as declareBareLoopHead,$t as parseLoopBinding,Gn as processLoops,jr as reportDeferredLoopWarnings};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{le}from"./chunk-kypwg2ws.js";import{Be,A}from"./chunk-t6m5d64b.js";import{Sa}from"./chunk-912r15hr.js";import{c}from"./chunk-xvs84gas.js";import S from"fs";import m from"path";import{pathToFileURL as O}from"url";var E=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],P=new Set;function en(s,l={}){let o=m.resolve(s,l.dir??"server/api"),i=[],f=new Map;if(!S.existsSync(o))return i;let t=Array.from(new Bun.Glob("**/*.{ts,js,mts,mjs}").scanSync({cwd:o})).sort();for(let e of t){if(e.endsWith(".d.ts"))continue;let p=e.replace(/\.(?:ts|js|mts|mjs)$/,"").split("/"),n=p.pop(),u=n.lastIndexOf("."),d=u>=0?n.slice(u+1):"get",g=d.toUpperCase();if(!E.includes(g)||d!==d.toLowerCase())throw Error(`Unsupported API method suffix in ${e}; use ${E.map((y)=>y.toLowerCase()).join(", ")}`);if(u>=0)n=n.slice(0,u);if(n!=="index")p.push(n);let r=new Set,h=p.map((y,I)=>{let v=/^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(y);if(v){if(r.has(v[2])||v[1]&&I!==p.length-1)throw Error(`Invalid API parameter in ${e}`);return r.add(v[2]),`:${v[2]}${v[1]?"*":""}`}if(!/^[\w-]+$/.test(y))throw Error(`Unsupported API path segment ${y} in ${e}`);return y}),w=`/api${h.length?`/${h.join("/")}`:""}`,x=`${g} ${w.replace(/:\w+/g,":param")}`;if(f.has(x))throw Error(`Ambiguous API route ${g} ${w}: ${f.get(x)} and ${e}`);f.set(x,e);let R=m.join(o,e);P.add(m.resolve(R)),P.add(S.realpathSync(R)),i.push({pattern:w,method:g,filePath:R})}return i.sort((e,a)=>{let p=e.pattern.split("/"),n=a.pattern.split("/"),u=(d)=>d?.endsWith("*")?0:d?.startsWith(":")?1:2;for(let d=0;d<Math.max(p.length,n.length);d++){let g=u(n[d])-u(p[d]);if(g)return g}return e.pattern.localeCompare(a.pattern)||e.method.localeCompare(a.method)})}async function Ys(s,l){let o=c(s,"api-types.d.ts"),i=["// Generated by stx. Include this file in tsconfig.json.","declare module '@stacksjs/stx/api-client' {"," interface KnownApiRoutes {"];for(let t of l){let e=`./${m.relative(m.dirname(o),t.filePath).replace(/\\/g,"/")}`,{params:a}=le(t.pattern);i.push(` ${JSON.stringify(`${t.method} ${t.pattern}`)}: { params: { ${a.map((p)=>`${JSON.stringify(p)}: string`).join("; ")} }; response: Awaited<ReturnType<typeof import(${JSON.stringify(e)}).default>> }`)}i.push(" }","}","export {}","");let f=i.join(`
|
|
3
3
|
`);if(!await Bun.file(o).exists()||await Bun.file(o).text()!==f)await Bun.write(o,f);return o}async function Zs(s,l,o={}){let i=en(s,o);await Ys(s,i);let f=[];for(let t of i){let e=await Bun.build({entrypoints:[t.filePath],target:"bun",format:"esm",minify:!1,splitting:!1});if(!e.success)throw Error(`API build failed for ${t.filePath}: ${e.logs.join(`
|
|
4
|
-
`)}`);let a=e.outputs.find((u)=>u.kind==="entry-point");if(!a)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await a.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),a),f.push({...t,filePath:n})}return f}function j(s,l){let o=s.map((i)=>({route:i,...le(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,a=(r)=>r.replace(/:\w+/g,":param"),p=t.filter((r)=>a(r.route.pattern)===a(e)),n=i.method,u=p.find((r)=>r.route.method===n)??(n==="HEAD"?p.find((r)=>r.route.method==="GET"):void 0);if(!u){let r=new Set(p.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=u.regex.exec(f),g=Object.create(null);try{u.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await l(u.route);if(typeof r!=="function")throw Error(`API endpoint ${u.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Qs(s,l){return j(l,async(o)=>(await import(O(m.resolve(s,o.filePath)).href)).default)}async function lp(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=en(s,o);return await Ys(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=en(s,o);await Ys(s,t);let{loadStxConfig:e}=await import("./chunk-
|
|
4
|
+
`)}`);let a=e.outputs.find((u)=>u.kind==="entry-point");if(!a)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await a.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),a),f.push({...t,filePath:n})}return f}function j(s,l){let o=s.map((i)=>({route:i,...le(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,a=(r)=>r.replace(/:\w+/g,":param"),p=t.filter((r)=>a(r.route.pattern)===a(e)),n=i.method,u=p.find((r)=>r.route.method===n)??(n==="HEAD"?p.find((r)=>r.route.method==="GET"):void 0);if(!u){let r=new Set(p.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=u.regex.exec(f),g=Object.create(null);try{u.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await l(u.route);if(typeof r!=="function")throw Error(`API endpoint ${u.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Qs(s,l){return j(l,async(o)=>(await import(O(m.resolve(s,o.filePath)).href)).default)}async function lp(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=en(s,o);return await Ys(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=en(s,o);await Ys(s,t);let{loadStxConfig:e}=await import("./chunk-5m6ja6mx.js"),a=A((await e(s)).runtimeConfig);return await Be(a,()=>j(t,async(p)=>{let n=await Bun.build({entrypoints:[p.filePath],target:"bun",format:"esm",splitting:!1});if(!n.success)throw Error(n.logs.join(`
|
|
5
5
|
`));let u=n.outputs.find((d)=>d.kind==="entry-point");if(!u||n.outputs.length!==1)throw Error(`Unsupported API bundle output: ${p.filePath}`);return(await import(`data:text/javascript;base64,${Buffer.from(await u.text()).toString("base64")}`)).default})(f))}catch(t){return console.error("[stx] API discovery failed:",t),Response.json({error:"API discovery failed; check the server log"},{status:500})}}}function eo(s,l,o){if(Sa(s))return!0;let i=/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/;if(i.test(m.basename(s)))return!0;try{if(i.test(m.basename(S.realpathSync(s))))return!0}catch{}if(P.has(m.resolve(s)))return!0;if(!o)return!1;let f=m.resolve(l,typeof o==="object"?o.dir??"server/api":"server/api"),t=(a)=>{try{return S.realpathSync(a)}catch{return m.resolve(a)}},e=t(s);return[f,m.resolve(l,"server"),m.resolve(l,".output/server")].some((a)=>{let p=t(a);return e===p||e.startsWith(`${p}${m.sep}`)})}
|
|
6
6
|
export{en,Ys,Zs,Qs,lp,eo};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{st,fc}from"./chunk-gtktv6nn.js";import{T}from"./chunk-6beg47t4.js";import{L,as,s,an,F,z,Ia,It,fn,Me,Le}from"./chunk-
|
|
2
|
+
import{st,fc}from"./chunk-gtktv6nn.js";import{T}from"./chunk-6beg47t4.js";import{L,as,s,an,F,z,Ia,It,fn,Me,Le}from"./chunk-pe9ry4mj.js";import{Yn}from"./chunk-fbj9b0p6.js";import{K}from"./chunk-yft8yn6y.js";import{rn}from"./chunk-jgxzbthg.js";var j=`(?:"[^"]*"|'[^']*'|[^>"'])*`,Q=/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s,q=65536,J=4,O=new Map;function bp(){O.clear()}function Y(e){let o=[];for(let n of z(e,F)){let t=n.token.match(/^<script\b([^>]*)>/i),r=n.token.match(/<\/script\s*>$/i);if(!t||!r)continue;let a=t[0].length,f=n.token.length-r[0].length;o.push(Object.freeze({fullMatch:n.token,attrs:t[1],body:n.token.slice(a,f),start:n.start,end:n.end}))}return o}function Rl(e,o={}){let n=e.length>=q,t=n?O.get(e):void 0;if(t===void 0){if(t=Y(e),n)Ia(O,J),O.set(e,t)}let r=o.skipAttrs;if(!r)return t.slice();let a=[];for(let f of t)if(r.lastIndex=0,!r.test(f.attrs))a.push(f);return a}function uo(e){let o=e.trim(),n=o.match(/^([\s\S]+?)\s+as\s+(.+)$/);if(n){let r=n[1].trim(),a=n[2].trim(),{itemVar:f,indexVar:c}=B(a);if(f)return{style:"as",iterable:r,itemVar:f,indexVar:c}}let t=o.match(/^(\([^)]+\)|\w+(?:\s*,\s*\w+)?)\s+(?:in|of)\s+([\s\S]+)$/);if(t){let r=t[1].trim(),a=t[2].trim(),{itemVar:f,indexVar:c}=B(r);if(f)return{style:"in",iterable:a,itemVar:f,indexVar:c}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function B(e){let o=e.trim(),n=o.match(/^(\w+)\s*=>\s*(\w+)$/);if(n)return{itemVar:n[2],indexVar:n[1]};let t=o.match(/^\(\s*(\w+)(?:\s*,\s*(\w+))?\s*\)$/);if(t)return{itemVar:t[1],indexVar:t[2]||null};let r=o.match(/^(\w+)\s*,\s*(\w+)$/);if(r)return{itemVar:r[1],indexVar:r[2]};let a=o.match(/^(\w+)$/);if(a)return{itemVar:a[1],indexVar:null};return{itemVar:null,indexVar:null}}function Ur(e,o){return fc(e,o)}function ee(e){let o=/@(if\s*\(|endif|elseif\s*\(|else\b)/g,n=0,t;while((t=o.exec(e))!==null){let r=t[1];if(r.startsWith("if"))n++;else if(r==="endif")n--;else if(n===0)return!0}return!1}function Xn(e){let o=new Set,n=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,t=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal|useModel)\s*(?:<[^>]*>)?\s*\(/g,r;while((r=n.exec(e))!==null){let a=r[1],f;while((f=t.exec(a))!==null)o.add(f[1])}return o}function te(e){if(!/[:@]for\s*=/.test(e)&&!/\bx-for\s*=/.test(e))return[];let o=new RegExp(`<([a-zA-Z][\\w-]*)\\b(${j})>`,"iy"),n=/(?:^|\s)(?::for|@for|x-for)\s*=\s*(?:"([^"]*)"|'([^']*)')/i,t=z(e,(a,f)=>{o.lastIndex=f;let c=o.exec(a);if(!c||c.index!==f||!n.test(c[2]))return-1;return o.lastIndex}),r=[];for(let a of t){o.lastIndex=0;let f=o.exec(a.token);if(!f)continue;let c=f[2].match(n),p=uo(c?.[1]??c?.[2]??""),h=[p.itemVar,p.indexVar].filter(Boolean);if(h.length===0)continue;let i=f[1],g=/\/\s*>$/.test(a.token)||M.has(i.toLowerCase())?a.end:W(e,a.start,i,a.end);if(g!==-1)r.push({start:a.start,end:g,vars:new Set(h)})}return r}var Z=new Set(["true","false","null","undefined","NaN","Infinity","typeof","instanceof","in","of","new","void","delete","this","Math","JSON","Date","Number","String","Boolean","Array","Object","RegExp","Map","Set","Symbol","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","window","document","console"]);function ne(e){return e.replace(/'(?:\\.|[^'\\])*'/g,"''").replace(/"(?:\\.|[^"\\])*"/g,'""').replace(/`(?:\\.|[^`\\])*`/g,"``")}function U(e,o,n,t){if(!e)return!1;let r=ne(e),a=!1,f=!1,c=!1,p=/([a-zA-Z_$][\w$]*)/g,h;while((h=p.exec(r))!==null){let l=h[1];if(r.slice(0,h.index).trimEnd().endsWith("."))continue;if(Z.has(l))continue;if(o.has(l)||t?.has(l))a=!0;else if(n&&l in n)f=!0}let i=/([a-zA-Z_$][\w$]*)(?:\.[a-zA-Z_$][\w$]*)*\s*\(\s*\)/g,u;while((u=i.exec(r))!==null){let l=u[1];if(r.slice(0,u.index).trimEnd().endsWith("."))continue;if(Z.has(l)||n&&l in n)continue;c=!0}return(a||c)&&!f}function N(e,o,n){let t=n===void 0?` ${o}`:` ${o}="${n.replace(/"/g,""")}"`,r=e.trim(),a=r.match(Q);if(a&&se(a[3],a[1])){let[,f,c,p]=a;return`<${f}${c}${t}>${p}</${f}>`}return`<template${t}>${r}</template>`}function se(e,o){let n=new RegExp(`<(/)?${o}(?=[\\s/>])`,"gi"),t=0,r;while((r=n.exec(e))!==null)if(r[1]){if(t--,t<0)return!1}else t++;return!0}function po(e,o){let n=Xn(e);function t(r){let a=r,f=te(r),c=(u)=>{let g=new Set;for(let l of f)if(u>l.start&&u<l.end)for(let d of l.vars)g.add(d);return g},p=/@if\s*\(/g,h,i=[];while((h=p.exec(a))!==null){let u=h.index,g=u+h[0].length,l=1,d=g;while(d<a.length&&l>0){if(a[d]==="(")l++;else if(a[d]===")")l--;d++}if(l!==0)continue;let b=a.substring(g,d-1).trim(),S=d,w=1,E=S,m=/@(if\s*\(|endif)/g;m.lastIndex=S;let x;while((x=m.exec(a))!==null)if(x[1].startsWith("if"))w++;else if(x[1]==="endif"){if(w--,w===0){E=x.index+x[0].length;break}}if(w!==0)continue;let y=a.substring(S,E-6).trim(),R;if(ee(y)){let _=rn(a.substring(u,E));if(_.length===0)continue;let I=_[0].branches.filter((v)=>v.type!=="else"),k=c(u);if(!(I.length>0&&I.every((v)=>U(v.condition,n,o,k))))continue;R=_[0].branches.map((v)=>{let V=t(v.content);if(v.type==="elseif")return N(V,"@else-if",v.condition??"");if(v.type==="else")return N(V,"@else");return N(V,"@if",v.condition??"")}).join(`
|
|
3
3
|
`)}else{if(!U(b,n,o,c(u)))continue;R=N(t(y),"@if",b)}i.push({start:u,end:E,replacement:R}),p.lastIndex=E}for(let u=i.length-1;u>=0;u--){let{start:g,end:l,replacement:d}=i[u];a=a.substring(0,g)+d+a.substring(l)}return a}return t(e)}function re(e){let o=e.trim();if(o==="")return;if(o==="true")return!0;if(o==="false")return!1;if(o==="null")return!1;if(o==="undefined")return!1;if(o==="NaN")return!1;if(/^-?\d+(?:\.\d+)?$/.test(o)){let r=Number(o);return r!==0&&!Number.isNaN(r)}let n=o.match(/^'((?:\\.|[^'\\])*)'$/);if(n)return n[1].length>0;let t=o.match(/^"((?:\\.|[^"\\])*)"$/);if(t)return t[1].length>0;return}var M=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),G=/<(script|style)\b/iy,ie=/<\/script/gi,oe=/<\/style/gi;function W(e,o,n,t){if(M.has(n.toLowerCase()))return t;let r=n.toLowerCase(),a=e.length,f=1,c=t;while(c<a){let p=e.indexOf("<",c);if(p===-1)return-1;if(c=p,e.startsWith("<!--",c)){let g=e.indexOf("-->",c+4);if(g===-1)return-1;c=g+3;continue}G.lastIndex=c;let h=G.exec(e);if(h){let g=e.indexOf(">",c);if(g===-1)return-1;if(e[g-1]==="/"){c=g+1;continue}let l=h[1].toLowerCase()==="script"?ie:oe;l.lastIndex=c;let d=l.exec(e);if(d===null)return-1;let b=e.indexOf(">",d.index);if(b===-1)return-1;c=b+1;continue}if(e[c+1]==="/"){let g=/^<\/([a-z][\w-]*)\s*>/i.exec(e.slice(c,c+64));if(!g){c++;continue}if(g[1].toLowerCase()===r){if(f--,c+=g[0].length,f===0)return c;continue}c+=g[0].length;continue}let i=/^<([a-z][\w-]*)\b/i.exec(e.slice(c,c+64));if(!i){c++;continue}let u=e.indexOf(">",c);if(u===-1)return-1;if(i[1].toLowerCase()===r){let g=e.slice(c,u+1);if(!(/\/\s*>$/.test(g)||M.has(r)))f++}c=u+1}return-1}var ce=/\s(?::else-if|x-else-if|@else-if|:else|x-else|@else)(?=[=\s/>])/;function ae(e,o){let n=o,t=e.length;for(;;){while(n<t&&e[n]!=="<")n++;if(n>=t)return!1;if(e.startsWith("<!--",n)){let f=e.indexOf("-->",n+4);if(f===-1)return!1;n=f+3;continue}break}if(e[n+1]==="/")return!1;let r=e.indexOf(">",n);if(r===-1)return!1;let a=e.slice(n,r+1);return ce.test(a)}function fo(e){if(!e.includes(":if")&&!e.includes(":show")&&!e.includes("x-if")&&!e.includes("x-show")&&!e.includes("@if=")&&!e.includes("@show="))return e;let o=[],n=/<([a-zA-Z][\w-]*)/y,t=/\s/,r=new Set([":if",":show","x-if","x-show","@if","@show"]);z(e,(i,u)=>{n.lastIndex=u;let g=n.exec(i);if(!g||/^(?:script|style)$/i.test(g[1]))return-1;let l=n.lastIndex,d;while(l<i.length){let b=l;while(l<i.length&&t.test(i[l]))l++;let S=l;if(i[S]==="/"){S++;while(S<i.length&&t.test(i[S]))S++}if(i[S]===">"){if(d)o.push({start:u,end:S+1,tag:g[1],...d});return-1}if(l===b)return-1;let w=l;while(l<i.length&&!t.test(i[l])&&i[l]!=="="&&i[l]!==">")l++;if(l===w)return-1;let E=i.slice(w,l);if(E.startsWith("@")&&E.includes("("))return-1;let m=l,x=l;while(x<i.length&&t.test(i[x]))x++;if(i[x]!=="="){l=m;continue}x++;while(x<i.length&&t.test(i[x]))x++;let y=i[x];if(y==='"'||y==="'"){let R=i.indexOf(y,x+1);if(R===-1)return-1;if(!d&&y==='"'&&r.has(E))d={attrName:E,attrStart:b,attrEnd:R+1,value:i.slice(x+1,R)};l=R+1}else{l=x;while(l<i.length&&!t.test(i[l])&&i[l]!==">")l++}}return-1});let a=[],f=-1;for(let i of o){let{start:u,end:g,tag:l,attrName:d,value:b}=i;if(u<f)continue;let S=re(b);if(S===void 0)continue;let m=/\/\s*>$/.test(e.slice(u,g))||M.has(l.toLowerCase())?g:W(e,u,l,g);if(m===-1)continue;if((d===":if"||d==="x-if"||d==="@if")&&ae(e,m))continue;if(S===!0){let y=e.slice(u,i.attrStart)+e.slice(i.attrEnd,g);a.push({start:u,end:g,replacement:y});continue}a.push({start:u,end:m,replacement:""}),f=m}if(a.length===0)return e;a.sort((i,u)=>i.start-u.start);let c=[],p=-1;for(let i of a){if(i.start<p)continue;c.push(i),p=i.end}let h=e;for(let i=c.length-1;i>=0;i--){let{start:u,end:g,replacement:l}=c[i];h=h.substring(0,u)+l+h.substring(g)}return h}var X=[":for","@for","x-for"];function Wr(e,o){if(!o||Object.keys(o).length===0)return e;if(!X.some((c)=>e.includes(`${c}=`)))return e;let n=Xn(e);if(Array.isArray(o.__stx_client_signal_names)){for(let c of o.__stx_client_signal_names)if(typeof c==="string")n.add(c)}let t=e,r=[],a=/<([a-zA-Z][\w-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g,f;while((f=a.exec(t))!==null){let[c,p,h]=f,i=f.index,u=i+c.length,g=X.map((R)=>({attr:R,m:new RegExp(`\\s${R}="([^"]*)"`).exec(h)})).find((R)=>R.m!==null);if(!g||!g.m)continue;let l=uo(g.m[1]);if(!l.iterable||!l.itemVar)continue;let d=l.iterable.trim().split(/[.[(]/)[0].trim();if(!d||n.has(d)||!(d in o))continue;let b=W(t,i,p,u);if(b===-1)continue;let S=h.replace(new RegExp(`\\s${g.attr}="[^"]*"`),"").replace(/\s:key="[^"]*"/,"").replace(/\sx-cloak(?=\s|$)/,""),w=t.slice(u,b-`</${p}>`.length),E={...o,[l.itemVar]:void 0};if(l.indexVar)E[l.indexVar]=void 0;let m=Wr(w,E),x=l.indexVar?`${l.iterable} as ${l.indexVar} => ${l.itemVar}`:`${l.iterable} as ${l.itemVar}`,y=p.toLowerCase()==="template"?m:`<${p}${S}>${m}</${p}>`;r.push({start:i,end:b,replacement:`@foreach(${x})${y}@endforeach`}),a.lastIndex=b}for(let c=r.length-1;c>=0;c--){let{start:p,end:h,replacement:i}=r[c];t=t.slice(0,p)+i+t.slice(h)}return t}function qr(e,o){let n=e,t=/@(for|foreach)\s*\(/g,r,a=[],f=[];while((r=t.exec(n))!==null){let c=r[1],p=r.index,h=p+r[0].length,i=1,u=h;while(u<n.length&&i>0){if(n[u]==="(")i++;else if(n[u]===")")i--;u++}if(i!==0)continue;let g=n.substring(h,u-1).trim(),l=u,d=uo(g),b=c==="for"?"@endfor":"@endforeach",S=1,w=l,E=c==="for"?new RegExp("@(for(?!each)\\s*\\(|endfor(?!each))","g"):new RegExp(`@(${c}\\s*\\(|end${c})`,"g");E.lastIndex=l;let m;while((m=E.exec(n))!==null)if(m[1].startsWith(c))S++;else if(S--,S===0){w=m.index+m[0].length;break}if(S!==0)continue;let x=()=>{let A=[d.itemVar,d.indexVar].filter(Boolean);if(A.length)f.push({start:p,end:w,vars:A})};if(d.iterable){let A=d.iterable.trim();if(A.startsWith("[")||A.startsWith("{")||A.startsWith("'")||A.startsWith('"')||A.startsWith("`")||/^-?\d/.test(A)){x();continue}let C=A.split(/[.[(]/)[0].trim(),v=o?C in o:!1,V=f.some((P)=>p>P.start&&p<P.end&&P.vars.includes(C));if(C&&(v||V)){x();continue}}if(d.style==="as")g=d.indexVar?`(${d.itemVar}, ${d.indexVar}) in ${d.iterable}`:`${d.itemVar} in ${d.iterable}`;let y=n.substring(l,w-b.length).trim(),R=o?{...o}:{};if(d.itemVar)delete R[d.itemVar];if(d.indexVar)delete R[d.indexVar];let _=qr(y,R),I=_.match(Q),k;if(I){let[,A,C,v]=I;k=`<${A}${C} @for="${g}">${v}</${A}>`}else k=`<template @for="${g}">${_}</template>`;a.push({start:p,end:w,replacement:k}),t.lastIndex=w}for(let c=a.length-1;c>=0;c--){let{start:p,end:h,replacement:i}=a[c];n=n.substring(0,p)+i+n.substring(h)}return n}function le(e){let o=new Set,n=[],t=0,r=0,a=e.length,f=(i)=>{let u=t+1;while(u<a){let g=e[u];if(g==="\\"){u+=2;continue}if(g===i)return u+1;u++}return a},c=()=>{let i=t+2;while(i<a&&e[i]!==`
|
|
4
4
|
`)i++;return i},p=()=>{let i=t+2;while(i<a-1){if(e[i]==="*"&&e[i+1]==="/")return i+2;i++}return a},h=(i)=>{let u=i,g=0;while(u<a){let l=e[u];if(l==="/"&&e[u+1]==="/"){let d=u+2;while(d<a&&e[d]!==`
|
|
5
|
-
`)d++;u=d;continue}if(l==="/"&&e[u+1]==="*"){let d=u+2;while(d<a-1&&!(e[d]==="*"&&e[d+1]==="/"))d++;u=d+2;continue}if(l==='"'||l==="'"||l==="`"){let d=u+1;while(d<a){if(e[d]==="\\"){d+=2;continue}if(e[d]===l){d++;break}d++}u=d;continue}if(l==="("||l==="["||l==="{"){g++,u++;continue}if(l===")"||l==="]"||l==="}"){g--,u++;continue}if(l===";"&&g===0)return u+1;u++}return a};while(t<a){let i=e[t];if(i==="/"&&e[t+1]==="/"){let u=c();n.push(e.slice(t,u)),t=u;continue}if(i==="/"&&e[t+1]==="*"){let u=p();n.push(e.slice(t,u)),t=u;continue}if(i==='"'||i==="'"||i==="`"){let u=f(i);n.push(e.slice(t,u)),t=u;continue}if(i==="{"){r++,n.push(i),t++;continue}if(i==="}"){r--,n.push(i),t++;continue}if(r===0){let u=t>0?e[t-1]:"";if(u===""||/\s/.test(u)||u===";"||u==="}"||u==="{"){let l=e.slice(t).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(l){let d=l[2],b=h(t+l[0].length);if(o.has(d)){n.push(`/* stx: deduped const ${d} */`),t=b;continue}o.add(d),n.push(e.slice(t,b)),t=b;continue}}}n.push(i),t++}return n.join("")}var ue=new Set(["script","style","html","head","meta","link","title","!doctype"]);function D(e,o,n){for(let t of n){if(t.start>=o)return!1;if(t.end>e)return!0}return!1}function fe(e,o,n){let t=0;while(t<e.length){let r=e.indexOf(o,t);if(r===-1)return!1;if(!D(r,r+o.length,n))return!0;t=r+o.length}return!1}function de(e,o){if(fe(e,"<body",o)){let r=new RegExp(`<body(${j})>`,"g"),a;while((a=r.exec(e))!==null)if(!D(a.index,a.index+a[0].length,o))return a.index+a[0].length-1;return null}let n=new RegExp(`<([a-zA-Z][a-zA-Z0-9-]*)\\b(${j})>`,"gi"),t;while((t=n.exec(e))!==null){if(D(t.index,t.index+t[0].length,o))continue;if(ue.has(t[1].toLowerCase()))continue;return t.index+t[0].length-1}return null}function ge(e,o,n,t){let r=[],a=` data-stx="${t}"`,f=0,c=!1,p=(h)=>{if(n!==null&&!c&&n>=f&&n<=h)r.push(e.slice(f,n),a,e.slice(n,h)),c=!0;else r.push(e.slice(f,h))};for(let h of o){if(h.start<f)continue;p(h.start),f=h.end}return p(e.length),r.join("")}async function Kr(e,o,n,t={}){let r=Rl(e,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),a=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useStore|useLocalStorage|useSessionStorage|keptState|useCookie|useId|useModel|useReactiveProp|useFetch|useRef|useEventListener|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useMediaQuery|useScrollLock|usePreferredDark|usePreferredLight|usePreferredReducedMotion|usePreferredContrast|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots|useOptimistic)\s*(?:<[^>]*>)?\s*\(/,f=[],{hasUserImports:c,bundleClientScript:p}=await s("stx/client-script-bundler",()=>import("./chunk-
|
|
5
|
+
`)d++;u=d;continue}if(l==="/"&&e[u+1]==="*"){let d=u+2;while(d<a-1&&!(e[d]==="*"&&e[d+1]==="/"))d++;u=d+2;continue}if(l==='"'||l==="'"||l==="`"){let d=u+1;while(d<a){if(e[d]==="\\"){d+=2;continue}if(e[d]===l){d++;break}d++}u=d;continue}if(l==="("||l==="["||l==="{"){g++,u++;continue}if(l===")"||l==="]"||l==="}"){g--,u++;continue}if(l===";"&&g===0)return u+1;u++}return a};while(t<a){let i=e[t];if(i==="/"&&e[t+1]==="/"){let u=c();n.push(e.slice(t,u)),t=u;continue}if(i==="/"&&e[t+1]==="*"){let u=p();n.push(e.slice(t,u)),t=u;continue}if(i==='"'||i==="'"||i==="`"){let u=f(i);n.push(e.slice(t,u)),t=u;continue}if(i==="{"){r++,n.push(i),t++;continue}if(i==="}"){r--,n.push(i),t++;continue}if(r===0){let u=t>0?e[t-1]:"";if(u===""||/\s/.test(u)||u===";"||u==="}"||u==="{"){let l=e.slice(t).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(l){let d=l[2],b=h(t+l[0].length);if(o.has(d)){n.push(`/* stx: deduped const ${d} */`),t=b;continue}o.add(d),n.push(e.slice(t,b)),t=b;continue}}}n.push(i),t++}return n.join("")}var ue=new Set(["script","style","html","head","meta","link","title","!doctype"]);function D(e,o,n){for(let t of n){if(t.start>=o)return!1;if(t.end>e)return!0}return!1}function fe(e,o,n){let t=0;while(t<e.length){let r=e.indexOf(o,t);if(r===-1)return!1;if(!D(r,r+o.length,n))return!0;t=r+o.length}return!1}function de(e,o){if(fe(e,"<body",o)){let r=new RegExp(`<body(${j})>`,"g"),a;while((a=r.exec(e))!==null)if(!D(a.index,a.index+a[0].length,o))return a.index+a[0].length-1;return null}let n=new RegExp(`<([a-zA-Z][a-zA-Z0-9-]*)\\b(${j})>`,"gi"),t;while((t=n.exec(e))!==null){if(D(t.index,t.index+t[0].length,o))continue;if(ue.has(t[1].toLowerCase()))continue;return t.index+t[0].length-1}return null}function ge(e,o,n,t){let r=[],a=` data-stx="${t}"`,f=0,c=!1,p=(h)=>{if(n!==null&&!c&&n>=f&&n<=h)r.push(e.slice(f,n),a,e.slice(n,h)),c=!0;else r.push(e.slice(f,h))};for(let h of o){if(h.start<f)continue;p(h.start),f=h.end}return p(e.length),r.join("")}async function Kr(e,o,n,t={}){let r=Rl(e,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),a=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useStore|useLocalStorage|useSessionStorage|keptState|useCookie|useId|useModel|useReactiveProp|useFetch|useRef|useEventListener|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useMediaQuery|useScrollLock|usePreferredDark|usePreferredLight|usePreferredReducedMotion|usePreferredContrast|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots|useOptimistic)\s*(?:<[^>]*>)?\s*\(/,f=[],{hasUserImports:c,bundleClientScript:p}=await s("stx/client-script-bundler",()=>import("./chunk-z6enp6s3.js"));for(let m of r){let x=m.body;if(Me(m.attrs))x=Le(x);if(t.forceClientSetup||a.test(x)){f.push({content:x,start:m.start,end:m.end});continue}if(!c(x))continue;try{let y=await p(It(x).code,o||"",{projectRoot:process.cwd(),externalizeUserModules:!1});if(a.test(y))f.push({content:x,start:m.start,end:m.end})}catch{}}if(f.length===0)return{output:e,setupCode:null};let h=`${o??""}\x00${f.map((m)=>m.content).join("\x00")}`,i=`__stx_setup_${Bun.hash(h).toString(36).slice(0,10)}`,u=[];for(let m=0;m<f.length;m++){let x=f[m].bundled??It(f[m].content).code;if(!f[m].bundled&&c(x))x=await p(x,o||"",{projectRoot:process.cwd()});x=ht(x);let y=T(x);u.push(`// \u2500\u2500 merged signal script #${m+1} \u2500\u2500
|
|
6
6
|
${y}`)}let g=u.join(`
|
|
7
7
|
|
|
8
8
|
`);g=le(g);let d=L(g).split(",").map((m)=>m.trim()).filter(Boolean),b=fn(g,n),S=`
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Qu}from"./chunk-cz0p258g.js";import"./chunk-jhr08gjs.js";import"./chunk-hr3m2h4n.js";import"./chunk-tenbwcts.js";import"./chunk-912r15hr.js";import"./chunk-ygb33q5w.js";import"./chunk-kypwg2ws.js";import"./chunk-pe9ry4mj.js";import"./chunk-f178pm4d.js";import"./chunk-t6m5d64b.js";import"./chunk-r0ys9aqa.js";import"./chunk-6beg47t4.js";import"./chunk-gtktv6nn.js";export{Qu as buildApp};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Pa,n,pe}from"./chunk-
|
|
2
|
+
import{Pa,n,pe}from"./chunk-pe9ry4mj.js";import{Qe}from"./chunk-yn9kvsk1.js";import{c}from"./chunk-xvs84gas.js";import o from"fs";import l from"path";var Pl=new Map,m=new Map;async function vp(e){let r;for(let i=0;i<3;i++)try{let g=(await o.promises.stat(e)).mtime.getTime(),a=m.get(e);if(a&&a.mtime===g)return a.content;let h=await Bun.file(e).text(),w=(await o.promises.stat(e)).mtime.getTime();if(w!==g)continue;return m.set(e,{content:h,mtime:w}),h}catch(s){r=s;break}throw m.delete(e),Error(`File not found: ${e}${r?` (${r.message})`:""}`)}function wp(e){m.delete(e)}function xp(e){for(let t of m.keys())if(t.startsWith(e))m.delete(t)}var f=null,B=null,x=null;function Sp(e){x=e}async function Il(e=!1){let t=x??await import("./chunk-jmjjjgy4.js");if(e)return t.generateSignalsRuntimeDev();if(f===null)f=t.generateSignalsRuntime();return f}var S=null;async function Ol(){if(S===null){let{getRouterScript:e}=await import("./chunk-mkaw0bn4.js");S=e()}return S}var y={};async function kp(e,t=!1){let r=e==="runtime"?await Il(t):await Ol(),i=e==="runtime"&&t?"runtime-debug":e,s=y[i];if(!s||s.content!==r)s={content:r,hash:Bun.hash(r).toString(16).padStart(16,"0").slice(0,16)},y[i]=s;return{content:r,hash:s.hash,url:`/_stx/${e}.${s.hash}.js`}}var E=500,T=33554432,u=new Map,p=0;function C(e){return c(process.cwd(),"module-bundles",`${e}.js`)}function _p(e){let t=Bun.hash(e).toString(16).padStart(16,"0").slice(0,16),r=u.get(t),i=r!==void 0;if(i)u.delete(t),p-=r.length*2;u.set(t,e),p+=e.length*2;while(u.size>1&&(u.size>E||p>T)){let s=u.keys().next().value;p-=u.get(s).length*2,u.delete(s)}if(!i)try{let s=C(t);if(!o.existsSync(s))o.mkdirSync(l.dirname(s),{recursive:!0}),o.writeFileSync(s,e)}catch{}return`/_stx/modules.${t}.js`}function ho(e){if(!/^[0-9a-f]{16}$/.test(e))return;let t=u.get(e);if(t!==void 0)return t;try{return o.readFileSync(C(e),"utf8")}catch{return}}function Cp(){m.clear(),pe(),Pa(),f=null,B=null,S=null}function v(e){let t={debug:e.debug===!0,middleware:(e.middleware??[]).map((r)=>({name:r.name,timing:r.timing,handler:String(r.handler)})),customDirectives:(e.customDirectives??[]).map((r)=>({name:r.name,hasEndTag:r.hasEndTag===!0,rawParams:r.rawParams===!0,handler:String(r.handler)}))};return new Bun.CryptoHasher("sha1").update(JSON.stringify(t)).digest("hex")}async function Zn(e,t){try{if(!t.cachePath)return null;let r=l.resolve(t.cachePath),i=l.join(r,`${Xr(e)}.html`),s=l.join(r,`${Xr(e)}.meta.json`);if(!await n(i)||!await n(s))return null;let g=await Bun.file(s).text(),a=JSON.parse(g);if(a.cacheVersion!==t.cacheVersion)return null;if(a.engine!==Qe())return null;if(a.optionsSignature!==v(t))return null;if((await o.promises.stat(e)).mtime.getTime()>a.mtime)return null;for(let d of a.dependencies)if(await n(d)){if((await o.promises.stat(d)).mtime.getTime()>a.mtime)return null}else return null;return await Bun.file(i).text()}catch(r){return console.warn(`Cache error for ${e}:`,r),null}}async function Qn(e,t,r,i){try{if(!i.cachePath)return;let s=l.resolve(i.cachePath);await o.promises.mkdir(s,{recursive:!0});let g=l.join(s,`${Xr(e)}.html`),a=l.join(s,`${Xr(e)}.meta.json`),h=await o.promises.stat(e);await Bun.write(g,t);let d={sourcePath:e,mtime:h.mtime.getTime(),dependencies:Array.from(r),cacheVersion:i.cacheVersion,engine:Qe(),optionsSignature:v(i),generatedAt:Date.now()};await Bun.write(a,JSON.stringify(d,null,2)),Pl.set(e,{output:t,mtime:h.mtime.getTime(),dependencies:r})}catch(s){console.warn(`Failed to cache template ${e}:`,s)}}var _=16;function Xr(e){return new Bun.CryptoHasher("sha1").update(e).digest("hex").substring(0,_)}
|
|
3
3
|
export{Pl,vp,wp,xp,Sp,Il,Ol,kp,_p,ho,Cp,Zn,Qn,Xr};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{g,m,d}from"./chunk-
|
|
2
|
+
import{g,m,d}from"./chunk-pe9ry4mj.js";import{N}from"./chunk-jhr08gjs.js";import{o}from"./chunk-nm7b8cmr.js";import k from"path";var q={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},T=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var M=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function H(e){let t=[],i=0,n;M.lastIndex=0;while((n=M.exec(e))!==null){if(n.index>i){let a=e.slice(i,n.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let s=n[1],r=n[2];t.push({type:"suspense",name:s,content:r}),i=n.index+n[0].length}if(i<e.length){let s=e.slice(i);if(s.trim())t.push({type:t.length===0?"shell":"content",content:s})}if(t.length===0)t.push({type:"shell",content:e});return t}async function cd(e,t={},i={}){let n={...N,...i,streaming:{...q,...i.streaming}},s=n.streaming?.bufferSize||16384;return new ReadableStream({async start(r){try{let a=await Bun.file(e).text(),S=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),f=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),h={...t,__filename:e,__dirname:k.dirname(e)};if(f.trim())await g(f,h,e);let E=H(c),u=new Set;if(!E.some((w)=>w.type==="suspense")){let w=n.streaming?.strategy||"auto",x=new RegExp(T.source,"g");if(!(w!=="manual"&&x.test(c))){let p=await o(c,h,e,n,u);for(let b=0;b<p.length;b+=s)r.enqueue(p.slice(b,b+s)),await new Promise((y)=>setTimeout(y,0))}else{let p=[],b=new RegExp(T.source,"g"),y;while((y=b.exec(c))!==null)p.push({name:y[1],content:y[2],start:y.index,end:y.index+y[0].length});let v=0;for(let _ of p){if(_.start>v){let I=c.slice(v,_.start);if(I.trim()){let O=await o(I,h,e,n,u);r.enqueue(O),await new Promise((D)=>setTimeout(D,0))}}let C=await o(_.content,h,e,n,u);r.enqueue(C),await new Promise((I)=>setTimeout(I,0)),v=_.end}if(v<c.length){let _=c.slice(v);if(_.trim()){let C=await o(_,h,e,n,u);r.enqueue(C)}}}}else{let w=new Map;for(let l of E)if(l.type==="shell"||l.type==="content"){let p=await o(l.content,h,e,n,u);r.enqueue(p)}else if(l.type==="suspense"&&l.name){let p=`stx-suspense-${l.name}`;r.enqueue(`<div id="${p}" data-suspense="${l.name}" style="display:contents;">
|
|
3
3
|
<template data-suspense-fallback>Loading...</template>
|
|
4
4
|
</div>`),w.set(l.name,o(l.content,h,e,n,u))}r.enqueue(`
|
|
5
5
|
<script>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{en,Ys,Zs,Qs,lp,eo}from"./chunk-
|
|
2
|
+
import{en,Ys,Zs,Qs,lp,eo}from"./chunk-68wa4bf0.js";import"./chunk-912r15hr.js";import"./chunk-kypwg2ws.js";import"./chunk-t6m5d64b.js";export{Zs as buildServerApi,lp as createServerApi,en as discoverServerApi,Ys as generateApiTypes,eo as isServerApiSource,Qs as productionApiDispatcher};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{x}from"./chunk-
|
|
2
|
+
import{x}from"./chunk-pe9ry4mj.js";import{ce}from"./chunk-bz3zn6f7.js";function g(e,t){let r={};for(let n of e)r[n]=ce(t(n));return new Proxy({},{get:(n,a)=>r[a]?.(),set:(n,a,o)=>{if(r[a])r[a].set(o);else r[a]=ce(o);return!0},has:(n,a)=>(a in r),deleteProperty:(n,a)=>(delete r[a],!0),ownKeys:()=>Reflect.ownKeys(r),getOwnPropertyDescriptor:(n,a)=>(a in r)?{enumerable:!0,configurable:!0,writable:!0,value:r[a]()}:void 0})}function v(e,t){let r={};for(let n of t)r[n]=e[n];return r}function Fi(e,t){let r=Object.keys(e),n=g(r,(i)=>t?.[i]??e[i].getDefaultValue()),a=g(r,()=>[]),o=g(r,()=>!1),c=g(r,()=>!1),f=g(r,()=>!1),s=ce(!1);async function u(i){f[i]=!0;let d=await e[i].validate(n[i],n);return a[i]=d,f[i]=!1,d.length===0}async function l(){s.set(!0);let i=await Promise.all(r.map(u));return s.set(!1),i.every(Boolean)}function m(){for(let i of r)n[i]=t?.[i]??e[i].getDefaultValue(),a[i]=[],o[i]=!1,c[i]=!1}function h(i){for(let d of r)if(d in i)n[d]=i[d],c[d]=!0}function b(i,d){n[i]=d,c[i]=!0}function y(i,d=!0){if(o[i]=d,d)u(i)}function p(i){return{value:n[i],errors:a[i],touched:o[i],dirty:c[i],valid:a[i].length===0,validating:f[i]}}function V(i){return async(d)=>{d?.preventDefault?.();for(let w of r)o[w]=!0;if(await l())await i(v(n,r))}}return{values:n,errors:a,touched:o,dirty:c,get isValid(){return r.every((i)=>a[i].length===0)},get isValidating(){return s()||r.some((i)=>f[i])},get isDirty(){return r.some((i)=>c[i])},validate:l,validateField:u,reset:m,setValues:h,setFieldValue:b,setFieldTouched:y,getFieldState:p,handleSubmit:V}}var il=Fi;class On{rules=[];defaultValue="";addRule(e){let t=new On;return t.rules=[...this.rules,e],t.defaultValue=this.defaultValue,t}required(e="This field is required"){return this.addRule({name:"required",message:e,validate:(t)=>{if(t===null||t===void 0)return e;if(typeof t==="string"&&t.trim()==="")return e;if(Array.isArray(t)&&t.length===0)return e;return!0}})}email(e="Please enter a valid email"){return this.addRule({name:"email",message:e,validate:(t)=>{if(!t)return!0;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(t))||e}})}url(e="Please enter a valid URL"){return this.addRule({name:"url",message:e,validate:(t)=>{if(!t)return!0;try{return new URL(String(t)),!0}catch{return e}}})}min(e,t){let r=t||`Must be at least ${e} characters`;return this.addRule({name:"min",message:r,validate:(n)=>{if(!n)return!0;return String(n).length>=e||r}})}max(e,t){let r=t||`Must be no more than ${e} characters`;return this.addRule({name:"max",message:r,validate:(n)=>{if(!n)return!0;return String(n).length<=e||r}})}length(e,t,r){let n=r||`Must be between ${e} and ${t} characters`;return this.addRule({name:"length",message:n,validate:(a)=>{if(!a)return!0;let o=String(a).length;return o>=e&&o<=t||n}})}pattern(e,t="Invalid format"){return this.addRule({name:"pattern",message:t,validate:(r)=>{if(!r)return!0;return e.test(String(r))||t}})}hasUppercase(e="Must contain an uppercase letter"){return this.pattern(/[A-Z]/,e)}hasLowercase(e="Must contain a lowercase letter"){return this.pattern(/[a-z]/,e)}hasNumber(e="Must contain a number"){return this.pattern(/\d/,e)}hasSpecial(e="Must contain a special character"){return this.pattern(/[!@#$%^&*(),.?":{}|<>]/,e)}alphanumeric(e="Only letters and numbers allowed"){return this.pattern(/^[a-zA-Z0-9]+$/,e)}startsWithLetter(e="Must start with a letter"){return this.pattern(/^[a-zA-Z]/,e)}noSpaces(e="Spaces are not allowed"){return this.addRule({name:"noSpaces",message:e,validate:(t)=>{if(!t)return!0;return!String(t).includes(" ")||e}})}number(e="Must be a number"){let t=this.addRule({name:"number",message:e,validate:(r)=>{if(!r&&r!==0)return!0;return!Number.isNaN(Number(r))||e}});return t.defaultValue=0,t}integer(e="Must be a whole number"){return this.addRule({name:"integer",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number.isInteger(Number(t))||e}})}positive(e="Must be a positive number"){return this.addRule({name:"positive",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number(t)>0||e}})}negative(e="Must be a negative number"){return this.addRule({name:"negative",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number(t)<0||e}})}minValue(e,t){let r=t||`Must be at least ${e}`;return this.addRule({name:"minValue",message:r,validate:(n)=>{if(!n&&n!==0)return!0;return Number(n)>=e||r}})}maxValue(e,t){let r=t||`Must be no more than ${e}`;return this.addRule({name:"maxValue",message:r,validate:(n)=>{if(!n&&n!==0)return!0;return Number(n)<=e||r}})}between(e,t,r){let n=r||`Must be between ${e} and ${t}`;return this.addRule({name:"between",message:n,validate:(a)=>{if(!a&&a!==0)return!0;let o=Number(a);return o>=e&&o<=t||n}})}matches(e,t){let r=t||`Must match ${e}`;return this.addRule({name:"matches",message:r,validate:(n,a)=>{if(!a)return!0;return n===a[e]||r}})}oneOf(e,t){let r=t||`Must be one of: ${e.join(", ")}`;return this.addRule({name:"oneOf",message:r,validate:(n)=>{if(!n)return!0;return e.includes(n)||r}})}notOneOf(e,t){let r=t||`Cannot be one of: ${e.join(", ")}`;return this.addRule({name:"notOneOf",message:r,validate:(n)=>{if(!n)return!0;return!e.includes(n)||r}})}date(e="Must be a valid date"){return this.addRule({name:"date",message:e,validate:(t)=>{if(!t)return!0;let r=new Date(String(t));return!Number.isNaN(r.getTime())||e}})}before(e,t){let r=new Date(e),n=t||`Must be before ${r.toLocaleDateString()}`;return this.addRule({name:"before",message:n,validate:(a)=>{if(!a)return!0;return new Date(String(a))<r||n}})}after(e,t){let r=new Date(e),n=t||`Must be after ${r.toLocaleDateString()}`;return this.addRule({name:"after",message:n,validate:(a)=>{if(!a)return!0;return new Date(String(a))>r||n}})}custom(e,t="Invalid value"){return this.addRule({name:"custom",message:t,validate:e})}async(e,t="Invalid value"){return this.addRule({name:"async",message:t,async:!0,validate:e})}when(e,t){let r=new On;r.rules=[...this.rules],r.defaultValue=this.defaultValue;for(let n of t.getRules())r.rules.push({...n,validate:(a,o)=>{if(!e(a,o||{}))return!0;return n.validate(a,o)}});return r}getRules(){return this.rules}getDefaultValue(){return this.defaultValue}default(e){let t=new On;return t.rules=[...this.rules],t.defaultValue=e,t}async validate(e,t){let r=[];for(let n of this.rules){let a=await n.validate(e,t);if(a!==!0)r.push(a)}return r}validateSync(e,t){let r=[];for(let n of this.rules){if(n.async)continue;let a=n.validate(e,t);if(a!==!0)r.push(a)}return r}}var id=new On;function al(e,t,r){let n=/@error\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderror/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return u.map((l)=>x(c,{...t,message:l},r)).join(`
|
|
3
3
|
`)}catch{return""}})}function cl(e,t,r){let n=/@errors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderrors/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return u.map((l)=>x(c,{...t,message:l},r)).join(`
|
|
4
4
|
`)}catch{return""}})}function ll(e,t,r){let n=/@hasErrors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@endhasErrors/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return c}catch{return""}})}function ad(e,t,r){let n=e;return n=al(n,t,r),n=cl(n,t,r),n=ll(n,t,r),n}export{Fi,il,On,id,al,cl,ll,ad};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{bp,Rl,uo,Ur,Xn,po,fo,Wr,qr,Kr,go,ua,Al,ht}from"./chunk-
|
|
2
|
+
import{bp,Rl,uo,Ur,Xn,po,fo,Wr,qr,Kr,go,ua,Al,ht}from"./chunk-71sawjg8.js";import"./chunk-fbj9b0p6.js";import"./chunk-jgxzbthg.js";import"./chunk-jhr08gjs.js";import"./chunk-hr3m2h4n.js";import"./chunk-tenbwcts.js";import"./chunk-912r15hr.js";import"./chunk-ygb33q5w.js";import"./chunk-kypwg2ws.js";import{L}from"./chunk-pe9ry4mj.js";import"./chunk-f178pm4d.js";import"./chunk-t6m5d64b.js";import"./chunk-r0ys9aqa.js";import"./chunk-6beg47t4.js";import"./chunk-gtktv6nn.js";export{bp as clearScriptScanCache,Wr as convertServerLoopAttributesToDirectives,po as convertSignalDirectivesToAttributes,qr as convertSignalLoopsToAttributes,Xn as extractClientSignalNames,L as extractExports,ua as findMarkupIndexOutsideScripts,Ur as hasSignalsSyntax,uo as parseLoopExpression,fo as preEvalLiteralReactiveIfs,Kr as processScriptSetup,go as processSignals,Al as rewriteStxImportSpecifiers,Rl as scanScriptTags,ht as stripStxRuntimeImports};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ou}from"./chunk-t2twa7wy.js";import"./chunk-rtfyx54t.js";import"./chunk-bkk6xq8p.js";import"./chunk-68wa4bf0.js";import"./chunk-fbj9b0p6.js";import"./chunk-jhr08gjs.js";import"./chunk-hr3m2h4n.js";import"./chunk-tenbwcts.js";import"./chunk-912r15hr.js";import"./chunk-ygb33q5w.js";import"./chunk-kypwg2ws.js";import"./chunk-pe9ry4mj.js";import"./chunk-f178pm4d.js";import"./chunk-t6m5d64b.js";import"./chunk-r0ys9aqa.js";import"./chunk-6beg47t4.js";import"./chunk-gtktv6nn.js";export{Ou as startProductionServer};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ze}from"./chunk-kypwg2ws.js";import{ft,Dn}from"./chunk-ct0ee0fr.js";import{Oe,un,Qa,ec}from"./chunk-
|
|
2
|
+
import{Ze}from"./chunk-kypwg2ws.js";import{ft,Dn}from"./chunk-ct0ee0fr.js";import{Oe,un,Qa,ec}from"./chunk-pe9ry4mj.js";import{mr,hr,yr,vr,Se}from"./chunk-r0ys9aqa.js";import{A}from"./chunk-t6m5d64b.js";import{Vo}from"./chunk-f178pm4d.js";import{h}from"./chunk-qy26afdn.js";import{o}from"./chunk-nm7b8cmr.js";import{N,i}from"./chunk-jhr08gjs.js";import{_a}from"./chunk-912r15hr.js";import{Ve,_e,Ii,Oi,Cn}from"./chunk-rtfyx54t.js";import{en,Zs}from"./chunk-68wa4bf0.js";import{En}from"./chunk-pfn70zdr.js";import{Kt,Fn,zn}from"./chunk-hqj28381.js";import{q}from"./chunk-fbj9b0p6.js";import m from"fs";import c from"path";import{createHash as Q}from"crypto";function W(n){return Q("sha256").update(n).digest("hex").slice(0,8)}function J(n=!1){let l=n?Dn():ft(),a=W(l);return{content:l,filename:`runtime.${a}.js`,hash:a}}function U(){let n=Ze(),l=W(n);return{content:n,filename:`router.${l}.js`,hash:l}}import V from"path";import{createHash as ee}from"crypto";function te(n={}){let l=new Set;return{context:new Proxy(n,{get(r,e){if(e in r)return r[e];if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return},has(r,e){if(e in r)return!0;if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return!1}}),accessedKeys:l}}async function X(n,l,a={}){let r=V.resolve(n),e=await Bun.file(r).text(),S=ee("sha256").update(e).digest("hex").slice(0,16);Qa();let _={};try{_=await i(a.configDir)}catch{}let y=[],d=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,f;while((f=d.exec(e))!==null){let R=f[1];if(/\bserver\b/.test(R))y.push(f[2])}let u=new Set(y.flatMap((R)=>Oe(R))),{context:D}=te({__filename:r,__dirname:V.dirname(r),__stx_serverDeclared:u}),w=new Set,j={...N,..._,...a,buildMode:"compile",strict:!1},b=await o(e,D,r,j,w),C=Ve(b),P=ec();return{route:l,sourceFile:n,html:b,fragment:C,placeholders:P,hasServerScripts:y.length>0,serverScriptContent:y,dependencies:Array.from(w),contentHash:S,status:un(e),streamTemplates:D.__streamTemplates}}var re=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function Z(n,l){let a=0,r=0;if(!m.existsSync(n))return{copied:a,bytes:r};m.mkdirSync(l,{recursive:!0});function e(S,_){let y=m.readdirSync(S,{withFileTypes:!0});for(let d of y){if(re.has(d.name))continue;let f=c.join(S,d.name),u=c.join(_,d.name);if(d.isDirectory())m.mkdirSync(u,{recursive:!0}),e(f,u);else if(d.isFile()){if(m.existsSync(u))continue;m.copyFileSync(f,u),a++,r+=m.statSync(u).size}}}return e(n,l),{copied:a,bytes:r}}async function zu(n={}){let l=Date.now(),a=c.resolve(n.root||process.cwd()),r=c.resolve(a,n.outputDir||".output");console.log("[stx build] Starting production build...");let e=await i(a),S=c.resolve(a,n.componentsDir??e.componentsDir??"components"),_=c.resolve(a,n.partialsDir??e.partialsDir??"partials"),y=c.resolve(a,n.layoutsDir??e.layoutsDir??"layouts"),d=n.publicDir??e.publicDir??"public",f=Se(e.app?.head,{known:vr,source:"app.head"}),u=e.app?.colorMode,D=e.router?.container||"main",w=n.routeRules??e.routeRules??{},j=En(w),b=n.serverApi??e.serverApi,C=typeof b==="object"?b:{};if(b)en(a,C);if(e.runtimeConfig)A(e.runtimeConfig,{});if(m.existsSync(r))m.rmSync(r,{recursive:!0});let P=[c.join(r,"public","__stx"),c.join(r,"public","assets"),c.join(r,"server","pages"),c.join(r,"server","fragments")];for(let s of P)m.mkdirSync(s,{recursive:!0});console.log("[stx build] Discovering routes...");let R=q(a,{pagesDirs:e._layerPageDirs}),Y=["components","layouts","partials"],B=R.filter((s)=>!Y.some((g)=>s.pattern.startsWith(`/${g}/`)||s.pattern===`/${g}`));console.log(`[stx build] Found ${B.length} page routes (${R.length-B.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let v=J(n.debug),x=U();await Bun.write(c.join(r,"public","__stx",v.filename),v.content),await Bun.write(c.join(r,"public","__stx",x.filename),x.content),console.log(`[stx build] Runtime: ${v.filename} (${(v.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${x.filename} (${(x.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let M=[],k=[];for(let s of B){let g=j(s.pattern),O=g.rendering==="prerender";if(O&&(s.pattern.includes(":")||s.pattern.includes("[")))throw Error(`Cannot prerender parameter route ${s.pattern}; use dynamic rendering (explicit path enumeration is not supported here)`);try{let t=await X(s.filePath,s.pattern,{configDir:a,componentsDir:S,partialsDir:_,layoutsDir:y,debug:n.debug});if(M.push(t),t.html=t.html.replace(/runtime\.__STX_HASH__\.js/g,v.filename).replace(/router\.__STX_HASH__\.js/g,x.filename),t.html=yr(t.html,f,{bodyScripts:[`<script src="/__stx/${x.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=mr(t.html,u);if(f.htmlAttrs)t.html=hr(t.html,f.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(t.html)){let p=t.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(p&&p[1]){let I=p[1];t.html=t.html.replace(" "+I,""),t.html=t.html.replace(/<body([^>]*)>/,`<body$1 ${I}>`)}}if(t.html=t.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),t.html=await h(t.html),O){let p=await Cn(t,{params:{},request:new Request(`http://stx.build${s.pattern}`),method:"GET",__stx_strict_hydration:!0});if(p.redirect||p.cookies?.length||p.boundaries?.length||p.headers&&Object.keys(p.headers).length)throw Error(`Prerendered route ${s.pattern} cannot set response headers/cookies, redirect or stream`);t.html=p.html,t.status=p.status??t.status,t.hasServerScripts=!1,t.serverScriptContent=[],t.placeholders={}}t.fragment=_e(t.html,D);let L=s.pattern==="/"?"index":s.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),z=c.join("server","pages",`${L}.compiled.json`),G=c.join("server","fragments",`${L}.html`);await Bun.write(c.join(r,z),JSON.stringify(t,null,2)),await Bun.write(c.join(r,G),t.fragment),k.push({pattern:s.pattern,compiledPath:z,fragmentPath:G,isDynamic:t.hasServerScripts,hasParams:s.pattern.includes(":")||s.pattern.includes("["),prerendered:O}),console.log(`[stx build] \u2713 ${s.pattern}`)}catch(t){if(Object.keys(g).length)throw t;console.error(`[stx build] \u2717 ${s.pattern}:`,t instanceof Error?t.message:t)}}let E=c.resolve(a,d);if(m.existsSync(E)){let{copied:s,bytes:g}=Z(E,c.join(r,"public"));if(s>0)console.log(`[stx build] Copied ${s} public asset${s===1?"":"s"} (${(g/1024).toFixed(1)}KB) from ${d}/`)}let H=zn(a);if(H){let{copied:s,bytes:g}=Z(H,c.join(r,"public",Fn));if(s>0)console.log(`[stx build] Copied ${s} asset${s===1?"":"s"} (${(g/1024).toFixed(1)}KB) from ${Kt}/`)}let F={runtime:v.filename,router:x.filename},T=Ii(k,F,r);if(T.routeRules=w,T.routerContainer=D,b)T.apiRoutes=await Zs(a,r,C);if(e.runtimeConfig)await Bun.write(c.join(r,"server/runtime-config.json"),JSON.stringify(e.runtimeConfig)),await Vo(a,e.runtimeConfig);if(e._layerGraph)await Bun.write(c.join(r,"server/layers.json"),JSON.stringify(_a(e._layerGraph),null,2));Oi(T,r);let K=Date.now()-l;return console.log(`
|
|
3
3
|
[stx build] Done in ${K}ms \u2014 ${M.length} pages compiled`),{pageCount:M.length,assets:F,outputDir:r,duration:K}}
|
|
4
4
|
export{zu};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{hn,Vo}from"./chunk-
|
|
2
|
+
import{hn,Vo}from"./chunk-f178pm4d.js";import"./chunk-t6m5d64b.js";export{Vo as generateRuntimeConfigTypes,hn as prepareRuntimeConfig};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{F,Ie}from"./chunk-
|
|
2
|
+
import{F,Ie}from"./chunk-pe9ry4mj.js";var o=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function u(t,e,r){let i={fullTag:r,content:e,attrs:t};if(/\bserver\b/.test(t))return{...i,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...i,type:"client"};if(o.test(e))return{...i,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...i,type:"client"};return{...i,type:"server"}}var S=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function Gt(t){let e=[],r=[],i=[],c=0;while(c<t.length){let s=t.indexOf("<",c);if(s===-1)break;let p=Ie(t,s);if(p>s){c=p;continue}let a=F(t,s);if(a>s){let f=t.slice(s,a),l=S.exec(f);if(l){let n=u(l[1],l[2],f);switch(n.type){case"signals":e.push(n);break;case"client":r.push(n);break;case"server":i.push(n);break}}c=a;continue}c=s+(t.startsWith("<!--",s)?4:1)}return{signals:e,client:r,server:i}}
|
|
3
3
|
export{Gt};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{pn,ql,Kl,Gl,Xl,Jl,g,Yl,Mo,Zl,Ka,Ga}from"./chunk-
|
|
2
|
+
import{pn,ql,Kl,Gl,Xl,Jl,g,Yl,Mo,Zl,Ka,Ga}from"./chunk-pe9ry4mj.js";import"./chunk-f178pm4d.js";import"./chunk-t6m5d64b.js";import"./chunk-r0ys9aqa.js";import"./chunk-6beg47t4.js";import"./chunk-gtktv6nn.js";export{pn as STX_ENGINE_BINDING_NAMES,Mo as convertToCommonJS,Ka as extractScriptFromTemplate,g as extractVariables,Ga as hasVariables,Yl as isCompleteImport,Jl as isMissingBindingFailure,Gl as isModuleResolutionFailure,Xl as isSyntaxFailure,Zl as splitDeclaration,ql as stripTypeScript,Kl as withoutStxReferrer};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import m from"path";var y=/__stxModules\["((?:[^"\\]|\\.)*)"\]/g;function I(...o){let r=new Set;for(let s of o){if(!s||!s.includes("__stxModules["))continue;for(let e of s.matchAll(y))try{r.add(JSON.parse(`"${e[1]}"`))}catch{}}return[...r].sort()}async function w(o,r={}){if(o.length===0)return null;let s=process.cwd(),e=[],a=[];o.forEach((t,c)=>{let i=t.startsWith("npm:")?t.slice(4):m.resolve(s,t),l=`__stxRegistered${c}`,p=JSON.stringify(t);e.push(`import * as ${l} from ${JSON.stringify(i)};`),a.push(`if (!globalThis.__stxModules[${p}]) globalThis.__stxModules[${p}] = ${l};`)});let d=[...e,"globalThis.__stxModules = globalThis.__stxModules || {};",...a].join(`
|
|
3
|
-
`),n;try{let{bundleClientScript:t}=await import("./chunk-
|
|
3
|
+
`),n;try{let{bundleClientScript:t}=await import("./chunk-z6enp6s3.js");n=await t(d,m.join(s,".stx-module-registry.ts"),{projectRoot:s,minify:r.minify,externalizeUserModules:!1,collectInputs:r.collectInputs,throwOnFailure:!0})}catch(t){let{formatBuildFailure:c}=await import("./chunk-6kam8r5y.js"),i=c(t);console.warn(`[stx] could not build the page module registry (#1957): ${i}`);let l=`[stx] the page module registry did not build, so ${o.join(", ")} cannot load (#1957): ${i}`;return`;console.error(${JSON.stringify(l)});`}let{transformAutoImports:f,generateAutoImportDestructuring:_}=await import("./chunk-q0v0cs2j.js"),u=f(n),h=_(u.stxImports,u.browserImports),{transformStoreImports:x}=await import("./chunk-9859r1d5.js");n=x(u.code);let g=JSON.stringify(new Bun.CryptoHasher("md5").update(d).digest("hex").slice(0,12));return[";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${g}]) return;`,` __stxBundles[${g}] = true;`,h,n,"})();"].join(`
|
|
4
4
|
`)}export{w as buildModuleRegistryScript,I as registeredModuleIdsIn};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{i}from"./chunk-
|
|
2
|
+
import{i}from"./chunk-jhr08gjs.js";import{Us}from"./chunk-pfn70zdr.js";import p from"path";async function Qu(t={}){let d=performance.now(),o=t.root||process.cwd(),e=await i(o),u=t.ssr?.routeRules??e.routeRules??{};if(Us(u),!e.ssr&&Object.keys(u).length)throw Error("routeRules require ssr: true and the production server; flat SSG output cannot apply request/cache policies");if(!e.ssr&&(t.ssr?.serverApi??e.serverApi))throw Error("serverApi requires ssr: true; flat SSG output cannot execute API endpoints");let r=e.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${r.toUpperCase()}${e.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let n,l;if(r==="ssg"){let{generateStaticSite:s}=await import("./ssg.js");n=await s({pagesDir:p.join(e.root||".",e.pagesDir||e.build?.pagesDir||"pages"),publicDir:e.publicDir||e.build?.publicDir||"public",outputDir:e.build?.outputDir||"dist",generate404:e.build?.generate404??!0,minify:e.build?.minify??!0,cleanOutput:e.build?.cleanOutput??!0,router:e.router,...t.ssg})}else{let{buildForProduction:s}=await import("./chunk-gcy2prwj.js");l=await s({root:o,outputDir:".output",debug:t.debug,...t.ssr})}let a=Math.round(performance.now()-d);return{mode:r,ssg:n,ssr:l,duration:a}}
|
|
3
3
|
export{Qu};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{wo,xo,So,ko,Qr,es,$p,Rp,Ap,Pp,ts,Ip}from"./chunk-
|
|
2
|
+
import{wo,xo,So,ko,Qr,es,$p,Rp,Ap,Pp,ts,Ip}from"./chunk-ygb33q5w.js";import"./chunk-r0ys9aqa.js";export{Ip as generateDefaultRobotsTxt,ts as generateRobotsTxt,Rp as generateSitemap,Ap as generateSitemapIndex,ko as injectSeoTags,Qr as metaDirective,wo as processMetaDirectives,So as processSeoDirective,xo as processStructuredData,$p as registerSeoDirectives,Pp as scanForSitemapEntries,es as structuredDataDirective};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{S}from"./chunk-gtktv6nn.js";import{T,xn}from"./chunk-6beg47t4.js";import{on,b,w,k,J}from"./chunk-
|
|
2
|
+
import{S}from"./chunk-gtktv6nn.js";import{T,xn}from"./chunk-6beg47t4.js";import{on,b,w,k,J}from"./chunk-pe9ry4mj.js";import{i}from"./chunk-jhr08gjs.js";import{Ee,Yt,Zt,Qt}from"./chunk-y8f59j6z.js";import{ht}from"./chunk-71sawjg8.js";import{pt,Nn,qt,ae}from"./chunk-2pga7zzb.js";import{C,wr}from"./chunk-078as147.js";import h from"path";var x=new Map,D=new Map,A=b(64),E=new Map,Z=["composables","functions"];function z(t){let n=h.basename(t,".ts");return n==="index"||n==="types"||t.endsWith(".d.ts")}async function q(t){if(t)return h.resolve(t);let n=`<default>:${process.cwd()}`,a=E.get(n);if(a!==void 0)return a;let e=await Q();if(e!==null)E.set(n,e);return e}async function Q(){let t=await i(),n=t.root||process.cwd(),a=t.composablesDir;if(a)return h.resolve(n,a);for(let e of Z){let s=h.resolve(n,e);try{let d=new Bun.Glob("**/*.ts");for await(let c of d.scan({cwd:s,absolute:!0}))if(!z(c))return s}catch{}}return null}async function G(t){let n=Array.isArray(t)?t:t?[h.resolve(t)]:(await i())._layerComposableDirs??[await q()].filter((e)=>!!e),a=new Map;for(let e of n){let s=new Bun.Glob("**/*.ts");try{for await(let d of s.scan({cwd:e,absolute:!0})){let c=h.relative(e,d);if(!z(d)&&!a.has(c))a.set(c,d)}}catch{}}return{key:n.join("\x00"),files:[...a.values()].sort()}}async function Ws(t){let{files:n}=await G(t),a=J({loader:"ts",target:"browser",define:k()}),e=[];for(let s of n)try{let d=await Bun.file(s).text(),c=a.scan(d).exports.filter((m)=>m!=="default");if(c.length>0)e.push({file:s,names:c})}catch{}return e}function V(t,n){return new RegExp(`\\b${n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(t)}function L(t,n){let a=new Set(t.match(/\w+/g)),e=new Set;for(let s of n)if(/^\w+$/.test(s)?a.has(s):V(t,s))e.add(s);return e}var U=b(64);function Y(t,n){let a=w(t,n.size),e=U.get(a);if(e)return e;let s;try{s=on(t,n)}catch{s=L(t,n)}let d=[...t.matchAll(/(?:const|let|var)\s*\{([^}]*)\}\s*=\s*window\.__composables\u0008/g),...t.matchAll(/import\s*\{([^}]*)\}\s*from\s*['"]@composables['"]/g)];for(let c of d)for(let m of c[1].split(",")){let p=m.trim().split(/\s*(?::|\u0008as\u0008)\s*/)[0];if(p&&n.has(p))s.add(p)}return U.set(a,s),s}function ee(t,n,a){let e=new Map;for(let{file:u,names:l}of t)for(let f of l)if(!e.has(f))e.set(f,u);let s=(u)=>{let l=[];for(let f of L(u,e.keys()))l.push(e.get(f));return l},d=new Set(e.keys()),c=(u)=>{let l=[];for(let f of Y(u,d))l.push(e.get(f));return l},m=new Set,p=a.flatMap((u,l)=>l===0?s(u):c(u));while(p.length>0){let u=[];for(let l of p){if(m.has(l))continue;m.add(l);for(let f of c(n.get(l)??""))if(!m.has(f))u.push(f)}p=u}return m}async function qd(t,n,a){let{key:e,files:s}=await G(t);if(!e)return null;let d=()=>[...new Set([...s,...s.flatMap((o)=>Ee(o))])],c=pt(d());if(s.length===0)return ae(x,e,c,""),null;s.sort();let m=J({loader:"ts",target:"browser",define:k()}),p=qt(D,e,c);if(!p){let o=new Map,r=[];for(let g of s)try{let y=await Bun.file(g).text();o.set(g,y);let _=m.scan(y).exports.filter((X)=>X!=="default");if(_.length>0)r.push({file:g,names:_})}catch{o.set(g,"")}p=ae(D,e,c,{codeByFile:o,modules:r})}let{codeByFile:u,modules:l}=p,f;if(n===void 0)f=new Set(s);else{let o=a?[n,...a]:[n],r=w(o.join("\x00"),e,o.length,c),g=A.get(r);if(f=g??ee(l,u,o),!g)A.set(r,f)}if(f.size===0)return null;let I=s.filter((o)=>f.has(o)),B=`${e}\x00${I.join("\x00")}\x00${Zt()}`,F=qt(x,B,c);if(F!==void 0)return F||null;let M=[],v=new Set,R=new Set;for(let o of I)try{let r=u.get(o)??await Bun.file(o).text(),g=h.basename(o,".ts");for(let _ of r.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(_[1])R.add(_[1]);let y=[];try{for(let _ of m.scan(r).exports)if(_!=="default")v.add(_),y.push(_)}catch{}if(r=T(r),Yt(r))r=await Qt(r,o,{projectRoot:process.cwd(),externalizeUserModules:!1,expose:y}),r=ht(r);r=xn(r),r=r.replace(/^export\s+(default\s+)?/gm,""),r=m.transformSync(r),M.push(`// Composable: ${g}
|
|
3
3
|
${r.trim()}`)}catch(r){console.warn(`[stx] Failed to load composable ${o}:`,r)}if(M.length===0||v.size===0)return ae(x,B,c,""),null;let H=[...v].map((o)=>` try { if (!(${JSON.stringify(o)} in __c)) __c[${JSON.stringify(o)}] = ${o}; } catch (e) {}`).join(`
|
|
4
4
|
`),j=JSON.stringify([...v]),N=M.join(`
|
|
5
5
|
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Hc,td,Vc,Uc,nd,rd}from"./chunk-haq3cg76.js";import"./chunk-pe9ry4mj.js";import"./chunk-f178pm4d.js";import"./chunk-t6m5d64b.js";import"./chunk-r0ys9aqa.js";import"./chunk-6beg47t4.js";import"./chunk-gtktv6nn.js";export{rd as applySlots,nd as extractSlotContent,td as parseSlotElement,Hc as parseSlots,Uc as processSlots,Vc as renderSlot};
|