@stacksjs/stx 0.2.289 → 0.2.291
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app-shell.js +5 -1
- package/dist/builtins/image-delivery.js +50 -1
- package/dist/{chunk-favq46aa.js → chunk-0gtbzvdf.js} +1 -1
- package/dist/{chunk-kb5j08tq.js → chunk-0jznnssx.js} +1 -1
- package/dist/chunk-0nr9jcv2.js +2 -0
- package/dist/{chunk-5yp3vt00.js → chunk-0nsa242z.js} +1 -1
- package/dist/{chunk-e67w1bge.js → chunk-0pjqw9nf.js} +1 -1
- package/dist/{chunk-2wtn443n.js → chunk-0ya4v5pr.js} +1 -1
- package/dist/chunk-12nxyp7k.js +2 -0
- package/dist/{chunk-n9kk3jz1.js → chunk-12sfyfes.js} +1 -1
- package/dist/{chunk-adr8nyhc.js → chunk-1f3hhrfj.js} +1 -1
- package/dist/{chunk-zy4zf7hy.js → chunk-1pmf8mbc.js} +1 -1
- package/dist/{chunk-gpspx24d.js → chunk-1y7105dt.js} +2 -2
- package/dist/{chunk-jj6yp7gm.js → chunk-278ay77z.js} +1 -1
- package/dist/{chunk-6085vha7.js → chunk-2hjag2ze.js} +1 -1
- package/dist/{chunk-tqgevvqn.js → chunk-3225x47e.js} +1 -1
- package/dist/chunk-367148d4.js +2 -0
- package/dist/chunk-3maxrw5t.js +2 -0
- package/dist/chunk-3vf4w6tn.js +2 -0
- package/dist/{chunk-n0j85038.js → chunk-5k2vmefg.js} +1 -1
- package/dist/{chunk-02af607x.js → chunk-603dkj8s.js} +1 -1
- package/dist/{chunk-9veqmqb6.js → chunk-64gh98cz.js} +61 -22
- package/dist/{chunk-fcfphfpw.js → chunk-6b9tm22t.js} +1 -1
- package/dist/{chunk-vvqe2gaz.js → chunk-6sme368t.js} +1 -1
- package/dist/{chunk-0b8032q1.js → chunk-6tna7a7t.js} +1 -1
- package/dist/chunk-6yy15yee.js +2 -0
- package/dist/{chunk-y5jjrnfa.js → chunk-7cwqawqt.js} +1 -1
- package/dist/{chunk-zqwmy0av.js → chunk-7emhfsfb.js} +1 -1
- package/dist/{chunk-fvej04d8.js → chunk-8x7699qk.js} +1 -1
- package/dist/{chunk-drbbt69f.js → chunk-8ybhs27t.js} +23 -4
- package/dist/{chunk-d0f60jrg.js → chunk-9rww0f53.js} +1 -1
- package/dist/{chunk-3br3pt6k.js → chunk-9vnh50p1.js} +1 -1
- package/dist/{chunk-rth88zfm.js → chunk-a4tv4wwg.js} +1 -1
- package/dist/{chunk-vzzkhjw7.js → chunk-a5x23sjv.js} +1 -1
- package/dist/chunk-ag3k1cp7.js +2 -0
- package/dist/chunk-ant3p5v8.js +3 -0
- package/dist/chunk-b2x8jxbq.js +2 -0
- package/dist/{chunk-fv923f7g.js → chunk-bf4xr43a.js} +1 -1
- package/dist/chunk-bxpvqbm3.js +2 -0
- package/dist/{chunk-nygtwffe.js → chunk-c1rwzz7v.js} +1 -1
- package/dist/{chunk-8daczchh.js → chunk-cdmk58g1.js} +1 -1
- package/dist/chunk-cjf28904.js +2 -0
- package/dist/{chunk-37zxqngs.js → chunk-cjtd0qqc.js} +1 -1
- package/dist/{chunk-besxa233.js → chunk-cp4dpkz8.js} +2 -2
- package/dist/{chunk-e0aybavh.js → chunk-d76qy741.js} +1 -1
- package/dist/chunk-dd9qpsxg.js +2 -0
- package/dist/chunk-dwfhkbnb.js +2 -0
- package/dist/{chunk-agx0620p.js → chunk-e4gbq08h.js} +1 -1
- package/dist/{chunk-ffmtamm2.js → chunk-eaev54m8.js} +1 -1
- package/dist/{chunk-np5dc1q1.js → chunk-f8hdq4gt.js} +1 -1
- package/dist/{chunk-qjkzpd68.js → chunk-fq5d2r74.js} +1 -1
- package/dist/{chunk-4hsvmefz.js → chunk-g10bygzc.js} +1 -1
- package/dist/{chunk-pvb0rf99.js → chunk-g71eqm8f.js} +1 -1
- package/dist/chunk-gb98w455.js +2 -0
- package/dist/chunk-gttwdcq3.js +2 -0
- package/dist/{chunk-kvrjfqxd.js → chunk-h6emafs7.js} +1 -1
- package/dist/chunk-hmercfd9.js +2 -0
- package/dist/{chunk-bkg7622z.js → chunk-hpks3cks.js} +1 -1
- package/dist/chunk-j7thx96e.js +2 -0
- package/dist/{chunk-31108nwx.js → chunk-jszyej4e.js} +1 -1
- package/dist/chunk-jze6dxct.js +2 -0
- package/dist/{chunk-havegv3v.js → chunk-k049j105.js} +343 -338
- package/dist/{chunk-8883pgj8.js → chunk-ke383bna.js} +1 -1
- package/dist/{chunk-ecgf48zt.js → chunk-kgjpgnk0.js} +2 -2
- package/dist/chunk-kr4mzzdn.js +2 -0
- package/dist/chunk-kxz4c02k.js +2 -0
- package/dist/{chunk-ymc99r5x.js → chunk-kzt0ycg7.js} +2 -2
- package/dist/chunk-mytda2c7.js +2 -0
- package/dist/{chunk-1e83cj7k.js → chunk-mzstheqe.js} +1 -1
- package/dist/{chunk-2e6xafcm.js → chunk-n3kmd544.js} +1 -1
- package/dist/{chunk-h7v70dbp.js → chunk-ncnmb3kq.js} +1 -1
- package/dist/chunk-nna2ra7b.js +2 -0
- package/dist/{chunk-dw57wss6.js → chunk-np744hxn.js} +1 -1
- package/dist/{chunk-9zdyma99.js → chunk-nszr6tyg.js} +1 -1
- package/dist/chunk-q9xk76f2.js +2 -0
- package/dist/{chunk-jv91rkhx.js → chunk-qkjrhzng.js} +1 -1
- package/dist/{chunk-kf8t2wq7.js → chunk-qyww2kx3.js} +1 -1
- package/dist/{chunk-dcxtrqfy.js → chunk-r2pck10q.js} +1 -1
- package/dist/{chunk-5zcg61j9.js → chunk-ry9mp3gp.js} +1 -1
- package/dist/{chunk-xpct12p7.js → chunk-s8xdgqxn.js} +1 -1
- package/dist/{chunk-kfy1jh6p.js → chunk-sdfr543c.js} +1 -1
- package/dist/{chunk-ym4ggcpy.js → chunk-sg0wxqc0.js} +1 -1
- package/dist/{chunk-s5f9bj8h.js → chunk-swe9ctpv.js} +1 -1
- package/dist/{chunk-byq2xpgb.js → chunk-tj99frhg.js} +1 -1
- package/dist/chunk-tnxq5ygy.js +2 -0
- package/dist/chunk-tt318keb.js +2 -0
- package/dist/{chunk-mc58fhgm.js → chunk-txmze65m.js} +1 -1
- package/dist/{chunk-t2wnvvec.js → chunk-v9fjy3rs.js} +10 -10
- package/dist/{chunk-2vza9m2x.js → chunk-vqq5zjbg.js} +1 -1
- package/dist/{chunk-gy933rct.js → chunk-vvkh24d4.js} +1 -1
- package/dist/chunk-vvnfyt9w.js +2 -0
- package/dist/chunk-vvzp0ev2.js +2 -0
- package/dist/{chunk-p0zq5ckb.js → chunk-vynan80s.js} +1 -1
- package/dist/{chunk-0xnvkqn6.js → chunk-w43x27h2.js} +3 -3
- package/dist/chunk-wwcdnhh5.js +2 -0
- package/dist/{chunk-461br5nn.js → chunk-wzb9q4ta.js} +1 -1
- package/dist/{chunk-zvw2qgwt.js → chunk-x21tn7gc.js} +1 -1
- package/dist/{chunk-r90w3x6h.js → chunk-xz3gc1kb.js} +1 -1
- package/dist/{chunk-n5y9gh1q.js → chunk-y0xah453.js} +1 -1
- package/dist/{chunk-mmnqd035.js → chunk-yh6he959.js} +1 -1
- package/dist/{chunk-yhqheg5m.js → chunk-yrz3hq80.js} +4 -4
- package/dist/{chunk-h61qt916.js → chunk-ytax6h7b.js} +1 -1
- package/dist/{chunk-p5b0r6fn.js → chunk-z3te7cgf.js} +1 -1
- package/dist/{chunk-vxxxczmn.js → chunk-z7g7djb3.js} +1 -1
- package/dist/{chunk-k4aq88mj.js → chunk-zbxbg129.js} +1 -1
- package/dist/{chunk-nkpj1a74.js → chunk-zcwpr2kc.js} +1 -1
- package/dist/cli.js +14 -14
- package/dist/client-script.d.ts +12 -0
- package/dist/client-script.js +5 -5
- package/dist/component-renderer.d.ts +8 -0
- package/dist/component-renderer.js +7 -0
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/database.js +1 -1
- package/dist/includes.js +36 -18
- package/dist/inline-assets.d.ts +0 -14
- package/dist/inline-assets.js +16 -2
- package/dist/pwa.js +2 -2
- package/dist/signals.js +60 -21
- package/dist/ssg.js +2 -2
- package/dist/utils.js +2 -2
- package/dist/visual-testing.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-08yja60e.js +0 -2
- package/dist/chunk-1gvebxh4.js +0 -2
- package/dist/chunk-2ctw99gz.js +0 -2
- package/dist/chunk-2s0jm6fq.js +0 -2
- package/dist/chunk-3jqcv3ve.js +0 -2
- package/dist/chunk-437n7hyx.js +0 -2
- package/dist/chunk-508p29a1.js +0 -2
- package/dist/chunk-50e0319x.js +0 -2
- package/dist/chunk-amwtttwf.js +0 -2
- package/dist/chunk-bq6q6pjx.js +0 -3
- package/dist/chunk-btqfj5be.js +0 -2
- package/dist/chunk-bw48gj8j.js +0 -2
- package/dist/chunk-bzsjhyet.js +0 -2
- package/dist/chunk-ckwq6fkw.js +0 -2
- package/dist/chunk-ddqynjve.js +0 -2
- package/dist/chunk-e7kd0ny8.js +0 -2
- package/dist/chunk-fcedzn8w.js +0 -2
- package/dist/chunk-fxk9j0rm.js +0 -2
- package/dist/chunk-gxghqvws.js +0 -2
- package/dist/chunk-gyd4cb9m.js +0 -2
- package/dist/chunk-hxjkjm6k.js +0 -2
- package/dist/chunk-j5n1td3p.js +0 -2
- package/dist/chunk-nh0frxtq.js +0 -2
- package/dist/chunk-nka77z47.js +0 -2
- package/dist/chunk-pne8pq50.js +0 -2
- package/dist/chunk-r84zvf0z.js +0 -2
- package/dist/chunk-t2w7twke.js +0 -2
- package/dist/chunk-vrnn3pqk.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Fi as a,Gi as b,Hi as c,Ii as d,Ji as e}from"./chunk-k70fgb2f.js";import"./chunk-
|
|
2
|
+
import{Fi as a,Gi as b,Hi as c,Ii as d,Ji as e}from"./chunk-k70fgb2f.js";import"./chunk-vqq5zjbg.js";export{a as processAsyncDirectives,c as isAsyncComponent,e as generateAsyncComponentRuntime,d as generateAsyncComponentCSS,b as defineAsyncComponent};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ri as a,Si as b,Ti as c,Ui as d,Vi as e,Wi as f,Xi as g}from"./chunk-jem20v5k.js";import"./chunk-
|
|
2
|
+
import{Ri as a,Si as b,Ti as c,Ui as d,Vi as e,Wi as f,Xi as g}from"./chunk-jem20v5k.js";import"./chunk-vqq5zjbg.js";export{d as useVirtualList,b as processVirtualListDirectives,f as processVirtualGridDirectives,e as processInfiniteListDirectives,c as generateVirtualListCSS,g as default,a as createVirtualList};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Rl as C}from"./chunk-
|
|
2
|
+
import{Rl as C}from"./chunk-k049j105.js";import{_s as Y}from"./chunk-fq5d2r74.js";import{$t as D}from"./chunk-ncnmb3kq.js";import u from"path";var S=/<script(\s[^>]*)?>([\s\S]*?)<\/script>/gi;function h(K){let J=(Q)=>Q.replace(/[^\n]/g," ");return K.replace(/<!--[\s\S]*?-->/g,J).replace(/\{\{--[\s\S]*?--\}\}/g,J)}function m(K){let J=[],Q=h(K);S.lastIndex=0;let $;while(($=S.exec(Q))!==null){let j=($[1]||"").trim(),F=($[0].match(/^<script(?:\s[^>]*)?>/i)?.[0]??"<script>").length,z=($[0].match(/<\/script\s*>$/i)?.[0]??"</script>").length,W=$.index+F,Z=$.index+$[0].length-z,G=K.slice(W,Z);if(/\bsrc\s*=/.test(j))continue;let q=j.match(/\btype\s*=\s*["']([^"']+)["']/i);if(q&&!/^(?:module|text\/(?:javascript|typescript))$/i.test(q[1]))continue;let X=/\bserver\b/.test(j)?"server":/\bclient\b/.test(j)?"client":"plain",U=B(K,W);J.push({kind:X,code:G,startLine:U,attrs:j})}return J}function B(K,J){let Q=1;for(let $=0;$<J&&$<K.length;$++)if(K.charCodeAt($)===10)Q++;return Q}function N(K,J){let Q=K.lastIndexOf(`
|
|
3
3
|
`,J-1)+1;return J-Q+1}function g(K){let J=K.split(""),Q=(j,F)=>{for(let z=j;z<F&&z<J.length;z++)if(J[z]!==`
|
|
4
4
|
`)J[z]=" "},$=[/<script(?:\s[^>]*)?>[\s\S]*?<\/script>/gi,/<style(?:\s[^>]*)?>[\s\S]*?<\/style>/gi,/<!--[\s\S]*?-->/g,/\{\{--[\s\S]*?--\}\}/g,/@verbatim\b[\s\S]*?@endverbatim\b/g];for(let j of $){j.lastIndex=0;let F;while((F=j.exec(K))!==null)Q(F.index,F.index+F[0].length)}return J.join("")}function p(K){let J=0,Q="";for(let $=0;$<K.length;$++){let j=K[$];if(Q){if(j==="\\"){$++;continue}if(j===Q)Q="";continue}if(j==='"'||j==="'"||j==="`"){Q=j;continue}if(j==="("||j==="["||j==="{"){J++;continue}if(j===")"||j==="]"||j==="}"){J--;continue}if(j==="|"&&J===0){if(K[$+1]==="|"){$++;continue}if(K[$-1]==="|")continue;return K.slice(0,$)}}return K}var R=new Set([":for","x-for","v-for"]),w=/(?:^|\s)((?::|x-|v-|@)[\w.:-]+)\s*=\s*(["'])([\s\S]*?)\2/g,O="__stx_interpolated",y="__StxElement",f="__StxTemplateValue",l=`type ${f}<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? (T extends () => infer V ? T & V : T) : T`;function L(K){return K.replace(/\{\{[\s\S]*?\}\}/g,O).replace(/\{!![\s\S]*?!!\}/g,O)}function Vj(K){return K.replace(/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/g,(J)=>{let Q=J.split(`
|
|
5
5
|
`).length-1,$=J.length-Q;return`0${" ".repeat(Math.max(0,$-1))}${`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{jv as Ae,kv as u}from"./chunk-vqq5zjbg.js";function _(e){return e.split(/[\\/]/).filter(Boolean).slice(0,-1).some((a)=>g.includes(a))}function m(e){return _(e.replace(/^\//,""))}var g;var b=u(()=>{g=["components","layouts","partials","emails"]});import h from"fs";import y from"path";function x(e,t){let a=e.filter((o)=>!m(o.pattern)),r=["// Auto-generated by STX - do not edit"];if(a.length===0)r.push("// No page routes found \u2014 route paths stay typed as string.","export {}","");else{r.push("declare module '@stacksjs/stx' {"," interface KnownRoutes {");for(let o of a){let i=[];for(let l of o.params){let f=o.pattern.includes(`:${l}?`)?"?":"";i.push(`${l}${f}: string`)}let c=i.join("; ");r.push(` '${o.pattern}': { ${c} }`)}r.push(" }","}","","export {}","")}let n=r.join(`
|
|
3
3
|
`),s=y.join(t,"route-types.d.ts");try{if(h.existsSync(s)&&h.readFileSync(s,"utf8")===n)return;h.mkdirSync(t,{recursive:!0}),h.writeFileSync(s,n)}catch{}}function S(e,t,a){let r=process.cwd(),n=y.relative(r,a),s=e.filter((i)=>!m(i.pattern)),o=["// Auto-generated by stx \u2014 do not edit",`// Source: ${n||"pages"}/`,"","export const routes = ["];for(let i of s){let c=y.relative(r,i.filePath).replace(/\\/g,"/"),l=JSON.stringify(i.params),f=i.layout?`, layout: '${y.relative(r,i.layout).replace(/\\/g,"/")}'`:"";o.push(` { pattern: '${i.pattern}', filePath: '${c}', isDynamic: ${i.isDynamic}, params: ${l}${f} },`)}o.push("] as const",""),o.push("export type RouteName = typeof routes[number]['pattern']",""),h.mkdirSync(t,{recursive:!0}),h.writeFileSync(y.join(t,"routes.ts"),o.join(`
|
|
4
|
-
`))}var F=u(()=>{b()});import V from"path";function k(e,t){let r=V.relative(t,e).replace(/\.(stx|md)$/,"");if(r=r.split(V.sep).join("/"),r==="index")return"/";if(r.endsWith("/index"))r=r.slice(0,-6);return r=r.replace(/\[\[([^\]]+)\]\]/g,":$1?"),r=r.replace(/\[([^\]]+)\]/g,":$1"),r=r.replace(/:\.\.\.([^/]+)/g,":$1*"),`/${r}`}function v(e){let t=[],a="",r=0;while(r<e.length){let n=e.slice(r),s=/^\/:([^/?*]+)\?/.exec(n);if(s){t.push(s[1]),a+="(?:/([^/]+))?",r+=s[0].length;continue}let o=/^:([^/?*]+)\*/.exec(n);if(o){t.push(o[1]),a+="(.+)",r+=o[0].length;continue}let i=/^:([^/?*]+)/.exec(n);if(i){t.push(i[1]),a+="([^/]+)",r+=i[0].length;continue}a+=e[r].replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),r+=1}return{regex:new RegExp(`^${a}$`),params:t}}function D(e,t){let a=e===""?"/":e;for(let r of t){let n=a.match(r.regex);if(n){let s={};return r.params.forEach((o,i)=>{s[o]=n[i+1]}),{route:r,params:s}}}return null}function W(e){let t=e.replace(/\[\[([^\]]+)\]\]/g,":$1?").replace(/\[([^\]]+)\]/g,":$1").replace(/:\.\.\.([^/]+)/g,":$1*");return v(t)}var I=()=>{};import xe from"fs";import M from"path";function A(e,t){let a=[],r=M.dirname(e);while(r.startsWith(t)||r===t){let n=M.join(r,"_layout.stx");if(xe.existsSync(n))a.unshift(n);if(r===t)break;r=M.dirname(r)}return a}var N=()=>{};import P from"fs";import d from"path";function K(e,t){let a=[];if(!P.existsSync(e))return a;let r=P.readdirSync(e,{withFileTypes:!0});for(let n of r){let s=d.join(e,n.name);if(n.isDirectory()){if(n.name.startsWith("."))continue;if(g.includes(n.name))continue;a.push(...K(s,t))}else if(n.isFile()){let o=d.extname(n.name);if(t.includes(o)){if(n.name.startsWith("_")&&n.name!=="_layout.stx")continue;if(n.name==="_layout.stx")continue;a.push(s)}}}return a}class C{routes;pagesDir;pagesDirs;config;constructor(e,t={}){this.config=t;let a=t.pagesDirs&&t.pagesDirs.length>0?t.pagesDirs:[t.pagesDir||"pages"];this.pagesDirs=a.map((o)=>d.resolve(e,o)),this.pagesDir=this.pagesDirs[0];let r=t.extensions||[".stx"],n=new Set;this.routes=[];for(let o of this.pagesDirs){let i=K(o,r);for(let c of i){let l=k(c,o);if(n.has(l))continue;n.add(l);let{regex:f,params:H}=v(l),O=t.layouts!==!1?A(c,o):[];this.routes.push({pattern:l,regex:f,params:H,filePath:c,isDynamic:H.length>0,layout:O.length>0?O[O.length-1]:void 0})}}this.routes.sort((o,i)=>{if(!o.isDynamic&&i.isDynamic)return-1;if(o.isDynamic&&!i.isDynamic)return 1;let c=o.pattern.split("/").length,l=i.pattern.split("/").length;if(c!==l)return l-c;return o.pattern.localeCompare(i.pattern)});let s=d.resolve(e,t.stateDir||process.env.STX_DIR?.trim()||".stx");x(this.routes,s),S(this.routes,s,this.pagesDir)}match(e){let t=e===""?"/":e;for(let a of this.routes){let r=t.match(a.regex);if(r){let n={};return a.params.forEach((s,o)=>{n[s]=r[o+1]}),{route:a,params:n}}}return null}resolve(e,t){let a=this.routes.find((n)=>n.pattern===e||n.filePath.includes(e));if(!a)return"#not-found";let r=a.pattern;if(t)for(let[n,s]of Object.entries(t))r=r.replace(`:${n}`,encodeURIComponent(s));return r}addRoute(e){this.routes.push(e),this.routes.sort((t,a)=>{if(!t.isDynamic&&a.isDynamic)return-1;if(t.isDynamic&&!a.isDynamic)return 1;return t.pattern.localeCompare(a.pattern)})}getLayout(e){return e.layout??null}}function z(e,t){return new C(e,t)}function $(e,t){let a=[`${t}.stx`,"error.stx"];for(let r of a){let n=d.join(e,r);if(P.existsSync(n))return n}return null}function Y(e,t){return e.map((a)=>{let r=d.relative(t,a.filePath),n=a.isDynamic?" (dynamic)":"";return`${a.pattern} \u2192 ${r}${n}`})}var J=u(()=>{F();I();N();b()});function Z(e){
|
|
4
|
+
`))}var F=u(()=>{b()});import V from"path";function k(e,t){let r=V.relative(t,e).replace(/\.(stx|md)$/,"");if(r=r.split(V.sep).join("/"),r==="index")return"/";if(r.endsWith("/index"))r=r.slice(0,-6);return r=r.replace(/\[\[([^\]]+)\]\]/g,":$1?"),r=r.replace(/\[([^\]]+)\]/g,":$1"),r=r.replace(/:\.\.\.([^/]+)/g,":$1*"),`/${r}`}function v(e){let t=[],a="",r=0;while(r<e.length){let n=e.slice(r),s=/^\/:([^/?*]+)\?/.exec(n);if(s){t.push(s[1]),a+="(?:/([^/]+))?",r+=s[0].length;continue}let o=/^:([^/?*]+)\*/.exec(n);if(o){t.push(o[1]),a+="(.+)",r+=o[0].length;continue}let i=/^:([^/?*]+)/.exec(n);if(i){t.push(i[1]),a+="([^/]+)",r+=i[0].length;continue}a+=e[r].replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),r+=1}return{regex:new RegExp(`^${a}$`),params:t}}function D(e,t){let a=e===""?"/":e;for(let r of t){let n=a.match(r.regex);if(n){let s={};return r.params.forEach((o,i)=>{s[o]=n[i+1]}),{route:r,params:s}}}return null}function W(e){let t=e.replace(/\[\[([^\]]+)\]\]/g,":$1?").replace(/\[([^\]]+)\]/g,":$1").replace(/:\.\.\.([^/]+)/g,":$1*");return v(t)}var I=()=>{};import xe from"fs";import M from"path";function A(e,t){let a=[],r=M.dirname(e);while(r.startsWith(t)||r===t){let n=M.join(r,"_layout.stx");if(xe.existsSync(n))a.unshift(n);if(r===t)break;r=M.dirname(r)}return a}var N=()=>{};import P from"fs";import d from"path";function K(e,t){let a=[];if(!P.existsSync(e))return a;let r=P.readdirSync(e,{withFileTypes:!0});for(let n of r){let s=d.join(e,n.name);if(n.isDirectory()){if(n.name.startsWith("."))continue;if(g.includes(n.name))continue;a.push(...K(s,t))}else if(n.isFile()){let o=d.extname(n.name);if(t.includes(o)){if(n.name.startsWith("_")&&n.name!=="_layout.stx")continue;if(n.name==="_layout.stx")continue;a.push(s)}}}return a}class C{routes;pagesDir;pagesDirs;config;constructor(e,t={}){this.config=t;let a=t.pagesDirs&&t.pagesDirs.length>0?t.pagesDirs:[t.pagesDir||"pages"];this.pagesDirs=a.map((o)=>d.resolve(e,o)),this.pagesDir=this.pagesDirs[0];let r=t.extensions||[".stx"],n=new Set;this.routes=[];for(let o of this.pagesDirs){let i=K(o,r);for(let c of i){let l=k(c,o);if(n.has(l))continue;n.add(l);let{regex:f,params:H}=v(l),O=t.layouts!==!1?A(c,o):[];this.routes.push({pattern:l,regex:f,params:H,filePath:c,isDynamic:H.length>0,layout:O.length>0?O[O.length-1]:void 0})}}this.routes.sort((o,i)=>{if(!o.isDynamic&&i.isDynamic)return-1;if(o.isDynamic&&!i.isDynamic)return 1;let c=o.pattern.split("/").length,l=i.pattern.split("/").length;if(c!==l)return l-c;return o.pattern.localeCompare(i.pattern)});let s=d.resolve(e,t.stateDir||process.env.STX_DIR?.trim()||".stx");x(this.routes,s),S(this.routes,s,this.pagesDir)}match(e){let t=e===""?"/":e;for(let a of this.routes){let r=t.match(a.regex);if(r){let n={};return a.params.forEach((s,o)=>{n[s]=r[o+1]}),{route:a,params:n}}}return null}resolve(e,t){let a=this.routes.find((n)=>n.pattern===e||n.filePath.includes(e));if(!a)return"#not-found";let r=a.pattern;if(t)for(let[n,s]of Object.entries(t))r=r.replace(`:${n}`,encodeURIComponent(s));return r}addRoute(e){this.routes.push(e),this.routes.sort((t,a)=>{if(!t.isDynamic&&a.isDynamic)return-1;if(t.isDynamic&&!a.isDynamic)return 1;return t.pattern.localeCompare(a.pattern)})}getLayout(e){return e.layout??null}}function z(e,t){return new C(e,t)}function $(e,t){let a=[`${t}.stx`,"error.stx"];for(let r of a){let n=d.join(e,r);if(P.existsSync(n))return n}return null}function Y(e,t){return e.map((a)=>{let r=d.relative(t,a.filePath),n=a.isDynamic?" (dynamic)":"";return`${a.pattern} \u2192 ${r}${n}`})}var J=u(()=>{F();I();N();b()});function Z(e){T=e.replace(/\/$/,"")}function Q(e,t,a={}){p[e]={path:t,name:e,params:a}}function ee(e){for(let[t,a]of Object.entries(e))if(typeof a==="string")p[t]={path:a,name:t};else p[t]={...a,name:t}}function te(e,t={},a=!1){let r=p[e];if(!r)return console.warn(`Route [${e}] not defined.`),"#undefined-route";let n={...r.params,...t},s=r.path;s=s.replace(/:(\w+)/g,(i,c)=>{let l=n[c];if(l===void 0)return console.warn(`Missing parameter [${c}] for route [${e}].`),`:${c}`;return delete n[c],encodeURIComponent(String(l))});let o=Object.entries(n);if(o.length>0){let i=o.map(([c,l])=>`${encodeURIComponent(c)}=${encodeURIComponent(String(l))}`).join("&");s+=(s.includes("?")?"&":"?")+i}return a&&T?`${T}${s}`:s}function re(){for(let e of Object.keys(p))delete p[e];T=""}var p,T="";var ae=u(()=>{p={}});import ne from"fs";import oe from"path";function se(e,t={}){return{type:"redirect",path:e,options:{replace:t.replace??!1,external:t.external??!1,redirectCode:t.redirectCode??302}}}function ie(e){return{type:"abort",error:typeof e==="string"?{statusCode:500,message:e}:e}}function ce(e,t={}){return{handler:e,mode:t.mode??"universal"}}function B(e){let t={};if(!e)return t;let a=e.split(";");for(let r of a){let[n,...s]=r.split("=");if(n){let o=n.trim(),i=s.join("=").trim();if(o)t[o]=decodeURIComponent(i)}}return t}function E(e,t,a={}){let r=`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(a.expires){let n=typeof a.expires==="number"?new Date(Date.now()+a.expires*1000):a.expires;r+=`; Expires=${n.toUTCString()}`}if(a.path)r+=`; Path=${a.path}`;if(a.domain)r+=`; Domain=${a.domain}`;if(a.secure)r+="; Secure";if(a.httpOnly)r+="; HttpOnly";if(a.sameSite)r+=`; SameSite=${a.sameSite}`;return r}function U(e,t){let a=e.headers.get("cookie")||"",r=B(a);return{get(n){return r[n]},set(n,s,o={}){r[n]=s,t.append("Set-Cookie",E(n,s,o))},delete(n){delete r[n],t.append("Set-Cookie",E(n,"",{expires:new Date(0),path:"/"}))},getAll(){return{...r}}}}function G(){return{get(e){if(typeof document>"u")return;return B(document.cookie)[e]},set(e,t,a={}){if(typeof document>"u")return;document.cookie=E(e,t,a)},delete(e){if(typeof document>"u")return;document.cookie=E(e,"",{expires:new Date(0),path:"/"})},getAll(){if(typeof document>"u")return{};return B(document.cookie)}}}function X(){let e=typeof window<"u"&&typeof window.localStorage<"u";return{get(t){if(!e)return null;try{return window.localStorage.getItem(t)}catch{return null}},set(t,a){if(!e)return;try{window.localStorage.setItem(t,a)}catch{}},remove(t){if(!e)return;try{window.localStorage.removeItem(t)}catch{}},isAvailable(){return e}}}function R(e,t){w.set(e,t)}function j(e){return w.get(e)}function le(e){return w.has(e)}function ue(){w.clear()}function he(){return Array.from(w.keys())}async function de(e,t="middleware"){let a=oe.resolve(e,t);if(!ne.existsSync(a))return;let r=ne.readdirSync(a);for(let n of r){if(!n.endsWith(".ts")&&!n.endsWith(".js"))continue;if(n.includes(".test.")||n.includes(".spec."))continue;let s=n.replace(/\.(ts|js)$/,""),o=oe.join(a,n);try{let c=(await import(o)).default;if(c&&typeof c.handler==="function")R(s,c);else if(typeof c==="function")R(s,{handler:c,mode:"universal"})}catch(i){console.warn(`Failed to load middleware '${s}' from ${o}:`,i)}}}function Se(e){let t={};if(!e)return t;let a=new URLSearchParams(e);for(let[r,n]of a)t[r]=n;return t}function pe(e,t,a,r=""){return{path:e,params:t,query:Se(r),fullPath:r?`${e}?${r}`:e,meta:a}}function fe(e,t,a,r){let n=r?.isServer??typeof window>"u",s=!n,o=new Headers;return{to:e,from:t,isClient:s,isServer:n,cookies:n&&a?U(a,o):G(),storage:X(),state:{},request:a,responseHeaders:o}}async function ge(e,t){let a=Array.isArray(e)?e:[e],r=t.isServer;for(let n of a){let s=j(n);if(!s)return console.error(`Route middleware '${n}' is not registered \u2014 failing the guard closed.`),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:`Route middleware '${n}' is not registered`}},state:t.state,responseHeaders:t.responseHeaders};if(s.mode==="server"&&!r)continue;try{let o=await s.handler(t);if(o){if(o.type==="redirect")return{passed:!1,redirect:o,state:t.state,responseHeaders:t.responseHeaders};if(o.type==="abort")return{passed:!1,abort:o,state:t.state,responseHeaders:t.responseHeaders}}}catch(o){return console.error(`Error in middleware '${n}':`,o),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:o instanceof Error?o.message:"Middleware error"}},state:t.state,responseHeaders:t.responseHeaders}}}return{passed:!0,state:t.state,responseHeaders:t.responseHeaders}}var w;var me=u(()=>{w=new Map});function q(e){let a=e.replace(/\\/g,"/").split("/").filter(Boolean),r=a.lastIndexOf("layouts"),n=r>=0?a[r+1]:a.at(-1);if(!n)return"app";return n.replace(/\.stx$/i,"")||"app"}function ye(e){let t=e.match(/<meta\b[^>]*name=["']stx-layout["'][^>]*content=["']([^"']+)["'][^>]*>/i),a=e.match(/<meta\b[^>]*name=["']stx-layout-group["'][^>]*content=["']([^"']+)["'][^>]*>/i),r=e.match(/<!--\s*stx-layout:\s*([^ ]+)\s*-->/i),n=t?.[1]||r?.[1]||"";return{layout:n,group:a?.[1]||q(n)}}var ve=()=>{};function ke(e){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(e).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return e}}function we(){if(L)return L;return L=ke(`
|
|
5
5
|
;(function(){
|
|
6
6
|
'use strict';
|
|
7
7
|
var ROUTER_REV=7;
|
|
@@ -1182,6 +1182,13 @@ else {
|
|
|
1182
1182
|
log('[router] full body swap for layout change');
|
|
1183
1183
|
// Replace entire body content \u2014 layout chrome and all
|
|
1184
1184
|
var bodyHTML=newBody.innerHTML;
|
|
1185
|
+
// The outgoing chrome's components are destroyed with it (#1958).
|
|
1186
|
+
// They are no longer re-run on every navigation, so they live as long
|
|
1187
|
+
// as their layout does, and _cleanupContainer above only covered the
|
|
1188
|
+
// container: their onDestroy and their scopes waited for the next
|
|
1189
|
+
// navigation's orphan sweep, and their effects were never disposed.
|
|
1190
|
+
// Before the swap, while the old markup is still here to walk.
|
|
1191
|
+
if(window.stx&&window.stx._cleanupContainer)window.stx._cleanupContainer(document.body);
|
|
1185
1192
|
document.body.innerHTML=bodyHTML;
|
|
1186
1193
|
// Copy body attributes (class, data-stx, etc.)
|
|
1187
1194
|
Array.from(newBody.attributes).forEach(function(attr){document.body.setAttribute(attr.name,attr.value)});
|
|
@@ -1267,6 +1274,18 @@ else {
|
|
|
1267
1274
|
if(isSignalsRuntimeScript(s,text))return;
|
|
1268
1275
|
if(text.indexOf('__stxRouter')!==-1)return;
|
|
1269
1276
|
if(newContent.contains(s))return;
|
|
1277
|
+
// Code only, as prepareRoutedBodyScripts takes it. A layout island's
|
|
1278
|
+
// type="stx/island" script is hydrated by its own trigger, and one
|
|
1279
|
+
// collected here was set up on every navigation, the trigger or not.
|
|
1280
|
+
var scriptType=(s.getAttribute('type')||'').trim().toLowerCase();
|
|
1281
|
+
if(scriptType&&scriptType!=='text/javascript'&&scriptType!=='application/javascript'&&scriptType!=='module')return;
|
|
1282
|
+
// A component with no scope root has no root for the owner check,
|
|
1283
|
+
// so its script is marked data-stx-instance instead. Out here it
|
|
1284
|
+
// belongs to the layout chrome, which this swap leaves in place with
|
|
1285
|
+
// its instance running; running it again set up a second one, and a
|
|
1286
|
+
// stx.mount wrapper re-run from here mounted onto the container, the
|
|
1287
|
+
// incoming page's content (#1958). Fragments leave these out.
|
|
1288
|
+
if(s.hasAttribute('data-stx-instance'))return;
|
|
1270
1289
|
if(text.indexOf('__stx_setup_')===-1&&!s.hasAttribute('data-stx-scoped')&&!s.hasAttribute('data-stx-page')&&!s.hasAttribute('data-stx-route-params'))return;
|
|
1271
1290
|
var key=text.substring(0,80);
|
|
1272
1291
|
if(seenSetups[key])return;
|
|
@@ -1835,5 +1854,5 @@ else {
|
|
|
1835
1854
|
|
|
1836
1855
|
if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',init);else init();
|
|
1837
1856
|
})();
|
|
1838
|
-
`),L}var L;var be=()=>{};var Ce={};Ae(Ce,{setAppUrl:()=>Z,runMiddleware:()=>ge,route:()=>te,resolveLayoutChain:()=>A,resetRoutes:()=>re,registerMiddleware:()=>R,patternToRegex:()=>v,navigateTo:()=>se,matchRoute:()=>D,loadMiddlewareFromDirectory:()=>de,isNonPageRoutePattern:()=>m,isNonPageRoutePath:()=>_,hasMiddleware:()=>le,getRouterScript:()=>we,getMiddlewareNames:()=>he,getMiddleware:()=>j,generateRouteTypes:()=>x,generateRouteManifest:()=>S,formatRoutes:()=>Y,findErrorPage:()=>$,filePathToPattern:()=>k,extractLayoutMetadata:()=>ye,deriveLayoutGroup:()=>q,defineRoutes:()=>ee,defineRoute:()=>Q,defineMiddleware:()=>ce,createStorageManager:()=>X,createServerCookieManager:()=>U,createRouter:()=>z,createRouteLocation:()=>pe,createMiddlewareContext:()=>fe,createClientCookieManager:()=>G,clearMiddleware:()=>ue,bracketPathToRegex:()=>W,abortNavigation:()=>ie,Router:()=>C,NON_PAGE_DIRS:()=>g});var
|
|
1839
|
-
export{g as
|
|
1857
|
+
`),L}var L;var be=()=>{};var Ce={};Ae(Ce,{setAppUrl:()=>Z,runMiddleware:()=>ge,route:()=>te,resolveLayoutChain:()=>A,resetRoutes:()=>re,registerMiddleware:()=>R,patternToRegex:()=>v,navigateTo:()=>se,matchRoute:()=>D,loadMiddlewareFromDirectory:()=>de,isNonPageRoutePattern:()=>m,isNonPageRoutePath:()=>_,hasMiddleware:()=>le,getRouterScript:()=>we,getMiddlewareNames:()=>he,getMiddleware:()=>j,generateRouteTypes:()=>x,generateRouteManifest:()=>S,formatRoutes:()=>Y,findErrorPage:()=>$,filePathToPattern:()=>k,extractLayoutMetadata:()=>ye,deriveLayoutGroup:()=>q,defineRoutes:()=>ee,defineRoute:()=>Q,defineMiddleware:()=>ce,createStorageManager:()=>X,createServerCookieManager:()=>U,createRouter:()=>z,createRouteLocation:()=>pe,createMiddlewareContext:()=>fe,createClientCookieManager:()=>G,clearMiddleware:()=>ue,bracketPathToRegex:()=>W,abortNavigation:()=>ie,Router:()=>C,NON_PAGE_DIRS:()=>g});var Te=u(()=>{J();I();ae();me();N();ve();F();b();be()});
|
|
1858
|
+
export{g as qu,_ as ru,m as su,x as tu,S as uu,k as vu,v as wu,D as xu,W as yu,A as zu,C as Au,z as Bu,$ as Cu,Y as Du,Z as Eu,Q as Fu,ee as Gu,te as Hu,re as Iu,se as Ju,ie as Ku,ce as Lu,U as Mu,G as Nu,X as Ou,R as Pu,j as Qu,le as Ru,ue as Su,he as Tu,de as Uu,pe as Vu,fe as Wu,ge as Xu,q as Yu,ye as Zu,ve as _u,we as $u,Ce as av,Te as bv};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{lv as l}from"./chunk-vqq5zjbg.js";import U from"fs";import G from"path";import I from"os";import H from"crypto";import{generatePlaceholder as m,processImage as g}from"ts-images";var d=[320,640,768,1024,1280,1536,1920],h=["webp","jpeg"],b=80,u=[".jpg",".jpeg",".png",".webp",".avif",".gif",".svg"],P={webp:"image/webp",avif:"image/avif",jpeg:"image/jpeg",png:"image/png"},N=null,W=!1;async function Y(){if(W)return N;W=!0;try{let J=await import("sharp");return N=J.default||J,N}catch{return null}}async function e(){return await Y()!==null}async function t(){return!0}async function JJ(J,K={}){let{widths:Z=d,formats:$=h,quality:q=b,fit:C="cover",placeholder:X="none",outputDir:Q=".stx/images",baseUrl:_="/images"}=K,j,x;if(typeof J==="string"){if(x=J,!await Bun.file(J).exists())throw new L(`Image not found: ${J}`,"NOT_FOUND");j=await Bun.file(J).arrayBuffer().then((V)=>Buffer.from(V))}else x="buffer-input",j=J;let w=H.createHash("sha256").update(j).digest("hex").slice(0,12),y=await O(j),{width:B,height:D}=y,A=B/D;await U.promises.mkdir(Q,{recursive:!0});let T=[],v=G.basename(x,G.extname(x)),z=Z.filter((V)=>V<=B);if(!z.includes(B)&&B<=Math.max(...Z))z.push(B);z.sort((V,R)=>V-R);for(let V of z){let R=Math.round(V/A);for(let F of $){let S=`${v}-${V}w-${w}.${F}`,k=G.join(Q,S),c=`${_}/${S}`,E=await n(j,{width:V,height:R,format:F,quality:q,fit:C});await Bun.write(k,E),T.push({path:k,url:c,width:V,height:R,format:F,size:E.length})}}let M;if(X!=="none")M=await o(j,X);return{src:x,variants:T,placeholder:M,width:B,height:D,aspectRatio:A,hash:w}}async function O(J){let K=typeof J==="string"?Buffer.from(await Bun.file(J).arrayBuffer()):J,Z=await Y();if(Z){let q=await Z(K).metadata();return{width:q.width||0,height:q.height||0,format:q.format||"unknown",hasAlpha:q.hasAlpha}}return p(K)}function p(J){if(J[0]===137&&J[1]===80&&J[2]===78&&J[3]===71){let K=J.readUInt32BE(16),Z=J.readUInt32BE(20);return{width:K,height:Z,format:"png",hasAlpha:!0}}if(J[0]===255&&J[1]===216){let K=2;while(K<J.length){if(J[K]!==255)break;let Z=J[K+1];if(Z>=192&&Z<=207&&Z!==196&&Z!==200&&Z!==204){let q=J.readUInt16BE(K+5);return{width:J.readUInt16BE(K+7),height:q,format:"jpeg",hasAlpha:!1}}let $=J.readUInt16BE(K+2);K+=2+$}}if(J.toString("utf8",0,4)==="RIFF"&&J.toString("utf8",8,12)==="WEBP"){let K=J.toString("utf8",12,16);if(K==="VP8 "){let Z=J.readUInt16LE(26)&16383,$=J.readUInt16LE(28)&16383;return{width:Z,height:$,format:"webp",hasAlpha:!1}}if(K==="VP8L"){let Z=J.readUInt32LE(21),$=(Z&16383)+1,q=(Z>>14&16383)+1;return{width:$,height:q,format:"webp",hasAlpha:!0}}}if(J.toString("utf8",0,3)==="GIF"){let K=J.readUInt16LE(6),Z=J.readUInt16LE(8);return{width:K,height:Z,format:"gif",hasAlpha:!0}}throw new L("Unable to parse image dimensions","PARSE_ERROR")}async function n(J,K){let Z=await Y();if(Z){let q=Z(J).resize(K.width,K.height,{fit:K.fit});switch(K.format){case"webp":q=q.webp({quality:K.quality});break;case"avif":q=q.avif({quality:K.quality});break;case"jpeg":q=q.jpeg({quality:K.quality});break;case"png":q=q.png({quality:K.quality});break}return q.toBuffer()}let $=G.join(I.tmpdir(),`stx-img-${H.randomBytes(8).toString("hex")}.${K.format}`);try{return await g({input:J,output:$,format:K.format,quality:K.quality,resize:{width:K.width,height:K.height,fit:K.fit}}),Buffer.from(await Bun.file($).arrayBuffer())}finally{await U.promises.unlink($).catch(()=>{})}}async function o(J,K){let Z=await Y();if(K==="blur"&&Z){let X=(await Z(J).resize(20).blur(10).toBuffer()).toString("base64"),Q=await O(J);return`data:${P[Q.format]||"image/jpeg"};base64,${X}`}if(K==="dominant-color"&&Z){let{dominant:C}=await Z(J).resize(1,1).toBuffer().then(async(X)=>{let Q=await Z(X).metadata();return{dominant:{r:128,g:128,b:128}}}).catch(()=>({dominant:{r:128,g:128,b:128}}));return`rgb(${C.r}, ${C.g}, ${C.b})`}let $=await O(J),q=G.join(I.tmpdir(),`stx-ph-${H.randomBytes(8).toString("hex")}.${$.format==="unknown"?"bin":$.format}`);try{await Bun.write(q,J);let C=K==="blur"?"blur":K==="thumbhash"?"thumbhash":"dominant-color",Q=await m(q,{strategy:C,width:C==="thumbhash"?void 0:32});if(K==="dominant-color"&&Q.dominantColor)return Q.dominantColor;if(Q.dataURL)return Q.dataURL;return"rgb(128, 128, 128)"}catch{return"rgb(128, 128, 128)"}finally{await U.promises.unlink(q).catch(()=>{})}}function KJ(J,K){return(K?J.filter(($)=>$.format===K):J).sort(($,q)=>$.width-q.width).map(($)=>`${$.url} ${$.width}w`).join(", ")}function ZJ(J){if(!J||Object.keys(J).length===0)return"100vw";return Object.entries(J).sort((Z,$)=>{let q=Number.parseInt(Z[0].replace(/\D/g,""))||0;return(Number.parseInt($[0].replace(/\D/g,""))||0)-q}).map(([Z,$])=>`(max-width: ${Z}) ${$}`).join(", ")+", 100vw"}function $J(J){let K=J.filter(($)=>$.format==="jpeg");if(K.length===0)return J[Math.floor(J.length/2)];let Z=K.sort(($,q)=>$.width-q.width);return Z[Math.floor(Z.length/2)]}function qJ(J){let K=new Map;for(let Z of J){let $=K.get(Z.format)||[];$.push(Z),K.set(Z.format,$)}return K}function CJ(J){let K=G.extname(J).toLowerCase();return u.includes(K)}function QJ(J){return P[J]||"application/octet-stream"}function VJ(J){return J.reduce((K,Z)=>K+Z.size,0)}function XJ(J){if(J<1024)return`${J} B`;if(J<1048576)return`${(J/1024).toFixed(1)} KB`;return`${(J/1048576).toFixed(2)} MB`}class L extends Error{code;constructor(J,K){super(J);this.name="ImageProcessingError",this.code=K}}
|
|
3
3
|
export{d as Eh,h as Fh,b as Gh,e as Hh,t as Ih,JJ as Jh,O as Kh,n as Lh,KJ as Mh,ZJ as Nh,$J as Oh,qJ as Ph,CJ as Qh,QJ as Rh,VJ as Sh,XJ as Th,L as Uh};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Au as
|
|
2
|
+
import{$u as K,Au as k,Bu as l,Cu as m,Du as n,Eu as o,Fu as p,Gu as q,Hu as r,Iu as s,Ju as t,Ku as u,Lu as v,Mu as w,Nu as x,Ou as y,Pu as z,Qu as A,Ru as B,Su as C,Tu as D,Uu as E,Vu as F,Wu as G,Xu as H,Yu as I,Zu as J,bv as L,qu as a,ru as b,su as c,tu as d,uu as e,vu as f,wu as g,xu as h,yu as i,zu as j}from"./chunk-8ybhs27t.js";import"./chunk-vqq5zjbg.js";L();export{o as setAppUrl,H as runMiddleware,r as route,j as resolveLayoutChain,s as resetRoutes,z as registerMiddleware,g as patternToRegex,t as navigateTo,h as matchRoute,E as loadMiddlewareFromDirectory,c as isNonPageRoutePattern,b as isNonPageRoutePath,B as hasMiddleware,K as getRouterScript,D as getMiddlewareNames,A as getMiddleware,d as generateRouteTypes,e as generateRouteManifest,n as formatRoutes,m as findErrorPage,f as filePathToPattern,J as extractLayoutMetadata,I as deriveLayoutGroup,q as defineRoutes,p as defineRoute,v as defineMiddleware,y as createStorageManager,w as createServerCookieManager,l as createRouter,F as createRouteLocation,G as createMiddlewareContext,x as createClientCookieManager,C as clearMiddleware,i as bracketPathToRegex,u as abortNavigation,k as Router,a as NON_PAGE_DIRS};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{$p as T,Xp as D}from"./chunk-k049j105.js";import{ht as N}from"./chunk-w43x27h2.js";import{lv as L}from"./chunk-vqq5zjbg.js";import Q from"fs";import Y from"path";var b=new Map,V=new Map;async function v(j){let z;for(let K=0;K<3;K++)try{let W=(await Q.promises.stat(j)).mtime.getTime(),J=V.get(j);if(J&&J.mtime===W)return J.content;let X=await Bun.file(j).text(),U=(await Q.promises.stat(j)).mtime.getTime();if(U!==W)continue;return V.set(j,{content:X,mtime:U}),X}catch(I){z=I;break}throw V.delete(j),Error(`File not found: ${j}${z?` (${z.message})`:""}`)}function E(j){V.delete(j)}function F(j){for(let B of V.keys())if(B.startsWith(j))V.delete(B)}var $=null,G=null,k=null;function R(j){k=j}async function S(j=!1){let B=k??await import("./chunk-vvkh24d4.js");if(j)return B.generateSignalsRuntimeDev();if($===null)$=B.generateSignalsRuntime();return $}var q=null;async function _(){if(q===null){let{getRouterScript:j}=await import("./chunk-9vnh50p1.js");q=j()}return q}function g(){V.clear(),T(),N(),$=null,G=null,q=null}function y(j){let B={debug:j.debug===!0,middleware:(j.middleware??[]).map((z)=>({name:z.name,timing:z.timing,handler:String(z.handler)})),customDirectives:(j.customDirectives??[]).map((z)=>({name:z.name,hasEndTag:z.hasEndTag===!0,handler:String(z.handler)}))};return new Bun.CryptoHasher("sha1").update(JSON.stringify(B)).digest("hex")}async function C(j,B){try{if(!B.cachePath)return null;let z=Y.resolve(B.cachePath),K=Y.join(z,`${M(j)}.html`),I=Y.join(z,`${M(j)}.meta.json`);if(!await D(K)||!await D(I))return null;let W=await Bun.file(I).text(),J=JSON.parse(W);if(J.cacheVersion!==B.cacheVersion)return null;if(J.optionsSignature!==y(B))return null;if((await Q.promises.stat(j)).mtime.getTime()>J.mtime)return null;for(let Z of J.dependencies)if(await D(Z)){if((await Q.promises.stat(Z)).mtime.getTime()>J.mtime)return null}else return null;return await Bun.file(K).text()}catch(z){return console.warn(`Cache error for ${j}:`,z),null}}async function u(j,B,z,K){try{if(!K.cachePath)return;let I=Y.resolve(K.cachePath);await Q.promises.mkdir(I,{recursive:!0});let W=Y.join(I,`${M(j)}.html`),J=Y.join(I,`${M(j)}.meta.json`),X=await Q.promises.stat(j);await Bun.write(W,B);let Z={sourcePath:j,mtime:X.mtime.getTime(),dependencies:Array.from(z),cacheVersion:K.cacheVersion,optionsSignature:y(K),generatedAt:Date.now()};await Bun.write(J,JSON.stringify(Z,null,2)),b.set(j,{output:B,mtime:X.mtime.getTime(),dependencies:z})}catch(I){console.warn(`Failed to cache template ${j}:`,I)}}var O=16;function M(j){return new Bun.CryptoHasher("sha1").update(j).digest("hex").substring(0,O)}
|
|
3
3
|
export{b as Oj,v as Pj,E as Qj,F as Rj,R as Sj,S as Tj,_ as Uj,g as Vj,C as Wj,u as Xj,M as Yj};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ii as a,ji as b,ki as c,li as d,mi as e,ni as f,oi as g,pi as h}from"./chunk-nmkra8q5.js";import"./chunk-fed3xsp9.js";import"./chunk-
|
|
2
|
+
import{ii as a,ji as b,ki as c,li as d,mi as e,ni as f,oi as g,pi as h}from"./chunk-nmkra8q5.js";import"./chunk-fed3xsp9.js";import"./chunk-vqq5zjbg.js";export{d as v,a as useForm,g as processHasErrorsDirective,h as processFormValidationDirectives,f as processErrorsDirective,e as processErrorDirective,b as defineForm,c as Validator};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{createHash as U}from"crypto";import Z from"fs";import Q from"path";import{generateThumbHash as w}from"ts-images";import{createImageDeliveryCatalog as T}from"ts-images/delivery";var L=new Set([".avif",".jpeg",".jpg",".png",".webp"]),F=[320,640,960,1280,1920],O="/_stx/images",Y=new Map;function R(j){return`/${j.split(Q.sep).map(encodeURIComponent).join("/")}`}function E(j){let q=Q.extname(j),G=j.slice(0,-q.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),J=U("sha256").update(j).digest("hex").slice(0,8);return`${G||"image"}-${J}`}function C(j){let q=(G)=>`${O}/${G.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:`stx:${O}`,async stat(G){let J=Q.join(j,G);try{let B=await Z.promises.stat(J);return B.size>0?{bytes:B.size,path:J,url:q(G)}:null}catch{return null}},async write(G,J){let B=Q.join(j,G);await Z.promises.mkdir(Q.dirname(B),{recursive:!0});let K=`${B}.${process.pid}.tmp`;return await Z.promises.writeFile(K,J),await Z.promises.rename(K,B),{bytes:J.byteLength,path:B,url:q(G)}},url:q}}async function z(j,q=j){let G=await Z.promises.readdir(q,{withFileTypes:!0});G.sort((B,K)=>B.name.localeCompare(K.name));let J=[];for(let B of G){let K=Q.join(q,B.name);if(B.isDirectory()){J.push(...await z(j,K));continue}if(!B.isFile()||!L.has(Q.extname(B.name).toLowerCase()))continue;J.push({absolutePath:K,relativePath:Q.relative(j,K)})}return J}function _(j){return j.map((q)=>({key:R(q.relativePath),input:q.absolutePath,name:E(q.relativePath)}))}async function I(j){let q=[],G=8;for(let J=0;J<j.length;J+=8){let B=j.slice(J,J+8),K=await Promise.all(B.map(async(M)=>{try{return await w(M.absolutePath),M}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${M.relativePath}`),null}}));q.push(...K.filter((M)=>M!==null))}return q}function V(j){return Q.join(j,"undecodable.json")}function k(j){try{let q=Z.readFileSync(V(j),"utf-8"),G=JSON.parse(q);return G&&typeof G==="object"?G:{}}catch{return{}}}function P(j,q){try{Z.mkdirSync(Q.dirname(V(j)),{recursive:!0}),Z.writeFileSync(V(j),JSON.stringify(q))}catch{}}function S(j){try{let q=Z.statSync(j);return{mtimeMs:q.mtimeMs,size:q.size}}catch{return}}function m(j){if(!j||j.startsWith("data:")||j.startsWith("blob:")||/^https?:\/\//i.test(j)||j.startsWith("//"))return;let q=j.split(/[?#]/,1)[0];if(!q)return;try{return`/${q.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function h(j){let q=m(j);return q?Y.get(q):void 0}function N(){Y=new Map}async function n(j,q){if(!j||!Z.existsSync(j))return N(),{count:0,fingerprint:""};let G=await z(j);if(G.length===0)return N(),{count:0,fingerprint:""};let J=k(q),B=G.filter((A)=>{let x=J[A.relativePath];if(!x)return!0;let $=S(A.absolutePath);return!$||$.mtimeMs!==x.mtimeMs||$.size!==x.size});if(B.length===0)return N(),{count:0,fingerprint:""};let K={outDir:Q.join(q,"_stx","images"),storage:C(Q.join(q,"_stx","images")),baseUrl:O,widths:F,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},M=B,X;try{X=await T({...K,entries:_(B)})}catch(A){if(M=await I(B),M.length===B.length)throw A;let x=new Set(M.map((W)=>W.relativePath)),$=!1;for(let W of B){if(x.has(W.relativePath))continue;let H=S(W.absolutePath);if(!H)continue;J[W.relativePath]=H,$=!0}if($)P(q,J);if(M.length===0)return N(),{count:0,fingerprint:""};X=await T({...K,entries:_(M)})}return Y=new Map(Object.entries(X.entries)),{count:M.length,fingerprint:X.fingerprint}}
|
|
3
|
+
export{h as at,N as bt,n as ct};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Xe as a}from"./chunk-1pmf8mbc.js";import"./chunk-k049j105.js";import"./chunk-kzt0ycg7.js";import"./chunk-r2pck10q.js";import"./chunk-278ay77z.js";import"./chunk-fq5d2r74.js";import"./chunk-ant3p5v8.js";import"./chunk-w43x27h2.js";import"./chunk-bf4xr43a.js";import"./chunk-n3kmd544.js";import"./chunk-c1rwzz7v.js";import"./chunk-wzb9q4ta.js";import"./chunk-ncnmb3kq.js";import"./chunk-8ybhs27t.js";import"./chunk-0jznnssx.js";import"./chunk-vqq5zjbg.js";export{a as startInteractive};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import C from"path";var G=".stx",K="STX_DIR",J=null;function O(j){J=j?.trim()||null}function H(){return process.env[K]?.trim()||J||G}function Q(j=process.cwd(),...q){let B=H();return C.isAbsolute(B)?C.join(B,...q):C.join(j,B,...q)}function W(j){if(!j||C.isAbsolute(j))return j;let q=j.replace(/\\/g,"/");if(q!==G&&!q.startsWith(`${G}/`))return j;let B=q.slice(G.length+1);return B?C.join(H(),B):H()}
|
|
3
|
-
export{G as
|
|
3
|
+
export{G as At,K as Bt,O as Ct,H as Dt,Q as Et,W as Ft};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Wf as a}from"./chunk-z3te7cgf.js";import"./chunk-yrz3hq80.js";import"./chunk-8x7699qk.js";import"./chunk-64gh98cz.js";import"./chunk-fed3xsp9.js";import"./chunk-58f0mthg.js";import"./chunk-k049j105.js";import"./chunk-kzt0ycg7.js";import"./chunk-r2pck10q.js";import"./chunk-278ay77z.js";import"./chunk-fq5d2r74.js";import"./chunk-ant3p5v8.js";import"./chunk-w43x27h2.js";import"./chunk-bf4xr43a.js";import"./chunk-n3kmd544.js";import"./chunk-c1rwzz7v.js";import"./chunk-wzb9q4ta.js";import"./chunk-ncnmb3kq.js";import"./chunk-8ybhs27t.js";import"./chunk-0jznnssx.js";import"./chunk-vqq5zjbg.js";export{a as buildForProduction};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
function A(h){let q=/import\s*\{([^}]+)\}\s*from\s*['"](@stores|stx\/stores)['"]\s*;?\n?/g;h=h.replace(q,(w,j)=>{return`const { ${j.split(",").map((k)=>k.trim()).filter(Boolean).join(", ")} } = window.__STX_STORES__
|
|
3
3
|
`});let v=/import\s*\{([^}]+)\}\s*from\s*['"]@composables['"]\s*;?\n?/g;return h=h.replace(v,(w,j)=>{return`const { ${j.split(",").map((k)=>k.trim()).filter(Boolean).join(", ")} } = window.__composables
|
|
4
4
|
`}),h}function B(h){return h.replace(/^import\s+[^'"]*?from\s*['"][^'"]+['"]\s*;?[ \t]*$/gm,"").replace(/^import\s+['"][^'"]+['"]\s*;?[ \t]*$/gm,"")}
|
|
5
|
-
export{A as
|
|
5
|
+
export{A as Wt,B as Xt};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Fs as Q}from"./chunk-kzt0ycg7.js";import"./chunk-278ay77z.js";import{Et as R}from"./chunk-bf4xr43a.js";import"./chunk-vqq5zjbg.js";import O from"fs";import U from"path";async function W(j,b={}){let q=Date.now(),z={total:0,passed:0,failed:0,new:0,failures:[],duration:0},K=b.snapshotDir||R(j.root,"story","snapshots");await O.promises.mkdir(K,{recursive:!0});let B=j.storyFiles;if(b.filter&&b.filter.length>0)B=B.filter((J)=>b.filter.some((G)=>J.fileName.toLowerCase().includes(G.toLowerCase())));for(let J of B)await X(J,K,b,z);return z.duration=Date.now()-q,z}async function X(j,b,q,z){let K=j.story;if(!K)return;for(let B of K.variants){z.total++;let J=U.join(b,`${j.id}-${B.id}.snap`),G=Y(B.source||""),L=await _(J);if(q.update||!L){let M={storyId:j.id,variantId:B.id,component:j.fileName,timestamp:Date.now(),hash:G};if(await O.promises.writeFile(J,JSON.stringify(M,null,2)),!L)z.new++;z.passed++}else try{let M=await O.promises.readFile(J,"utf-8"),N=JSON.parse(M);if(N.hash===G)z.passed++;else z.failed++,z.failures.push({storyId:j.id,variantId:B.id,component:j.fileName,message:"Snapshot mismatch",difference:Z(N.hash,G)})}catch(M){z.failed++,z.failures.push({storyId:j.id,variantId:B.id,component:j.fileName,message:`Error reading snapshot: ${M}`})}}}async function A(j,b={}){return(await W(j,{...b,update:!0})).total}function Y(j){let b=0;for(let q=0;q<j.length;q++){let z=j.charCodeAt(q);b=(b<<5)-b+z,b=b&b}return b.toString(16)}function Z(j,b){if(j===b)return 0;let q=Math.abs(Number.parseInt(j,16)-Number.parseInt(b,16));return Math.min(q/1e6,1)}async function _(j){try{return await O.promises.access(j),!0}catch{return!1}}function I(j){let b=[];if(b.push(""),b.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),b.push(" STX Story Visual Regression Tests"),b.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),b.push(""),j.failures.length>0){b.push(" \u274C Failures:"),b.push("");for(let q of j.failures){if(b.push(` \u2022 ${q.component} / ${q.variantId}`),b.push(` ${q.message}`),q.difference!==void 0)b.push(` Difference: ${(q.difference*100).toFixed(2)}%`);b.push("")}}if(b.push(" Summary:"),b.push(` Total: ${j.total}`),b.push(` Passed: ${j.passed} \u2713`),b.push(` Failed: ${j.failed} \u2717`),j.new>0)b.push(` New: ${j.new} \u26A1`);return b.push(` Time: ${j.duration}ms`),b.push(""),b.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),b.push(""),b.join(`
|
|
3
3
|
`)}async function S(j,b={}){let q=performance.now(),z=[],K=0,B=0;for(let G of j.storyFiles)try{let L=await Bun.file(G.path).text(),M=await Q(L,G.path);if(M.length>0){for(let N of M)z.push({storyId:G.id,variantId:"default",component:G.component,message:`A11y: ${N.message}`,expected:"No accessibility violations",actual:`${N.type}: ${N.message} (impact: ${N.impact})`});B++}else K++}catch(L){z.push({storyId:G.id,variantId:"default",component:G.component,message:`Failed to check a11y: ${L instanceof Error?L.message:String(L)}`,expected:"File readable for a11y check",actual:"File read error"}),B++}let J=performance.now()-q;return{total:j.storyFiles.length,passed:K,failed:B,new:0,failures:z,duration:J}}export{A as updateSnapshots,W as runVisualTests,S as runA11yTests,I as formatTestResults};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Sl as KJ,
|
|
2
|
+
import{Sl as KJ,gr as WJ}from"./chunk-k049j105.js";import{$s as JJ,_s as e}from"./chunk-fq5d2r74.js";import{gt as ZJ,kt as g}from"./chunk-w43x27h2.js";import{Et as h}from"./chunk-bf4xr43a.js";import z from"path";import O from"fs";function XJ(J){if(!J||typeof J!=="object")return!1;let K=J;return typeof K.message==="string"&&(K.name==="BuildMessage"||K.name==="ResolveMessage"||("position"in K))}function jJ(J){if(J&&typeof J==="object"&&Array.isArray(J.errors))return J.errors;return[J]}function D(J,K){let Z=[];for(let W of jJ(J)){if(XJ(W)){let H=W.position||void 0;Z.push({file:K||H?.file,line:H?.line,column:H?.column,message:W.message??"",lineText:H?.lineText});continue}Z.push({file:K,message:W instanceof Error?W.message:String(W)})}return Z}function d(J,K){return D(J,K).map((Z)=>{let W=Z.file?`${Z.file}${Z.line?`:${Z.line}${Z.column?`:${Z.column}`:""}`:""}`:"",H=Z.lineText?`
|
|
3
3
|
${Z.lineText.trim()}`:"";return W?`${W}: ${Z.message}${H}`:`${Z.message}${H}`}).join(`
|
|
4
4
|
`)}var VJ=6,$J=1,GJ=new Map,P=600,kJ=100,f=new Map;async function OJ(J){let K=f.get(J)??0;if(K>0&&K<kJ){f.set(J,K+1);return}f.set(J,1);try{let Z=(await O.promises.readdir(J)).filter((Y)=>Y.endsWith(".js"));if(Z.length<=P)return;let H=(await Promise.all(Z.map(async(Y)=>{try{return{name:Y,at:(await O.promises.stat(z.join(J,Y))).mtimeMs}}catch{return null}}))).filter((Y)=>Y!==null);H.sort((Y,q)=>q.at-Y.at);for(let Y of H.slice(P)){let q=Y.name.slice(0,-3);await O.promises.rm(z.join(J,`${q}.js`),{force:!0}),await O.promises.rm(z.join(J,`${q}.deps.json`),{force:!0})}S("pruned bundle cache to",P,"entries")}catch{}}function DJ(J){return GJ.get(J)??[]}function m(J,K){if(J)GJ.set(J,K)}function wJ(J=process.env){return J.STX_DEBUG==="true"||J.STX_DEBUG==="1"}function S(...J){if(wJ())console.log("[stx:bundler]",...J)}var p=[];function r(J,K,Z){p.push({filePath:J||"<inline>",message:K,details:Z})}function EJ(){return p.slice()}function PJ(){p.length=0}var u;function fJ(J){u=J}function i(){if(u)return u;try{let J=WJ.strict;return typeof J==="object"&&J!==null?J.bundlerFallback??"warn":"warn"}catch{return"warn"}}var s=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function bJ(J){let K=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,Z;while((Z=K.exec(J))!==null){let H=Z[1];if(!s.some((q)=>q.test(H)))return S("detected user import:",H),!0}let W=/^[ \t]*import[ \t]+['"]([^'"]+)['"]/gm;while((Z=W.exec(J))!==null){let H=Z[1];if(/\.css(?:\?.*)?$/.test(H))continue;if(!s.some((q)=>q.test(H)))return S("detected side-effect import:",H),!0}return!1}var E="stx-module:",AJ=/\.(?:[cm]?[jt]sx?|json)$/i;function UJ(J,K){return z.relative(J,K).split(z.sep).join("/")}function CJ(J,K){let Z=0,W=(Y)=>{let q=`__stxMod${Z++}`,X=JSON.stringify(Y);return K.push(`var ${q} = globalThis.__stxModules && globalThis.__stxModules[${X}];`,`if (${q} === undefined) throw new Error("[stx] module " + ${JSON.stringify(X)} + " is not registered on this page (#1957)");`),q},H=(Y,q)=>{for(let X of Y.split(",")){let $=X.trim();if(!$)continue;let G=$.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!G)continue;let Q=G[1].startsWith('"')?JSON.parse(G[1]):G[1],j=G[2]??Q;K.push(`var ${j} = ${q}[${JSON.stringify(Q)}];`)}};return J=J.replace(/^[ \t]*import\s+([^;"']*?)\s+from\s+["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(Y,q,X)=>{let $=X.slice(E.length),G=W($),Q=q.trim(),j=Q.match(/^([\w$]+)\s*(?:,\s*|$)/);if(j&&!Q.startsWith("{")&&!Q.startsWith("*"))K.push(`var ${j[1]} = ${G}.default;`),Q=Q.slice(j[0].length).trim();let w=Q.match(/^\*\s*as\s+([\w$]+)$/);if(w)K.push(`var ${w[1]} = ${G};`);else if(Q.startsWith("{"))H(Q.replace(/^\{|\}$/g,""),G);return""}),J=J.replace(/^[ \t]*import\s+["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(Y,q)=>{return W(q.slice(E.length)),""}),J}function t(J){let K=[J,`${J}.ts`,`${J}.tsx`,`${J}.js`,`${J}.mjs`,`${J}.jsx`,z.join(J,"index.ts"),z.join(J,"index.tsx"),z.join(J,"index.js"),z.join(J,"index.mjs")];for(let Z of K)try{if(O.existsSync(Z)&&O.statSync(Z,{throwIfNoEntry:!1})?.isFile())return Z}catch{}return}function LJ(J,K,Z,W,H){let Y=(X,$)=>{if(!H||X!==Z||!AJ.test($))return null;try{if(!O.statSync($,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}return W.add($),{path:`${E}${UJ(process.cwd(),$)}`,external:!0}},q=(X,$)=>{let G=X===Z?K:z.dirname(X),Q=z.resolve(G,$);return t(Q)??Q};return{name:"stx-client-bundle",setup(X){X.onResolve({filter:/^(stx|@stacksjs\/stx)$/},($)=>({path:$.path,external:!0})),X.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},($)=>({path:$.path,external:!0})),X.onResolve({filter:/^\//},($)=>{let G=t($.path);if(G){let Q=Y($.importer,G);if(Q)return Q;if(G!==Z)W.add(G);return{path:G}}return{path:$.path,external:!0}}),X.onResolve({filter:/^\.\.?\//},($)=>{let G=q($.importer,$.path),Q=Y($.importer,G);if(Q)return Q;return W.add(G),{path:G}}),X.onResolve({filter:/^[@~]\//},($)=>{let G=z.resolve(J,$.path.slice(2)),Q=[G,`${G}.ts`,`${G}.tsx`,`${G}.js`,`${G}.mjs`,`${G}.jsx`,z.join(G,"index.ts"),z.join(G,"index.tsx"),z.join(G,"index.js"),z.join(G,"index.mjs")];for(let j of Q)if(O.existsSync(j)&&O.statSync(j,{throwIfNoEntry:!1})?.isFile()){let w=Y($.importer,j);if(w)return w;return S(`resolved ${$.path[0]}/ import:`,$.path,"\u2192",j),W.add(j),{path:j}}return console.warn(`[stx:bundler] could not resolve ${$.path[0]}/ import:`,$.path),{path:G}}),X.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},($)=>{if(!H||$.importer!==Z)return;return{path:`${E}npm:${$.path}`,external:!0}}),X.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},($)=>{let G=z.extname($.path).toLowerCase(),Q=G===".json"?"json":G===".tsx"?"tsx":G===".jsx"?"jsx":G===".ts"||G===".mts"||G===".cts"?"ts":"js";if($.path!==Z)W.add($.path);return{contents:O.readFileSync($.path,"utf8"),loader:Q}})}}}var b=new Map,B=ZJ(64),a=Symbol.for("stx.client-bundle-build-queue");function SJ(J){let K=globalThis,W=(K[a]??Promise.resolve()).then(J,J);return K[a]=W.then(()=>{return},()=>{return}),W}async function gJ(J,K,Z={}){let W=Z.projectRoot||process.cwd(),H=Z.minify??!1,Y=Z.externalizeUserModules??!0,q=Z.cacheDir||h(W,"bundle-cache"),X=new Bun.CryptoHasher("md5");X.update(`${VJ}\x00${Y?"registry":"inline"}\x00${J}\x00${K}`);let $=X.digest("hex").slice(0,12),G=z.join(q,`${$}.js`),Q=B.get(G);if(Q){if(g(Q.files)){S("memo hit:",$);let M=Q.files.map((L)=>L.path);return m(K,M),Z.collectInputs?.push(...M),Q.code}B.delete(G),S("memo invalidated by dep change:",$)}let j=z.join(q,`${$}.deps.json`),w=Bun.file(G);if(await w.exists()){let M=Bun.file(j),L=!0,A=null;if(await M.exists())try{let I=JSON.parse(await M.text());if(I.metadataVersion!==$J||!Array.isArray(I.files))L=!1;else A=I.files;if(A&&!g(A))L=!1}catch{L=!1}if(L){if(S("cache hit:",$),A)m(K,A.map((_)=>_.path)),Z.collectInputs?.push(...A.map((_)=>_.path));let I=await w.text();if(A)B.set(G,{code:I,files:A});return I}S("cache invalidated by dep change:",$)}let F=b.get($);if(F){let M=await F;if(Z.collectInputs)Z.collectInputs.push(...(B.get(G)?.files??[]).map((L)=>L.path));return M}let T=SJ(()=>TJ(J,K,{projectRoot:W,minify:H,cacheDir:q,hash:$,cachePath:G,depsPath:j,collectInputs:Z.collectInputs,externalizeUserModules:Y}));b.set($,T);try{return await T}finally{b.delete($)}}async function TJ(J,K,Z){let{projectRoot:W,minify:H,cacheDir:Y,hash:q,cachePath:X,depsPath:$,externalizeUserModules:G}=Z,Q=h(W,"bundle-tmp"),j=z.join(Q,`${q}.ts`),w=z.join(Q,"out",q);O.mkdirSync(Q,{recursive:!0}),O.mkdirSync(w,{recursive:!0});let F=z.dirname(K),T=new Set,M=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,L=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,A=e(J),{depths:I,balanced:_}=JJ(A),c=(U)=>!_||I[U]===0,C;while((C=M.exec(A))!==null){if(C[1])continue;if(!c(C.index))continue;if(C[2])C[2].split(",").forEach((U)=>{let k=MJ(U);if(k)T.add(k)});else if(C[3])T.add(C[3])}while((C=L.exec(A))!==null){if(C[1])continue;if(!c(C.index))continue;T.add(C[2])}let QJ=T.size>0?`
|
|
5
5
|
export { ${[...T].join(", ")} }`:"";await Bun.write(j,J+QJ),S("bundling:",q,"from:",z.basename(K));let o=new Set;try{let U=await Bun.build({entrypoints:[j],outdir:w,target:"browser",format:"esm",minify:H,plugins:[LJ(W,F,j,o,G)],define:{"process.env.NODE_ENV":H?'"production"':'"development"',...KJ()},root:W});if(!U.success){let x=U.logs.filter((N)=>N.level==="error").map((N)=>N.message).join(", ")||`Unable to bundle ${z.basename(K)}`,R=D(U.logs,K||void 0);if(console.warn("[stx:bundler] build failed:",x),r(K||"",x,R),i()==="error")throw Error(x);return J}let k="";for(let V of U.outputs){k=await V.text();break}let y=[];for(let V of k.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let x of V[1].split(",")){let R=x.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(R){y.push([R[2],R[1]]);continue}let N=x.trim();if(/^[A-Za-z_$][\w$]*$/.test(N))y.push([N,N])}let n=[];k=CJ(k,n);let qJ=k.match(/^\s*import\s+[^;]+;?\s*$/gm)||[];k=k.replace(/^\s*import\s+[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim();let l=`__stxBundle_${q}`,YJ=y.map(([V,x])=>`${JSON.stringify(V)}: ${x}`).join(", "),HJ=y.map(([V])=>`var ${V} = undefined;`).join(`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{a as x,b as u,c as b,d as Az,e as G,f as d,h as y,i as I,j as Uz,k as v}from"./chunk-0y46fbkx.js";import{l as h,m as f,n as g}from"./chunk-q9n5swx7.js";import{
|
|
2
|
+
import{a as x,b as u,c as b,d as Az,e as G,f as d,h as y,i as I,j as Uz,k as v}from"./chunk-0y46fbkx.js";import{l as h,m as f,n as g}from"./chunk-q9n5swx7.js";import{vo as V}from"./chunk-k049j105.js";import"./chunk-kzt0ycg7.js";import"./chunk-r2pck10q.js";import"./chunk-278ay77z.js";import"./chunk-fq5d2r74.js";import"./chunk-ant3p5v8.js";import"./chunk-w43x27h2.js";import"./chunk-bf4xr43a.js";import"./chunk-n3kmd544.js";import"./chunk-c1rwzz7v.js";import"./chunk-wzb9q4ta.js";import"./chunk-ncnmb3kq.js";import"./chunk-8ybhs27t.js";import"./chunk-0jznnssx.js";import{lv as F}from"./chunk-vqq5zjbg.js";import l from"fs";import R from"path";function m(z,J){let Z=[R.join(z.root,"stx.config.ts"),R.join(z.root,"stx.config.js"),R.join(z.root,"stx.config.mjs")],K=J.debounceMs??300,$=null,X=[];for(let B of Z)try{if(!l.existsSync(B))continue;let Y=l.watch(B,(W)=>{if(W==="change"){if($)clearTimeout($);$=setTimeout(async()=>{d("Config file changed, restarting...");try{await J.onChange()}catch(j){G(`Failed to restart: ${j}`)}},K)}});X.push(Y)}catch{}return{stop(){if($)clearTimeout($);for(let B of X)B.close()}}}import E from"fs";import i from"path";var Gz=".stx/story/analytics.json",Nz=1,c=1e4;class M{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(z){this.storagePath=i.join(z,Gz),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let z=E.readFileSync(this.storagePath,"utf-8");return JSON.parse(z)}catch{return{version:Nz,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let z=i.dirname(this.storagePath);if(await E.promises.mkdir(z,{recursive:!0}),this.storage.events.length>c)this.storage.events=this.storage.events.slice(-c);await E.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:Hz(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(z){this.storage.events.push({...z,timestamp:Date.now()}),this.dirty=!0}trackView(z,J){if(this.endViewTiming(z),this.viewStartTimes.set(z,Date.now()),this.track({type:"view",componentId:z,variantId:J}),this.currentSession&&!this.currentSession.componentViews.includes(z))this.currentSession.componentViews.push(z)}endViewTiming(z){let J=this.viewStartTimes.get(z);if(J){let Z=Date.now()-J;this.track({type:"view",componentId:z,metadata:{duration:Z,endView:!0}}),this.viewStartTimes.delete(z)}}trackPropChange(z,J,Z){this.track({type:"prop_change",componentId:z,propName:J,metadata:{value:Z}})}trackVariantSwitch(z,J){this.track({type:"variant_switch",componentId:z,variantId:J})}trackSearch(z,J){this.track({type:"search",query:z,metadata:{resultCount:J}})}getComponentAnalytics(z,J){let Z=this.storage.events.filter((Q)=>Q.componentId===z),K=Z.filter((Q)=>Q.type==="view"&&!Q.metadata?.endView),$=Z.filter((Q)=>Q.type==="prop_change"),X=Z.filter((Q)=>Q.type==="variant_switch"),B={};for(let Q of $)if(Q.propName)B[Q.propName]=(B[Q.propName]||0)+1;let Y={};for(let Q of X)if(Q.variantId)Y[Q.variantId]=(Y[Q.variantId]||0)+1;let W=new Set(this.storage.sessions.filter((Q)=>Q.componentViews.includes(z)).map((Q)=>Q.id)),j=Z.filter((Q)=>Q.metadata?.duration).map((Q)=>Q.metadata.duration),U=j.length>0?j.reduce((Q,D)=>Q+D,0)/j.length:0,_=Object.entries(B).sort((Q,D)=>D[1]-Q[1]).slice(0,5).map(([Q])=>Q);return{componentId:z,componentName:J,viewCount:K.length,uniqueViews:W.size,lastViewed:K[K.length-1]?.timestamp,propChanges:B,topChangedProps:_,variantViews:Y,avgTimeSpent:U}}getMostViewedComponents(z=10){let J=new Map;for(let Z of this.storage.events)if(Z.type==="view"&&Z.componentId&&!Z.metadata?.endView)J.set(Z.componentId,(J.get(Z.componentId)||0)+1);return Array.from(J.entries()).map(([Z,K])=>({componentId:Z,viewCount:K})).sort((Z,K)=>K.viewCount-Z.viewCount).slice(0,z)}getMostChangedProps(z=10){let J=new Map;for(let Z of this.storage.events)if(Z.type==="prop_change"&&Z.propName)J.set(Z.propName,(J.get(Z.propName)||0)+1);return Array.from(J.entries()).map(([Z,K])=>({propName:Z,changeCount:K})).sort((Z,K)=>K.changeCount-Z.changeCount).slice(0,z)}getSearchAnalytics(){let z=this.storage.events.filter(($)=>$.type==="search"),J=new Map,Z=0;for(let $ of z){if($.query)J.set($.query,(J.get($.query)||0)+1);if($.metadata?.resultCount!==void 0)Z+=$.metadata.resultCount}let K=Array.from(J.entries()).map(([$,X])=>({query:$,count:X})).sort(($,X)=>X.count-$.count).slice(0,10);return{totalSearches:z.length,topQueries:K,avgResultCount:z.length>0?Z/z.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function Hz(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import P from"fs";import p from"path";var Fz=".stx/story/bookmarks.json",Vz=1;class T{storage;storagePath;dirty=!1;constructor(z){this.storagePath=p.join(z,Fz),this.storage=this.loadStorage()}loadStorage(){try{let z=P.readFileSync(this.storagePath,"utf-8");return JSON.parse(z)}catch{return{version:Vz,bookmarks:[]}}}async save(){if(!this.dirty)return;let z=p.dirname(this.storagePath);await P.promises.mkdir(z,{recursive:!0}),await P.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(z,J,Z,K={}){let $={id:Rz(),name:K.name||`${z}/${J}`,storyId:z,variantId:J,props:Z,created:Date.now(),notes:K.notes,color:K.color};return this.storage.bookmarks.push($),this.dirty=!0,$}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(z){return this.storage.bookmarks.filter((J)=>J.storyId===z)}getBookmark(z){return this.storage.bookmarks.find((J)=>J.id===z)}isBookmarked(z,J){return this.storage.bookmarks.some((Z)=>Z.storyId===z&&Z.variantId===J)}updateBookmark(z,J){let Z=this.getBookmark(z);if(!Z)return;return Object.assign(Z,J),this.dirty=!0,Z}deleteBookmark(z){let J=this.storage.bookmarks.findIndex((Z)=>Z.id===z);if(J===-1)return!1;return this.storage.bookmarks.splice(J,1),this.dirty=!0,!0}toggleBookmark(z,J,Z){let K=this.storage.bookmarks.find((X)=>X.storyId===z&&X.variantId===J);if(K)return this.deleteBookmark(K.id),{added:!1};return{added:!0,bookmark:this.addBookmark(z,J,Z)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(z,J=!0){let Z=JSON.parse(z),K=0;for(let $ of Z.bookmarks){if(J){let X=this.storage.bookmarks.find((B)=>B.id===$.id);if(X)Object.assign(X,$);else this.storage.bookmarks.push($)}else this.storage.bookmarks.push($);K++}if(K>0)this.dirty=!0;return K}}function Rz(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var N=new Set;function s(){return{open(z){N.add(z),z.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(z){N.delete(z)},message(z,J){}}}function q(z){let J=JSON.stringify({...z,timestamp:z.timestamp||Date.now()});for(let Z of N)try{Z.send(J)}catch{N.delete(Z)}}function n(z,J){q({type:"story-update",data:{storyId:z,...J}})}function a(z,J){q({type:"story-add",data:{storyId:z,...J}})}function o(z){q({type:"story-remove",data:{storyId:z}})}function r(z){return`
|
|
3
3
|
<script>
|
|
4
4
|
(function() {
|
|
5
5
|
const ws = new WebSocket('${z}');
|
|
@@ -556,7 +556,7 @@ window.__stxPerformance = {
|
|
|
556
556
|
|
|
557
557
|
window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
|
|
558
558
|
</script>
|
|
559
|
-
`}import w from"fs";import Xz from"path";var Mz=".stx/story/presets.json",C=1,Pz=10;class k{storage;storagePath;dirty=!1;constructor(z){this.storagePath=Xz.join(z,Mz),this.storage=this.loadStorage()}loadStorage(){try{let z=w.readFileSync(this.storagePath,"utf-8"),J=JSON.parse(z);if(J.version!==C)return this.migrateStorage(J);return J}catch{return{version:C,presets:[],recentIds:[]}}}migrateStorage(z){return{version:C,presets:z.presets||[],recentIds:z.recentIds||[]}}async save(){if(!this.dirty)return;let z=Xz.dirname(this.storagePath);await w.promises.mkdir(z,{recursive:!0}),await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(z,J,Z={}){let K={id:Tz(),name:z,description:Z.description,props:J,componentId:Z.componentId,created:Date.now(),usageCount:0,tags:Z.tags};return this.storage.presets.push(K),this.dirty=!0,K}getPreset(z){return this.storage.presets.find((J)=>J.id===z)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(z){return this.storage.presets.filter((J)=>!J.componentId||J.componentId===z)}getRecentPresets(){return this.storage.recentIds.map((z)=>this.getPreset(z)).filter((z)=>z!==void 0)}usePreset(z){let J=this.getPreset(z);if(!J)return;return J.lastUsed=Date.now(),J.usageCount++,this.storage.recentIds=[z,...this.storage.recentIds.filter((Z)=>Z!==z)].slice(0,Pz),this.dirty=!0,J}updatePreset(z,J){let Z=this.getPreset(z);if(!Z)return;return Object.assign(Z,J),this.dirty=!0,Z}deletePreset(z){let J=this.storage.presets.findIndex((Z)=>Z.id===z);if(J===-1)return!1;return this.storage.presets.splice(J,1),this.storage.recentIds=this.storage.recentIds.filter((Z)=>Z!==z),this.dirty=!0,!0}searchPresets(z){let J=z.toLowerCase();return this.storage.presets.filter((Z)=>{if(Z.name.toLowerCase().includes(J))return!0;if(Z.description?.toLowerCase().includes(J))return!0;if(Z.tags?.some((K)=>K.toLowerCase().includes(J)))return!0;return!1})}getMostUsedPresets(z=5){return[...this.storage.presets].sort((J,Z)=>Z.usageCount-J.usageCount).slice(0,z)}exportPresets(z){let J=z?this.storage.presets.filter((Z)=>z.includes(Z.id)):this.storage.presets;return JSON.stringify({presets:J},null,2)}importPresets(z,J=!1){let Z=JSON.parse(z),K=0;for(let $ of Z.presets){let X=this.storage.presets.find((B)=>B.id===$.id);if(X&&!J)continue;if(X)Object.assign(X,$);else this.storage.presets.push($);K++}if(K>0)this.dirty=!0;return K}}function Tz(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";var Qz=new Map;async function H(z,J,Z={}){let K=performance.now(),$=[];try{let X=await S.promises.stat(J),B=Qz.get(J),Y;if(B&&B.mtime===X.mtimeMs)Y=B.content;else Y=await S.promises.readFile(J,"utf-8"),Qz.set(J,{content:Y,mtime:X.mtimeMs,analyzed:null});let{processDirectives:W}=await import("./chunk-
|
|
559
|
+
`}import w from"fs";import Xz from"path";var Mz=".stx/story/presets.json",C=1,Pz=10;class k{storage;storagePath;dirty=!1;constructor(z){this.storagePath=Xz.join(z,Mz),this.storage=this.loadStorage()}loadStorage(){try{let z=w.readFileSync(this.storagePath,"utf-8"),J=JSON.parse(z);if(J.version!==C)return this.migrateStorage(J);return J}catch{return{version:C,presets:[],recentIds:[]}}}migrateStorage(z){return{version:C,presets:z.presets||[],recentIds:z.recentIds||[]}}async save(){if(!this.dirty)return;let z=Xz.dirname(this.storagePath);await w.promises.mkdir(z,{recursive:!0}),await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(z,J,Z={}){let K={id:Tz(),name:z,description:Z.description,props:J,componentId:Z.componentId,created:Date.now(),usageCount:0,tags:Z.tags};return this.storage.presets.push(K),this.dirty=!0,K}getPreset(z){return this.storage.presets.find((J)=>J.id===z)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(z){return this.storage.presets.filter((J)=>!J.componentId||J.componentId===z)}getRecentPresets(){return this.storage.recentIds.map((z)=>this.getPreset(z)).filter((z)=>z!==void 0)}usePreset(z){let J=this.getPreset(z);if(!J)return;return J.lastUsed=Date.now(),J.usageCount++,this.storage.recentIds=[z,...this.storage.recentIds.filter((Z)=>Z!==z)].slice(0,Pz),this.dirty=!0,J}updatePreset(z,J){let Z=this.getPreset(z);if(!Z)return;return Object.assign(Z,J),this.dirty=!0,Z}deletePreset(z){let J=this.storage.presets.findIndex((Z)=>Z.id===z);if(J===-1)return!1;return this.storage.presets.splice(J,1),this.storage.recentIds=this.storage.recentIds.filter((Z)=>Z!==z),this.dirty=!0,!0}searchPresets(z){let J=z.toLowerCase();return this.storage.presets.filter((Z)=>{if(Z.name.toLowerCase().includes(J))return!0;if(Z.description?.toLowerCase().includes(J))return!0;if(Z.tags?.some((K)=>K.toLowerCase().includes(J)))return!0;return!1})}getMostUsedPresets(z=5){return[...this.storage.presets].sort((J,Z)=>Z.usageCount-J.usageCount).slice(0,z)}exportPresets(z){let J=z?this.storage.presets.filter((Z)=>z.includes(Z.id)):this.storage.presets;return JSON.stringify({presets:J},null,2)}importPresets(z,J=!1){let Z=JSON.parse(z),K=0;for(let $ of Z.presets){let X=this.storage.presets.find((B)=>B.id===$.id);if(X&&!J)continue;if(X)Object.assign(X,$);else this.storage.presets.push($);K++}if(K>0)this.dirty=!0;return K}}function Tz(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";var Qz=new Map;async function H(z,J,Z={}){let K=performance.now(),$=[];try{let X=await S.promises.stat(J),B=Qz.get(J),Y;if(B&&B.mtime===X.mtimeMs)Y=B.content;else Y=await S.promises.readFile(J,"utf-8"),Qz.set(J,{content:Y,mtime:X.mtimeMs,analyzed:null});let{processDirectives:W}=await import("./chunk-6yy15yee.js"),j={},U=A(Y);if(U)try{await V(U,j,J)}catch(O){$.push(`Warning: Could not extract script variables: ${O instanceof Error?O.message:String(O)}`)}if(Z.props)Object.assign(j,Z.props);let Q=await W(Y,j,J,{},new Set),D=Wz(Y),L=A(Y);return Q=jz(Q),Q=Dz(Q,j),{html:Q,css:D,js:L,errors:$,duration:performance.now()-K}}catch(X){return $.push(X instanceof Error?X.message:String(X)),{html:`<div class="stx-render-error">${Lz($[0])}</div>`,css:"",js:"",errors:$,duration:performance.now()-K}}}async function qz(z){try{let J=await S.promises.readFile(z,"utf-8"),Z=A(J);if(!Z)return null;let K={};if(await V(Z,K,z),Array.isArray(K.variants))return K.variants;return null}catch{return null}}async function Bz(z,J,Z,K){let $=J.story?.variants;if(!$){let Y=await qz(J.path);if(Y)$=Y}if(!$&&Z==="default")return H(z,J.path,{props:K||{}});if(!$)return H(z,J.path,{props:K||{}});let X=$.find((Y)=>Y.id===Z);if(!X&&Z==="default")return H(z,J.path,{props:K||{}});if(!X)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${Z}' not found`],duration:0};let B={...X.state,...K};if(X.source)return wz(z,X.source,B);return H(z,J.path,{props:B})}async function wz(z,J,Z={}){let K=performance.now(),$=[];try{let{processDirectives:X}=await import("./chunk-6yy15yee.js"),B={...Z},Y=A(J);if(Y)try{await V(Y,B,"inline-template.stx")}catch{}let j=await X(J,B,"inline-template.stx",{},new Set);return j=jz(j),j=Dz(j,B),{html:j,css:Wz(J),js:A(J),errors:$,duration:performance.now()-K}}catch(X){return $.push(X instanceof Error?X.message:String(X)),{html:`<div class="stx-render-error">${Lz($[0])}</div>`,css:"",js:"",errors:$,duration:performance.now()-K}}}function Wz(z){let J=[],Z=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,K=Z.exec(z);while(K!==null)J.push(K[1].trim()),K=Z.exec(z);return J.join(`
|
|
560
560
|
`)}function jz(z){return z.replace(/<!--[\s\S]*?-->/g,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/^\s*\n/gm,"").trim()}function A(z){let J=[],Z=/<script\b[^>]*>([\s\S]*?)<\/script>/gi,K=Z.exec(z);while(K!==null)J.push(K[1].trim()),K=Z.exec(z);return J.join(`
|
|
561
561
|
`)}function Dz(z,J){let Z=`<script>window.__stxProps = ${JSON.stringify(J)};</script>`;return z+Z}function Lz(z){return z.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}async function Oz(z,J){let Z=await I(z);f(z,Z);let K=v(z.config,Z);g(z,K),console.log(` Found ${Z.length} story files`);let $=typeof J.host==="string"?J.host:J.host===!0?"0.0.0.0":"localhost",X=new k(z.root),B=new T(z.root),Y=new M(z.root),W=s(),j=Bun.serve({port:J.port,hostname:$,fetch:async(Q,D)=>{let O=new URL(Q.url).pathname;if(O==="/__hmr"){if(D.upgrade(Q,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(O.startsWith("/api/"))return Cz(z,O,Q,{presetsManager:X,bookmarksManager:B,analyticsTracker:Y});return kz(z,O,J.port)},websocket:{open(Q){W.open(Q)},close(Q){W.close(Q)},message(Q,D){W.message(Q,D)}}}),U=`http://${$}:${J.port}`,_=Uz(z,async(Q,D)=>{console.log(` [${Q}] ${D.relativePath}`);let L=await I(z);f(z,L);let O=v(z.config,L);if(g(z,O),Q==="add")a(D.id,{fileName:D.fileName});else if(Q==="unlink")o(D.id);else n(D.id,{fileName:D.fileName})});if(J.open){let Q=U;try{let{exec:D}=await import("child_process"),L=process.platform;D(`${L==="darwin"?"open":L==="win32"?"start":"xdg-open"} ${Q}`)}catch{}}return{server:j,url:U,close:async()=>{_(),j.stop()}}}async function Cz(z,J,Z,K){let{presetsManager:$,bookmarksManager:X,analyticsTracker:B}=K;if(J==="/api/stories")return Response.json({files:z.storyFiles.map((Y)=>({id:Y.id,fileName:Y.fileName,relativePath:Y.relativePath,treePath:Y.treePath})),tree:z.tree});if(J.startsWith("/api/story/")){let Y=J.slice(11),W=z.storyFiles.find((j)=>j.id===Y);if(!W)return new Response("Story not found",{status:404});try{let j=await Bun.file(W.path).text();return Response.json({id:W.id,fileName:W.fileName,relativePath:W.relativePath,content:j})}catch{return new Response("Error reading story",{status:500})}}if(J==="/api/config")return Response.json({theme:z.config.theme,responsivePresets:z.config.responsivePresets,backgroundPresets:z.config.backgroundPresets});if(J.startsWith("/api/render/")){let Y=new URL(Z.url),W=J.slice(12).split("/"),j=W[0],U=W[1]||"default",_,Q=Y.searchParams.get("props");if(Q)try{_=JSON.parse(Q)}catch{}let D=z.storyFiles.find((L)=>L.id===j);if(!D)return new Response("Story not found",{status:404});try{let L=await Bz(z,D,U,_);return Response.json({html:L.html,css:L.css,js:L.js,errors:L.errors,duration:L.duration})}catch(L){return Response.json({html:"",css:"",js:"",errors:[L instanceof Error?L.message:String(L)],duration:0},{status:500})}}if(J==="/api/presets"&&Z.method==="GET")return Response.json({presets:$.getAllPresets()});if(J==="/api/presets"&&Z.method==="POST")try{let Y=await Z.json(),W=$.createPreset(Y.name,Y.props,{componentId:Y.componentId,description:Y.description});return await $.save(),Response.json(W)}catch(Y){return Response.json({error:String(Y)},{status:400})}if(J.startsWith("/api/presets/")&&!J.includes("/use")&&Z.method==="GET"){let Y=J.slice(13),W=$.getPreset(Y);if(!W)return new Response("Preset not found",{status:404});return Response.json(W)}if(J.endsWith("/use")&&Z.method==="POST"){let Y=J.slice(13,-4),W=$.usePreset(Y);if(!W)return new Response("Preset not found",{status:404});return await $.save(),Response.json(W)}if(J.startsWith("/api/presets/")&&Z.method==="DELETE"){let Y=J.slice(13);if(!$.deletePreset(Y))return new Response("Preset not found",{status:404});return await $.save(),Response.json({success:!0})}if(J==="/api/bookmarks"&&Z.method==="GET")return Response.json({bookmarks:X.getAllBookmarks()});if(J==="/api/bookmarks"&&Z.method==="POST")try{let Y=await Z.json(),W=X.addBookmark(Y.storyId,Y.variantId,Y.props,{name:Y.name,notes:Y.notes,color:Y.color});return await X.save(),Response.json(W)}catch(Y){return Response.json({error:String(Y)},{status:400})}if(J==="/api/bookmarks/toggle"&&Z.method==="POST")try{let Y=await Z.json(),W=X.toggleBookmark(Y.storyId,Y.variantId,Y.props);return await X.save(),Response.json(W)}catch(Y){return Response.json({error:String(Y)},{status:400})}if(J.startsWith("/api/bookmarks/")&&J!=="/api/bookmarks/toggle"&&Z.method==="GET"){let Y=J.slice(15),W=X.getBookmark(Y);if(!W)return new Response("Bookmark not found",{status:404});return Response.json(W)}if(J.startsWith("/api/bookmarks/")&&Z.method==="DELETE"){let Y=J.slice(15);if(!X.deleteBookmark(Y))return new Response("Bookmark not found",{status:404});return await X.save(),Response.json({success:!0})}if(J==="/api/analytics/track"&&Z.method==="POST")try{let Y=await Z.json();if(Y.type==="view"&&Y.componentId)B.trackView(Y.componentId,Y.variantId);else if(Y.type==="prop_change"&&Y.componentId&&Y.propName)B.trackPropChange(Y.componentId,Y.propName,null);else if(Y.type==="variant_switch"&&Y.componentId&&Y.variantId)B.trackVariantSwitch(Y.componentId,Y.variantId);else if(Y.type==="search"&&Y.query)B.trackSearch(Y.query,0);return await B.save(),Response.json({success:!0})}catch(Y){return Response.json({error:String(Y)},{status:400})}if(J==="/api/analytics/summary"&&Z.method==="GET")return Response.json({mostViewed:B.getMostViewedComponents(10),mostChangedProps:B.getMostChangedProps(10),searchAnalytics:B.getSearchAnalytics()});if(J.startsWith("/api/analytics/component/")&&Z.method==="GET"){let Y=J.slice(25),W=z.storyFiles.find((U)=>U.id===Y),j=B.getComponentAnalytics(Y,W?.fileName||Y);return Response.json(j)}return new Response("Not found",{status:404})}function kz(z,J,Z){let K=Sz(z,Z);return new Response(K,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function Sz(z,J){let{theme:Z}=z.config,K=Z.title||"STX Story",$=`ws://localhost:${J}/__hmr`,X=r($);return`<!DOCTYPE html>
|
|
562
562
|
<html lang="en" class="${Z.darkClass||"dark"}">
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{si as a,ti as b}from"./chunk-ynt7y2n5.js";import"./chunk-
|
|
2
|
+
import{si as a,ti as b}from"./chunk-ynt7y2n5.js";import"./chunk-vqq5zjbg.js";export{a as processTeleportDirectives,b as ensureTeleportTargets};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Jf as c,Kf as d,Lf as e,Mf as f,Nf as g,Of as h}from"./chunk-1f3hhrfj.js";import{ng as a,qg as b}from"./chunk-8x7699qk.js";import"./chunk-3225x47e.js";import"./chunk-efr3ejqt.js";import"./chunk-k049j105.js";import"./chunk-kzt0ycg7.js";import"./chunk-r2pck10q.js";import"./chunk-278ay77z.js";import"./chunk-fq5d2r74.js";import"./chunk-ant3p5v8.js";import"./chunk-w43x27h2.js";import"./chunk-bf4xr43a.js";import"./chunk-n3kmd544.js";import"./chunk-c1rwzz7v.js";import"./chunk-wzb9q4ta.js";import"./chunk-ncnmb3kq.js";import"./chunk-8ybhs27t.js";import"./chunk-0jznnssx.js";import"./chunk-vqq5zjbg.js";export{d as virtualPathFor,g as typecheckStxFiles,e as sourcePathFor,h as formatTypecheckDiagnostics,f as findRuntimeTypeDeclarations,b as extractTemplateExpressions,a as extractScriptBlocks,c as buildVirtualSource};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{$l as k,Rl as c,Ul as d,Vl as e,Wl as f,Xl as g,Yl as h,Zl as i,_l as j,am as l,bm as m}from"./chunk-k049j105.js";import"./chunk-kzt0ycg7.js";import"./chunk-r2pck10q.js";import"./chunk-278ay77z.js";import{Zs as a,_s as b}from"./chunk-fq5d2r74.js";import"./chunk-ant3p5v8.js";import"./chunk-w43x27h2.js";import"./chunk-bf4xr43a.js";import"./chunk-n3kmd544.js";import"./chunk-c1rwzz7v.js";import"./chunk-wzb9q4ta.js";import"./chunk-ncnmb3kq.js";import"./chunk-8ybhs27t.js";import"./chunk-0jznnssx.js";import"./chunk-vqq5zjbg.js";export{h as transformAutoImports,b as stripCommentsAndLiterals,e as renderVendorStyleTags,m as processClientScript,g as injectBrowserCoreAutoImports,l as generateServerDataBridge,j as generateBrowserAutoImportDestructuring,i as generateAutoImportDestructuring,a as findInterpolationEnd,k as extractBridgeData,d as extractAndStripCssImports,f as STX_AUTO_IMPORTS,c as BROWSER_CORE_IMPORTS};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ag as c,Bg as d,Cg as e,Dg as f,Eg as g,Fg as h,Gg as i,Hg as j,Ig as k,Jg as l,yg as a,zg as b}from"./chunk-8bxtvsgm.js";import"./chunk-
|
|
2
|
+
import{Ag as c,Bg as d,Cg as e,Dg as f,Eg as g,Fg as h,Gg as i,Hg as j,Ig as k,Jg as l,yg as a,zg as b}from"./chunk-8bxtvsgm.js";import"./chunk-vqq5zjbg.js";export{g as toUsers,f as toUser,c as stopBroadcasting,b as startBroadcasting,d as loadChannels,a as getBroadcastServer,j as channel,h as broadcastPrivate,i as broadcastPresence,e as broadcast,l as BroadcastServer,k as Broadcast};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Eh as a,Fh as b,Gh as c,Hh as d,Ih as e,Jh as f,Kh as g,Lh as h,Mh as i,Nh as j,Oh as k,Ph as l,Qh as m,Rh as n,Sh as o,Th as p,Uh as q}from"./chunk-
|
|
2
|
+
import{Eh as a,Fh as b,Gh as c,Hh as d,Ih as e,Jh as f,Kh as g,Lh as h,Mh as i,Nh as j,Oh as k,Ph as l,Qh as m,Rh as n,Sh as o,Th as p,Uh as q}from"./chunk-9rww0f53.js";import"./chunk-vqq5zjbg.js";export{h as resizeAndConvert,f as processImage,d as isSharpAvailable,m as isImageFile,e as isImageBackendAvailable,l as groupVariantsByFormat,o as getTotalSize,n as getMimeType,g as getImageMetadata,k as getFallbackVariant,i as generateSrcSet,j as generateSizes,p as formatSize,q as ImageProcessingError,a as DEFAULT_WIDTHS,c as DEFAULT_QUALITY,b as DEFAULT_FORMATS};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{iv as W,jv as k,kv as G}from"./chunk-vqq5zjbg.js";import A from"fs";import B from"path";function h(j){let q=0;for(let K=0;K<j.length;K++){let Q=j[K];q=(q<<5)-q+Q,q=q&q}return Math.abs(q).toString(16).padStart(8,"0")}function u(j,q){let K=B.basename(j);for(let Q of q)if(Q.startsWith("*.")){let Y=Q.slice(1);if(K.endsWith(Y))return!0}else if(Q.includes("*")){let Y=new RegExp(`^${Q.replace(/\*/g,".*")}$`);if(Y.test(K)||Y.test(j))return!0}else if(K===Q||j.includes(Q))return!0;return!1}function f(j,q,K){let Q=B.extname(j).toLowerCase(),Y=l[Q],X=(K.maxFileSizeKB||500)*1024;if(q>X)return!1;if(K.exclude&&u(j,K.exclude))return!1;if(K.include&&K.include.length>0){for(let Z of K.include)if(Z.startsWith("*.")){if(j.endsWith(Z.slice(1)))return!0}else if(j.includes(Z))return!0}if(Y&&K[Y]===!0)return!0;if(!Y)return!1;return!1}function T(j,q,K,Q){let Y=A.readdirSync(j,{withFileTypes:!0});for(let X of Y){let Z=B.join(j,X.name);if(X.isDirectory()){if(["node_modules",".git",".stx"].includes(X.name))continue;T(Z,q,K,Q)}else if(X.isFile()){let O=A.statSync(Z),_=B.relative(q,Z);if(f(_,O.size,K)){let $=A.readFileSync(Z),L=h($),V=`/${_.replace(/\\/g,"/")}`;Q.push({url:V,revision:L,size:O.size})}}}}function U(j,q){let K=q.pwa?.precache,Q=[];if(!K?.enabled)return{entries:[],totalSize:0,fileCount:0};if(!A.existsSync(j))return{entries:[],totalSize:0,fileCount:0};T(j,j,K,Q),Q.sort((X,Z)=>X.url.localeCompare(Z.url));let Y=Q.reduce((X,Z)=>X+Z.size,0);return{entries:Q,totalSize:Y,fileCount:Q.length}}function J(j){if(j.entries.length===0)return"[]";return`[
|
|
3
3
|
${j.entries.map((K)=>` { url: '${K.url}', revision: '${K.revision}' }`).join(`,
|
|
4
4
|
`)}
|
|
5
5
|
]`}function E(j){if(j<1024)return`${j} B`;if(j<1048576)return`${(j/1024).toFixed(1)} KB`;return`${(j/1048576).toFixed(2)} MB`}var l;var F=G(()=>{l={".html":"includeHtml",".htm":"includeHtml",".js":"includeJs",".mjs":"includeJs",".css":"includeCss",".png":"includeImages",".jpg":"includeImages",".jpeg":"includeImages",".gif":"includeImages",".webp":"includeImages",".svg":"includeImages",".ico":"includeImages",".woff":"includeFonts",".woff2":"includeFonts",".ttf":"includeFonts",".eot":"includeFonts",".otf":"includeFonts"}});function g(j){let q={"cache-first":{className:"CacheFirst",importFrom:"workbox-strategies"},"network-first":{className:"NetworkFirst",importFrom:"workbox-strategies"},"stale-while-revalidate":{className:"StaleWhileRevalidate",importFrom:"workbox-strategies"},"network-only":{className:"NetworkOnly",importFrom:"workbox-strategies"},"cache-only":{className:"CacheOnly",importFrom:"workbox-strategies"}};return q[j]||q["network-first"]}function R(j){return g(j).className}function M(j){let q=j.pwa;if(!q?.enabled)return"";let K=q.routes||[],Q=q.cacheStorage,Y=[];for(let X of K){let Z=R(X.strategy),O=[];if(X.maxAgeSeconds||X.maxEntries||Q?.maxEntries){let $=X.maxEntries||Q?.maxEntries||100,L=X.maxAgeSeconds||(Q?.maxAge?Q.maxAge*24*60*60:void 0);O.push(`new ExpirationPlugin({
|
|
@@ -8,4 +8,4 @@ function N(D,G){let j=D[G],F=G+1;while(F<D.length){if(D[F]==="\\"){F+=2;continue
|
|
|
8
8
|
`:" ",j++}G+=" ",j++;continue}if(H==="`"){G+=" ",j++;while(j<D.length&&D[j]!=="`"){if(D[j]==="\\"){G+=" ",j+=2;continue}if(D[j]==="$"&&D[j+1]==="{"){let J=j+2,K=M(D,J);if(G+=" ",G+=R(D.slice(J,K)),K<D.length)G+=" ";j=K+1;continue}G+=D[j]===`
|
|
9
9
|
`?`
|
|
10
10
|
`:" ",j++}G+=" ",j++;continue}G+=H,j++}return G}function U(D){let G=new Uint16Array(D.length),j=0,F=!0;for(let H=0;H<D.length;H++){let J=D[H];if(J===")"||J==="]"||J==="}")if(j===0)F=!1;else j--;if(G[H]=j,J==="("||J==="["||J==="{")j++}return{depths:G,balanced:F&&j===0}}
|
|
11
|
-
export{M as
|
|
11
|
+
export{M as Zs,R as _s,U as $s};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ag as t,bg as e,dg as b,mg as JJ}from"./chunk-yhqheg5m.js";import{Nm as u,Om as l,bo as o,gm as y,hm as P,qm as x,uo as g,xm as v}from"./chunk-havegv3v.js";import{Yu as s,av as OJ,vu as a}from"./chunk-drbbt69f.js";import{kv as R}from"./chunk-2vza9m2x.js";import r from"fs";import B from"path";var{serve:IJ}=globalThis.Bun;function q(J,K,Q={}){let X=`${encodeURIComponent(J)}=${encodeURIComponent(K)}`;if(Q.maxAge!==void 0)X+=`; Max-Age=${Q.maxAge}`;if(Q.expires)X+=`; Expires=${Q.expires.toUTCString()}`;if(Q.path)X+=`; Path=${Q.path}`;if(Q.domain)X+=`; Domain=${Q.domain}`;if(Q.secure)X+="; Secure";if(Q.httpOnly)X+="; HttpOnly";if(Q.sameSite)X+=`; SameSite=${Q.sameSite}`;return X}async function KJ(J){let K=J.headers.get("content-type")||"",Q={},X=(Z,$)=>{let G=Q[Z];if(G===void 0)Q[Z]=$;else if(Array.isArray(G))G.push($);else Q[Z]=[G,$]};if(K.includes("multipart/form-data")){let Z=await J.formData();for(let[$,G]of Z.entries())if(typeof G==="string")X($,G);return Q}if(K.includes("application/x-www-form-urlencoded")){for(let[Z,$]of new URLSearchParams(await J.text()).entries())X(Z,$);return Q}return Q}function f(J){if(!J)return!1;let K=J.toUpperCase();return K!=="GET"&&K!=="HEAD"}async function h(J,K={}){let Q=K.request,X=K.method??Q?.method;if(!Q||!f(X))return{ran:!1};if(typeof J.action!=="function")return{ran:!1};let Z={};try{Z=await KJ(Q)}catch{}let $=await J.action({request:Q,form:Z,params:K.params??{},query:J.query??{},cookies:K.cookies??{}});if($&&typeof $==="object"){let G=$,W=QJ(G.cookies),I=G.redirect;if(typeof I==="string"&&I)return{redirect:I,ran:!0,...W.length>0?{cookies:W}:{}};let{cookies:_,redirect:N,...U}=G;if(Object.assign(J,U),W.length>0)return{ran:!0,cookies:W}}return{ran:!0}}function QJ(J){if(!J||typeof J!=="object"||Array.isArray(J))return[];let K=[];for(let[Q,X]of Object.entries(J)){if(!Q)continue;if(typeof X==="string"){K.push(q(Q,X));continue}if(X&&typeof X==="object"){let Z=X;if(typeof Z.value!=="string")continue;K.push(q(Q,Z.value,Z))}}return K}function m(J,K=[],Q){let X=new Headers({Location:J,"Cache-Control":"no-store"});for(let Z of K)X.append("Set-Cookie",Z);for(let[Z,$]of Object.entries(Q??{}))if(Z.toLowerCase()!=="location")X.set(Z,$);return new Response(null,{status:303,headers:X})}async function wJ(J,K={}){return(await c(J,K)).html}async function d(J,K={}){let{html:Q,context:X,redirect:Z,cookies:$}=await c(J,K),G=u(X),W=l(X);if(Z)return{html:Q,redirect:Z,cookies:$,status:G,headers:W};let{extractStreamBoundaries:I}=await import("./chunk-31108nwx.js"),_=I(X),N=J.streamTemplates;if(N&&Object.keys(N).length>0){let{processDirectives:U}=await import("./chunk-ckwq6fkw.js"),{defaultConfig:z}=await import("./chunk-nka77z47.js"),O=X.streamBoundaries||{},w={...z,autoShell:!1},D=Object.keys(N).map((V)=>({id:V,render:async()=>{let F=typeof O[V]==="function"?await O[V]():void 0;return U(N[V],{...X,$boundary:F},J.sourceFile,w,new Set)}})),E=new Set(D.map((V)=>V.id));_=[...(_||[]).filter((V)=>!E.has(V.id)),...D]}return{html:Q,boundaries:_&&_.length>0?_:void 0,cookies:$,status:G,headers:W}}async function c(J,K){let Q={__filename:J.sourceFile,__dirname:J.sourceFile.replace(/[/\\][^/\\]+$/,""),...K};if(!J.hasServerScripts&&!P(J.html))return{html:J.html,context:Q};for(let $ of J.serverScriptContent)try{await g($,Q,J.sourceFile)}catch(G){console.warn(`[stx] Server script error in ${J.sourceFile}:`,G)}let X=await h(Q,{request:K.request,method:K.method,params:K.params??{},cookies:K.cookies??{}});if(X.redirect)return{html:J.html,context:Q,redirect:X.redirect,cookies:X.cookies};if(!P(J.html))return{html:J.html,context:Q,cookies:X.cookies};let Z=new Map;for(let[$,G]of Object.entries(J.placeholders))if(G.expression)try{let W=v(G.expression,Q);if(G.type==="raw")Z.set($,W!==void 0&&W!==null?String(W):"");else Z.set($,W!==void 0&&W!==null?x(String(W)):"")}catch{Z.set($,"")}return{html:y(J.html,Z),context:Q,cookies:X.cookies}}async function AJ(J,K={}){if(!J.hasServerScripts&&!P(J.fragment))return J.fragment;let Q={__filename:J.sourceFile,__dirname:J.sourceFile.replace(/[/\\][^/\\]+$/,""),...K};for(let Z of J.serverScriptContent)try{await g(Z,Q,J.sourceFile)}catch($){console.warn(`[stx] Server script error in ${J.sourceFile}:`,$)}if(!P(J.fragment))return J.fragment;let X=new Map;for(let[Z,$]of Object.entries(J.placeholders))if($.expression)try{let G=v($.expression,Q);if($.type==="raw")X.set(Z,G!==void 0&&G!==null?String(G):"");else X.set(Z,G!==void 0&&G!==null?x(String(G)):"")}catch{X.set(Z,"")}return y(J.fragment,X)}OJ();import C from"zlib";import{promisify as n}from"util";var XJ=n(C.brotliCompress),ZJ=n(C.gzip),$J=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],GJ=["text/event-stream","multipart/x-mixed-replace"],UJ=1024;function WJ(J){if(!J)return!1;let K=J.toLowerCase();if(GJ.some((Q)=>K.startsWith(Q)))return!1;return $J.some((Q)=>K.startsWith(Q))}function jJ(J){let K=new Map;for(let Q of J.split(",")){let[X,...Z]=Q.trim().split(";"),$=X.trim().toLowerCase();if(!$)continue;let G=1;for(let W of Z){let I=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(W);if(!I)continue;let _=Number.parseFloat(I[1]);if(Number.isFinite(_))G=_}K.set($,G)}return K}function YJ(J){if(!J)return null;let K=jJ(J),Q=K.get("*"),X=(Z)=>K.get(Z)??Q??0;if(X("br")>0)return"br";if(X("gzip")>0)return"gzip";return null}async function i(J,K,Q={}){if(K.headers.get("content-encoding"))return K;if(K.status===204||K.status===304||!K.body)return K;if(!WJ(K.headers.get("content-type")))return K;let X=YJ(J.headers.get("accept-encoding"));if(!X)return K;let Z;try{Z=new Uint8Array(await K.arrayBuffer())}catch{return K}let $=()=>new Response(Z,{status:K.status,statusText:K.statusText,headers:p(K.headers)});if(Z.length<(Q.threshold??UJ))return $();try{let G=X==="br"?await XJ(Z,{params:{[C.constants.BROTLI_PARAM_QUALITY]:Q.quality??5,[C.constants.BROTLI_PARAM_SIZE_HINT]:Z.length}}):await ZJ(Z);if(G.length>=Z.length)return $();let W=p(K.headers);return W.set("Content-Encoding",X),W.set("Content-Length",String(G.length)),new Response(G,{status:K.status,statusText:K.statusText,headers:W})}catch{return $()}}function p(J){let K=new Headers(J),Q=K.get("Vary");if(!Q)return K.set("Vary","Accept-Encoding"),K;if(!Q.split(",").some((Z)=>Z.trim().toLowerCase()==="accept-encoding"))K.set("Vary",`${Q}, Accept-Encoding`);return K}var _J={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function mJ(J={}){let K=B.resolve(J.outputDir||".output"),Q=J.port||3000,X=JJ(K);if(!X)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${X.routes.length} routes...`);let Z=new Map,$=new Map,G=new Map,W=new Map;for(let U of X.routes)try{let z=B.join(K,U.compiledPath),O=JSON.parse(await Bun.file(z).text());Z.set(U.pattern,O),G.set(U.pattern,s(O.html)),W.set(U.pattern,o(O.html));let w=B.join(K,U.fragmentPath);if(await Bun.file(w).exists())$.set(U.pattern,await Bun.file(w).text())}catch(z){console.warn(`[stx] Failed to load route ${U.pattern}:`,z)}let I=new Map,_=[];for(let U of X.routes)if(U.hasParams){let{regex:z,params:O}=a(U.pattern);_.push({regex:z,route:U,paramNames:O})}else I.set(U.pattern,U);let N=IJ({port:Q,async fetch(U){return i(U,await(async()=>{let O=new URL(U.url).pathname;if(J.onRequest){let j=await J.onRequest(U);if(j)return j}if(J.apiRoutes?.[O])return J.apiRoutes[O](U);if((U.method==="GET"||U.method==="HEAD")&&O!=="/"){let j=B.resolve(K,"public"),Y;try{Y=decodeURIComponent(O)}catch{Y=O}if(!Y.includes("\x00")){let L=B.resolve(j,`.${Y}`);if(L===j||L.startsWith(`${j}${B.sep}`))try{if(r.existsSync(L)&&r.statSync(L).isFile()){let M=B.extname(L).toLowerCase(),S=_J[M]||"application/octet-stream",H=O.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(O);return new Response(Bun.file(L),{headers:{"Content-Type":S,"Cache-Control":H?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let w=e(U),D=null,E={};if(D=I.get(O)||null,!D)for(let{regex:j,route:Y,paramNames:L}of _){let A=O.match(j);if(A){D=Y,L.forEach((M,S)=>{E[M]=A[S+1]});break}}if(!D){let j=I.get("/404")||null;if(j){let Y=Z.get(j.pattern);if(Y)return new Response(Y.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}if(w){let j=$.get(D.pattern);if(j){let Y=G.get(D.pattern);return new Response(j,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...W.has(D.pattern)?{"X-STX-Runtime":W.get(D.pattern)?"true":"false"}:{},...Y?{"X-STX-Layout":Y.layout,"X-STX-Layout-Group":Y.group}:{},...b(),"Cache-Control":t}})}}let V=f(U.method),F=Z.get(D.pattern);if(!F){let j=I.get("/500")||null;if(j){let Y=Z.get(j.pattern);if(Y)return new Response(Y.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(!V&&!F.hasServerScripts&&Object.keys(F.placeholders).length===0)return new Response(F.html,{status:F.status??200,headers:{"Content-Type":"text/html",...b(),"Cache-Control":"public, max-age=60"}});try{let{html:j,boundaries:Y,redirect:L,cookies:A,status:M,headers:S}=await d(F,{params:E,request:U,method:U.method});if(L)return m(L,A,S);if(Y&&Y.length>0){let{renderStreamingPage:T,streamToResponse:k}=await import("./chunk-31108nwx.js");return k(T(j,Y,{timeoutMs:30000}),{status:M??F.status??200,headers:{"Cache-Control":"no-cache",...S}})}let H=new Headers({"Content-Type":"text/html",...b(),"Cache-Control":"no-cache"});for(let T of A??[])H.append("Set-Cookie",T);for(let[T,k]of Object.entries(S??{}))H.set(T,k);return new Response(j,{status:M??F.status??200,headers:H})}catch(j){return console.error(`[stx] Hydration error for ${O}:`,j),new Response(F.html,{headers:{"Content-Type":"text/html"}})}})())}});return console.log(`[stx] Production server running at http://localhost:${Q}`),console.log(`[stx] Serving ${X.routes.length} routes (${Z.size} pre-loaded)`),{port:Q,stop:()=>N.stop()}}
|
|
2
|
+
import{ag as t,bg as e,dg as b,mg as JJ}from"./chunk-yrz3hq80.js";import{Nm as u,Om as l,co as o,gm as y,hm as P,qm as x,vo as g,xm as v}from"./chunk-k049j105.js";import{Zu as s,bv as OJ,wu as a}from"./chunk-8ybhs27t.js";import{lv as R}from"./chunk-vqq5zjbg.js";import r from"fs";import B from"path";var{serve:IJ}=globalThis.Bun;function q(J,K,Q={}){let X=`${encodeURIComponent(J)}=${encodeURIComponent(K)}`;if(Q.maxAge!==void 0)X+=`; Max-Age=${Q.maxAge}`;if(Q.expires)X+=`; Expires=${Q.expires.toUTCString()}`;if(Q.path)X+=`; Path=${Q.path}`;if(Q.domain)X+=`; Domain=${Q.domain}`;if(Q.secure)X+="; Secure";if(Q.httpOnly)X+="; HttpOnly";if(Q.sameSite)X+=`; SameSite=${Q.sameSite}`;return X}async function KJ(J){let K=J.headers.get("content-type")||"",Q={},X=(Z,$)=>{let G=Q[Z];if(G===void 0)Q[Z]=$;else if(Array.isArray(G))G.push($);else Q[Z]=[G,$]};if(K.includes("multipart/form-data")){let Z=await J.formData();for(let[$,G]of Z.entries())if(typeof G==="string")X($,G);return Q}if(K.includes("application/x-www-form-urlencoded")){for(let[Z,$]of new URLSearchParams(await J.text()).entries())X(Z,$);return Q}return Q}function f(J){if(!J)return!1;let K=J.toUpperCase();return K!=="GET"&&K!=="HEAD"}async function h(J,K={}){let Q=K.request,X=K.method??Q?.method;if(!Q||!f(X))return{ran:!1};if(typeof J.action!=="function")return{ran:!1};let Z={};try{Z=await KJ(Q)}catch{}let $=await J.action({request:Q,form:Z,params:K.params??{},query:J.query??{},cookies:K.cookies??{}});if($&&typeof $==="object"){let G=$,W=QJ(G.cookies),I=G.redirect;if(typeof I==="string"&&I)return{redirect:I,ran:!0,...W.length>0?{cookies:W}:{}};let{cookies:_,redirect:N,...U}=G;if(Object.assign(J,U),W.length>0)return{ran:!0,cookies:W}}return{ran:!0}}function QJ(J){if(!J||typeof J!=="object"||Array.isArray(J))return[];let K=[];for(let[Q,X]of Object.entries(J)){if(!Q)continue;if(typeof X==="string"){K.push(q(Q,X));continue}if(X&&typeof X==="object"){let Z=X;if(typeof Z.value!=="string")continue;K.push(q(Q,Z.value,Z))}}return K}function m(J,K=[],Q){let X=new Headers({Location:J,"Cache-Control":"no-store"});for(let Z of K)X.append("Set-Cookie",Z);for(let[Z,$]of Object.entries(Q??{}))if(Z.toLowerCase()!=="location")X.set(Z,$);return new Response(null,{status:303,headers:X})}async function wJ(J,K={}){return(await c(J,K)).html}async function d(J,K={}){let{html:Q,context:X,redirect:Z,cookies:$}=await c(J,K),G=u(X),W=l(X);if(Z)return{html:Q,redirect:Z,cookies:$,status:G,headers:W};let{extractStreamBoundaries:I}=await import("./chunk-jszyej4e.js"),_=I(X),N=J.streamTemplates;if(N&&Object.keys(N).length>0){let{processDirectives:U}=await import("./chunk-6yy15yee.js"),{defaultConfig:z}=await import("./chunk-3maxrw5t.js"),O=X.streamBoundaries||{},w={...z,autoShell:!1},D=Object.keys(N).map((V)=>({id:V,render:async()=>{let F=typeof O[V]==="function"?await O[V]():void 0;return U(N[V],{...X,$boundary:F},J.sourceFile,w,new Set)}})),E=new Set(D.map((V)=>V.id));_=[...(_||[]).filter((V)=>!E.has(V.id)),...D]}return{html:Q,boundaries:_&&_.length>0?_:void 0,cookies:$,status:G,headers:W}}async function c(J,K){let Q={__filename:J.sourceFile,__dirname:J.sourceFile.replace(/[/\\][^/\\]+$/,""),...K};if(!J.hasServerScripts&&!P(J.html))return{html:J.html,context:Q};for(let $ of J.serverScriptContent)try{await g($,Q,J.sourceFile)}catch(G){console.warn(`[stx] Server script error in ${J.sourceFile}:`,G)}let X=await h(Q,{request:K.request,method:K.method,params:K.params??{},cookies:K.cookies??{}});if(X.redirect)return{html:J.html,context:Q,redirect:X.redirect,cookies:X.cookies};if(!P(J.html))return{html:J.html,context:Q,cookies:X.cookies};let Z=new Map;for(let[$,G]of Object.entries(J.placeholders))if(G.expression)try{let W=v(G.expression,Q);if(G.type==="raw")Z.set($,W!==void 0&&W!==null?String(W):"");else Z.set($,W!==void 0&&W!==null?x(String(W)):"")}catch{Z.set($,"")}return{html:y(J.html,Z),context:Q,cookies:X.cookies}}async function AJ(J,K={}){if(!J.hasServerScripts&&!P(J.fragment))return J.fragment;let Q={__filename:J.sourceFile,__dirname:J.sourceFile.replace(/[/\\][^/\\]+$/,""),...K};for(let Z of J.serverScriptContent)try{await g(Z,Q,J.sourceFile)}catch($){console.warn(`[stx] Server script error in ${J.sourceFile}:`,$)}if(!P(J.fragment))return J.fragment;let X=new Map;for(let[Z,$]of Object.entries(J.placeholders))if($.expression)try{let G=v($.expression,Q);if($.type==="raw")X.set(Z,G!==void 0&&G!==null?String(G):"");else X.set(Z,G!==void 0&&G!==null?x(String(G)):"")}catch{X.set(Z,"")}return y(J.fragment,X)}OJ();import C from"zlib";import{promisify as n}from"util";var XJ=n(C.brotliCompress),ZJ=n(C.gzip),$J=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],GJ=["text/event-stream","multipart/x-mixed-replace"],UJ=1024;function WJ(J){if(!J)return!1;let K=J.toLowerCase();if(GJ.some((Q)=>K.startsWith(Q)))return!1;return $J.some((Q)=>K.startsWith(Q))}function jJ(J){let K=new Map;for(let Q of J.split(",")){let[X,...Z]=Q.trim().split(";"),$=X.trim().toLowerCase();if(!$)continue;let G=1;for(let W of Z){let I=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(W);if(!I)continue;let _=Number.parseFloat(I[1]);if(Number.isFinite(_))G=_}K.set($,G)}return K}function YJ(J){if(!J)return null;let K=jJ(J),Q=K.get("*"),X=(Z)=>K.get(Z)??Q??0;if(X("br")>0)return"br";if(X("gzip")>0)return"gzip";return null}async function i(J,K,Q={}){if(K.headers.get("content-encoding"))return K;if(K.status===204||K.status===304||!K.body)return K;if(!WJ(K.headers.get("content-type")))return K;let X=YJ(J.headers.get("accept-encoding"));if(!X)return K;let Z;try{Z=new Uint8Array(await K.arrayBuffer())}catch{return K}let $=()=>new Response(Z,{status:K.status,statusText:K.statusText,headers:p(K.headers)});if(Z.length<(Q.threshold??UJ))return $();try{let G=X==="br"?await XJ(Z,{params:{[C.constants.BROTLI_PARAM_QUALITY]:Q.quality??5,[C.constants.BROTLI_PARAM_SIZE_HINT]:Z.length}}):await ZJ(Z);if(G.length>=Z.length)return $();let W=p(K.headers);return W.set("Content-Encoding",X),W.set("Content-Length",String(G.length)),new Response(G,{status:K.status,statusText:K.statusText,headers:W})}catch{return $()}}function p(J){let K=new Headers(J),Q=K.get("Vary");if(!Q)return K.set("Vary","Accept-Encoding"),K;if(!Q.split(",").some((Z)=>Z.trim().toLowerCase()==="accept-encoding"))K.set("Vary",`${Q}, Accept-Encoding`);return K}var _J={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function mJ(J={}){let K=B.resolve(J.outputDir||".output"),Q=J.port||3000,X=JJ(K);if(!X)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${X.routes.length} routes...`);let Z=new Map,$=new Map,G=new Map,W=new Map;for(let U of X.routes)try{let z=B.join(K,U.compiledPath),O=JSON.parse(await Bun.file(z).text());Z.set(U.pattern,O),G.set(U.pattern,s(O.html)),W.set(U.pattern,o(O.html));let w=B.join(K,U.fragmentPath);if(await Bun.file(w).exists())$.set(U.pattern,await Bun.file(w).text())}catch(z){console.warn(`[stx] Failed to load route ${U.pattern}:`,z)}let I=new Map,_=[];for(let U of X.routes)if(U.hasParams){let{regex:z,params:O}=a(U.pattern);_.push({regex:z,route:U,paramNames:O})}else I.set(U.pattern,U);let N=IJ({port:Q,async fetch(U){return i(U,await(async()=>{let O=new URL(U.url).pathname;if(J.onRequest){let j=await J.onRequest(U);if(j)return j}if(J.apiRoutes?.[O])return J.apiRoutes[O](U);if((U.method==="GET"||U.method==="HEAD")&&O!=="/"){let j=B.resolve(K,"public"),Y;try{Y=decodeURIComponent(O)}catch{Y=O}if(!Y.includes("\x00")){let L=B.resolve(j,`.${Y}`);if(L===j||L.startsWith(`${j}${B.sep}`))try{if(r.existsSync(L)&&r.statSync(L).isFile()){let M=B.extname(L).toLowerCase(),S=_J[M]||"application/octet-stream",H=O.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(O);return new Response(Bun.file(L),{headers:{"Content-Type":S,"Cache-Control":H?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let w=e(U),D=null,E={};if(D=I.get(O)||null,!D)for(let{regex:j,route:Y,paramNames:L}of _){let A=O.match(j);if(A){D=Y,L.forEach((M,S)=>{E[M]=A[S+1]});break}}if(!D){let j=I.get("/404")||null;if(j){let Y=Z.get(j.pattern);if(Y)return new Response(Y.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}if(w){let j=$.get(D.pattern);if(j){let Y=G.get(D.pattern);return new Response(j,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...W.has(D.pattern)?{"X-STX-Runtime":W.get(D.pattern)?"true":"false"}:{},...Y?{"X-STX-Layout":Y.layout,"X-STX-Layout-Group":Y.group}:{},...b(),"Cache-Control":t}})}}let V=f(U.method),F=Z.get(D.pattern);if(!F){let j=I.get("/500")||null;if(j){let Y=Z.get(j.pattern);if(Y)return new Response(Y.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(!V&&!F.hasServerScripts&&Object.keys(F.placeholders).length===0)return new Response(F.html,{status:F.status??200,headers:{"Content-Type":"text/html",...b(),"Cache-Control":"public, max-age=60"}});try{let{html:j,boundaries:Y,redirect:L,cookies:A,status:M,headers:S}=await d(F,{params:E,request:U,method:U.method});if(L)return m(L,A,S);if(Y&&Y.length>0){let{renderStreamingPage:T,streamToResponse:k}=await import("./chunk-jszyej4e.js");return k(T(j,Y,{timeoutMs:30000}),{status:M??F.status??200,headers:{"Cache-Control":"no-cache",...S}})}let H=new Headers({"Content-Type":"text/html",...b(),"Cache-Control":"no-cache"});for(let T of A??[])H.append("Set-Cookie",T);for(let[T,k]of Object.entries(S??{}))H.set(T,k);return new Response(j,{status:M??F.status??200,headers:H})}catch(j){return console.error(`[stx] Hydration error for ${O}:`,j),new Response(F.html,{headers:{"Content-Type":"text/html"}})}})())}});return console.log(`[stx] Production server running at http://localhost:${Q}`),console.log(`[stx] Serving ${X.routes.length} routes (${Z.size} pre-loaded)`),{port:Q,stop:()=>N.stop()}}
|
|
3
3
|
export{WJ as Ye,YJ as Ze,i as _e,q as $e,KJ as af,f as bf,h as cf,m as df,wJ as ef,d as ff,AJ as gf,mJ as hf};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{fr as E}from"./chunk-k049j105.js";import{lv as D}from"./chunk-vqq5zjbg.js";import I from"path";async function M(k={}){let G=performance.now(),J=k.root||process.cwd(),j=await E(),q=j.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${q.toUpperCase()}${j.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let A,B;if(q==="ssg"){let{generateStaticSite:z}=await import("./ssg.js");A=await z({pagesDir:I.join(j.root||".",j.pagesDir||j.build?.pagesDir||"pages"),publicDir:j.publicDir||j.build?.publicDir||"public",outputDir:j.build?.outputDir||"dist",generate404:j.build?.generate404??!0,minify:j.build?.minify??!0,cleanOutput:j.build?.cleanOutput??!0,router:j.router,...k.ssg})}else{let{buildForProduction:z}=await import("./chunk-bxpvqbm3.js");B=await z({outputDir:".output",debug:k.debug,...k.ssr})}let H=Math.round(performance.now()-G);return{mode:q,ssg:A,ssr:B,duration:H}}
|
|
3
3
|
export{M as Mg};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Oj as a,Pj as b,Qj as c,Rj as d,Sj as e,Tj as f,Uj as g,Vj as h,Wj as i,Xj as j,Yj as k}from"./chunk-a4tv4wwg.js";import"./chunk-k049j105.js";import"./chunk-kzt0ycg7.js";import"./chunk-r2pck10q.js";import"./chunk-278ay77z.js";import"./chunk-fq5d2r74.js";import"./chunk-ant3p5v8.js";import"./chunk-w43x27h2.js";import"./chunk-bf4xr43a.js";import"./chunk-n3kmd544.js";import"./chunk-c1rwzz7v.js";import"./chunk-wzb9q4ta.js";import"./chunk-ncnmb3kq.js";import"./chunk-8ybhs27t.js";import"./chunk-0jznnssx.js";import"./chunk-vqq5zjbg.js";export{a as templateCache,b as readFileCached,d as invalidateFileCacheByDir,c as invalidateFileCache,k as hashFilePath,f as getCachedSignalsRuntime,g as getCachedRouterScript,h as clearDevCaches,i as checkCache,j as cacheTemplate,e as __setSignalsGeneratorsForTest};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Ip as H,_p as x,dr as g,pm as O,vo as R}from"./chunk-k049j105.js";import b from"path";var v={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},M=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var T=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function f(q){let B=[],Q=0,G;T.lastIndex=0;while((G=T.exec(q))!==null){if(G.index>Q){let X=q.slice(Q,G.index);if(X.trim())B.push({type:B.length===0?"shell":"content",content:X})}let J=G[1],K=G[2];B.push({type:"suspense",name:J,content:K}),Q=G.index+G[0].length}if(Q<q.length){let J=q.slice(Q);if(J.trim())B.push({type:B.length===0?"shell":"content",content:J})}if(B.length===0)B.push({type:"shell",content:q});return B}async function r(q,B={},Q={}){let G={...g,...Q,streaming:{...v,...Q.streaming}},J=G.streaming?.bufferSize||16384;return new ReadableStream({async start(K){try{let X=await Bun.file(q).text(),z=X.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),L=z?z[1]:"",Y=X.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),j={...B,__filename:q,__dirname:b.dirname(q)};if(L.trim())await R(L,j,q);let D=f(Y),$=new Set;if(!D.some((w)=>w.type==="suspense")){let w=G.streaming?.strategy||"auto",U=new RegExp(M.source,"g");if(!(w!=="manual"&&U.test(Y))){let F=await H(Y,j,q,G,$);for(let V=0;V<F.length;V+=J)K.enqueue(F.slice(V,V+J)),await new Promise((W)=>setTimeout(W,0))}else{let F=[],V=new RegExp(M.source,"g"),W;while((W=V.exec(Y))!==null)F.push({name:W[1],content:W[2],start:W.index,end:W.index+W[0].length});let y=0;for(let A of F){if(A.start>y){let k=Y.slice(y,A.start);if(k.trim()){let E=await H(k,j,q,G,$);K.enqueue(E),await new Promise((S)=>setTimeout(S,0))}}let I=await H(A.content,j,q,G,$);K.enqueue(I),await new Promise((k)=>setTimeout(k,0)),y=A.end}if(y<Y.length){let A=Y.slice(y);if(A.trim()){let I=await H(A,j,q,G,$);K.enqueue(I)}}}}else{let w=new Map;for(let Z of D)if(Z.type==="shell"||Z.type==="content"){let F=await H(Z.content,j,q,G,$);K.enqueue(F)}else if(Z.type==="suspense"&&Z.name){let F=`stx-suspense-${Z.name}`;K.enqueue(`<div id="${F}" data-suspense="${Z.name}" style="display:contents;">
|
|
3
3
|
<template data-suspense-fallback>Loading...</template>
|
|
4
4
|
</div>`),w.set(Z.name,H(Z.content,j,q,G,$))}K.enqueue(`
|
|
5
5
|
<script>
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{eo as a,fo as b,go as c,ho as d,io as e,jo as f,ko as g,lo as h,mo as i,no as j,oo as k,po as l,qo as m}from"./chunk-k049j105.js";import"./chunk-kzt0ycg7.js";import"./chunk-r2pck10q.js";import"./chunk-278ay77z.js";import"./chunk-fq5d2r74.js";import"./chunk-ant3p5v8.js";import"./chunk-w43x27h2.js";import"./chunk-bf4xr43a.js";import"./chunk-n3kmd544.js";import"./chunk-c1rwzz7v.js";import"./chunk-wzb9q4ta.js";import"./chunk-ncnmb3kq.js";import"./chunk-8ybhs27t.js";import"./chunk-0jznnssx.js";import"./chunk-vqq5zjbg.js";export{m as stripStxRuntimeImports,b as scanScriptTags,l as rewriteStxImportSpecifiers,j as processSignals,h as processScriptSetup,f as preEvalLiteralReactiveIfs,c as parseLoopExpression,d as hasSignalsSyntax,k as findMarkupIndexOutsideScripts,i as extractExports,g as convertSignalLoopsToAttributes,e as convertSignalDirectivesToAttributes,a as clearScriptScanCache};
|