@stacksjs/stx 0.2.723 → 0.2.726
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-xhzqv5h9.js → chunk-10gwxztv.js} +2 -2
- package/dist/{chunk-a7ytatj3.js → chunk-28nbcn4j.js} +1 -1
- package/dist/chunk-2z9e5p7x.js +2 -0
- package/dist/{chunk-p545mp8h.js → chunk-4j2t024b.js} +1 -1
- package/dist/{chunk-bepd7hzm.js → chunk-5bfzvtqp.js} +1 -1
- package/dist/{chunk-3pqnreg6.js → chunk-5wje2046.js} +1 -1
- package/dist/{chunk-bs4hjp54.js → chunk-5yxqf776.js} +1 -1
- package/dist/{chunk-ebeafpvn.js → chunk-6nzevj72.js} +1 -1
- package/dist/{chunk-m03k1xcn.js → chunk-6vs9qxr8.js} +1 -1
- package/dist/{chunk-0hta0m1m.js → chunk-73jgx8ae.js} +1 -1
- package/dist/{chunk-469799fs.js → chunk-7g2f0fqq.js} +2 -2
- package/dist/{chunk-2kyzfn3x.js → chunk-7jztw5cx.js} +1 -1
- package/dist/{chunk-c9zwy7ra.js → chunk-7mjecv1n.js} +1 -1
- package/dist/chunk-7yjw9xm8.js +2 -0
- package/dist/{chunk-1jrthmg8.js → chunk-8tb2tfv2.js} +4 -4
- package/dist/chunk-adgqcd6b.js +2 -0
- package/dist/chunk-ap9m4885.js +2 -0
- package/dist/{chunk-3qrnbqrf.js → chunk-bfzmpe10.js} +1 -1
- package/dist/{chunk-dj4f04rd.js → chunk-bsvf1zmg.js} +1 -1
- package/dist/chunk-bzqy0fwx.js +3 -0
- package/dist/{chunk-jhmexxdt.js → chunk-c17sd8hh.js} +1 -1
- package/dist/{chunk-93pg3gxy.js → chunk-c1ndk2d7.js} +1 -1
- package/dist/chunk-dbxm66yb.js +2 -0
- package/dist/{chunk-sxhtcy4d.js → chunk-dyvy8n50.js} +1 -1
- package/dist/{chunk-rfyad28t.js → chunk-e2szbeh4.js} +1 -1
- package/dist/chunk-fk0qv372.js +2 -0
- package/dist/{chunk-aapb2aj4.js → chunk-fszrmstt.js} +1 -1
- package/dist/chunk-g357b110.js +2 -0
- package/dist/{chunk-jr977nvv.js → chunk-gjj9shb2.js} +1 -1
- package/dist/{chunk-bgrd7e2m.js → chunk-hfyjtgsh.js} +1 -1
- package/dist/{chunk-0vp4xgcw.js → chunk-hgzh0yad.js} +1 -1
- package/dist/{chunk-fgsnn1qx.js → chunk-hyreq9bq.js} +2 -2
- package/dist/{chunk-sw5pcraj.js → chunk-jajnchh8.js} +1 -1
- package/dist/{chunk-pknwkcz7.js → chunk-jgywz5k0.js} +22 -22
- package/dist/{chunk-fjjjcepz.js → chunk-jpr3npq4.js} +1 -1
- package/dist/{chunk-yzvnpyjm.js → chunk-k4dzsnfh.js} +1 -1
- package/dist/chunk-kc38t7q5.js +2 -0
- package/dist/chunk-mck1zppb.js +2 -0
- package/dist/{chunk-vx496vb1.js → chunk-mp4518w9.js} +1 -1
- package/dist/{chunk-skenfh9x.js → chunk-na0w7js8.js} +5 -5
- package/dist/{chunk-wpjhkx3t.js → chunk-phxqwskq.js} +4 -4
- package/dist/{chunk-nyag265f.js → chunk-pmbgny9j.js} +1 -1
- package/dist/{chunk-f5n4gck8.js → chunk-qphdhsjb.js} +1 -1
- package/dist/{chunk-k6eeaya4.js → chunk-r7gvv38b.js} +1 -1
- package/dist/{chunk-85bav773.js → chunk-rkmaksfp.js} +5 -5
- package/dist/chunk-rt8z92yc.js +2 -0
- package/dist/{chunk-agxf0h40.js → chunk-saw5wtf8.js} +1 -1
- package/dist/{chunk-w1tac80w.js → chunk-t1jh07km.js} +1 -1
- package/dist/{chunk-yb4kwfyk.js → chunk-t20wm54c.js} +1 -1
- package/dist/{chunk-s3077g8h.js → chunk-t278dq7n.js} +1 -1
- package/dist/{chunk-t6m74mpb.js → chunk-t8y83pqq.js} +1 -1
- package/dist/{chunk-rf2pqe49.js → chunk-tj50xwha.js} +1 -1
- package/dist/{chunk-jrycb3h1.js → chunk-v0ypxnpg.js} +3 -3
- package/dist/{chunk-c2mvmfzx.js → chunk-wgdeyyh3.js} +2 -2
- package/dist/{chunk-86nv7tj9.js → chunk-wqh69t0r.js} +1 -1
- package/dist/{chunk-k70xy1ex.js → chunk-wxqgfymd.js} +1 -1
- package/dist/{chunk-h9rkzmm5.js → chunk-x7xscv4q.js} +1 -1
- package/dist/{chunk-eb9k5kd6.js → chunk-xebwgqam.js} +3 -3
- package/dist/{chunk-sfvs6akz.js → chunk-xzk1dfvr.js} +1 -1
- package/dist/{chunk-2377988v.js → chunk-yd5v5pc1.js} +1 -1
- package/dist/{chunk-qekjfxyy.js → chunk-z020cr6a.js} +1 -1
- package/dist/{chunk-g0rrfadp.js → chunk-zme7xdnw.js} +2 -2
- package/dist/{chunk-md9h1vq2.js → chunk-zzkfs79f.js} +1 -1
- package/dist/cli.js +7 -7
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/native/runtime/craft.d.ts +1 -1
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +2 -2
- package/dist/types/config-types.d.ts +1 -0
- package/dist/utils.js +5 -0
- package/package.json +5 -5
- package/dist/chunk-01gqepb6.js +0 -2
- package/dist/chunk-10j9mzw1.js +0 -2
- package/dist/chunk-3abjyqbr.js +0 -2
- package/dist/chunk-4dnsjs3g.js +0 -2
- package/dist/chunk-6dfj8r4p.js +0 -2
- package/dist/chunk-bstrjgqy.js +0 -3
- package/dist/chunk-c8tefpc1.js +0 -2
- package/dist/chunk-m8aky4kp.js +0 -2
- package/dist/chunk-njs1az59.js +0 -2
- package/dist/chunk-rycv5n90.js +0 -2
- package/dist/chunk-wzs6qdpp.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Yn,$e}from"./chunk-1xjv71dw.js";import{z,w,gr,Cs,C}from"./chunk-pknwkcz7.js";import{a,P}from"./chunk-g0rrfadp.js";import{vo}from"./chunk-p545mp8h.js";import{et}from"./chunk-j2mpqa4p.js";import{l}from"./chunk-qc93ce5h.js";import{s,ge}from"./chunk-05qf3e2p.js";import d from"path";import v from"fs";import{AsyncLocalStorage as ht}from"async_hooks";var xt=11;function X(t,e,n){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(d.basename(t))||vo(t,e,n)}var at=2;function tf(t){let e=process.env.STX_BUNDLE_CACHE_DIR?.trim();return e?d.resolve(e):l(t,"bundle-cache")}function st(t,e){let n=t;for(let i of $t(e))if(i!==d.sep)n=n.split(i).join("\x00root");return n}var rt=new Map;function $t(t){let e=d.resolve(t),n=rt.get(e);if(!n){let i=e;try{i=v.realpathSync(e)}catch{}n=[...new Set([e,i])].sort((u,m)=>m.length-u.length),rt.set(e,n)}return n}function yt(t,e){try{let n=v.statSync(t),i=d.resolve(e),u=t.startsWith(`${i}${d.sep}`);return{path:u?d.relative(i,t):t,...u?{inRoot:!0}:{},mtimeMs:n.mtimeMs,size:n.size,hash:Bun.hash(v.readFileSync(t)).toString(36)}}catch{return null}}function ct(t,e){return t.inRoot?d.join(d.resolve(e),t.path):t.path}function bt(t,e){for(let n of t){let i=ct(n,e);try{let u=v.statSync(i);if(u.size!==n.size)return!1;if(u.mtimeMs!==n.mtimeMs&&Bun.hash(v.readFileSync(i)).toString(36)!==n.hash)return!1}catch{return!1}}return!0}var lt=new Map,wt=100;function nf(t=process.env){let e=Number(t.STX_BUNDLE_CACHE_LIMIT);return Number.isFinite(e)&&e>=1?Math.floor(e):2000}var G=new Map;async function St(t){let e=G.get(t)??0;if(e>0&&e<wt){G.set(t,e+1);return}G.set(t,1);try{let n=(await v.promises.readdir(t)).filter((c)=>c.endsWith(".js")),i=nf();if(n.length<=i)return;let m=(await Promise.all(n.map(async(c)=>{try{return{name:c,at:(await v.promises.stat(d.join(t,c))).mtimeMs}}catch{return null}}))).filter((c)=>c!==null);m.sort((c,y)=>y.at-c.at);for(let c of m.slice(i)){let y=c.name.slice(0,-3);await v.promises.rm(d.join(t,`${y}.js`),{force:!0}),await v.promises.rm(d.join(t,`${y}.deps.json`),{force:!0})}D("pruned bundle cache to",i,"entries")}catch{}}function Te(t){return lt.get(t)??[]}function q(t,e){if(t)lt.set(t,e)}function rf(t=process.env){return t.STX_DEBUG==="true"||t.STX_DEBUG==="1"}function D(...t){if(rf())console.log("[stx:bundler]",...t)}var Y=[];function Ba(t,e,n){Y.push({filePath:t||"<inline>",message:e,details:n})}function Yt(){return Y.slice()}function Zt(){Y.length=0}var Z;function Gm(t){Z=t}function Fa(){if(Z)return Z;try{let t=P.strict;return typeof t==="object"&&t!==null?t.bundlerFallback??"warn":"warn"}catch{return"warn"}}var Q=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function Qt(t){let e=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,n;while((n=e.exec(t))!==null){let u=n[1];if(!Q.some((c)=>c.test(u)))return D("detected user import:",u),!0}let i=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((n=i.exec(t))!==null){let u=n[1];if(/\.css(?:\?.*)?$/.test(u))continue;if(!Q.some((c)=>c.test(u)))return D("detected side-effect import:",u),!0}return!1}var Jn="stx-module:",vt=/\.(?:[cm]?[jt]sx?|json)$/i;function sf(t,e){return d.relative(t,e).split(d.sep).join("/")}function of(t,e){if(e.size===0)return t;return t.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(n,i,u,m)=>{let c=e.get(m);return c&&!m.startsWith(Jn)?`${i}${u}${c}${u}`:n})}function af(t,e){let n=0,i=(m)=>{let c=`__stxMod${n++}`,y=JSON.stringify(m);return e.push(`var ${c} = globalThis.__stxModules && globalThis.__stxModules[${y}];`,`if (${c} === undefined) throw new Error("[stx] module " + ${JSON.stringify(y)} + " is not registered on this page (#1957)");`),c},u=(m,c)=>{for(let y of m.split(",")){let R=y.trim();if(!R)continue;let B=R.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!B)continue;let j=B[1].startsWith('"')?JSON.parse(B[1]):B[1],p=B[2]??j;e.push(`var ${p} = ${c}[${JSON.stringify(j)}];`)}};return t=t.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(m,c,y)=>{let R=y.slice(Jn.length),B=i(R),j=c.trim(),p=j.match(/^([\w$]+)\s*(?:,\s*|$)/);if(p&&!j.startsWith("{")&&!j.startsWith("*"))e.push(`var ${p[1]} = ${B}.default;`),j=j.slice(p[0].length).trim();let r=j.match(/^\*\s*as\s+([\w$]+)$/);if(r)e.push(`var ${r[1]} = ${B};`);else if(j.startsWith("{"))u(j.replace(/^\{|\}$/g,""),B);return""}),t=t.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(m,c)=>(i(c.slice(Jn.length)),"")),t}function it(t){let e=[t,`${t}.ts`,`${t}.tsx`,`${t}.js`,`${t}.mjs`,`${t}.jsx`,d.join(t,"index.ts"),d.join(t,"index.tsx"),d.join(t,"index.js"),d.join(t,"index.mjs")];for(let n of e)try{if(v.existsSync(n)&&v.statSync(n,{throwIfNoEntry:!1})?.isFile())return n}catch{}return}var K=new ht;function mo(t,e){let n=new Bun.CryptoHasher("md5");for(let[i,u]of[...t].sort(([m],[c])=>m<c?-1:m>c?1:0))n.update(`${i}\x00${u}\x00`);return K.run({modules:t,key:n.digest("hex").slice(0,12)},e)}function en(){return K.getStore()?.key??""}function Bt(t,e,n,i,u,m,c=new Map,y,R){let B=(p,r,o)=>{if(X(r,t,y))return null;if(!m||p!==n||!vt.test(r))return null;try{if(!v.statSync(r,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}u.add(r);let b=`${Jn}${sf(process.cwd(),r)}`;return c.set(o,b),{path:b,external:!0}},j=(p,r)=>{let o=p===n?e:d.dirname(p),b=d.resolve(o,r);return it(b)??b};return{name:"stx-client-bundle",setup(p){if(p.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(r)=>({path:r.path,external:!0})),p.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(r)=>({path:r.path,external:!0})),p.onResolve({filter:/^\//},(r)=>{if(r.path===n)return{path:n};let o=it(r.path);if(o){let b=B(r.importer,o,r.path);if(b)return b;if(o!==n)u.add(o);return{path:o}}return{path:r.path,external:!0}}),p.onResolve({filter:/^\.\.?\//},(r)=>{let o=j(r.importer,r.path),b=B(r.importer,o,r.path);if(b)return b;return u.add(o),{path:o}}),p.onResolve({filter:/^[@~]\//},(r)=>{let o=d.resolve(t,r.path.slice(2)),b=[o,`${o}.ts`,`${o}.tsx`,`${o}.js`,`${o}.mjs`,`${o}.jsx`,d.join(o,"index.ts"),d.join(o,"index.tsx"),d.join(o,"index.js"),d.join(o,"index.mjs")];for(let x of b)if(v.existsSync(x)&&v.statSync(x,{throwIfNoEntry:!1})?.isFile()){let A=B(r.importer,x,r.path);if(A)return A;return D(`resolved ${r.path[0]}/ import:`,r.path,"\u2192",x),u.add(x),{path:x}}return console.warn(`[stx:bundler] could not resolve ${r.path[0]}/ import:`,r.path),{path:o}}),m)p.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(r)=>{if(r.importer!==n)return;let o=`${Jn}npm:${r.path}`;return c.set(r.path,o),{path:o,external:!0}});p.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(r)=>{if(r.path===n)return{contents:i,loader:"ts"};if(X(r.path,t,y))throw Error(`Server-only API source cannot be imported by a client script: ${r.path}`);let o=d.extname(r.path).toLowerCase(),b=o===".json"?"json":o===".tsx"?"tsx":o===".jsx"?"jsx":o===".ts"||o===".mts"||o===".cts"?"ts":"js";if(r.path!==n)u.add(r.path);let x=R?.get(r.path);if(x!==void 0)return{contents:x,loader:"js"};return{contents:v.readFileSync(r.path,"utf8"),loader:b}})}}}var H=new Map,k=w(64),ot=Symbol.for("stx.client-bundle-build-queue");function cf(t){let e=globalThis,i=(e[ot]??Promise.resolve()).then(t,t);return e[ot]=i.then(()=>{return},()=>{return}),i}async function tn(t,e,n={}){let i=n.projectRoot||process.cwd(),u=(await a(i)).serverApi,m=n.minify??!1,c=n.externalizeUserModules??!0,y=n.expose?.length?[...new Set(n.expose)].sort():void 0,R=n.cacheDir||tf(i),B=K.getStore(),j=new Bun.CryptoHasher("md5");j.update(`${xt}\x00${et()}\x00${JSON.stringify(u??!1)}\x00${c?"registry":"inline"}\x00${y?y.join(","):"*"}\x00${m?"minified":"readable"}\x00${B?.key??""}\x00${st(t,i)}\x00${st(e,i)}`);let p=j.digest("hex").slice(0,12),r=d.join(R,`${p}.js`),o=k.get(r);if(o){if(Cs(o.files)&&o.files.every((M)=>!X(M.path,i,u))){D("memo hit:",p);let M=o.files.map((O)=>O.path);return q(e,M),n.collectInputs?.push(...M),o.code}k.delete(r),D("memo invalidated by dep change:",p)}let b=d.join(R,`${p}.deps.json`),x=Bun.file(r);if(await x.exists()){let M=Bun.file(b),O=!1,I=null;if(await M.exists())try{let F=JSON.parse(await M.text());if(F.metadataVersion===at&&Array.isArray(F.files)&&bt(F.files,i))I=gr(F.files.map((g)=>ct(g,i))),O=I.length===F.files.length&&!I.some((g)=>X(g.path,i,u))}catch{O=!1}if(O){if(D("cache hit:",p),I)q(e,I.map((T)=>T.path)),n.collectInputs?.push(...I.map((T)=>T.path));let F=await x.text(),g=new Date;if(v.promises.utimes(r,g,g).catch(()=>{}),I)k.set(r,{code:F,files:I});return F}D("cache invalidated by dep change:",p)}let A=H.get(p);if(A){let M=await A;if(n.collectInputs)n.collectInputs.push(...(k.get(r)?.files??[]).map((O)=>O.path));return M}let V=cf(()=>_t(t,e,{projectRoot:i,minify:m,cacheDir:R,hash:p,cachePath:r,depsPath:b,collectInputs:n.collectInputs,externalizeUserModules:c,serverApi:u,expose:y,throwOnFailure:n.throwOnFailure,substitutes:B?.modules}));H.set(p,V);try{return await V}finally{H.delete(p)}}var jt=0;function lf(t){return`${t}-${process.pid}-${++jt}`}async function _t(t,e,n){let{projectRoot:i,minify:u,cacheDir:m,hash:c,cachePath:y,depsPath:R,externalizeUserModules:B}=n,j=l(i,"bundle-tmp"),p=lf(c),r=d.join(i,`.stx-client-${p}.ts`),o=d.join(j,"out",p);v.mkdirSync(o,{recursive:!0});let b=d.dirname(e),x=new Set,A=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,V=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,M=s(t),{depths:O,balanced:I}=ge(M),F=(_)=>!I||O[_]===0,g;while((g=A.exec(M))!==null){if(g[1])continue;if(!F(g.index))continue;if(g[2])g[2].split(",").forEach((_)=>{let f=Et(_);if(f)x.add(f)});else if(g[3])x.add(g[3])}while((g=V.exec(M))!==null){if(g[1])continue;if(!F(g.index))continue;x.add(g[2])}let T=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((g=T.exec(M))!==null){if(!F(g.index))continue;let _=/^\s*['"]([^'"]+)['"]/.exec(t.slice(g.index+g[0].length))?.[1];if(_&&Q.some((f)=>f.test(_)))continue;if(g[1])x.add(g[1]);if(g[2])x.add(g[2]);for(let f of(g[3]??"").split(",")){let S=f.trim();if(!S||/^type\s/.test(S))continue;let L=/\bas\s+(\w+)\s*$/.exec(S)?.[1]??/^\w+$/.exec(S)?.[0];if(L)x.add(L)}}for(let _ of M.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let f of _[1].split(",")){let S=/\bas\s+(\w+)\s*$/.exec(f)?.[1]??/^\s*(\w+)\s*$/.exec(f)?.[1];if(S)x.delete(S)}let ut=x.size>0?`
|
|
2
|
+
import{Yn,$e}from"./chunk-1xjv71dw.js";import{z,w,gr,Cs,C}from"./chunk-jgywz5k0.js";import{a,P}from"./chunk-zme7xdnw.js";import{vo}from"./chunk-4j2t024b.js";import{et}from"./chunk-j2mpqa4p.js";import{l}from"./chunk-qc93ce5h.js";import{s,ge}from"./chunk-05qf3e2p.js";import d from"path";import v from"fs";import{AsyncLocalStorage as ht}from"async_hooks";var xt=11;function X(t,e,n){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(d.basename(t))||vo(t,e,n)}var at=2;function tf(t){let e=process.env.STX_BUNDLE_CACHE_DIR?.trim();return e?d.resolve(e):l(t,"bundle-cache")}function st(t,e){let n=t;for(let i of $t(e))if(i!==d.sep)n=n.split(i).join("\x00root");return n}var rt=new Map;function $t(t){let e=d.resolve(t),n=rt.get(e);if(!n){let i=e;try{i=v.realpathSync(e)}catch{}n=[...new Set([e,i])].sort((u,m)=>m.length-u.length),rt.set(e,n)}return n}function yt(t,e){try{let n=v.statSync(t),i=d.resolve(e),u=t.startsWith(`${i}${d.sep}`);return{path:u?d.relative(i,t):t,...u?{inRoot:!0}:{},mtimeMs:n.mtimeMs,size:n.size,hash:Bun.hash(v.readFileSync(t)).toString(36)}}catch{return null}}function ct(t,e){return t.inRoot?d.join(d.resolve(e),t.path):t.path}function bt(t,e){for(let n of t){let i=ct(n,e);try{let u=v.statSync(i);if(u.size!==n.size)return!1;if(u.mtimeMs!==n.mtimeMs&&Bun.hash(v.readFileSync(i)).toString(36)!==n.hash)return!1}catch{return!1}}return!0}var lt=new Map,wt=100;function nf(t=process.env){let e=Number(t.STX_BUNDLE_CACHE_LIMIT);return Number.isFinite(e)&&e>=1?Math.floor(e):2000}var G=new Map;async function St(t){let e=G.get(t)??0;if(e>0&&e<wt){G.set(t,e+1);return}G.set(t,1);try{let n=(await v.promises.readdir(t)).filter((c)=>c.endsWith(".js")),i=nf();if(n.length<=i)return;let m=(await Promise.all(n.map(async(c)=>{try{return{name:c,at:(await v.promises.stat(d.join(t,c))).mtimeMs}}catch{return null}}))).filter((c)=>c!==null);m.sort((c,y)=>y.at-c.at);for(let c of m.slice(i)){let y=c.name.slice(0,-3);await v.promises.rm(d.join(t,`${y}.js`),{force:!0}),await v.promises.rm(d.join(t,`${y}.deps.json`),{force:!0})}D("pruned bundle cache to",i,"entries")}catch{}}function Te(t){return lt.get(t)??[]}function q(t,e){if(t)lt.set(t,e)}function rf(t=process.env){return t.STX_DEBUG==="true"||t.STX_DEBUG==="1"}function D(...t){if(rf())console.log("[stx:bundler]",...t)}var Y=[];function Ba(t,e,n){Y.push({filePath:t||"<inline>",message:e,details:n})}function Yt(){return Y.slice()}function Zt(){Y.length=0}var Z;function Gm(t){Z=t}function Fa(){if(Z)return Z;try{let t=P.strict;return typeof t==="object"&&t!==null?t.bundlerFallback??"warn":"warn"}catch{return"warn"}}var Q=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function Qt(t){let e=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,n;while((n=e.exec(t))!==null){let u=n[1];if(!Q.some((c)=>c.test(u)))return D("detected user import:",u),!0}let i=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((n=i.exec(t))!==null){let u=n[1];if(/\.css(?:\?.*)?$/.test(u))continue;if(!Q.some((c)=>c.test(u)))return D("detected side-effect import:",u),!0}return!1}var Jn="stx-module:",vt=/\.(?:[cm]?[jt]sx?|json)$/i;function sf(t,e){return d.relative(t,e).split(d.sep).join("/")}function of(t,e){if(e.size===0)return t;return t.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(n,i,u,m)=>{let c=e.get(m);return c&&!m.startsWith(Jn)?`${i}${u}${c}${u}`:n})}function af(t,e){let n=0,i=(m)=>{let c=`__stxMod${n++}`,y=JSON.stringify(m);return e.push(`var ${c} = globalThis.__stxModules && globalThis.__stxModules[${y}];`,`if (${c} === undefined) throw new Error("[stx] module " + ${JSON.stringify(y)} + " is not registered on this page (#1957)");`),c},u=(m,c)=>{for(let y of m.split(",")){let R=y.trim();if(!R)continue;let B=R.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!B)continue;let j=B[1].startsWith('"')?JSON.parse(B[1]):B[1],p=B[2]??j;e.push(`var ${p} = ${c}[${JSON.stringify(j)}];`)}};return t=t.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(m,c,y)=>{let R=y.slice(Jn.length),B=i(R),j=c.trim(),p=j.match(/^([\w$]+)\s*(?:,\s*|$)/);if(p&&!j.startsWith("{")&&!j.startsWith("*"))e.push(`var ${p[1]} = ${B}.default;`),j=j.slice(p[0].length).trim();let r=j.match(/^\*\s*as\s+([\w$]+)$/);if(r)e.push(`var ${r[1]} = ${B};`);else if(j.startsWith("{"))u(j.replace(/^\{|\}$/g,""),B);return""}),t=t.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(m,c)=>(i(c.slice(Jn.length)),"")),t}function it(t){let e=[t,`${t}.ts`,`${t}.tsx`,`${t}.js`,`${t}.mjs`,`${t}.jsx`,d.join(t,"index.ts"),d.join(t,"index.tsx"),d.join(t,"index.js"),d.join(t,"index.mjs")];for(let n of e)try{if(v.existsSync(n)&&v.statSync(n,{throwIfNoEntry:!1})?.isFile())return n}catch{}return}var K=new ht;function mo(t,e){let n=new Bun.CryptoHasher("md5");for(let[i,u]of[...t].sort(([m],[c])=>m<c?-1:m>c?1:0))n.update(`${i}\x00${u}\x00`);return K.run({modules:t,key:n.digest("hex").slice(0,12)},e)}function en(){return K.getStore()?.key??""}function Bt(t,e,n,i,u,m,c=new Map,y,R){let B=(p,r,o)=>{if(X(r,t,y))return null;if(!m||p!==n||!vt.test(r))return null;try{if(!v.statSync(r,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}u.add(r);let b=`${Jn}${sf(process.cwd(),r)}`;return c.set(o,b),{path:b,external:!0}},j=(p,r)=>{let o=p===n?e:d.dirname(p),b=d.resolve(o,r);return it(b)??b};return{name:"stx-client-bundle",setup(p){if(p.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(r)=>({path:r.path,external:!0})),p.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(r)=>({path:r.path,external:!0})),p.onResolve({filter:/^\//},(r)=>{if(r.path===n)return{path:n};let o=it(r.path);if(o){let b=B(r.importer,o,r.path);if(b)return b;if(o!==n)u.add(o);return{path:o}}return{path:r.path,external:!0}}),p.onResolve({filter:/^\.\.?\//},(r)=>{let o=j(r.importer,r.path),b=B(r.importer,o,r.path);if(b)return b;return u.add(o),{path:o}}),p.onResolve({filter:/^[@~]\//},(r)=>{let o=d.resolve(t,r.path.slice(2)),b=[o,`${o}.ts`,`${o}.tsx`,`${o}.js`,`${o}.mjs`,`${o}.jsx`,d.join(o,"index.ts"),d.join(o,"index.tsx"),d.join(o,"index.js"),d.join(o,"index.mjs")];for(let x of b)if(v.existsSync(x)&&v.statSync(x,{throwIfNoEntry:!1})?.isFile()){let A=B(r.importer,x,r.path);if(A)return A;return D(`resolved ${r.path[0]}/ import:`,r.path,"\u2192",x),u.add(x),{path:x}}return console.warn(`[stx:bundler] could not resolve ${r.path[0]}/ import:`,r.path),{path:o}}),m)p.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(r)=>{if(r.importer!==n)return;let o=`${Jn}npm:${r.path}`;return c.set(r.path,o),{path:o,external:!0}});p.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(r)=>{if(r.path===n)return{contents:i,loader:"ts"};if(X(r.path,t,y))throw Error(`Server-only API source cannot be imported by a client script: ${r.path}`);let o=d.extname(r.path).toLowerCase(),b=o===".json"?"json":o===".tsx"?"tsx":o===".jsx"?"jsx":o===".ts"||o===".mts"||o===".cts"?"ts":"js";if(r.path!==n)u.add(r.path);let x=R?.get(r.path);if(x!==void 0)return{contents:x,loader:"js"};return{contents:v.readFileSync(r.path,"utf8"),loader:b}})}}}var H=new Map,k=w(64),ot=Symbol.for("stx.client-bundle-build-queue");function cf(t){let e=globalThis,i=(e[ot]??Promise.resolve()).then(t,t);return e[ot]=i.then(()=>{return},()=>{return}),i}async function tn(t,e,n={}){let i=n.projectRoot||process.cwd(),u=(await a(i)).serverApi,m=n.minify??!1,c=n.externalizeUserModules??!0,y=n.expose?.length?[...new Set(n.expose)].sort():void 0,R=n.cacheDir||tf(i),B=K.getStore(),j=new Bun.CryptoHasher("md5");j.update(`${xt}\x00${et()}\x00${JSON.stringify(u??!1)}\x00${c?"registry":"inline"}\x00${y?y.join(","):"*"}\x00${m?"minified":"readable"}\x00${B?.key??""}\x00${st(t,i)}\x00${st(e,i)}`);let p=j.digest("hex").slice(0,12),r=d.join(R,`${p}.js`),o=k.get(r);if(o){if(Cs(o.files)&&o.files.every((M)=>!X(M.path,i,u))){D("memo hit:",p);let M=o.files.map((O)=>O.path);return q(e,M),n.collectInputs?.push(...M),o.code}k.delete(r),D("memo invalidated by dep change:",p)}let b=d.join(R,`${p}.deps.json`),x=Bun.file(r);if(await x.exists()){let M=Bun.file(b),O=!1,I=null;if(await M.exists())try{let F=JSON.parse(await M.text());if(F.metadataVersion===at&&Array.isArray(F.files)&&bt(F.files,i))I=gr(F.files.map((g)=>ct(g,i))),O=I.length===F.files.length&&!I.some((g)=>X(g.path,i,u))}catch{O=!1}if(O){if(D("cache hit:",p),I)q(e,I.map((T)=>T.path)),n.collectInputs?.push(...I.map((T)=>T.path));let F=await x.text(),g=new Date;if(v.promises.utimes(r,g,g).catch(()=>{}),I)k.set(r,{code:F,files:I});return F}D("cache invalidated by dep change:",p)}let A=H.get(p);if(A){let M=await A;if(n.collectInputs)n.collectInputs.push(...(k.get(r)?.files??[]).map((O)=>O.path));return M}let V=cf(()=>_t(t,e,{projectRoot:i,minify:m,cacheDir:R,hash:p,cachePath:r,depsPath:b,collectInputs:n.collectInputs,externalizeUserModules:c,serverApi:u,expose:y,throwOnFailure:n.throwOnFailure,substitutes:B?.modules}));H.set(p,V);try{return await V}finally{H.delete(p)}}var jt=0;function lf(t){return`${t}-${process.pid}-${++jt}`}async function _t(t,e,n){let{projectRoot:i,minify:u,cacheDir:m,hash:c,cachePath:y,depsPath:R,externalizeUserModules:B}=n,j=l(i,"bundle-tmp"),p=lf(c),r=d.join(i,`.stx-client-${p}.ts`),o=d.join(j,"out",p);v.mkdirSync(o,{recursive:!0});let b=d.dirname(e),x=new Set,A=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,V=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,M=s(t),{depths:O,balanced:I}=ge(M),F=(_)=>!I||O[_]===0,g;while((g=A.exec(M))!==null){if(g[1])continue;if(!F(g.index))continue;if(g[2])g[2].split(",").forEach((_)=>{let f=Et(_);if(f)x.add(f)});else if(g[3])x.add(g[3])}while((g=V.exec(M))!==null){if(g[1])continue;if(!F(g.index))continue;x.add(g[2])}let T=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((g=T.exec(M))!==null){if(!F(g.index))continue;let _=/^\s*['"]([^'"]+)['"]/.exec(t.slice(g.index+g[0].length))?.[1];if(_&&Q.some((f)=>f.test(_)))continue;if(g[1])x.add(g[1]);if(g[2])x.add(g[2]);for(let f of(g[3]??"").split(",")){let S=f.trim();if(!S||/^type\s/.test(S))continue;let L=/\bas\s+(\w+)\s*$/.exec(S)?.[1]??/^\w+$/.exec(S)?.[0];if(L)x.add(L)}}for(let _ of M.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let f of _[1].split(",")){let S=/\bas\s+(\w+)\s*$/.exec(f)?.[1]??/^\s*(\w+)\s*$/.exec(f)?.[1];if(S)x.delete(S)}let ut=x.size>0?`
|
|
3
3
|
export { ${[...x].join(", ")} }`:"";D("bundling:",c,"from:",d.basename(e));let tt=new Set,nt=new Map;try{let _=await Bun.build({entrypoints:[r],outdir:o,target:"browser",format:"esm",minify:u?{whitespace:!1,identifiers:!0,syntax:!0}:!1,plugins:[Bt(i,b,r,t+ut,tt,B,nt,n.serverApi,n.substitutes)],define:{"process.env.NODE_ENV":u?'"production"':'"development"',...C()},root:i});if(!_.success){let E=_.logs.filter((N)=>N.level==="error").map((N)=>N.message).join(", ")||`Unable to bundle ${d.basename(e)}`,U=Yn(_.logs,e||void 0);if(console.warn("[stx:bundler] build failed:",E),Ba(e||"",E,U),n.throwOnFailure||Fa()==="error")throw Error(E);return t}let f="";for(let h of _.outputs){f=await h.text();break}let S=[];for(let h of f.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let E of h[1].split(",")){let U=E.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(U){S.push([U[2],U[1]]);continue}let N=E.trim();if(/^[A-Za-z_$][\w$]*$/.test(N))S.push([N,N])}if(n.expose){let h=new Set(n.expose);for(let E=S.length-1;E>=0;E--)if(!h.has(S[E][0]))S.splice(E,1)}let L=[];f=af(of(f,nt),L);let dt=f.match(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm)||[];if(f=f.replace(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim(),u&&f)try{f=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(f)}catch{}let J=`__stxBundle_${c}`,pt=new Set(z(t,!0).split(",").map((h)=>h.trim())),ft=S.map(([h,E])=>`get ${JSON.stringify(h)}() { return ${E} }${pt.has(h)?`, set ${JSON.stringify(h)}(__stxValue_${E}) { ${E} = __stxValue_${E} }`:""}`).join(", "),mt=S.map(([h])=>`var ${h} = undefined;`).join(`
|
|
4
4
|
`),gt=S.map(([h])=>`${h} = ${J}[${JSON.stringify(h)}];`).join(`
|
|
5
5
|
`);if(f=`${dt.join(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{nn,ho,yo,bo,Xm,vo}from"./chunk-
|
|
2
|
+
import{nn,ho,yo,bo,Xm,vo}from"./chunk-4j2t024b.js";import"./chunk-3fwdxxh1.js";import"./chunk-2mqzpzy7.js";import"./chunk-rbmt5w9v.js";export{yo as buildServerApi,Xm as createServerApi,nn as discoverServerApi,ho as generateApiTypes,vo as isServerApiSource,bo as productionApiDispatcher};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{wg}from"./chunk-saw5wtf8.js";import"./chunk-rkmaksfp.js";import"./chunk-wgdeyyh3.js";import"./chunk-x9wwd2ee.js";import"./chunk-73jgx8ae.js";import"./chunk-8tb2tfv2.js";import"./chunk-t8y83pqq.js";import"./chunk-bzqy0fwx.js";import"./chunk-r3j4m04w.js";import"./chunk-7g2f0fqq.js";import"./chunk-phxqwskq.js";import"./chunk-m5nzpjej.js";import"./chunk-6vs9qxr8.js";import"./chunk-zme7xdnw.js";import"./chunk-5bfzvtqp.js";import"./chunk-4c86wr9a.js";import"./chunk-3fwdxxh1.js";import"./chunk-q7fh1xka.js";import"./chunk-2mqzpzy7.js";import"./chunk-jgywz5k0.js";import"./chunk-pmbgny9j.js";import"./chunk-rbmt5w9v.js";import"./chunk-zkx2m308.js";import"./chunk-zn3c0ew5.js";import"./chunk-ez35607j.js";export{wg as startInteractive};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{_}from"./chunk-ez35607j.js";import{we,At,Go,Xo,mc,hc,yc,bc,Ts,Yo,vc,wc,xc,gn}from"./chunk-
|
|
2
|
+
import{_}from"./chunk-ez35607j.js";import{we,At,Go,Xo,mc,hc,yc,bc,Ts,Yo,vc,wc,xc,gn}from"./chunk-jgywz5k0.js";import{a}from"./chunk-zme7xdnw.js";import{so}from"./chunk-qphdhsjb.js";import{l}from"./chunk-qc93ce5h.js";import{existsSync as M,readFileSync as K}from"fs";import h from"path";var ge=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),ee=gn.filter((e)=>!ge.has(e)).sort(),te=[..._].sort(),me=[...new Set([...ee,...te])].sort(),he=new Set(ee),be=new Set(te),ye=new Set(me),Y=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function xe(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ne(e,t){let s=[];for(let u of t){if(u.offset===void 0)continue;let i=u.kind==="server"?he:be;Y.lastIndex=0;for(let c of u.code.matchAll(Y)){let g=c.index+c[0].indexOf("{")+1;for(let m of c[1].matchAll(/[^,]+/g)){let x=m[0];if(/^\s*type\s/.test(x))continue;let y=/^\s*([A-Za-z_$][\w$]*)/.exec(x);if(!y)continue;let r=y[1];if(!ye.has(r)||i.has(r))continue;let f=u.offset+g+m.index+y[0].length-r.length,p=e.slice(0,f),k=p.split(`
|
|
3
3
|
`).length;s.push({line:k,column:f-(p.lastIndexOf(`
|
|
4
4
|
`)+1)+1,offset:f,length:r.length,name:r,kind:u.kind,message:xe(r,u.kind)})}}}return s}import v from"path";var Se="@stacksjs/stx-typescript-plugin";function ke(e,t){let s=v.resolve(e);for(;;){let u=v.join(s,"tsconfig.json");if(t(u))return u;let i=v.dirname(s);if(i===s)return;s=i}}function ie(e,t,s){let u=ke(e,s);if(!u)return;let i=new Set,c=(g)=>{if(i.has(g))return;i.add(g);let m=t(g);if(!m)return;let x=m.compilerOptions?.plugins;if(Array.isArray(x)){let r=x.find((p)=>p?.name===Se),f=Array.isArray(r?.libs)?r.libs.filter((p)=>typeof p==="string"):[];return r?{configPath:g,libs:f.map((p)=>v.resolve(v.dirname(g),p))}:null}let y=typeof m.extends==="string"?[m.extends]:Array.isArray(m.extends)?m.extends:[];for(let r of[...y].reverse()){if(typeof r!=="string"||!r.startsWith("."))continue;let f=v.resolve(v.dirname(g),r.endsWith(".json")?r:`${r}.json`),p=c(f);if(p!==void 0)return p}return};return c(u)??void 0}function bl(e,t="",s=""){let u=e.startLine>1?`
|
|
5
5
|
`.repeat(e.startLine-1):"",i=Yo(e)+Xo(Go(e.code)),c=e.kind==="client"||e.kind==="plain"?yc(t,e.code):"";return Ts(`${u+i}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-zkx2m308.js";import"./chunk-ez35607j.js";import"./chunk-zn3c0ew5.js";import"./chunk-
|
|
2
|
+
import"./chunk-zkx2m308.js";import"./chunk-ez35607j.js";import"./chunk-zn3c0ew5.js";import"./chunk-jgywz5k0.js";import"./chunk-rbmt5w9v.js";import"./chunk-pmbgny9j.js";import"./chunk-4c86wr9a.js";import"./chunk-5bfzvtqp.js";import{l}from"./chunk-qc93ce5h.js";import u from"fs";import m from"path";async function d(e,t={}){let s=Date.now(),n={total:0,passed:0,failed:0,new:0,failures:[],duration:0},i=t.snapshotDir||l(e.root,"story","snapshots");await u.promises.mkdir(i,{recursive:!0});let r=e.storyFiles;if(t.filter&&t.filter.length>0)r=r.filter((a)=>t.filter.some((o)=>a.fileName.toLowerCase().includes(o.toLowerCase())));for(let a of r)await h(a,i,t,n);return n.duration=Date.now()-s,n}async function h(e,t,s,n){let i=e.story;if(!i)return;for(let r of i.variants){n.total++;let a=m.join(t,`${e.id}-${r.id}.snap`),o=g(r.source||""),f=await w(a);if(s.update||!f){let p={storyId:e.id,variantId:r.id,component:e.fileName,timestamp:Date.now(),hash:o};if(await u.promises.writeFile(a,JSON.stringify(p,null,2)),!f)n.new++;n.passed++}else try{let p=await u.promises.readFile(a,"utf-8"),c=JSON.parse(p);if(c.hash===o)n.passed++;else n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:"Snapshot mismatch",difference:y(c.hash,o)})}catch(p){n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:`Error reading snapshot: ${p}`})}}}async function x(e,t={}){return(await d(e,{...t,update:!0})).total}function g(e){let t=0;for(let s=0;s<e.length;s++){let n=e.charCodeAt(s);t=(t<<5)-t+n,t=t&t}return t.toString(16)}function y(e,t){if(e===t)return 0;let s=Math.abs(Number.parseInt(e,16)-Number.parseInt(t,16));return Math.min(s/1e6,1)}async function w(e){try{return await u.promises.access(e),!0}catch{return!1}}function F(e){let t=[];if(t.push(""),t.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"),t.push(" STX Story Visual Regression Tests"),t.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"),t.push(""),e.failures.length>0){t.push(" \u274C Failures:"),t.push("");for(let s of e.failures){if(t.push(` \u2022 ${s.component} / ${s.variantId}`),t.push(` ${s.message}`),s.difference!==void 0)t.push(` Difference: ${(s.difference*100).toFixed(2)}%`);t.push("")}}if(t.push(" Summary:"),t.push(` Total: ${e.total}`),t.push(` Passed: ${e.passed} \u2713`),t.push(` Failed: ${e.failed} \u2717`),e.new>0)t.push(` New: ${e.new} \u26A1`);return t.push(` Time: ${e.duration}ms`),t.push(""),t.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"),t.push(""),t.join(`
|
|
3
3
|
`)}export{F as formatTestResults,d as runVisualTests,x as updateSnapshots};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Zn,i}from"./chunk-rkmaksfp.js";import"./chunk-wgdeyyh3.js";import"./chunk-x9wwd2ee.js";import"./chunk-73jgx8ae.js";import"./chunk-8tb2tfv2.js";import"./chunk-t8y83pqq.js";import"./chunk-bzqy0fwx.js";import"./chunk-r3j4m04w.js";import"./chunk-7g2f0fqq.js";import{be}from"./chunk-phxqwskq.js";import"./chunk-m5nzpjej.js";import"./chunk-6vs9qxr8.js";import"./chunk-zme7xdnw.js";import"./chunk-5bfzvtqp.js";import"./chunk-4c86wr9a.js";import"./chunk-3fwdxxh1.js";import"./chunk-q7fh1xka.js";import"./chunk-2mqzpzy7.js";import{Ie,As,Ps}from"./chunk-jgywz5k0.js";import"./chunk-pmbgny9j.js";import"./chunk-rbmt5w9v.js";import"./chunk-zkx2m308.js";import"./chunk-zn3c0ew5.js";import"./chunk-ez35607j.js";export{Zn as buildModulesTag,be as injectRouterScript,i as processDirectives,As as processJsonDirective,Ps as processOnceDirective,Ie as validateClientScript};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{f,d}from"./chunk-zkx2m308.js";import{J,I,p}from"./chunk-
|
|
2
|
+
import{f,d}from"./chunk-zkx2m308.js";import{J,I,p}from"./chunk-jgywz5k0.js";function z(t,o){let i=1,r=o,e="<template",n="</template";while(r<t.length&&i>0){let s=t.indexOf("<",r);if(s===-1)break;if(r=s,t.startsWith(e,r)&&(r+e.length>=t.length||/[\s>\/]/.test(t[r+e.length]))){i++,r+=e.length;continue}if(t.startsWith(n,r)){let a=t.indexOf(">",r+n.length);if(a!==-1){if(i--,i===0)return a+1;r=a+1;continue}}r++}return i===0?r:-1}var N=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function k(t,o){let i=null;for(let r=o;r<t.length;r++){let e=t[r];if(i){if(e==="\\"){r++;continue}if(e===i)i=null;continue}if(e==='"'||e==="'"){i=e;continue}if(e===">")return r+1}return-1}function B(t,o,i){let r=o.toLowerCase(),e=1,n=i;while(n<t.length){let s=t.indexOf("<",n);if(s===-1)return-1;if(t.startsWith("<!--",s)){let g=t.indexOf("-->",s+4);n=g===-1?t.length:g+3;continue}let a=k(t,s+1);if(a===-1)return-1;let u=t.slice(s,a),c=u.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(c&&c[2].toLowerCase()===r){if(c[1]==="/"){if(e--,e===0)return a}else if(!/\/\s*>$/.test(u))e++}n=a}return-1}function Z(t){let o=[],i=[],r=/\bslot\s*=\s*(?:"([^"]+)"|'([^']+)')/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let l=t.indexOf("-->",n+4);e=l===-1?t.length:l+3;continue}let s=k(t,n+1);if(s===-1)break;let a=t.slice(n,s),u=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!u){e=s;continue}let c=u[2].toLowerCase();if(u[1]==="/"){let l=i.lastIndexOf(c);if(l!==-1)i.splice(l);e=s;continue}let g=/\/\s*>$/.test(a),m=i.length===0?a.match(r):null;if(m){let l=m[1]||m[2],h=a.replace(r,"").replace(/\s+(?=\/?>$)/,"").replace(/\s{2,}/g," "),S=g||N.has(c)?-1:B(t,c,s);if(S===-1)o.push({start:n,end:s,slotName:l,element:h}),e=s;else o.push({start:n,end:S,slotName:l,element:h+t.slice(s,S)}),e=S;continue}if(!g&&!N.has(c)){if(i.push(c),c==="script"||c==="style"){let l=t.toLowerCase().indexOf(`</${c}>`,s);if(l!==-1){e=l;continue}}}e=s}return o}function L(t){let o=[],i=[],r=/^<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>$/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let l=t.indexOf("-->",n+4);e=l===-1?t.length:l+3;continue}let s=k(t,n+1);if(s===-1)break;let a=t.slice(n,s),u=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!u){e=s;continue}let c=u[1]==="/",g=u[2].toLowerCase();if(c){let l=i.lastIndexOf(g);if(l!==-1)i.splice(l);e=s;continue}if(g==="template"&&i.length===0){let l=a.match(r);if(l){let h=z(t,s);if(h!==-1){let S=l[1]||l[2]||l[3];o.push({start:n,end:h,slotName:S,content:t.slice(s,h-11).trim(),propsBinding:l[4]||void 0}),e=h;continue}}}if(!/\/\s*>$/.test(a)&&!N.has(g)){if(i.push(g),g==="script"||g==="style"){let l=t.toLowerCase().indexOf(`</${g}>`,s);if(l!==-1){e=l;continue}}}e=s}return o}function _l(t){let o={default:"",named:new Map},i=t,r=L(t);for(let n of r)o.named.set(n.slotName,{name:n.slotName,content:n.content,propsBinding:n.propsBinding});r.sort((n,s)=>s.start-n.start);for(let n of r)i=i.slice(0,n.start)+i.slice(n.end);let e=Z(i);for(let n of e){let s=o.named.get(n.slotName);if(s)s.content+=n.element;else o.named.set(n.slotName,{name:n.slotName,content:n.element})}for(let n=e.length-1;n>=0;n--){let s=e[n];i=i.slice(0,s.start)+i.slice(s.end)}return o.default=i.trim(),o}function Vg(t){let o=t.match(/name\s*=\s*["']([^"']+)["']/),i=o?o[1]:"",r={},e=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,n;while((n=e.exec(t))!==null)r[n[1]]=n[2];let s=t.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),a=s?s[1].trim():"";return{name:i,props:r,defaultContent:a}}async function Cl(t,o,i,r){if(!t)return i;let e=t.content;if(t.propsBinding&&Object.keys(o).length>0){let n=t.propsBinding.trim(),s={...r},a=new Set,u=new Set;if(n.startsWith("{")&&n.endsWith("}")){let c=n.slice(1,-1).split(",").map((g)=>g.trim()).filter(Boolean);for(let g of c){let[m,l]=g.split(":").map((S)=>S.trim()),h=l||m;if(s[h]=o[m],o[m]!==void 0)u.add(h);else a.add(h)}}else if(s[n]=o,Object.values(o).some((c)=>c===void 0))a.add(n);else u.add(n);e=j(e,s,a,u)}return e}function j(t,o,i,r){return t.replace(/\{\{\s*([^}]+)\s*\}\}/g,(e,n)=>{try{let s=n.trim();if(I(s,i))return e;if(Array.isArray(o.__stx_preserved_client_expressions)&&o.__stx_preserved_client_expressions.includes(s)&&!I(s,r))return e;let a=_(s,o);if(a===void 0)return e;return p(String(a??""))}catch{return`{{ ${n} }}`}})}function _(t,o){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test(t)){let r=t.split("."),e=o;for(let n of r)if(e&&typeof e==="object"&&n in e)e=e[n];else return;return e}let i=t.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(i){let[,r,e,n]=i,s=o[r],a=parseInt(n,10);if(typeof s==="number")switch(e){case"+":return s+a;case"-":return s-a;case"*":return s*a;case"/":return s/a}}try{if(!f(t))return;return d(t,Object.keys(o))(...Object.values(o))}catch{return}}async function El(t,o,i,r){let e=t;e=await W(e,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(a,u,c,g)=>{let m=o.named.get(u),l=g?.trim()||"",h=c||"",S={},E=[],C=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,b;while((b=C.exec(h))!==null){let w=b[1],x=b[2];S[w]=_(x,i),E.push([w,x])}if(r!==void 0&&m?.propsBinding&&Object.values(S).some((w)=>w===void 0)){let w=m.propsBinding.trim(),x=J(`${w} in []`),y="__stx_slot_props";while(x.includes(y))y+="_";let M=E.map(([A,P])=>{let O=S[A],R;try{R=O===void 0?void 0:JSON.stringify(O)}catch{}return`${JSON.stringify(A)}:(${R??P})`}).join(","),v=p(JSON.stringify({binding:w,names:x,owner:r}));return`<template :for="${p(`${y} in [{${M}}]`)}" data-stx-slot-binding="${encodeURIComponent(w)}" data-stx-slot-scope="${v}">${m.content}</template>`}return await Cl(m,S,l,i)});let s=/<slot\b((?:"[^"]*"|'[^']*'|[^>"'])*?)\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return e=e.replace(s,(a,u,c)=>{if(/\bname\s*=/.test(u||""))return a;let g=c?.trim()||"";return o.default||g}),e}async function W(t,o,i){let r=[],e=[];t.replace(o,(a,...u)=>{let c=u[u.length-2];return e.push({match:a,index:c}),r.push(i(a,...u.slice(0,-2))),a});let n=await Promise.all(r),s=t;for(let a=e.length-1;a>=0;a--){let{match:u,index:c}=e[a];s=s.slice(0,c)+n[a]+s.slice(c+u.length)}return s}function Ug(t){let o=_l(t);return{defaultSlot:o.default,namedSlots:o.named}}async function Wg(t,o,i,r,e){return await El(t,{default:o,named:i},r,e)}
|
|
3
3
|
export{_l,Vg,Cl,El,Ug,Wg};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Im,Om}from"./chunk-yd5v5pc1.js";import"./chunk-c17sd8hh.js";import"./chunk-4j2t024b.js";import"./chunk-1xjv71dw.js";import"./chunk-7g2f0fqq.js";import"./chunk-phxqwskq.js";import"./chunk-m5nzpjej.js";import"./chunk-zme7xdnw.js";import"./chunk-5bfzvtqp.js";import"./chunk-4c86wr9a.js";import"./chunk-3fwdxxh1.js";import"./chunk-q7fh1xka.js";import"./chunk-2mqzpzy7.js";import"./chunk-jgywz5k0.js";import"./chunk-pmbgny9j.js";import"./chunk-rbmt5w9v.js";import"./chunk-zkx2m308.js";import"./chunk-zn3c0ew5.js";import"./chunk-ez35607j.js";export{Om as clearStoreCache,Im as getStoreScript};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{zg}from"./chunk-
|
|
2
|
+
import{zg}from"./chunk-28nbcn4j.js";import"./chunk-zme7xdnw.js";import"./chunk-5bfzvtqp.js";import"./chunk-4c86wr9a.js";import"./chunk-3fwdxxh1.js";import"./chunk-q7fh1xka.js";import"./chunk-2mqzpzy7.js";import"./chunk-jgywz5k0.js";import"./chunk-pmbgny9j.js";import"./chunk-rbmt5w9v.js";import"./chunk-zkx2m308.js";import"./chunk-zn3c0ew5.js";import"./chunk-ez35607j.js";export{zg as buildApp};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{W,Oe}from"./chunk-
|
|
2
|
+
import{W,Oe}from"./chunk-jgywz5k0.js";var o=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function u(t,e,r){let i={fullTag:r,content:e,attrs:t};if(/\bserver\b/.test(t))return{...i,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...i,type:"client"};if(o.test(e))return{...i,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...i,type:"client"};return{...i,type:"server"}}var S=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function Jt(t){let e=[],r=[],i=[],c=0;while(c<t.length){let s=t.indexOf("<",c);if(s===-1)break;let p=Oe(t,s);if(p>s){c=p;continue}let a=W(t,s);if(a>s){let f=t.slice(s,a),l=S.exec(f);if(l){let n=u(l[1],l[2],f);switch(n.type){case"signals":e.push(n);break;case"client":r.push(n);break;case"server":i.push(n);break}}c=a;continue}c=s+(t.startsWith("<!--",s)?4:1)}return{signals:e,client:r,server:i}}
|
|
3
3
|
export{Jt};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{tf,nf,Te,rf,Ba,Yt,Zt,Gm,Fa,Qt,Jn,sf,of,af,mo,en,cf,tn,lf}from"./chunk-
|
|
2
|
+
import{tf,nf,Te,rf,Ba,Yt,Zt,Gm,Fa,Qt,Jn,sf,of,af,mo,en,cf,tn,lf}from"./chunk-c17sd8hh.js";import"./chunk-4j2t024b.js";import"./chunk-1xjv71dw.js";import"./chunk-zme7xdnw.js";import"./chunk-5bfzvtqp.js";import"./chunk-4c86wr9a.js";import"./chunk-3fwdxxh1.js";import"./chunk-q7fh1xka.js";import"./chunk-2mqzpzy7.js";import"./chunk-jgywz5k0.js";import"./chunk-pmbgny9j.js";import"./chunk-rbmt5w9v.js";import"./chunk-zkx2m308.js";import"./chunk-zn3c0ew5.js";import"./chunk-ez35607j.js";export{Jn as MODULE_SPECIFIER_PREFIX,tf as bundleCacheDir,nf as bundleCacheEntryLimit,tn as bundleClientScript,Zt as clearBundleFailures,Te as clientBundleDependencies,Yt as getBundleFailures,Qt as hasUserImports,en as moduleSubstitutionKey,of as normalizeRegistrySpecifiers,cf as queueClientBundleBuild,Ba as recordBundleFailure,sf as registryIdForPath,Fa as resolveBundlerFallback,af as rewriteRegistryImports,Gm as setBundlerFallbackMode,rf as shouldLogBundlerDiagnostics,lf as tempBuildName,mo as withModuleSubstitutes};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{at,ct,lt}from"./chunk-6ts3sthp.js";import"./chunk-ez35607j.js";import"./chunk-zn3c0ew5.js";import{m}from"./chunk-
|
|
2
|
+
import{at,ct,lt}from"./chunk-6ts3sthp.js";import"./chunk-ez35607j.js";import"./chunk-zn3c0ew5.js";import{m}from"./chunk-jgywz5k0.js";import"./chunk-zkx2m308.js";import"./chunk-rbmt5w9v.js";import"./chunk-pmbgny9j.js";import{zt,Ws,Ht,Ai,it,Pi,qs,Vt,Oi,Ut}from"./chunk-h16qbyjd.js";import M from"fs";import x from"path";function E(t,e){let r=[x.join(t.root,"stx.config.ts"),x.join(t.root,"stx.config.js"),x.join(t.root,"stx.config.mjs")],s=e.debounceMs??300,o=null,a=[];for(let c of r)try{if(!M.existsSync(c))continue;let n=M.watch(c,(d)=>{if(d==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{Pi("Config file changed, restarting...");try{await e.onChange()}catch(p){it(`Failed to restart: ${p}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var nt=".stx/story/analytics.json",st=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,nt),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:st,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:dt(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let d=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),p=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),g=p.length>0?p.reduce((i,l)=>i+l,0)/p.length:0,y=Object.entries(c).sort((i,l)=>l[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:d.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:y,variantViews:n,avgTimeSpent:g}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function dt(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var pt=".stx/story/bookmarks.json",mt=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,pt),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:mt,bookmarks:[]}}}async save(){if(!this.dirty)return;let t=B.dirname(this.storagePath);await S.promises.mkdir(t,{recursive:!0}),await S.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(t,e,r,s={}){let o={id:ut(),name:s.name||`${t}/${e}`,storyId:t,variantId:e,props:r,created:Date.now(),notes:s.notes,color:s.color};return this.storage.bookmarks.push(o),this.dirty=!0,o}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(t){return this.storage.bookmarks.filter((e)=>e.storyId===t)}getBookmark(t){return this.storage.bookmarks.find((e)=>e.id===t)}isBookmarked(t,e){return this.storage.bookmarks.some((r)=>r.storyId===t&&r.variantId===e)}updateBookmark(t,e){let r=this.getBookmark(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deleteBookmark(t){let e=this.storage.bookmarks.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.bookmarks.splice(e,1),this.dirty=!0,!0}toggleBookmark(t,e,r){let s=this.storage.bookmarks.find((a)=>a.storyId===t&&a.variantId===e);if(s)return this.deleteBookmark(s.id),{added:!1};return{added:!0,bookmark:this.addBookmark(t,e,r)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(t,e=!0){let r=JSON.parse(t),s=0;for(let o of r.bookmarks){if(e){let a=this.storage.bookmarks.find((c)=>c.id===o.id);if(a)Object.assign(a,o);else this.storage.bookmarks.push(o)}else this.storage.bookmarks.push(o);s++}if(s>0)this.dirty=!0;return s}}function ut(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var v=new Set;function N(){return{open(t){v.add(t),t.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(t){v.delete(t)},message(t,e){}}}function C(t){let e=JSON.stringify({...t,timestamp:t.timestamp||Date.now()});for(let r of v)try{r.send(e)}catch{v.delete(r)}}function V(t,e){C({type:"story-update",data:{storyId:t,...e}})}function H(t,e){C({type:"story-add",data:{storyId:t,...e}})}function O(t){C({type:"story-remove",data:{storyId:t}})}function F(t){return`
|
|
3
3
|
<script>
|
|
4
4
|
(function() {
|
|
5
5
|
const ws = new WebSocket('${t}');
|
|
@@ -556,7 +556,7 @@ window.__stxPerformance = {
|
|
|
556
556
|
|
|
557
557
|
window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
|
|
558
558
|
</script>
|
|
559
|
-
`}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-
|
|
559
|
+
`}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-fk0qv372.js"),p={},g=h(n);if(g)try{await m(g,p,e)}catch(f){o.push(`Warning: Could not extract script variables: ${f instanceof Error?f.message:String(f)}`)}if(r.props)Object.assign(p,r.props);let i=await d(n,p,e,{},new Set),l=Z(n),u=h(n);return i=Q(i),i=tt(i,p),{html:i,css:l,js:u,errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}async function vt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=h(e);if(!r)return null;let s={};if(await m(r,s,t),Array.isArray(s.variants))return s.variants;return null}catch{return null}}async function Y(t,e,r,s){let o=e.story?.variants;if(!o){let n=await vt(e.path);if(n)o=n}if(!o&&r==="default")return b(t,e.path,{props:s||{}});if(!o)return b(t,e.path,{props:s||{}});let a=o.find((n)=>n.id===r);if(!a&&r==="default")return b(t,e.path,{props:s||{}});if(!a)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${r}' not found`],duration:0};let c={...a.state,...s};if(a.source)return bt(t,a.source,c);return b(t,e.path,{props:c})}async function bt(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-fk0qv372.js"),c={...r},n=h(e);if(n)try{await m(n,c,"inline-template.stx")}catch{}let p=await a(e,c,"inline-template.stx",{},new Set);return p=Q(p),p=tt(p,c),{html:p,css:Z(e),js:h(e),errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}function Z(t){let e=[],r=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
|
|
560
560
|
`)}function Q(t){return t.replace(/<!--[\s\S]*?-->/g,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/^\s*\n/gm,"").trim()}function h(t){let e=[],r=/<script\b[^>]*>([\s\S]*?)<\/script>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
|
|
561
561
|
`)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}async function rt(t,e){let r=await Vt(t);ct(t,r);let s=Ut(t.config,r);lt(t,s),console.log(` Found ${r.length} story files`);let o=typeof e.host==="string"?e.host:e.host===!0?"0.0.0.0":"localhost",a=new I(t.root),c=new P(t.root),n=new k(t.root),d=N(),p=Bun.serve({port:e.port,hostname:o,fetch:async(i,l)=>{let f=new URL(i.url).pathname;if(f==="/__hmr"){if(l.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(f.startsWith("/api/"))return xt(t,f,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return wt(t,f,e.port)},websocket:{open(i){d.open(i)},close(i){d.close(i)},message(i,l){d.message(i,l)}}}),g=`http://${o}:${e.port}`,y=Oi(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let u=await Vt(t);ct(t,u);let f=Ut(t.config,u);if(lt(t,f),i==="add")H(l.id,{fileName:l.fileName});else if(i==="unlink")O(l.id);else V(l.id,{fileName:l.fileName})});if(e.open){let i=g;try{let{exec:l}=await import("child_process"),u=process.platform;l(`${u==="darwin"?"open":u==="win32"?"start":"xdg-open"} ${i}`)}catch{}}return{server:p,url:g,close:async()=>{y(),p.stop()}}}async function xt(t,e,r,s){let{presetsManager:o,bookmarksManager:a,analyticsTracker:c}=s;if(e==="/api/stories")return Response.json({files:t.storyFiles.map((n)=>({id:n.id,fileName:n.fileName,relativePath:n.relativePath,treePath:n.treePath})),tree:t.tree});if(e.startsWith("/api/story/")){let n=e.slice(11),d=t.storyFiles.find((p)=>p.id===n);if(!d)return new Response("Story not found",{status:404});try{let p=await Bun.file(d.path).text();return Response.json({id:d.id,fileName:d.fileName,relativePath:d.relativePath,content:p})}catch{return new Response("Error reading story",{status:500})}}if(e==="/api/config")return Response.json({theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets});if(e.startsWith("/api/render/")){let n=new URL(r.url),d=e.slice(12).split("/"),p=d[0],g=d[1]||"default",y,i=n.searchParams.get("props");if(i)try{y=JSON.parse(i)}catch{}let l=t.storyFiles.find((u)=>u.id===p);if(!l)return new Response("Story not found",{status:404});try{let u=await Y(t,l,g,y);return Response.json({html:u.html,css:u.css,js:u.js,errors:u.errors,duration:u.duration})}catch(u){return Response.json({html:"",css:"",js:"",errors:[u instanceof Error?u.message:String(u)],duration:0},{status:500})}}if(e==="/api/presets"&&r.method==="GET")return Response.json({presets:o.getAllPresets()});if(e==="/api/presets"&&r.method==="POST")try{let n=await r.json(),d=o.createPreset(n.name,n.props,{componentId:n.componentId,description:n.description});return await o.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/presets/")&&!e.includes("/use")&&r.method==="GET"){let n=e.slice(13),d=o.getPreset(n);if(!d)return new Response("Preset not found",{status:404});return Response.json(d)}if(e.endsWith("/use")&&r.method==="POST"){let n=e.slice(13,-4),d=o.usePreset(n);if(!d)return new Response("Preset not found",{status:404});return await o.save(),Response.json(d)}if(e.startsWith("/api/presets/")&&r.method==="DELETE"){let n=e.slice(13);if(!o.deletePreset(n))return new Response("Preset not found",{status:404});return await o.save(),Response.json({success:!0})}if(e==="/api/bookmarks"&&r.method==="GET")return Response.json({bookmarks:a.getAllBookmarks()});if(e==="/api/bookmarks"&&r.method==="POST")try{let n=await r.json(),d=a.addBookmark(n.storyId,n.variantId,n.props,{name:n.name,notes:n.notes,color:n.color});return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/bookmarks/toggle"&&r.method==="POST")try{let n=await r.json(),d=a.toggleBookmark(n.storyId,n.variantId,n.props);return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/bookmarks/")&&e!=="/api/bookmarks/toggle"&&r.method==="GET"){let n=e.slice(15),d=a.getBookmark(n);if(!d)return new Response("Bookmark not found",{status:404});return Response.json(d)}if(e.startsWith("/api/bookmarks/")&&r.method==="DELETE"){let n=e.slice(15);if(!a.deleteBookmark(n))return new Response("Bookmark not found",{status:404});return await a.save(),Response.json({success:!0})}if(e==="/api/analytics/track"&&r.method==="POST")try{let n=await r.json();if(n.type==="view"&&n.componentId)c.trackView(n.componentId,n.variantId);else if(n.type==="prop_change"&&n.componentId&&n.propName)c.trackPropChange(n.componentId,n.propName,null);else if(n.type==="variant_switch"&&n.componentId&&n.variantId)c.trackVariantSwitch(n.componentId,n.variantId);else if(n.type==="search"&&n.query)c.trackSearch(n.query,0);return await c.save(),Response.json({success:!0})}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/analytics/summary"&&r.method==="GET")return Response.json({mostViewed:c.getMostViewedComponents(10),mostChangedProps:c.getMostChangedProps(10),searchAnalytics:c.getSearchAnalytics()});if(e.startsWith("/api/analytics/component/")&&r.method==="GET"){let n=e.slice(25),d=t.storyFiles.find((g)=>g.id===n),p=c.getComponentAnalytics(n,d?.fileName||n);return Response.json(p)}return new Response("Not found",{status:404})}function wt(t,e,r){let s=kt(t,r);return new Response(s,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function kt(t,e){let{theme:r}=t.config,s=r.title||"STX Story",o=`ws://localhost:${e}/__hmr`,a=F(o);return`<!DOCTYPE html>
|
|
562
562
|
<html lang="en" class="${r.darkClass||"dark"}">
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{gn,Nf,Df,Mf,Lf,jf,m,Bf,ei,Ff,Rc,Ac}from"./chunk-
|
|
2
|
+
import{gn,Nf,Df,Mf,Lf,jf,m,Bf,ei,Ff,Rc,Ac}from"./chunk-jgywz5k0.js";import"./chunk-pmbgny9j.js";import"./chunk-rbmt5w9v.js";import"./chunk-zkx2m308.js";import"./chunk-zn3c0ew5.js";import"./chunk-ez35607j.js";export{gn as STX_ENGINE_BINDING_NAMES,ei as convertToCommonJS,Rc as extractScriptFromTemplate,m as extractVariables,Ac as hasVariables,Bf as isCompleteImport,jf as isMissingBindingFailure,Mf as isModuleResolutionFailure,Lf as isSyntaxFailure,Ff as splitDeclaration,Nf as stripTypeScript,Df as withoutStxReferrer};
|